tdem-web-sdk 1.0.12 → 1.0.14

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.
Files changed (35) hide show
  1. package/README.md +21 -0
  2. package/lib/packages/core/src/http/request-finalizer.d.ts +25 -0
  3. package/lib/packages/core/src/index.d.ts +6 -2
  4. package/lib/packages/core/src/interface/config.d.ts +1 -0
  5. package/lib/packages/core/src/interface/env.d.ts +1 -0
  6. package/lib/packages/core/src/interface/event.d.ts +27 -2
  7. package/lib/packages/core/src/interface/index.d.ts +1 -1
  8. package/lib/packages/core/src/pipes/tdem-sample-gate.d.ts +3 -2
  9. package/lib/packages/core/src/sample/evaluate.d.ts +5 -1
  10. package/lib/packages/core/src/sample/eventTypes.d.ts +16 -2
  11. package/lib/packages/core/src/sample/types.d.ts +1 -0
  12. package/lib/packages/core/src/util/event-session.d.ts +5 -0
  13. package/lib/packages/core/src/util/index.d.ts +5 -0
  14. package/lib/packages/web-sdk/src/index.core.d.ts +6 -0
  15. package/lib/packages/web-sdk/src/index.d.ts +2 -0
  16. package/lib/packages/web-sdk/src/interface/core.d.ts +9 -0
  17. package/lib/packages/web-sdk/src/interface/index.d.ts +6 -2
  18. package/lib/packages/web-sdk/src/plugins/cgi-speed/dial-observation.d.ts +44 -0
  19. package/lib/packages/web-sdk/src/plugins/cgi-speed/sse-observer.d.ts +2 -0
  20. package/lib/packages/web-sdk/src/plugins/{session-replay → click-detection}/click-detector.d.ts +10 -7
  21. package/lib/packages/web-sdk/src/plugins/session-replay/index.d.ts +1 -1
  22. package/lib/packages/web-sdk/src/plugins/session-replay/logger.d.ts +4 -33
  23. package/lib/packages/web-sdk/src/plugins/session-replay/types.d.ts +1 -1
  24. package/lib/packages/web-sdk/src/plugins/struggle-monitor.d.ts +4 -0
  25. package/lib/packages/web-sdk/src/tdem.d.ts +11 -0
  26. package/lib/packages/web-sdk/src/util/click-target.d.ts +5 -0
  27. package/lib/packages/web-sdk/src/util/entry-registry.d.ts +28 -0
  28. package/lib/packages/web-sdk/src/util/logger.d.ts +35 -0
  29. package/lib/tdem.core.global.min.js +10 -0
  30. package/lib/tdem.core.min.js +10 -0
  31. package/lib/tdem.f.min.js +3 -3
  32. package/lib/tdem.global.min.js +3 -3
  33. package/lib/tdem.ie.min.js +3 -3
  34. package/lib/tdem.min.js +3 -3
  35. package/package.json +17 -1
