@ekko-earth/ekko-js
Version:
A framework-agnostic web SDK for displaying carbon impact.
1 lines • 58.8 kB
JavaScript
const e={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},t=console,n={};Object.keys(e).forEach((e=>{n[e]=t[e]}));const o="Datadog Browser SDK:",r={debug:n.debug.bind(t,o),log:n.log.bind(t,o),info:n.info.bind(t,o),warn:n.warn.bind(t,o),error:n.error.bind(t,o)},i="https://docs.datadoghq.com",s=`${i}/real_user_monitoring/browser/troubleshooting`,a="More details:";function c(e,t){return(...n)=>{try{return e(...n)}catch(e){r.error(t,e)}}}function u(e){return 0!==e&&100*Math.random()<=e}const l=1e3,d=6e4;function f(){return(new Date).getTime()}function p(){return f()}function g(){return performance.now()}function m(){return{relative:g(),timeStamp:p()}}let h;function y(){return void 0===h&&(h=performance.timing.navigationStart),h}const b=1024,v=/[^\u0000-\u007F]/;function w(e){return v.test(e)?void 0!==window.TextEncoder?(new TextEncoder).encode(e).length:new Blob([e]).size:e.length}function S(e,t){return Object.keys(e).some((n=>e[n]===t))}function k(e){return 0===Object.keys(e).length}function C(){if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get(){return this},configurable:!0});let e=_dd_temp_;return delete Object.prototype._dd_temp_,"object"!=typeof e&&(e="object"==typeof self?self:"object"==typeof window?window:{}),e}function x(e,t){const n=C();let o;return n.Zone&&"function"==typeof n.Zone.__symbol__&&(o=e[n.Zone.__symbol__(t)]),o||(o=e[t]),o}let _,E=!1;function T(e){E=e}function $(e){return function(){return R(e,this,arguments)}}function R(e,t,n){try{return e.apply(t,n)}catch(e){L(e)}}function L(e){if(I(e),_)try{_(e)}catch(e){I(e)}}function I(...e){E&&r.error("[MONITOR]",...e)}function O(e,t){return x(C(),"setTimeout")($(e),t)}function A(e){x(C(),"clearTimeout")(e)}function P(e,t){return x(C(),"setInterval")($(e),t)}function D(e){x(C(),"clearInterval")(e)}class U{constructor(e){this.onFirstSubscribe=e,this.observers=[]}subscribe(e){return this.observers.push(e),1===this.observers.length&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe(this)||void 0),{unsubscribe:()=>{this.observers=this.observers.filter((t=>e!==t)),!this.observers.length&&this.onLastUnsubscribe&&this.onLastUnsubscribe()}}}notify(e){this.observers.forEach((t=>t(e)))}}function M(...e){return new U((t=>{const n=e.map((e=>e.subscribe((e=>t.notify(e)))));return()=>n.forEach((e=>e.unsubscribe()))}))}function q(e,t,n){let o,r,i=!1;return{throttled:(...n)=>{i?o=n:(e(...n),i=!0,r=O((()=>{o&&e(...o),i=!1,o=void 0}),t))},cancel:()=>{A(r),i=!1,o=void 0}}}function B(){}function j(e){return e?(parseInt(e,10)^16*Math.random()>>parseInt(e,10)/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,j)}const N=/([\w-]+)\s*=\s*([^;]+)/g;function F(e,t,n=""){const o=e.charCodeAt(t-1),r=o>=55296&&o<=56319?t+1:t;return e.length<=r?e:`${e.slice(0,r)}${n}`}function H(){return 0===(null!=z?z:z=function(e=window){var t;const n=e.navigator.userAgent;return e.chrome||/HeadlessChrome/.test(n)?0:0===(null===(t=e.navigator.vendor)||void 0===t?void 0:t.indexOf("Apple"))||/safari/i.test(n)&&!/chrome|android/i.test(n)?1:2}())}let z,G,W;function J(e,t,n=0,o){const r=new Date;r.setTime(r.getTime()+n);const i=`expires=${r.toUTCString()}`,s=o&&o.crossSite?"none":"strict",a=o&&o.domain?`;domain=${o.domain}`:"",c=o&&o.secure?";secure":"",u=o&&o.partitioned?";partitioned":"";document.cookie=`${e}=${t};${i};path=/;samesite=${s}${a}${c}${u}`}function V(e){return function(e,t){for(N.lastIndex=0;;){const n=N.exec(e);if(!n)break;if(n[1]===t)return n[2]}}(document.cookie,e)}function Y(e){return G||(G=function(e){const t=new Map;for(N.lastIndex=0;;){const n=N.exec(e);if(!n)break;t.set(n[1],n[2])}return t}(document.cookie)),G.get(e)}function X(e,t){J(e,"",0,t)}const Z="_dd_s";function K(e){return Object.values(e)}const Q=144e5,ee=9e5,te=31536e6,ne="cookie",oe="local-storage",re=/^([a-zA-Z]+)=([a-z0-9-]+)$/;function ie(e,t){const n={isExpired:"1"};return t.trackAnonymousUser&&((null==e?void 0:e.anonymousId)?n.anonymousId=null==e?void 0:e.anonymousId:n.anonymousId=j()),n}function se(e){return k(e)}function ae(e){return!se(e)}function ce(e){return void 0!==e.isExpired||!((void 0===(t=e).created||f()-Number(t.created)<Q)&&(void 0===t.expire||f()<Number(t.expire)));var t}function ue(e){e.expire=String(f()+ee)}function le(e){return(t=e,Object.entries(t)).map((([e,t])=>"anonymousId"===e?`aid=${t}`:`${e}=${t}`)).join("&");var t}function de(e){const t={};return function(e){return!!e&&(-1!==e.indexOf("&")||re.test(e))}(e)&&e.split("&").forEach((e=>{const n=re.exec(e);if(null!==n){const[,e,o]=n;"aid"===e?t.anonymousId=o:t[e]=o}})),t}function fe(e){const t=function(e){const t={};t.secure=!!e.useSecureSessionCookie||!!e.usePartitionedCrossSiteSessionCookie,t.crossSite=!!e.usePartitionedCrossSiteSessionCookie,t.partitioned=!!e.usePartitionedCrossSiteSessionCookie,e.trackSessionAcrossSubdomains&&(t.domain=function(){if(void 0===W){const e=`dd_site_test_${j()}`,t="test",n=window.location.hostname.split(".");let o=n.pop();for(;n.length&&!V(e);)o=`${n.pop()}.${o}`,J(e,t,l,{domain:o});X(e,{domain:o}),W=o}return W}());return t}(e);return function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{const t=`dd_cookie_test_${j()}`,n="test";J(t,n,d,e);const o=V(t)===n;return X(t,e),o}catch(e){return r.error(e),!1}}(t)?{type:ne,cookieOptions:t}:void 0}function pe(e,t){const n={isLockEnabled:H(),persistSession:(o=t,e=>{J(Z,le(e),ee,o)}),retrieveSession:ge,expireSession:n=>function(e,t,n){const o=ie(t,n);J(Z,le(o),n.trackAnonymousUser?te:Q,e)}(t,n,e)};var o;return function(e){if(!Y(Z)){const t=Y("_dd"),n=Y("_dd_r"),o=Y("_dd_l"),r={};t&&(r.id=t),o&&/^[01]$/.test(o)&&(r.logs=o),n&&/^[012]$/.test(n)&&(r.rum=n),ae(r)&&(ue(r),e.persistSession(r))}}(n),n}function ge(){return de(V(Z))}function me(){try{const e=j(),t=`_dd_test_${e}`;localStorage.setItem(t,e);const n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:oe}:void 0}catch(e){return}}function he(e){return{isLockEnabled:!1,persistSession:ye,retrieveSession:be,expireSession:t=>function(e,t){ye(ie(e,t))}(t,e)}}function ye(e){localStorage.setItem(Z,le(e))}function be(){return de(localStorage.getItem(Z))}const ve=[];let we;function Se(e,t,n=0){var o;const{isLockEnabled:r,persistSession:i,expireSession:s}=t,a=e=>i({...e,lock:u}),c=()=>{const e=t.retrieveSession(),n=e.lock;return e.lock&&delete e.lock,{session:e,lock:n}};if(we||(we=e),e!==we)return void ve.push(e);if(r&&n>=100)return void Ce(t);let u,l=c();if(r){if(l.lock)return void ke(e,t,n);if(u=j(),a(l.session),l=c(),l.lock!==u)return void ke(e,t,n)}let d=e.process(l.session);if(r&&(l=c(),l.lock!==u))ke(e,t,n);else{if(d&&(ce(d)?s(d):(ue(d),r?a(d):i(d))),r&&(!d||!ce(d))){if(l=c(),l.lock!==u)return void ke(e,t,n);i(l.session),d=l.session}null===(o=e.after)||void 0===o||o.call(e,d||l.session),Ce(t)}}function ke(e,t,n){O((()=>{Se(e,t,n+1)}),10)}function Ce(e){we=void 0;const t=ve.shift();t&&Se(t,e)}const xe=l;function _e(e){switch(e.sessionPersistence){case ne:return fe(e);case oe:return me();case void 0:{let t=fe(e);return!t&&e.allowFallbackToLocalStorage&&(t=me()),t}default:r.error(`Invalid session persistence '${String(e.sessionPersistence)}'`)}}function Ee(e,t,n,o){const r=new U,i=new U,s=new U,a=e.type===ne?pe(t,e.cookieOptions):he(t),{expireSession:c}=a,u=P((function(){Se({process:e=>ce(e)?ie(e,t):void 0,after:g},a)}),xe);let l;m();const{throttled:d,cancel:p}=q((()=>{Se({process:e=>{if(se(e))return;const t=g(e);return function(e){if(se(e))return!1;const{trackingType:t,isTracked:r}=o(e[n]);e[n]=t,delete e.isExpired,r&&!e.id&&(e.id=j(),e.created=String(f()))}(t),t},after:e=>{ae(e)&&!h()&&function(e){l=e,r.notify()}(e),l=e}},a)}),xe);function g(e){return ce(e)&&(e=ie(e,t)),h()&&(!function(e){return l.id!==e.id||l[n]!==e[n]}(e)?(s.notify({previousState:l,newState:e}),l=e):(l=ie(l,t),i.notify())),e}function m(){Se({process:e=>{if(se(e))return ie(e,t)},after:e=>{l=e}},a)}function h(){return void 0!==l[n]}return{expandOrRenewSession:d,expandSession:function(){Se({process:e=>h()?g(e):void 0},a)},getSession:()=>l,renewObservable:r,expireObservable:i,sessionStateUpdateObservable:s,restartSession:m,expire:()=>{p(),c(l),g(ie(l,t))},stop:()=>{D(u)},updateSessionState:function(e){Se({process:t=>({...t,...e}),after:g},a)}}}const Te={GRANTED:"granted",NOT_GRANTED:"not-granted"};function $e(e,t,n){if("object"!=typeof e||null===e)return JSON.stringify(e);const o=Re(Object.prototype),r=Re(Array.prototype),i=Re(Object.getPrototypeOf(e)),s=Re(e);try{return JSON.stringify(e,t,n)}catch(e){return"<error: unable to serialize object>"}finally{o(),r(),i(),s()}}function Re(e){const t=e,n=t.toJSON;return n?(delete t.toJSON,()=>{t.toJSON=n}):B}function Le(e){return function(e,t){const n=function(){if(void 0===Oe)try{const e=new Ie("http://test/path");Oe="http://test/path"===e.href}catch(e){Oe=!1}return Oe?Ie:void 0}();if(n)try{return void 0!==t?new n(e,t):new n(e)}catch(n){throw new Error(`Failed to construct URL: ${String(n)} ${$e({url:e,base:t})}`)}if(void 0===t&&!/:/.test(e))throw new Error(`Invalid URL: '${e}'`);let o=document;const r=o.createElement("a");if(void 0!==t){o=document.implementation.createHTMLDocument("");const e=o.createElement("base");e.href=t,o.head.appendChild(e),o.body.appendChild(r)}return r.href=e,r}(e,location.href).href}const Ie=URL;let Oe;const Ae="dd0g-gov.com",Pe="datadoghq.com",De="pci.browser-intake-datadoghq.com",Ue=["ddsource","ddtags"];function Me(e,t,n){const o=function(e,t){const n=`/api/v2/${t}`,o=e.proxy;if("string"==typeof o){const e=Le(o);return t=>`${e}?ddforward=${encodeURIComponent(`${n}?${t}`)}`}if("function"==typeof o)return e=>o({path:n,parameters:e});const r=function(e,t){const{site:n=Pe,internalAnalyticsSubdomain:o}=t;if("logs"===e&&t.usePciIntake&&n===Pe)return De;if(o&&n===Pe)return`${o}.${Pe}`;if(n===Ae)return`http-intake.logs.${n}`;const r=n.split("."),i=r.pop();return`browser-intake-${r.join("-")}.${i}`}(t,e);return e=>`https://${r}${n}?${e}`}(e,t);return{build(r,i){const s=function({clientToken:e,internalAnalyticsSubdomain:t},n,o,r,{retry:i,encoding:s}){const a=["sdk_version:6.6.2",`api:${r}`].concat(o);i&&a.push(`retry_count:${i.count}`,`retry_after:${i.lastFailureStatus}`);const c=["ddsource=browser",`ddtags=${encodeURIComponent(a.join(","))}`,`dd-api-key=${e}`,`dd-evp-origin-version=${encodeURIComponent("6.6.2")}`,"dd-evp-origin=browser",`dd-request-id=${j()}`];s&&c.push(`dd-evp-encoding=${s}`);"rum"===n&&c.push(`batch_time=${p()}`);t&&c.reverse();return c.join("&")}(e,t,n,r,i);return o(s)},tags:n,urlPrefix:o(""),trackType:t}}function qe(e,t){const n=200-e.length-1;(t.length>n||function(e){if(!function(){try{return new RegExp("[\\p{Ll}]","u"),!0}catch(e){return!1}}())return!1;return new RegExp("[^\\p{Ll}\\p{Lo}0-9_:./-]","u").test(e)}(t))&&r.warn(`${e} value doesn't meet tag requirements and will be sanitized. ${a} ${i}/getting_started/tagging/#defining-tags`);return`${e}:${t.replace(/,/g,"_")}`}function Be(e){const t=e.site||Pe,n=function(e){const{env:t,service:n,version:o,datacenter:r}=e,i=[];return t&&i.push(qe("env",t)),n&&i.push(qe("service",n)),o&&i.push(qe("version",o)),r&&i.push(qe("datacenter",r)),i}(e),o=function(e,t){return{logsEndpointBuilder:Me(e,"logs",t),rumEndpointBuilder:Me(e,"rum",t),profilingEndpointBuilder:Me(e,"profile",t),sessionReplayEndpointBuilder:Me(e,"replay",t)}}(e,n),r=function(e,t){if(!e.replica)return;const n={...e,site:Pe,clientToken:e.replica.clientToken},o={logsEndpointBuilder:Me(n,"logs",t),rumEndpointBuilder:Me(n,"rum",t)};return{applicationId:e.replica.applicationId,...o}}(e,n);return{replica:r,site:t,...o}}function je(e,t){return null==e||"string"==typeof e||(r.error(`${t} must be defined as a string`),!1)}function Ne(e,t){return!!(void 0===e||(n=e,function(e){return"number"==typeof e}(n)&&n>=0&&n<=100))||(r.error(`${t} Sample Rate should be a number between 0 and 100`),!1);var n}function Fe(e){var t,n,o,s,u,l;if(e&&e.clientToken){if((!(d=e.site)||"string"!=typeof d||/(datadog|ddog|datad0g|dd0g)/.test(d)||(r.error(`Site should be a valid Datadog site. ${a} ${i}/getting_started/site/.`),0))&&Ne(e.sessionSampleRate,"Session")&&Ne(e.telemetrySampleRate,"Telemetry")&&Ne(e.telemetryConfigurationSampleRate,"Telemetry Configuration")&&Ne(e.telemetryUsageSampleRate,"Telemetry Usage")&&je(e.version,"Version")&&je(e.env,"Env")&&je(e.service,"Service")){var d;if(void 0===e.trackingConsent||S(Te,e.trackingConsent))return{beforeSend:e.beforeSend&&c(e.beforeSend,"beforeSend threw an error:"),sessionStoreStrategyType:_e(e),sessionSampleRate:null!==(t=e.sessionSampleRate)&&void 0!==t?t:100,telemetrySampleRate:null!==(n=e.telemetrySampleRate)&&void 0!==n?n:20,telemetryConfigurationSampleRate:null!==(o=e.telemetryConfigurationSampleRate)&&void 0!==o?o:5,telemetryUsageSampleRate:null!==(s=e.telemetryUsageSampleRate)&&void 0!==s?s:5,service:e.service||void 0,silentMultipleInit:!!e.silentMultipleInit,allowUntrustedEvents:!!e.allowUntrustedEvents,trackingConsent:null!==(u=e.trackingConsent)&&void 0!==u?u:Te.GRANTED,trackAnonymousUser:null===(l=e.trackAnonymousUser)||void 0===l||l,storeContextsAcrossPages:!!e.storeContextsAcrossPages,batchBytesLimit:16384,eventRateLimiterThreshold:3e3,maxTelemetryEventsPerPage:15,flushTimeout:3e4,batchMessagesLimit:50,messageBytesLimit:262144,...Be(e)};r.error('Tracking Consent should be either "granted" or "not-granted"')}}else r.error("Client Token is not configured, we will not send any data.")}var He;!function(e){e.WRITABLE_RESOURCE_GRAPHQL="writable_resource_graphql",e.MISSING_URL_CONTEXT_TELEMETRY="missing_url_context_telemetry",e.USER_ACCOUNT_TRACE_HEADER="user_account_trace_header",e.PROFILING="profiling"}(He||(He={}));const ze=new Set;function Ge(e){Array.isArray(e)&&e.filter((e=>S(He,e))).forEach((e=>{ze.add(e)}))}function We(){return ze}const Je="?";function Ve(e){const t=[];let n=ot(e,"stack");const o=String(e);return n&&n.startsWith(o)&&(n=n.slice(o.length)),n&&n.split("\n").forEach((e=>{const n=function(e){const t=Ze.exec(e);if(!t)return;const n=t[2]&&0===t[2].indexOf("native"),o=t[2]&&0===t[2].indexOf("eval"),r=Ke.exec(t[2]);o&&r&&(t[2]=r[1],t[3]=r[2],t[4]=r[3]);return{args:n?[t[2]]:[],column:t[4]?+t[4]:void 0,func:t[1]||Je,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){const t=Qe.exec(e);if(!t)return;return{args:[],column:t[3]?+t[3]:void 0,func:Je,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){const t=et.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||Je,line:+t[3],url:t[2]}}(e)||function(e){const t=tt.exec(e);if(!t)return;const n=t[3]&&t[3].indexOf(" > eval")>-1,o=nt.exec(t[3]);n&&o&&(t[3]=o[1],t[4]=o[2],t[5]=void 0);return{args:t[2]?t[2].split(","):[],column:t[5]?+t[5]:void 0,func:t[1]||Je,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=Je),t.push(n))})),{message:ot(e,"message"),name:ot(e,"name"),stack:t}}const Ye="((?:file|https?|blob|chrome-extension|electron|native|eval|webpack|snippet|<anonymous>|\\w+\\.|\\/).*?)",Xe="(?::(\\d+))",Ze=new RegExp(`^\\s*at (.*?) ?\\(${Ye}${Xe}?${Xe}?\\)?\\s*$`,"i"),Ke=new RegExp(`\\((\\S*)${Xe}${Xe}\\)`);const Qe=new RegExp(`^\\s*at ?${Ye}${Xe}?${Xe}??\\s*$`,"i");const et=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;const tt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,nt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function ot(e,t){if("object"!=typeof e||!e||!(t in e))return;const n=e[t];return"string"==typeof n?n:void 0}function rt(e,t,n,o){const r=[{url:t,column:o,line:n}],{name:i,message:s}=function(e){let t,n;"[object String]"==={}.toString.call(e)&&([,t,n]=it.exec(e));return{name:t,message:n}}(e);return{name:i,message:s,stack:r}}const it=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;function st(e){const t=new Error(e);let n;return t.name="HandlingStack",R((()=>{const e=Ve(t);e.stack=e.stack.slice(2),n=at(e)})),n}function at(e){let t=ct(e);return e.stack.forEach((e=>{const n="?"===e.func?"<anonymous>":e.func,o=e.args&&e.args.length>0?`(${e.args.join(", ")})`:"",r=e.line?`:${e.line}`:"",i=e.line&&e.column?`:${e.column}`:"";t+=`\n at ${n}${o} @ ${e.url}${r}${i}`})),t}function ct(e){return`${e.name||"Error"}: ${e.message}`}function ut(e,t,n,{computeHandlingStack:o}={}){let r=e[t];if("function"!=typeof r){if(!(t in e)||!t.startsWith("on"))return{stop:B};r=B}let i=!1;const s=function(){if(i)return r.apply(this,arguments);const e=Array.from(arguments);let t;R(n,null,[{target:this,parameters:e,onPostCall:e=>{t=e},handlingStack:o?st("instrumented method"):void 0}]);const s=r.apply(this,e);return t&&R(t,null,[s]),s};return e[t]=s,{stop:()=>{i=!0,e[t]===s&&(e[t]=r)}}}function lt(e,t=225280){const n=Re(Object.prototype),o=Re(Array.prototype),r=[],i=new WeakMap,s=dt(e,"$",void 0,r,i),a=JSON.stringify(s);let c=a?a.length:0;if(!(c>t)){for(;r.length>0&&c<t;){const n=r.shift();let o=0;if(Array.isArray(n.source))for(let s=0;s<n.source.length;s++){const a=dt(n.source[s],n.path,s,r,i);if(c+=void 0!==a?JSON.stringify(a).length:4,c+=o,o=1,c>t){pt(t,"truncated",e);break}n.target[s]=a}else for(const s in n.source)if(Object.prototype.hasOwnProperty.call(n.source,s)){const a=dt(n.source[s],n.path,s,r,i);if(void 0!==a&&(c+=JSON.stringify(a).length+o+s.length+3,o=1),c>t){pt(t,"truncated",e);break}n.target[s]=a}}return n(),o(),s}pt(t,"discarded",e)}function dt(e,t,n,o,r){const i=function(e){const t=e;if(t&&"function"==typeof t.toJSON)try{return t.toJSON()}catch(e){}return e}(e);if(!i||"object"!=typeof i)return function(e){if("bigint"==typeof e)return`[BigInt] ${e.toString()}`;if("function"==typeof e)return`[Function] ${e.name||"unknown"}`;if("symbol"==typeof e)return`[Symbol] ${e.description||e.toString()}`;return e}(i);const s=ft(i);if("[Object]"!==s&&"[Array]"!==s&&"[Error]"!==s)return s;const a=e;if(r.has(a))return`[Reference seen at ${r.get(a)}]`;const c=void 0!==n?`${t}.${n}`:t,u=Array.isArray(i)?[]:{};return r.set(a,c),o.push({source:i,target:u,path:c}),u}function ft(e){try{if(e instanceof Event)return{type:(t=e).type,isTrusted:t.isTrusted,currentTarget:t.currentTarget?ft(t.currentTarget):null,target:t.target?ft(t.target):null};if(e instanceof RegExp)return`[RegExp] ${e.toString()}`;const n=Object.prototype.toString.call(e).match(/\[object (.*)\]/);if(n&&n[1])return`[${n[1]}]`}catch(e){}var t;return"[Unserializable]"}function pt(e,t,n){r.warn(`The data provided has been ${t} as it is over the limit of ${e} characters:`,n)}const gt="No stack, consider using an instance of Error";function mt({stackTrace:e,originalError:t,handlingStack:n,componentStack:o,startClocks:r,nonErrorPrefix:i,source:s,handling:a}){const c=bt(t),u=function(e,t,n,o){return(null==e?void 0:e.message)&&(null==e?void 0:e.name)?e.message:t?"Empty message":`${n} ${$e(lt(o))}`}(e,c,i,t),l=function(e,t){if(void 0===t)return!1;if(e)return!0;return t.stack.length>0&&(t.stack.length>1||void 0!==t.stack[0].url)}(c,e)?at(e):gt,d=c?vt(t,s):void 0;return{startClocks:r,source:s,handling:a,handlingStack:n,componentStack:o,originalError:t,type:e?e.name:void 0,message:u,stack:l,causes:d,fingerprint:ht(t),context:yt(t)}}function ht(e){return bt(e)&&"dd_fingerprint"in e?String(e.dd_fingerprint):void 0}function yt(e){if(null!==e&&"object"==typeof e&&"dd_context"in e)return e.dd_context}function bt(e){return e instanceof Error||"[object Error]"===Object.prototype.toString.call(e)}function vt(e,t){let n=e;const o=[];for(;bt(null==n?void 0:n.cause)&&o.length<10;){const e=Ve(n.cause);o.push({message:n.cause.message,source:t,type:null==e?void 0:e.name,stack:e&&at(e)}),n=n.cause}return o.length?o:void 0}const wt="agent",St="console",kt="logger",Ct="network",xt="source",_t="report";function Et(e){const t=(t,n)=>{const o=mt({stackTrace:t,originalError:n,startClocks:m(),nonErrorPrefix:"Uncaught",source:xt,handling:"unhandled"});e.notify(o)},{stop:n}=(o=t,ut(window,"onerror",(({parameters:[e,t,n,r,i]})=>{let s;s=bt(i)?Ve(i):rt(e,t,n,r),o(s,null!=i?i:e)})));var o;const{stop:r}=function(e){return ut(window,"onunhandledrejection",(({parameters:[t]})=>{const n=t.reason||"Empty reason",o=Ve(n);e(o,n)}))}(t);return{stop:()=>{n(),r()}}}function Tt(e,t){t.silentMultipleInit||r.error(`${e} is already initialized.`)}function $t(e,t,n,o,r){return Rt(e,t,[n],o,r)}function Rt(e,t,n,o,{once:r,capture:i,passive:s}={}){const a=$((t=>{(t.isTrusted||t.__ddIsTrusted||e.allowUntrustedEvents)&&(r&&d(),o(t))})),c=s?{capture:i,passive:s}:i,u=window.EventTarget&&t instanceof EventTarget?window.EventTarget.prototype:t,l=x(u,"addEventListener");function d(){const e=x(u,"removeEventListener");n.forEach((n=>e.call(t,n,a,c)))}return n.forEach((e=>l.call(t,e,a,c))),{stop:d}}const Lt={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function It(e,t){const n=[];t.includes(Lt.cspViolation)&&n.push(function(e){return new U((t=>{const{stop:n}=$t(e,document,"securitypolicyviolation",(e=>{t.notify(function(e){const t=`'${e.blockedURI}' blocked by '${e.effectiveDirective}' directive`;return Ot({type:e.effectiveDirective,message:`${Lt.cspViolation}: ${t}`,originalError:e,csp:{disposition:e.disposition},stack:At(e.effectiveDirective,e.originalPolicy?`${t} of the policy "${F(e.originalPolicy,100,"...")}"`:"no policy",e.sourceFile,e.lineNumber,e.columnNumber)})}(e))}));return n}))}(e));const o=t.filter((e=>e!==Lt.cspViolation));return o.length&&n.push(function(e){return new U((t=>{if(!window.ReportingObserver)return;const n=$(((e,n)=>e.forEach((e=>t.notify(function(e){const{type:t,body:n}=e;return Ot({type:n.id,message:`${t}: ${n.message}`,originalError:e,stack:At(n.id,n.message,n.sourceFile,n.lineNumber,n.columnNumber)})}(e)))))),o=new window.ReportingObserver(n,{types:e,buffered:!0});return o.observe(),()=>{o.disconnect()}}))}(o)),M(...n)}function Ot(e){return{startClocks:m(),source:_t,handling:"unhandled",...e}}function At(e,t,n,o,r){return n?at({name:e,message:t,stack:[{func:"?",url:n,line:null!=o?o:void 0,column:null!=r?r:void 0}]}):void 0}function Pt(e,t){const n=window.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}function Dt(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function Ut(e,t,n=function(){if("undefined"!=typeof WeakSet){const e=new WeakSet;return{hasAlreadyBeenSeen(t){const n=e.has(t);return n||e.add(t),n}}}const e=[];return{hasAlreadyBeenSeen(t){const n=e.indexOf(t)>=0;return n||e.push(t),n}}}()){if(void 0===t)return e;if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const e=t.flags||[t.global?"g":"",t.ignoreCase?"i":"",t.multiline?"m":"",t.sticky?"y":"",t.unicode?"u":""].join("");return new RegExp(t.source,e)}if(n.hasAlreadyBeenSeen(t))return;if(Array.isArray(t)){const o=Array.isArray(e)?e:[];for(let e=0;e<t.length;++e)o[e]=Ut(o[e],t[e],n);return o}const o="object"===Dt(e)?e:{};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=Ut(o[e],t[e],n));return o}function Mt(e){return Ut(void 0,e)}function qt(...e){let t;for(const n of e)null!=n&&(t=Ut(t,n));return t}function Bt(){var e;const t=window.navigator;return{status:t.onLine?"connected":"not_connected",interfaces:t.connection&&t.connection.type?[t.connection.type]:void 0,effective_type:null===(e=t.connection)||void 0===e?void 0:e.effectiveType}}function jt(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}function Nt(){const e=[];return{add:t=>{e.push(t)>500&&e.splice(0,1)},remove:t=>{jt(e,t)},drain:t=>{e.forEach((e=>e(t))),e.length=0}}}const Ft="log",Ht="configuration",zt="usage",Gt=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],Wt=["ddog-gov.com"];let Jt=Nt(),Vt=e=>{Jt.add((()=>Vt(e)))};function Yt(e,t){let n;const o=new U,r=new Set,i=!Wt.includes(t.site)&&u(t.telemetrySampleRate),s={[Ft]:i,[Ht]:i&&u(t.telemetryConfigurationSampleRate),[zt]:i&&u(t.telemetryUsageSampleRate)},a={is_local_file:"file:"===window.location.protocol,is_worker:"WorkerGlobalScope"in self};return Vt=i=>{const c=$e(i);if(s[i.type]&&r.size<t.maxTelemetryEventsPerPage&&!r.has(c)){const t=function(e,t,o){return qt({type:"telemetry",date:p(),service:e,version:"6.6.2",source:"browser",_dd:{format_version:2},telemetry:qt(t,{runtime_env:o,connectivity:Bt(),sdk_setup:"npm"}),experimental_features:Array.from(We())},void 0!==n?n():{})}(e,i,a);o.notify(t),Pt("telemetry",t),r.add(c)}},_=Zt,{setContextProvider:e=>{n=e},observable:o,enabled:i}}function Xt(t,n){I(e.debug,t,n),Vt({type:Ft,message:t,status:"debug",...n})}function Zt(e,t){Vt({type:Ft,status:"error",...Kt(e),...t})}function Kt(e){if(bt(e)){const t=Ve(e);return{error:{kind:t.name,stack:at(Qt(t))},message:t.message}}return{error:{stack:gt},message:`Uncaught ${$e(e)}`}}function Qt(e){return e.stack=e.stack.filter((e=>!e.url||Gt.some((t=>e.url.startsWith(t))))),e}const en=1/0;let tn=null;const nn=new Set;function on({expireDelay:e,maxEntries:t}){let n=[];const o=[];tn||(tn=P((()=>{nn.forEach((e=>e()))}),6e4));const r=()=>{const t=g()-e;for(;n.length>0&&n[n.length-1].endTime<t;){const e=n.pop();e&&o.push(e.startTime)}};return nn.add(r),{add:function(e,o){const r={value:e,startTime:o,endTime:en,remove:()=>{jt(n,r)},close:e=>{r.endTime=e}};return t&&n.length>=t&&n.pop(),n.unshift(r),r},find:function(e=Infinity,t={returnInactive:!1}){for(const o of n)if(o.startTime<=e){if(t.returnInactive||e<=o.endTime)return o.value;break}},closeActive:function(e){const t=n[0];t&&t.endTime===en&&t.close(e)},findAll:function(e=Infinity,t=0){const o=e+t;return n.filter((t=>t.startTime<=o&&e<=t.endTime)).map((e=>e.value))},reset:function(){n=[]},stop:function(){nn.delete(r),0===nn.size&&tn&&(D(tn),tn=null)},getAllEntries:function(){return n.map((({startTime:e,endTime:t,value:n})=>({startTime:e,endTime:t===en?"Infinity":t,value:n})))},getDeletedEntries:function(){return o}}}const rn=d,sn=Q;function an(e,t,n,o){const r=new U,i=new U,s=Ee(e.sessionStoreStrategyType,e,t,n),a=on({expireDelay:sn});function c(){return{id:s.getSession().id,trackingType:s.getSession()[t],isReplayForced:!!s.getSession().forcedReplay,anonymousId:s.getSession().anonymousId}}return s.renewObservable.subscribe((()=>{a.add(c(),g()),r.notify()})),s.expireObservable.subscribe((()=>{i.notify(),a.closeActive(g())})),s.expandOrRenewSession(),a.add(c(),[0,y()][0]),o.observable.subscribe((()=>{o.isGranted()?s.expandOrRenewSession():s.expire()})),function(e,t){const{stop:n}=Rt(e,window,["click","touchstart","keydown","scroll"],t,{capture:!0,passive:!0})}(e,(()=>{o.isGranted()&&s.expandOrRenewSession()})),function(e,t){const n=()=>{"visible"===document.visibilityState&&t()},{stop:o}=$t(e,document,"visibilitychange",n);P(n,rn)}(e,(()=>s.expandSession())),function(e,t){const{stop:n}=$t(e,window,"resume",t,{capture:!0})}(e,(()=>s.restartSession())),{findSession:(e,t)=>a.find(e,t),renewObservable:r,expireObservable:i,sessionStateUpdateObservable:s.sessionStateUpdateObservable,expire:s.expire,updateSessionState:s.updateSessionState}}function cn(e){return e>=500}const un=3145728,ln=l;function dn(e,t,n,o,r){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?pn(e,t,n,{onSuccess:()=>gn(0,t,n,o,r),onFailure:()=>{t.queuedPayloads.enqueue(e),fn(t,n,o,r)}}):t.queuedPayloads.enqueue(e)}function fn(e,t,n,o){2===e.transportStatus&&O((()=>{pn(e.queuedPayloads.first(),e,t,{onSuccess:()=>{e.queuedPayloads.dequeue(),e.currentBackoffTime=ln,gn(1,e,t,n,o)},onFailure:()=>{e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),fn(e,t,n,o)}})}),e.currentBackoffTime)}function pn(e,t,n,{onSuccess:o,onFailure:r}){t.bandwidthMonitor.add(e),n(e,(n=>{t.bandwidthMonitor.remove(e),!function(e){return"opaque"!==e.type&&(0===e.status&&!navigator.onLine||408===e.status||429===e.status||cn(e.status))}(n)?(t.transportStatus=0,o()):(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:n.status},r())}))}function gn(e,t,n,o,r){0===e&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(r({message:`Reached max ${o} events size queued for upload: 3MiB`,source:wt,startClocks:m()}),t.queueFullReported=!0);const i=t.queuedPayloads;for(t.queuedPayloads=mn();i.size()>0;)dn(i.dequeue(),t,n,o,r)}function mn(){const e=[];return{bytesCount:0,enqueue(t){this.isFull()||(e.push(t),this.bytesCount+=t.bytesCount)},first:()=>e[0],dequeue(){const t=e.shift();return t&&(this.bytesCount-=t.bytesCount),t},size:()=>e.length,isFull(){return this.bytesCount>=un}}}function hn(e,t,n){const o={transportStatus:0,currentBackoffTime:ln,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle(e){return 0===this.ongoingRequestCount||this.ongoingByteCount+e.bytesCount<=81920&&this.ongoingRequestCount<32},add(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount}},queuedPayloads:mn(),queueFullReported:!1},r=(n,o)=>function(e,t,n,o){const r=function(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}}()&&n.bytesCount<t;if(r){const t=e.build("fetch-keepalive",n);fetch(t,{method:"POST",body:n.data,keepalive:!0,mode:"cors"}).then($((e=>null==o?void 0:o({status:e.status,type:e.type})))).catch($((()=>bn(e,n,o))))}else bn(e,n,o)}(e,t,n,o);return{send:t=>{dn(t,o,r,e.trackType,n)},sendOnExit:n=>{!function(e,t,n){const o=!!navigator.sendBeacon&&n.bytesCount<t;if(o)try{const t=e.build("beacon",n);if(navigator.sendBeacon(t,n.data))return}catch(e){!function(e){yn||(yn=!0,L(e))}(e)}bn(e,n)}(e,t,n)}}}let yn=!1;function bn(e,t,n){const o=e.build("fetch",t);fetch(o,{method:"POST",body:t.data,mode:"cors"}).then($((e=>null==n?void 0:n({status:e.status,type:e.type})))).catch($((()=>null==n?void 0:n({status:0}))))}function vn(){const e=C().DatadogEventBridge;if(e)return{getCapabilities(){var t;return JSON.parse((null===(t=e.getCapabilities)||void 0===t?void 0:t.call(e))||"[]")},getPrivacyLevel(){var t;return null===(t=e.getPrivacyLevel)||void 0===t?void 0:t.call(e)},getAllowedWebViewHosts:()=>JSON.parse(e.getAllowedWebViewHosts()),send(t,n,o){const r=o?{id:o}:void 0;e.send(JSON.stringify({eventType:t,event:n,view:r}))}}}function wn(e){var t;void 0===e&&(e=null===(t=C().location)||void 0===t?void 0:t.hostname);const n=vn();return!!n&&n.getAllowedWebViewHosts().some((t=>e===t||e.endsWith(`.${t}`)))}const Sn={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};function kn({encoder:e,request:t,flushController:n,messageBytesLimit:o}){let i={};const c=n.flushObservable.subscribe((n=>function(n){const o=K(i).join("\n");i={};const r=(a=n.reason,K(Sn).includes(a)),s=r?t.sendOnExit:t.send;var a;if(r&&e.isAsync){const t=e.finishSync();t.outputBytesCount&&s(Cn(t));const n=[t.pendingData,o].filter(Boolean).join("\n");n&&s({data:n,bytesCount:w(n)})}else o&&e.write(e.isEmpty?o:`\n${o}`),e.finish((e=>{s(Cn(e))}))}(n)));function u(t,c){const u=$e(t),l=e.estimateEncodedBytesCount(u);l>=o?r.warn(`Discarded a message whose size was bigger than the maximum allowed size ${o}KB. ${a} ${s}/#technical-limitations`):(function(e){return void 0!==e&&void 0!==i[e]}(c)&&function(t){const o=i[t];delete i[t];const r=e.estimateEncodedBytesCount(o);n.notifyAfterRemoveMessage(r)}(c),function(t,o,r){n.notifyBeforeAddMessage(o),void 0!==r?(i[r]=t,n.notifyAfterAddMessage()):e.write(e.isEmpty?t:`\n${t}`,(e=>{n.notifyAfterAddMessage(e-o)}))}(u,l,c))}return{flushController:n,add:u,upsert:u,stop:c.unsubscribe}}function Cn(e){let t;return t="string"==typeof e.output?e.output:new Blob([e.output],{type:"text/plain"}),{data:t,bytesCount:e.outputBytesCount,encoding:e.encoding}}function xn({messagesLimit:e,bytesLimit:t,durationLimit:n,pageMayExitObservable:o,sessionExpireObservable:r}){const i=o.subscribe((e=>d(e.reason))),s=r.subscribe((()=>d("session_expire"))),a=new U((()=>()=>{i.unsubscribe(),s.unsubscribe()}));let c,u=0,l=0;function d(e){if(0===l)return;const t=l,n=u;l=0,u=0,f(),a.notify({reason:e,messagesCount:t,bytesCount:n})}function f(){A(c),c=void 0}return{flushObservable:a,get messagesCount(){return l},notifyBeforeAddMessage(e){u+e>=t&&d("bytes_limit"),l+=1,u+=e,void 0===c&&(c=O((()=>{d("duration_limit")}),n))},notifyAfterAddMessage(n=0){u+=n,l>=e?d("messages_limit"):u>=t&&d("bytes_limit")},notifyAfterRemoveMessage(e){u-=e,l-=1,0===l&&f()}}}function _n(e,t,n,o,r,i,s=kn){const a=u(e,t),c=n&&u(e,n);function u(e,{endpoint:t,encoder:n}){return s({encoder:n,request:hn(t,e.batchBytesLimit,o),flushController:xn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageMayExitObservable:r,sessionExpireObservable:i}),messageBytesLimit:e.messageBytesLimit})}return{flushObservable:a.flushController.flushObservable,add(e,t=!0){a.add(e),c&&t&&c.add(n.transformMessage?n.transformMessage(e):e)},upsert:(e,t)=>{a.upsert(e,t),c&&c.upsert(n.transformMessage?n.transformMessage(e):e,t)},stop:()=>{a.stop(),c&&c.stop()}}}function En(){let e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write(n,o){const r=w(n);t+=r,e+=n,o&&o(r)},finish(e){e(this.finishSync())},finishSync(){const n={output:e,outputBytesCount:t,rawBytesCount:t,pendingData:""};return e="",t=0,n},estimateEncodedBytesCount:e=>e.length}}let Tn;const $n=new WeakMap;function Rn(e){return Tn||(Tn=function(e){return new U((t=>{const{stop:n}=ut(XMLHttpRequest.prototype,"open",Ln),{stop:o}=ut(XMLHttpRequest.prototype,"send",(n=>{!function({target:e,handlingStack:t},n,o){const r=$n.get(e);if(!r)return;const i=r;i.state="start",i.startClocks=m(),i.isAborted=!1,i.xhr=e,i.handlingStack=t;let s=!1;const{stop:a}=ut(e,"onreadystatechange",(()=>{e.readyState===XMLHttpRequest.DONE&&c()})),c=()=>{if(u(),a(),s)return;s=!0;const t=r;var n,c;t.state="complete",t.duration=(n=i.startClocks.timeStamp,p()-n),t.status=e.status,o.notify((c=t,{...c}))},{stop:u}=$t(n,e,"loadend",c);o.notify(i)}(n,e,t)}),{computeHandlingStack:!0}),{stop:r}=ut(XMLHttpRequest.prototype,"abort",In);return()=>{n(),o(),r()}}))}(e)),Tn}function Ln({target:e,parameters:[t,n]}){$n.set(e,{state:"open",method:String(t).toUpperCase(),url:Le(String(n))})}function In({target:e}){const t=$n.get(e);t&&(t.isAborted=!0)}let On;function An(){return On||(On=new U((e=>{if(!window.fetch)return;const{stop:t}=ut(window,"fetch",(t=>function({parameters:e,onPostCall:t,handlingStack:n},o){const[r,i]=e;let s=i&&i.method;void 0===s&&r instanceof Request&&(s=r.method);const a=void 0!==s?String(s).toUpperCase():"GET",c=r instanceof Request?r.url:Le(String(r)),u=m(),l={state:"start",init:i,input:r,method:a,startClocks:u,url:c,handlingStack:n};o.notify(l),e[0]=l.input,e[1]=l.init,t((e=>function(e,t,n){const o=n;function r(t){o.state="resolve",Object.assign(o,t),e.notify(o)}t.then($((e=>{r({response:e,responseType:e.type,status:e.status,isAborted:!1})})),$((e=>{var t,n;r({status:0,isAborted:(null===(n=null===(t=o.init)||void 0===t?void 0:t.signal)||void 0===n?void 0:n.aborted)||e instanceof DOMException&&e.code===DOMException.ABORT_ERR,error:e})})))}(o,e,l)))}(t,e)),{computeHandlingStack:!0});return t}))),On}let Pn={};function Dn(n){return M(...n.map((n=>(Pn[n]||(Pn[n]=function(n){return new U((o=>{const r=t[n];return t[n]=(...t)=>{r.apply(console,t);const i=st("console error");R((()=>{o.notify(function(t,n,o){const r=t.map((e=>function(e){if("string"==typeof e)return lt(e);if(bt(e))return ct(Ve(e));return $e(lt(e),void 0,2)}(e))).join(" ");let i;if(n===e.error){const e=t.find(bt);i={stack:e?at(Ve(e)):void 0,fingerprint:ht(e),causes:e?vt(e,"console"):void 0,startClocks:m(),message:r,source:St,handling:"handled",handlingStack:o,context:yt(e)}}return{api:n,message:r,error:i,handlingStack:o}}(t,n,i))}))},()=>{t[n]=r}}))}(n)),Pn[n]))))}function Un(e,t,n){const o={...e};for(const[i,{required:s,type:a}]of Object.entries(t))"string"===a&&i in o&&(o[i]=String(o[i])),s&&!(i in e)&&r.warn(`The property ${i} of ${n} is required; context will not be sent to the intake.`);return o}function Mn(e="",{customerDataTracker:t,propertiesConfig:n={}}={}){let o={};const i=new U,s={getContext:()=>Mt(o),setContext:a=>{!function(e){const t="object"===Dt(e);return t||r.error("Unsupported context:",e),t}(a)?s.clearContext():(o=lt(Un(a,n,e)),null==t||t.updateCustomerData(o)),i.notify()},setContextProperty:(r,s)=>{o=lt(Un({...o,[r]:s},n,e)),null==t||t.updateCustomerData(o),i.notify()},removeContextProperty:r=>{delete o[r],null==t||t.updateCustomerData(o),Un(o,n,e),i.notify()},clearContext:()=>{o={},null==t||t.resetCustomerData(),i.notify()},changeObservable:i};return s}const qn="_dd_c",Bn=[];function jn(e,t,n,o){const r=function(e,t){return`${qn}_${e}_${t}`}(n,o);Bn.push($t(e,window,"storage",(({key:e})=>{r===e&&t.setContext(s())}))),t.changeObservable.subscribe((function(){localStorage.setItem(r,JSON.stringify(t.getContext()))}));const i=qt(s(),t.getContext());function s(){const e=localStorage.getItem(r);return e?JSON.parse(e):{}}k(i)||t.setContext(i)}function Nn(e=2){const t=new Map;let n=!1;function o(o=0){if(n||0===e)return;const i=2===e?3072:16384;let c=o;t.forEach((e=>{c+=e.getBytesCount()})),c>i&&(!function(e){r.warn(`Customer data exceeds the recommended ${e/b}KiB threshold. ${a} ${s}/#customer-data-exceeds-the-recommended-threshold-warning`)}(i),n=!0)}return{createDetachedTracker:()=>{const e=Fn((()=>o(e.getBytesCount())));return e},getOrCreateTracker:e=>(t.has(e)||t.set(e,Fn(o)),t.get(e)),setCompressionStatus:t=>{0===e&&(e=t,o())},getCompressionStatus:()=>e,stop:()=>{t.forEach((e=>e.stop())),t.clear()}}}function Fn(e){let t=0;const{throttled:n,cancel:o}=q((n=>{t=w($e(n)),e()}),200),r=()=>{o(),t=0};return{updateCustomerData:e=>{k(e)?r():n(e)},resetCustomerData:r,getBytesCount:()=>t,stop:()=>{o()}}}function Hn(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||Y("datadog-synthetics-injects-rum"))}function zn(){const e=window._DATADOG_SYNTHETICS_PUBLIC_ID||Y("datadog-synthetics-public-id");return"string"==typeof e?e:void 0}function Gn(){const e=window._DATADOG_SYNTHETICS_RESULT_ID||Y("datadog-synthetics-result-id");return"string"==typeof e?e:void 0}function Wn(e,t,n){const o=n.getHandler(),r=Array.isArray(o)?o:[o];return Vn[e]>=Vn[n.getLevel()]&&r.includes(t)}const Jn={ok:"ok",debug:"debug",info:"info",notice:"notice",warn:"warn",error:"error",critical:"critical",alert:"alert",emerg:"emerg"},Vn={[Jn.ok]:0,[Jn.debug]:1,[Jn.info]:2,[Jn.notice]:4,[Jn.warn]:5,[Jn.error]:6,[Jn.critical]:7,[Jn.alert]:8,[Jn.emerg]:9};function Yn(e,{includeMessage:t=!1}={}){return{stack:e.stack,kind:e.type,message:t?e.message:void 0,causes:e.causes,fingerprint:e.fingerprint,handling:e.handling}}var Xn=window&&window.__decorate||function(e,t,n,o){var r,i=arguments.length,s=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(i<3?r(s):i>3?r(t,n,s):r(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s};const Zn="console",Kn="http",Qn=Object.keys(Jn);class eo{constructor(e,t,n,o=Kn,r=Jn.debug,i={}){this.handleLogStrategy=e,this.handlerType=o,this.level=r,this.contextManager=Mn("logger",{customerDataTracker:t}),this.contextManager.setContext(i),n&&this.contextManager.setContextProperty("logger",{name:n})}logImplementation(e,t,n=Jn.info,o,r){const i=lt(t);let s;if(null!=o){s=qt({error:Yn(mt({stackTrace:bt(o)?Ve(o):void 0,originalError:o,nonErrorPrefix:"Provided",source:kt,handling:"handled",startClocks:m()}),{includeMessage:!0})},i)}else s=i;this.handleLogStrategy({message:lt(e),context:s,status:n},this,r)}log(e,t,n=Jn.info,o){let r;Wn(n,Kn,this)&&(r=st("log")),this.logImplementation(e,t,n,o,r)}setContext(e){this.contextManager.setContext(e)}getContext(){return this.contextManager.getContext()}setContextProperty(e,t){this.contextManager.setContextProperty(e,t)}removeContextProperty(e){this.contextManager.removeContextProperty(e)}clearContext(){this.contextManager.clearContext()}setHandler(e){this.handlerType=e}getHandler(){return this.handlerType}setLevel(e){this.level=e}getLevel(){return this.level}}function to(e){return function(t,n,o){let r;Wn(e,Kn,this)&&(r=st("log")),this.logImplementation(t,n,e,o,r)}}Xn([function(e,t,n){const o=n.value;n.value=function(...e){return(_?$(o):o).apply(this,e)}}],eo.prototype,"logImplementation",null),eo.prototype.ok=to(Jn.ok),eo.prototype.debug=to(Jn.debug),eo.prototype.info=to(Jn.info),eo.prototype.notice=to(Jn.notice),eo.prototype.warn=to(Jn.warn),eo.prototype.error=to(Jn.error),eo.prototype.critical=to(Jn.critical),eo.prototype.alert=to(Jn.alert),eo.prototype.emerg=to(Jn.emerg);function no(e,t,n){return void 0===e?[]:"all"===e||Array.isArray(e)&&e.every((e=>t.includes(e)))?"all"===e?t:function(e){const t=new Set;return e.forEach((e=>t.add(e))),Array.from(t)}(e):void r.error(`${n} should be "all" or an array with allowed values "${t.join('", "')}"`)}function oo(t,n,o){const i=Nt();let s,a;const c=n.observable.subscribe(u);function u(){if(!a||!s||!n.isGranted())return;c.unsubscribe();const e=o(s,a);i.drain(e)}return{init(t){if(!t)return void r.error("Missing configuration");if(Ge(t.enableExperimentalFeatures),wn()&&(t=function(e){return{...e,clientToken:"empty"}}(t)),s=t,a)return void Tt("DD_LOGS",t);const o=function(t){!0===t.usePciIntake&&t.site&&"datadoghq.com"!==t.site&&r.warn("PCI compliance for Logs is only available for Datadog organizations in the US1 site. Default intake will be used.");const n=Fe(t),o=no(t.forwardConsoleLogs,K(e),"Forward Console Logs"),i=no(t.forwardReports,K(Lt),"Forward Reports");if(n&&o&&i)return t.forwardErrorsToLogs&&!o.includes(e.error)&&o.push(e.error),{forwardErrorsToLogs:!1!==t.forwardErrorsToLogs,forwardConsoleLogs:o,forwardReports:i,requestErrorResponseLengthLimit:32768,...n}}(t);o&&(a=o,An().subscribe(B),n.tryToInit(o.trackingConsent),u())},get initConfiguration(){return s},getInternalContext:B,handleLog(e,n,o,r=t(),s=p()){i.add((t=>t.handleLog(e,n,o,r,s)))}}}const ro="logs";function io(e,t){const n=an(e,"logs",(t=>function(e,t){const n=function(e){return"0"===e||"1"===e}(t)?t:so(e);return{trackingType:n,isTracked:"1"===n}}(e,t)),t);return{findTrackedSession:(e,t={returnInactive:!1})=>{const o=n.findSession(e,t);return o&&"1"===o.trackingType?{id:o.id,anonymousId:o.anonymousId}:void 0},expireObservable:n.expireObservable}}function so(e){return u(e.sessionSampleRate)?"1":"0"}let ao=!1;function co(e){const t=window;if(Hn()){const e=n(t.DD_RUM_SYNTHETICS);return e||ao||(ao=!0,Xt("Logs sent before RUM is injected by the synthetics worker",{testId:zn(),resultId:Gn()})),e}return n(t.DD_RUM);function n(t){if(t&&t.getInternalContext)return t.getInternalContext(e)}}function uo(e,t,n,o,r){const i=Qn.concat(["custom"]),s={};i.forEach((e=>{s[e]=function(e,t,n){let o=0,r=!1;return{isLimitReached(){if(0===o&&O((()=>{o=0}),d),o+=1,o<=t||r)return r=!1,!1;if(o===t+1){r=!0;try{n({message:`Reached max number of ${e}s by minute: ${t}`,source:wt,startClocks:m()})}finally{r=!1}}return!0}}}(e,t.eventRateLimiterThreshold,r)})),n.subscribe(0,(({rawLogsEvent:r,messageContext:i,savedCommonContext:a,domainContext:c})=>{var u,l;const d=r.date-y();const f=e.findTrackedSession(d);if(!e.findTrackedSession(d,{returnInactive:!0}))return;const p=a||o();let g;!k(p.account)&&p.account.id&&(g=p.account),f&&f.anonymousId&&!p.user.anonymous_id&&(p.user.anonymous_id=f.anonymousId);const m=qt({service:t.service,session_id:f?f.id:void 0,session:f?{id:f.id}:void 0,usr:k(p.user)?void 0:p.user,account:g,view:p.view},p.context,co(d),r,i);!1===(null===(u=t.beforeSend)||void 0===u?void 0:u.call(t,m,c))||m.origin!==wt&&(null!==(l=s[m.status])&&void 0!==l?l:s.custom).isLimitReached()||n.notify(1,m)}))}const lo={[e.log]:Jn.info,[e.debug]:Jn.debug,[e.info]:Jn.info,[e.warn]:Jn.warn,[e.error]:Jn.error};function fo(e,t){if(!e.forwardErrorsToLogs)return{stop:B};const n=Rn(e).subscribe((e=>{"complete"===e.state&&r("xhr",e)})),o=An().subscribe((e=>{"resolve"===e.state&&r("fetch",e)}));function r(n,o){var r;function i(e){const r={isAborted:o.isAborted,handlingStack:o.handlingStack};t.notify(0,{rawLogsEvent:{message:`${go(n)} error ${o.method} ${o.url}`,date:o.startClocks.timeStamp,error:{stack:e||"Failed to load",handling:void 0},http:{method:o.method,status_code:o.status,url:o.url},status:Jn.error,origin:Ct},domainContext:r})}r=o.url,Ue.every((e=>r.includes(e)))||!function(e){return 0===e.status&&"opaque"!==e.responseType}(o)&&!cn(o.status)||("xhr"in o?function(e,t,n){"string"==typeof e.response?n(po(e.response,t)):n(e.response)}(o.xhr,e,i):o.response?function(e,t,n){const o=function(e){try{return e.clone()}catch(e){return}}(e);o&&o.body?window.TextDecoder?function(e,t,n){!function(e,t,n){const o=e.getReader(),r=[];let i=0;function s(){let e,s;o.cancel().catch(B);{let t;if(1===r.length)t=r[0];else{t=new Uint8Array(i);let e=0;r.forEach((n=>{t.set(n,e),e+=n.length}))}e=t.slice(0,n.bytesLimit),s=t.length>n.bytesLimit}t(void 0,e,s)}!function e(){o.read().then($((t=>{t.done?s():(r.push(t.value),i+=t.value.length,i>n.bytesLimit?s():e())})),$((e=>t(e))))}()}(e,((e,t,o)=>{if(e)n(e);else{let e=(new TextDecoder).decode(t);o&&(e+="..."),n(void 0,e)}}),{bytesLimit:t})}(o.body,t.requestErrorResponseLengthLimit,((e,t)=>{n(e?`Unable to retrieve response: ${e}`:t)})):o.text().then($((e=>n(po(e,t)))),$((e=>n(`Unable to retrieve response: ${e}`)))):n()}(o.response,e,i):o.error&&function(e,t,n){n(po(at(Ve(e)),t))}(o.error,e,i))}return{stop:()=>{n.unsubscribe(),o.unsubscribe()}}}function po(e,t){return e.length>t.requestErrorResponseLengthLimit?`${e.substring(0,t.requestErrorResponseLengthLimit)}...`:e}function go(e){return"xhr"===e?"XHR":"Fetch"}const mo=class{constructor(){this.callbacks={}}notify(e,t){const n=this.callbacks[e];n&&n.forEach((e=>e(t)))}subscribe(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),{unsubscribe:()=>{this.callbacks[e]=this.callbacks[e].filter((e=>t!==e))}}}};function ho(e){return{handleLog:function(o,r,i,s,a){const c=qt(r.getContext(),o.context);if(Wn(o.status,Zn,r)&&function({status:e,message:o},r){n[yo[e]].call(t,o,r)}(o,c),Wn(o.status,Kn,r)){const t={rawLogsEvent:{date:a||p(),message:o.message,status:o.status,origin:kt},messageContext:c,savedCommonContext:s};i&&(t.domainContext={handlingStack:i}),e.notify(0,t)}}}}const yo={[Jn.ok]:e.debug,[Jn.debug]:e.debug,[Jn.info]:e.info,[Jn.notice]:e.info,[Jn.warn]:e.warn,[Jn.error]:e.error,[Jn.critical]:e.error,[Jn.alert]:e.error,[Jn.emerg]:e.error};function bo(e,t,n,o,r){const i=Yt("browser-logs-sdk",t);i.setContextProvider((()=>{var e,t,n,o,i,s;return{application:{id:null===(e=co())||void 0===e?void 0:e.application_id},session:{id:null===(t=r.findTrackedSession())||void 0===t?void 0:t.id},view:{id:null===(o=null===(n=co())||void 0===n?void 0:n.view)||void 0===o?void 0:o.id},action:{id:null===(s=null===(i=co())||void 0===i?void 0:i.user_action)||void 0===s?void 0:s.id}}}));const s=[];if(wn()){const e=vn(),t=i.observable.subscribe((t=>e.send("internal_telemetry",t)));s.push((()=>t.unsubscribe()))}else{const e=_n(t,{endpoint:t.rumEndpointBuilder,encoder:En()},t.replica&&{endpoint:t.replica.rumEndpointBuilder,encoder:En()},n,o,r.expireObservable);s.push((()=>e.stop()));const a=i.observable.subscribe((n=>e.add(n,function(e){return"datad0g.com"===e.site}(t))));s.push((()=>a.unsubscribe()))}return Jt.drain(),function(e){Vt({type:Ht,configuration:e})}(function(e){const t={session_sample_rate:(n=e).sessionSampleRate,telemetry_sample_rate:n.telemetrySampleRate,telemetry_configuration_sample_rate:n.telemetryConfigurationSampleRate,telemetry_usage_sample_rate:n.telemetryUsageSampleRate,use_before_send:!!n.beforeSend,use_partitioned_cross_site_session_cookie:n.usePartitionedCrossSiteSessionCookie,use_secure_session_cookie:n.useSecureSessionCookie,use_proxy:!!n.proxy,silent_multiple_init:n.silentMultipleInit,track_session_across_subdomains:n.trackSessionAcrossSubdomains,track_anonymous_user:n.trackAnonymousUser,session_persistence:n.sessionPersistence,allow_fallback_to_local_storage:!!n.allowFallbackToLocalStorage,store_contexts_across_pages:!!n.storeContextsAcrossPages,allow_untrusted_events:!!n.allowUntrustedEvents,tracking_consent:n.trackingConsent};var n;return{forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports,use_pci_intake:e.usePciIntake,...t}}(e)),{telemetry:i,stop:()=>{s.forEach((e=>e()))}}}const vo=function(e){const t=Nn(),n=Mn("global context",{customerDataTracker:t.getOrCreateTracker(2)}),o=Mn("user",{customerDataTracker:t.getOrCreateTracker(1),propertiesConfig:{id:{type:"string"},name:{type:"string"},email:{type:"string"}}}),r=Mn("account",{customerDataTracker:t.getOrCreateTracker(1),propertiesConfig:{id:{type:"string",required:!0},name:{type:"string"}}}),i=function(e){const t=new U;return{tryToInit(t){e||(e=t)},update(n){e=n,t.notify()},isGranted:()=>e===Te.GRANTED,observable:t}}();function s(){return function(e,t,n){return{view:{referrer:document.referrer,url:window.location.href},context:e.getContext(),user:t.getContext(),account:n.getContext()}}(n,o,r)}let a=oo(s,i,((t,c)=>{t.storeContextsAcrossPages&&(jn(c,n,ro,2),jn(c,o,ro,1),jn(c,r,ro,4));const u=e(t,c,s,i);return a=function(e,t){return{init:e=>{Tt("DD_LOGS",e)},initConfiguration:e,...t}}(t,u),u}));const c={};return function(e){const t={version:"6.6.2",onReady(e){e()},...e};return Object.defineProperty(t,"_setDebug",{get:()=>T,enumerable:!1}),t}({logger:new eo(((...e)=>a.handleLog(...e)),t.createDetachedTracker()),init:$((e=>a.init(e))),setTrackingConsent:$((e=>{i.update(e),Vt({type:zt,usage:{feature:"set-tracking-consent",tracking_consent:e}})})),getGlobalContext:$((()=>n.getContext())),setGlobalContext:$((e=>n.setContext(e))),setGlobalContextProperty:$(((e,t)=>n.setContextProperty(e,t))),removeGlobalContextProperty:$((e=>n.r