UNPKG

@ekko-earth/ekko-js

Version:

A framework-agnostic web SDK for displaying carbon impact.

1 lines 61.3 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EkkoJS={})}(this,(function(e){"use strict";const t={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},n=console,o={};Object.keys(t).forEach((e=>{o[e]=n[e]}));const r="Datadog Browser SDK:",i={debug:o.debug.bind(n,r),log:o.log.bind(n,r),info:o.info.bind(n,r),warn:o.warn.bind(n,r),error:o.error.bind(n,r)},s="https://docs.datadoghq.com",a=`${s}/real_user_monitoring/browser/troubleshooting`,c="More details:";function u(e,t){return(...n)=>{try{return e(...n)}catch(e){i.error(t,e)}}}function l(e){return 0!==e&&100*Math.random()<=e}const d=1e3,f=6e4;function p(){return(new Date).getTime()}function g(){return p()}function m(){return performance.now()}function h(){return{relative:m(),timeStamp:g()}}let y;function b(){return void 0===y&&(y=performance.timing.navigationStart),y}const v=1024,w=/[^\u0000-\u007F]/;function k(e){return w.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 C(e){return 0===Object.keys(e).length}function x(){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 E(e,t){const n=x();let o;return n.Zone&&"function"==typeof n.Zone.__symbol__&&(o=e[n.Zone.__symbol__(t)]),o||(o=e[t]),o}let _,R=!1;function T(e){R=e}function $(e){return function(){return O(e,this,arguments)}}function O(e,t,n){try{return e.apply(t,n)}catch(e){I(e)}}function I(e){if(L(e),_)try{_(e)}catch(e){L(e)}}function L(...e){R&&i.error("[MONITOR]",...e)}function A(e,t){return E(x(),"setTimeout")($(e),t)}function P(e){E(x(),"clearTimeout")(e)}function D(e,t){return E(x(),"setInterval")($(e),t)}function U(e){E(x(),"clearInterval")(e)}class M{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 j(...e){return new M((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=A((()=>{o&&e(...o),i=!1,o=void 0}),t))},cancel:()=>{P(r),i=!1,o=void 0}}}function B(){}function N(e){return e?(parseInt(e,10)^16*Math.random()>>parseInt(e,10)/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,N)}const F=/([\w-]+)\s*=\s*([^;]+)/g;function H(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 z(){return 0===(null!=G?G:G=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 G,W,J;function Y(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 K(e){return function(e,t){for(F.lastIndex=0;;){const n=F.exec(e);if(!n)break;if(n[1]===t)return n[2]}}(document.cookie,e)}function V(e){return W||(W=function(e){const t=new Map;for(F.lastIndex=0;;){const n=F.exec(e);if(!n)break;t.set(n[1],n[2])}return t}(document.cookie)),W.get(e)}function X(e,t){Y(e,"",0,t)}const Z="_dd_s";function Q(e){return Object.values(e)}const ee=144e5,te=9e5,ne=31536e6,oe="cookie",re="local-storage",ie=/^([a-zA-Z]+)=([a-z0-9-]+)$/;function se(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=N()),n}function ae(e){return C(e)}function ce(e){return!ae(e)}function ue(e){return void 0!==e.isExpired||!((void 0===(t=e).created||p()-Number(t.created)<ee)&&(void 0===t.expire||p()<Number(t.expire)));var t}function le(e){e.expire=String(p()+te)}function de(e){return(t=e,Object.entries(t)).map((([e,t])=>"anonymousId"===e?`aid=${t}`:`${e}=${t}`)).join("&");var t}function fe(e){const t={};return function(e){return!!e&&(-1!==e.indexOf("&")||ie.test(e))}(e)&&e.split("&").forEach((e=>{const n=ie.exec(e);if(null!==n){const[,e,o]=n;"aid"===e?t.anonymousId=o:t[e]=o}})),t}function pe(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===J){const e=`dd_site_test_${N()}`,t="test",n=window.location.hostname.split(".");let o=n.pop();for(;n.length&&!K(e);)o=`${n.pop()}.${o}`,Y(e,t,d,{domain:o});X(e,{domain:o}),J=o}return J}());return t}(e);return function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{const t=`dd_cookie_test_${N()}`,n="test";Y(t,n,f,e);const o=K(t)===n;return X(t,e),o}catch(e){return i.error(e),!1}}(t)?{type:oe,cookieOptions:t}:void 0}function ge(e,t){const n={isLockEnabled:z(),persistSession:(o=t,e=>{Y(Z,de(e),te,o)}),retrieveSession:me,expireSession:n=>function(e,t,n){const o=se(t,n);Y(Z,de(o),n.trackAnonymousUser?ne:ee,e)}(t,n,e)};var o;return function(e){if(!V(Z)){const t=V("_dd"),n=V("_dd_r"),o=V("_dd_l"),r={};t&&(r.id=t),o&&/^[01]$/.test(o)&&(r.logs=o),n&&/^[012]$/.test(n)&&(r.rum=n),ce(r)&&(le(r),e.persistSession(r))}}(n),n}function me(){return fe(K(Z))}function he(){try{const e=N(),t=`_dd_test_${e}`;localStorage.setItem(t,e);const n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:re}:void 0}catch(e){return}}function ye(e){return{isLockEnabled:!1,persistSession:be,retrieveSession:ve,expireSession:t=>function(e,t){be(se(e,t))}(t,e)}}function be(e){localStorage.setItem(Z,de(e))}function ve(){return fe(localStorage.getItem(Z))}const we=[];let ke;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(ke||(ke=e),e!==ke)return void we.push(e);if(r&&n>=100)return void xe(t);let u,l=c();if(r){if(l.lock)return void Ce(e,t,n);if(u=N(),a(l.session),l=c(),l.lock!==u)return void Ce(e,t,n)}let d=e.process(l.session);if(r&&(l=c(),l.lock!==u))Ce(e,t,n);else{if(d&&(ue(d)?s(d):(le(d),r?a(d):i(d))),r&&(!d||!ue(d))){if(l=c(),l.lock!==u)return void Ce(e,t,n);i(l.session),d=l.session}null===(o=e.after)||void 0===o||o.call(e,d||l.session),xe(t)}}function Ce(e,t,n){A((()=>{Se(e,t,n+1)}),10)}function xe(e){ke=void 0;const t=we.shift();t&&Se(t,e)}const Ee=d;function _e(e){switch(e.sessionPersistence){case oe:return pe(e);case re:return he();case void 0:{let t=pe(e);return!t&&e.allowFallbackToLocalStorage&&(t=he()),t}default:i.error(`Invalid session persistence '${String(e.sessionPersistence)}'`)}}function Re(e,t,n,o){const r=new M,i=new M,s=new M,a=e.type===oe?ge(t,e.cookieOptions):ye(t),{expireSession:c}=a,u=D((function(){Se({process:e=>ue(e)?se(e,t):void 0,after:g},a)}),Ee);let l;m();const{throttled:d,cancel:f}=q((()=>{Se({process:e=>{if(ae(e))return;const t=g(e);return function(e){if(ae(e))return!1;const{trackingType:t,isTracked:r}=o(e[n]);e[n]=t,delete e.isExpired,r&&!e.id&&(e.id=N(),e.created=String(p()))}(t),t},after:e=>{ce(e)&&!h()&&function(e){l=e,r.notify()}(e),l=e}},a)}),Ee);function g(e){return ue(e)&&(e=se(e,t)),h()&&(!function(e){return l.id!==e.id||l[n]!==e[n]}(e)?(s.notify({previousState:l,newState:e}),l=e):(l=se(l,t),i.notify())),e}function m(){Se({process:e=>{if(ae(e))return se(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:()=>{f(),c(l),g(se(l,t))},stop:()=>{U(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=Oe(Object.prototype),r=Oe(Array.prototype),i=Oe(Object.getPrototypeOf(e)),s=Oe(e);try{return JSON.stringify(e,t,n)}catch(e){return"<error: unable to serialize object>"}finally{o(),r(),i(),s()}}function Oe(e){const t=e,n=t.toJSON;return n?(delete t.toJSON,()=>{t.toJSON=n}):B}function Ie(e){return function(e,t){const n=function(){if(void 0===Ae)try{const e=new Le("http://test/path");Ae="http://test/path"===e.href}catch(e){Ae=!1}return Ae?Le: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 Le=URL;let Ae;const Pe="dd0g-gov.com",De="datadoghq.com",Ue="pci.browser-intake-datadoghq.com",Me=["ddsource","ddtags"];function je(e,t,n){const o=function(e,t){const n=`/api/v2/${t}`,o=e.proxy;if("string"==typeof o){const e=Ie(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=De,internalAnalyticsSubdomain:o}=t;if("logs"===e&&t.usePciIntake&&n===De)return Ue;if(o&&n===De)return`${o}.${De}`;if(n===Pe)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=${N()}`];s&&c.push(`dd-evp-encoding=${s}`);"rum"===n&&c.push(`batch_time=${g()}`);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))&&i.warn(`${e} value doesn't meet tag requirements and will be sanitized. ${c} ${s}/getting_started/tagging/#defining-tags`);return`${e}:${t.replace(/,/g,"_")}`}function Be(e){const t=e.site||De,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:je(e,"logs",t),rumEndpointBuilder:je(e,"rum",t),profilingEndpointBuilder:je(e,"profile",t),sessionReplayEndpointBuilder:je(e,"replay",t)}}(e,n),r=function(e,t){if(!e.replica)return;const n={...e,site:De,clientToken:e.replica.clientToken},o={logsEndpointBuilder:je(n,"logs",t),rumEndpointBuilder:je(n,"rum",t)};return{applicationId:e.replica.applicationId,...o}}(e,n);return{replica:r,site:t,...o}}function Ne(e,t){return null==e||"string"==typeof e||(i.error(`${t} must be defined as a string`),!1)}function Fe(e,t){return!!(void 0===e||(n=e,function(e){return"number"==typeof e}(n)&&n>=0&&n<=100))||(i.error(`${t} Sample Rate should be a number between 0 and 100`),!1);var n}function He(e){var t,n,o,r,a,l;if(e&&e.clientToken){if((!(d=e.site)||"string"!=typeof d||/(datadog|ddog|datad0g|dd0g)/.test(d)||(i.error(`Site should be a valid Datadog site. ${c} ${s}/getting_started/site/.`),0))&&Fe(e.sessionSampleRate,"Session")&&Fe(e.telemetrySampleRate,"Telemetry")&&Fe(e.telemetryConfigurationSampleRate,"Telemetry Configuration")&&Fe(e.telemetryUsageSampleRate,"Telemetry Usage")&&Ne(e.version,"Version")&&Ne(e.env,"Env")&&Ne(e.service,"Service")){var d;if(void 0===e.trackingConsent||S(Te,e.trackingConsent))return{beforeSend:e.beforeSend&&u(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!==(r=e.telemetryUsageSampleRate)&&void 0!==r?r:5,service:e.service||void 0,silentMultipleInit:!!e.silentMultipleInit,allowUntrustedEvents:!!e.allowUntrustedEvents,trackingConsent:null!==(a=e.trackingConsent)&&void 0!==a?a: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)};i.error('Tracking Consent should be either "granted" or "not-granted"')}}else i.error("Client Token is not configured, we will not send any data.")}var ze;!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"}(ze||(ze={}));const Ge=new Set;function We(e){Array.isArray(e)&&e.filter((e=>S(ze,e))).forEach((e=>{Ge.add(e)}))}function Je(){return Ge}const Ye="?";function Ke(e){const t=[];let n=rt(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=Qe.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]||Ye,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){const t=et.exec(e);if(!t)return;return{args:[],column:t[3]?+t[3]:void 0,func:Ye,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){const t=tt.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||Ye,line:+t[3],url:t[2]}}(e)||function(e){const t=nt.exec(e);if(!t)return;const n=t[3]&&t[3].indexOf(" > eval")>-1,o=ot.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]||Ye,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=Ye),t.push(n))})),{message:rt(e,"message"),name:rt(e,"name"),stack:t}}const Ve="((?:file|https?|blob|chrome-extension|electron|native|eval|webpack|snippet|<anonymous>|\\w+\\.|\\/).*?)",Xe="(?::(\\d+))",Ze=new RegExp(`^\\s*at (.*?) ?\\(${Ve}${Xe}?${Xe}?\\)?\\s*$`,"i"),Qe=new RegExp(`\\((\\S*)${Xe}${Xe}\\)`);const et=new RegExp(`^\\s*at ?${Ve}${Xe}?${Xe}??\\s*$`,"i");const tt=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;const nt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,ot=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function rt(e,t){if("object"!=typeof e||!e||!(t in e))return;const n=e[t];return"string"==typeof n?n:void 0}function it(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]=st.exec(e));return{name:t,message:n}}(e);return{name:i,message:s,stack:r}}const st=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;function at(e){const t=new Error(e);let n;return t.name="HandlingStack",O((()=>{const e=Ke(t);e.stack=e.stack.slice(2),n=ct(e)})),n}function ct(e){let t=ut(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 ut(e){return`${e.name||"Error"}: ${e.message}`}function lt(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;O(n,null,[{target:this,parameters:e,onPostCall:e=>{t=e},handlingStack:o?at("instrumented method"):void 0}]);const s=r.apply(this,e);return t&&O(t,null,[s]),s};return e[t]=s,{stop:()=>{i=!0,e[t]===s&&(e[t]=r)}}}function dt(e,t=225280){const n=Oe(Object.prototype),o=Oe(Array.prototype),r=[],i=new WeakMap,s=ft(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=ft(n.source[s],n.path,s,r,i);if(c+=void 0!==a?JSON.stringify(a).length:4,c+=o,o=1,c>t){gt(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=ft(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){gt(t,"truncated",e);break}n.target[s]=a}}return n(),o(),s}gt(t,"discarded",e)}function ft(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=pt(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 pt(e){try{if(e instanceof Event)return{type:(t=e).type,isTrusted:t.isTrusted,currentTarget:t.currentTarget?pt(t.currentTarget):null,target:t.target?pt(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 gt(e,t,n){i.warn(`The data provided has been ${t} as it is over the limit of ${e} characters:`,n)}const mt="No stack, consider using an instance of Error";function ht({stackTrace:e,originalError:t,handlingStack:n,componentStack:o,startClocks:r,nonErrorPrefix:i,source:s,handling:a}){const c=vt(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(dt(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)?ct(e):mt,d=c?wt(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:yt(t),context:bt(t)}}function yt(e){return vt(e)&&"dd_fingerprint"in e?String(e.dd_fingerprint):void 0}function bt(e){if(null!==e&&"object"==typeof e&&"dd_context"in e)return e.dd_context}function vt(e){return e instanceof Error||"[object Error]"===Object.prototype.toString.call(e)}function wt(e,t){let n=e;const o=[];for(;vt(null==n?void 0:n.cause)&&o.length<10;){const e=Ke(n.cause);o.push({message:n.cause.message,source:t,type:null==e?void 0:e.name,stack:e&&ct(e)}),n=n.cause}return o.length?o:void 0}const kt="agent",St="console",Ct="logger",xt="network",Et="source",_t="report";function Rt(e){const t=(t,n)=>{const o=ht({stackTrace:t,originalError:n,startClocks:h(),nonErrorPrefix:"Uncaught",source:Et,handling:"unhandled"});e.notify(o)},{stop:n}=(o=t,lt(window,"onerror",(({parameters:[e,t,n,r,i]})=>{let s;s=vt(i)?Ke(i):it(e,t,n,r),o(s,null!=i?i:e)})));var o;const{stop:r}=function(e){return lt(window,"onunhandledrejection",(({parameters:[t]})=>{const n=t.reason||"Empty reason",o=Ke(n);e(o,n)}))}(t);return{stop:()=>{n(),r()}}}function Tt(e,t){t.silentMultipleInit||i.error(`${e} is already initialized.`)}function $t(e,t,n,o,r){return Ot(e,t,[n],o,r)}function Ot(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=E(u,"addEventListener");function d(){const e=E(u,"removeEventListener");n.forEach((n=>e.call(t,n,a,c)))}return n.forEach((e=>l.call(t,e,a,c))),{stop:d}}const It={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function Lt(e,t){const n=[];t.includes(It.cspViolation)&&n.push(function(e){return new M((t=>{const{stop:n}=$t(e,document,"securitypolicyviolation",(e=>{t.notify(function(e){const t=`'${e.blockedURI}' blocked by '${e.effectiveDirective}' directive`;return At({type:e.effectiveDirective,message:`${It.cspViolation}: ${t}`,originalError:e,csp:{disposition:e.disposition},stack:Pt(e.effectiveDirective,e.originalPolicy?`${t} of the policy "${H(e.originalPolicy,100,"...")}"`:"no policy",e.sourceFile,e.lineNumber,e.columnNumber)})}(e))}));return n}))}(e));const o=t.filter((e=>e!==It.cspViolation));return o.length&&n.push(function(e){return new M((t=>{if(!window.ReportingObserver)return;const n=$(((e,n)=>e.forEach((e=>t.notify(function(e){const{type:t,body:n}=e;return At({type:n.id,message:`${t}: ${n.message}`,originalError:e,stack:Pt(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)),j(...n)}function At(e){return{startClocks:h(),source:_t,handling:"unhandled",...e}}function Pt(e,t,n,o,r){return n?ct({name:e,message:t,stack:[{func:"?",url:n,line:null!=o?o:void 0,column:null!=r?r:void 0}]}):void 0}function Dt(e,t){const n=window.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}function Ut(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function Mt(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]=Mt(o[e],t[e],n);return o}const o="object"===Ut(e)?e:{};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=Mt(o[e],t[e],n));return o}function jt(e){return Mt(void 0,e)}function qt(...e){let t;for(const n of e)null!=n&&(t=Mt(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 Nt(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}function Ft(){const e=[];return{add:t=>{e.push(t)>500&&e.splice(0,1)},remove:t=>{Nt(e,t)},drain:t=>{e.forEach((e=>e(t))),e.length=0}}}const Ht="log",zt="configuration",Gt="usage",Wt=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],Jt=["ddog-gov.com"];let Yt=Ft(),Kt=e=>{Yt.add((()=>Kt(e)))};function Vt(e,t){let n;const o=new M,r=new Set,i=!Jt.includes(t.site)&&l(t.telemetrySampleRate),s={[Ht]:i,[zt]:i&&l(t.telemetryConfigurationSampleRate),[Gt]:i&&l(t.telemetryUsageSampleRate)},a={is_local_file:"file:"===window.location.protocol,is_worker:"WorkerGlobalScope"in self};return Kt=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:g(),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(Je())},void 0!==n?n():{})}(e,i,a);o.notify(t),Dt("telemetry",t),r.add(c)}},_=Zt,{setContextProvider:e=>{n=e},observable:o,enabled:i}}function Xt(e,n){L(t.debug,e,n),Kt({type:Ht,message:e,status:"debug",...n})}function Zt(e,t){Kt({type:Ht,status:"error",...Qt(e),...t})}function Qt(e){if(vt(e)){const t=Ke(e);return{error:{kind:t.name,stack:ct(en(t))},message:t.message}}return{error:{stack:mt},message:`Uncaught ${$e(e)}`}}function en(e){return e.stack=e.stack.filter((e=>!e.url||Wt.some((t=>e.url.startsWith(t))))),e}const tn=1/0;let nn=null;const on=new Set;function rn({expireDelay:e,maxEntries:t}){let n=[];const o=[];nn||(nn=D((()=>{on.forEach((e=>e()))}),6e4));const r=()=>{const t=m()-e;for(;n.length>0&&n[n.length-1].endTime<t;){const e=n.pop();e&&o.push(e.startTime)}};return on.add(r),{add:function(e,o){const r={value:e,startTime:o,endTime:tn,remove:()=>{Nt(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===tn&&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(){on.delete(r),0===on.size&&nn&&(U(nn),nn=null)},getAllEntries:function(){return n.map((({startTime:e,endTime:t,value:n})=>({startTime:e,endTime:t===tn?"Infinity":t,value:n})))},getDeletedEntries:function(){return o}}}const sn=f,an=ee;function cn(e,t,n,o){const r=new M,i=new M,s=Re(e.sessionStoreStrategyType,e,t,n),a=rn({expireDelay:an});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(),m()),r.notify()})),s.expireObservable.subscribe((()=>{i.notify(),a.closeActive(m())})),s.expandOrRenewSession(),a.add(c(),[0,b()][0]),o.observable.subscribe((()=>{o.isGranted()?s.expandOrRenewSession():s.expire()})),function(e,t){const{stop:n}=Ot(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);D(n,sn)}(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 un(e){return e>=500}const ln=3145728,dn=d;function fn(e,t,n,o,r){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?gn(e,t,n,{onSuccess:()=>mn(0,t,n,o,r),onFailure:()=>{t.queuedPayloads.enqueue(e),pn(t,n,o,r)}}):t.queuedPayloads.enqueue(e)}function pn(e,t,n,o){2===e.transportStatus&&A((()=>{gn(e.queuedPayloads.first(),e,t,{onSuccess:()=>{e.queuedPayloads.dequeue(),e.currentBackoffTime=dn,mn(1,e,t,n,o)},onFailure:()=>{e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),pn(e,t,n,o)}})}),e.currentBackoffTime)}function gn(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||un(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 mn(e,t,n,o,r){0===e&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(r({message:`Reached max ${o} events size queued for upload: 3MiB`,source:kt,startClocks:h()}),t.queueFullReported=!0);const i=t.queuedPayloads;for(t.queuedPayloads=hn();i.size()>0;)fn(i.dequeue(),t,n,o,r)}function hn(){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>=ln}}}function yn(e,t,n){const o={transportStatus:0,currentBackoffTime:dn,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:hn(),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($((()=>vn(e,n,o))))}else vn(e,n,o)}(e,t,n,o);return{send:t=>{fn(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){bn||(bn=!0,I(e))}(e)}vn(e,n)}(e,t,n)}}}let bn=!1;function vn(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 wn(){const e=x().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 kn(e){var t;void 0===e&&(e=null===(t=x().location)||void 0===t?void 0:t.hostname);const n=wn();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 Cn({encoder:e,request:t,flushController:n,messageBytesLimit:o}){let r={};const s=n.flushObservable.subscribe((n=>function(n){const o=Q(r).join("\n");r={};const i=(a=n.reason,Q(Sn).includes(a)),s=i?t.sendOnExit:t.send;var a;if(i&&e.isAsync){const t=e.finishSync();t.outputBytesCount&&s(xn(t));const n=[t.pendingData,o].filter(Boolean).join("\n");n&&s({data:n,bytesCount:k(n)})}else o&&e.write(e.isEmpty?o:`\n${o}`),e.finish((e=>{s(xn(e))}))}(n)));function u(t,s){const u=$e(t),l=e.estimateEncodedBytesCount(u);l>=o?i.warn(`Discarded a message whose size was bigger than the maximum allowed size ${o}KB. ${c} ${a}/#technical-limitations`):(function(e){return void 0!==e&&void 0!==r[e]}(s)&&function(t){const o=r[t];delete r[t];const i=e.estimateEncodedBytesCount(o);n.notifyAfterRemoveMessage(i)}(s),function(t,o,i){n.notifyBeforeAddMessage(o),void 0!==i?(r[i]=t,n.notifyAfterAddMessage()):e.write(e.isEmpty?t:`\n${t}`,(e=>{n.notifyAfterAddMessage(e-o)}))}(u,l,s))}return{flushController:n,add:u,upsert:u,stop:s.unsubscribe}}function xn(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 En({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 M((()=>()=>{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(){P(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=A((()=>{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=Cn){const a=u(e,t),c=n&&u(e,n);function u(e,{endpoint:t,encoder:n}){return s({encoder:n,request:yn(t,e.batchBytesLimit,o),flushController:En({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 Rn(){let e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write(n,o){const r=k(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 On(e){return Tn||(Tn=function(e){return new M((t=>{const{stop:n}=lt(XMLHttpRequest.prototype,"open",In),{stop:o}=lt(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=h(),i.isAborted=!1,i.xhr=e,i.handlingStack=t;let s=!1;const{stop:a}=lt(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,g()-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}=lt(XMLHttpRequest.prototype,"abort",Ln);return()=>{n(),o(),r()}}))}(e)),Tn}function In({target:e,parameters:[t,n]}){$n.set(e,{state:"open",method:String(t).toUpperCase(),url:Ie(String(n))})}function Ln({target:e}){const t=$n.get(e);t&&(t.isAborted=!0)}let An;function Pn(){return An||(An=new M((e=>{if(!window.fetch)return;const{stop:t}=lt(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:Ie(String(r)),u=h(),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}))),An}let Dn={};function Un(e){return j(...e.map((e=>(Dn[e]||(Dn[e]=function(e){return new M((o=>{const r=n[e];return n[e]=(...n)=>{r.apply(console,n);const i=at("console error");O((()=>{o.notify(function(e,n,o){const r=e.map((e=>function(e){if("string"==typeof e)return dt(e);if(vt(e))return ut(Ke(e));return $e(dt(e),void 0,2)}(e))).join(" ");let i;if(n===t.error){const t=e.find(vt);i={stack:t?ct(Ke(t)):void 0,fingerprint:yt(t),causes:t?wt(t,"console"):void 0,startClocks:h(),message:r,source:St,handling:"handled",handlingStack:o,context:bt(t)}}return{api:n,message:r,error:i,handlingStack:o}}(n,e,i))}))},()=>{n[e]=r}}))}(e)),Dn[e]))))}function Mn(e,t,n){const o={...e};for(const[r,{required:s,type:a}]of Object.entries(t))"string"===a&&r in o&&(o[r]=String(o[r])),s&&!(r in e)&&i.warn(`The property ${r} of ${n} is required; context will not be sent to the intake.`);return o}function jn(e="",{customerDataTracker:t,propertiesConfig:n={}}={}){let o={};const r=new M,s={getContext:()=>jt(o),setContext:a=>{!function(e){const t="object"===Ut(e);return t||i.error("Unsupported context:",e),t}(a)?s.clearContext():(o=dt(Mn(a,n,e)),null==t||t.updateCustomerData(o)),r.notify()},setContextProperty:(i,s)=>{o=dt(Mn({...o,[i]:s},n,e)),null==t||t.updateCustomerData(o),r.notify()},removeContextProperty:i=>{delete o[i],null==t||t.updateCustomerData(o),Mn(o,n,e),r.notify()},clearContext:()=>{o={},null==t||t.resetCustomerData(),r.notify()},changeObservable:r};return s}const qn="_dd_c",Bn=[];function Nn(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):{}}C(i)||t.setContext(i)}function Fn(e=2){const t=new Map;let n=!1;function o(o=0){if(n||0===e)return;const r=2===e?3072:16384;let s=o;t.forEach((e=>{s+=e.getBytesCount()})),s>r&&(!function(e){i.warn(`Customer data exceeds the recommended ${e/v}KiB threshold. ${c} ${a}/#customer-data-exceeds-the-recommended-threshold-warning`)}(r),n=!0)}return{createDetachedTracker:()=>{const e=Hn((()=>o(e.getBytesCount())));return e},getOrCreateTracker:e=>(t.has(e)||t.set(e,Hn(o)),t.get(e)),setCompressionStatus:t=>{0===e&&(e=t,o())},getCompressionStatus:()=>e,stop:()=>{t.forEach((e=>e.stop())),t.clear()}}}function Hn(e){let t=0;const{throttled:n,cancel:o}=q((n=>{t=k($e(n)),e()}),200),r=()=>{o(),t=0};return{updateCustomerData:e=>{C(e)?r():n(e)},resetCustomerData:r,getBytesCount:()=>t,stop:()=>{o()}}}function zn(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||V("datadog-synthetics-injects-rum"))}function Gn(){const e=window._DATADOG_SYNTHETICS_PUBLIC_ID||V("datadog-synthetics-public-id");return"string"==typeof e?e:void 0}function Wn(){const e=window._DATADOG_SYNTHETICS_RESULT_ID||V("datadog-synthetics-result-id");return"string"==typeof e?e:void 0}function Jn(e,t,n){const o=n.getHandler(),r=Array.isArray(o)?o:[o];return Kn[e]>=Kn[n.getLevel()]&&r.includes(t)}const Yn={ok:"ok",debug:"debug",info:"info",notice:"notice",warn:"warn",error:"error",critical:"critical",alert:"alert",emerg:"emerg"},Kn={[Yn.ok]:0,[Yn.debug]:1,[Yn.info]:2,[Yn.notice]:4,[Yn.warn]:5,[Yn.error]:6,[Yn.critical]:7,[Yn.alert]:8,[Yn.emerg]:9};function Vn(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",Qn="http",eo=Object.keys(Yn);class to{constructor(e,t,n,o=Qn,r=Yn.debug,i={}){this.handleLogStrategy=e,this.handlerType=o,this.level=r,this.contextManager=jn("logger",{customerDataTracker:t}),this.contextManager.setContext(i),n&&this.contextManager.setContextProperty("logger",{name:n})}logImplementation(e,t,n=Yn.info,o,r){const i=dt(t);let s;if(null!=o){s=qt({error:Vn(ht({stackTrace:vt(o)?Ke(o):void 0,originalError:o,nonErrorPrefix:"Provided",source:Ct,handling:"handled",startClocks:h()}),{includeMessage:!0})},i)}else s=i;this.handleLogStrategy({message:dt(e),context:s,status:n},this,r)}log(e,t,n=Yn.info,o){let r;Jn(n,Qn,this)&&(r=at("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 no(e){return function(t,n,o){let r;Jn(e,Qn,this)&&(r=at("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)}}],to.prototype,"logImplementation",null),to.prototype.ok=no(Yn.ok),to.prototype.debug=no(Yn.debug),to.prototype.info=no(Yn.info),to.prototype.notice=no(Yn.notice),to.prototype.warn=no(Yn.warn),to.prototype.error=no(Yn.error),to.prototype.critical=no(Yn.critical),to.prototype.alert=no(Yn.alert),to.prototype.emerg=no(Yn.emerg);function oo(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 i.error(`${n} should be "all" or an array with allowed values "${t.join('", "')}"`)}function ro(e,n,o){const r=Ft();let s,a;const c=n.observable.subscribe(u);function u(){if(!a||!s||!n.isGranted())return;c.unsubscribe();const e=o(s,a);r.drain(e)}return{init(e){if(!e)return void i.error("Missing configuration");if(We(e.enableExperimentalFeatures),kn()&&(e=function(e){return{...e,clientToken:"empty"}}(e)),s=e,a)return void Tt("DD_LOGS",e);const o=function(e){!0===e.usePciIntake&&e.site&&"datadoghq.com"!==e.site&&i.warn("PCI compliance for Logs is only available for Datadog organizations in the US1 site. Default intake will be used.");const n=He(e),o=oo(e.forwardConsoleLogs,Q(t),"Forward Console Logs"),r=oo(e.forwardReports,Q(It),"Forward Reports");if(n&&o&&r)return e.forwardErrorsToLogs&&!o.includes(t.error)&&o.push(t.error),{forwardErrorsToLogs:!1!==e.forwardErrorsToLogs,forwardConsoleLogs:o,forwardReports:r,requestErrorResponseLengthLimit:32768,...n}}(e);o&&(a=o,Pn().subscribe(B),n.tryToInit(o.trackingConsent),u())},get initConfiguration(){return s},getInternalContext:B,handleLog(t,n,o,i=e(),s=g()){r.add((e=>e.handleLog(t,n,o,i,s)))}}}const io="logs";function so(e,t){const n=cn(e,"logs",(t=>function(e,t){const n=function(e){return"0"===e||"1"===e}(t)?t:ao(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 ao(e){return l(e.sessionSampleRate)?"1":"0"}let co=!1;function uo(e){const t=window;if(zn()){const e=n(t.DD_RUM_SYNTHETICS);return e||co||(co=!0,Xt("Logs sent before RUM is injected by the synthetics worker",{testId:Gn(),resultId:Wn()})),e}return n(t.DD_RUM);function n(t){if(t&&t.getInternalContext)return t.getInternalContext(e)}}function lo(e,t,n,o,r){const i=eo.concat(["custom"]),s={};i.forEach((e=>{s[e]=function(e,t,n){let o=0,r=!1;return{isLimitReached(){if(0===o&&A((()=>{o=0}),f),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:kt,startClocks:h()})}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-b();const f=e.findTrackedSession(d);if(!e.findTrackedSession(d,{returnInactive:!0}))return;const p=a||o();let g;!C(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:C(p.user)?void 0:p.user,account:g,view:p.view},p.context,uo(d),r,i);!1===(null===(u=t.beforeSend)||void 0===u?void 0:u.call(t,m,c))||m.origin!==kt&&(null!==(l=s[m.status])&&void 0!==l?l:s.custom).isLimitReached()||n.notify(1,m)}))}const fo={[t.log]:Yn.info,[t.debug]:Yn.debug,[t.info]:Yn.info,[t.warn]:Yn.warn,[t.error]:Yn.error};function po(e,t){if(!e.forwardErrorsToLogs)return{stop:B};const n=On(e).subscribe((e=>{"complete"===e.state&&r("xhr",e)})),o=Pn().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:`${mo(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:Yn.error,origin:xt},domainContext:r})}r=o.url,Me.every((e=>r.includes(e)))||!function(e){return 0===e.status&&"opaque"!==e.responseType}(o)&&!un(o.status)||("xhr"in o?function(e,t,n){"string"==typeof e.response?n(go(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(go(e,t)))),$((e=>n(`Unable to retrieve response: ${e}`)))):n()}(o.response,e,i):o.error&&function(e,t,n){n(go(ct(Ke(e)),t))}(o.error,e,i))}return{stop:()=>{n.unsubscribe(),o.unsubscribe()}}}function go(e,t){return e.length>t.requestErrorResponseLengthLimit?`${e.substring(0,t.requestErrorResponseLengthLimit)}...`:e}function mo(e){return"xhr"===e?"XHR":"Fetch"}const ho=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 yo(e){return{handleLog:function(t,r,i,s,a){const c=qt(r.getContext(),t.context);if(Jn(t.status,Zn,r)&&function({status:e,message:t},r){o[bo[e]].call(n,t,r)}(t,c),Jn(t.status,Qn,r)){const n={rawLogsEvent:{date:a||g(),message:t.message,status:t.status,origin:Ct},messageContext:c,savedCommonContext:s};i&&(n.domainContext={handlingStack:i}),e.notify(0,n)}}}}const bo={[Yn.ok]:t.debug,[Yn.debug]:t.debug,[Yn.info]:t.info,[Yn.notice]:t.info,[Yn.warn]:t.warn,[Yn.error]:t.error,[Yn.critical]:t.error,[Yn.alert]:t.error,[Yn.emerg]:t.error};function vo(e,t,n,o,r){const i=Vt("browser-logs-sdk",t);i.setContextProvider((()=>{var e,t,n,o,i,s;return{application:{id:null===(e=uo())||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=uo())||void 0===n?void 0:n.view)||void 0===o?void 0:o.id},action:{id:null===(s=null===(i=uo())||void 0===i?void 0:i.user_action)||void 0===s?void 0:s.id}}}));const s=[];if(kn()){const e=wn(),t=i.observable.subscribe((t=>e.send("internal_telemetry",t)));s.push((()=>t.unsubscribe()))}else{const e=_n(t,{endpoint:t.rumEndpointBuilder,encoder:Rn()},t.replica&&{endpoint:t.replica.rumEndpointBuilder,encoder:Rn()},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 Yt.drain(),function(e){Kt({type:zt,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 wo=function(e){const t=Fn(),n=jn("global context",{customerDataTracker:t.getOrCreateTracker(2)}),o=jn("user",{customerDataTracker:t.getOrCreateTracker(1),propertiesConfig:{id:{type:"string"},name:{type:"string"},email:{type:"string"}}}),r=jn("account",{customerDataTracker:t.getOrCreateTracker(1),propertiesConfig:{id:{type:"string",required:!0},name:{type:"string"}}}),i=function(e){const t=new M;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=ro(s,i,((t,c)=>{t.storeContextsAcrossPages&&(Nn(c,n,io,2),Nn(c,o,io,1),Nn(c,r,io,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 to(((...e)=>a.handleLog(...e)),t.createDetachedTracker()),init:$((e=>a.init(e))),setTrackingConsent:$((e=>{i.update(e),Kt({type:Gt,usa