@@ -0,0 +1,10 @@
1
+ /**
2
+ * ===========================================================================
3
+ * tdem-web-sdk (core)@1.0.14 (c) 2026 TencentCloud Real User Monitoring.
4
+ * Author pumpkincai.
5
+ * Last Release Time Thu Nov 19 2026 16:45:19 GMT+0800 (China Standard Time).
6
+ * Released under the MIT License.
7
+ * Thanks for supporting TDEM!
8
+ * ===========================================================================
9
+ **/
10
+ var TDEMCore=(R=>{var F=function(e,t){return(F=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}))(e,t)};function U(e,t){function n(){this.constructor=e}F(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var q,H,O=function(){return(O=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function j(e,a,s,l){return new(s=s||Promise)(function(n,t){function r(e){try{i(l.next(e))}catch(e){t(e)}}function o(e){try{i(l.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?n(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(r,o)}i((l=l.apply(e,a||[])).next())})}function W(r,o){var i,a,s,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(n){return function(e){var t=[n,e];if(i)throw new TypeError("Generator is already executing.");for(;l;)try{if(i=1,a&&(s=2&t[0]?a.return:t[0]?a.throw||((s=a.return)&&s.call(a),0):a.next)&&!(s=s.call(a,t[1])).done)return s;switch(a=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return l.label++,{value:t[1],done:!1};case 5:l.label++,a=t[1],t=[0];continue;case 7:t=l.ops.pop(),l.trys.pop();continue;default:if(!((s=0<(s=l.trys).length&&s[s.length-1])||6!==t[0]&&2!==t[0])){l=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3]))l.label=t[1];else if(6===t[0]&&l.label<s[1])l.label=s[1],s=t;else{if(!(s&&l.label<s[2])){s[2]&&l.ops.pop(),l.trys.pop();continue}l.label=s[2],l.ops.push(t)}}t=o.call(r,l)}catch(e){t=[6,e],a=0}finally{i=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function h(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)r[o]=i[a];return r}function B(e){this.name="__st"+(1e9*Math.random()>>>0)+q+"__",null!=e&&e.forEach(this.add,this),q+=1}function V(e,t){return void 0===t&&(t="https://dem.rumt-zh.com"),t=(e.url||"").replace(/\/+$/,"")||("string"==typeof t?t:"https://dem.rumt-zh.com"),e.url=t,e.hostUrl=t,e.offlineUrl=t+"/offline",e.whiteListUrl=t+"/collect/whitelist",e.pvUrl=t+"/collect/pv",e.eventUrl=t+"/collect/events",e.speedUrl=t+"/speed",e.customTimeUrl=t+"/speed/custom",e.performanceUrl=t+"/speed/performance",e.performanceUrlForHippy=t+"/speed/hippyPerformance",e.webVitalsUrl=t+"/speed/webvitals",e.setDataReportUrl=t+"/speed/miniProgramData",e}function z(e){try{return localStorage.getItem(e)}catch(e){return null}}function G(e,t){try{localStorage.setItem(e,t)}catch(e){}}function K(e,t){try{return e?JSON.parse(e):t}catch(e){return t}}Array.prototype.find||Object.defineProperty(Array.prototype,"find",{configurable:!0,writable:!0,value:function(e){if(null===this)throw new TypeError('"this" is null or not defined');var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var r=arguments[1],o=0;o<n;){var i=t[o];if(e.call(r,i,o,t))return i;o+=1}}}),window.WeakSet||(q=Date.now()%1e9,B.prototype.add=function(e){var t=this.name;return e[t]||Object.defineProperty(e,t,{value:!0,writable:!0}),this},B.prototype.delete=function(e){return!!e[this.name]&&!(e[this.name]=void 0)},B.prototype.has=function(e){return!!e[this.name]},H=B,Object.defineProperty(window,"WeakSet",{value:function(e){return new H(e)}})),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++)if(null!=(r=arguments[n]))for(var r=Object(r),o=Object.keys(Object(r)),i=0,a=o.length;i<a;i++){var s=o[i],l=Object.getOwnPropertyDescriptor(r,s);null!=l&&l.enumerable&&(t[s]=r[s])}return t}});var J,$=/_?t(\d)?(imestamp)?=\d+&?/g,X=["aegis.qq.com","tamaegis.com","/aegis-sdk","rumt-","/flog.core.min.js","pingfore.qq.com","pingfore.tencent.com","zhiyan.tencent-cloud.net","h.trace.qq.com","btrace.qq.com","beacon.qq.com","dmplog.qq.com","qq.com/report","svibeacon.onezapp.com","cube.weixinbridge.com","doubleclick.net","pcmgrmonitor.3g.qq.com","tdm.qq.com","report.qqweb.qq.com","tpstelemetry.tencent.com","galileotelemetry.tencent.com","insight.cloud.tencent.com","facebook.com","facebook.net","google","yahoo.com","twitter.com","ga-audiences","report.idqqimg.com","arms-retcode.aliyuncs.com","px.effirst.com","sentry","baidu.com","hot-update.json","u.c.b.r.o.w.s.e.r","report.url.cn","sockjs-node","m3u8","flv"],Y=["ResizeObserver loop limit exceeded","ResizeObserver loop completed","Failed to execute 'transaction'","window.indexedDB.deleteDatabase is not a function"],Q=["ext1","ext2","ext3","ext4","ext5","ext6","ext7","ext8","ext9","ext10","level","trace","tag","seq","code"],Z=["static","fetch"],I="unknown",ee=(te.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},te.prototype.on=function(e,t,n){var r;if(void 0===n&&(n=0),this)return(r=this.eventsList[e])||(this.eventsList[e]=[],r=this.eventsList[e]),-1===this.indexOf(r,t)&&r.push({name:e,type:n||0,callback:t}),this},te.prototype.one=function(e,t){this.on(e,t,1)},te.prototype.remove=function(e,t){if(this){var n=this.eventsList[e];if(n){if(t)return n.length&&(t=this.indexOf(n,t),n.splice(t,1)),this;try{delete this.eventsList[e]}catch(e){}}return null}},te.prototype.clear=function(){this.eventsList={}},te);function te(){var a=this;this.emit=function(e,t){if(a){var n;if(null!=(r=a.eventsList[e])&&r.length)for(var r=r.slice(),o=0;o<r.length;o++){n=r[o];try{var i=n.callback.apply(a,[t]);if(1===n.type&&a.remove(e,n.callback),!1===i)break}catch(e){throw e}}return a}},this.eventsList={}}function ne(e){if(null!=e){e=String(e).trim();if(e){var t=e.toLowerCase();if(t!==I&&"undefined"!==t&&"null"!==t&&"未知"!==e)return e}}}function re(e){return e&&"string"==typeof e?e.replace(/evaluate_script/g,"\0tdem_script_metric\0").replace(/eval/gi,"evaI").replace(/\u0000tdem_script_metric\u0000/g,"evaluate_script"):e}function oe(e,t){return"number"==typeof e||"string"==typeof e?e:t?J.string:J.number}function ie(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function ae(e,t){return void 0===t&&(t=2048),String(e).replace($,"").slice(0,t)}function se(e){return"string"==typeof e&&/^\//.test(e)?"https:"===(null==location?void 0:location.protocol):/^https/.test(e)}function le(e,t,n){var r,o,i;try{if("function"==typeof(null==t?void 0:t.retCodeHandler))return{code:void 0===(i=(o=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx,null==n?void 0:n.payload)||{}).code)?I:i,isErr:o.isErr};if(!(e="string"==typeof e?JSON.parse(e):e))return{code:I,isErr:!1};"function"==typeof(null==(r=null==t?void 0:t.ret)?void 0:r.join)&&(me=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var a=Object.getOwnPropertyNames(e).filter(function(e){return-1!==me.indexOf(e.toLowerCase())});return a.length?{code:""+(i="未知"!==(i=e[a[0]])&&""!==i?i:I),isErr:0!==i&&"0"!==i&&i!==I}:{code:I,isErr:!1}}catch(e){return{code:I,isErr:!1}}}function ce(e,t,n){try{var r="function"==typeof t?t(e,null==n?void 0:n.url,null==n?void 0:n.ctx)||"":e;return he(r).slice(0,10240)}catch(e){return""}}function ue(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,ge(),2)||"undefined").replace(/"/gim,""):JSON.stringify(e,ge(),2)||"undefined"}catch(e){return"error happen when tdem stringify: \n "+e.message+" \n "+e.stack}}function de(e,t){var n,r={fetch:[],static:[],bridge:[]},o=new FormData;return Array.isArray(e)?e.forEach(function(e){var t=we(e);r[e.type].push(t)}):(n=we(e),r[e.type].push(n)),o.append("payload",ve(O({duration:r},t))),o}function m(t,e){return"string"!=typeof t||!t||e&&-1<t.indexOf(e)||be.test(t)||X.some(function(e){return-1<t.indexOf(e)})}(n=J=J||{})[n.number=-1]="number",n.string="";var v,pe=["application/xhtml+xml","application/xml","application/pdf","application/pkcs12","application/javascript","application/x-javascript","application/ecmascript","application/vnd.mspowerpoint","application/vnd.apple.mpegurl","application/ogg","text/css","text/javascript","image","audio","video","video/mp2t"],fe=/\.(json|js|css|jpg|jpeg|png|svg|apng|webp|gif|bmp|mp4|mp3|ts|mpeg|wav|webm|ogg|flv|m3u8|ttf|woff2|otf|eot|woff|html|htm|shtml|shtm|)$/i,me=["ret","retcode","code","errcode"],ge=function(){var n=new WeakSet;return function(e,t){if(t instanceof Error)return"Error.message: "+t.message+" \n Error.stack: "+t.stack;if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular "+(e||"root")+"]";n.add(t)}return t}},ve=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e,ge())||"undefined"}catch(e){return"error happen when tdem stringify: \n "+e.message+" \n "+e.stack}},he=function(n,r){void 0===r&&(r=3);var o,i,a,s="";return Array.isArray(n)?(s+="[",o=n.length,n.forEach(function(e,t){s=(s+="object"==typeof e&&1<r?he(e,r-1):_e(e))+(t===o-1?"":",")}),s+="]"):n instanceof Object||"object"==typeof n?(s="{",i=Object.keys(n),a=i.length,i.forEach(function(e,t){"object"==typeof n[e]&&1<r?s+='"'+e+'":'+he(n[e],r-1):s+=ye(e,n[e]),s+=t===a-1||t<a-1&&void 0===n[i[t+1]]?"":","}),s+="}"):s+=n,s},ye=function(e,t){var n=typeof t,r="";return"string"==n||"object"==n?r+='"'+e+'":"'+t+'"':"function"==typeof t?r+='"'+e+'":"function '+t.name+'"':"symbol"==typeof t?r+='"'+e+'":"symbol"':"number"!=typeof t&&"boolean"!=n||(r+='"'+e+'": '+t),r},_e=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},we=function(t){var n;return t.payload?(n={},Object.keys(t).forEach(function(e){"payload"!==e&&(n[e]=t[e])}),n):t},be=/data:(image|text|application|font)\/.*;base64/;(n=v=v||{}).LOG="log",n.SPEED="speed",n.PERFORMANCE="performance",n.OFFLINE="offline",n.WHITE_LIST="whiteList",n.VITALS="vitals",n.PV="pv",n.CUSTOM_PV="customPV",n.EVENT="event",n.CUSTOM="custom",n.SDK_ERROR="sdkError",n.SET_DATA="setData",n.LOAD_PACKAGE="loadPackage",n.MEMORY="memory";var t,P,M,Ee={maxAttempts:3,delays:[0,1e3,3e3]};function Se(e){return null==e?t.production:(e=>{switch(e){case t.production:case t.development:case t.gray:case t.pre:case t.daily:case t.local:case t.test:case t.others:return!0;default:return!1}})(e)?e:t.others}function A(){return"evt_"+Date.now()+"_"+Math.random().toString(36).substring(2,8)}function Te(e){var t=[];if(e.stack)for(var n=0,r=0,o=e.stack.split("\n");r<o.length;r++){var i,a,s,l,c,u=o[r],d=u.match(/at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)/);d?(a=d[1],i=d[2],s=d[3],l=d[4],c=i.split("/").pop()||i,t.push({abs_path:i,colno:parseInt(l,10),filename:c,function:a||"(anonymous)",lineno:parseInt(s,10),in_app:i.includes("node_modules")||i.includes("cdn")?0:1,stack_level:n++})):(d=u.match(/at\s+(.+?):(\d+):(\d+)/))&&(a=d[1],s=d[2],l=d[3],c=a.split("/").pop()||a,t.push({abs_path:a,colno:parseInt(l,10),filename:c,function:"(anonymous)",lineno:parseInt(s,10),in_app:a.includes("node_modules")||a.includes("cdn")?0:1,stack_level:n++}))}return t}function ke(d,l){return function(o,i){var a,s,e,t,n;null!=o&&o.log&&null!=o&&o.type?(a=function(e,t,n,r){switch(t){case v.LOG:i=e;var o=(Array.isArray(i)?i:[i]).map(function(n){return Object.getOwnPropertyNames(n).reduce(function(e,t){return"ctx"!==t&&(e[t]=n[t]),e},{level:"2",msg:""})});if(!o||0===o.length)return"{}";o=Array.isArray(o)?o:[o];var i=Array.from(new Set(o.flatMap(function(e){return Object.keys(e)}))),a={};return i.forEach(function(t){a[t]=o.map(function(e){return e[t]||""})}),a.count=o.length,ve(a);case v.SPEED:return i=e,s=n,s=O(O({},d.bean),{from:s}),u=O({},d.bean),(()=>{try{return"undefined"!=typeof FormData&&"function"==typeof FormData.prototype.append}catch(e){}})()?de(i,s):(s=i,i=u,c={fetch:[],static:[],bridge:[]},u={},Array.isArray(s)?s.forEach(function(e){var t;null!=(t=c[e.type])&&t.push(e)}):null!=(l=c[s.type])&&l.push(s),u.payload=JSON.stringify(O({duration:c},i)),u);case v.EVENT:return r;default:return r||{}}var s,l,c,u,i},1!==(e=Array.isArray(o.log)?o.log:[o.log]).length?(s={},e.forEach(function(e){var t=e.from||"undefined";delete e.from,s[t]||(s[t]=[]),s[t].push(e)}),Object.keys(s).forEach(function(e){var t,n=s[e],r=null!=(r=o.url)&&r.includes("?")?"&":"?";"undefined"===e?(t=""+o.url,i(O(O({},o),{url:t,log:1===n.length?n[0]:n,data:a(n,l,e,o.data)}))):(t=o.url+r+"from="+e,i(O(O({},o),{url:t,log:1===n.length?n[0]:n,beanFilter:h(o.beanFilter||[],["from"]),data:a(n,l,e,o.data)})))})):(t=(e=e[0]).from,delete e.from,n=null!=(n=o.url)&&n.includes("?")?"&":"?",t?(n=o.url+n+"from="+t,i(O(O({},o),{url:n,log:e,beanFilter:h(o.beanFilter||[],["from"]),data:a(e,l,t,o.data)}))):(n=""+o.url,i(O(O({},o),{url:n,log:e,data:a(e,l,t,o.data)}))))):i(o)}}function Ce(l,c){return function(e,t){var n,r,o,i=Array.isArray(e),a=i?e:[e],s=(l.lifeCycle.emit("beforeRequest",e),l.config.beforeRequest);(a="function"==typeof s?a.map(function(t){try{var e=s({logs:t,logType:c});return(null==e?void 0:e.logType)===c&&null!=e&&e.logs?e.logs:!1!==e&&t}catch(e){return t}}).filter(function(e){return!1!==e}):a).length&&(n=a,e=Q,!Array.isArray(n)||n.length<=1||(r=[],o=[],!(o="string"==typeof e?[e]:e))||o.length<=0||(o.forEach(function(t){n.forEach(function(e){null!=e&&e[t]&&r.push(t)})}),0<r.length&&(n=n.map(function(e){var t={};return r.forEach(function(e){t[e]=""}),O(O({},t),e)}))),a=n,t(i?a:a[0]))}}function Re(o){return function(e,t){o.lifeCycle.emit("modifyRequest",e);var n=o.config.modifyRequest;if("function"==typeof n)try{var r=n(e);"object"==typeof r&&"url"in r&&(e=r)}catch(e){console.error(e)}t(e)}}function Ie(r){return function(e,t){null!=(n=r.lifeCycle)&&n.emit("afterRequest",e);var n=(r.config||{}).afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}(n=t=t||{}).production="production",n.development="development",n.gray="gray",n.pre="pre",n.daily="daily",n.local="local",n.test="test",n.others="others",(n=P=P||{}).JS_ERROR="js_error",n.PROMISE_ERROR="promise_error",n.RESOURCE_ERROR="resource_error",n.API_ERROR="api_error",n.BLANK_SCREEN="blank_screen",n.PAGE_LOAD="page_load",n.RESOURCE_LOAD="resource_load",n.API_CALL="api_call",n.SSE_CALL="sse_call",n.true="web_vitals",n.LAG_DETECTED="lag_detected",n.NO_RESPONSE="no_response",n.MEMORY_USAGE="memory_usage",n.APP_METRICS="app_metrics",n.PROCESS_SIGNAL="process_signal",n.MEMORY_OOM="memory_oom",n.FILE_IO="file_io",n.CLICK="click",n.SCROLL="scroll",n.LONG_PRESS="long_press",n.PAGE_VIEW="page_view",n.TAB_HIDDEN="tab_hidden",n.TAB_VISIBLE="tab_visible",n.WINDOW_BLUR="window_blur",n.WINDOW_FOCUS="window_focus",n.FORM_FOCUS="form_focus",n.FORM_BLUR="form_blur",n.FORM_CHANGE="form_change",n.FORM_SUBMIT="form_submit",n.FORM_SUBMIT_RESULT="form_submit_result",n.STRUGGLE="struggle",n.CUSTOM="custom",n.LOG="log",n.DIAL_PROBE="dial_probe",n.DIAL_MTR="dial_mtr",(n=M=M||{}).ERROR="error",n.PERFORMANCE="performance",n.BEHAVIOR="behavior",n.NETWORK="network",n.LOG="log",n.CUSTOM="custom";var Oe=function(e){return e.filter(function(n,r){return"static"!==n.type||!e.find(function(e,t){return n.url===e.url&&200===n.status&&r<t})})},Pe={},Me={},Ae=function(e){return Pe[e]||(Pe[e]=setTimeout(function(){Me[e]={},Pe[e]=null},6e4)),Pe[e]},xe={generateTraceId:Ne(16),generateSpanId:Ne(8)},De=Array(32);function Ne(t){return function(){for(var e=0;e<2*t;e++)De[e]=Math.floor(16*Math.random())+48,58<=De[e]&&(De[e]+=39);return String.fromCharCode.apply(null,De.slice(0,2*t))}}function Le(){return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,function(e){return(e^(16*Math.random()&15)>>e/4).toString(16)})}function Fe(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function Ue(e){for(var t,n,r,o="",i=0,a=(e=String(e)).length%3;i<e.length;){if(255<(t=e.charCodeAt(i++))||255<(n=e.charCodeAt(i++))||255<(r=e.charCodeAt(i++)))throw new TypeError("Failed to execute 'btoa': The string to be encoded contains characters outside of the Latin1 range.");o+=s.charAt((t=t<<16|n<<8|r)>>18&63)+s.charAt(t>>12&63)+s.charAt(t>>6&63)+s.charAt(63&t)}return a?o.slice(0,a-3)+"===".substring(a):o}function qe(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!je.test(e))throw new TypeError("Failed to execute 'atob': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var n,r,o="",i=0;i<e.length;)t=s.indexOf(e.charAt(i++))<<18|s.indexOf(e.charAt(i++))<<12|(n=s.indexOf(e.charAt(i++)))<<6|(r=s.indexOf(e.charAt(i++))),o+=64===n?String.fromCharCode(t>>16&255):64===r?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return o}function He(e){var t,n="";return n="object"==typeof e&&(t=(e=((e,t)=>{for(var n=0;n<t.length;n++){var r=t[n],o=e[r]||"function"==typeof e.get&&e.get(r);if(o)return[r,o]}return["",""]})(e,Object.keys(Be)))[0])?Be[t](e[1]):n}var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",je=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,We=(e.prototype.generate=function(e,t,n){if(void 0===t&&(t={}),this.url=e,!this.isUrlIgnored()&&this.isUrlInTraceUrls()&&this.traceType){switch(this.traceType){case"traceparent":this.traceId=this.createTraceparent();break;case"b3":this.traceId=this.createB3();break;case"sw8":this.traceId=this.createSw8(n);break;case"sentry-trace":this.traceId=this.createSentryTrace();break;default:return console.warn("this trace key "+this.traceType+" is not supported"),void(this.traceId="")}return t[this.traceType]&&(this.traceId=t[this.traceType]),{name:this.traceType,value:this.traceId}}},e.prototype.createTraceparent=function(){var e=xe.generateSpanId();return"00-"+xe.generateTraceId()+"-"+e+"-0"+this.traceFlag.toString(16)},e.prototype.createB3=function(){var e=xe.generateSpanId();return xe.generateTraceId()+"-"+e+"-"+this.traceFlag},e.prototype.createSw8=function(e){var t="function"==typeof btoa?btoa:Ue,e=e||{},n=e.host,n=void 0===n?"":n,e=e.pathname,e=void 0===e?"":e,r=Fe(),o=Fe();return"1-"+String(t(o))+"-"+String(t(r))+"-1-"+String(t("tdem"))+"-"+String(t("1.0.14"))+"-"+String(t(encodeURI(e)))+"-"+String(t(n))},e.prototype.createSentryTrace=function(){var e=Le().substring(16);return Le()+"-"+e+"-"+this.traceFlag},e.prototype.isUrlIgnored=function(){if(Array.isArray(this.ignoreUrls)&&0!==this.ignoreUrls.length)for(var e=0,t=this.ignoreUrls;e<t.length;e++){var n=t[e];if(this.urlMatches(this.url,n))return!0}return!1},e.prototype.isUrlInTraceUrls=function(){if(!this.urls)return!0;if(Array.isArray(this.urls)){if(0===this.urls.length)return!1;for(var e=0,t=this.urls;e<t.length;e++){var n=t[e];if(this.urlMatches(this.url,n))return!0}}return!1},e.prototype.urlMatches=function(e,t){return"string"==typeof t?e===t:!!e.match(t)},e),Be={sw8:function(e){var t="function"==typeof atob?atob:qe,e=e.split("-")[1];return e?t(e):""},traceparent:function(e){return e.split("-")[1]},b3:function(e){return e.split("-")[0]},"sentry-trace":function(e){return e.split("-")[0]}},Ve=new WeakMap;function e(e,t,n,r){void 0===n&&(n=null),this.traceType=e,this.ignoreUrls=t,this.urls=n,this.traceFlag=null==r?1:Number(!!r)}function ze(e){var t,n;return String((null==(t=null==(t=null==(n=e.sessionManager)?void 0:n.getSession)?void 0:t.call(n))?void 0:t.id)||(null==(n=e.bean)?void 0:n.sessionId)||"")}function Ge(e,t){Ve.set(e,t)}function Ke(e){return Ve.get(e)}function Je(i){return function(e){e&&0!==e.length&&i.sendPipeline([function(e,r){var o=new Map;e.forEach(function(e){var t=null!=(t=Ke(e))?t:ze(i),n=o.get(t)||[];n.push(e),o.set(t,n)}),o.forEach(function(t,e){var e={protocol_version:2,project_key:String(i.config.id||""),sdk:{name:i.sdkName,version:i.sdkVersion},app:{version:String(i.config.version||"1.0.0")},context:O(O({},(e=>{var t=ze(e),n=String(e.config.userId||e.config.uin||""),t={session_id:t,platform:(t=String(e.runtimePlatform||e.config.platform||"web").trim().toLowerCase(),["web","wx-miniprogram","uniapp","android","ios","electron","unknown"].includes(t)?t:"wx"===t?"wx-miniprogram":"my"!==t&&"qq"!==t&&"tt"!==t&&"undefined"!=typeof window?"web":"unknown")},n=(n&&(t.user_id=n),(n=String(e.bean.aid||"").trim())&&"true"!==n&&(t.device_id=n),e.bean.runtime?String(e.bean.runtime):""),r=e.bean.processType?String(e.bean.processType):"",o=void 0!==e.bean.windowId?String(e.bean.windowId):"",i=void 0!==e.bean.webContentsId?String(e.bean.webContentsId):"",e=e.bean.appVersion?String(e.bean.appVersion):"";return n&&(t.runtime=n),r&&(t.process_type=r),o&&(t.window_id=o),i&&(t.web_contents_id=i),e&&(t.app_version=e),"undefined"!=typeof navigator&&(t.user_agent=navigator.userAgent,t.language=navigator.language),"undefined"!=typeof screen&&(t.screen_resolution=screen.width+"x"+screen.height),t})(i)),{session_id:e}),events:t},n=String(i.config.url||"").replace(/\/+$/,"");n&&r({url:n+"/api/v1/collect/events",data:JSON.stringify(e),method:"POST",contentType:"application/json",addBean:!1,type:v.EVENT,log:t,success:function(){i.lifeCycle.emit("afterReport",{success:!0,events:t})},fail:function(e){i.lifeCycle.emit("afterReport",{success:!1,error:e,events:t})}})})}],v.EVENT)(e)}}var $e=new Set(Object.values({error:["js_error","promise_error","resource_error","api_error","blank_screen","no_response"],performance:["page_load","web_vitals","lag_detected","memory_usage","memory_oom"],network:["resource_load","api_call","sse_call"],custom:["custom"]}).flat());function Xe(e){new Set(Object.values(e).flat())}Xe({error:["js_error","promise_error","resource_error","api_error"],performance:["page_load"],network:["resource_load","api_call"],custom:["custom"]}),Xe({error:["crash","api_error"],performance:["app_launch","lag_detected"],network:["api_call","sse_call"],custom:["custom"]}),Xe({error:["crash","api_error","no_response"],performance:["app_launch","lag_detected"],network:["api_call","sse_call"],custom:["custom"]}),Xe({error:["js_error","promise_error","resource_error","api_error","blank_screen","crash"],performance:["page_load","web_vitals","lag_detected","no_response","app_metrics","process_signal","file_io"],network:["resource_load","api_call","sse_call"],custom:["custom"]});var Ye={event:{enabled:!0,types:{}},replay:{enabled:!1,experience_sample_rate:0,error_traceback:!1,error_sample_rate:100}};function i(e){return null==e?"":String(e)}function Qe(r,e,o){return e.enabled&&e.conditions&&0!==e.conditions.length&&e.conditions.every(function(e){var t=e,e=((e,t,n)=>{if(t.startsWith("tags."))return o=t.slice("tags.".length),e.tags&&o in e.tags?e.tags[o]:void 0;if(t.startsWith("event_properties."))return o=t.slice("event_properties.".length),e.event_properties&&o in e.event_properties?e.event_properties[o]:void 0;if("page_path"===t){if(!n)return t in(o=e)&&null!=o[t]?o[t]:void 0;if(!e.page_url)return;try{return new URL(e.page_url).pathname}catch(e){return}}if("page_url"!==t)return t in(n=e)&&null!=n[t]?n[t]:void 0;var r=e.page_url;if(null!=r){var o=String(r);if(o)try{return decodeURIComponent(o)}catch(r){return o}}})(r,t.field,o);if(void 0===e)return!1;var n=i(e);switch(t.operator){case"equals":return n===i(t.value);case"not_equals":return n!==i(t.value);case"contains":return n.includes(i(t.value));case"not_contains":return!n.includes(i(t.value));case"starts_with":return n.startsWith(i(t.value));case"ends_with":return n.endsWith(i(t.value));case"in":return(Array.isArray(t.value)?t.value.map(i):[]).includes(n);case"not_in":return!(Array.isArray(t.value)?t.value.map(i):[]).includes(n);default:return!1}})}function Ze(e,t,n,r){var o,i,a,s;void 0===t&&(t=Ye),void 0===n&&(n=Math.random),void 0===r&&(r={});try{if(null==(o=null==t?void 0:t.event)||!o.enabled)return!1;for(var l=null!=(i=r.closedSet)?i:$e,c=!1!==r.derivePagePath,u=(a=t,s=e.event_type,l.has(s)&&(null==(a=null==(a=a.event)?void 0:a.types)?void 0:a[s])||{sample_rate:100,rules:[]}),d=u.sample_rate,p=0,f=u.rules||[];p<f.length;p++){var m=f[p];if(m.enabled&&Qe(e,m,c)){d=m.sample_rate;break}}return 100<=d||!(d<=0)&&100*n()<d}catch(e){return!0}}function et(e){e=null==(e=e)?void 0:e._tdemSampleGate;return!!e&&e.isDecided&&e.isSampled}function tt(e,t){var n=e.data||{},r=t.bean||{};return{event_type:String(e.event_type||""),event_category:e.event_category,event_name:e.event_name||n.event_name,page_url:e.page_url,user_id:r.user_id||t.config.userId,device_id:r.device_id||t.config.aid,env:t.config.env,version:String(null!=(t=null!=(t=t.config.version)?t:r.app_version)?t:""),tags:n.tags||e.tags,event_properties:n.event_properties||n.properties||n}}function nt(e){return e._tdemSampleConfig||null}function rt(e){return e._tdemSampleEvaluateOptions||{}}function ot(n){if(n&&n.reduce&&n.length)return 1===n.length?function(e,t){n[0](e,t||ct)}:n.reduce(function(n,r){return function(e,t){return void 0===t&&(t=ct),n(e,function(e){return null==r?void 0:r(e,t)})}});throw new TypeError("createPipeline need at least one function param")}function it(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]="sendPipeline"===e?function(){return function(){}}:function(){}:t[e]=function(){})})}function at(n){var r={};return n&&"object"==typeof n&&gt.forEach(function(e){var t=n[e];"string"==typeof t&&""!==t&&(r[e]=t)}),r}function st(){return void 0!==window.performance&&"function"==typeof performance.getEntriesByType&&"function"==typeof performance.now}function lt(e){var t;return-1<(null==(t=null==(t=window.PerformanceObserver)?void 0:t.supportedEntryTypes)?void 0:t.indexOf(e))}var ct=function(){},ut={low:1,medium:3,high:5},dt=new Set(["custom_struggle_name","form_id","field_id","trigger_event_id","struggle_status","struggle_owner_type","struggle_owner_key","detection_source","rule_version"]),pt={rage_click:3,dead_click:4,error_click:4,form_validation_error:3,slow_page:3,back_forward:2,long_focus_time:2,form_zigzag:2,uncompleted_form:3,custom_struggle:3},ft={rage_click:4,dead_click:5,error_click:5,form_validation_error:4,slow_page:4,back_forward:3,long_focus_time:3,form_zigzag:3,uncompleted_form:3,custom_struggle:3},mt=(y.use=function(e){-1===y.installedPlugins.indexOf(e)&&e.tdemPlugin&&y.installedPlugins.push(e)},y.unuse=function(e){e=y.installedPlugins.indexOf(e);-1!==e&&y.installedPlugins.splice(e,1)},y.prototype.getInternalTransport=function(){return this.internalTransport},y.prototype.setInternalTransport=function(e){this.internalTransport=e},y.prototype.getInternalRetrySchedule=function(){return this.internalRetrySchedule},y.prototype.transportRequest=function(t,n){return j(this,void 0,void 0,function(){return W(this,function(e){switch(e.label){case 0:if(this.internalTransport)return[4,this.internalTransport.request(t,n)];throw new Error("Internal Transport is not configured");case 1:return[2,e.sent()||{ok:!0,request:t}]}})})},y.prototype.transportHandoff=function(t,n){return j(this,void 0,void 0,function(){return W(this,function(e){switch(e.label){case 0:if(this.internalTransport)return[4,(this.internalTransport.handoff||this.internalTransport.request).call(this.internalTransport,O(O({},t),{handoff:!0}),n)];throw new Error("Internal Transport is not configured");case 1:return[2,e.sent()||{ok:!0,request:t,handoffAccepted:!0}]}})})},y.prototype.init=function(e){this.setConfig(e),this.config=V(this.config,e.hostUrl);for(var t=0;t<y.installedPlugins.length;t++)try{y.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},y.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,r=y.instances.indexOf(this);-1!==r&&y.instances.splice(r,1);for(var o=y.installedPlugins.length-1;0<=o;o--)try{y.installedPlugins[o].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),e)t=this,n=Object.getOwnPropertyDescriptors(t),Object.keys(n).forEach(function(e){n[e].writable&&(t[e]=null)}),Object.setPrototypeOf(this,null);else{for(var i=this;i.constructor!==Object&&it(i,this),i=Object.getPrototypeOf(i););0===y.instances.length&&(r=Object.getPrototypeOf(this).constructor,it(r),it(y))}},y.prototype.setConfig=function(e){Object.assign(this.config,e);var e=this.config,t=e.id,n=e.uin,r=e.version,o=e.aid,i=e.env,a=e.pageUrl,e=e.userId||(null!=n?String(n):""),n=this.bean.id!==t||this.bean.uin!==e||this.bean.aid!==o;return this.bean.id=t||"",this.bean.uin=e,this.bean.version=r||"1.0.14",this.bean.aid=o||"",this.bean.env=Se(i),a&&this.extendBean("from",encodeURIComponent(a.slice(0,2048))),n&&this.lifeCycle.emit("onConfigChange",this.config),this.config},y.prototype.extendBean=function(e,t){this.bean[e]=t},y.prototype.send=function(e,o,i){var t=this;return ot([Re(this),ke(this,null==e?void 0:e.type),function(n,r){t.request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];r({isErr:!1,result:e,logType:n.type,logs:n.log}),null!=o&&o.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];r({isErr:!0,result:e,logType:n.type,logs:n.log}),null!=i&&i.apply(void 0,e)})},Ie(this)])(e)},y.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(ue(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.0.14)",addBean:!1,method:"get",type:v.SDK_ERROR,log:e})}],v.SDK_ERROR)(e)},y.prototype.sendPipeline=function(e,t){var n,i=this;return ot(h([function(e,t){if(e&&e.type===v.EVENT)return t(e);if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),!n.isHidden||!n.isGetSample)if(n.isGetSample)n.isHidden||t(e);else{if(n.isGetSample=!0,Math.random()<n.config.random)return n.isHidden=!1,t(e);n.isHidden=!0}},Ce(n=this,t)],e,[ke(this,t),Re(this),function(r,o){i.request(r,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=!1;-1<(""+e[i.failRequestCount=0]).indexOf("403 forbidden")&&(n=!0,i.destroy()),o({isErr:n,result:e,logType:null==r?void 0:r.type,logs:null==r?void 0:r.log}),null!=(n=null==r?void 0:r.success)&&n.call.apply(n,h([r],e))},function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];60<=++i.failRequestCount&&i.destroy(),-1<(""+t[0]).indexOf("403 forbidden")&&i.destroy(),o({isErr:!0,result:t,logType:null==r?void 0:r.type,logs:null==r?void 0:r.log}),null!=(e=null==r?void 0:r.fail)&&e.call.apply(e,h([r],t))})},Ie(this)]))},y.prototype.track=function(e,t){void 0===t&&(t={}),e&&"string"==typeof e?(e={event_id:A(),event_type:P.CUSTOM,event_category:M.CUSTOM,timestamp:Date.now(),page_url:this.getCurrentEventPageUrl(),data:{event_name:e,replay_id:this.getEventReplayId(),tags:this.sanitizeEventTags(t.tags),event_properties:this.sanitizeEventProperties(t.properties)}},this.reportTDEMEvent(e)):console.warn("track: name must be a non-empty string")},y.prototype.trackStruggle=function(e,t){void 0===t&&(t={});var n,e="string"==typeof e?e.trim():"";!e||128<e.length?console.warn("trackStruggle: name must be a non-empty string limited to 128 characters"):(n=t.severity||"medium",(n=ut[n])?this.reportStruggle({type:"custom_struggle",ownerType:"business",ownerKey:e,severity:n,detectionSource:"custom",ruleVersion:"custom-v1",tags:t.tags,properties:O(O({},t.properties||{}),{custom_struggle_name:e})}):console.warn("trackStruggle: severity must be low, medium, or high"))},y.prototype.reportTDEMEvent=function(e){var r,t,n,o=this,e=Array.isArray(e)?e:[e];e.length&&(r="string"==typeof(n=(t=this).viewId)&&n.trim()?n.trim():"string"==typeof(t=null==(n=t.bean)?void 0:n.viewId)&&t.trim()?t.trim():"",n=e.map(function(e){var t,n="string"!=typeof e.view_id&&r?O(O({},e),{view_id:r}):e,n=O(O({},n),{page_url:n.page_url||o.getCurrentEventPageUrl(),data:O(O(O({},n.data),void 0!==Ke(e)||null!=(t=n.data)&&t.replay_id||!o.getCurrentReplayId()?{}:{replay_id:o.getCurrentReplayId()}),o.mergeEventTags(null==(t=n.data)?void 0:t.tags)?{tags:o.mergeEventTags(null==(t=n.data)?void 0:t.tags)}:{})});return Ge(n,null!=(t=Ke(e))?t:ze(o)),n}),this.lifeCycle.emit("tdemEventCreated",n),this.tdemEventPipeline(n))},y.prototype.measure=function(e,t,n){void 0===n&&(n={}),e&&"string"==typeof e?"number"==typeof t?t<0||2147483646<t?console.warn("measure: duration must between 0 and 2147483646"):this.submitMeasure(e,t,n):console.warn("measure: duration must be a number"):console.warn("measure: name must be a non-empty string")},y.prototype.startMeasure=function(e){"string"==typeof e&&e?this.timeMap[e]?console.warn("Measure "+e+" already exists"):this.timeMap[e]=Date.now():console.warn("startMeasure: name must be a non-empty string")},y.prototype.endMeasure=function(e,t){var n;void 0===t&&(t={}),"string"==typeof e&&e?void 0!==(n=this.getTimeEventDuration(e))?(this.submitMeasure(e,n,t),delete this.timeMap[e]):console.warn("Measure "+e+" does not exist"):console.warn("endMeasure: name must be a non-empty string")},y.prototype.captureMessage=function(e,t){var n;void 0===t&&(t={}),"string"==typeof e&&e?(n="error"===t.level?"error":"warn"===t.level?"warn":"info",n={event_id:A(),event_type:P.LOG,event_category:M.LOG,timestamp:Date.now(),page_url:this.getCurrentEventPageUrl(t.pageUrl),data:{log_level:n,replay_id:this.getEventReplayId(t.replayId),tags:this.sanitizeEventTags(t.tags),event_properties:this.sanitizeEventProperties(O({message:e},t.properties||{}))}},this.reportTDEMEvent(n)):console.warn("captureMessage: message must be a non-empty string")},y.prototype.captureException=function(e,t){void 0===t&&(t={});var e="string"==typeof e?new Error(e):e;e instanceof Error?(e={event_id:A(),event_type:P.JS_ERROR,event_category:M.ERROR,timestamp:Date.now(),page_url:this.getCurrentEventPageUrl(t.pageUrl),data:{exception_stacks:[{type:e.name||"Error",value:e.message,mechanism_type:"manual",mechanism_handled:1}],exception_frames:Te(e),replay_id:this.getEventReplayId(t.replayId),tags:this.sanitizeEventTags(t.tags),event_properties:this.sanitizeEventProperties(O(O({},t.properties||{}),t.level?{capture_level:t.level}:{}))}},this.reportTDEMEvent(e)):console.warn("captureException: error must be an Error or string")},y.prototype.setTags=function(e){e=this.sanitizeEventTags(e);this.setConfig({defaultTags:O(O({},this.config.defaultTags||{}),e||{})})},y.prototype.removeTags=function(e){var t,e=Array.isArray(e)?e:[e];e.length&&(t=O({},this.config.defaultTags||{}),e.forEach(function(e){delete t[e]}),this.setConfig({defaultTags:t}))},y.prototype.clearTags=function(){this.setConfig({defaultTags:{}})},y.prototype.setUser=function(e){"string"==typeof e&&e?this.setConfig({userId:e}):console.warn("setUser: userId must be a non-empty string")},y.prototype.clearUser=function(){this.setConfig({userId:"",uin:""})},y.prototype.reportStruggle=function(e){var t,n,r,o;e&&e.type&&e.ownerType&&e.ownerKey?(t=e.type,n="number"==typeof e.severity?e.severity:pt[t],r="number"==typeof e.weight?e.weight:ft[t],o=O(O({event_id:A(),event_type:P.STRUGGLE,event_category:M.BEHAVIOR,timestamp:null!=(o=null==(o=e.sourceContext)?void 0:o.timestamp)?o:Date.now(),page_url:this.getCurrentEventPageUrl(e.pageUrl)},e.sourceContext?{view_id:e.sourceContext.viewId}:{}),{data:{event_name:t,replay_id:null!=(t=null==(o=e.sourceContext)?void 0:o.replayId)?t:this.getEventReplayId(),tags:this.sanitizeEventTags(e.tags),is_effective_action:!1,related_event_ids:this.normalizeRelatedEventIds(e.relatedEventIds),payload:this.sanitizeEventPayload(e.payload,e.payloadAllowlist),struggle_weight:r,struggle_severity:n,struggle_value:"number"==typeof e.value?e.value:r*n,event_properties:O(O({},this.sanitizeStruggleProperties(e.properties)),{form_id:e.formId||"",field_id:e.fieldId||"",trigger_event_id:e.triggerEventId||"",struggle_status:e.status||"detected",struggle_owner_type:e.ownerType,struggle_owner_key:e.ownerKey,detection_source:e.detectionSource||"sdk_auto",rule_version:e.ruleVersion||this.getDefaultRuleVersion()})}}),e.sourceContext&&Ge(o,e.sourceContext.sessionId),this.reportTDEMEvent(o)):console.warn("reportStruggle params error")},y.prototype.reportFormSubmitResult=function(e){e&&e.status?(e={event_id:A(),event_type:P.FORM_SUBMIT_RESULT,event_category:M.BEHAVIOR,timestamp:Date.now(),page_url:this.getCurrentEventPageUrl(e.pageUrl),data:{event_name:e.eventName||"form_submit_"+e.status,replay_id:this.getEventReplayId(),tags:this.sanitizeEventTags(e.tags),is_effective_action:"boolean"!=typeof e.isEffectiveAction||e.isEffectiveAction,trigger_event_id:e.triggerEventId,related_event_ids:this.normalizeRelatedEventIds(e.relatedEventIds),payload:this.sanitizeEventPayload(e.payload,e.payloadAllowlist),validation_message:e.validationMessage?e.validationMessage.slice(0,256):void 0,event_properties:{status:e.status,validation_code:e.validationCode||"",form_id:e.formId||"",field_id:e.fieldId||""}}},this.reportTDEMEvent(e)):console.warn("reportFormSubmitResult params error")},y.prototype.reportPageView=function(e,t){void 0===t&&(t={});e=this.getCurrentEventPageUrl(e||t.pageUrl),e={event_id:A(),event_type:P.PAGE_VIEW,event_category:M.BEHAVIOR,timestamp:Date.now(),page_url:e,data:{page_title:t.pageTitle||"",referrer:t.referrer,replay_id:this.getEventReplayId(t.replayId),tags:this.sanitizeEventTags(t.tags),event_properties:this.sanitizeEventProperties(O(O(O(O(O(O(O({},t.properties||{}),t.navigationType?{navigation_type:t.navigationType}:{}),t.fromPage?{from_page:t.fromPage}:{}),t.toPage?{to_page:t.toPage}:{}),"boolean"==typeof t.isFirstVisit?{is_first_visit:t.isFirstVisit?"1":"0"}:{}),"boolean"==typeof t.isFirstLoad?{is_first_load:t.isFirstLoad?"1":"0"}:{}),t.deviceType?{device_type:t.deviceType}:{}))}};this.reportTDEMEvent(e)},y.prototype.setPage=function(e,t){var n;e&&"string"==typeof e?(n=this._customPageUrl||this.getCurrentEventPageUrl(),this._customPageUrl=e,this.reportPageView(e,{pageTitle:null==t?void 0:t.pageTitle,navigationType:"push",fromPage:(n||"").slice(0,512),toPage:e.slice(0,512),isFirstVisit:!1,tags:O({source:"manual",environment:this.config.env||"production",version:String(this.config.version||"")},null!=t&&t.pageGroup?{page_group:t.pageGroup}:{})}),this.lifeCycle.emit("pageChanged",{pageUrl:e,previousUrl:n,source:"manual"})):console.warn("setPage: pageUrl must be a non-empty string")},y.prototype.leavePage=function(){var e;this._customPageUrl&&(e=this._customPageUrl,this._customPageUrl=null,this.lifeCycle.emit("pageChanged",{pageUrl:this.getCurrentEventPageUrl(),previousUrl:e,source:"auto"}))},y.prototype.getCurrentEventPageUrl=function(e){var t;if(e)return e;if(this._customPageUrl)return this._customPageUrl;try{return this.getOriginFrom()}catch(e){return this.config.pageUrl||"undefined"!=typeof window&&(null==(t=window.location)?void 0:t.href)||""}},y.prototype.getCurrentReplayId=function(){var e,t;return String((null==(t=null==(t=null==(e=this.sessionManager)?void 0:e.getSession)?void 0:t.call(e))?void 0:t.replayId)||"")},y.prototype.getDefaultRuleVersion=function(){var e;return(null==(e=null==(e=this.config)?void 0:e.struggleMonitor)?void 0:e.ruleVersion)||"1.0.0"},y.prototype.getEventReplayId=function(e){return e||this.getCurrentReplayId()||void 0},y.prototype.mergeEventTags=function(e){return this.sanitizeEventTags(O(O(O({},this.config.defaultTags||{}),e||{}),{environment:Se(this.config.env)}))},y.prototype.sanitizeStringMap=function(n,r){var o;if(void 0===r&&(r=1024),n&&"object"==typeof n)return o={},Object.keys(n).forEach(function(e){var t=n[e];e&&null!=t&&(o[String(e)]=String(t).slice(0,r))}),Object.keys(o).length?o:void 0},y.prototype.sanitizeEventTags=function(e){return this.sanitizeStringMap(e,1024)},y.prototype.sanitizeEventProperties=function(e){return this.sanitizeStringMap(e,1024)},y.prototype.sanitizeStruggleProperties=function(e){var n=this.sanitizeEventProperties(e);if(n)return Object.keys(n).reduce(function(e,t){return dt.has(t)&&"custom_struggle_name"!==t||(e[t]=n[t]),e},{})},y.prototype.sanitizeEventPayload=function(n,e){var r,o=this;if(n&&"object"==typeof n)return e=(e=this.getPayloadAllowlist(e)).length?e:Object.keys(n),r={},e.forEach(function(e){var t;Object.prototype.hasOwnProperty.call(n,e)&&void 0!==(t=o.sanitizePayloadValue(n[e]))&&(r[e]=t)}),Object.keys(r).length?r:void 0},y.prototype.sanitizePayloadValue=function(n,r){var o=this;if(void 0===r&&(r=0),null!=n){if("string"==typeof n)return n.slice(0,256);if("number"==typeof n||"boolean"==typeof n)return n;if(Array.isArray(n))return n.slice(0,10).map(function(e){e=o.sanitizePayloadValue(e,r+1);return void 0===e?null:e});if("object"!=typeof n)return String(n).slice(0,256);if(2<=r)try{return JSON.stringify(n).slice(0,256)}catch(n){return}var i={};return Object.keys(n).slice(0,20).forEach(function(e){var t=o.sanitizePayloadValue(n[e],r+1);void 0!==t&&(i[e]=t)}),Object.keys(i).length?i:void 0}},y.prototype.getPayloadAllowlist=function(e){var t=null==(t=null==(t=this.config)?void 0:t.struggleMonitor)?void 0:t.payloadAllowlist;return Array.from(new Set(h(Array.isArray(t)?t:[],Array.isArray(e)?e:[]).filter(function(e){return!!e})))},y.prototype.normalizeRelatedEventIds=function(e){return Array.isArray(e)&&e.length&&(e=Array.from(new Set(e.filter(function(e){return"string"==typeof e&&e})))).length?e:void 0},y.prototype.ready=function(e,t,n){throw new Error('You need to override "ready" method')},y.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},y.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},y.prototype.getOriginFrom=function(){throw new Error('You need to override "getOriginFrom" method')},Object.defineProperty(y.prototype,"__version__",{get:function(){return"1.0.14"},enumerable:!1,configurable:!0}),y.prototype.submitMeasure=function(e,t,n){void 0===n&&(n={});e={event_id:A(),event_type:P.CUSTOM,event_category:M.CUSTOM,timestamp:Date.now(),page_url:this.getCurrentEventPageUrl(n.pageUrl),data:{event_name:e,measurements:{duration:t},replay_id:this.getEventReplayId(n.replayId),tags:this.sanitizeEventTags(n.tags),payload:this.sanitizeEventPayload(n.payload),event_properties:this.sanitizeEventProperties(n.properties)}};this.reportTDEMEvent(e)},y.prototype.getTimeEventDuration=function(e){if(void 0!==e&&this.timeMap[e])return Date.now()-this.timeMap[e]},y.version="1.0.14",y.instances=[],y.environment=t,y.installedPlugins=[],y),n=(r.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewTdem(e))},r.prototype.unpatch=function(e){var t=this.instances.indexOf(e);-1!==t&&(this.instances.splice(t,1),0===this.instances.length)&&this.uninstall(e)},r.prototype.countInstance=function(){return this.instances.length},r.prototype.uninstall=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.destroy)&&t.apply(this,[e])},r.prototype.walk=function(n){var r=this;this.instances.forEach(function(e){var t=r.canUse(e);t&&n(e,t)})},r.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},r.prototype.getConfig=function(e){return null==(e=e.config)?void 0:e[this.name]},r.prototype.exist=function(e){return-1===this.instances.indexOf(e)},r.prototype.triggerInit=function(e){var t;this.inited||(this.inited=!0,null==(t=null==(t=this.option)?void 0:t.init))||t.call(this.option,this.getConfig(e))},r.prototype.triggerOnNewTdem=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.onNewTdem)&&t.call(this.option,e,this.getConfig(e))},r),gt=["req_dial_links","req_dial_links_truncated","dns_dial_links","dns_dial_links_truncated"],vt=window.WebSocket,a=[],ht={construct:function(e,t){var r=new e(t[0],t[1]);return r.originSend=r.send,r.addEventListener("error",function(e){var e=(null==e?void 0:e.currentTarget)||{},t=e.url,n=e.readyState;null!=a&&a.forEach(function(e){e=e.onErr;null!=e&&e({msg:"无法获知具体错误信息,需在浏览器控制台查看!",readyState:n,connectUrl:t})})}),Object.defineProperty(r,"send",{get:function(){return function(e){null!=(t=r.originSend)&&t.call(r,e);var t=r.readyState;if(t!==WebSocket.OPEN){var n={readyState:t,connectUrl:r.url};switch(t){case WebSocket.CLOSED:a.forEach(function(e){e=e.sendErr;null!=e&&e(O({msg:"消息发送失败,连接已关闭!"},n))});break;case WebSocket.CONNECTING:a.forEach(function(e){(0,e.sendErr)(O({msg:"消息发送失败,正在连接中!"},n))});break;case WebSocket.CLOSING:a.forEach(function(e){(0,e.sendErr)(O({msg:"消息发送失败,连接正在关闭!"},n))})}}}}}),r}};function r(e){this.tdemPlugin=!0,this.name="",this.instances=[],this.inited=!1,e.$walk=this.walk.bind(this),e.$getConfig=this.getConfig.bind(this),this.option=e,this.name=e.name}function y(e,t){var o,i,a,s,n,l,r,c,u,d,p,f,m,g;void 0===t&&(t={}),this.sdkName="tdem-web-sdk",this.sdkVersion=y.version,this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:60,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,lagMonitor:!0,blankScreen:!0,memoryMonitor:!0,speedSample:!0,onClose:!0,reportLoadPackageSpeed:!0,env:"production",url:"",reportImmediately:!0,tdemConfig:!0,hostUrl:"https://dem.rumt-zh.com",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",performanceUrlForHippy:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:""},this.isWhiteList=!1,this.lifeCycle=new ee,this.bean={},this.internalRetrySchedule=Ee,this._customPageUrl=null,this.tdemEventPipeline=ot([(a=i=!1,s=[],n=function(e,t){var n,r;Array.isArray(e)&&0===e.length?t(e):(n=nt(o))?Array.isArray(e)?(r=e.filter(function(e){return Ze(tt(e,o),n,Math.random,rt(o))})).length&&t(r):Ze(tt(e,o),n,Math.random,rt(o))&&t(e):i?a&&t(e):s.length<1e3&&s.push({event:e,resolve:t})},(o=this)._tdemSampleGate={decide:function(e){i=!0,a=e;e=s;s=[],nt(o)?e.forEach(function(e){var t=e.event;return n(t,e.resolve)}):a&&e.forEach(function(e){var t=e.event;return(0,e.resolve)(t)})},reDecide:function(e){return!!nt(o)||(e<=0?a=!1:100<=e?a=!0:a=100*Math.random()<e)},get isDecided(){return i||!!nt(o)},get isSampled(){return a}},function(e,t){n(e,t)}),(r=this,c=20,p=Math.max(Number(c)||1,1),f=[],g=!(m=function(){}),function(e,t){function n(){for(clearTimeout(u),clearTimeout(d),d=u=void 0;0<f.length;)t(f.splice(0,p))}e=Array.isArray(e)?e:[e];f.push.apply(f,e);m=n,!g&&e.some(function(e){return e.event_type===P.PAGE_VIEW})?(g=!0,n()):r.sendNow&&0<f.length?n():0!==e.length?p<=f.length?n():0!==f.length&&(clearTimeout(u),u=setTimeout(function(){0<f.length&&m()},5e3),d=d||setTimeout(function(){0<f.length&&m()},3e4)):0<f.length&&n()}),function(t,n){try{var e,r=JSON.parse(JSON.stringify(t)),o=(l.lifeCycle.emit("beforeReport",r),l.config.beforeReport);"function"==typeof o?0<(e=t.filter(function(e){return!1!==o(e)})).length&&n(e):n(t)}catch(e){n(t)}},Je(l=this)]),this.timeMap={},this.failRequestCount=0,this.internalTransport=t.transport,this.internalRetrySchedule=t.retrySchedule||Ee,y.instances.push(this)}function x(e){return e=e.sessionManager,[(null==(t=null==(t=null==e?void 0:e.getSession)?void 0:t.call(e))?void 0:t.replayId)||"",null==t||t.id,!t||t.sampled,null==t||t.sampled][0];var t}var o,yt,_t,wt,bt,Et,St,Tt,kt,Ct,Rt,It=new n({name:"onError"}),Ot=It=new n({name:"onError",onNewTdem:function(e){this.startListen(e)},getFromParam:function(e){var t;return(null==(t=e.getOriginFrom)?void 0:t.call(e))||window.location.href},startListen:function(l){function e(e){var t,n=e&&ue(e.reason);n&&(t=[{type:(null==(t=e.reason)?void 0:t.name)||"PromiseRejection",value:(null==(t=e.reason)?void 0:t.message)||String(n),mechanism_type:"unhandledrejection",mechanism_handled:0}],n=e.reason instanceof Error?Te(e.reason):[],e={event_id:A(),event_type:P.PROMISE_ERROR,event_category:M.ERROR,timestamp:Date.now(),page_url:c.getFromParam(l),data:{exception_stacks:t,exception_frames:n,replay_id:x(l),tags:{environment:l.config.env||"production"}}},null!=(t=l.reportTDEMEvent))&&t.call(l,e)}function t(e){if(e=(null==e?void 0:e.target)||(null==e?void 0:e.srcElement)){var t=e.src||e.href||"",n=e.tagName,n=(void 0===n?"script":n).toLowerCase(),r=["audio","video"].includes(n);if((!r||null!=e&&e.error)&&!(m(o=t,l.config.hostUrl)||-1<window.location.href.indexOf(o))){var o="other";if(/\.js$/.test(t)||"script"===n)o="script";else if(/\.css$/.test(t)||"link"===n)o="stylesheet";else if("img"===n)o="image";else{if(!r)return;o="media"}t={event_id:A(),event_type:P.RESOURCE_ERROR,event_category:M.ERROR,timestamp:Date.now(),page_url:c.getFromParam(l),data:{url:t,resource_type:o,replay_id:x(l),tags:O({environment:l.config.env||"production"},r&&null!=e&&e.error?{error_code:String(e.error.code),error_message:e.error.message||""}:{}),event_properties:{element_tag:n}}};null!=(o=l.reportTDEMEvent)&&o.call(l,t)}}}var n,r,o,c=this,u=window.onerror,i=(window.onerror=function(e,t,n,r,o){var i,a,s=ue(e);"string"!=typeof(i=s)||!i||Y.some(function(e){return-1<i.indexOf(e)})||X.some(function(e){return-1<i.indexOf(e)})||(s=[{type:(null==o?void 0:o.name)||"Error",value:String(e),mechanism_type:"onerror",mechanism_handled:0}],a=o?Te(o):[{abs_path:t||"",colno:r||0,filename:(null==t?void 0:t.split("/").pop())||"",function:"(anonymous)",lineno:n||0,in_app:1,stack_level:0}],s={event_id:A(),event_type:P.JS_ERROR,event_category:M.ERROR,timestamp:Date.now(),page_url:c.getFromParam(l),data:{exception_stacks:s,exception_frames:a,replay_id:x(l),tags:{environment:l.config.env||"production",version:String(l.config.version||"")}}},null!=(a=l.reportTDEMEvent)&&a.call(l,s)),null!=u&&u.call(window,e,t,n,r,o)},window.addEventListener("unhandledrejection",e),window.document.addEventListener("error",t,!0),l.lifeCycle.on("destroy",function(){0===It.countInstance()&&(window.removeEventListener("unhandledrejection",e),window.document.removeEventListener("error",t,!0))}),l.config.websocket);(("object"==typeof i?!1!==i.enabled:i)||l.config.websocketHack)&&(i={key:l.config.id+"-"+this.name,onErr:function(e){var t;null!=(t=c.publishWsErrorLog)&&t.call(c,e,l)},sendErr:function(e){var t;null!=(t=c.publishWsErrorLog)&&t.call(c,e,l)}},this.hackWebsocketConfig=i,i=this.hackWebsocketConfig,window.Proxy)&&window.WebSocket&&(n=window.WebSocket,window&&!n.isHack&&(r=new Proxy(WebSocket,ht),n.isHack=!0,window.WebSocket=r),o=i,a.find(function(e){return e.key===o.key})||o&&a.push(o))},publishWsErrorLog:function(e,n){var t=e.connectUrl,r=e.msg,e=e.readyState,o={event_id:A(),event_type:P.JS_ERROR,event_category:M.ERROR,timestamp:Date.now(),page_url:this.getFromParam(n),data:{exception_stacks:[{type:"WebSocketError",value:"WEBSOCKET_ERROR: connect: "+t+" readyState: "+e+" msg: "+r,mechanism_type:"websocket",mechanism_handled:0}],exception_frames:[],replay_id:x(n),tags:{environment:n.config.env||"production",websocket_url:t||"",websocket_ready_state:String(null!=e?e:"")}}};this.$walk(function(e){var t;e===n&&null!=(t=e.reportTDEMEvent)&&t.call(e,o)})},destroy:function(){var t,e;this.option.hackWebsocketConfig&&(t=this.option.hackWebsocketConfig,window.WebSocket=vt,-1!==(e=a.findIndex(function(e){return e.key===t.key})))&&a.splice(e,1)}}),Pt=new n({name:"assets"}),Mt=Pt=new n({name:"assets",collectCur:0,collectEntryType:"resource",ASSETS_INITIATOR_TYPE:["img","css","script","link","audio","video"],getFromParam:function(e){var t;return(null==(t=e.getOriginFrom)?void 0:t.call(e))||window.location.href},onNewTdem:function(e){var t=this;st()&&(setTimeout(function(){t.collectSuccessLog(e),t.collectFailLog(e)},5e3),performance.onresourcetimingbufferfull=function(){"function"==typeof performance.clearResourceTimings&&(t.collectCur=0,performance.clearResourceTimings())})},processLog:function(e,t){var n=t.duration||0,r=t.transferSize||0,n={event_id:A(),event_type:P.RESOURCE_LOAD,event_category:M.NETWORK,timestamp:Date.now(),page_url:t.from||window.location.href,data:{url:t.url,resource_type:t.type||"static",measurements:{duration:n,dns_time:t.domainLookup,tcp_time:t.connectTime,transfer_size:0<r?r:void 0},replay_id:x(e),tags:{environment:e.config.env||"production",is_https:t.isHttps?"true":"false"},event_properties:{is_cached:String(0===r),protocol:t.nextHopProtocol||"",http_status:String(t.status||0)}}};null!=(r=e.reportTDEMEvent)&&r.call(e,n)},publish:function(t,n){var r=this;this.$walk(function(e){e===n&&(Array.isArray(t)?t.forEach(r.processLog):r.processLog(n,t))})},publishMany:function(e,t){for(var n=t.config,r=this.getFromParam(t),o=0,i=e.length;o<i;o++){var a=e[o];-1===this.ASSETS_INITIATOR_TYPE.indexOf(a.initiatorType)||m(a.name,n.hostUrl)||this.publish(this.generateLog(a,n,r),t)}},collectSuccessLog:function(n){var e,t,r=this;"function"==typeof window.PerformanceObserver?(this.publishMany(performance.getEntriesByType(this.collectEntryType),n),(e=new window.PerformanceObserver(function(e){r.publishMany(e.getEntries(),n)})).observe({entryTypes:[this.collectEntryType]}),n.lifeCycle.on("destroy",function(){0===Pt.countInstance()&&e.disconnect()})):(t=setInterval(function(){var e=performance.getEntriesByType(r.collectEntryType),t=e.slice(r.collectCur);r.collectCur=e.length,r.publishMany(t,n)},3e3),n.lifeCycle.on("destroy",function(){0===Pt.countInstance()&&clearInterval(t)}))},collectFailLog:function(o){function e(e){var t,n,r;e&&(e=e.target||e.srcElement,!(t=(null==e?void 0:e.src)||(null==e?void 0:e.href))||"string"!=typeof t||-1<window.location.href.indexOf(t)||(e="function"==typeof(null==(e=a.api)?void 0:e.resourceTypeHandler)?null==e?void 0:e.resourceTypeHandler(t):"",r=performance.getEntriesByType(i.collectEntryType).find(function(e){return e.name===t}),m(t,a.hostUrl))||(n=i.getFromParam(o),r={url:ae(t),status:400,duration:Number(((null==r?void 0:r.duration)||0).toFixed(2)),method:"get",type:e||"static",isHttps:se(t),urlQuery:ie(t,!0),nextHopProtocol:"",domainLookup:0,connectTime:0,from:n},i.publish(r,o)))}var i=this,a=o.config;window.document.addEventListener("error",e,!0),o.lifeCycle.on("destroy",function(){0===Pt.countInstance()&&window.document.removeEventListener("error",e,!0)})},generateLog:function(e,t,n){var t="function"==typeof(null==(r=t.api)?void 0:r.resourceTypeHandler)?null==(r=t.api)?void 0:r.resourceTypeHandler(e.name):"",r=e.transferSize;return{url:ae(e.name),method:"get",duration:Number(e.duration.toFixed(2)),status:200,type:t||"static",isHttps:se(e.name),nextHopProtocol:e.nextHopProtocol||"",urlQuery:ie(e.name,!0),domainLookup:oe(e.domainLookupEnd-e.domainLookupStart),connectTime:oe(e.connectEnd-e.connectStart),transferSize:0<r?r:-1,from:n}},collectNotReportedLog:function(e){var t,n;st()&&(t=(n=performance.getEntriesByType(this.collectEntryType)).length,"function"!=typeof window.PerformanceObserver)&&this.collectCur!==t&&(n=n.slice(this.collectCur),this.collectCur=t,this.publishMany(n,e))},destroy:function(){this.option.publish=function(){}}}),At={maxRetryCount:10,retryInterval:function(e){return 1e3*(2<<e)},whenRetryEndStillFail:"discard"};function xt(){wt=[],yt=-1,o=null,Ct(addEventListener)}function _(e,t){var n=Qt(),r="navigate";return 0<=Xt?r="back-forward-cache":n&&(document.prerendering||0<Zt()?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}}function Dt(e,t,n){try{var r;if(PerformanceObserver.supportedEntryTypes.includes(e))return(r=new PerformanceObserver(function(e){Promise.resolve().then(function(){t(e.getEntries())})})).observe(Object.assign({type:e,buffered:!0},n||{})),r}catch(e){}}function w(t,n,r,o){var i,a;return function(e){0<=n.value&&(e||o)&&((a=n.value-(i||0))||void 0===i)&&(i=n.value,n.delta=a,n.rating=(e=n.value)>r[1]?"poor":e>r[0]?"needs-improvement":"good",t(n))}}function Nt(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})}function Lt(t){function e(e){"pagehide"!==e.type&&"hidden"!==document.visibilityState||t(e)}addEventListener("visibilitychange",e,!0),addEventListener("pagehide",e,!0)}function Ft(t){var n=!1;return function(e){n||(t(e),n=!0)}}function Ut(){return en<0&&(en=tn(),rn(),Yt(function(){setTimeout(function(){en=tn(),rn()},0)})),{get firstHiddenTime(){return en}}}function qt(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()}function Ht(i,a){a=a||{},qt(function(){var t,n=Ut(),r=_("FCP"),o=Dt("paint",function(e){e.forEach(function(e){"first-contentful-paint"===e.name&&(o.disconnect(),e.startTime<n.firstHiddenTime)&&(r.value=Math.max(e.startTime-Zt(),0),r.entries.push(e),t(!0))})});o&&(t=w(i,r,an,a.reportAllChanges),Yt(function(e){r=_("FCP"),t=w(i,r,an,a.reportAllChanges),Nt(function(){r.value=performance.now()-e.timeStamp,t(!0)})}))})}function jt(e){var t,n,r,o,i,a;e.cancelable&&(t=(1e12<e.timeStamp?new Date:performance.now())-e.timeStamp,"pointerdown"==e.type?(n=t,r=e,o=function(){un(n,r),a()},i=function(){a()},a=function(){removeEventListener("pointerup",o,ln),removeEventListener("pointercancel",i,ln)},addEventListener("pointerup",o,ln),addEventListener("pointercancel",i,ln)):un(t,e))}function Wt(e){e.forEach(function(e){e.interactionId&&(gn=Math.min(gn,e.interactionId),vn=Math.max(vn,e.interactionId),mn=vn?(vn-gn)/7+1:0)})}function Bt(){return hn()-_n}function Vt(e){var t=E[E.length-1],n=wn[e.interactionId];(n||E.length<10||e.duration>t.latency)&&(n?(n.entries.push(e),n.latency=Math.max(n.latency,e.duration)):(t={id:e.interactionId,latency:e.duration,entries:[e]},wn[t.id]=t,E.push(t)),E.sort(function(e,t){return t.latency-e.latency}),E.splice(10).forEach(function(e){delete wn[e.id]}))}function zt(e,t){function n(t,n,r,o){function i(e){"visibilitychange"===t&&"hidden"!==document.visibilityState||(o?setTimeout(function(){return n(e)},o):n(e),r&&removeEventListener(t,i,!0))}addEventListener(t,i,!0)}var r;n("visibilitychange",e,null==t?void 0:t.once,null==(r=null==t?void 0:t.delay)?void 0:r.visibilitychange),n("pagehide",e,null==t?void 0:t.once,null==(r=null==t?void 0:t.delay)?void 0:r.pagehide),n("beforeunload",e,null==t?void 0:t.once,null==(r=null==t?void 0:t.delay)?void 0:r.beforeunload)}bt={passive:!0,capture:!0},Et=new Date,St=function(e,t){o||(o=t,yt=e,_t=new Date,Ct(removeEventListener),Tt())},Tt=function(){var t;0<=yt&&yt<_t-Et&&(t={entryType:"first-input",name:o.type,target:o.target,cancelable:o.cancelable,startTime:o.timeStamp,processingStart:o.timeStamp+yt},wt.forEach(function(e){e(t)}),wt=[])},kt=function(e){var t,n,r,o,i,a;e.cancelable&&(t=(1e12<e.timeStamp?new Date:performance.now())-e.timeStamp,"pointerdown"==e.type?(n=t,r=e,o=function(){St(n,r),a()},i=function(){a()},a=function(){removeEventListener("pointerup",o,bt),removeEventListener("pointercancel",i,bt)},addEventListener("pointerup",o,bt),addEventListener("pointercancel",i,bt)):St(t,e))},Ct=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach(function(e){return t(e,kt,bt)})},Rt="hidden"===document.visibilityState?0:1/0,addEventListener("visibilitychange",function e(t){"hidden"===document.visibilityState&&(Rt=t.timeStamp,removeEventListener("visibilitychange",e,!0))},!0),xt(),self.webVitals={firstInputPolyfill:function(e){wt.push(e),Tt()},resetFirstInputPolyfill:xt,get firstHiddenTime(){return Rt}};var b,Gt,Kt,Jt,$t,Xt=-1,Yt=function(t){addEventListener("pageshow",function(e){e.persisted&&(Xt=e.timeStamp,t(e))},!0)},Qt=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},Zt=function(){var e=Qt();return e&&e.activationStart||0},en=-1,tn=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},nn=function(e){"hidden"===document.visibilityState&&-1<en&&(en="visibilitychange"===e.type?e.timeStamp:0,on())},rn=function(){addEventListener("visibilitychange",nn,!0),addEventListener("prerenderingchange",nn,!0)},on=function(){removeEventListener("visibilitychange",nn,!0),removeEventListener("prerenderingchange",nn,!0)},an=[1800,3e3],sn=[.1,.25],ln={passive:!0,capture:!0},cn=new Date,un=function(e,t){b||(b=t,Gt=e,Kt=new Date,pn(removeEventListener),dn())},dn=function(){var t;0<=Gt&&Gt<Kt-cn&&(t={entryType:"first-input",name:b.type,target:b.target,cancelable:b.cancelable,startTime:b.timeStamp,processingStart:b.timeStamp+Gt},Jt.forEach(function(e){e(t)}),Jt=[])},pn=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach(function(e){return t(e,jt,ln)})},fn=[100,300],mn=0,gn=1/0,vn=0,hn=function(){return $t?mn:performance.interactionCount||0},yn=[200,500],_n=0,E=[],wn={},bn=[2500,4e3],En={},Sn=(Tn.prototype.start=function(){var t=this,n=new PerformanceObserver(function(e){e=e.getEntriesByName("first-contentful-paint");0<e.length&&(t.fcp=e[0].startTime,t.slientWindowStartTime=t.fcp,n.disconnect(),setTimeout(function(){t.checkTTI()},Math.max(t.slienceTimeInterval-(performance.now()-t.fcp)+20,1)))});n.observe({entryTypes:["paint"]}),this.longtaskObserver=new PerformanceObserver(function(e){e=e.getEntries();t.longTaskEntries=t.longTaskEntries.concat(e)}),this.longtaskObserver.observe({entryTypes:["longtask"]}),this.resourceObserver=new PerformanceObserver(function(e){e=e.getEntries();t.resourceEntries=t.resourceEntries.concat(e)}),this.resourceObserver.observe({entryTypes:["resource"]})},Tn.prototype.checkTTI=function(){var e=this;this.hasSlientWindow()?(this.calculateTTI(),this.longtaskObserver.disconnect(),this.resourceObserver.disconnect()):setTimeout(function(){e.checkTTI()},this.checkInterval)},Tn.prototype.hasSlientWindow=function(){var e,t=performance.now();return!(t-this.slientWindowStartTime<5e3||((e=this.getLastLongTaskEndTime())>this.slientWindowStartTime?(this.slientWindowStartTime=e,this.resourceEntries=[]):this.getRequestCount(this.slientWindowStartTime,t)<=2?(this.lastLongtaskEndTime=e,0):(t=this.resourceEntries.sort(function(e,t){return e.startTime-t.startTime}),this.slientWindowStartTime=t[this.resourceEntries.length-2].startTime,1)))},Tn.prototype.getLastLongTaskEndTime=function(){var t;return 0===this.longTaskEntries.length?-1:(t=0,this.longTaskEntries.forEach(function(e){e.startTime+e.duration>t&&(t=e.startTime+e.duration)}),t)},Tn.prototype.getRequestCount=function(t,n){var r=0;return this.resourceEntries.forEach(function(e){e.startTime>=t&&e.startTime+e.duration<=n&&(r+=1)}),r},Tn.prototype.calculateTTI=function(){var e=-1===this.lastLongtaskEndTime?this.slientWindowStartTime:this.lastLongtaskEndTime,t=performance.timing.domContentLoadedEventEnd-performance.timing.navigationStart,e=Math.max(t,e);this.onTTICallback(e)},Tn);function Tn(e){this.slienceTimeInterval=5e3,this.checkInterval=100,this.fcp=0,this.longTaskEntries=[],this.resourceEntries=[],this.slientWindowStartTime=performance.now(),this.onTTICallback=e}function kn(e){var t=e.name;0<(e=e.value)&&(Rn[t]=e)}function l(e,t,n,r){return void 0===n&&(n=15e3),void 0===r&&(r=0),(t=void 0===t?0:t)<=e&&e<=n?e:r}function c(e){return-1!==xn.indexOf(e)}new n({name:"webVitals"});var Cn,Rn={FCP:-1,LCP:-1,FID:-1,CLS:-1,INP:-1,TTI:-1,from:void 0},In=new Map,On=new n({name:"webVitals",onNewTdem:function(e){var t,n,r,i,a,s,l,c,u,d,p,o,f,m,g=this;if(st()&&"function"==typeof window.PerformanceObserver&&"function"==typeof performance.getEntriesByName)try{"function"!=typeof(m=(o=void 0===o?"undefined"==typeof window?{}:window:o).PerformanceObserver)||m.__tdemStartTimeGuard||(f=m,Object.setPrototypeOf(v,f),v.prototype=f.prototype,v.__tdemStartTimeGuard=!0,o.PerformanceObserver=v),In.set(e,{isWebVitalsReported:!1,hasFirstEntry:!1,custom:null}),Ht(kn),d=kn,p={},qt(function(){function e(e){(e=e[e.length-1])&&e.startTime<r.firstHiddenTime&&(o.value=Math.max(e.startTime-Zt(),0),o.entries=[e],t())}var t,n,r=Ut(),o=_("LCP"),i=Dt("largest-contentful-paint",e);i&&(t=w(d,o,bn,p.reportAllChanges),n=Ft(function(){En[o.id]||(e(i.takeRecords()),i.disconnect(),En[o.id]=!0,t(!0))}),["keydown","click"].forEach(function(e){addEventListener(e,function(){return setTimeout(n,0)},!0)}),Lt(n),Yt(function(e){o=_("LCP"),t=w(d,o,bn,p.reportAllChanges),Nt(function(){o.value=performance.now()-e.timeStamp,En[o.id]=!0,t(!0)})}))}),c=kn,u={},qt(function(){function t(e){e.startTime<n.firstHiddenTime&&(r.value=e.processingStart-e.startTime,r.entries.push(e),i(!0))}function e(e){e.forEach(t)}var n=Ut(),r=_("FID"),o=Dt("first-input",e),i=w(c,r,fn,u.reportAllChanges);o&&Lt(Ft(function(){e(o.takeRecords()),o.disconnect()})),o&&Yt(function(){r=_("FID"),i=w(c,r,fn,u.reportAllChanges),Jt=[],Gt=-1,b=null,pn(addEventListener),Jt.push(t),dn()})}),s=kn,l={},Ht(Ft(function(){function e(e){e.forEach(function(e){var t,n;e.hadRecentInput||(t=o[0],n=o[o.length-1],r&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(r+=e.value,o.push(e)):(r=e.value,o=[e]))}),r>n.value&&(n.value=r,n.entries=o,t())}var t,n=_("CLS",0),r=0,o=[],i=Dt("layout-shift",e);i&&(t=w(s,n,sn,l.reportAllChanges),Lt(function(){e(i.takeRecords()),t(!0)}),Yt(function(){n=_("CLS",r=0),t=w(s,n,sn,l.reportAllChanges),Nt(function(){return t()})}),setTimeout(t,0))})),i=kn,a={},qt(function(){var e;"interactionCount"in performance||($t=$t||Dt("event",Wt,{type:"event",buffered:!0,durationThreshold:0}));function t(e){e.forEach(function(t){t.interactionId&&Vt(t),"first-input"!==t.entryType||E.some(function(e){return e.entries.some(function(e){return t.duration===e.duration&&t.startTime===e.startTime})})||Vt(t)}),e=Math.min(E.length-1,Math.floor(Bt()/50)),(e=E[e])&&e.latency!==n.value&&(n.value=e.latency,n.entries=e.entries,o())}var n=_("INP"),r=Dt("event",t,{durationThreshold:null!=(e=a.durationThreshold)?e:40}),o=w(i,n,yn,a.reportAllChanges);r&&("PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&r.observe({type:"first-input",buffered:!0}),Lt(function(){t(r.takeRecords()),n.value<0&&0<Bt()&&(n.value=0,n.entries=[]),o(!0)}),Yt(function(){E=[],_n=hn(),n=_("INP"),o=w(i,n,yn,a.reportAllChanges)}))}),r=function(e){kn({name:"TTI",value:e})},st()&&new Sn(r).start(),zt(function(){g.tryReport(e,null,"onHidden")},{once:!0,delay:{visibilitychange:10}}),Rn.from=(null==(n=null==(t=e)?void 0:t.getOriginFrom)?void 0:n.call(t))||window.location.href}catch(e){}function v(n){return new f(function(e,t){try{n(e,t)}catch(e){if(!(0<=(e instanceof Error?e.message:String(e||"")).indexOf("startTime")))throw e}})}},tryReport:function(t,n,r){var o=this;void 0===r&&(r="manual"),this.$walk(function(e){e===t&&("object"==typeof(e=o.$getConfig(t))&&!0===e.manualReport||"onHidden"!==r?(e=In.get(t))&&!e.hasFirstEntry?(e.hasFirstEntry=!0,"manual"===r&&n&&(e.custom=n)):o.doReport(t,(null==e?void 0:e.custom)||n):o.doReport(t,null))})},doReport:function(i,a){var e=In.get(i);if(e){if(null!=e&&e.isWebVitalsReported)return;e.isWebVitalsReported=!0}this.$walk(function(e){var t,n,r,o;e===i&&(t=O({},Rn),a&&Object.keys(a).forEach(function(e){null!=a[e]&&(t[e]=a[e])}),n={environment:e.config.env||"production",version:String(e.config.version||"")},r={},0<t.LCP&&(r.lcp=t.LCP),0<t.FCP&&(r.fcp=t.FCP),0<t.FID&&(r.fid=t.FID),0<=t.CLS&&(r.cls=t.CLS),0<t.TTFB&&(r.ttfb=t.TTFB),0<t.TTI&&(r.tti=t.TTI),0<t.INP&&(r.inp=t.INP),o={event_id:A(),event_type:P.true,event_category:M.PERFORMANCE,timestamp:Date.now(),page_url:t.from||(null==(o=e.getOriginFrom)?void 0:o.call(e))||window.location.href,data:{measurements:r,replay_id:x(e),tags:n}},null!=(r=e.reportTDEMEvent))&&r.call(e,o)})},publish:function(e,t){this.tryReport(e,t,"manual")},destroy:function(){this.option.publish=function(){}}}),Pn=(new n({name:"pagePerformance"}),3),Mn=new Map,An=new n({name:"pagePerformance",performanceMap:{},onNewTdem:function(t){var e;st()&&(Mn.set(t,{isPagePerformanceReported:!1}),Cn?this.publish(Cn,t):this.startCalcPerformance(t),e=this.publishWhenObHidden.bind(this,t),zt(e,{once:!0}),t.lifeCycle.on("destroy",function(){var e=Mn.get(t);e&&(e.isPagePerformanceReported=!1)}))},publishWhenObHidden:function(e){var t,n=Mn.get(e);if(null==n||!n.isPagePerformanceReported){n=0;if(null!=(t=e.firstScreenInfo)&&t.timing)n=e.firstScreenInfo.timing;else if(lt("paint"))try{var r,o=performance.getEntriesByName("first-contentful-paint");o&&0<o.length&&(r=o[0])&&0<r.startTime&&(n=r.startTime)}catch(e){}(Cn=this.buildPerformanceLog(e,n,this.getPageUrl(e),window.location.href))&&this.publish(Cn,e,!0)}},buildPerformanceLog:function(e,t,n,r){var o=performance.timing;if(o)return n={from:n,originFrom:r,dnsLookup:l(o.domainLookupEnd-o.domainLookupStart),tcp:l(o.connectEnd-o.connectStart),ssl:l(0===o.secureConnectionStart?0:o.requestStart-o.secureConnectionStart),ttfb:l(o.responseStart-o.requestStart),contentDownload:l(o.responseEnd-o.responseStart),domParse:l(o.domInteractive-o.domLoading,0,15e3,1070),resourceDownload:l(o.loadEventStart-o.domInteractive,0,15e3,1070),firstScreenTiming:l(Math.floor(t),0,15e3,15e3)},(r=e.config).extraPerformanceData&&"{}"!==JSON.stringify(r.extraPerformanceData)&&(t=(o=r.extraPerformanceData).engineInit,e=o.bundleLoad,n=O(O({},n),{engineInit:l(t,0,1e4),bundleLoad:l(e,0,1e4)})),n},publish:function(r,o){this.$walk(function(e){var t,n;e===o&&(n=(t=performance.timing).navigationStart,t={event_id:A(),event_type:P.PAGE_LOAD,event_category:M.PERFORMANCE,timestamp:Date.now(),page_url:r.originFrom||window.location.href,data:{measurements:{lcp:Rn.lcp,fcp:Rn.fcp,fid:Rn.fid,cls:Rn.cls,ttfb:Rn.ttfb||r.ttfb,dns_time:r.dnsLookup,tcp_time:r.tcp,ssl_time:r.ssl,request_time:r.ttfb,response_time:r.contentDownload,dom_parse_time:r.domParse,dom_ready:t.domContentLoadedEventEnd-n,load_complete:t.loadEventEnd-n,first_screen_time:r.firstScreenTiming},replay_id:x(e),tags:{environment:e.config.env||"production",version:String(e.config.version||"")}}},null!=(n=e.reportTDEMEvent)&&n.call(e,t),n=Mn.get(e))&&(n.isPagePerformanceReported=!0)})},getPageUrl:function(e){var t=this.$getConfig(e);if(null!=t&&t.urlHandler&&"function"==typeof(null==t?void 0:t.urlHandler)){t=null==t?void 0:t.urlHandler();if(t)return encodeURIComponent(t)}return e.getCurrentPageUrl()},startCalcPerformance:function(t){var n=this;try{var r=this.getPageUrl(t),o=t.getOriginFrom();this.getFirstScreenTiming(t,function(e){Cn=n.buildPerformanceLog(t,e,r,o);e=Mn.get(t);!Cn||null!=e&&e.isPagePerformanceReported||n.publish(Cn,t)})}catch(t){}},getFirstScreenTiming:function(s,l){var c=this;s.lifeCycle.on("destroy",function(){v&&clearTimeout(v)});var u,d=this,n=["script","style","link","br"],p=[],f={},m=(lt("paint")&&(u=new PerformanceObserver(function(e){e.getEntries().forEach(function(e){var t;"paint"===e.entryType&&"first-contentful-paint"===e.name&&0<(t=document.querySelectorAll("[TDEM-FIRST-SCREEN-TIMING],[AEGIS-FIRST-SCREEN-TIMING]")).length&&s.config.id&&!c.performanceMap[s.config.id]&&(c.setFirstScreenInfo(s,e.startTime,t[0],t),null!=l&&l(e.startTime),m.disconnect(),u.disconnect(),v)&&clearTimeout(v)})})).observe({entryTypes:["paint"]}),new MutationObserver(function(e){var t={roots:[],ignores:[],rootsDomNum:[],time:performance.now()};e.forEach(function(e){e&&e.addedNodes&&Array.prototype.slice.call(e.addedNodes).forEach(function(e){d.isEleInArray(e,t.ignores)?t.ignores.push(e):1===e.nodeType&&(e.hasAttribute("TDEM-FIRST-SCREEN-TIMING")||e.hasAttribute("AEGIS-FIRST-SCREEN-TIMING"))?(Object.prototype.hasOwnProperty.apply(f,[t.time])||(f[t.time]=[]),f[t.time].push(e)):1===e.nodeType&&(d.hasAncestorOrSelfWithAttribute(e,"TDEM-IGNORE-FIRST-SCREEN-TIMING")?t.ignores.push(e):-1!==n.indexOf(e.nodeName.toLocaleLowerCase())||d.isEleInArray(e,t.roots)||(t.roots.push(e),t.rootsDomNum.push(d.walkAndCount(e)||0)))})}),t.roots.length&&p.push(t)})),g=(m.observe(document,{childList:!0,subtree:!0}),function(n){(n=void 0===n?0:n)||(r=0,(e=Object.keys(f)).length?(n=Math.max.apply(null,e),c.setFirstScreenInfo(s,n,null==(e=f[n])?void 0:e[0],f)):p.forEach(function(e){for(var t=0;t<e.roots.length;t++)e.rootsDomNum[t]>r&&d.isInFirstScreen(e.roots[t])&&(r=e.rootsDomNum[t],n=e.time,c.setFirstScreenInfo(s,n,e.roots[t]))}),p.length=0,Object.keys(f).forEach(function(e){f[e]=f[e].map(function(e){var t={tagName:e.tagName},n=e.attributes;if(!n)return e;for(var r=0;r<n.length;r++){var o=n[r];o.name&&(t[o.name]=e.getAttribute(o.name))}return t})}));var r,e=performance.timing,t=e.domInteractive-e.domLoading,o=n;v=null;for(var i=0,a=[t,e.loadEventStart-e.domInteractive,o];i<a.length;i++)if(a[i]<=0&&0<Pn){v=setTimeout(function(){return g(o)},3e3);break}v?--Pn:(m.disconnect(),null!=u&&u.disconnect(),null!=l&&l(n))}),v=setTimeout(function(){return g()},3e3)},setFirstScreenInfo:function(e,t,n,r){var o;e.config.id&&this.performanceMap[e.config.id]||(e.config.id&&(this.performanceMap[e.config.id]=!0),("object"!=typeof(null==(o=e.config)?void 0:o.pagePerformance)||null!=(o=e.config.pagePerformance)&&o.firstScreenInfo)&&(e.firstScreenInfo={element:n,timing:t,markDoms:r}))},isEleInArray:function(e,t){return!(!e||e===document.documentElement)&&(-1!==t.indexOf(e)||this.isEleInArray(e.parentElement,t))},isInFirstScreen:function(e){var t;return!(!e||"function"!=typeof e.getBoundingClientRect)&&(e=e.getBoundingClientRect(),t=window.innerHeight,0<=e.left)&&e.left<window.innerWidth&&0<=e.top&&e.top<t&&0<e.width&&0<e.height},walkAndCount:function(e){var t=0;if(e&&1===e.nodeType){t+=1;var n=e.children;if(null!=n&&n.length)for(var r=0;r<n.length;r++)1===n[r].nodeType&&(n[r].hasAttribute("TDEM-IGNORE-FIRST-SCREEN-TIMING")||n[r].hasAttribute("AEGIS-IGNORE-FIRST-SCREEN-TIMING"))||(t+=this.walkAndCount(n[r]))}return t},hasAncestorOrSelfWithAttribute:function(e,t){for(var n=t.replace(/^TDEM-/,"AEGIS-"),r=e;r&&r!==document.body;){if(r.hasAttribute(t)||n!==t&&r.hasAttribute(n))return!0;r=r.parentElement}return!1}}),xn=window.navigator.userAgent.toLowerCase(),u={};function Dn(){return{host:new URL(location.href).host,pathname:location.pathname}}u.macos=function(){return c("mac")},u.ios=function(){return u.iphone()||u.ipod()||u.ipad()},u.iphone=function(){return!u.windows()&&c("iphone")},u.ipod=function(){return c("ipod")},u.ipad=function(){var e="MacIntel"===navigator.platform&&1<navigator.maxTouchPoints;return c("ipad")||e},u.android=function(){return!u.windows()&&c("android")},u.androidPhone=function(){return u.android()&&c("mobile")},u.androidTablet=function(){return u.android()&&!c("mobile")},u.blackberry=function(){return c("blackberry")||c("bb10")},u.blackberryPhone=function(){return u.blackberry()&&!c("tablet")},u.blackberryTablet=function(){return u.blackberry()&&c("tablet")},u.windows=function(){return c("windows")},u.windowsPhone=function(){return u.windows()&&c("phone")},u.windowsTablet=function(){return u.windows()&&c("touch")&&!u.windowsPhone()},u.fxos=function(){return(c("(mobile")||c("(tablet"))&&c(" rv:")},u.fxosPhone=function(){return u.fxos()&&c("mobile")},u.fxosTablet=function(){return u.fxos()&&c("tablet")},u.meego=function(){return c("meego")},u.cordova=function(){return window.cordova&&"file:"===location.protocol},u.nodeWebkit=function(){return"object"==typeof window.process},u.mobile=function(){return u.androidPhone()||u.iphone()||u.ipod()||u.windowsPhone()||u.blackberryPhone()||u.fxosPhone()||u.meego()},u.tablet=function(){return u.ipad()||u.androidTablet()||u.blackberryTablet()||u.windowsTablet()||u.fxosTablet()},u.desktop=function(){return!u.tablet()&&!u.mobile()};var Nn,Ln,Fn,Un,qn=!(u.isIE=function(){return"ActiveXObject"in window}),Hn=[],jn=/^\/[^/]/;function Wn(e,t){return Un(e,t)}var Bn=!1,D=[];function Vn(e){var n;return e?"undefined"!=typeof Headers&&e instanceof Headers?(n={},e.forEach(function(e,t){n[t]=e,n[t.toLowerCase()]=e}),n):Array.isArray(e)?e.reduce(function(e,t){return t&&t[0]&&(e[String(t[0])]=String(t[1])),e},{}):O({},e):{}}function zn(r,e,o){return null!=e&&e.length&&"object"==typeof r?e.reduce(function(e,t){var n=window.Headers&&r instanceof Headers?r.get(t):r[t];return n?e+(""===e?"":"\n\n")+o+" header "+t+": "+n:e},""):""}function Gn(t,e){var n=ar.capture(),r=Date.now();g.forEach(function(e,t){12e4<r-e.created&&g.delete(t)}),1e3<=g.size&&g.delete(g.keys().next().value);var o,i="cgi-"+r.toString(16)+"-"+Math.random().toString(16).slice(2)+"-"+(++or).toString(16),a="undefined"!=typeof globalThis?globalThis.performance:void 0,s=new Set;try{a.getEntriesByType("resource").forEach(function(e){e.name===t&&s.add(ir(e))})}catch(t){}try{"function"==typeof a.now&&(o=a.now())}catch(t){}var l=!1;return g.forEach(function(e){e.finished||e.url!==t||(e.ambiguous=!0,l=!0)}),g.set(i,{id:i,owner:n,url:t,lower:o,existing:s,ambiguous:l,created:r,initiatorType:e}),i}function N(t,e){var n;void 0===e?(n=Array.from(g.values()).find(function(e){return e.url===t}))&&g.delete(n.id):g.delete(e)}function Kn(e,t,n){return cr(e,t,n).dnsTimeMs}function Jn(a,s){var l,c,u,t,e,n=g.get(a.requestId),d=n?n.owner:null;n&&(a.willReport||ar.isCurrent(d))?(t=function(e){void 0===e&&(e=!1);function t(e){N(a.url,a.requestId),s(ar.isCurrent(d)?e:{},o)}var n,r=O(O({},a),{timingUnavailable:e}),o=e?void 0:Kn(a.url,a.startedAtMs,a.requestId),i=(e=r,r={ms:o},(i=void 0===(i=d)?ar.capture():i)&&ar.isCurrent(i)?(n=Number(e.statusCode)||0,r=r.ms,ar.invoke(i,O(O({requestId:e.requestId,source:"renderer_fetch_xhr",host:lr(e.url),url:e.url,statusCode:n,errorCode:"",durationMs:e.durationMs},void 0!==r?{dnsTimeMs:r}:{}),{willReport:e.willReport,process:"renderer",startedAtMs:e.startedAtMs}),200)):{});i&&"function"==typeof i.then?i.then(t,function(){return t({})}):t(i)},a.transportFailure?t(!0):(l=a.url,c=a.startedAtMs,u=a.requestId,e=(n="undefined"!=typeof globalThis?globalThis:{}).document,n=n.performance,"settled"===(e=null!=e&&null!=n&&"function"==typeof n.getEntriesByType&&cr(l,c,u).pendingEntry?new Promise(function(t){var n,e=Date.now()+200,r=0,o=!1,i=function(e){o||(o=!0,void 0!==n&&clearTimeout(n),t(e))},a=function(){200<=r||Date.now()>=e?i("timeout"):cr(l,c,u).pendingEntry?(r+=50,n=setTimeout(a,50)):i("settled")};o||(n=setTimeout(a,0))}):"settled")?t():e.then(function(e){return t("timeout"===e)},function(){return t()}))):(N(a.url,a.requestId),s({},void 0))}function $n(e,t){return e&&-1===["null","undefined"].indexOf(e)?t+": "+e:""}function Xn(e,t,n){void 0===t&&(t="");var r,o,e="function"==typeof(null==(o=e.api)?void 0:o.resourceTypeHandler)?null==(o=e.api)?void 0:o.resourceTypeHandler(n):"";return-1===Z.indexOf(e)&&(r=void 0===t?"":t,o=(void 0===n?"":n).split("?")[0],e=fe.test(o)||pe.some(function(e){return-1!==String(r).indexOf(e)})?"static":"fetch"),e}function Yn(e,t){return e?L.AJAX_ERROR:t?L.RET_ERROR:L.API_RESPONSE}function Qn(e,t,n){if(!e)return!1;if(null!=(t=null==t?void 0:t.api)&&t.isSlowApi&&"function"==typeof(null==t?void 0:t.isSlowApi))try{return t.isSlowApi(n||{duration:e})}catch(e){return console.warn("[TDEM] isSlowApi function happen error:",e,", this data will not be reported."),!1}return(n=null!=(n=null==t?void 0:t.slowThreshold)?n:null==t?void 0:t.apiSlowThreshold)&&"number"==typeof n?n<e:1e3<e}function Zn(e,t){if(null!=(e=e.api)&&e.usePerformanceTiming&&"string"==typeof t.url){e=null==(e=performance.getEntriesByName(t.url))?void 0:e.pop();if(e)return{url:t.url,isHttps:se(t.url),method:t.method,type:t.type,status:t.status,duration:Number(e.duration.toFixed(2)),nextHopProtocol:e.nextHopProtocol||"",domainLookup:oe(e.domainLookupEnd-e.domainLookupStart),connectTime:oe(e.connectEnd-e.connectStart)}}return{url:t.url,isHttps:se(t.url),method:t.method,type:t.type,status:t.status,duration:Number(t.duration.toFixed(2)),nextHopProtocol:"",domainLookup:J.number,connectTime:J.number}}var er,tr,nr,rr,g=new Map,or=0,ir=function(e){return e.startTime+":"+e.responseEnd},ar=(er=null,{register:function(e,t){if(void 0===t&&(t={}),"function"!=typeof e)throw new TypeError("A request finalizer must be a function");if(er&&!0!==t.replace)throw new Error("A request finalizer is already registered");var n={handler:e,pending:new Set};return nr(n),function(){er===n&&nr(null)}},capture:function(){return er},isCurrent:tr=function(e){return null!==e&&er===e},onInvalidated:rr=function(e,t){var n;return tr(e)?((n=er).pending.add(t),function(){n.pending.delete(t)}):(t(),function(){})},invokeSync:function(e,t){if(!e||!tr(e))return{};try{var n=e.handler(t);return n&&"function"==typeof n.then?(Promise.resolve(n).catch(function(){}),{}):tr(e)?at(n):{}}catch(e){return{}}},invoke:function(a,e,t){if(!a||!tr(a))return{};try{var s=a.handler(e);return s&&"function"==typeof s.then?new Promise(function(n){function e(e){if(!r){r=!0,clearTimeout(i),o();var t={};try{tr(a)&&(t=at(e))}catch(e){}n(t)}}var r=!1,o=function(){},i=setTimeout(function(){return e()},t),o=rr(a,function(){return e()});Promise.resolve(s).then(e,function(){return e()})}):tr(a)?at(s):{}}catch(a){return{}}}}),sr=ar.register,lr=function(e){try{return new URL(e).hostname||""}catch(e){return""}},cr=function(n,r,e){if((t=lr(n))&&(0<=t.indexOf(":")||4===(t=t.split(".")).length&&t.every(function(e){return/^\d{1,3}$/.test(e)&&Number(e)<=255})))return{pendingEntry:!1};var t=Array.from(g.values()).filter(function(e){return!e.finished&&e.url===n}),o=e?g.get(e):1===t.length?t[0]:void 0;if(o&&o.ambiguous||1<t.length)return{pendingEntry:!1};e="undefined"!=typeof globalThis&&globalThis.performance?globalThis.performance:"undefined"!=typeof performance?performance:void 0;if(!e||"function"!=typeof e.getEntriesByType)return{pendingEntry:!1};var i,t=[];try{var a=Number(e.timeOrigin),s=Number.isFinite(a)&&0<a,t=e.getEntriesByType("resource").filter(function(e){var t;return!(!e||e.name!==n||o&&o.initiatorType&&e.initiatorType!==o.initiatorType||o&&o.existing.has(ir(e))||(e=Number(e.startTime||0),t=s?a+e:e,!(o&&void 0!==o.lower?e>=o.lower:r<=t&&t<r+1)))})}catch(n){return{pendingEntry:!1}}return 1<t.length?{pendingEntry:!1}:0===t.length?{pendingEntry:!0}:(e=t[0],0<Number(e.redirectStart)||0<Number(e.redirectEnd)||(t=Number(e.domainLookupStart),i=Number(e.domainLookupEnd),!Number.isFinite(t))||!Number.isFinite(i)||i<t?{pendingEntry:!1}:(e=0<Number(e.requestStart)||0<Number(e.connectEnd),i===t?e?{dnsTimeMs:0,pendingEntry:!1}:{pendingEntry:!1}:{dnsTimeMs:i-t,pendingEntry:!1}))},L={API_RESPONSE:"api_response",AJAX_ERROR:"ajax_error",RET_ERROR:"ret_error",SLOW_NET_REQUEST:"slow_net_request"};function ur(e){return!e||"boolean"==typeof e||"number"!=typeof(e=e.sseStallThresholdMs)||!Number.isFinite(e)||e<=0?6e4:e}function dr(e){return e&&"text/event-stream"===e.split(";")[0].trim().toLowerCase()}function pr(e){return"string"==typeof e&&""!==e.trim()}function fr(e){var t=String(e.requestUrl||""),n=String(e.finalUrl||""),r=t&&ie(t)||t,o=n&&ie(n)||n||r,n=!0===e.redirected||!!n&&!!t&&n!==t;return{url:o,originalUrl:r&&o&&r!==o?r:void 0,httpMethod:String(e.httpMethod||"GET").toUpperCase(),redirectCount:n?1:0}}function mr(n){function r(){w();var e=n.stallThresholdMs;0<e&&(c=setTimeout(function(){t("stalled")},e))}function o(){var e,t,n=p();void 0===i?i=n:void 0!==a&&(e=n-a,(void 0===s||s<e)&&(s=e),t=m,(e=e)<500?t.gap_lt_500_count+=1:e<1e3?t.gap_500_999_count+=1:e<3e3?t.gap_1000_2999_count+=1:e<1e4?t.gap_3000_9999_count+=1:e<6e4?t.gap_10000_59999_count+=1:t.gap_ge_60000_count+=1),a=n,h+=1,r()}function t(e){if(!y){y=!0,w(),_.splice(0).forEach(function(e){try{e()}catch(e){}});var t=Math.max(0,p()-f),t=O({duration:t,redirect_count:Math.max(0,n.redirectCount||0),message_count:h,stall_threshold_ms:n.stallThresholdMs},m),e=(void 0!==i&&(t.time_to_first_message=Math.max(0,i-f)),void 0!==a&&(t.last_message_offset=Math.max(0,a-f)),void 0!==s&&(t.max_message_gap=s),{http_method:n.httpMethod||"GET",outcome:e,model_version:d}),t=(void 0!==l&&0<l&&(e.http_status=String(l)),n.originalUrl&&n.originalUrl!==n.url&&(e.original_url=n.originalUrl),{event_id:A(),event_type:P.SSE_CALL,event_category:M.NETWORK,timestamp:p(),page_url:n.pageUrl||"",data:{url:n.url,resource_type:"sse",measurements:t,replay_id:n.replayId||void 0,event_properties:e}});try{n.report(t)}catch(e){}}}e=n.llmVersion;var i,a,s,l,c,e,u,d=(e=String(null==e?"":e).trim())?(u=Array.from(e)).length<=128?e:u.slice(0,128).join(""):"unknown",p=n.now||Date.now,f=p(),m={gap_lt_500_count:0,gap_500_999_count:0,gap_1000_2999_count:0,gap_3000_9999_count:0,gap_10000_59999_count:0,gap_ge_60000_count:0},g="",v=!1,h=0,y=!1,_=[],w=function(){void 0!==c&&(clearTimeout(c),c=void 0)};return r(),{ingestText:function(e){if(!y){e=e.replace(/\r\n/g,"\n");if(v){var t=e.indexOf("\n\n");if(-1===t)return;v=!1,e=e.slice(t+2)}for(var n=(g=(g+=e).replace(/\r\n/g,"\n")).indexOf("\n\n");-1!==n;){var r=g.slice(0,n);g=g.slice(n+2),r.replace(/\r\n/g,"\n").split("\n").some(function(e){return e.startsWith("data:")||"data"===e})&&o(),n=g.indexOf("\n\n")}1048576<g.length&&(v=!(g=""))}},ingestCompleteMessage:function(){y||o()},noteHttpStatus:function(e){0<e&&(l=e)},succeed:function(){return t("success")},failTransport:function(){return t("transport_error")},httpError:function(){return t("http_error")},cancel:function(){return t("cancelled")},pauseStall:function(){y||w()},resumeStall:function(){y||r()},onSeal:function(t){if(y){try{t()}catch(t){}return function(){}}return _.push(t),function(){var e=_.indexOf(t);-1!==e&&_.splice(e,1)}},seal:t,get sealed(){return y},get messageCount(){return h},get httpStatus(){return l}}}function gr(p,f){var m;return j(this,void 0,void 0,function(){var o,i,a,s,l,c,u,d;return W(this,function(e){switch(e.label){case 0:if(!p||"function"!=typeof p.getReader)return f.succeed(),[2];o=p.getReader(),a=i=!1,s=function(){if(!i&&!a&&"function"==typeof o.cancel){a=!0;try{var e=o.cancel();e&&"function"==typeof e.catch&&e.catch(function(){})}catch(e){}}},l=f.onSeal(s),c="undefined"!=typeof TextDecoder?new TextDecoder:{decode:function(e){return"undefined"!=typeof Buffer?Buffer.from(e).toString("utf8"):Array.from(e).map(function(e){return String.fromCharCode(e)}).join("")}},e.label=1;case 1:e.trys.push([1,5,6,7]),e.label=2;case 2:return f.sealed?[3,4]:[4,o.read()];case 3:return u=e.sent(),d=u.done,u=u.value,d?(i=!0,f.succeed(),[2]):(u&&f.ingestText(c.decode(u,{stream:!0})),[3,2]);case 4:return[3,7];case 5:return d=e.sent(),f.sealed||f[n=f.messageCount,r=f.httpStatus,!(t=d)||"object"!=typeof t||"AbortError"!==t.name&&"ABORT_ERR"!==t.code&&"ECONNABORTED"!==t.code&&!0!==t.aborted?(0<n||"number"==typeof r&&200<=r&&r<400)&&((e=>{if(pr(e)&&-1!==e.toLowerCase().indexOf("terminated"))return 1;for(var t=e,n=new Set;t&&"object"==typeof t&&!n.has(t);){n.add(t);var r=String(t.name||""),o=String(t.code||""),i=String(t.message||"").toLowerCase();if("TypeError"===r&&-1!==i.indexOf("terminated"))return 1;if("ERR_INVALID_STATE"===o)return 1;t=t.cause}})(t)||pr(t))?"succeed":"failTransport":"cancel"](),[3,7];case 6:l(),s();try{null!=(m=o.releaseLock)&&m.call(o)}catch(t){}return[7];case 7:return[2]}var t,n,r})})}var vr,hr,yr=!(nr=function(e){var t=er;er=e,t&&(Array.from(t.pending).forEach(function(e){return e()}),t.pending.clear())});function _r(e){var t=e.__tdemXhrHooks;t&&(e.removeEventListener("readystatechange",t.onReadyStateChange),e.removeEventListener("progress",t.onProgress),e.removeEventListener("loadend",t.onLoadEnd),e.removeEventListener("abort",t.onAbort),e.removeEventListener("error",t.onError),e.removeEventListener("timeout",t.onTimeout),e.__tdemXhrHooks=void 0)}function wr(e){var t=String(e.responseType||"").toLowerCase();if(!t||"text"===t)try{return"string"==typeof e.responseText?e.responseText:""}catch(e){}}new n({name:"api"});var d,br,Er,Sr=new n({name:"api",override:!1,onNewTdem:function(e){var t,n;this.override||(this.override=!0,null!=(n=e.config.api)&&n.injectTraceHeader&&(this.traceRequestHeader=new We(n.injectTraceHeader,null!=(t=null==n?void 0:n.injectTraceIgnoreUrls)?t:[],null==n?void 0:n.injectTraceUrls,null==n?void 0:n.traceFlag)),this.overrideFetch(e.config,e),this.overrideXhr(e.config,e),!1!==n&&this.overrideEventSource(e.config,e))},getFromParam:function(e){var t;return(null==(t=e.getOriginFrom)?void 0:t.call(e))||window.location.href},currentViewId:function(e){var t=null!=(e=null!=(t=e.viewId)?t:null==(t=e.bean)?void 0:t.viewId)?e:"";return String(t||"")},rememberViewId:function(e,t){e&&(e.__tdemViewId=this.currentViewId(t))},reportWithStartedView:function(e,t,n){var n=String((null==n?void 0:n.__tdemViewId)||(null==t?void 0:t.view_id)||""),t=!n||null!=t&&t.view_id?t:O(O({},t),{view_id:n});null!=(n=e.reportTDEMEvent)&&n.call(e,t)},overrideFetch:function(T,k){var C=this,s=T.api,e={name:this.name,traceRequestHeader:null!=s&&s.injectTraceHeader?this.traceRequestHeader:null,shouldInjectTrace:function(){return et(k)},getCurrentFrom:function(){return C.getFromParam(k)},beforeFetch:function(e,t){m(e,T.hostUrl)||(t.__tdemRequestId=Gn(e,"fetch")),C.rememberViewId(t,k)},cloneError:function(e,t,n,r,o,i){var a;m(n,T.hostUrl)||(a=e.headers?e.headers.get("content-type"):"",!1!==s&&dr(a)?(N(n,null==(a=r)?void 0:a.__tdemRequestId),(a=mr({url:(a=fr({requestUrl:n,finalUrl:e&&e.url,httpMethod:null==r?void 0:r.method,redirected:!!e.redirected})).url,originalUrl:a.originalUrl,httpMethod:a.httpMethod,redirectCount:a.redirectCount,stallThresholdMs:ur(s),report:function(e){return C.reportWithStartedView(k,e,r)},pageUrl:i||C.getFromParam(k),replayId:x(k),llmVersion:T.llmVersion})).noteHttpStatus(e.status),400<=e.status?a.httpError():a.succeed()):Jn({requestId:(null==(i=r)?void 0:i.__tdemRequestId)||"",url:n,statusCode:e.status||0,durationMs:t,startedAtMs:Number(o)||0,willReport:!1},function(){}))},then:function(g,v,h,y,_,w,b){if(!m(h,T.hostUrl)){var e,t,E=(null==(n=y)?void 0:n.__tdemRequestId)||"",n=(y&&(y.__tdemRequestId=E),g.headers?g.headers.get("content-type"):"");if(!1!==s&&dr(n))return N(h,E),e=fr({requestUrl:h,finalUrl:g&&g.url,httpMethod:null==y?void 0:y.method,redirected:!!g.redirected}),(t=mr({url:e.url,originalUrl:e.originalUrl,httpMethod:e.httpMethod,redirectCount:e.redirectCount,stallThresholdMs:ur(s),report:function(e){return C.reportWithStartedView(k,e,y)},pageUrl:w||C.getFromParam(k),replayId:x(k),llmVersion:T.llmVersion})).noteHttpStatus(g.status),g.__tdemSseObserver=t,400<=g.status?(t.httpError(),void gr(g.body,t).catch(function(){})):void gr(g.body,t).catch(function(){t.sealed||t.failTransport()});var S=Xn(T,n||"",h);"fetch"===S?Promise.resolve().then(function(){return g.clone().text()}).then(function(a){var e,s=g.status<=0||400<=g.status,t=(null==(t=T.api)?void 0:t.reqHeaders)||[],l=zn(null==y?void 0:y.headers,t,"req"),t=(null==(t=T.api)?void 0:t.resHeaders)||[],c=zn(g.headers,t,"res"),u=He(null==y?void 0:y.headers),t=le(a,T.api,{url:h,ctx:g,payload:null==y?void 0:y.body}),d=t.code,p=t.isErr,t=null==(t=T.api)?void 0:t.apiDetail,f=t?ce(null==y?void 0:y.body,null==(e=T.api)?void 0:e.reqParamHandler,{url:h}):"",m=t?ce(a,null==(e=T.api)?void 0:e.resBodyHandler,{url:h,ctx:g}):"";setTimeout(function(){var n=Zn(T,{url:h,duration:v,type:S,status:g.status||0,method:(null==y?void 0:y.method)||"get"}),e=[s?"FETCH_ERROR: "+a:"","fetch req url: "+h,"res status: "+(n.status||0),"res duration: "+n.duration+"ms","res startTime: "+_,l,c,"req method: "+(n.method||"GET"),"res retcode: "+d,$n(f,"req param"),$n(m,"res data")].filter(function(e){return e}).join("\n\n"),r=(n.payload=null==y?void 0:y.body,n.ret=d,n.isErr=+p,n.from=w||C.getFromParam(k),{msg:e,code:d,trace:u,errorMsg:"",from:w||C.getFromParam(k),originFrom:b,viewId:null==(e=y)?void 0:e.__tdemViewId,level:L.API_RESPONSE}),e=Qn(null==n?void 0:n.duration,T,n),t=Yn(s,p);r.level=t===L.API_RESPONSE&&e?L.SLOW_NET_REQUEST:t,r.isErr=p;var o=e||r.level!==L.API_RESPONSE,i=null==(t=k.config)?void 0:t.api;Jn({requestId:E,url:h,statusCode:n.status||0,durationMs:Number(n.duration)||0,startedAtMs:Number(_)||0,willReport:!!(o||k.isWhiteList||null!=i&&i.reportRequest||null!=i&&i.injectTraceHeader),transportFailure:!(0<g.status)},function(e,t){e&&Object.keys(e).length&&(r.dialFields=e),null!=t&&(r.dnsTime=t),(o||k.isWhiteList||null!=i&&i.reportRequest||null!=i&&i.injectTraceHeader)&&C.publishNormalLog(r,k),C.publishSpeed(n,k)})},0)}).catch(function(){Jn({requestId:E,url:h,statusCode:g.status||0,durationMs:v,startedAtMs:Number(_)||0,willReport:!1},function(){})}):(N(h,E),setTimeout(function(){var e=Zn(T,{url:h,duration:v,type:S,status:g.status||0,method:(null==y?void 0:y.method)||"get"});e.type="static",e.urlQuery=ie(h,!0),e.from=w||C.getFromParam(k),C.publishSpeed(e,k)},0))}},catch:function(e,t,o,i,a,s,l){if(m(o,T.hostUrl))throw e;var c,n,u,d,p,f=(null==(n=i)?void 0:n.__tdemRequestId)||"";if((n=g.get(f))&&(n.finished=!0),"AbortError"!==(e&&e.name))throw c=Xn(T,"",o),n=(null==(n=T.api)?void 0:n.reqHeaders)||[],u=zn(null==i?void 0:i.headers,n,"req"),d=He(null==i?void 0:i.headers),p=null!=(n=T.api)&&n.apiDetail?ce(null==i?void 0:i.body,null==(n=T.api)?void 0:n.reqParamHandler,{url:o}):"",setTimeout(function(){var n=Zn(T,{url:o,duration:t,type:c,status:0,method:(null==i?void 0:i.method)||"get"}),r=(n.from=s||C.getFromParam(k),"AJAX_ERROR: "+e+"\n \nreq url: "+o+"\n \nres status: 0\n \nres duration: "+n.duration+"ms\n \nreq method: "+((null==i?void 0:i.method)||"get")+"\n \nreq param: "+p+"\n \nres startTime: "+a+"\n \n"+u);Jn({requestId:f,url:o,statusCode:0,durationMs:Number(n.duration)||0,startedAtMs:Number(a)||0,willReport:!0,transportFailure:!0},function(e){var t;C.publishSpeed(n,k),C.publishNormalLog({msg:r,level:L.AJAX_ERROR,code:-400,trace:d,errorMsg:"",from:s||C.getFromParam(k),originFrom:l,viewId:null==(t=i)?void 0:t.__tdemViewId,dialFields:e},k)})},0),e;N(o,f)}},R=(this.hackFetchOptions=e,this.hackFetchOptions),I=null==(e=T.api)?void 0:e.ignoreHackReg;if(void 0===I&&(I=/\.flv(\?|$)/i),D.find(function(e){return e.name===R.name}))throw new Error("name '"+R.name+"' is already in hackFetch option list");D.push(R),!Bn&&window.fetch&&(Bn=!0,Un=window.fetch,window.fetch=function(e,t){void 0===t&&(t={});var n,o="string"==typeof e?e:e&&"object"==typeof e?"string"==typeof(n=e.url)&&n?n:"string"==typeof(n=e.href)&&n?n:"":"";if(o&&null!=(n=null==I?void 0:I.test)&&n.call(I,o))return Wn(e,t);jn.test(o)&&(o=""+location.origin+o);var r,i,a,s,l,c,u,d,p=R||{},f=p.traceRequestHeader,p=p.shouldInjectTrace;if(f&&(!p||p()))try{var m=((e,t)=>(e="undefined"!=typeof Request&&"string"!=typeof e&&e instanceof Request?Vn(e.headers):{},O(O({},e),Vn(t.headers))))(e,t),g=Dn(),v=g.host,h=g.pathname,y=f.generate(o,m,{host:v,pathname:h})||{},_=y.name,w=y.value;_&&w&&(r=e,i=t,a=_,s=w,c="undefined"!=typeof Headers?Headers:null,u="undefined"!=typeof Request&&"string"!=typeof r&&r instanceof Request,d=i.headers,c&&(u||d&&d instanceof c)?(l=new c(u?r.headers:void 0),d instanceof c?d.forEach(function(e,t){return l.set(t,e)}):Array.isArray(d)?d.forEach(function(e){e&&e[0]&&l.set(String(e[0]),String(e[1]))}):d&&"object"==typeof d&&Object.keys(d).forEach(function(e){l.set(e,String(d[e]))}),l.has(a)||l.set(a,s),i.headers=l):(u=Vn(d))[a]||u[a.toLowerCase()]||(i.headers=Object.assign({},u,((r={})[a]=s,r))))}catch(e){}for(var b=new Map,E=window.location.href,S=0;S<D.length;S++){var T=D[S];try{"function"==typeof T.beforeFetch&&T.beforeFetch(o,t),"function"==typeof T.getCurrentFrom&&b.set(T.name,T.getCurrentFrom())}catch(e){}}var k=Date.now(),C=Object.assign({},t,{method:(p=e,(g=t)&&g.method?String(g.method).toUpperCase():"string"!=typeof p&&p&&p.method?String(p.method).toUpperCase():"GET")});return Wn(e,t).then(function(e){var t;try{t=e.clone()}catch(t){for(var n=0;n<D.length;n++){var r=D[n];try{"function"==typeof r.cloneError&&r.cloneError(e,Date.now()-k,o,C,k,b.get(r.name),E)}catch(e){}}return e}for(n=0;n<D.length;n++){r=D[n];try{"function"==typeof r.then&&r.then(t,Date.now()-k,o,C,k,b.get(r.name),E)}catch(e){}}return e}).catch(function(e){for(var t=0;t<D.length;t++){var n=D[t];try{"function"==typeof n.catch&&n.catch(e,Date.now()-k,o,C,k,b.get(n.name),E)}catch(e){}}throw e})})},overrideXhr:function(k,C){var o,R=this,e={name:this.name,ignoreHackReg:null==(e=k.api)?void 0:e.ignoreHackReg,traceRequestHeader:null!=(e=k.api)&&e.injectTraceHeader?this.traceRequestHeader:null,getCurrentFrom:function(){return R.getFromParam(C)},open:function(e){var t;(t=(e=e).__tdemSseObserver)&&!t.sealed&&t.cancel(),_r(e),e.__tdemSseClaimed=!1,e.__tdemSseObserver=void 0,e.failType=void 0},send:function(w,b,E,S){R.rememberViewId(w,C);function e(){w.failType="abort"}function t(){w.failType="error"}function n(){w.failType="timeout"}function r(){var e;!1===k.api||w.__tdemSseClaimed||(e=w.tdemUrl||"",!m(e,k.hostUrl)&&dr(("function"==typeof w.getResponseHeader?w.getResponseHeader("content-type"):"")||"")&&(w.__tdemSseClaimed=!0,(e=mr({url:(e=fr({requestUrl:w.tdemUrl||"",finalUrl:("string"==typeof w.responseURL?w.responseURL:"")||void 0,httpMethod:w.tdemMethod})).url,originalUrl:e.originalUrl,httpMethod:e.httpMethod,redirectCount:e.redirectCount,stallThresholdMs:ur(k.api),report:function(e){return R.reportWithStartedView(C,e,w)},pageUrl:E||R.getFromParam(C),replayId:x(C),llmVersion:k.llmVersion})).noteHttpStatus(w.status),w.__tdemSseObserver=e))}function o(){r()}function i(){r();var e,t=w.__tdemSseObserver;t&&void 0!==(e=wr(w))&&e.length>c&&(t.ingestText(e.slice(c)),c=e.length)}function a(){var e,v,h,t,y,_=w.tdemUrl||"";w.__tdemSseClaimed?(N(_,w.__tdemRequestId),(e=w.__tdemSseObserver)&&!e.sealed&&(void 0!==(t=wr(w))&&t.length>c&&e.ingestText(t.slice(c)),e.noteHttpStatus(w.status),"abort"===w.failType?e.cancel():400<=w.status?e.httpError():w.failType?e.failTransport():e.succeed()),_r(w)):(_r(w),m(_,k.hostUrl)||"abort"===w.failType?N(_,w.__tdemRequestId):(v="",(w.failType||!w.status||400<=w.status)&&(v=w.failType||"failed"),h=Date.now()-T,t=w.getResponseHeader("content-type")||"",y=Xn(k,t,_),setTimeout(function(){var c=Zn(k,{url:_,duration:h,type:y,status:w.status,method:w.tdemMethod||"get"});if(c.from=E||R.getFromParam(C),"fetch"===y){var e=(null==(e=k.api)?void 0:e.reqHeaders)||[],u=zn(w.tdemXhrReqHeader,e,"req"),e=(null==(e=k.api)?void 0:e.resHeaders)||[],t=w.getAllResponseHeaders().split("\r\n").reduce(function(e,t){t=t.split(": ");return t[0]&&t[1]&&(e[t[0]]=t[1]),e},{}),d=zn(t,e,"res"),p=He(w.tdemXhrReqHeader),e=null==(t=k.api)?void 0:t.apiDetail,f=e?ce(b,null==(t=k.api)?void 0:t.reqParamHandler,{url:_}):"",m=e?ce(w.response,null==(t=k.api)?void 0:t.resBodyHandler,{url:_}):"";try{var n,r,o,i=w.response,a=k.api,s={url:_,ctx:w,payload:b},l=function(e){var n=e.code,r=e.isErr,o=[v?"AJAX_ERROR: request "+v:"","fetch req url: "+_,"res status: "+(c.status||0),"res duration: "+c.duration+"ms","res startTime: "+T,u,d,"req method: "+(c.method||"GET"),"res retcode: "+n,$n(f,"req param"),$n(m,"res data")].filter(function(e){return e}).join("\n\n"),i=(c.ret=n,c.isErr=+r,c.payload=b,Yn(!!v,r)),a=Qn(null==c?void 0:c.duration,k,c),s=i===L.API_RESPONSE&&a?L.SLOW_NET_REQUEST:i,e=w.__tdemRequestId||"",l=(w.__tdemRequestId=e,null==(t=C.config)?void 0:t.api),t=i!==L.API_RESPONSE||a||C.isWhiteList||(null==l?void 0:l.reportRequest)||(null==l?void 0:l.injectTraceHeader);Jn({requestId:e,url:_,statusCode:c.status||0,durationMs:Number(c.duration)||0,startedAtMs:Number(T)||0,willReport:!!t,transportFailure:!(0<w.status)},function(e,t){(i!==L.API_RESPONSE||a||C.isWhiteList||null!=l&&l.reportRequest||null!=l&&l.injectTraceHeader)&&R.publishNormalLog({msg:o,level:s,code:n,isErr:r,trace:p,errorMsg:"",from:E||R.getFromParam(C),originFrom:S,viewId:w.__tdemViewId,dialFields:e,dnsTime:t},C),R.publishSpeed(c,C)})};try{if("function"==typeof(null==a?void 0:a.retCodeHandlerAsync))return void a.retCodeHandlerAsync(i,null==s?void 0:s.url,null==s?void 0:s.ctx,function(e){var t=e.code;null!=l&&l({code:void 0===t?I:t,isErr:e.isErr})});if("function"==typeof(null==a?void 0:a.retCodeHandler))return void(o=(r=a.retCodeHandler(i,null==s?void 0:s.url,null==s?void 0:s.ctx,null==s?void 0:s.payload)||{}).code,null!=l&&l({code:void 0===o?I:o,isErr:r.isErr}));if(!(i="string"==typeof i?JSON.parse(i):i))return void(null!=l&&l({code:I,isErr:!1}));"function"==typeof(null==(n=null==a?void 0:a.ret)?void 0:n.join)&&(me=[].concat(a.ret.map(function(e){return e.toLowerCase()})));var g=Object.getOwnPropertyNames(i).filter(function(e){return-1!==me.indexOf(e.toLowerCase())});if(g.length)return void("未知"!==(o=i[g[0]])&&""!==o||(o=I),null!=l&&l({code:""+o,isErr:0!==o&&"0"!==o&&o!==I}));null!=l&&l({code:I,isErr:!1})}catch(i){null!=l&&l({code:I,isErr:!1})}}catch(e){N(_,w.__tdemRequestId),c.ret=I,R.publishSpeed(c,C)}}else N(_,w.__tdemRequestId),c.type="static",c.urlQuery=ie(_,!0),R.publishSpeed(c,C)},0)))}var s,l,T=Date.now(),c=(m(w.tdemUrl||"",k.hostUrl)||(w.__tdemRequestId=Gn(w.tdemUrl||"","xmlhttprequest")),((null==k?void 0:k.api)||{}).injectTraceHeader&&et(C)&&(l=(s=Dn()).host,s=(l=R.traceRequestHeader.generate(w.tdemUrl,{},{host:l,pathname:s.pathname})||{}).name,l=l.value,s)&&l&&w.setRequestHeader(s,l),0);w.__tdemXhrHooks={onReadyStateChange:o,onProgress:i,onLoadEnd:a,onAbort:e,onError:t,onTimeout:n},w.addEventListener("readystatechange",o),w.addEventListener("progress",i),w.addEventListener("loadend",a),w.addEventListener("abort",e),w.addEventListener("error",t),w.addEventListener("timeout",n)}};this.hackXHROptions=e,o=this.hackXHROptions,Hn.find(function(e){return e.name===o.name})||(Hn.push(o),!qn&&window.XMLHttpRequest&&(Nn=window.XMLHttpRequest.prototype.send,Ln=window.XMLHttpRequest.prototype.open,Fn=window.XMLHttpRequest.prototype.setRequestHeader,qn=!0,window.XMLHttpRequest.prototype.open=function(){this.tdemMethod=arguments[0];var e,t=arguments[1];if(jn.test(t)&&(t=""+location.origin+t),this.tdemUrl=t,null==(t=null==(e=o.ignoreHackReg)?void 0:e.test)||!t.call(e,this.tdemUrl))if(this.tdemXhrStartTime=Date.now(),this.sendByTdem)u.isIE()||(this.timeout=5e3);else for(var n=0;n<Hn.length;n++){var r=Hn[n];try{"function"==typeof r.open&&r.open(this)}catch(e){}}return Ln.apply(this,arguments)},window.XMLHttpRequest.prototype.setRequestHeader=function(){var e,t,n;return null!=(t=null==(n=o.ignoreHackReg)?void 0:n.test)&&t.call(n,this.tdemUrl)?Fn.apply(this,arguments):(t=arguments[0],n=arguments[1],this.tdemXhrReqHeader=null!=(e=this.tdemXhrReqHeader)?e:{},null!=o&&o.traceRequestHeader&&-1<["traceparent","b3","sw8","sentry-trace"].indexOf(t)&&(this.tdemXhrReqHeader[t]||(arguments[1]=n),this.tdemXhrReqHeader[t])?void 0:(this.tdemXhrReqHeader[t]=arguments[1],Fn.apply(this,arguments)))},window.XMLHttpRequest.prototype.send=function(){var e,t;if(!(null!=(t=null==(e=o.ignoreHackReg)?void 0:e.test)&&t.call(e,this.tdemUrl)||this.sendByTdem))for(var n=0;n<Hn.length;n++){var r=Hn[n];try{"function"==typeof r.send&&r.send(this,arguments[0],"function"==typeof r.getCurrentFrom?r.getCurrentFrom():void 0,window.location.href)}catch(e){}}return Nn.apply(this,arguments)}))},overrideEventSource:function(i,a){var n,s=this;function e(e,t){t=new n(e,t);try{null!=hr&&hr(t,String(e))}catch(e){}return t}hr={onCreate:function(t,e){var n={__tdemViewId:s.currentViewId(a)};if(!m(e,i.hostUrl)){var r=mr({url:ie(e)||e,httpMethod:"GET",stallThresholdMs:ur(i.api),report:function(e){return s.reportWithStartedView(a,e,n)},pageUrl:s.getFromParam(a),replayId:x(a),llmVersion:i.llmVersion});r.pauseStall(),t.addEventListener("open",function(){return r.resumeStall()}),t.addEventListener("message",function(){return r.ingestCompleteMessage()}),t.addEventListener("error",function(){if(!r.sealed){var e=t.readyState;0!==e?2===e&&r.failTransport():r.pauseStall()}});var o=t.close.bind(t);t.close=function(){try{r.sealed||r.cancel()}finally{o()}}}}}.onCreate,"undefined"!=typeof window&&window.EventSource&&!yr&&(yr=!0,n=vr=window.EventSource,e.prototype=n.prototype,e.CONNECTING=n.CONNECTING,e.OPEN=n.OPEN,e.CLOSED=n.CLOSED,window.EventSource=e)},publishSpeed:function(e){},publishNormalLog:function(n,e){var t,r,o,i,a,s,l,c,u;[L.API_RESPONSE,L.AJAX_ERROR,L.RET_ERROR,L.SLOW_NET_REQUEST].includes(n.level)&&(t=(t=null==(t=n.msg)?void 0:t.match(/(?:fetch req url|req url):\s*(.+?)(?:\n|$)/))?t[1].trim():"",r=(r=null==(r=n.msg)?void 0:r.match(/req method:\s*(.+?)(?:\n|$)/i))?r[1].trim().toUpperCase():"GET",s=(s=null==(s=n.msg)?void 0:s.match(/res status:\s*(\d+)/))?parseInt(s[1],10):0,o=(o=null==(o=n.msg)?void 0:o.match(/res duration:\s*([\d.]+)ms/))?parseFloat(o[1]):0,l=(l=null==(l=n.msg)?void 0:l.match(/=+\s*res data\s*=+\s*\n([\s\S]*?)(?:\n=+|$)/))?l[1].trim().slice(0,1e3):void 0,i={},n.trace&&(i.trace_id=n.trace),(u=(c={httpStatus:s,isTransportFailure:s<=0,isBusinessError:n.level===L.RET_ERROR||!!n.isErr,businessCode:n.code}).aborted?{report:!1,eventType:null}:(u=Number(c.httpStatus),c.isTransportFailure||!Number.isFinite(u)||u<=0?{report:!0,eventType:"api_error",outcome:"transport_error"}:400<=u?{report:!0,eventType:"api_error",outcome:"http_error"}:c.isBusinessError?{report:!0,eventType:"api_error",outcome:"business_error",businessCode:ne(c.businessCode)||I}:{report:!0,eventType:"api_call",businessCode:ne(c.businessCode)})).report)&&u.eventType&&(a={http_method:r,http_status:String(s)},u.outcome&&(a.outcome=u.outcome),u.businessCode&&(a.business_code=u.businessCode),n.dialFields&&"object"==typeof n.dialFields&&Object.keys(n.dialFields).forEach(function(e){var t=n.dialFields[e];null!=t&&""!==t&&(a[e]=String(t))}),c={duration:o},null!=n.dnsTime&&Number.isFinite(Number(n.dnsTime))&&(c.dns_time=Math.max(0,Number(n.dnsTime))),"api_error"===u.eventType?(s=O(O({event_id:A(),event_type:P.API_ERROR,event_category:M.ERROR,timestamp:Date.now(),page_url:n.from||(null==(r=e.getOriginFrom)?void 0:r.call(e))||window.location.href},n.viewId?{view_id:String(n.viewId)}:{}),{data:{url:t,measurements:c,response_body:l,replay_id:x(e),tags:0<Object.keys(i).length?i:void 0,event_properties:a}}),null!=(o=e.reportTDEMEvent)&&o.call(e,s)):(l=O(O({event_id:A(),event_type:P.API_CALL,event_category:M.NETWORK,timestamp:Date.now(),page_url:n.from||(null==(r=e.getOriginFrom)?void 0:r.call(e))||window.location.href},n.viewId?{view_id:String(n.viewId)}:{}),{data:{url:t,measurements:c,replay_id:x(e),tags:0<Object.keys(i).length?i:void 0,event_properties:a}}),null!=(o=e.reportTDEMEvent)&&o.call(e,l)))},destroy:function(){var t,n,e;this.option.publishSpeed=function(){},this.option.publishNormalLog=function(){},this.option.hackXHROptions&&(t=this.option.hackXHROptions,-1!==(e=Hn.findIndex(function(e){return e.name===t.name})))&&Hn.splice(e,1),this.option.hackFetchOptions&&(n=this.option.hackFetchOptions,-1!==(e=D.findIndex(function(e){return e.name===n.name})))&&D.splice(e,1),vr&&(window.EventSource=vr),yr=!1,hr=vr=void 0,this.option.override=!1}}),Tr={},kr=new n({name:"bridge",override:!1,onNewTdem:function(e){this.override||(this.override=!0,this.overrideBridge(e))},getFromParam:function(e){var t;return(null==(t=e.getOriginFrom)?void 0:t.call(e))||window.location.href},publishSpeed:function(t,n){this.$walk(function(e){e===n&&e.speedLogPipeline(t)})},overrideBridge:function(c){var u=this,d=c.config,e="object"==typeof d.bridge?d.bridge:void 0,t=null==e?void 0:e.target,e=null==e?void 0:e.methods;t&&null!=e&&e.length&&e.forEach(function(e){var l=t[e];Tr[e]=l,t[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e[0],o=e[1],n=e[2],i=e[3],a=Date.now(),s=u.getFromParam(c);l(r,o,n,function(e){var t=le(e,d.api),n=t.code,t=t.isErr,n={url:r+"-"+o,name:r+"-"+o,duration:Date.now()-a,type:"bridge",ret:n,isErr:+t,from:s};u.publishSpeed(n,c),i(e)})}})},unHackBridge:function(e){var e="object"==typeof e.config.bridge?e.config.bridge:void 0,t=null==e?void 0:e.target;Tr=(t&&Object.keys(Tr).forEach(function(e){Tr[e]&&(t[e]=Tr[e])}),{})},destroy:function(e){this.option.publishSpeed=function(){},this.option.unHackBridge(e),this.option.override=!1}}),Cr=new n({name:"aid",aid:"",init:function(e){try{var t=!0!==e&&e||window.localStorage.getItem("TDEM_ID");t||(t=Fe(),window.localStorage.setItem("TDEM_ID",t)),this.aid=t}catch(e){}},onNewTdem:function(e){e.bean.aid=this.aid,e.config.aid=this.aid}}),p=(new n({name:"aid"}),(p=d=d||{})[p.unknown=100]="unknown",p[p.wifi=1]="wifi",p[p.net2g=2]="net2g",p[p.net3g=3]="net3g",p[p.net4g=4]="net4g",p[p.net5g=5]="net5g",p[p.net6g=6]="net6g",(p=br=br||{})[p.android=1]="android",p[p.ios=2]="ios",p[p.windows=3]="windows",p[p.macos=4]="macos",p[p.linux=5]="linux",p[p.other=100]="other",(p=Er=Er||{})[p.unknown=100]="unknown",p[p.normal=0]="normal",p[p.weak=1]="weak",p[p.disconnected=2]="disconnected",new n({name:"device",onNewTdem:function(e){e.extendBean("platform",this.getPlatform()),e.extendBean("netType",d.unknown),this.getDpi(e),this.refreshNetworkTypeToBean(e),this.refreshNetworkStatusToBean(e)},getDpi:function(e){e.extendBean("vp",Math.round(window.innerWidth)+" * "+Math.round(window.innerHeight)),window.screen&&e.extendBean("sr",Math.round(window.screen.width)+" * "+Math.round(window.screen.height))},getPlatform:function(){var t={android:/\bAndroid\s*([^;]+)/,ios:/\b(iPad|iPhone|iPod)\b.*? OS ([\d_]+)/,windows:/\b(Windows NT)/,macos:/\b(Mac OS)/,linux:/\b(Linux)/i},e=Object.keys(t).find(function(e){return t[e].test(navigator.userAgent)});return e?br[e]:br.other},refreshNetworkTypeToBean:function(t){var n=this,e=t.config;e&&("function"==typeof e.getNetworkType?e.getNetworkType:Rr)(function(e){d[e]||(e=d.unknown),t.extendBean("netType",e),n.NetworkRefreshTimer=setTimeout(function(){n.refreshNetworkTypeToBean(t),clearTimeout(n.NetworkRefreshTimer)},1e4)})},refreshNetworkStatusToBean:function(t){var e,n=this,r=t.config;r&&null!=(e="function"==typeof r.getNetworkStatus?r.getNetworkStatus:e)&&e(function(e){void 0===Er[e]&&(e=Er.unknown),t.extendBean("netStatus",e),n.NetworkStatusRefreshTimer=setTimeout(function(){n.refreshNetworkStatusToBean(t),clearTimeout(n.NetworkStatusRefreshTimer)},1e4)})}})),Rr=function(e){var t="",n=navigator.userAgent.match(/NetType\/(\w+)/);n?t=n[1]:navigator.connection&&(t=navigator.connection.effectiveType||navigator.connection.type),e((n=t=t||I,0<=(n=String(n).toLowerCase()).indexOf("4g")?d.net4g:0<=n.indexOf("wifi")?d.wifi:0<=n.indexOf("5g")?d.net5g:0<=n.indexOf("6g")?d.net6g:0<=n.indexOf("3g")?d.net3g:0<=n.indexOf("2g")?d.net2g:d.unknown))},Ir=(new n({name:"spa"}),["replaceState","pushState","popstate","hashchange"]),Or=new n({name:"spa",visitStates:new WeakMap,navigationStack:[],navigationIndex:-1,onNewTdem:function(n){var r=this,e=(history.pushState=this.wr("pushState")||history.pushState,history.replaceState=this.wr("replaceState")||history.replaceState,this.sendPv=this.sendPv.bind(this),location.href);this.navigationStack.length||(this.navigationStack=[e],this.navigationIndex=0),n.config.spa&&this.sendPv(n,"reload"),Ir.forEach(function(e){var t=e;window.addEventListener(e,function(){return r.sendPv.call(r,n,t)})})},wr:function(n){var r=history[n],e="__"+n+"__hasWrittenByTamSpa";return"function"==typeof r&&!history[e]&&(Object.defineProperty(history,e,{value:!0,enumerable:!1}),function(){var e=r.apply(this,arguments),t=null;return"function"==typeof Event?t=new Event(n):(t=document.createEvent("HTMLEvents")).initEvent(n,!1,!0),window.dispatchEvent(t),e})},resolveNavigationType:function(e,t){var n;return"pushState"===e?(this.navigationIndex<this.navigationStack.length-1&&(this.navigationStack=this.navigationStack.slice(0,this.navigationIndex+1)),this.navigationStack.push(t),this.navigationIndex=this.navigationStack.length-1,"push"):"replaceState"===e?(this.navigationIndex<0?(this.navigationStack=[t],this.navigationIndex=0):this.navigationStack[this.navigationIndex]=t,"replace"):"hashchange"===e?"hashchange":"popstate"===e?0<=(e=this.navigationStack.lastIndexOf(t))?(n=e<this.navigationIndex?"back":"forward",this.navigationIndex=e,n):(this.navigationStack.push(t),this.navigationIndex=this.navigationStack.length-1,"forward"):"reload"},sendPv:function(a,e){var s=this,l=(void 0===e&&(e="reload"),a._customPageUrl),c=(a._customPageUrl=null,location.pathname+location.hash+a.config.id),u=a.getOriginFrom(),d=this.visitStates.get(a),p=this.resolveNavigationType(e,location.href);c&&(c!==(null==d?void 0:d.firedUrl)||l)&&this.$walk(function(n){var r,o,e,t,i;n===a&&("function"==typeof n.beginPageVisit?n.beginPageVisit(u,!!l):d&&(t=n,i=Le(),t.viewId=i,"function"==typeof t.extendBean)&&t.extendBean("viewId",i),r="string"==typeof(e=n.viewId||(null==(e=n.bean)?void 0:e.viewId)||"")?e:"",o=Date.now(),s.visitStates.set(a,{firedUrl:c,pageUrl:u}),setTimeout(function(){var e,t=O(O({event_id:A(),event_type:P.PAGE_VIEW,event_category:M.BEHAVIOR,timestamp:o,page_url:u},r?{view_id:r}:{}),{data:{page_title:document.title||"",referrer:document.referrer||void 0,is_effective_action:!0,replay_id:x(n),tags:{environment:n.config.env||"production",version:String(n.config.version||""),is_spa:"true"},event_properties:{navigation_type:p,from_page:(l||(null==d?void 0:d.pageUrl)||"").slice(0,512),to_page:(u||"").slice(0,512)}}});null!=(e=n.reportTDEMEvent)&&e.call(n,t)},0))})},destroy:function(){this.option.sendPv=function(){}}}),Pr="__MONITOR_SESSION_V1__";function Mr(e,t){"undefined"!=typeof document&&(e=[e+"="+encodeURIComponent(t),"path=/","SameSite=Lax"],"undefined"!=typeof location&&"https:"===location.protocol&&e.push("Secure"),document.cookie=e.join("; "))}function Ar(e,t,n){void 0===n&&(n=1);var r=Date.now();return{sessionId:e,createdAt:r,lastActivity:r,source:t,version:n}}function xr(){var e="undefined"==typeof globalThis?{}:globalThis;return e[Nr]||(e[Nr]=Object.create(null))}function Dr(e){return null==e?"":String(e)}var Nr="__TDEM_ENTRY_REGISTRY__",Lr=(Fr.prototype.request=function(i,a){var s=this;return void 0===a&&(a={}),i.sendBeacon||i.handoff?Promise.resolve(this.handoff(i,a)):new Promise(function(n){var e,r,t,o=new XMLHttpRequest;o.sendByTdem=!0,o.addEventListener("readystatechange",function(){var e,t;4===o.readyState&&((e={ok:0<o.status&&o.status<400,status:o.status,statusText:o.statusText,body:o.response,request:i}).ok?(null!=(t=a.success)&&t.call(a,o.response),null!=(t=a.final)&&t.call(a,e),n(e)):(t=O(O({},e),{error:o.response}),null!=(e=a.fail)&&e.call(a,o.response),null!=(e=a.final)&&e.call(a,t),n(t)))}),"get"===(i.method||"GET").toLowerCase()?(o.open("get",(e=i.url,r=i.data,"string"!=typeof e?"":"object"==typeof r&&r?(t=Object.getOwnPropertyNames(r).map(function(e){var t=r[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&"),e+(-1===e.indexOf("?")?"?":"&")+re(t)):e)),s.applyHeaders(o,i.headers),o.send()):(o.open("post",i.url),s.applyHeaders(o,i.headers),i.contentType&&o.setRequestHeader("Content-Type",i.contentType),t=void 0!==i.body?i.body:i.data,s.shouldSanitizeEvalKeyword(i,t)&&(t=re(t)),o.send(t))})},Fr.prototype.shouldSanitizeEvalKeyword=function(e,t){return"string"==typeof t&&!("replay"===e.kind||(e=null!=(t=null==(t=e.headers)?void 0:t["Content-Encoding"])?t:null==(t=e.headers)?void 0:t["content-encoding"])&&/gzip/i.test(e))},Fr.prototype.handoff=function(e,t){void 0===t&&(t={});var n,r="undefined"!=typeof navigator?navigator:void 0;return r&&"function"==typeof r.sendBeacon?(n=void 0!==e.body?e.body:e.data,n={ok:r=r.sendBeacon(e.url,n),request:e,handoffAccepted:r,error:r?void 0:new Error("navigator.sendBeacon rejected the payload")},r?null!=(r=t.success)&&r.call(t,{accepted:!0}):null!=(r=t.fail)&&r.call(t,n.error),null!=(r=t.final)&&r.call(t,n),n):(r={ok:!1,request:e,error:new Error("navigator.sendBeacon is unavailable")},null!=(n=t.fail)&&n.call(t,r.error),null!=(e=t.final)&&e.call(t,r),r)},Fr.prototype.applyHeaders=function(t,n){n&&Object.keys(n).forEach(function(e){t.setRequestHeader(e,n[e])})},Fr);function Fr(){}function Ur(e){try{var t="undefined"!=typeof window?window.location.href:"https://tdem.invalid/",n=new URL(e,t);return n.origin+n.pathname+n.hash}catch(t){return e.split("?")[0]}}var qr,Hr,f=new Map,S=(U(T,qr=mt),T.prototype.beginPageVisit=function(e,t){void 0===t&&(t=!1);var n=Ur(e);return!t&&n===this.viewPageIdentity||(this.viewId=Le(),this.extendBean("viewId",this.viewId),this.lifeCycle.emit("pageVisitChanged",{pageUrl:e,viewId:this.viewId})),this.viewPageIdentity=n,this.viewId},T.prototype.reportPageView=function(e,t){void 0===t&&(t={}),this.beginPageVisit(e||t.pageUrl||this.getOriginFrom(),!!t.navigationType),qr.prototype.reportPageView.call(this,e,t)},T.prototype.leavePage=function(){this._customPageUrl&&(this.beginPageVisit("undefined"!=typeof window?window.location.href:"",!0),qr.prototype.leavePage.call(this))},T.prototype._bootstrapInit=function(e){this.setConfig(e),this.config=V(this.config,e.hostUrl),this._prefetchConfigAndInit(e)},T.prototype._initImmediately=function(e){this.init(e),this._afterInit(e)},T.prototype._prefetchConfigAndInit=function(i){return j(this,void 0,void 0,function(){var t,n,r,o;return W(this,function(e){switch(e.label){case 0:if(t=this.config.id,n=this._buildPrefetchConfigUrl(),r=null,!t||!n)return[3,4];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.transportRequest({kind:"config",url:n,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_key:t})})];case 2:return(o=e.sent()).ok&&0===(o="string"==typeof o.body?JSON.parse(o.body):o.body).code&&o.data&&(r=o.data),[3,4];case 3:return e.sent(),(o=this._loadPrefetchDataFromCache(t))&&(r=o),[3,4];case 4:r&&(this._prefetchedConfigData=r);try{this._initAfterPreparedConfig(i)}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing TDEM, which will affect your normal use of TDEM.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),this.sendSDKError(e)}return[2]}})})},T.prototype._buildPrefetchConfigUrl=function(){var e=(this.config.url||"").replace(/\/+$/,"");return e?e+"/api/v1/sample-config":""},T.prototype._loadPrefetchDataFromCache=function(e){var t;try{var n,r=localStorage.getItem("TDEM_SAMPLE_CONFIG");return r?!((n=JSON.parse(r)).projectKey!==e||6048e5<=Date.now()-n.timestamp)&&null!=(t=n.document)&&t.event?n.document:null:null}catch(e){return null}},T.prototype._initAfterPreparedConfig=function(e){for(var t=0;t<mt.installedPlugins.length;t++)try{mt.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited"),this._afterInit(e)},T.prototype._afterInit=function(e){var t,n,r,i,a=this;this._sdkInitialized=!0,n=this.config.id,t=T.entryName,(n=(n=Dr(n))?xr()[n]:null)&&n.owner===t&&(n.state=1),this.extendBean("sessionId",T.sessionID),this.extendBean("from",this.getCurrentPageUrl()),"undefined"!=typeof document&&this.extendBean("referer",encodeURIComponent(document.referrer||"")),r=K(z("tdem-web-retry-report-requests"),[]),(i=function(){var o;r.length&&(o=r.splice(0,1)[0],G("tdem-web-retry-report-requests",JSON.stringify(r)),a.$request(o,function(){for(var e,t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{return null==(t=f.get(null==(e=o.extraRetryOptions)?void 0:e.success))?void 0:t.apply(o,n)}finally{i()}},function(){for(var e,t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{return null==(t=f.get(null==(e=o.extraRetryOptions)?void 0:e.fail))?void 0:t.apply(o,n)}finally{i()}}))})()},T.prototype.getBean=function(t){var n=this;return void 0===t&&(t=[]),""+Object.getOwnPropertyNames(this.bean).filter(function(e){return-1===t.indexOf(e)}).map(function(e){return"from"===e?"from="+n.getCurrentPageUrl():e+"="+n.bean[e]}).join("&")},T.prototype.getCurrentPageUrl=function(){var e;return this._customPageUrl?encodeURIComponent(this._customPageUrl.slice(0,2048)):(e=this.config.pageUrl||location.href,e=(e="function"==typeof this.config.urlHandler?this.config.urlHandler()||location.href:e).slice(0,2048),encodeURIComponent(e))},T.prototype.getOriginFrom=function(){if(this._customPageUrl)return this._customPageUrl.slice(0,2048);try{return("undefined"!=typeof window&&window.location?window.location.href:"").slice(0,2048)}catch(e){return""}},T.prototype.ready=function(){function i(){var e,n,r,o;t.reportRequestQueue.length&&(e=t.reportRequestQueue.splice(0,1)[0],n=e.options,r=e.success,o=e.fail,t.$request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return null==r?void 0:r.apply(n,e)}finally{i()}},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return null==o?void 0:o.apply(n,e)}finally{i()}}))}var t=this;i(),this.isReportReady=!0},T.prototype.request=function(l,n,c){var u,d,p=this;this.config.reportImmediately||this.isReportReady?this.$request(l,u=function(e){var t=K(z("tdem-web-retry-report-requests"),[]);null!=t&&t.length&&l.extraRetryOptions&&(t.splice(t.findIndex(function(e){return e.extraRetryOptions.requestId===l.extraRetryOptions.requestId}),1),G("tdem-web-retry-report-requests",JSON.stringify(t)),f.delete(l.extraRetryOptions.success),f.delete(l.extraRetryOptions.fail)),null!=n&&n(e)},d=function(e){if(!p.config.reportRetry)return null==c?void 0:c(e);var t,n="boolean"==typeof p.config.reportRetry?At:O(O({},At),p.config.reportRetry),r=n.maxRetryCount,o=void 0===r?At.maxRetryCount:r,r=n.retryInterval,r=void 0===r?At.retryInterval:r,n=n.whenRetryEndStillFail,i=void 0===n?At.whenRetryEndStillFail:n,a=(l.extraRetryOptions||(l.extraRetryOptions={requestId:"",retriedCount:0,success:"",fail:""}),l.extraRetryOptions),s=(a.requestId=a.requestId||l.url+"-"+Date.now()+"-"+Math.random(),a.requestId),n=(a.retriedCount=a.retriedCount||0,a.success=a.success||s+"_successCallback",a.fail=a.fail||s+"_failCallback",K(z("tdem-web-retry-report-requests"),[]));n.find(function(e){return e.extraRetryOptions.requestId===s})?(t=n.findIndex(function(e){return e.extraRetryOptions.requestId===s}),n[t]=l):n.push(l),G("tdem-web-retry-report-requests",JSON.stringify(n)),setTimeout(function(){if(a.retriedCount<o)l.extraRetryOptions.retriedCount+=1,p.$request(l,u,d);else{if("discard"===i){var e=K(z("tdem-web-retry-report-requests"),[]).filter(function(e){return(null==(e=e.extraRetryOptions)?void 0:e.requestId)!==s});if(e.length)G("tdem-web-retry-report-requests",JSON.stringify(e));else try{localStorage.removeItem("tdem-web-retry-report-requests")}catch(e){}}f.delete(a.success),f.delete(a.fail)}},"function"==typeof r?r(l.extraRetryOptions.retriedCount):r),null!=c&&c(e),f.has(a.success)||f.set(a.success,u),f.has(a.fail)||f.set(a.fail,d)}):this.reportRequestQueue.push({options:l,success:n,fail:c})},T.prototype.$request=function(s,e,t){var n,r;if(s&&"string"==typeof s.url&&""!==s.url&&this.bean.id)return n=s.url,!1!==s.addBean&&(n=((e,t)=>{var n,r,o,i=e,a=s.beanFilter||[];for(n in t)-1===a.indexOf(n)&&((o=(r=new RegExp("([?&])"+n+"(=([^&]*))?(?=&|$)")).exec(i))?o[2]&&""!==o[3]&&"undefined"!==o[3]||(i=i.replace(r,"$1"+n+"="+t[n])):(o=-1<i.indexOf("?")?"&":"?",i+=o+n+"="+t[n]));return i})(n,O(O({},this.bean),{from:this.getCurrentPageUrl()}))),s.url=n,n=s.method||"get",r=this.config.onBeforeRequest,(s=r?r(s,this):s)?s.url?(r={success:e,fail:t},void((e={kind:s.type===v.WHITE_LIST?"config":"events",url:s.url,method:n.toUpperCase(),contentType:s.contentType,data:s.data,body:s.data,sendBeacon:!!(null!=s&&s.sendBeacon||this.sendNow),source:s}).sendBeacon?this.transportHandoff(e,r):this.transportRequest(e,r))):console.warn("Please handle the parameters reasonably, options.url is necessary"):console.warn("Sending request blocked")},T.prototype.publishPluginsLogs=function(){var e=T.installedPlugins.find(function(e){return"assets"===e.name});null!=e&&e.option.collectNotReportedLog(this)},T.prototype.uploadLogs=function(e,t){var n;void 0===e&&(e={}),void 0===t&&(t={}),null!=(n=this.lifeCycle)&&n.emit("uploadLogs",e,t)},T.prototype.reportWebVitals=function(e){try{var t=T.installedPlugins.find(function(e){return"webVitals"===e.name});t&&this.config.webVitals&&this.config.webVitals.manualReport&&t.option.publish(this,e)}catch(e){}},T.prototype.destroy=function(e){var t,n,r;void 0===e&&(e=!1),n=this.config.id,t=T.entryName,(r=(n=Dr(n))?xr():null)&&r[n]&&r[n].owner===t&&delete r[n],qr.prototype.destroy.call(this,e)},T.entryName="tdem-web-sdk",T.sessionID=(jr=Le,("undefined"==typeof window?Ar(jr(),"tdem"):(Hr="undefined"!=typeof document&&(Hr="_tdem_s".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Hr=document.cookie.match(new RegExp("(?:^|; )"+Hr+"=([^;]*)")))?decodeURIComponent(Hr[1]):null,S=window[Pr],Hr?(null==S?void 0:S.sessionId)===Hr?(S.lastActivity=Date.now(),S):(to=Ar(Hr,(null==S?void 0:S.source)||"tdem",(null==S?void 0:S.version)||1),window[Pr]=to):null!=S&&S.sessionId?(S.lastActivity=Date.now(),Mr("_tdem_s",S.sessionId),S):(to=Ar(jr(),"tdem"),Mr("_tdem_s",(window[Pr]=to).sessionId),to))).sessionId),T);function T(e,t){var n,r,o,a,i,s,l,c,u,d,p,f,m=qr.call(this,e,t=void 0===t?{}:t)||this,g=(m._entrySkipped=!1,m.sendNow=!1,m.isReportReady=!1,m.reportRequestQueue=[],m._sdkInitialized=!1,m.viewId="",m.viewPageIdentity="",m.speedLogPipeline=ot([(c=[],u=(i=m).config,i.lifeCycle.on("destroy",function(){c.length=0}),function(e,t){Array.isArray(e)?c=c.concat(e):c.push(e),s&&c.length>=s||i.sendNow&&0<c.length?(c=Oe(c),0<(c=Array.isArray(c)?c:[]).length&&t(c.splice(0,c.length)),l&&clearTimeout(l)):(l&&clearTimeout(l),l=setTimeout(function(){l=null,c=Oe(c),0<(c=Array.isArray(c)?c:[]).length&&t(c.splice(0,c.length))},u.delay))}),(a=m.config,function(e,t){var n,r,o,i="number"==typeof a.repeat?a.repeat:60;!a.speedSample||i<=0?t(e):(n=(null==a?void 0:a.id)||"0",r=Me[n]||{},Array.isArray(e)?(o=e.filter(function(e){var t=!r[e.url]||r[e.url]<i;return t?(r[e.url]=1+~~r[e.url],Me[n]=r):Pe[n]||Ae(n),t})).length&&t(o):!r[e.url]||r[e.url]<i?(r[e.url]=1+~~r[e.url],Me[n]=r,t(e)):Pe[n]||Ae(n))}),(o=m,function(t,n){Rr(function(e){o.extendBean("netType",e),n(t)})}),function(e,t){null!=(n=m.lifeCycle)&&n.emit("beforeReportSpeed",e);var n,r=m.config.beforeReportSpeed;if((e="function"==typeof r?e.filter(function(e){return!1!==r(e)}):e).length)return t(e)},function(e,t){t(e.map(function(e){return void 0!==e.payload&&delete e.payload,e}))},function(e){return m.sendPipeline([function(e,t){t({type:v.SPEED,url:""+m.config.speedUrl,method:"post",data:de(e,O(O({},m.bean),{from:m.getCurrentPageUrl()})),log:e})}],v.SPEED)(e)}]),t=e&&e.id,d=T.entryName,(t=Dr(t))?(g=(p=xr())[t])&&g.owner!==d?{status:"skipped_duplicate",owner:g.owner}:(g||(p[t]={owner:d,state:0}),{status:"owned",owner:d}):{status:"owned",owner:d});if("skipped_duplicate"===g.status)m._entrySkipped=!0,-1!==(p=mt.instances.indexOf(m))&&mt.instances.splice(p,1),console.warn("[TDEM] skip "+T.entryName+": "+(e&&e.id)+" owned by "+g.owner);else{m.viewId=Le(),m.extendBean("viewId",m.viewId),m.viewPageIdentity=Ur(m.getOriginFrom()),m.getInternalTransport()||m.setInternalTransport(new Lr),e.asyncPlugin=!0;try{"undefined"!=typeof document&&(f=String(e.userId||e.uin||(null!=(n=document.cookie.match(/\buin=\D+(\d*)/))?n:[])[1]||(null!=(r=document.cookie.match(/\bilive_uin=\D*(\d+)/))?r:[])[1]||""),e.userId=f,e.uin=e.uin||f),m._bootstrapInit(e)}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing TDEM, which will affect your normal use of TDEM.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),m.sendSDKError(e)}}return m}new n({name:"ie"}),new n({name:"onClose"});var jr=new n({name:"onClose",onNewTdem:function(e){function t(){return r.publishNotReportedLog(e)}function n(){"undefined"!=typeof document&&"hidden"!==document.visibilityState||t()}var r=this;document.addEventListener("visibilitychange",n,!0),window.addEventListener("pagehide",t,!0),e.lifeCycle.on("destroy",function(){document.removeEventListener("visibilitychange",n,!0),window.removeEventListener("pagehide",t,!0)})},publishNotReportedLog:function(n){var r=this;this.$walk(function(e){if(e===n){var t=e.sendNow;try{e.sendNow=!0,e.lifeCycle.emit("beforeCloseFlush"),e.publishPluginsLogs(),r.publishThrottlePipeLogs(e)}finally{e.sendNow=t}}})},publishThrottlePipeLogs:function(e){null!=e&&e.speedLogPipeline([]),null!=e&&e.tdemEventPipeline([])}}),Wr='a,button,input[type="button"],input[type="submit"],input[type="reset"],input[type="image"],[role="button"],[onclick],[ng-click],[v-on\\:click]',Br=new WeakMap;function Vr(e){return e.closest(Wr)||e}function zr(e,t){return null==(e=Br.get(e))?void 0:e.get(t)}function Gr(e){return e instanceof Array?new Map(e.map(function(e){return[e,!0]})):new Map}function Kr(e,t){return"string"==typeof e?e.split(t):[]}new n({name:"click"});var Jr=function(e){if(""!==e.id&&e.id)return'id("'+e.id+'")';if(e===document.body)return e.tagName;if(e instanceof Document)return"document";var t=0;if(e.parentNode)for(var n=e.parentNode.childNodes,r=0;r<n.length;r+=1){var o=n[r];if(o===e)return Jr(e.parentNode)+"/"+e.tagName+"["+(t+1)+"]";1===o.nodeType&&o.tagName===e.tagName&&(t+=1)}return 0},$r=function(e){if(3===e.nodeType||4===e.nodeType)return e.nodeValue||"";if(1!==e.nodeType)return"";if("string"==typeof e.textContent)return e.textContent;for(var t="",n=e.firstChild;n;n=n.nextSibling)t+=$r(n);return t},Pr=new n({name:"click",listeners:[],onNewTdem:function(e){this.startListen(e)},startListen:function(s){for(var e=this,t=0,n=Object.entries({click:1,longpress:2});t<n.length;t++)(a=>{e.listeners.push(((e,t,n,r)=>{function o(e){var t=document.documentElement;t&&n.call(t,e,e.target)}return void 0===r&&(r=!0),e.addEventListener(t,o,r),{destroy:function(){e.removeEventListener(t,o,r)}}})(document,a,function(e,t){var n,r,o,i;t&&!((e,t)=>{e="object"==typeof e.click?e.click:void 0,n=Gr((null==e?void 0:e.ignoreClasses)||[])||new Map;for(var n,r=(e={ignoreIds:Gr((null==e?void 0:e.ignoreIds)||[])||new Map,ignoreClasses:n}).ignoreClasses,o=e.ignoreIds,i=!(0===o.size&&0===r.size),a=t,s=(Kr(t.getAttribute("id")||""," "),Kr(t.getAttribute("class")||"",""),0),l=!1;a&&i&&a.getAttribute;){if(l)return 1;if(10<=s)break;for(var c=Kr(a.getAttribute("id")||""," "),u=Kr(a.getAttribute("class")||"",""),d=0,p=c;d<p.length;d++){var f=p[d];if(o.has(f)){l=!0;break}}for(var m=0,g=u;m<g.length;m++){var v=g[m];if(r.has(v)){l=!0;break}}s+=1,a=a.parentNode||a.parentElement}})(s.config,t)&&(n=Jr(t),r=(r=(e=>{var t="",n=e.nodeType;if(1===n||9===n||11===n){if("string"==typeof e.textContent)return e.textContent;for(var r=e.firstChild;r;r=r.nextSibling)t+=$r(e)}else if(3===n||4===n)return e.nodeValue;return t})(t))?r.replace(/^\s+|\s+$/g,""):"",o=t.getBoundingClientRect&&t.getBoundingClientRect(),n={event_id:A(),event_type:P.CLICK,event_category:M.BEHAVIOR,timestamp:Date.now(),page_url:s._customPageUrl||window.location.href,data:{target_element:String(n),target_text:r.slice(0,127),click_position:o?{x:parseInt(String(o.left+window.scrollX),10)||0,y:parseInt(String(o.top+window.scrollY),10)||0}:void 0,replay_id:x(s),tags:{environment:s.config.env||"production",event_op:a,node_name:(null==t?void 0:t.nodeName)||""},event_properties:{target_id:t.id||"",target_class:"string"==typeof t.className?t.className.slice(0,128):""}}},r=e,o=s,t=n,(i=Br.get(r)||new Map).set(o,t),Br.set(r,i),s.lifeCycle.emit("clickCaptured",{event:e,source:n}),null!=(o=s.reportTDEMEvent))&&o.call(s,n)},!0))})(n[t][0])},destroy:function(){var e=this.option||this;e.listeners.forEach(function(e){return e.destroy()}),e.listeners=[]}}),Xr=(new n({name:"console"}),["log","error","warn","info","debug","trace"]),Yr={log:console.log,error:console.error,warn:console.warn,info:console.info,debug:console.debug,trace:console.trace||console.log};function Qr(e,t){return void 0===t&&(t=2),"number"==typeof e&&Number.isFinite(e)?(t=Math.pow(10,Math.max(0,Math.min(12,Math.floor(t)))),Math.round(e*t)/t):0}function Zr(e,t){return void 0===t&&(t=2048),"string"==typeof e&&e.trim()?e.trim().slice(0,Math.max(1,Math.floor(t))):"unknown"}function eo(e){var t,n=so.get(e);if(n){n.destroyed=!0;try{null!=(t=n.observer)&&t.disconnect()}catch(e){}n.observer=null,n.lagRecords.length=0,e.lifeCycle.remove("destroy",n.onDestroy),so.delete(e)}}var to=new n({name:"console",onNewTdem:function(e){this.startListen(e)},startListen:function(e){var p,f;f="object"==typeof(p=e).config.console?p.config.console:void 0,Xr.forEach(function(u){var d=Yr[u];console[u]=function(){for(var e,t,n,r,o,i,a,s,l=[],c=0;c<arguments.length;c++)l[c]=arguments[c];try{d.apply(console,l),i=u,a=p.isWhiteList,("all"===(s=(null==(s=f)?void 0:s.level)||"error")||a||("error"===s?"error"===i:"warn"===s?"error"===i||"warn"===i:"info"===s?["error","warn","info"].includes(i):"log"===s?["error","warn","info","log"].includes(i):"error"===i))&&(r=l.map(function(e){if("object"==typeof e&&null!==e)try{return JSON.stringify(e)}catch(e){}return String(e)}).join(" "),o={event_id:A(),event_type:P.LOG,event_category:M.LOG,timestamp:Date.now(),page_url:(null==(e=p.getOriginFrom)?void 0:e.call(p))||("undefined"!=typeof window?null==(t=window.location)?void 0:t.href:""),data:{log_level:"error"===u?"error":"warn"===u?"warn":"info",replay_id:x(p),tags:{console_method:u},event_properties:{message:("console."+u+": "+r).slice(0,2048)}}},null!=(n=p.reportTDEMEvent)&&n.call(p,o))}catch(e){Yr.error("Console hook error:",e)}}})},destroy:function(){Object.keys(Yr).forEach(function(e){console[e]=Yr[e]})}}),no=(C.prototype.start=function(){this.isRunning||(document.addEventListener("pointerdown",this.handlePointerDown,!0),document.addEventListener("click",this.handleClick,!0),document.addEventListener("visibilitychange",this.onVisibility),window.addEventListener("pagehide",this.closeRage),window.addEventListener("beforeunload",this.closeRage),this.isRunning=!0)},C.prototype.stop=function(){this.isRunning&&(document.removeEventListener("pointerdown",this.handlePointerDown,!0),document.removeEventListener("click",this.handleClick,!0),document.removeEventListener("visibilitychange",this.onVisibility),window.removeEventListener("pagehide",this.closeRage),window.removeEventListener("beforeunload",this.closeRage),this.cleanupSlowClick(),this.finishRage(),this.isRunning=!1)},C.prototype.handlePointerDown=function(e){var t=this,n=e.target;n&&n instanceof Element&&(n=Vr(n),this.cleanupSlowClick(),this.clickStartTime=Date.now(),this.clickNode=n,(e=this.getExternalNavigationReason(e,n))?"custom"!==e?this.markEffectiveAction(e):this.cleanupSlowClick():(this.slowClickTimeoutId=setTimeout(function(){t.handleSlowClick("timeout")},this.options.slowClickTimeout),this.startMutationObserver()))},C.prototype.handleClick=function(e){var t,n,r,o=this;e.target instanceof Element&&(r=Vr(e.target),t=Date.now(),e={node:this.getNodeInfo(r),target:r,event:e,timestamp:t,effectiveActionReason:this.getExternalNavigationReason(e,r)||void 0},this.cleanupSlowClick(),this.clickNode=r,this.clickStartTime=t,this.slowClickTimeoutId=setTimeout(function(){return o.handleSlowClick("timeout")},this.options.slowClickTimeout),this.startMutationObserver(),this.options.onClickStart(e),e.effectiveActionReason&&"custom"!==e.effectiveActionReason&&this.markEffectiveAction(e.effectiveActionReason),n=this.options.getClickContext(),this.rage&&(this.rage.target!==r||this.rage.context!==n||t-this.rage.lastAt>=this.options.rageClickWindow)&&this.finishRage(),r=this.rage||{target:r,context:n,candidates:[],related:[],count:0,lastAt:t},(this.rage=r).lastAt=t,r.anchor?(r.count++,r.related=h(r.related,[e]).slice(-10)):(r.candidates=h(r.candidates,[e]).filter(function(e){return t-e.timestamp<=o.options.rageClickWindow}).slice(-this.options.rageClickCount),r.candidates.length>=this.options.rageClickCount&&(r.anchor=r.candidates[0],r.count=r.candidates.length,r.related=r.candidates,r.candidates=[])),null!==this.rageTimer&&clearTimeout(this.rageTimer),this.rageTimer=setTimeout(function(){return o.finishRage()},this.options.rageClickWindow))},C.prototype.finishRage=function(){null!==this.rageTimer&&clearTimeout(this.rageTimer),this.rageTimer=null;var e,t=this.rage;(this.rage=null)!=t&&t.anchor&&(e=t.related.includes(t.anchor)?t.related:h([t.anchor],t.related.slice(-9)),this.options.onRageClick({node:t.anchor.node,clickCount:t.count,timeWindowMs:this.options.rageClickWindow,timestamp:t.anchor.timestamp,lastTimestamp:t.lastAt,clicks:e}))},C.prototype.startMutationObserver=function(){var t=this;this.clickNode&&document.body&&"undefined"!=typeof MutationObserver&&(this.mutationObserver=new MutationObserver(function(e){t.hasSignificantMutation(e)&&(t.emitEffectiveAction("dom_mutation"),t.handleSlowClick("mutation"))}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","disabled","aria-hidden","aria-disabled","aria-busy"],characterData:!0}))},C.prototype.hasSignificantMutation=function(e){for(var t=0,n=e;t<n.length;t++){var r=n[t];if("characterData"===r.type)return!0;if("childList"===r.type&&(0<r.addedNodes.length||0<r.removedNodes.length)&&Array.from(r.addedNodes).concat(Array.from(r.removedNodes)).some(function(e){var t;return e.nodeType===Node.TEXT_NODE&&!(null==(t=e.textContent)||!t.trim())||e.nodeType===Node.ELEMENT_NODE&&!["SCRIPT","STYLE","LINK"].includes(e.tagName)}))return!0;if("attributes"===r.type){r=r.attributeName;if(["class","style","hidden","disabled","aria-hidden","aria-disabled","aria-busy"].includes(r||""))return!0}}return!1},C.prototype.handleSlowClick=function(e){var t;this.clickNode&&this.clickStartTime&&((t=Date.now()-this.clickStartTime)>=this.options.slowClickThreshold&&this.options.onSlowClick({node:this.getNodeInfo(this.clickNode),timeAfterClickMs:t,endReason:e,timestamp:this.clickStartTime}),this.cleanupSlowClick())},C.prototype.cleanupSlowClick=function(){this.slowClickTimeoutId&&(clearTimeout(this.slowClickTimeoutId),this.slowClickTimeoutId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.clickStartTime=0,this.clickNode=null},C.prototype.markEffectiveAction=function(e){this.clickNode&&this.clickStartTime&&(this.emitEffectiveAction(e),this.cleanupSlowClick())},C.prototype.emitEffectiveAction=function(e){this.clickNode&&this.options.onEffectiveAction({reason:e,timestamp:Date.now(),node:this.getNodeInfo(this.clickNode)})},C.prototype.getExternalNavigationReason=function(e,t){var n=t.closest("a");if(n){if(n.download)return"download";var r=(n.getAttribute("target")||"").toLowerCase();if(r&&"_self"!==r)return"external_navigation";if(n.href&&(1===e.button||e.metaKey||e.ctrlKey||e.shiftKey))return"external_navigation"}r=t.closest("form"),n=((null==r?void 0:r.getAttribute("target"))||"").toLowerCase();return n&&"_self"!==n?"external_navigation":t.hasAttribute("data-tdem-ignore-dead-click")||t.closest("[data-tdem-ignore-dead-click]")||t.hasAttribute("data-tdem-effective-action")||t.closest("[data-tdem-effective-action]")?"custom":null},C.prototype.getNodeInfo=function(e){var t;return{id:(null==(t=e.__sn)?void 0:t.id)||0,tagName:e.tagName.toLowerCase(),textContent:(e.textContent||"").trim().substring(0,100),selector:this.getSelector(e)}},C.prototype.getSelector=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r,o=n.tagName.toLowerCase();if(n.id){o+="#"+n.id,t.unshift(o);break}n.className&&"string"==typeof n.className&&0<(r=n.className.trim().split(/\s+/).slice(0,2)).length&&(o+="."+r.join(".")),t.unshift(o),n=n.parentElement}return t.join(" > ")},C.prototype.isActive=function(){return this.isRunning},C),k={enabled:!0,ruleVersion:"1.0.0",payloadAllowlist:[],click:{enabled:!0,deadClickWindowMs:3e3,deadClickDebounceIntervalMs:1e3,rageClickWindowMs:3e3,rageClickCount:5,errorClickWindowMs:3e3,resolveOnDomMutation:!0,resolveOnSpaNavigation:!0,resolveOnExternalNavigation:!0,resolveOnWindowOpen:!0,resolveOnPageUnload:!0,resolveOnFormAction:!0,resolveOnApiSuccess:!0,ignoreDeadClickSelectors:[],effectiveActionSelectors:[],clickableSelectors:[]},performance:{enabled:!0,slowPageLcpThreshold:4e3,slowPageInpThreshold:500},form:{enabled:!0,fieldIdAttr:"data-field-id",formIdAttr:"data-form-id",longFocusThresholdMs:2e4,incompleteMinFieldRatio:.3,zigzagMinCount:2},navigation:{enabled:!0,backForwardAsStruggle:!0},custom:{enabled:!0,detector:void 0}},ro=new Set([P.JS_ERROR,P.PROMISE_ERROR,P.RESOURCE_ERROR,P.API_ERROR]),oo=new Set([P.FORM_CHANGE,P.FORM_SUBMIT,P.FORM_SUBMIT_RESULT]),io=(new n({name:"struggleMonitor"}),new n({name:"struggleMonitor",instanceStates:new Map,originalWindowOpen:null,windowOpenHooked:!1,onNewTdem:function(n){var e,t,r,o,i,a,s=this,l=!0===(e=this.$getConfig(n))?O({},k):e&&"object"==typeof e?(t=(void 0===(l=null==(l=e.click)?void 0:l.deadClickDebounceIntervalMs)||Number.isInteger(l)&&1<=l&&l<=6e4)&&null!=l?l:1e3,void 0!==l&&l!==t&&console.warn("struggleMonitor: invalid deadClickDebounceIntervalMs; using 1000ms"),O(O(O({},k),e),{click:O(O(O({},k.click),e.click||{}),{deadClickDebounceIntervalMs:t}),performance:O(O({},k.performance),e.performance||{}),form:O(O({},k.form),e.form||{}),navigation:O(O({},k.navigation),e.navigation||{}),custom:O(O({},k.custom),e.custom||{}),payloadAllowlist:(Array.isArray(e.payloadAllowlist)?e:k).payloadAllowlist,enabled:!1!==e.enabled})):O(O({},k),{enabled:!1});l.enabled&&(r={config:l,clickDetector:null,recentClicks:[],pendingDeadClicks:new Map,latestDead:new Map,clickContexts:new WeakMap,contextKey:this.getClickContextKey(n),closing:!1,focusStartMap:new Map,formStateMap:new Map,removeDomListeners:[],onEventCreated:null,onDestroy:null},this.instanceStates.set(n,r),this.initClickDetector(n,r),this.initFormListeners(n,r),r.onEventCreated=function(e){s.handleEventCreated(n,r,e||[])},n.lifeCycle.on("tdemEventCreated",r.onEventCreated),r.onDestroy=function(){return s.cleanupInstance(n)},n.lifeCycle.on("destroy",r.onDestroy),n.lifeCycle.on("clickCaptured",o=function(e){var t=e.event,n=e.source,e=r.clickContexts.get(t);e&&(e.sourceContext.replayId=String(n.data.replay_id||"")),r.pendingDeadClicks.forEach(function(e){e.event===t&&(e.clickEventId=n.event_id,e.ownerKey=n.data.target_element||e.ownerKey)})}),r.removeDomListeners.push(function(){return n.lifeCycle.remove("clickCaptured",o)}),n.lifeCycle.on("pageChanged",i=function(){return s.closeClickGroups(r)}),r.removeDomListeners.push(function(){return n.lifeCycle.remove("pageChanged",i)}),n.lifeCycle.on("pageVisitChanged",i),r.removeDomListeners.push(function(){return n.lifeCycle.remove("pageVisitChanged",i)}),n.lifeCycle.on("beforeCloseFlush",i),r.removeDomListeners.push(function(){return n.lifeCycle.remove("beforeCloseFlush",i)}),r.removeDomListeners.push("undefined"==typeof window?function(){}:(window.addEventListener("monitor-session-update",a=function(e){var t=e.detail.sessionId;e.detail.source,t!==r.contextKey.split("\n")[0]&&(r.contextKey=s.getClickContextKey(n),s.closeClickGroups(r,!0))}),function(){return window.removeEventListener("monitor-session-update",a)})))},initClickDetector:function(t,n){var e,r=this;"undefined"!=typeof window&&"undefined"!=typeof document&&(n.clickDetector=new no({getClickContext:function(){return r.getClickContextKey(t)},slowClickTimeout:null!=(e=null==(e=n.config.click)?void 0:e.deadClickWindowMs)?e:3e3,slowClickThreshold:null!=(e=null==(e=n.config.click)?void 0:e.deadClickWindowMs)?e:3e3,rageClickCount:null!=(e=null==(e=n.config.click)?void 0:e.rageClickCount)?e:5,rageClickWindow:null!=(e=null==(e=n.config.click)?void 0:e.rageClickWindowMs)?e:3e3,onRageClick:function(e){r.onRageClick(t,n,e)},onClickStart:function(e){r.onClickStart(t,n,e)},onEffectiveAction:function(e){r.onEffectiveAction(t,n,e)},onSlowClick:function(e){r.onSlowClick(t,n,e)}}),n.clickDetector.start(),this.initClickEffectiveActionListeners(n),this.initWindowOpenHook())},initClickEffectiveActionListeners:function(n){var e,t,r=this;"undefined"!=typeof window&&((e=function(e,t){window.addEventListener(e,t),n.removeDomListeners.push(function(){window.removeEventListener(e,t)})})("pagehide",function(){var e;r.closeClickGroups(n),!1!==(null==(e=n.config.click)?void 0:e.resolveOnPageUnload)&&(r.resolvePendingDeadClicks(n,"page_unload"),null!=(e=n.clickDetector))&&e.markEffectiveAction("page_unload")}),e("beforeunload",function(){var e;r.closeClickGroups(n),!1!==(null==(e=n.config.click)?void 0:e.resolveOnPageUnload)&&(r.resolvePendingDeadClicks(n,"page_unload"),null!=(e=n.clickDetector))&&e.markEffectiveAction("page_unload")}),t=function(){"hidden"===document.visibilityState&&r.closeClickGroups(n)},document.addEventListener("visibilitychange",t),n.removeDomListeners.push(function(){return document.removeEventListener("visibilitychange",t)}))},initWindowOpenHook:function(){var r,o;"undefined"==typeof window||this.windowOpenHooked||(r=window.open,this.originalWindowOpen=r,this.windowOpenHooked=!0,o=this,window.open=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=r.apply(window,e);return o.resolveWindowOpenActions(),n})},resolveWindowOpenActions:function(){var r=this,o=Date.now();this.instanceStates.forEach(function(e,t){var n;!1!==(null==(n=e.config.click)?void 0:n.resolveOnWindowOpen)&&(null!=(n=e.clickDetector)&&n.markEffectiveAction("window_open"),r.resolvePendingDeadClicks(e,"window_open",o,t._customPageUrl||r.getCurrentPageUrl()))})},restoreWindowOpenHook:function(){"undefined"!=typeof window&&this.windowOpenHooked&&this.originalWindowOpen&&(window.open=this.originalWindowOpen,this.originalWindowOpen=null,this.windowOpenHooked=!1)},initFormListeners:function(r,o){var e,t,i=this;null!=(t=o.config.form)&&t.enabled&&"undefined"!=typeof document&&((t=function(e,t,n){void 0===n&&(n=!0),document.addEventListener(e,t,n),o.removeDomListeners.push(function(){document.removeEventListener(e,t,n)})})("focusin",function(e){e=i.getTrackableField(e.target);e&&i.reportFormEvent(r,o,P.FORM_FOCUS,e,e.form||void 0)}),t("focusout",function(e){e=i.getTrackableField(e.target);e&&i.reportFormEvent(r,o,P.FORM_BLUR,e,e.form||void 0)}),t("change",function(e){e=i.getTrackableField(e.target);e&&i.reportFormEvent(r,o,P.FORM_CHANGE,e,e.form||void 0)}),t("submit",function(e){e=e.target;e instanceof HTMLFormElement&&i.reportFormEvent(r,o,P.FORM_SUBMIT,null,e)}),t("invalid",function(e){var t,n,e=i.getTrackableField(e.target);e&&(n=e.form||void 0,n=i.buildFormBaseData(r,o,e,n),n={event_id:A(),event_type:P.FORM_SUBMIT_RESULT,event_category:M.BEHAVIOR,timestamp:Date.now(),page_url:"undefined"!=typeof window?window.location.href:(null==(t=r.getOriginFrom)?void 0:t.call(r))||"",data:O(O({},n),{event_name:"form_submit_fail",is_effective_action:!0,validation_message:e.validationMessage||void 0,event_properties:O(O({},n.event_properties||{}),{status:"fail",validation_code:!1===(null==(t=e.validity)?void 0:t.valid)?"invalid":"validation_error"})})},null!=(e=r.reportTDEMEvent))&&e.call(r,n)}),e=function(){i.reportPendingUncompletedForms(r,o,"pagehide")},"undefined"!=typeof window)&&(window.addEventListener("pagehide",e),o.removeDomListeners.push(function(){window.removeEventListener("pagehide",e)}))},getTrackableField:function(e){return!(e&&e instanceof Element)||!(e=e.closest("input, textarea, select"))||e instanceof HTMLInputElement&&["button","submit","reset","image","hidden"].includes(e.type)?null:e},buildFormBaseData:function(e,t,n,r){var n=n||null,r=r||(null==n?void 0:n.form)||void 0,o=(null==(o=t.config.form)?void 0:o.fieldIdAttr)||"data-field-id",t=(null==(t=t.config.form)?void 0:t.formIdAttr)||"data-form-id",o=n?n.getAttribute(o)||n.id||n.name||n.tagName.toLowerCase()+"_"+(n.type||"field"):void 0,t=r&&(r.getAttribute(t)||r.id||r.getAttribute("name")||r.getAttribute("action"))||void 0,i="string"==typeof(null==(i=n)?void 0:i.value)?n.value.length:0,i=0===i?"0":i<=10?"1_10":i<=50?"11_50":"51_plus";return{replay_id:x(e),is_effective_action:!0,form_id:t,field_id:o,tags:{},event_properties:{field_name:(null==n?void 0:n.name)||"",field_type:(null==n?void 0:n.type)||(null==(e=null==n?void 0:n.tagName)?void 0:e.toLowerCase())||"",form_name:(null==r?void 0:r.getAttribute("name"))||"",is_required:String(!(null==n||!n.required)),value_length_bucket:String(i)}}},reportFormEvent:function(e,t,n,r,o){var t=this.buildFormBaseData(e,t,r,o),o="undefined"!=typeof window?window.location.href:(null==(r=e.getOriginFrom)?void 0:r.call(e))||"",r={event_id:A(),timestamp:Date.now(),page_url:o};n!==P.FORM_FOCUS?n!==P.FORM_BLUR?n!==P.FORM_CHANGE?(o=O(O({},r),{event_type:P.FORM_SUBMIT,event_category:M.BEHAVIOR,data:O(O({},t),{submit_method:"native_submit"})}),null!=(n=e.reportTDEMEvent)&&n.call(e,o)):(n=O(O({},r),{event_type:P.FORM_CHANGE,event_category:M.BEHAVIOR,data:t}),null!=(o=e.reportTDEMEvent)&&o.call(e,n)):(o=O(O({},r),{event_type:P.FORM_BLUR,event_category:M.BEHAVIOR,data:t}),null!=(n=e.reportTDEMEvent)&&n.call(e,o)):(n=O(O({},r),{event_type:P.FORM_FOCUS,event_category:M.BEHAVIOR,data:t}),null!=(o=e.reportTDEMEvent)&&o.call(e,n))},onClickStart:function(e,t,n){var r,o,i,a,s=t.config.click||k.click;!1!==s.enabled&&(this.checkClickContext(e,t),r=zr(n.event,e),o={timestamp:n.timestamp,sessionId:ze(e),viewId:String(null!=(o=null!=(o=null!=(o=null==r?void 0:r.view_id)?o:e.viewId)?o:null==(o=e.bean)?void 0:o.viewId)?o:""),replayId:String(null!=(o=null==(o=null==r?void 0:r.data)?void 0:o.replay_id)?o:x(e))},i=e._customPageUrl||(null==r?void 0:r.page_url)||this.getCurrentPageUrl(),t.clickContexts.set(n.event,{pageUrl:i,sourceContext:o}),a=(null==(a=null==r?void 0:r.data)?void 0:a.target_element)||n.node.selector||n.node.tagName||"unknown",this.isDeadClickExempt(n,s)||this.shouldIgnoreDeadClick(n.target,s)||"custom"!==n.effectiveActionReason&&(n.effectiveActionReason&&this.shouldResolveByReason(t,n.effectiveActionReason)?this.resolvePendingDeadClicks(t,n.effectiveActionReason,n.timestamp,i):this.scheduleDeadClick(e,t,{pendingId:"pending_"+n.timestamp+"_"+Math.random().toString(16).slice(2),timestamp:n.timestamp,pageUrl:i,ownerKey:a,node:n.node,target:n.target,event:n.event,groupKey:t.contextKey,debounceIntervalMs:null!=(e=s.deadClickDebounceIntervalMs)?e:1e3,sourceContext:o,clickEventId:null==r?void 0:r.event_id})))},onEffectiveAction:function(e,t,n){this.checkClickContext(e,t),this.shouldResolveByReason(t,n.reason)&&(e=e._customPageUrl||this.getCurrentPageUrl(),this.resolvePendingDeadClicks(t,n.reason,n.timestamp,e))},scheduleDeadClick:function(t,n,r){var o=this,i=null!=(e=null==(e=n.config.click)?void 0:e.deadClickWindowMs)?e:3e3,e=n.latestDead.get(r.target),e=(e&&e.groupKey===r.groupKey&&r.timestamp>=e.timestamp&&r.timestamp-e.timestamp<e.debounceIntervalMs&&(r.debounceIntervalMs=e.debounceIntervalMs,this.removeDeadClick(n,e)),setTimeout(function(){o.checkClickContext(t,n);var e=n.pendingDeadClicks.get(r.pendingId);e&&(o.removeDeadClick(n,e),o.emitDeadClick(t,n,e,i))},Math.max(i,r.debounceIntervalMs))),e=O(O({},r),{timeout:e});n.pendingDeadClicks.set(r.pendingId,e),n.latestDead.set(r.target,e),200<n.pendingDeadClicks.size&&(e=n.pendingDeadClicks.values().next().value)&&this.removeDeadClick(n,e)},removeDeadClick:function(e,t){clearTimeout(t.timeout),e.pendingDeadClicks.delete(t.pendingId),e.latestDead.get(t.target)===t&&e.latestDead.delete(t.target)},getClickContextKey:function(e){var t;return[ze(e),e._customPageUrl||this.getCurrentPageUrl(),null!=(e=null!=(t=e.viewId)?t:null==(t=e.bean)?void 0:t.viewId)?e:""].join("\n")},checkClickContext:function(e,t){var n,e=this.getClickContextKey(e);e!==t.contextKey&&(n=e.split("\n")[0]!==t.contextKey.split("\n")[0],t.contextKey=e,this.closeClickGroups(t,n))},closeClickGroups:function(t,e){var n,r=this;void 0===e&&(e=!1),null!=(n=t.clickDetector)&&n.finishRage(),t.latestDead.clear(),e&&(t.pendingDeadClicks.forEach(function(e){return r.removeDeadClick(t,e)}),t.recentClicks=[])},emitDeadClick:function(e,t,n,r){var o,i=n.clickEventId?[n.clickEventId]:void 0;null!=(o=e.reportStruggle)&&o.call(e,{type:"dead_click",ownerType:"element",ownerKey:n.ownerKey,pageUrl:n.pageUrl,sourceContext:O(O({},n.sourceContext),{timestamp:n.timestamp+r}),triggerEventId:n.clickEventId,relatedEventIds:i,detectionSource:"rule_engine",ruleVersion:t.config.ruleVersion,payloadAllowlist:t.config.payloadAllowlist,payload:{timeout_ms:r,selector:n.node.selector||""}})},resolvePendingDeadClicks:function(n,r,o,i){var e,a=this,s=(void 0===o&&(o=Date.now()),null!=(e=null==(e=n.config.click)?void 0:e.deadClickWindowMs)?e:3e3);n.pendingDeadClicks.forEach(function(e){var t=o-e.timestamp;t<0||s<t||"spa_navigation"!==r&&"page_unload"!==r&&i&&e.pageUrl&&i!==e.pageUrl||a.removeDeadClick(n,e)})},shouldResolveByReason:function(e,t){e=e.config.click||k.click;return!1!==e.enabled&&("dom_mutation"===t?!1!==e.resolveOnDomMutation:"spa_navigation"===t?!1!==e.resolveOnSpaNavigation:"external_navigation"===t||"download"===t?!1!==e.resolveOnExternalNavigation:"window_open"===t?!1!==e.resolveOnWindowOpen:"page_unload"===t?!1!==e.resolveOnPageUnload:"form_change"===t||"form_submit"===t?!1!==e.resolveOnFormAction:"api_success"!==t||!1!==e.resolveOnApiSuccess)},isDeadClickExempt:function(e,t){var e=e.event.target,t=Array.isArray(t.clickableSelectors)?t.clickableSelectors:[];return!(e instanceof Element&&((e,t)=>{if(void 0===t&&(t=[]),e.closest(Wr))return 1;for(var n=0;n<t.length;n++)try{if(t[n]&&e.closest(t[n]))return 1}catch(e){}try{return"pointer"===window.getComputedStyle(e).cursor}catch(e){}})(e,t)&&(!(t=e.closest("[contenteditable]"))||"false"===t.getAttribute("contenteditable"))&&!e.closest('input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]),textarea,select,option,label'))},shouldIgnoreDeadClick:function(t,e){return h(e.ignoreDeadClickSelectors||[],e.effectiveActionSelectors||[]).some(function(e){try{return!!e&&!!t.closest(e)}catch(e){return!1}})},getCurrentPageUrl:function(){return"undefined"==typeof window?"":window.location.href},getEventPageUrl:function(e){return(null==e?void 0:e.page_url)||(null==(e=null==e?void 0:e.data)?void 0:e.page_url)||""},onRageClick:function(t,e,n){var r,o,i,a;!1!==e.config.click.enabled&&(r=n.node.selector||n.node.tagName||"unknown",o=e.clickContexts.get(n.clicks[0].event))&&(i=(a=n.clicks.map(function(e){return zr(e.event,t)})).map(function(e){return null==e?void 0:e.event_id}).filter(Boolean).slice(-10),a={type:"rage_click",ownerType:"element",ownerKey:(null==(a=null==(a=a[0])?void 0:a.data)?void 0:a.target_element)||r,pageUrl:o.pageUrl,sourceContext:O(O({},o.sourceContext),{timestamp:n.lastTimestamp}),triggerEventId:i[0],relatedEventIds:i.length?i:void 0,detectionSource:"rule_engine",ruleVersion:e.config.ruleVersion,payloadAllowlist:e.config.payloadAllowlist,payload:{clickCount:n.clickCount,timeWindowMs:n.timeWindowMs,click_count:n.clickCount,time_window_ms:n.timeWindowMs,selector:n.node.selector||""}},null!=(r=t.reportStruggle))&&r.call(t,a)},onSlowClick:function(e,t,n){},handleEventCreated:function(o,i,e){var t,a=this,s=(this.checkClickContext(o,i),Date.now()),n=i.config.click||k.click,r=Math.max(null!=(t=n.errorClickWindowMs)?t:3e3,null!=(t=n.rageClickWindowMs)?t:3e3,null!=(t=n.deadClickWindowMs)?t:3e3);i.recentClicks=i.recentClicks.filter(function(e){return s-e.timestamp<=r}),e.forEach(function(e){var t,n,r;e&&e.event_type!==P.STRUGGLE&&(t=e.timestamp||s,n=a.getEventPageUrl(e),e.event_type===P.CLICK?(r=(null==(r=e.data)?void 0:r.target_element)||(null==(r=e.data)?void 0:r.target_id)||(null==(r=e.data)?void 0:r.target_class)||"unknown",i.recentClicks.push({eventId:e.event_id,timestamp:t,pageUrl:n,ownerKey:r}),i.recentClicks=i.recentClicks.slice(-200)):(e.event_type===P.PAGE_VIEW&&a.closeClickGroups(i),a.isEffectiveActionEvent(i,e)&&(a.resolvePendingDeadClicks(i,a.getEffectiveActionReason(e),t,n),null!=(r=i.clickDetector)&&r.markEffectiveAction(a.getEffectiveActionReason(e))),ro.has(e.event_type)?a.tryReportErrorClick(o,i,e):e.event_type===P.PAGE_LOAD||e.event_type===P.true?a.tryReportSlowPage(o,i,e):e.event_type===P.FORM_FOCUS?(a.trackFormFocus(i,e),a.trackFormChangeAndZigzag(o,i,e)):e.event_type===P.FORM_CHANGE?a.trackFormChangeAndZigzag(o,i,e):e.event_type===P.FORM_BLUR?a.tryReportLongFocusTime(o,i,e):e.event_type===P.FORM_SUBMIT?a.trackFormSubmitResult(i,e):e.event_type===P.FORM_SUBMIT_RESULT?(a.trackFormSubmitResult(i,e),a.tryReportFormValidationError(o,i,e)):e.event_type===P.PAGE_VIEW&&null!=(n=null==(t=e.data)?void 0:t.event_properties)&&n.navigation_type&&a.tryReportBackForward(o,i,e)),a.tryReportCustomStruggle(o,i,e))})},isEffectiveActionEvent:function(e,t){var n;return!1!==(null==(n=e.config.click)?void 0:n.enabled)&&(t.event_type===P.API_CALL?!1!==(null==(n=e.config.click)?void 0:n.resolveOnApiSuccess):t.event_type===P.PAGE_VIEW&&null!=(n=null==(n=t.data)?void 0:n.event_properties)&&n.navigation_type?!1!==(null==(n=e.config.click)?void 0:n.resolveOnSpaNavigation):oo.has(t.event_type)?!1!==(null==(n=e.config.click)?void 0:n.resolveOnFormAction):!0===(null==(e=t.data)?void 0:e.is_effective_action))},getEffectiveActionReason:function(e){return e.event_type===P.API_CALL?"api_success":e.event_type===P.PAGE_VIEW?"spa_navigation":e.event_type===P.FORM_CHANGE?"form_change":e.event_type===P.FORM_SUBMIT||e.event_type===P.FORM_SUBMIT_RESULT?"form_submit":"custom"},getFormStateKey:function(e,t){return e||t||"unknown_form"},ensureFormState:function(e,t,n){var r=this.getFormStateKey(t,n);return e.formStateMap.has(r)||e.formStateMap.set(r,{formId:t||r,pageUrl:n||"",touchedFieldIds:new Set,requiredFieldIds:new Set,changedFieldIds:new Set,focusPath:[],zigzagHits:0,hasSuccessSubmit:!1,reportedZigzag:!1,reportedUncompleted:!1}),e.formStateMap.get(r)},recordFormTouch:function(e,t){var n,e=this.ensureFormState(e,null==(e=null==t?void 0:t.data)?void 0:e.form_id,null==t?void 0:t.page_url),r=String((null==(r=null==t?void 0:t.data)?void 0:r.field_id)||"");return r&&(e.touchedFieldIds.add(r),!0===(null==(n=t.data)?void 0:n.is_required)&&e.requiredFieldIds.add(r),t.event_type===P.FORM_CHANGE)&&e.changedFieldIds.add(r),null!=t&&t.page_url&&(e.pageUrl=t.page_url),e},trackFormFocus:function(e,t){var n,r=t,o=String((null==(o=null==r?void 0:r.data)?void 0:o.field_id)||"");o&&((n=this.recordFormTouch(e,r)).focusPath.push(o),12<n.focusPath.length&&n.focusPath.shift(),e.focusStartMap.set(o,{timestamp:t.timestamp||Date.now(),eventId:t.event_id,formId:null==(n=null==r?void 0:r.data)?void 0:n.form_id,pageUrl:null==r?void 0:r.page_url}))},trackFormChangeAndZigzag:function(e,t,n){var r,o,i,a,s;n.event_type!==P.FORM_CHANGE?n.event_type!==P.FORM_FOCUS||(s=(o=this.recordFormTouch(t,r=n)).focusPath).length<4||o.reportedZigzag||(i=(s=s.slice(-4))[0],a=s[1],!i)||!a||i===a||i!==s[2]||a!==s[3]||o.changedFieldIds.size<2||(o.zigzagHits+=1,s=null!=(a=null==(i=t.config.form)?void 0:i.zigzagMinCount)?a:2,o.zigzagHits<s)||(o.reportedZigzag=!0,null==(i=e.reportStruggle))||i.call(e,{type:"form_zigzag",ownerType:"form",ownerKey:o.formId,pageUrl:o.pageUrl,formId:o.formId,fieldId:String((null==(a=null==r?void 0:r.data)?void 0:a.field_id)||""),triggerEventId:r.event_id,relatedEventIds:[r.event_id],detectionSource:"rule_engine",ruleVersion:t.config.ruleVersion,payloadAllowlist:t.config.payloadAllowlist,payload:{zigzag_hits:o.zigzagHits,changed_field_count:o.changedFieldIds.size}}):this.recordFormTouch(t,n)},trackFormSubmitResult:function(e,t){t.event_type!==P.FORM_SUBMIT&&t.event_type!==P.FORM_SUBMIT_RESULT||((e=this.recordFormTouch(e,t)).lastSubmitEventId=t.event_id,t.event_type===P.FORM_SUBMIT_RESULT&&"success"===(null==(t=null==(t=t.data)?void 0:t.event_properties)?void 0:t.status)&&(e.hasSuccessSubmit=!0))},reportPendingUncompletedForms:function(t,n,r){var o=this;n.formStateMap.forEach(function(e){o.tryReportUncompletedForm(t,n,e,r)})},tryReportUncompletedForm:function(e,t,n,r){var o,i,a,s;n.reportedUncompleted||n.hasSuccessSubmit||0===n.touchedFieldIds.size||(a=0<(i=n.requiredFieldIds.size)?i:n.touchedFieldIds.size)<=0||(a=n.changedFieldIds.size/a)<(s=null!=(s=null==(s=t.config.form)?void 0:s.incompleteMinFieldRatio)?s:.3)||(n.reportedUncompleted=!0,null==(o=e.reportStruggle))||o.call(e,{type:"uncompleted_form",ownerType:"form",ownerKey:n.formId,pageUrl:n.pageUrl,formId:n.formId,triggerEventId:n.lastSubmitEventId,relatedEventIds:n.lastSubmitEventId?[n.lastSubmitEventId]:void 0,detectionSource:"rule_engine",ruleVersion:t.config.ruleVersion,payloadAllowlist:t.config.payloadAllowlist,payload:{touched_field_count:n.touchedFieldIds.size,changed_field_count:n.changedFieldIds.size,required_field_count:i,changed_ratio:Number(a.toFixed(4)),threshold_ratio:s}})},tryReportLongFocusTime:function(e,t,n){var r,o,i,a,s=String((null==(s=null==n?void 0:n.data)?void 0:s.field_id)||"");s&&(o=t.focusStartMap.get(s))&&(t.focusStartMap.delete(s),i=null!=(i=null==(i=t.config.form)?void 0:i.longFocusThresholdMs)?i:2e4,(a=Math.max((n.timestamp||Date.now())-o.timestamp,0))<i||null==(r=e.reportStruggle)||r.call(e,{type:"long_focus_time",ownerType:"field",ownerKey:s,pageUrl:(null==n?void 0:n.page_url)||o.pageUrl,formId:(null==(r=null==n?void 0:n.data)?void 0:r.form_id)||o.formId,fieldId:s,triggerEventId:n.event_id,relatedEventIds:[o.eventId||"",n.event_id].filter(Boolean),detectionSource:"rule_engine",ruleVersion:t.config.ruleVersion,payloadAllowlist:t.config.payloadAllowlist,payload:{focus_duration_ms:a,threshold_ms:i}}))},tryReportErrorClick:function(e,t,n){var r,o,i;t.recentClicks.length&&(o=null!=(i=(t.config.click||k.click).errorClickWindowMs)?i:3e3,i=h(t.recentClicks).reverse().find(function(e){return 0<=n.timestamp-e.timestamp&&n.timestamp-e.timestamp<=o}))&&null!=(r=e.reportStruggle)&&r.call(e,{type:"error_click",ownerType:"element",ownerKey:i.ownerKey,pageUrl:i.pageUrl||n.page_url,triggerEventId:i.eventId,relatedEventIds:[n.event_id],detectionSource:"rule_engine",ruleVersion:t.config.ruleVersion,payloadAllowlist:t.config.payloadAllowlist,payload:{errorEventType:n.event_type}})},tryReportSlowPage:function(e,t,n){var r,o,i,a=t.config.performance||k.performance;a.enabled&&(o=(null==(o=n.data)?void 0:o.measurements)||{},r=Number(o.lcp||0),o=Number(o.inp||0),i=null!=(i=a.slowPageLcpThreshold)?i:4e3,a=null!=(a=a.slowPageInpThreshold)?a:500,i<=r||a<=o)&&null!=(i=e.reportStruggle)&&i.call(e,{type:"slow_page",ownerType:"page",ownerKey:n.page_url||("undefined"!=typeof window?window.location.href:""),pageUrl:n.page_url,triggerEventId:n.event_id,detectionSource:"rule_engine",ruleVersion:t.config.ruleVersion,payloadAllowlist:t.config.payloadAllowlist,payload:{lcp:r,inp:o,sourceEventType:n.event_type}})},tryReportFormValidationError:function(e,t,n){var r,o,i,a,s=(null==(s=null==n?void 0:n.data)?void 0:s.event_properties)||{},l=(null==n?void 0:n.data)||{};"fail"===String((null==s?void 0:s.status)||(null===(o=l)?void 0:o.status)||"")&&(o=String((null==s?void 0:s.field_id)||(null===(o=l)?void 0:o.field_id)||""),i=String((null==s?void 0:s.form_id)||(null===(i=l)?void 0:i.form_id)||""),a=o||i||(null==n?void 0:n.page_url)||"unknown",null!=(r=e.reportStruggle))&&r.call(e,{type:"form_validation_error",ownerType:o?"field":"form",ownerKey:a,pageUrl:null==n?void 0:n.page_url,formId:i,fieldId:o,triggerEventId:n.event_id,relatedEventIds:[n.event_id],detectionSource:"rule_engine",ruleVersion:t.config.ruleVersion,payloadAllowlist:t.config.payloadAllowlist,payload:{validation_code:(null==s?void 0:s.validation_code)||(null===(r=l)?void 0:r.validation_code),validation_message:null==(e=null==n?void 0:n.data)?void 0:e.validation_message,sourceEventType:n.event_type}})},tryReportBackForward:function(e,t,n){var r,o,i=t.config.navigation||k.navigation;i.enabled&&i.backForwardAsStruggle&&(n=null==(n=null==(i=n)?void 0:i.data)?void 0:n.event_properties,"back"!==(o=String((null==n?void 0:n.navigation_type)||""))&&"forward"!==o||null==(r=e.reportStruggle)||r.call(e,{type:"back_forward",ownerType:"page",ownerKey:String((null==n?void 0:n.to_page)||"")||(null==i?void 0:i.page_url)||"unknown",pageUrl:null==i?void 0:i.page_url,triggerEventId:i.event_id,relatedEventIds:[i.event_id],detectionSource:"rule_engine",ruleVersion:t.config.ruleVersion,payloadAllowlist:t.config.payloadAllowlist,payload:{navigation_type:o,from_page:null==n?void 0:n.from_page,to_page:null==n?void 0:n.to_page}}))},tryReportCustomStruggle:function(n,r,o){var e=r.config.custom||k.custom;e.enabled&&"function"==typeof e.detector&&(e=e.detector({event:o,tdem:n}),(Array.isArray(e)?e:e?[e]:[]).forEach(function(e){var t,e=O(O({},e),{type:(null==e?void 0:e.type)||"custom_struggle",ownerType:(null==e?void 0:e.ownerType)||"app",ownerKey:(null==e?void 0:e.ownerKey)||o.page_url||"custom",ruleVersion:(null==e?void 0:e.ruleVersion)||r.config.ruleVersion,payloadAllowlist:(null==e?void 0:e.payloadAllowlist)||r.config.payloadAllowlist,detectionSource:(null==e?void 0:e.detectionSource)||"custom"});null!=(t=n.reportStruggle)&&t.call(n,e)}))},cleanupInstance:function(e){var t=this.instanceStates.get(e);t&&!t.closing&&(t.closing=!0,this.closeClickGroups(t,!0),t.onEventCreated&&e.lifeCycle.remove("tdemEventCreated",t.onEventCreated),t.onDestroy&&e.lifeCycle.remove("destroy",t.onDestroy),t.clickDetector&&t.clickDetector.stop(),t.pendingDeadClicks.forEach(function(e){clearTimeout(e.timeout)}),t.pendingDeadClicks.clear(),this.reportPendingUncompletedForms(e,t,"destroy"),t.focusStartMap.clear(),t.formStateMap.clear(),t.removeDomListeners.forEach(function(e){return e()}),t.removeDomListeners=[],this.instanceStates.delete(e),0===this.instanceStates.size)&&this.restoreWindowOpenHook()},destroy:function(){var n=this.option||this;n.instanceStates.forEach(function(e,t){n.cleanupInstance(t)}),n.instanceStates.clear(),n.restoreWindowOpenHook()}})),ao={enabled:!0,threshold:2e3,noResponseThreshold:5e3,sampleRate:1},so=new Map,lo=new n({name:"lagMonitor",onNewTdem:function(i,e){t=e,void 0===(r=null!=(n=i.config)&&n.debug?function(e,t){"undefined"!=typeof console&&console.warn&&console.warn("[TDEM] "+e+": "+t+", fallback applied")}:function(){})&&(r=function(){});var t,r,n,a=!1===t?O(O({},ao),{enabled:!1}):!0===t||void 0===t?O({},ao):!t||"object"!=typeof t||Array.isArray(t)?(r("lagMonitor","invalid_type"),O({},ao)):(n=O({},ao),void 0!==t.enabled&&("boolean"==typeof t.enabled?n.enabled=t.enabled:r("lagMonitor.enabled","invalid_type")),n.threshold=(o=function(e,t,n){return void 0===e?n:"number"!=typeof e?(r(t,"invalid_type"),n):Number.isFinite(e)?e<=0?(r(t,"out_of_range"),n):e:(r(t,"invalid_number"),n)})(t.threshold,"lagMonitor.threshold",ao.threshold),n.noResponseThreshold=o(t.noResponseThreshold,"lagMonitor.noResponseThreshold",ao.noResponseThreshold),void 0!==t.sampleRate&&("number"!=typeof t.sampleRate?r("lagMonitor.sampleRate","invalid_type"):Number.isFinite(t.sampleRate)?t.sampleRate<0||1<t.sampleRate?r("lagMonitor.sampleRate","out_of_range"):n.sampleRate=t.sampleRate:r("lagMonitor.sampleRate","invalid_number")),n.noResponseThreshold<=n.threshold&&(n.noResponseThreshold=Math.max(5e3,n.threshold+1),r("lagMonitor.noResponseThreshold","relation_conflict")),n);if(a.enabled&&"undefined"!=typeof PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&PerformanceObserver.supportedEntryTypes.includes("long-animation-frame")&&(o=a.sampleRate,Math.random()<o)){var o,s=[],l={observer:null,lagRecords:s,sampled:!0,destroyed:!1,onDestroy:function(){return eo(i)}};so.set(i,l),i.lifeCycle.on("destroy",l.onDestroy);try{l.observer=new PerformanceObserver(function(e){if(!l.destroyed)try{e.getEntries().forEach(function(e){var t,n,r,o;l.destroyed||e.duration<=a.threshold||(t=null==(t=e.scripts)?void 0:t[0],e={name:e.name,timestamp:Date.now(),entryType:e.entryType,startTime:e.startTime,duration:e.duration,invoker:null==t?void 0:t.invoker,sourceURL:null==t?void 0:t.sourceURL},s.push(e),100<s.length&&s.shift(),t=i,r=(e=e).duration>=(n=a).noResponseThreshold,o=x(t),e={event_id:A(),event_type:r?P.NO_RESPONSE:P.LAG_DETECTED,event_category:r?M.ERROR:M.PERFORMANCE,timestamp:Date.now(),page_url:(null==(r=t.getOriginFrom)?void 0:r.call(t))||window.location.href,data:O(O({measurements:{duration:Qr(e.duration),start_time_ms:Qr(e.startTime),lag_threshold_ms:n.threshold,no_response_threshold_ms:n.noResponseThreshold},event_properties:{entry_type:e.entryType||"long-animation-frame",source_url:Zr(e.sourceURL,2048),invoker:Zr(e.invoker,256)}},o?{replay_id:o}:{}),{tags:{environment:(null==(r=t.config)?void 0:r.env)||"production",version:String((null==(n=t.config)?void 0:n.version)||"")}})},t.reportTDEMEvent(e))})}catch(e){}}),l.observer.observe({type:"long-animation-frame",buffered:!1})}catch(e){eo(i)}}},getLagRecords:function(e){return h((null==(e=so.get(e))?void 0:e.lagRecords)||[])},destroy:function(){Array.from(so.keys()).forEach(eo)}}),co={enabled:!0,containers:["body","html","#app","#root"],ignoreContainers:[],containerMatchers:{tagName:["body","html"],id:["app","root"],className:[]},ignoreMatchers:{tagName:[],id:[],className:[]},detectStartPosition:{x:0,y:0},emptyElementsPercent:70,sameElementsPercent:70,debounceDuration:2e3,everySideSampleNumber:9,disableSameElementsCheck:!0,ignoreElesWhenDomChange:[],reDetectInterval:2e3,samePointDepth:5,customBlankScreenDector:null},uo=["canvas","img","svg","iframe"];function C(e){var t,n=this;void 0===e&&(e={}),this.isRunning=!1,this.clickStartTime=0,this.clickNode=null,this.slowClickTimeoutId=null,this.mutationObserver=null,this.rage=null,this.rageTimer=null,this.closeRage=function(){return n.finishRage()},this.onVisibility=function(){"hidden"===document.visibilityState&&n.finishRage()},this.options={slowClickTimeout:null!=(t=e.slowClickTimeout)?t:7e3,slowClickThreshold:null!=(t=e.slowClickThreshold)?t:3e3,rageClickCount:null!=(t=e.rageClickCount)?t:5,rageClickWindow:null!=(t=e.rageClickWindow)?t:3e3,onSlowClick:e.onSlowClick||function(){},onRageClick:e.onRageClick||function(){},onClickStart:e.onClickStart||function(){},onEffectiveAction:e.onEffectiveAction||function(){},onDeadClick:e.onDeadClick||function(){},getClickContext:e.getClickContext||function(){return window.location.href}},this.handleClick=this.handleClick.bind(this),this.handlePointerDown=this.handlePointerDown.bind(this)}function po(e){var t=e.nodeName.toLowerCase(),n=e.id||"",r=(e="string"==typeof(e=e).className?e.className:e.getAttribute("class")||"").split(" ").filter(Boolean).map(function(e){return"."+e}).join("");return{tagName:t,id:n,className:e,selector:t+(n?"#"+n:"")+r}}function fo(t,e){var n;if(null!=(n=null==e?void 0:e.tagName)&&n.some(function(e){return t.tagName===e.toLowerCase().trim()}))return!0;if(t.id&&null!=(n=null==e?void 0:e.id)&&n.some(function(e){return t.id===e.trim()}))return!0;if(t.className&&null!=(n=null==e?void 0:e.className)&&n.length){var r=t.className.split(" ").map(function(e){return e.trim()}).filter(Boolean);if(e.className.some(function(e){return r.includes(e.trim())}))return!0}return!1}function mo(t,e){return e.some(function(e){return t.selector.includes(e)})}function go(e){return{tagName:h(e.tagName||[]),id:h(e.id||[]),className:h(e.className||[])}}function vo(){return O(O({},co),{containers:h(co.containers),ignoreContainers:h(co.ignoreContainers),containerMatchers:go(co.containerMatchers),ignoreMatchers:go(co.ignoreMatchers),detectStartPosition:O({},co.detectStartPosition),ignoreElesWhenDomChange:h(co.ignoreElesWhenDomChange)})}function ho(e,t){return void 0===t&&(t=2),t=Math.pow(10,t),Math.round(e*t)/t}function yo(e){var t,n=To.get(e);n&&(n.destroyed=!0,n.detectTimer&&clearTimeout(n.detectTimer),n.bodyWaitTimer&&clearTimeout(n.bodyWaitTimer),null!==n.idleCallbackId&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(n.idleCallbackId),n.idleCallbackId=null),null!==n.bodyWaitFrame&&(window.cancelAnimationFrame||clearTimeout)(n.bodyWaitFrame),null!=(t=n.observer)&&t.disconnect(),e.lifeCycle.remove("errorOccurred",n.onErrorOccurred),e.lifeCycle.remove("destroy",n.onDestroy),window.removeEventListener("pagehide",n.handlePageHide),window.removeEventListener("beforeunload",n.handleBeforeUnload),document.removeEventListener("visibilitychange",n.handleVisibilityChange),To.delete(e))}function _o(e,t,n){null!=(e=null==e?void 0:e.config)&&e.debug&&"undefined"!=typeof console&&console.warn("[TDEM] "+t+": "+n+", fallback applied")}function wo(e){return"number"==typeof e&&Number.isFinite(e)}function bo(){var e;try{var t=null==(e=window.performance)?void 0:e.memory;return!t||!wo(t.usedJSHeapSize)||!wo(t.totalJSHeapSize)||!wo(t.jsHeapSizeLimit)||t.usedJSHeapSize<0||t.totalJSHeapSize<0||t.jsHeapSizeLimit<0?null:{used:t.usedJSHeapSize,total:t.totalJSHeapSize,limit:t.jsHeapSizeLimit,ratio:0<t.jsHeapSizeLimit?Math.min(1,t.usedJSHeapSize/t.jsHeapSizeLimit):0}}catch(e){return null}}function Eo(e){var t=Ro.get(e);t&&(t.destroyed=!0,t.reportTimer&&clearInterval(t.reportTimer),t.oomCheckTimer&&clearInterval(t.oomCheckTimer),t.records.length=0,e.lifeCycle.remove("destroy",t.onDestroy),"undefined"!=typeof window&&(window.removeEventListener("pagehide",t.onPageExit),window.removeEventListener("beforeunload",t.onPageExit)),Ro.delete(e))}function So(e,t,n){var r,o,i;t.destroyed||(o=bo())&&(t.records.push(o),50<t.records.length&&t.records.shift(),i=x(e),n={event_id:A(),event_type:n,event_category:M.PERFORMANCE,timestamp:Date.now(),page_url:(null==(r=e.getOriginFrom)?void 0:r.call(e))||window.location.href,data:O(O({measurements:O({used_js_heap_size_bytes:o.used,total_js_heap_size_bytes:o.total,js_heap_size_limit_bytes:o.limit,usage_ratio:o.ratio},n===P.MEMORY_OOM?{oom_threshold_mb:t.config.oomThreshold}:{}),event_properties:{detection_source:"performance_memory"}},i?{replay_id:i}:{}),{tags:{environment:(null==(r=e.config)?void 0:r.env)||"production",version:String((null==(o=e.config)?void 0:o.version)||"")}})},e.reportTDEMEvent(n))}var To=new Map,ko=new n({name:"blankScreen",onNewTdem:function(E,e){var S,T,k,C,R,t,I,n,r,o,i,a,s,l,c,u,d,p,f,m,g,v=this;"undefined"!=typeof document&&document.elementsFromPoint&&(e=e,void 0===(s=null!=(g=E.config)&&g.debug?function(e,t){"undefined"!=typeof console&&console.warn&&console.warn("[TDEM] "+e+": "+t+", fallback applied")}:function(){})&&(s=function(){}),g=vo(),(S=!1===e?O(O({},g),{enabled:!1}):!0===e||void 0===e?g:!e||"object"!=typeof e||Array.isArray(e)?(s("blankScreen","invalid_type"),g):(l="containerMatchers"in(e=e)||"ignoreMatchers"in e,m="containers"in e||"ignoreContainers"in e,c=function(e,t,n,r){return void 0===e?h(t):Array.isArray(e)&&e.length<=100&&e.every(function(e){return"string"==typeof e&&0<e.trim().length&&e.trim().length<=r})?e.map(function(e){return e.trim()}):(s(n,"invalid_array"),h(t))},f=function(e,t,n){return void 0===e?go(t):!e||"object"!=typeof e||Array.isArray(e)?(s(n,"invalid_type"),go(t)):{tagName:c((e=e).tagName,t.tagName||[],n+".tagName",128),id:c(e.id,t.id||[],n+".id",128),className:c(e.className,t.className||[],n+".className",128)}},u=function(e,t,n,r){return void 0===e?t:"number"!=typeof e?(s(n,"invalid_type"),t):Number.isFinite(e)?r(e)?e:(s(n,"out_of_range"),t):(s(n,"invalid_number"),t)},d=function(e,t,n,r,o){return u(e,t,n,function(e){return Number.isInteger(e)&&r<=e&&e<=o})},p=vo(),void 0!==e.enabled&&("boolean"==typeof e.enabled?p.enabled=e.enabled:s("blankScreen.enabled","invalid_type")),p.containers=c(e.containers,g.containers,"blankScreen.containers",256),p.ignoreContainers=c(e.ignoreContainers,g.ignoreContainers,"blankScreen.ignoreContainers",256),p.containerMatchers=f(e.containerMatchers,g.containerMatchers,"blankScreen.containerMatchers"),p.ignoreMatchers=f(e.ignoreMatchers,g.ignoreMatchers,"blankScreen.ignoreMatchers"),m&&!l&&(p.containerMatchers={tagName:[],id:[],className:[]},p.ignoreMatchers={tagName:[],id:[],className:[]}),void 0===(f=e.detectStartPosition)||f&&"object"==typeof f&&!Array.isArray(f)?p.detectStartPosition={x:u((m=f||{}).x,g.detectStartPosition.x,"blankScreen.detectStartPosition.x",function(e){return 0<=e}),y:u(m.y,g.detectStartPosition.y,"blankScreen.detectStartPosition.y",function(e){return 0<=e})}:s("blankScreen.detectStartPosition","invalid_type"),p.emptyElementsPercent=u(e.emptyElementsPercent,g.emptyElementsPercent,"blankScreen.emptyElementsPercent",function(e){return 0<e&&e<=100}),p.sameElementsPercent=u(e.sameElementsPercent,g.sameElementsPercent,"blankScreen.sameElementsPercent",function(e){return 0<e&&e<=100}),p.debounceDuration=u(e.debounceDuration,g.debounceDuration,"blankScreen.debounceDuration",function(e){return 0<=e}),p.reDetectInterval=u(e.reDetectInterval,g.reDetectInterval,"blankScreen.reDetectInterval",function(e){return 0<e}),p.everySideSampleNumber=d(e.everySideSampleNumber,g.everySideSampleNumber,"blankScreen.everySideSampleNumber",2,50),p.samePointDepth=d(e.samePointDepth,g.samePointDepth,"blankScreen.samePointDepth",1,20),void 0!==e.disableSameElementsCheck&&("boolean"==typeof e.disableSameElementsCheck?p.disableSameElementsCheck=e.disableSameElementsCheck:s("blankScreen.disableSameElementsCheck","invalid_type")),p.ignoreElesWhenDomChange=c(e.ignoreElesWhenDomChange,g.ignoreElesWhenDomChange,"blankScreen.ignoreElesWhenDomChange",256),void 0!==e.customBlankScreenDector&&(null===e.customBlankScreenDector||"function"==typeof e.customBlankScreenDector?p.customBlankScreenDector=e.customBlankScreenDector:s("blankScreen.customBlankScreenDector","invalid_type")),p)).enabled)&&(l=((e,t,n)=>({totalSamplePoints:e=4*e-3,whitePointThreshold:Math.floor(e*t/100),samePointThreshold:Math.floor(e*n/100)}))(S.everySideSampleNumber,S.emptyElementsPercent,S.sameElementsPercent),T=l.totalSamplePoints,k=l.whitePointThreshold,C=l.samePointThreshold,R={observer:null,detectTimer:null,bodyWaitTimer:null,bodyWaitFrame:null,idleCallbackId:null,destroyed:!1,initialDetectionPending:!0,incidentStatus:"healthy",preDetectResult:null,triggerType:"dom_change",onErrorOccurred:function(){},onDestroy:function(){return yo(E)},handlePageHide:function(){},handleBeforeUnload:function(){},handleVisibilityChange:function(){}},To.set(E,R),t=function(){return j(v,void 0,void 0,function(){var c,u,d,p,f,m,g,v,h,y,_,w,b;return W(this,function(e){var t,n,r,o,i,a,s,l;if(!R.destroyed)try{if("initial_load"===R.triggerType&&(R.initialDetectionPending=!1),c=window.innerHeight,u=window.innerWidth,d=S.detectStartPosition,p=d.x,f=d.y,u<=p||c<=f)return[2];if(m=[],v=g=0,((e,t,n,r)=>{for(var o=r.x,i=r.y,a=o+(e-o)/2,s=i+(t-i)/2,l=n+1,c=[],u=1;u<l;u+=1){var d=o+(e-o)*u/l,p=i+(t-i)*u/l;c.push({x:d,y:s}),u!==l/2&&c.push({x:a,y:p},{x:d,y:p},{x:d,y:t-p})}return c})(u,c,S.everySideSampleNumber,S.detectStartPosition).forEach(function(e){a=e.x,s=e.y,e=document.elementsFromPoint(a,s),e=(l=function(e){var t=e[0];if(t&&null!==t.shadowRoot){t=(null==(t=t.shadowRoot)?void 0:t.elementsFromPoint(a,s))||[];if(t.length>e.length)return l(t)}return e})(e),t=S.containers,n=S.ignoreContainers,r=S.containerMatchers,o=S.ignoreMatchers,e=e.map(po),i=e.map(function(e){return e.selector});var t,n,r,o,i,a,s,l,c=(e=e[0])?(r=(c=!(!r||!(null!=(c=r.tagName)&&c.length||null!=(c=r.id)&&c.length||null!=(c=r.className)&&c.length)))?fo(e,r):mo(e,t),t=c?fo(e,o):mo(e,n),{isWhitePoint:r&&!t,selectorPointers:i}):{isWhitePoint:!1,selectorPointers:i};c.isWhitePoint&&(g+=1),m.push(c.selectorPointers)}),h=k<=g,y=!1,S.disableSameElementsCheck||(_=m.map(function(e){return e.slice(0,S.samePointDepth)}),i={},_.map(function(e){return e.join(" < ")}).forEach(function(e){i[e]=i[e]?i[e]+1:1}),a=Object.keys(i).map(function(e){return[e,i[e]]}).sort(function(e,t){return t[1]-e[1]})[0]||["",0],s=a[0],w={samePointerMap:i,maximumSamePointerClass:s,maximumSamePointerCounter:a[1]},y=C<=(v=w.maximumSamePointerCounter)&&(l=w.maximumSamePointerClass,!uo.some(function(e){return l.startsWith(e)}))),b=!1,S.customBlankScreenDector)try{b=!0===S.customBlankScreenDector()}catch(e){b=!1}if(!(h||y||b))return R.incidentStatus="healthy",R.preDetectResult=null,[2];if("reported"===R.incidentStatus)return[2];if("suspect"===R.incidentStatus&&R.preDetectResult)return t=R.preDetectResult,r=t.customTriggered?"custom":t.whitePointTriggered&&t.sameElementTriggered?"both":t.whitePointTriggered?"white_point":"same_element",o=x(E),t={event_id:A(),event_type:P.BLANK_SCREEN,event_category:M.ERROR,timestamp:Date.now(),page_url:(null==(n=E.getOriginFrom)?void 0:n.call(E))||window.location.href,data:O(O({measurements:{white_point_count:t.whitePointCount,same_point_count:t.samePointCount,total_sample_points:T,white_point_threshold:k,same_point_threshold:C,white_point_ratio:ho(t.whitePointCount/T,6),same_point_ratio:ho(t.samePointCount/T,6),viewport_width_px:Math.max(0,Math.round(window.innerWidth)),viewport_height_px:Math.max(0,Math.round(window.innerHeight))},event_properties:{trigger_reason:r,trigger_type:t.triggerType,detection_method:t.customTriggered?"custom_detector":"viewport_sampling",same_elements_check_enabled:String(!S.disableSameElementsCheck)}},o?{replay_id:o}:{}),{tags:{environment:(null==(n=E.config)?void 0:n.env)||"production",version:String((null==(r=E.config)?void 0:r.version)||"")}})},E.reportTDEMEvent(t),R.incidentStatus="reported",R.preDetectResult=null,[2];R.preDetectResult={whitePointCount:g,samePointCount:v,whitePointTriggered:h,sameElementTriggered:y,customTriggered:b,triggerType:R.triggerType},R.incidentStatus="suspect",R.detectTimer=setTimeout(function(){R.detectTimer=null,I()},S.reDetectInterval)}catch(e){}return[2]})})},I=function(){return j(v,void 0,void 0,function(){return W(this,function(e){switch(e.label){case 0:if(R.destroyed)return[2];if("function"!=typeof window.requestIdleCallback)return[3,5];e.label=1;case 1:return e.trys.push([1,2,,4]),R.idleCallbackId=window.requestIdleCallback(function(e){R.idleCallbackId=null,R.destroyed||(0<e.timeRemaining()?t():R.detectTimer=setTimeout(function(){R.detectTimer=null,t()},0))}),[3,4];case 2:return e.sent(),[4,t()];case 3:return e.sent(),[3,4];case 4:return[3,7];case 5:return[4,t()];case 6:e.sent(),e.label=7;case 7:return[2]}})})},n=function(e){void 0===e&&(e="dom_change"),R.destroyed||"suspect"===R.incidentStatus||"initial_load"!==e&&R.initialDetectionPending||(R.triggerType=e,R.detectTimer&&clearTimeout(R.detectTimer),R.detectTimer=setTimeout(function(){R.detectTimer=null,I()},S.debounceDuration))},R.onErrorOccurred=function(){return n("error")},E.lifeCycle.on("errorOccurred",R.onErrorOccurred),E.lifeCycle.on("destroy",R.onDestroy),r=function(){!R.destroyed&&document.body&&(R.observer=new MutationObserver(function(e){var t=null==(t=e[0])?void 0:t.target;if(1===e.length&&t instanceof Element){e=po(t).selector;if(S.ignoreElesWhenDomChange.includes(e))return}n("dom_change")}),R.observer.observe(document.body,{childList:!0,subtree:!0}))},document.body?r():(o=window.requestAnimationFrame||function(e){return setTimeout(e,1e3/60)},i=function(){document.body?(R.bodyWaitTimer&&clearTimeout(R.bodyWaitTimer),r()):R.bodyWaitFrame=o(i)},R.bodyWaitFrame=o(i),R.bodyWaitTimer=setTimeout(function(){null!==R.bodyWaitFrame&&((window.cancelAnimationFrame||clearTimeout)(R.bodyWaitFrame),R.bodyWaitFrame=null)},1e4)),R.handlePageHide=a=function(){R.destroyed||(R.detectTimer&&clearTimeout(R.detectTimer),R.triggerType="page_state",R.preDetectResult&&(R.preDetectResult.triggerType="page_state"),t())},R.handleBeforeUnload=a,R.handleVisibilityChange=function(){"hidden"===document.visibilityState&&a()},window.addEventListener("pagehide",R.handlePageHide),window.addEventListener("beforeunload",R.handleBeforeUnload),document.addEventListener("visibilitychange",R.handleVisibilityChange),n("initial_load"))},destroy:function(){Array.from(To.keys()).forEach(yo)}}),Co={enabled:!0,enableMemoryReport:!0,enableOOMReport:!0,oomThreshold:100,memoryReportInterval:6e4,oomCheckInterval:1e4,monitorPages:[],sampleRate:1},Ro=new Map,Io=new n({name:"memoryMonitor",onNewTdem:function(n,e){var r,t,o=((e,n)=>{var r,o;return!1===e?O(O({},Co),{enabled:!1}):(r=e&&"object"==typeof e?e:{},void 0===e||!0===e||e&&"object"==typeof e&&!Array.isArray(e)||_o(n,"memoryMonitor","invalid_type"),o=O(O({},Co),{oomThreshold:0<(e=(null==(e=bo())?void 0:e.limit)||0)?Math.round(e/1024/1024*.9):100}),["enabled","enableMemoryReport","enableOOMReport"].forEach(function(e){void 0!==r[e]&&("boolean"==typeof r[e]?o[e]=r[e]:_o(n,"memoryMonitor."+e,"invalid_type"))}),["oomThreshold","memoryReportInterval","oomCheckInterval"].forEach(function(e){var t=r[e];void 0!==t&&(wo(t)&&0<t?o[e]=t:_o(n,"memoryMonitor."+e,wo(t)?"out_of_range":"invalid_number"))}),void 0!==r.sampleRate&&(wo(r.sampleRate)&&0<=r.sampleRate&&r.sampleRate<=1?o.sampleRate=r.sampleRate:_o(n,"memoryMonitor.sampleRate","out_of_range")),void 0!==r.monitorPages&&(Array.isArray(r.monitorPages)&&r.monitorPages.length<=100&&r.monitorPages.every(function(e){return"string"==typeof e&&!!e||e instanceof RegExp})?o.monitorPages=h(r.monitorPages):_o(n,"memoryMonitor.monitorPages","invalid_value")),o)})(e,n);!o.enabled||!(()=>{var e;try{return"undefined"!=typeof window&&null!=(e=window.performance)&&e.memory}catch(e){}})()||Math.random()>=o.sampleRate||(e=o.monitorPages).length&&(t="undefined"==typeof window?"":window.location.href,!e.some(function(e){return"string"==typeof e?t.includes(e):(e.lastIndex=0,e.test(t))}))||(r={config:o,reportTimer:null,oomCheckTimer:null,lastOOMTime:0,records:[],destroyed:!1,onDestroy:function(){return Eo(n)},onPageExit:function(){return Eo(n)}},Ro.set(n,r),n.lifeCycle.on("destroy",r.onDestroy),"undefined"!=typeof window&&(window.addEventListener("pagehide",r.onPageExit),window.addEventListener("beforeunload",r.onPageExit)),o.enableMemoryReport&&(r.reportTimer=setInterval(function(){return So(n,r,P.MEMORY_USAGE)},o.memoryReportInterval)),o.enableOOMReport&&(r.oomCheckTimer=setInterval(function(){var e=bo(),t=Date.now();e&&e.used/1024/1024>o.oomThreshold&&3e5<t-r.lastOOMTime&&(r.lastOOMTime=t,So(n,r,P.MEMORY_OOM))},o.oomCheckInterval)))},destroy:function(){Array.from(Ro.keys()).forEach(Eo)}});function Oo(e){return Number.isNaN(e)?0:Math.max(0,Math.min(1,e))}function Po(e){return Oo((e=e,(Number.isNaN(e)?0:Math.max(0,Math.min(100,e)))/100))}function Mo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ao(e,t){try{var n={projectKey:e,document:t,timestamp:Date.now()};localStorage.setItem("TDEM_SAMPLE_CONFIG",JSON.stringify(n))}catch(e){}}function xo(e){var t;try{var n,r=localStorage.getItem("TDEM_SAMPLE_CONFIG");return r?!((n=JSON.parse(r)).projectKey!==e||6048e5<=Date.now()-n.timestamp)&&null!=(t=n.document)&&t.event?n.document:null:null}catch(e){return null}}function Do(e,t){try{var n=e.config.sessionReplay,r=t,o=(!1===n&&(r=O(O({},t),{replay:O(O({},t.replay),{enabled:!1})})),e._tdemSampleConfig=r,e._tdemSampleGate||null);null!=o&&o.decide(!0),i=e,d=(null==r?void 0:r.replay)||{},p={},"boolean"==typeof d.enabled&&(p.enabled=d.enabled),void 0!==d.experience_sample_rate&&(p.experience_sample_rate=Number(d.experience_sample_rate)),"boolean"==typeof d.error_traceback&&(p.error_traceback=d.error_traceback),void 0!==d.error_sample_rate&&(p.error_sample_rate=Number(d.error_sample_rate)),a=p,s=i.config.sessionReplay,a=a,s=!1===(s=s)||void 0===s?{enabled:!1,sessionSampleRate:.1,errorSampleRate:1,errorTraceback:!0}:!0===s?{enabled:!0,sessionSampleRate:.1,errorSampleRate:1,errorTraceback:!0}:{enabled:!1!==s.enabled,sessionSampleRate:"number"==typeof s.sessionSampleRate?Oo(s.sessionSampleRate):.1,errorSampleRate:"number"==typeof s.errorSampleRate?Oo(s.errorSampleRate):1,errorTraceback:void 0===s.errorTraceback||!!s.errorTraceback},l=s.enabled,(a=a&&"object"==typeof a?a:null)&&Mo(a,"enabled")&&(l=s.enabled&&!!a.enabled),c=s.sessionSampleRate,u=s.errorSampleRate,s=s.errorTraceback,l&&a&&(Mo(a,"experience_sample_rate")&&null!=a.experience_sample_rate?c=Po(Number(a.experience_sample_rate)):Mo(a,"replay_sample_rate")&&null!=a.replay_sample_rate&&(c=Po(Number(a.replay_sample_rate))),Mo(a,"error_traceback")&&null!=a.error_traceback&&(s=!!a.error_traceback),Mo(a,"error_sample_rate"))&&null!=a.error_sample_rate&&(u=Po(Number(a.error_sample_rate))),a={enabled:l,sessionSampleRate:c,errorSampleRate:s?u:0,errorTraceback:s},i._effectiveReplayPolicy=a,i._replaySampled=a.enabled,u=null==(c=null==(l=i.constructor.installedPlugins)?void 0:l.find)?void 0:c.call(l,function(e){return e&&"sessionReplay"===e.name}),"function"==typeof(i=null==(s=null==u?void 0:u.option)?void 0:s.applyEffectivePolicy)&&i.call(u.option,a)}catch(t){console.warn("[TDEM] sample config apply failed",t),e._tdemSampleConfig=Ye}var i,a,s,l,c,u,d,p}function No(e,t){var n=e.config.sampleConfigPreference||"remote-first",e=e.config.sampleConfig,r=n||"remote-first";try{return"local-first"===r?e||t||Ye:t||e||Ye}catch(n){return e||Ye}}var Lo,n=new n({name:"tdemConfig",onNewTdem:function(e){try{var t=e._prefetchedConfigData;null!=t&&t.event?Do(e,No(e,t)):Do(e,No(e,null)),function(a){var s;j(this,void 0,void 0,function(){var n,r,o,i;return W(this,function(e){switch(e.label){case 0:if(n=a.config.id,null!=(r=a._prefetchedConfigData)&&r.event)return delete a._prefetchedConfigData,o=No(a,r),n&&Ao(n,o),Do(a,o),[2];if(!n)return Do(a,No(a,null)),[2];if(t=(a.config.url||"").replace(/\/+$/,""),!(r=t?t+"/api/v1/sample-config":""))return Do(a,No(a,xo(n))),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.transportRequest({kind:"config",url:r,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_key:n})})];case 2:if(!(i=e.sent()).ok)throw new Error("HTTP "+i.status);if(0===(i="string"==typeof i.body?JSON.parse(i.body):i.body).code&&null!=(s=i.data)&&s.event)return o=No(a,i.data),Ao(n,o),Do(a,o),[2];throw new Error("API error: code="+i.code);case 3:return i=e.sent(),console.warn("[TDEM] Failed to fetch sample-config:",i),Do(a,No(a,xo(n))),[3,4];case 4:return[2]}var t})})}(e)}catch(t){console.warn("[TDEM] tdemConfig init failed",t),Do(e,Ye)}}}),Ot=(S.entryName="tdem-web-sdk/core",S.use(Ot),S.use(Sr),S.use(Mt),S.use(An),S.use(On),S.use(Cr),S.use(p),S.use(Or),S.use(jr),S.use(Pr),S.use(to),S.use(kr),S.use(n),S.use(io),S.use(lo),S.use(ko),S.use(Io),U(Fo,Lo=S),Fo);function Fo(e,t){t=Lo.call(this,e,t)||this;return e&&void 0!==e.sessionReplay&&console.warn("[TDEM] core ignores sessionReplay; use tdem-web-sdk for replay."),t}return R.default=Ot,R.registerCgiRequestFinalizer=sr,Object.defineProperty(R,"__esModule",{value:!0}),R})({});