@montonio/montonio-js 1.0.59 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/montonio.es.js +2 -2
- package/dist/montonio.umd.js +2 -2
- package/dist/montonio.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/montonio.es.js
CHANGED
|
@@ -90,7 +90,7 @@ class se {
|
|
|
90
90
|
try {
|
|
91
91
|
const i = {
|
|
92
92
|
Accept: "application/json",
|
|
93
|
-
"X-Montonio-Js-Version": "1.0
|
|
93
|
+
"X-Montonio-Js-Version": "1.1.0"
|
|
94
94
|
};
|
|
95
95
|
r && (i["Content-Type"] = "application/json");
|
|
96
96
|
const c = {
|
|
@@ -3492,7 +3492,7 @@ class ae {
|
|
|
3492
3492
|
env: t === Ce.PRODUCTION ? "live-production" : "live-sandbox",
|
|
3493
3493
|
forwardErrorsToLogs: !0,
|
|
3494
3494
|
service: "montonio-js",
|
|
3495
|
-
version: "1.0
|
|
3495
|
+
version: "1.1.0",
|
|
3496
3496
|
silentMultipleInit: !0,
|
|
3497
3497
|
forwardConsoleLogs: "all"
|
|
3498
3498
|
}), Me.setGlobalContext({
|
package/dist/montonio.umd.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
`);super(`Invalid CheckoutOptions provided:
|
|
4
4
|
${n}
|
|
5
5
|
|
|
6
|
-
Please fix these validation errors and try again.`),this.name=m.ErrorEnum.CHECKOUT_OPTIONS_VALIDATION_ERROR}}m.MessageTypeEnum=void 0,function(e){e.CHECKOUT_PAYMENT_COMPONENT_READY="montonio:checkout.paymentComponentReady",e.CHECKOUT_CHANGE_LOCALE="montonio:checkout.changeLocale",e.CHECKOUT_SUBMIT_PAYMENT="montonio:checkout.submitPayment",e.CHECKOUT_START_PAYMENT_AUTH="montonio:checkout.startPaymentAuth",e.CHECKOUT_SEND_PAYMENT_AUTH_DATA="montonio:checkout.sendPaymentAuthData",e.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY="montonio:checkout.paymentAuthComponentReady",e.CHECKOUT_PAYMENT_AUTH_COMPLETED="montonio:checkout.paymentAuthCompleted",e.CHECKOUT_PAYMENT_COMPLETED="montonio:checkout.paymentCompleted",e.CHECKOUT_PAYMENT_FAILED="montonio:checkout.paymentFailed",e.CHECKOUT_SEND_PAYMENT_FAILED_DATA="montonio:checkout.sendPaymentFailedData",e.CHECKOUT_HEIGHT_CHANGED="montonio:checkout.heightChanged",e.CHECKOUT_VALIDATE_FIELDS="montonio:checkout.validateFields",e.CHECKOUT_VALIDATE_FIELDS_RESULT="montonio:checkout.validateFieldsResult",e.CHECKOUT_PAYMENT_FORM_CHANGED="montonio:checkout.paymentFormChanged"}(m.MessageTypeEnum||(m.MessageTypeEnum={}));class K{constructor(){this.environmentVariables={stargateUrl:{sandbox:"https://sandbox-stargate.montonio.com",production:"https://stargate.montonio.com","prelive-sandbox":"https://sandbox-stargate.prelive.montonio.com","prelive-production":"https://stargate.prelive.montonio.com",development:"https://api-stargate.montonio.dev"},datadogClientToken:"pubb5b1ffe19aeb16a90d1181fd3e866b83"}}static get instance(){return K._instance||(K._instance=new K),K._instance}getConfig(t,n){const r=this.environmentVariables[t];if(typeof r=="string")return r;if(!n)throw new Error(`Environment parameter required for config key: ${t}`);return r[n]}}class oe{constructor(){this.timeout=3e4}static get instance(){return oe._instance||(oe._instance=new oe),oe._instance}async get(t){return this.request(t,"GET")}async post(t,n){return this.request(t,"POST",n)}async patch(t,n){return this.request(t,"PATCH",n)}async request(t,n,r){const o=new AbortController,s=setTimeout(()=>o.abort(),this.timeout);try{const i={Accept:"application/json","X-Montonio-Js-Version":"1.0.59"};r&&(i["Content-Type"]="application/json");const c={method:n,headers:i,credentials:"include",mode:"cors",signal:o.signal};r&&(c.body=JSON.stringify(r));const a=await fetch(t,c);if(!a.ok)throw new Error(`HTTP error ${a.status}: ${a.statusText}`);return await a.json()}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timeout after ${this.timeout}ms`):i}finally{clearTimeout(s)}}}class Mt{constructor(){this.subscriptions=new Map,this.setupMessageListener()}subscribe(t,n,r){if(this.subscriptions.has(t))throw new Error(`Subscription for '${t}' already exists`);const o=this.extractWindowFromIframe(r);this.subscriptions.set(t,{handler:n,sources:[o]})}addIframeToSubscription(t,n){const r=this.subscriptions.get(t);if(!r)throw new Error(`Subscription for '${t}' not found`);const o=this.extractWindowFromIframe(n);r.sources.includes(o)||r.sources.push(o)}waitForMessage(t,n,r=3e4){return new Promise((o,s)=>{const i=setTimeout(()=>{this.removeIframeFromSubscription(t,n),s(new Error(`Message ${t} timeout after ${r}ms`))},r);this.subscribe(t,c=>{clearTimeout(i),this.removeIframeFromSubscription(t,n),o(c)},n)})}postMessage(t,n,r="*"){this.extractWindowFromIframe(t).postMessage(n,r)}clearAllSubscriptions(){this.subscriptions.clear()}clearSubscriptionsExcept(t){for(const n of[...this.subscriptions.keys()])t.includes(n)||this.subscriptions.delete(n)}removeIframeFromSubscription(t,n){const r=this.subscriptions.get(t);if(!r)throw new Error(`Subscription for '${t}' not found`);const o=this.extractWindowFromIframe(n);r.sources=r.sources.filter(s=>s!==o),r.sources.length===0&&this.subscriptions.delete(t)}setupMessageListener(){window.addEventListener("message",t=>{try{if(!t.data||typeof t.data!="object"||!t.data.name)return;const n=t.data;this.subscriptions.forEach((r,o)=>{if(!(o!==n.name||!r.sources.some(i=>i===t.source)))try{r.handler(n)}catch(i){console.error("Error in message handler:",i)}})}catch(n){console.error("Error processing iframe message:",n)}})}extractWindowFromIframe(t){return t.getContentWindow()}}const T={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},N=console,j={};Object.keys(T).forEach(e=>{j[e]=N[e]});const ye="Datadog Browser SDK:",y={debug:j.debug.bind(N,ye),log:j.log.bind(N,ye),info:j.info.bind(N,ye),warn:j.warn.bind(N,ye),error:j.error.bind(N,ye)},Ze="https://docs.datadoghq.com",ir=`${Ze}/real_user_monitoring/browser/troubleshooting`,Qe="More details:";function Dt(e,t){return(...n)=>{try{return e(...n)}catch(r){y.error(t,r)}}}function be(e){return e!==0&&Math.random()*100<=e}function cr(e){return ar(e)&&e>=0&&e<=100}function ar(e){return typeof e=="number"}const se=1e3,D=60*se,$t=60*D,ur=365*(24*$t);function $(){return new Date().getTime()}function U(){return $()}function Ae(){return performance.now()}function x(){return{relative:Ae(),timeStamp:U()}}function lr(){return{relative:0,timeStamp:Ht()}}function Ft(e,t){return t-e}function dr(e,t){return e+t}function fr(e){return e-Ht()}let et;function Ht(){var e,t;return et===void 0&&(et=(t=(e=performance.timing)===null||e===void 0?void 0:e.navigationStart)!==null&&t!==void 0?t:performance.timeOrigin),et}const ie=1024,Bt=1024*ie,mr=/[^\u0000-\u007F]/;function Gt(e){return mr.test(e)?window.TextEncoder!==void 0?new TextEncoder().encode(e).length:new Blob([e]).size:e.length}function pr(e){return{...e}}function Kt(e,t){return Object.keys(e).some(n=>e[n]===t)}function Ie(e){return Object.keys(e).length===0}function R(){if(typeof globalThis=="object")return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get(){return this},configurable:!0});let e=_dd_temp_;return delete Object.prototype._dd_temp_,typeof e!="object"&&(typeof self=="object"?e=self:typeof window=="object"?e=window:e={}),e}const L=R(),z="WorkerGlobalScope"in L;function ce(e,t){const n=R();let r;return n.Zone&&typeof n.Zone.__symbol__=="function"&&(r=e[n.Zone.__symbol__(t)]),r||(r=e[t]),r}let Re,jt=!1;function hr(e){Re=e}function gr(e){jt=e}function Er(e,t,n){const r=n.value;n.value=function(...o){return(Re?b(r):r).apply(this,o)}}function b(e){return function(){return ae(e,this,arguments)}}function ae(e,t,n){try{return e.apply(t,n)}catch(r){tt(r)}}function tt(e){if(nt(e),Re)try{Re(e)}catch(t){nt(t)}}function nt(...e){jt&&y.error("[MONITOR]",...e)}function Se(e,t){return ce(R(),"setTimeout")(b(e),t)}function zt(e){ce(R(),"clearTimeout")(e)}function rt(e,t){return ce(R(),"setInterval")(b(e),t)}function Yt(e){ce(R(),"clearInterval")(e)}function Vt(e){var t;const n=(t=L.queueMicrotask)===null||t===void 0?void 0:t.bind(L);typeof n=="function"?n(b(e)):Promise.resolve().then(b(e))}class S{constructor(t){this.onFirstSubscribe=t,this.observers=[]}subscribe(t){return this.addObserver(t),{unsubscribe:()=>this.removeObserver(t)}}notify(t){this.observers.forEach(n=>n(t))}addObserver(t){this.observers.push(t),this.observers.length===1&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe(this)||void 0)}removeObserver(t){this.observers=this.observers.filter(n=>t!==n),!this.observers.length&&this.onLastUnsubscribe&&this.onLastUnsubscribe()}}function Wt(...e){return new S(t=>{const n=e.map(r=>r.subscribe(o=>t.notify(o)));return()=>n.forEach(r=>r.unsubscribe())})}class qt extends S{constructor(t){super(),this.maxBufferSize=t,this.buffer=[]}notify(t){this.buffer.push(t),this.buffer.length>this.maxBufferSize&&this.buffer.shift(),super.notify(t)}subscribe(t){let n=!1;const r={unsubscribe:()=>{n=!0,this.removeObserver(t)}};return Vt(()=>{for(const o of this.buffer){if(n)return;t(o)}n||this.addObserver(t)}),r}unbuffer(){Vt(()=>{this.maxBufferSize=this.buffer.length=0})}}function yr(e,t,n){let r=!1,o,s;return{throttled:(...i)=>{if(r){o=i;return}e(...i),r=!0,s=Se(()=>{o&&e(...o),r=!1,o=void 0},t)},cancel:()=>{zt(s),r=!1,o=void 0}}}function F(){}function H(e){return e?(parseInt(e,10)^Math.random()*16>>parseInt(e,10)/4).toString(16):`10000000-1000-4000-8000-${1e11}`.replace(/[018]/g,H)}const Le=/([\w-]+)\s*=\s*([^;]+)/g;function br(e,t){for(Le.lastIndex=0;;){const n=Le.exec(e);if(n){if(n[1]===t)return n[2]}else break}}function Sr(e){const t=new Map;for(Le.lastIndex=0;;){const n=Le.exec(e);if(n)t.set(n[1],n[2]);else break}return t}function _r(e,t,n=""){const r=e.charCodeAt(t-1),s=r>=55296&&r<=56319?t+1:t;return e.length<=s?e:`${e.slice(0,s)}${n}`}function Tr(){return Or()===0}let Ne;function Or(){return Ne!=null?Ne:Ne=Cr()}function Cr(e=window){var t;const n=e.navigator.userAgent;return e.chrome||/HeadlessChrome/.test(n)?0:((t=e.navigator.vendor)===null||t===void 0?void 0:t.indexOf("Apple"))===0||/safari/i.test(n)&&!/chrome|android/i.test(n)?1:2}function ot(e){return Jt(e,location.href).href}function Jt(e,t){const{URL:n}=vr();try{return t!==void 0?new n(e,t):new n(e)}catch(r){throw new Error(`Failed to construct URL: ${String(r)}`)}}let st;function vr(){if(!st){let e,t;try{e=document.createElement("iframe"),e.style.display="none",document.body.appendChild(e),t=e.contentWindow}catch(n){t=L}st={URL:t.URL},e==null||e.remove()}return st}function xe(e,t,n=0,r){const o=new Date;o.setTime(o.getTime()+n);const s=`expires=${o.toUTCString()}`,i=r&&r.crossSite?"none":"strict",c=r&&r.domain?`;domain=${r.domain}`:"",a=r&&r.secure?";secure":"",u=r&&r.partitioned?";partitioned":"";document.cookie=`${e}=${t};${s};path=/;samesite=${i}${c}${a}${u}`}function it(e){return br(document.cookie,e)}let ct;function Y(e){return ct||(ct=Sr(document.cookie)),ct.get(e)}function Xt(e,t){xe(e,"",0,t)}function wr(e){if(document.cookie===void 0||document.cookie===null)return!1;try{const t=`dd_cookie_test_${H()}`,n="test";xe(t,n,D,e);const r=it(t)===n;return Xt(t,e),r}catch(t){return y.error(t),!1}}let at;function Zt(e=location.hostname,t=document.referrer){if(at===void 0){const n=Ar(e,t);if(n){const r=`dd_site_test_${H()}`,o="test",s=n.split(".");let i=s.pop();for(;s.length&&!it(r);)i=`${s.pop()}.${i}`,xe(r,o,se,{domain:i});Xt(r,{domain:i}),at=i}}return at}function Ar(e,t){try{return e||Jt(t).hostname}catch(n){}}const B="_dd_s";function Ir(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(t(r,n,e))return r}}function ke(e){return Object.values(e)}function Rr(e){return Object.entries(e)}const ut=4*$t,Qt=15*D,Lr=ur,en="0",_e={COOKIE:"cookie",LOCAL_STORAGE:"local-storage"},tn=/^([a-zA-Z]+)=([a-z0-9-]+)$/,lt="&";function Nr(e){return!!e&&(e.indexOf(lt)!==-1||tn.test(e))}const xr="1";function V(e,t){const n={isExpired:xr};return t.trackAnonymousUser&&(e!=null&&e.anonymousId?n.anonymousId=e==null?void 0:e.anonymousId:n.anonymousId=H()),n}function Ue(e){return Ie(e)}function nn(e){return!Ue(e)}function Te(e){return e.isExpired!==void 0||!kr(e)}function kr(e){return(e.created===void 0||$()-Number(e.created)<ut)&&(e.expire===void 0||$()<Number(e.expire))}function rn(e){e.expire=String($()+Qt)}function on(e){return Rr(e).map(([t,n])=>t==="anonymousId"?`aid=${n}`:`${t}=${n}`).join(lt)}function dt(e){const t={};return Nr(e)&&e.split(lt).forEach(n=>{const r=tn.exec(n);if(r!==null){const[,o,s]=r;o==="aid"?t.anonymousId=s:t[o]=s}}),t}const Ur="_dd",Pr="_dd_r",Mr="_dd_l",Dr="rum",$r="logs";function Fr(e){if(!Y(B)){const n=Y(Ur),r=Y(Pr),o=Y(Mr),s={};n&&(s.id=n),o&&/^[01]$/.test(o)&&(s[$r]=o),r&&/^[012]$/.test(r)&&(s[Dr]=r),nn(s)&&(rn(s),e.persistSession(s))}}function sn(e){const t=Br(e);return t&&wr(t)?{type:_e.COOKIE,cookieOptions:t}:void 0}function Hr(e,t){const n={isLockEnabled:Tr(),persistSession:r=>cn(t,e,r,Qt),retrieveSession:an,expireSession:r=>cn(t,e,V(r,e),ut)};return Fr(n),n}function cn(e,t,n,r){xe(B,on(n),t.trackAnonymousUser?Lr:r,e)}function an(){const e=it(B);return dt(e)}function Br(e){const t={};if(t.secure=!!e.useSecureSessionCookie||!!e.usePartitionedCrossSiteSessionCookie,t.crossSite=!!e.usePartitionedCrossSiteSessionCookie,t.partitioned=!!e.usePartitionedCrossSiteSessionCookie,e.trackSessionAcrossSubdomains){const n=Zt();if(!n)return;t.domain=n}return t}const Gr="_dd_test_";function un(){try{const e=H(),t=`${Gr}${e}`;localStorage.setItem(t,e);const n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:_e.LOCAL_STORAGE}:void 0}catch(e){return}}function Kr(e){return{isLockEnabled:!1,persistSession:ln,retrieveSession:jr,expireSession:t=>zr(t,e)}}function ln(e){localStorage.setItem(B,on(e))}function jr(){const e=localStorage.getItem(B);return dt(e)}function zr(e,t){ln(V(e,t))}const Yr=10,Vr=100,Wr=se,dn="--",fn=[];let Pe;function W(e,t,n=0){var r;const{isLockEnabled:o,persistSession:s,expireSession:i}=t,c=f=>s({...f,lock:u}),a=()=>{const{lock:f,...p}=t.retrieveSession();return{session:p,lock:f&&!Jr(f)?f:void 0}};if(Pe||(Pe=e),e!==Pe){fn.push(e);return}if(o&&n>=Vr){mn(t);return}let u,d=a();if(o){if(d.lock){Me(e,t,n);return}if(u=qr(),c(d.session),d=a(),d.lock!==u){Me(e,t,n);return}}let l=e.process(d.session);if(o&&(d=a(),d.lock!==u)){Me(e,t,n);return}if(l&&(Te(l)?i(l):(rn(l),o?c(l):s(l))),o&&!(l&&Te(l))){if(d=a(),d.lock!==u){Me(e,t,n);return}s(d.session),l=d.session}(r=e.after)===null||r===void 0||r.call(e,l||d.session),mn(t)}function Me(e,t,n){Se(()=>{W(e,t,n+1)},Yr)}function mn(e){Pe=void 0;const t=fn.shift();t&&W(t,e)}function qr(){return H()+dn+U()}function Jr(e){const[,t]=e.split(dn);return!t||Ft(Number(t),U())>Wr}const pn=se;function Xr(e){switch(e.sessionPersistence){case _e.COOKIE:return sn(e);case _e.LOCAL_STORAGE:return un();case void 0:{let t=sn(e);return!t&&e.allowFallbackToLocalStorage&&(t=un()),t}default:y.error(`Invalid session persistence '${String(e.sessionPersistence)}'`)}}function Zr(e,t){return e.type===_e.COOKIE?Hr(t,e.cookieOptions):Kr(t)}function Qr(e,t,n,r,o=Zr(e,t)){const s=new S,i=new S,c=new S,a=rt(p,pn);let u;O();const{throttled:d,cancel:l}=yr(()=>{W({process:E=>{if(Ue(E))return;const k=g(E);return _(k),k},after:E=>{nn(E)&&!G()&&vc(E),u=E}},o)},pn);function f(){W({process:E=>G()?g(E):void 0},o)}function p(){const E=o.retrieveSession();Te(E)?W({process:k=>Te(k)?V(k,t):void 0,after:g},o):g(E)}function g(E){return Te(E)&&(E=V(E,t)),G()&&(Ee(E)?Cc():(c.notify({previousState:u,newState:E}),u=E)),E}function O(){W({process:E=>{if(Ue(E))return V(E,t)},after:E=>{u=E}},o)}function _(E){if(Ue(E))return!1;const k=r(E[n]);E[n]=k,delete E.isExpired,k!==en&&!E.id&&(E.id=H(),E.created=String($()))}function G(){return(u==null?void 0:u[n])!==void 0}function Ee(E){return u.id!==E.id||u[n]!==E[n]}function Cc(){u=V(u,t),i.notify()}function vc(E){u=E,s.notify()}function wc(E){W({process:k=>({...k,...E}),after:g},o)}return{expandOrRenewSession:d,expandSession:f,getSession:()=>u,renewObservable:s,expireObservable:i,sessionStateUpdateObservable:c,restartSession:O,expire:()=>{l(),o.expireSession(u),g(V(u,t))},stop:()=>{Yt(a)},updateSessionState:wc}}const ft={GRANTED:"granted",NOT_GRANTED:"not-granted"};function eo(e){const t=new S;return{tryToInit(n){e||(e=n)},update(n){e=n,t.notify()},isGranted(){return e===ft.GRANTED},observable:t}}function hn(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function to(e,t,n=!1){return e.some(r=>{try{if(typeof r=="function")return r(t);if(r instanceof RegExp)return r.test(t);if(typeof r=="string")return n?t.startsWith(r):r===t}catch(o){y.error(o)}return!1})}const no=["chrome-extension://","moz-extension://"];function gn(e){return no.some(t=>e.includes(t))}function ro(e,t=""){if(gn(e))return!1;const r=t.split(`
|
|
6
|
+
Please fix these validation errors and try again.`),this.name=m.ErrorEnum.CHECKOUT_OPTIONS_VALIDATION_ERROR}}m.MessageTypeEnum=void 0,function(e){e.CHECKOUT_PAYMENT_COMPONENT_READY="montonio:checkout.paymentComponentReady",e.CHECKOUT_CHANGE_LOCALE="montonio:checkout.changeLocale",e.CHECKOUT_SUBMIT_PAYMENT="montonio:checkout.submitPayment",e.CHECKOUT_START_PAYMENT_AUTH="montonio:checkout.startPaymentAuth",e.CHECKOUT_SEND_PAYMENT_AUTH_DATA="montonio:checkout.sendPaymentAuthData",e.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY="montonio:checkout.paymentAuthComponentReady",e.CHECKOUT_PAYMENT_AUTH_COMPLETED="montonio:checkout.paymentAuthCompleted",e.CHECKOUT_PAYMENT_COMPLETED="montonio:checkout.paymentCompleted",e.CHECKOUT_PAYMENT_FAILED="montonio:checkout.paymentFailed",e.CHECKOUT_SEND_PAYMENT_FAILED_DATA="montonio:checkout.sendPaymentFailedData",e.CHECKOUT_HEIGHT_CHANGED="montonio:checkout.heightChanged",e.CHECKOUT_VALIDATE_FIELDS="montonio:checkout.validateFields",e.CHECKOUT_VALIDATE_FIELDS_RESULT="montonio:checkout.validateFieldsResult",e.CHECKOUT_PAYMENT_FORM_CHANGED="montonio:checkout.paymentFormChanged"}(m.MessageTypeEnum||(m.MessageTypeEnum={}));class K{constructor(){this.environmentVariables={stargateUrl:{sandbox:"https://sandbox-stargate.montonio.com",production:"https://stargate.montonio.com","prelive-sandbox":"https://sandbox-stargate.prelive.montonio.com","prelive-production":"https://stargate.prelive.montonio.com",development:"https://api-stargate.montonio.dev"},datadogClientToken:"pubb5b1ffe19aeb16a90d1181fd3e866b83"}}static get instance(){return K._instance||(K._instance=new K),K._instance}getConfig(t,n){const r=this.environmentVariables[t];if(typeof r=="string")return r;if(!n)throw new Error(`Environment parameter required for config key: ${t}`);return r[n]}}class oe{constructor(){this.timeout=3e4}static get instance(){return oe._instance||(oe._instance=new oe),oe._instance}async get(t){return this.request(t,"GET")}async post(t,n){return this.request(t,"POST",n)}async patch(t,n){return this.request(t,"PATCH",n)}async request(t,n,r){const o=new AbortController,s=setTimeout(()=>o.abort(),this.timeout);try{const i={Accept:"application/json","X-Montonio-Js-Version":"1.1.0"};r&&(i["Content-Type"]="application/json");const c={method:n,headers:i,credentials:"include",mode:"cors",signal:o.signal};r&&(c.body=JSON.stringify(r));const a=await fetch(t,c);if(!a.ok)throw new Error(`HTTP error ${a.status}: ${a.statusText}`);return await a.json()}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timeout after ${this.timeout}ms`):i}finally{clearTimeout(s)}}}class Mt{constructor(){this.subscriptions=new Map,this.setupMessageListener()}subscribe(t,n,r){if(this.subscriptions.has(t))throw new Error(`Subscription for '${t}' already exists`);const o=this.extractWindowFromIframe(r);this.subscriptions.set(t,{handler:n,sources:[o]})}addIframeToSubscription(t,n){const r=this.subscriptions.get(t);if(!r)throw new Error(`Subscription for '${t}' not found`);const o=this.extractWindowFromIframe(n);r.sources.includes(o)||r.sources.push(o)}waitForMessage(t,n,r=3e4){return new Promise((o,s)=>{const i=setTimeout(()=>{this.removeIframeFromSubscription(t,n),s(new Error(`Message ${t} timeout after ${r}ms`))},r);this.subscribe(t,c=>{clearTimeout(i),this.removeIframeFromSubscription(t,n),o(c)},n)})}postMessage(t,n,r="*"){this.extractWindowFromIframe(t).postMessage(n,r)}clearAllSubscriptions(){this.subscriptions.clear()}clearSubscriptionsExcept(t){for(const n of[...this.subscriptions.keys()])t.includes(n)||this.subscriptions.delete(n)}removeIframeFromSubscription(t,n){const r=this.subscriptions.get(t);if(!r)throw new Error(`Subscription for '${t}' not found`);const o=this.extractWindowFromIframe(n);r.sources=r.sources.filter(s=>s!==o),r.sources.length===0&&this.subscriptions.delete(t)}setupMessageListener(){window.addEventListener("message",t=>{try{if(!t.data||typeof t.data!="object"||!t.data.name)return;const n=t.data;this.subscriptions.forEach((r,o)=>{if(!(o!==n.name||!r.sources.some(i=>i===t.source)))try{r.handler(n)}catch(i){console.error("Error in message handler:",i)}})}catch(n){console.error("Error processing iframe message:",n)}})}extractWindowFromIframe(t){return t.getContentWindow()}}const T={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},N=console,j={};Object.keys(T).forEach(e=>{j[e]=N[e]});const ye="Datadog Browser SDK:",y={debug:j.debug.bind(N,ye),log:j.log.bind(N,ye),info:j.info.bind(N,ye),warn:j.warn.bind(N,ye),error:j.error.bind(N,ye)},Ze="https://docs.datadoghq.com",ir=`${Ze}/real_user_monitoring/browser/troubleshooting`,Qe="More details:";function Dt(e,t){return(...n)=>{try{return e(...n)}catch(r){y.error(t,r)}}}function be(e){return e!==0&&Math.random()*100<=e}function cr(e){return ar(e)&&e>=0&&e<=100}function ar(e){return typeof e=="number"}const se=1e3,D=60*se,$t=60*D,ur=365*(24*$t);function $(){return new Date().getTime()}function U(){return $()}function Ae(){return performance.now()}function x(){return{relative:Ae(),timeStamp:U()}}function lr(){return{relative:0,timeStamp:Ht()}}function Ft(e,t){return t-e}function dr(e,t){return e+t}function fr(e){return e-Ht()}let et;function Ht(){var e,t;return et===void 0&&(et=(t=(e=performance.timing)===null||e===void 0?void 0:e.navigationStart)!==null&&t!==void 0?t:performance.timeOrigin),et}const ie=1024,Bt=1024*ie,mr=/[^\u0000-\u007F]/;function Gt(e){return mr.test(e)?window.TextEncoder!==void 0?new TextEncoder().encode(e).length:new Blob([e]).size:e.length}function pr(e){return{...e}}function Kt(e,t){return Object.keys(e).some(n=>e[n]===t)}function Ie(e){return Object.keys(e).length===0}function R(){if(typeof globalThis=="object")return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get(){return this},configurable:!0});let e=_dd_temp_;return delete Object.prototype._dd_temp_,typeof e!="object"&&(typeof self=="object"?e=self:typeof window=="object"?e=window:e={}),e}const L=R(),z="WorkerGlobalScope"in L;function ce(e,t){const n=R();let r;return n.Zone&&typeof n.Zone.__symbol__=="function"&&(r=e[n.Zone.__symbol__(t)]),r||(r=e[t]),r}let Re,jt=!1;function hr(e){Re=e}function gr(e){jt=e}function Er(e,t,n){const r=n.value;n.value=function(...o){return(Re?b(r):r).apply(this,o)}}function b(e){return function(){return ae(e,this,arguments)}}function ae(e,t,n){try{return e.apply(t,n)}catch(r){tt(r)}}function tt(e){if(nt(e),Re)try{Re(e)}catch(t){nt(t)}}function nt(...e){jt&&y.error("[MONITOR]",...e)}function Se(e,t){return ce(R(),"setTimeout")(b(e),t)}function zt(e){ce(R(),"clearTimeout")(e)}function rt(e,t){return ce(R(),"setInterval")(b(e),t)}function Yt(e){ce(R(),"clearInterval")(e)}function Vt(e){var t;const n=(t=L.queueMicrotask)===null||t===void 0?void 0:t.bind(L);typeof n=="function"?n(b(e)):Promise.resolve().then(b(e))}class S{constructor(t){this.onFirstSubscribe=t,this.observers=[]}subscribe(t){return this.addObserver(t),{unsubscribe:()=>this.removeObserver(t)}}notify(t){this.observers.forEach(n=>n(t))}addObserver(t){this.observers.push(t),this.observers.length===1&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe(this)||void 0)}removeObserver(t){this.observers=this.observers.filter(n=>t!==n),!this.observers.length&&this.onLastUnsubscribe&&this.onLastUnsubscribe()}}function Wt(...e){return new S(t=>{const n=e.map(r=>r.subscribe(o=>t.notify(o)));return()=>n.forEach(r=>r.unsubscribe())})}class qt extends S{constructor(t){super(),this.maxBufferSize=t,this.buffer=[]}notify(t){this.buffer.push(t),this.buffer.length>this.maxBufferSize&&this.buffer.shift(),super.notify(t)}subscribe(t){let n=!1;const r={unsubscribe:()=>{n=!0,this.removeObserver(t)}};return Vt(()=>{for(const o of this.buffer){if(n)return;t(o)}n||this.addObserver(t)}),r}unbuffer(){Vt(()=>{this.maxBufferSize=this.buffer.length=0})}}function yr(e,t,n){let r=!1,o,s;return{throttled:(...i)=>{if(r){o=i;return}e(...i),r=!0,s=Se(()=>{o&&e(...o),r=!1,o=void 0},t)},cancel:()=>{zt(s),r=!1,o=void 0}}}function F(){}function H(e){return e?(parseInt(e,10)^Math.random()*16>>parseInt(e,10)/4).toString(16):`10000000-1000-4000-8000-${1e11}`.replace(/[018]/g,H)}const Le=/([\w-]+)\s*=\s*([^;]+)/g;function br(e,t){for(Le.lastIndex=0;;){const n=Le.exec(e);if(n){if(n[1]===t)return n[2]}else break}}function Sr(e){const t=new Map;for(Le.lastIndex=0;;){const n=Le.exec(e);if(n)t.set(n[1],n[2]);else break}return t}function _r(e,t,n=""){const r=e.charCodeAt(t-1),s=r>=55296&&r<=56319?t+1:t;return e.length<=s?e:`${e.slice(0,s)}${n}`}function Tr(){return Or()===0}let Ne;function Or(){return Ne!=null?Ne:Ne=Cr()}function Cr(e=window){var t;const n=e.navigator.userAgent;return e.chrome||/HeadlessChrome/.test(n)?0:((t=e.navigator.vendor)===null||t===void 0?void 0:t.indexOf("Apple"))===0||/safari/i.test(n)&&!/chrome|android/i.test(n)?1:2}function ot(e){return Jt(e,location.href).href}function Jt(e,t){const{URL:n}=vr();try{return t!==void 0?new n(e,t):new n(e)}catch(r){throw new Error(`Failed to construct URL: ${String(r)}`)}}let st;function vr(){if(!st){let e,t;try{e=document.createElement("iframe"),e.style.display="none",document.body.appendChild(e),t=e.contentWindow}catch(n){t=L}st={URL:t.URL},e==null||e.remove()}return st}function xe(e,t,n=0,r){const o=new Date;o.setTime(o.getTime()+n);const s=`expires=${o.toUTCString()}`,i=r&&r.crossSite?"none":"strict",c=r&&r.domain?`;domain=${r.domain}`:"",a=r&&r.secure?";secure":"",u=r&&r.partitioned?";partitioned":"";document.cookie=`${e}=${t};${s};path=/;samesite=${i}${c}${a}${u}`}function it(e){return br(document.cookie,e)}let ct;function Y(e){return ct||(ct=Sr(document.cookie)),ct.get(e)}function Xt(e,t){xe(e,"",0,t)}function wr(e){if(document.cookie===void 0||document.cookie===null)return!1;try{const t=`dd_cookie_test_${H()}`,n="test";xe(t,n,D,e);const r=it(t)===n;return Xt(t,e),r}catch(t){return y.error(t),!1}}let at;function Zt(e=location.hostname,t=document.referrer){if(at===void 0){const n=Ar(e,t);if(n){const r=`dd_site_test_${H()}`,o="test",s=n.split(".");let i=s.pop();for(;s.length&&!it(r);)i=`${s.pop()}.${i}`,xe(r,o,se,{domain:i});Xt(r,{domain:i}),at=i}}return at}function Ar(e,t){try{return e||Jt(t).hostname}catch(n){}}const B="_dd_s";function Ir(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(t(r,n,e))return r}}function ke(e){return Object.values(e)}function Rr(e){return Object.entries(e)}const ut=4*$t,Qt=15*D,Lr=ur,en="0",_e={COOKIE:"cookie",LOCAL_STORAGE:"local-storage"},tn=/^([a-zA-Z]+)=([a-z0-9-]+)$/,lt="&";function Nr(e){return!!e&&(e.indexOf(lt)!==-1||tn.test(e))}const xr="1";function V(e,t){const n={isExpired:xr};return t.trackAnonymousUser&&(e!=null&&e.anonymousId?n.anonymousId=e==null?void 0:e.anonymousId:n.anonymousId=H()),n}function Ue(e){return Ie(e)}function nn(e){return!Ue(e)}function Te(e){return e.isExpired!==void 0||!kr(e)}function kr(e){return(e.created===void 0||$()-Number(e.created)<ut)&&(e.expire===void 0||$()<Number(e.expire))}function rn(e){e.expire=String($()+Qt)}function on(e){return Rr(e).map(([t,n])=>t==="anonymousId"?`aid=${n}`:`${t}=${n}`).join(lt)}function dt(e){const t={};return Nr(e)&&e.split(lt).forEach(n=>{const r=tn.exec(n);if(r!==null){const[,o,s]=r;o==="aid"?t.anonymousId=s:t[o]=s}}),t}const Ur="_dd",Pr="_dd_r",Mr="_dd_l",Dr="rum",$r="logs";function Fr(e){if(!Y(B)){const n=Y(Ur),r=Y(Pr),o=Y(Mr),s={};n&&(s.id=n),o&&/^[01]$/.test(o)&&(s[$r]=o),r&&/^[012]$/.test(r)&&(s[Dr]=r),nn(s)&&(rn(s),e.persistSession(s))}}function sn(e){const t=Br(e);return t&&wr(t)?{type:_e.COOKIE,cookieOptions:t}:void 0}function Hr(e,t){const n={isLockEnabled:Tr(),persistSession:r=>cn(t,e,r,Qt),retrieveSession:an,expireSession:r=>cn(t,e,V(r,e),ut)};return Fr(n),n}function cn(e,t,n,r){xe(B,on(n),t.trackAnonymousUser?Lr:r,e)}function an(){const e=it(B);return dt(e)}function Br(e){const t={};if(t.secure=!!e.useSecureSessionCookie||!!e.usePartitionedCrossSiteSessionCookie,t.crossSite=!!e.usePartitionedCrossSiteSessionCookie,t.partitioned=!!e.usePartitionedCrossSiteSessionCookie,e.trackSessionAcrossSubdomains){const n=Zt();if(!n)return;t.domain=n}return t}const Gr="_dd_test_";function un(){try{const e=H(),t=`${Gr}${e}`;localStorage.setItem(t,e);const n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:_e.LOCAL_STORAGE}:void 0}catch(e){return}}function Kr(e){return{isLockEnabled:!1,persistSession:ln,retrieveSession:jr,expireSession:t=>zr(t,e)}}function ln(e){localStorage.setItem(B,on(e))}function jr(){const e=localStorage.getItem(B);return dt(e)}function zr(e,t){ln(V(e,t))}const Yr=10,Vr=100,Wr=se,dn="--",fn=[];let Pe;function W(e,t,n=0){var r;const{isLockEnabled:o,persistSession:s,expireSession:i}=t,c=f=>s({...f,lock:u}),a=()=>{const{lock:f,...p}=t.retrieveSession();return{session:p,lock:f&&!Jr(f)?f:void 0}};if(Pe||(Pe=e),e!==Pe){fn.push(e);return}if(o&&n>=Vr){mn(t);return}let u,d=a();if(o){if(d.lock){Me(e,t,n);return}if(u=qr(),c(d.session),d=a(),d.lock!==u){Me(e,t,n);return}}let l=e.process(d.session);if(o&&(d=a(),d.lock!==u)){Me(e,t,n);return}if(l&&(Te(l)?i(l):(rn(l),o?c(l):s(l))),o&&!(l&&Te(l))){if(d=a(),d.lock!==u){Me(e,t,n);return}s(d.session),l=d.session}(r=e.after)===null||r===void 0||r.call(e,l||d.session),mn(t)}function Me(e,t,n){Se(()=>{W(e,t,n+1)},Yr)}function mn(e){Pe=void 0;const t=fn.shift();t&&W(t,e)}function qr(){return H()+dn+U()}function Jr(e){const[,t]=e.split(dn);return!t||Ft(Number(t),U())>Wr}const pn=se;function Xr(e){switch(e.sessionPersistence){case _e.COOKIE:return sn(e);case _e.LOCAL_STORAGE:return un();case void 0:{let t=sn(e);return!t&&e.allowFallbackToLocalStorage&&(t=un()),t}default:y.error(`Invalid session persistence '${String(e.sessionPersistence)}'`)}}function Zr(e,t){return e.type===_e.COOKIE?Hr(t,e.cookieOptions):Kr(t)}function Qr(e,t,n,r,o=Zr(e,t)){const s=new S,i=new S,c=new S,a=rt(p,pn);let u;O();const{throttled:d,cancel:l}=yr(()=>{W({process:E=>{if(Ue(E))return;const k=g(E);return _(k),k},after:E=>{nn(E)&&!G()&&vc(E),u=E}},o)},pn);function f(){W({process:E=>G()?g(E):void 0},o)}function p(){const E=o.retrieveSession();Te(E)?W({process:k=>Te(k)?V(k,t):void 0,after:g},o):g(E)}function g(E){return Te(E)&&(E=V(E,t)),G()&&(Ee(E)?Cc():(c.notify({previousState:u,newState:E}),u=E)),E}function O(){W({process:E=>{if(Ue(E))return V(E,t)},after:E=>{u=E}},o)}function _(E){if(Ue(E))return!1;const k=r(E[n]);E[n]=k,delete E.isExpired,k!==en&&!E.id&&(E.id=H(),E.created=String($()))}function G(){return(u==null?void 0:u[n])!==void 0}function Ee(E){return u.id!==E.id||u[n]!==E[n]}function Cc(){u=V(u,t),i.notify()}function vc(E){u=E,s.notify()}function wc(E){W({process:k=>({...k,...E}),after:g},o)}return{expandOrRenewSession:d,expandSession:f,getSession:()=>u,renewObservable:s,expireObservable:i,sessionStateUpdateObservable:c,restartSession:O,expire:()=>{l(),o.expireSession(u),g(V(u,t))},stop:()=>{Yt(a)},updateSessionState:wc}}const ft={GRANTED:"granted",NOT_GRANTED:"not-granted"};function eo(e){const t=new S;return{tryToInit(n){e||(e=n)},update(n){e=n,t.notify()},isGranted(){return e===ft.GRANTED},observable:t}}function hn(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function to(e,t,n=!1){return e.some(r=>{try{if(typeof r=="function")return r(t);if(r instanceof RegExp)return r.test(t);if(typeof r=="string")return n?t.startsWith(r):r===t}catch(o){y.error(o)}return!1})}const no=["chrome-extension://","moz-extension://"];function gn(e){return no.some(t=>e.includes(t))}function ro(e,t=""){if(gn(e))return!1;const r=t.split(`
|
|
7
7
|
`).filter(o=>{const s=o.trim();return s.length&&/^at\s+|@/.test(s)})[1]||"";return gn(r)}const oo="Running the Browser SDK in a Web extension content script is forbidden unless the `allowedTrackingOrigins` option is provided.",so="SDK initialized on a non-allowed domain.";function io(e,t,n=typeof location!="undefined"?location.origin:""){const r=e.allowedTrackingOrigins;if(!r)return ro(n,t)?(y.error(oo),!1):!0;const o=to(r,n);return o||y.error(so),o}const co="datad0g.com",ao="dd0g-gov.com",ue="datadoghq.com",uo="ddog-gov.com",lo="pci.browser-intake-datadoghq.com",fo=["ddsource","dd-api-key","dd-request-id"];function q(e,t,n){const r=mo(e,t);return{build(o,s){const i=ho(e,t,o,s,n);return r(i)},trackType:t}}function mo(e,t){const n=`/api/v2/${t}`,r=e.proxy;if(typeof r=="string"){const s=ot(r);return i=>`${s}?ddforward=${encodeURIComponent(`${n}?${i}`)}`}if(typeof r=="function")return s=>r({path:n,parameters:s});const o=po(t,e);return s=>`https://${o}${n}?${s}`}function po(e,t){const{site:n=ue,internalAnalyticsSubdomain:r}=t;if(e==="logs"&&t.usePciIntake&&n===ue)return lo;if(r&&n===ue)return`${r}.${ue}`;if(n===ao)return`http-intake.logs.${n}`;const o=n.split("."),s=o.pop();return`browser-intake-${o.join("-")}.${s}`}function ho({clientToken:e,internalAnalyticsSubdomain:t,source:n="browser"},r,o,{retry:s,encoding:i},c=[]){const a=[`ddsource=${n}`,`dd-api-key=${e}`,`dd-evp-origin-version=${encodeURIComponent("6.22.0")}`,"dd-evp-origin=browser",`dd-request-id=${H()}`].concat(c);return i&&a.push(`dd-evp-encoding=${i}`),r==="rum"&&(a.push(`batch_time=${U()}`,`_dd.api=${o}`),s&&a.push(`_dd.retry_count=${s.count}`,`_dd.retry_after=${s.lastFailureStatus}`)),t&&a.reverse(),a.join("&")}function go(e){const t=e.site||ue,n=Eo(e.source),r=yo({...e,site:t,source:n});return{replica:bo({...e,site:t,source:n}),site:t,source:n,...r}}function Eo(e){return e==="flutter"||e==="unity"?e:"browser"}function yo(e){return{logsEndpointBuilder:q(e,"logs"),rumEndpointBuilder:q(e,"rum"),profilingEndpointBuilder:q(e,"profile"),sessionReplayEndpointBuilder:q(e,"replay"),exposuresEndpointBuilder:q(e,"exposures")}}function bo(e){if(!e.replica)return;const t={...e,site:ue,clientToken:e.replica.clientToken};return{logsEndpointBuilder:q(t,"logs"),rumEndpointBuilder:q(t,"rum",[`application.id=${e.replica.applicationId}`])}}function So(e){return fo.every(t=>e.includes(t))}function mt(e,t){return e!=null&&typeof e!="string"?(y.error(`${t} must be defined as a string`),!1):!0}function _o(e){return e&&typeof e=="string"&&!/(datadog|ddog|datad0g|dd0g)/.test(e)?(y.error(`Site should be a valid Datadog site. ${Qe} ${Ze}/getting_started/site/.`),!1):!0}function De(e,t){return e!==void 0&&!cr(e)?(y.error(`${t} Sample Rate should be a number between 0 and 100`),!1):!0}function To(e,t){var n,r,o,s,i,c,a,u,d,l;if(!e||!e.clientToken){y.error("Client Token is not configured, we will not send any data.");return}if(e.allowedTrackingOrigins!==void 0&&!Array.isArray(e.allowedTrackingOrigins)){y.error("Allowed Tracking Origins must be an array");return}if(!(!_o(e.site)||!De(e.sessionSampleRate,"Session")||!De(e.telemetrySampleRate,"Telemetry")||!De(e.telemetryConfigurationSampleRate,"Telemetry Configuration")||!De(e.telemetryUsageSampleRate,"Telemetry Usage")||!mt(e.version,"Version")||!mt(e.env,"Env")||!mt(e.service,"Service")||!io(e,t!=null?t:""))){if(e.trackingConsent!==void 0&&!Kt(ft,e.trackingConsent)){y.error('Tracking Consent should be either "granted" or "not-granted"');return}return{beforeSend:e.beforeSend&&Dt(e.beforeSend,"beforeSend threw an error:"),sessionStoreStrategyType:z?void 0:Xr(e),sessionSampleRate:(n=e.sessionSampleRate)!==null&&n!==void 0?n:100,telemetrySampleRate:(r=e.telemetrySampleRate)!==null&&r!==void 0?r:20,telemetryConfigurationSampleRate:(o=e.telemetryConfigurationSampleRate)!==null&&o!==void 0?o:5,telemetryUsageSampleRate:(s=e.telemetryUsageSampleRate)!==null&&s!==void 0?s:5,service:(i=e.service)!==null&&i!==void 0?i:void 0,env:(c=e.env)!==null&&c!==void 0?c:void 0,version:(a=e.version)!==null&&a!==void 0?a:void 0,datacenter:(u=e.datacenter)!==null&&u!==void 0?u:void 0,silentMultipleInit:!!e.silentMultipleInit,allowUntrustedEvents:!!e.allowUntrustedEvents,trackingConsent:(d=e.trackingConsent)!==null&&d!==void 0?d:ft.GRANTED,trackAnonymousUser:(l=e.trackAnonymousUser)!==null&&l!==void 0?l:!0,storeContextsAcrossPages:!!e.storeContextsAcrossPages,batchBytesLimit:16*ie,eventRateLimiterThreshold:3e3,maxTelemetryEventsPerPage:15,flushTimeout:30*se,batchMessagesLimit:z?1:50,messageBytesLimit:256*ie,variant:e.variant,sdkVersion:e.sdkVersion,...go(e)}}}function Oo(e){return{session_sample_rate:e.sessionSampleRate,telemetry_sample_rate:e.telemetrySampleRate,telemetry_configuration_sample_rate:e.telemetryConfigurationSampleRate,telemetry_usage_sample_rate:e.telemetryUsageSampleRate,use_before_send:!!e.beforeSend,use_partitioned_cross_site_session_cookie:e.usePartitionedCrossSiteSessionCookie,use_secure_session_cookie:e.useSecureSessionCookie,use_proxy:!!e.proxy,silent_multiple_init:e.silentMultipleInit,track_session_across_subdomains:e.trackSessionAcrossSubdomains,track_anonymous_user:e.trackAnonymousUser,session_persistence:e.sessionPersistence,allow_fallback_to_local_storage:!!e.allowFallbackToLocalStorage,store_contexts_across_pages:!!e.storeContextsAcrossPages,allow_untrusted_events:!!e.allowUntrustedEvents,tracking_consent:e.trackingConsent,use_allowed_tracking_origins:Array.isArray(e.allowedTrackingOrigins),source:e.source,sdk_version:e.sdkVersion,variant:e.variant}}var $e;(function(e){e.TRACK_INTAKE_REQUESTS="track_intake_requests",e.USE_TREE_WALKER_FOR_ACTION_NAME="use_tree_walker_for_action_name",e.FEATURE_OPERATION_VITAL="feature_operation_vital",e.SHORT_SESSION_INVESTIGATION="short_session_investigation"})($e||($e={}));const pt=new Set;function Co(e){Array.isArray(e)&&vo(e.filter(t=>Kt($e,t)))}function vo(e){e.forEach(t=>{pt.add(t)})}function wo(e){return pt.has(e)}function Ao(){return pt}const le="?";function de(e){var t,n;const r=[];let o=ht(e,"stack");const s=String(e);if(o&&o.startsWith(s)&&(o=o.slice(s.length)),o&&o.split(`
|
|
8
8
|
`).forEach(i=>{const c=Lo(i)||xo(i)||Uo(i)||Do(i);c&&(!c.func&&c.line&&(c.func=le),r.push(c))}),r.length>0&&Bo()&&e instanceof Error){const i=[];let c=e;for(;(c=Object.getPrototypeOf(c))&&yn(c);){const a=((t=c.constructor)===null||t===void 0?void 0:t.name)||le;i.push(a)}for(let a=i.length-1;a>=0&&((n=r[0])===null||n===void 0?void 0:n.func)===i[a];a--)r.shift()}return{message:ht(e,"message"),name:ht(e,"name"),stack:r}}const En="((?:file|https?|blob|chrome-extension|electron|native|eval|webpack|snippet|<anonymous>|\\w+\\.|\\/).*?)",fe="(?::(\\d+))",Io=new RegExp(`^\\s*at (.*?) ?\\(${En}${fe}?${fe}?\\)?\\s*$`,"i"),Ro=new RegExp(`\\((\\S*)${fe}${fe}\\)`);function Lo(e){const t=Io.exec(e);if(!t)return;const n=t[2]&&t[2].indexOf("native")===0,r=t[2]&&t[2].indexOf("eval")===0,o=Ro.exec(t[2]);return r&&o&&(t[2]=o[1],t[3]=o[2],t[4]=o[3]),{args:n?[t[2]]:[],column:t[4]?+t[4]:void 0,func:t[1]||le,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}const No=new RegExp(`^\\s*at ?${En}${fe}?${fe}??\\s*$`,"i");function xo(e){const t=No.exec(e);if(t)return{args:[],column:t[3]?+t[3]:void 0,func:le,line:t[2]?+t[2]:void 0,url:t[1]}}const ko=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;function Uo(e){const t=ko.exec(e);if(t)return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||le,line:+t[3],url:t[2]}}const Po=/^\s*(.*?)(?:\((.*?)\))?(?:(?:(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle|\[wasm code\])(?::(\d+))?(?::(\d+))?)|@)\s*$/i,Mo=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function Do(e){const t=Po.exec(e);if(!t)return;const n=t[3]&&t[3].indexOf(" > eval")>-1,r=Mo.exec(t[3]);return n&&r&&(t[3]=r[1],t[4]=r[2],t[5]=void 0),{args:t[2]?t[2].split(","):[],column:t[5]?+t[5]:void 0,func:t[1]||le,line:t[4]?+t[4]:void 0,url:t[3]}}function ht(e,t){if(typeof e!="object"||!e||!(t in e))return;const n=e[t];return typeof n=="string"?n:void 0}function $o(e,t,n,r){if(t===void 0)return;const{name:o,message:s}=Ho(e);return{name:o,message:s,stack:[{url:t,column:r,line:n}]}}const Fo=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;function Ho(e){let t,n;return{}.toString.call(e)==="[object String]"&&([,t,n]=Fo.exec(e)),{name:t,message:n}}function yn(e){return String(e.constructor).startsWith("class ")}let Fe;function Bo(){if(Fe!==void 0)return Fe;class e extends Error{constructor(){super(),this.name="Error"}}const[t,n]=[e,Error].map(r=>new r);return Fe=yn(Object.getPrototypeOf(t))&&n.stack!==t.stack,Fe}function He(e){const n=new Error(e);n.name="HandlingStack";let r;return ae(()=>{const o=de(n);o.stack=o.stack.slice(2),r=me(o)}),r}function me(e){let t=bn(e);return e.stack.forEach(n=>{const r=n.func==="?"?"<anonymous>":n.func,o=n.args&&n.args.length>0?`(${n.args.join(", ")})`:"",s=n.line?`:${n.line}`:"",i=n.line&&n.column?`:${n.column}`:"";t+=`
|
|
9
9
|
at ${r}${o} @ ${n.url}${s}${i}`}),t}function bn(e){return`${e.name||"Error"}: ${e.message}`}function J(e,t,n,{computeHandlingStack:r}={}){let o=e[t];if(typeof o!="function")if(t in e&&t.startsWith("on"))o=F;else return{stop:F};let s=!1;const i=function(){if(s)return o.apply(this,arguments);const c=Array.from(arguments);let a;ae(n,null,[{target:this,parameters:c,onPostCall:d=>{a=d},handlingStack:r?He("instrumented method"):void 0}]);const u=o.apply(this,c);return a&&ae(a,null,[u]),u};return e[t]=i,{stop:()=>{s=!0,e[t]===i&&(e[t]=o)}}}function Oe(e,t,n){if(typeof e!="object"||e===null)return JSON.stringify(e);const r=pe(Object.prototype),o=pe(Array.prototype),s=pe(Object.getPrototypeOf(e)),i=pe(e);try{return JSON.stringify(e,t,n)}catch(c){return"<error: unable to serialize object>"}finally{r(),o(),s(),i()}}function pe(e){const t=e,n=t.toJSON;return n?(delete t.toJSON,()=>{t.toJSON=n}):F}const Go=220*ie,Ko="$",jo=3;function P(e,t=Go){const n=pe(Object.prototype),r=pe(Array.prototype),o=[],s=new WeakMap,i=gt(e,Ko,void 0,o,s),c=JSON.stringify(i);let a=c?c.length:0;if(a>t){yt(t,"discarded",e);return}for(;o.length>0&&a<t;){const u=o.shift();let d=0;if(Array.isArray(u.source))for(let l=0;l<u.source.length;l++){const f=gt(u.source[l],u.path,l,o,s);if(f!==void 0?a+=JSON.stringify(f).length:a+=4,a+=d,d=1,a>t){yt(t,"truncated",e);break}u.target[l]=f}else for(const l in u.source)if(Object.prototype.hasOwnProperty.call(u.source,l)){const f=gt(u.source[l],u.path,l,o,s);if(f!==void 0&&(a+=JSON.stringify(f).length+d+l.length+jo,d=1),a>t){yt(t,"truncated",e);break}u.target[l]=f}}return n(),r(),i}function gt(e,t,n,r,o){const s=Vo(e);if(!s||typeof s!="object")return zo(s);const i=Et(s);if(i!=="[Object]"&&i!=="[Array]"&&i!=="[Error]")return i;const c=e;if(o.has(c))return`[Reference seen at ${o.get(c)}]`;const a=n!==void 0?`${t}.${n}`:t,u=Array.isArray(s)?[]:{};return o.set(c,a),r.push({source:s,target:u,path:a}),u}function zo(e){return typeof e=="bigint"?`[BigInt] ${e.toString()}`:typeof e=="function"?`[Function] ${e.name||"unknown"}`:typeof e=="symbol"?`[Symbol] ${e.description||e.toString()}`:e}function Et(e){try{if(e instanceof Event)return Yo(e);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(t){}return"[Unserializable]"}function Yo(e){return{type:e.type,isTrusted:e.isTrusted,currentTarget:e.currentTarget?Et(e.currentTarget):null,target:e.target?Et(e.target):null}}function Vo(e){const t=e;if(t&&typeof t.toJSON=="function")try{return t.toJSON()}catch(n){}return e}function yt(e,t,n){y.warn(`The data provided has been ${t} as it is over the limit of ${e} characters:`,n)}const Sn="No stack, consider using an instance of Error";function bt({stackTrace:e,originalError:t,handlingStack:n,componentStack:r,startClocks:o,nonErrorPrefix:s,useFallbackStack:i=!0,source:c,handling:a}){const u=X(t);return!e&&u&&(e=de(t)),{startClocks:o,source:c,handling:a,handlingStack:n,componentStack:r,originalError:t,type:e?e.name:void 0,message:Wo(e,u,s,t),stack:e?me(e):i?Sn:void 0,causes:u?Zo(t,c):void 0,fingerprint:qo(t),context:Jo(t)}}function Wo(e,t,n,r){return e!=null&&e.message&&(e!=null&&e.name)?e.message:t?"Empty message":`${n} ${Oe(P(r))}`}function qo(e){return X(e)&&"dd_fingerprint"in e?String(e.dd_fingerprint):void 0}function Jo(e){if(e!==null&&typeof e=="object"&&"dd_context"in e)return e.dd_context}function Xo(e){var t;return(t=/@ (.+)/.exec(e))===null||t===void 0?void 0:t[1]}function X(e){return e instanceof Error||Object.prototype.toString.call(e)==="[object Error]"}function Zo(e,t){let n=e;const r=[];for(;X(n==null?void 0:n.cause)&&r.length<10;){const o=de(n.cause);r.push({message:n.cause.message,source:t,type:o==null?void 0:o.name,stack:o&&me(o)}),n=n.cause}return r.length?r:void 0}const A={AGENT:"agent",CONSOLE:"console",CUSTOM:"custom",LOGGER:"logger",NETWORK:"network",SOURCE:"source",REPORT:"report"};function Qo(){return new S(e=>{const t=(o,s)=>{const i=bt({stackTrace:s,originalError:o,startClocks:x(),nonErrorPrefix:"Uncaught",source:A.SOURCE,handling:"unhandled"});e.notify(i)},{stop:n}=es(t),{stop:r}=ts(t);return()=>{n(),r()}})}function es(e){return J(R(),"onerror",({parameters:[t,n,r,o,s]})=>{let i;X(s)||(i=$o(t,n,r,o)),e(s!=null?s:t,i)})}function ts(e){return J(R(),"onunhandledrejection",({parameters:[t]})=>{e(t.reason||"Empty reason")})}function ns(e){const t={version:"6.22.0",onReady(n){n()},...e};return Object.defineProperty(t,"_setDebug",{get(){return gr},enumerable:!1}),t}function rs(e,t,n){const r=e[t];r&&!r.q&&r.version&&y.warn("SDK is loaded more than once. This is unsupported and might have unexpected behavior."),e[t]=n,r&&r.q&&r.q.forEach(o=>Dt(o,"onReady callback threw an error:")())}function _n(e,t){t.silentMultipleInit||y.error(`${e} is already initialized.`)}function Z(e,t,n,r,o){return St(e,t,[n],r,o)}function St(e,t,n,r,{once:o,capture:s,passive:i}={}){const c=b(f=>{!f.isTrusted&&!f.__ddIsTrusted&&!e.allowUntrustedEvents||(o&&l(),r(f))}),a=i?{capture:s,passive:i}:s,u=window.EventTarget&&t instanceof EventTarget?window.EventTarget.prototype:t,d=ce(u,"addEventListener");n.forEach(f=>d.call(t,f,c,a));function l(){const f=ce(u,"removeEventListener");n.forEach(p=>f.call(t,p,c,a))}return{stop:l}}const Be={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function os(e,t){const n=[];t.includes(Be.cspViolation)&&n.push(is(e));const r=t.filter(o=>o!==Be.cspViolation);return r.length&&n.push(ss(r)),Wt(...n)}function ss(e){return new S(t=>{if(!window.ReportingObserver)return;const n=b((o,s)=>o.forEach(i=>t.notify(cs(i)))),r=new window.ReportingObserver(n,{types:e,buffered:!0});return r.observe(),()=>{r.disconnect()}})}function is(e){return new S(t=>{const{stop:n}=Z(e,document,"securitypolicyviolation",r=>{t.notify(as(r))});return n})}function cs(e){const{type:t,body:n}=e;return Tn({type:n.id,message:`${t}: ${n.message}`,originalError:e,stack:On(n.id,n.message,n.sourceFile,n.lineNumber,n.columnNumber)})}function as(e){const t=`'${e.blockedURI}' blocked by '${e.effectiveDirective}' directive`;return Tn({type:e.effectiveDirective,message:`${Be.cspViolation}: ${t}`,originalError:e,csp:{disposition:e.disposition},stack:On(e.effectiveDirective,e.originalPolicy?`${t} of the policy "${_r(e.originalPolicy,100,"...")}"`:"no policy",e.sourceFile,e.lineNumber,e.columnNumber)})}function Tn(e){return{startClocks:x(),source:A.REPORT,handling:"unhandled",...e}}function On(e,t,n,r,o){return n?me({name:e,message:t,stack:[{func:"?",url:n,line:r!=null?r:void 0,column:o!=null?o:void 0}]}):void 0}const us=200;function Cn(e){const{env:t,service:n,version:r,datacenter:o,sdkVersion:s,variant:i}=e,c=[Q("sdk_version",s!=null?s:"6.22.0")];return t&&c.push(Q("env",t)),n&&c.push(Q("service",n)),r&&c.push(Q("version",r)),o&&c.push(Q("datacenter",o)),i&&c.push(Q("variant",i)),c}function Q(e,t){const n=t?`${e}:${t}`:e;return(n.length>us||ls(n))&&y.warn(`Tag ${n} doesn't meet tag requirements and will be sanitized. ${Qe} ${Ze}/getting_started/tagging/#defining-tags`),vn(n)}function vn(e){return e.replace(/,/g,"_")}function ls(e){return ds()?new RegExp("[^\\p{Ll}\\p{Lo}0-9_:./-]","u").test(e):!1}function ds(){try{return new RegExp("[\\p{Ll}]","u"),!0}catch(e){return!1}}function wn(e,t){const n=L.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}function Ge(e,t,n=fs()){if(t===void 0)return e;if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=t.flags||[t.global?"g":"",t.ignoreCase?"i":"",t.multiline?"m":"",t.sticky?"y":"",t.unicode?"u":""].join("");return new RegExp(t.source,o)}if(n.hasAlreadyBeenSeen(t))return;if(Array.isArray(t)){const o=Array.isArray(e)?e:[];for(let s=0;s<t.length;++s)o[s]=Ge(o[s],t[s],n);return o}const r=hn(e)==="object"?e:{};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=Ge(r[o],t[o],n));return r}function An(e){return Ge(void 0,e)}function ee(...e){let t;for(const n of e)n!=null&&(t=Ge(t,n));return t}function fs(){if(typeof WeakSet!="undefined"){const t=new WeakSet;return{hasAlreadyBeenSeen(n){const r=t.has(n);return r||t.add(n),r}}}const e=[];return{hasAlreadyBeenSeen(t){const n=e.indexOf(t)>=0;return n||e.push(t),n}}}function ms(){var e;const t=L.navigator;return{status:t.onLine?"connected":"not_connected",interfaces:t.connection&&t.connection.type?[t.connection.type]:void 0,effective_type:(e=t.connection)===null||e===void 0?void 0:e.effectiveType}}function In(e){return e>=500}function ps(e){try{return e.clone()}catch(t){return}}const hs=80*ie,gs=32,Rn=20*Bt,Es=D,Ln=se;function Nn(e,t,n,r,o,s){t.transportStatus===0&&t.queuedPayloads.size()===0&&t.bandwidthMonitor.canHandle(e)?kn(e,t,n,s,{onSuccess:()=>Un(0,t,n,r,o,s),onFailure:()=>{t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e}),xn(t,n,r,o,s)}}):t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e})}function xn(e,t,n,r,o){e.transportStatus===2&&Se(()=>{const s=e.queuedPayloads.first();kn(s,e,t,o,{onSuccess:()=>{e.queuedPayloads.dequeue(),e.currentBackoffTime=Ln,Un(1,e,t,n,r,o)},onFailure:()=>{e.currentBackoffTime=Math.min(Es,e.currentBackoffTime*2),xn(e,t,n,r,o)}})},e.currentBackoffTime)}function kn(e,t,n,r,{onSuccess:o,onFailure:s}){t.bandwidthMonitor.add(e),n(e,i=>{t.bandwidthMonitor.remove(e),ys(i)?(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:i.status},r.notify({type:"failure",bandwidth:t.bandwidthMonitor.stats(),payload:e}),s()):(t.transportStatus=0,r.notify({type:"success",bandwidth:t.bandwidthMonitor.stats(),payload:e}),o())})}function Un(e,t,n,r,o,s){e===0&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(o({message:`Reached max ${r} events size queued for upload: ${Rn/Bt}MiB`,source:A.AGENT,startClocks:x()}),t.queueFullReported=!0);const i=t.queuedPayloads;for(t.queuedPayloads=Pn();i.size()>0;)Nn(i.dequeue(),t,n,r,o,s)}function ys(e){return e.type!=="opaque"&&(e.status===0&&!navigator.onLine||e.status===408||e.status===429||In(e.status))}function bs(){return{transportStatus:0,currentBackoffTime:Ln,bandwidthMonitor:Ss(),queuedPayloads:Pn(),queueFullReported:!1}}function Pn(){const e=[];return{bytesCount:0,enqueue(t){return this.isFull()?!1:(e.push(t),this.bytesCount+=t.bytesCount,!0)},first(){return e[0]},dequeue(){const t=e.shift();return t&&(this.bytesCount-=t.bytesCount),t},size(){return e.length},isFull(){return this.bytesCount>=Rn}}}function Ss(){return{ongoingRequestCount:0,ongoingByteCount:0,canHandle(e){return this.ongoingRequestCount===0||this.ongoingByteCount+e.bytesCount<=hs&&this.ongoingRequestCount<gs},add(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount},stats(){return{ongoingByteCount:this.ongoingByteCount,ongoingRequestCount:this.ongoingRequestCount}}}}function Mn(e,t,n){const r=new S,o=bs();return{observable:r,send:s=>{for(const i of e)Nn(s,o,(c,a)=>Os(i,t,c,a),i.trackType,n,r)},sendOnExit:s=>{for(const i of e)_s(i,t,s)}}}function _s(e,t,n){if(!!navigator.sendBeacon&&n.bytesCount<t)try{const o=e.build("beacon",n);if(navigator.sendBeacon(o,n.data))return}catch(o){Ts(o)}_t(e,n)}let Dn=!1;function Ts(e){Dn||(Dn=!0,tt(e))}function Os(e,t,n,r){if(Cs()&&n.bytesCount<t){const s=e.build("fetch-keepalive",n);fetch(s,{method:"POST",body:n.data,keepalive:!0,mode:"cors"}).then(b(i=>r==null?void 0:r({status:i.status,type:i.type}))).catch(b(()=>_t(e,n,r)))}else _t(e,n,r)}function _t(e,t,n){const r=e.build("fetch",t);fetch(r,{method:"POST",body:t.data,mode:"cors"}).then(b(o=>n==null?void 0:n({status:o.status,type:o.type}))).catch(b(()=>n==null?void 0:n({status:0})))}function Cs(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}}function Tt(){const e=vs();if(e)return{getCapabilities(){var t;return JSON.parse(((t=e.getCapabilities)===null||t===void 0?void 0:t.call(e))||"[]")},getPrivacyLevel(){var t;return(t=e.getPrivacyLevel)===null||t===void 0?void 0:t.call(e)},getAllowedWebViewHosts(){return JSON.parse(e.getAllowedWebViewHosts())},send(t,n,r){const o=r?{id:r}:void 0;e.send(JSON.stringify({eventType:t,event:n,view:o}))}}}function Ke(e){var t;e===void 0&&(e=(t=R().location)===null||t===void 0?void 0:t.hostname);const n=Tt();return!!n&&n.getAllowedWebViewHosts().some(r=>e===r||e.endsWith(`.${r}`))}function vs(){return R().DatadogEventBridge}const je={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};function ws(e){return new S(t=>{const{stop:n}=St(e,window,["visibilitychange","freeze"],o=>{o.type==="visibilitychange"&&document.visibilityState==="hidden"?t.notify({reason:je.HIDDEN}):o.type==="freeze"&&t.notify({reason:je.FROZEN})},{capture:!0}),r=Z(e,window,"beforeunload",()=>{t.notify({reason:je.UNLOADING})}).stop;return()=>{n(),r()}})}function As(e){return ke(je).includes(e)}function $n({encoder:e,request:t,flushController:n,messageBytesLimit:r}){let o={};const s=n.flushObservable.subscribe(l=>d(l));function i(l,f,p){n.notifyBeforeAddMessage(f),p!==void 0?(o[p]=l,n.notifyAfterAddMessage()):e.write(e.isEmpty?l:`
|
|
10
10
|
${l}`,g=>{n.notifyAfterAddMessage(g-f)})}function c(l){return l!==void 0&&o[l]!==void 0}function a(l){const f=o[l];delete o[l];const p=e.estimateEncodedBytesCount(f);n.notifyAfterRemoveMessage(p)}function u(l,f){const p=Oe(l),g=e.estimateEncodedBytesCount(p);if(g>=r){y.warn(`Discarded a message whose size was bigger than the maximum allowed size ${r}KB. ${Qe} ${ir}/#technical-limitations`);return}c(f)&&a(f),i(p,g,f)}function d(l){const f=ke(o).join(`
|
|
11
11
|
`);o={};const p=As(l.reason),g=p?t.sendOnExit:t.send;if(p&&e.isAsync){const O=e.finishSync();O.outputBytesCount&&g(Fn(O));const _=[O.pendingData,f].filter(Boolean).join(`
|
|
12
12
|
`);_&&g({data:_,bytesCount:Gt(_)})}else f&&e.write(e.isEmpty?f:`
|
|
13
|
-
${f}`),e.finish(O=>{g(Fn(O))})}return{flushController:n,add:u,upsert:u,stop:s.unsubscribe}}function Fn(e){let t;return typeof e.output=="string"?t=e.output:t=new Blob([e.output],{type:"text/plain"}),{data:t,bytesCount:e.outputBytesCount,encoding:e.encoding}}function Hn({messagesLimit:e,bytesLimit:t,durationLimit:n,pageMayExitObservable:r,sessionExpireObservable:o}){const s=r.subscribe(g=>d(g.reason)),i=o.subscribe(()=>d("session_expire")),c=new S(()=>()=>{s.unsubscribe(),i.unsubscribe()});let a=0,u=0;function d(g){if(u===0)return;const O=u,_=a;u=0,a=0,p(),c.notify({reason:g,messagesCount:O,bytesCount:_})}let l;function f(){l===void 0&&(l=Se(()=>{d("duration_limit")},n))}function p(){zt(l),l=void 0}return{flushObservable:c,get messagesCount(){return u},notifyBeforeAddMessage(g){a+g>=t&&d("bytes_limit"),u+=1,a+=g,f()},notifyAfterAddMessage(g=0){a+=g,u>=e?d("messages_limit"):a>=t&&d("bytes_limit")},notifyAfterRemoveMessage(g){a-=g,u-=1,u===0&&p()}}}const he="DISCARDED",te="SKIPPED";function Is(){const e={};return{register(t,n){return e[t]||(e[t]=[]),e[t].push(n),{unregister:()=>{e[t]=e[t].filter(r=>r!==n)}}},triggerHook(t,n){const r=e[t]||[],o=[];for(const s of r){const i=s(n);if(i===he)return he;i!==te&&o.push(i)}return ee(...o)}}}const ne={LOG:"log",CONFIGURATION:"configuration",USAGE:"usage"},Rs=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],Ls=1,Ns=[uo];let Ot;function Ce(){return Ot||(Ot=new qt(100)),Ot}function xs(e,t,n,r,o,s){const i=new S,{stop:c}=Us(t,r,o,s,i),{enabled:a,metricsEnabled:u}=ks(e,t,n,i);return{stop:c,enabled:a,metricsEnabled:u}}function ks(e,t,n,r,o=Ls){const s={},i=!Ns.includes(t.site)&&be(t.telemetrySampleRate),c={[ne.LOG]:i,[ne.CONFIGURATION]:i&&be(t.telemetryConfigurationSampleRate),[ne.USAGE]:i&&be(t.telemetryUsageSampleRate),metric:i&&be(o)},a=Ps(),u=Ce();return u.subscribe(({rawEvent:l,metricName:f})=>{if(f&&!c.metric||!c[l.type])return;const p=f||l.status||l.type;let g=s[p];if(g||(g=s[p]=new Set),g.size>=t.maxTelemetryEventsPerPage)return;const O=Oe(l);if(g.has(O))return;const _=n.triggerHook(1,{startTime:x().relative});if(_===he)return;const G=d(_,e,l,a);r.notify(G),wn("telemetry",G),g.add(O)}),u.unbuffer(),hr(Ds),{enabled:i,metricsEnabled:c.metric};function d(l,f,p,g){const _={type:"telemetry",date:x().timeStamp,service:f,version:"6.22.0",source:"browser",_dd:{format_version:2},telemetry:ee(p,{runtime_env:g,connectivity:ms(),sdk_setup:"npm"}),ddtags:Cn(t).join(","),experimental_features:Array.from(Ao())};return ee(_,l)}}function Us(e,t,n,r,o){const s=[];if(Ke()){const i=Tt(),c=o.subscribe(a=>i.send("internal_telemetry",a));s.push(c.unsubscribe)}else{const i=[e.rumEndpointBuilder];e.replica&&Ms(e)&&i.push(e.replica.rumEndpointBuilder);const c=$n({encoder:r(4),request:Mn(i,e.batchBytesLimit,t),flushController:Hn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageMayExitObservable:n,sessionExpireObservable:new S}),messageBytesLimit:e.messageBytesLimit});s.push(c.stop);const a=o.subscribe(c.add);s.push(a.unsubscribe)}return{stop:()=>s.forEach(i=>i())}}function Ps(){var e;return{is_local_file:((e=L.location)===null||e===void 0?void 0:e.protocol)==="file:",is_worker:z}}function Ms(e){return e.site===co}function Ct(e,t){nt(T.debug,e,t),Ce().notify({rawEvent:{type:ne.LOG,message:e,status:"debug",...t}})}function Ds(e,t){Ce().notify({rawEvent:{type:ne.LOG,status:"error",...Hs(e),...t}})}function $s(e){Ce().notify({rawEvent:{type:ne.CONFIGURATION,configuration:e}})}function Fs(e){Ce().notify({rawEvent:{type:ne.USAGE,usage:e}})}function Hs(e){if(X(e)){const t=de(e);return{error:{kind:t.name,stack:me(Bs(t))},message:t.message}}return{error:{stack:Sn},message:`Uncaught ${Oe(e)}`}}function Bs(e){return e.stack=e.stack.filter(t=>!t.url||Rs.some(n=>t.url.startsWith(n))),e}function Gs(e){const t=new Set;return e.forEach(n=>t.add(n)),Array.from(t)}function Bn(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}const ze=1/0,Ks=D;let ve=null;const Ye=new Set;function js(){Ye.forEach(e=>e())}function zs({expireDelay:e,maxEntries:t}){let n=[];ve||(ve=rt(()=>js(),Ks));const r=()=>{const d=Ae()-e;for(;n.length>0&&n[n.length-1].endTime<d;)n.pop()};Ye.add(r);function o(d,l){const f={value:d,startTime:l,endTime:ze,remove:()=>{Bn(n,f)},close:p=>{f.endTime=p}};return t&&n.length>=t&&n.pop(),n.unshift(f),f}function s(d=ze,l={returnInactive:!1}){for(const f of n)if(f.startTime<=d){if(l.returnInactive||d<=f.endTime)return f.value;break}}function i(d){const l=n[0];l&&l.endTime===ze&&l.close(d)}function c(d=ze,l=0){const f=dr(d,l);return n.filter(p=>p.startTime<=f&&d<=p.endTime).map(p=>p.value)}function a(){n=[]}function u(){Ye.delete(r),Ye.size===0&&ve&&(Yt(ve),ve=null)}return{add:o,find:s,closeActive:i,findAll:c,reset:a,stop:u}}const Ys="datadog-synthetics-public-id",Vs="datadog-synthetics-result-id",Ws="datadog-synthetics-injects-rum";function Gn(){return z?!1:!!(L._DATADOG_SYNTHETICS_INJECTS_RUM||Y(Ws))}function qs(){const e=window._DATADOG_SYNTHETICS_PUBLIC_ID||Y(Ys);return typeof e=="string"?e:void 0}function Js(){const e=window._DATADOG_SYNTHETICS_RESULT_ID||Y(Vs);return typeof e=="string"?e:void 0}function Xs(){return!!(qs()&&Js())}const Zs=D,Qs=ut;function ei(e,t,n,r){const o=new S,s=new S,i=Qr(e.sessionStoreStrategyType,e,t,n),c=zs({expireDelay:Qs});if(i.renewObservable.subscribe(()=>{c.add(a(),Ae()),o.notify()}),i.expireObservable.subscribe(()=>{s.notify(),c.closeActive(Ae())}),i.expandOrRenewSession(),c.add(a(),lr().relative),wo($e.SHORT_SESSION_INVESTIGATION)){const u=i.getSession();u&&si(e,u)}r.observable.subscribe(()=>{r.isGranted()?i.expandOrRenewSession():i.expire()}),ti(e,()=>{r.isGranted()&&i.expandOrRenewSession()}),ni(e,()=>i.expandSession()),ri(e,()=>i.restartSession());function a(){const u=i.getSession();return u?{id:u.id,trackingType:u[t],isReplayForced:!!u.forcedReplay,anonymousId:u.anonymousId}:(oi().catch(()=>{}),{id:"invalid",trackingType:en,isReplayForced:!1,anonymousId:void 0})}return{findSession:(u,d)=>c.find(u,d),renewObservable:o,expireObservable:s,sessionStateUpdateObservable:i.sessionStateUpdateObservable,expire:i.expire,updateSessionState:i.updateSessionState}}function ti(e,t){const{stop:n}=St(e,window,["click","touchstart","keydown","scroll"],t,{capture:!0,passive:!0})}function ni(e,t){const n=()=>{document.visibilityState==="visible"&&t()},{stop:r}=Z(e,document,"visibilitychange",n);rt(n,Zs)}function ri(e,t){const{stop:n}=Z(e,window,"resume",t,{capture:!0})}async function oi(){const e=an();Ct("Unexpected session state",{session:e,isSyntheticsTest:Xs(),createdTimestamp:e==null?void 0:e.created,expireTimestamp:e==null?void 0:e.expire,cookie:await Kn(),currentDomain:`${window.location.protocol}//${window.location.hostname}`})}function si(e,t){if(!window.cookieStore||!t.created)return;const n=Number(t.created),r=$(),{stop:o}=Z(e,cookieStore,"change",s);function s(i){const c=Ir(i.changed,u=>u.name===B);if(!c)return;const a=$()-n;if(a>14*D)o();else{const u=dt(c.value);if(u.id&&u.id!==t.id){o();const d=$()-r;Kn().then(l=>{Ct("Session cookie changed",{time:d,session_age:a,old:t,new:u,cookie:l})}).catch(tt)}}}}async function Kn(){let e;return"cookieStore"in window?e=await window.cookieStore.getAll(B):e=document.cookie.split(/\s*;\s*/).filter(t=>t.startsWith(B)),{count:e.length,domain:Zt()||"undefined",...e}}function jn(){let e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write(n,r){const o=Gt(n);t+=o,e+=n,r&&r(o)},finish(n){n(this.finishSync())},finishSync(){const n={output:e,outputBytesCount:t,rawBytesCount:t,pendingData:""};return e="",t=0,n},estimateEncodedBytesCount(n){return n.length}}}class ii{constructor(){this.callbacks={}}notify(t,n){const r=this.callbacks[t];r&&r.forEach(o=>o(n))}subscribe(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),{unsubscribe:()=>{this.callbacks[t]=this.callbacks[t].filter(r=>n!==r)}}}}function ci(e,t,n){let r=0,o=!1;return{isLimitReached(){if(r===0&&Se(()=>{r=0},D),r+=1,r<=t||o)return o=!1,!1;if(r===t+1){o=!0;try{n({message:`Reached max number of ${e}s by minute: ${t}`,source:A.AGENT,startClocks:x()})}finally{o=!1}}return!0}}}let vt;const wt=new WeakMap;function ai(e){return vt||(vt=ui(e)),vt}function ui(e){return new S(t=>{const{stop:n}=J(XMLHttpRequest.prototype,"open",li),{stop:r}=J(XMLHttpRequest.prototype,"send",s=>{di(s,e,t)},{computeHandlingStack:!0}),{stop:o}=J(XMLHttpRequest.prototype,"abort",fi);return()=>{n(),r(),o()}})}function li({target:e,parameters:[t,n]}){wt.set(e,{state:"open",method:String(t).toUpperCase(),url:ot(String(n))})}function di({target:e,parameters:[t],handlingStack:n},r,o){const s=wt.get(e);if(!s)return;const i=s;i.state="start",i.startClocks=x(),i.isAborted=!1,i.xhr=e,i.handlingStack=n,i.body=t;let c=!1;const{stop:a}=J(e,"onreadystatechange",()=>{e.readyState===XMLHttpRequest.DONE&&u()}),u=()=>{if(d(),a(),c)return;c=!0;const l=s;l.state="complete",l.duration=Ft(i.startClocks.timeStamp,U()),l.status=e.status,o.notify(pr(l))},{stop:d}=Z(r,e,"loadend",u);o.notify(i)}function fi({target:e}){const t=wt.get(e);t&&(t.isAborted=!0)}let At;function zn(){return At||(At=mi()),At}function mi(){return new S(e=>{if(!L.fetch)return;const{stop:t}=J(L,"fetch",n=>pi(n,e),{computeHandlingStack:!0});return t})}function pi({parameters:e,onPostCall:t,handlingStack:n},r){const[o,s]=e;let i=s&&s.method;i===void 0&&o instanceof Request&&(i=o.method);const c=i!==void 0?String(i).toUpperCase():"GET",a=o instanceof Request?o.url:ot(String(o)),u=x(),d={state:"start",init:s,input:o,method:c,startClocks:u,url:a,handlingStack:n};r.notify(d),e[0]=d.input,e[1]=d.init,t(l=>hi(r,l,d))}function hi(e,t,n){const r=n;function o(s){r.state="resolve",Object.assign(r,s),e.notify(r)}t.then(b(s=>{o({response:s,responseType:s.type,status:s.status,isAborted:!1})}),b(s=>{var i,c;o({status:0,isAborted:((c=(i=r.init)===null||i===void 0?void 0:i.signal)===null||c===void 0?void 0:c.aborted)||s instanceof DOMException&&s.code===DOMException.ABORT_ERR,error:s})}))}let It={};function gi(e){const t=e.map(n=>(It[n]||(It[n]=Ei(n)),It[n]));return Wt(...t)}function Ei(e){return new S(t=>{const n=N[e];return N[e]=(...r)=>{n.apply(console,r);const o=He("console error");ae(()=>{t.notify(yi(r,e,o))})},()=>{N[e]=n}})}function yi(e,t,n){const r=e.map(o=>bi(o)).join(" ");if(t===T.error){const o=e.find(X),s=bt({originalError:o,handlingStack:n,startClocks:x(),source:A.CONSOLE,handling:"handled",nonErrorPrefix:"Provided",useFallbackStack:!1});return s.message=r,{api:t,message:r,handlingStack:n,error:s}}return{api:t,message:r,error:void 0,handlingStack:n}}function bi(e){return typeof e=="string"?P(e):X(e)?bn(de(e)):Oe(P(e),void 0,2)}const Si=500;function _i(){const e=[];return{add:o=>{e.push(o)>Si&&e.splice(0,1)},remove:o=>{Bn(e,o)},drain:o=>{e.forEach(s=>s(o)),e.length=0}}}function Ti(e){const t=hn(e)==="object";return t||y.error("Unsupported context:",e),t}function Rt(e,t,n){const r={...e};for(const[o,{required:s,type:i}]of Object.entries(t))i==="string"&&!Yn(r[o])&&(r[o]=String(r[o])),s&&Yn(r[o])&&y.warn(`The property ${o} of ${n} is required; context will not be sent to the intake.`);return r}function Yn(e){return e==null||e===""}function Ve(e="",{propertiesConfig:t={}}={}){let n={};const r=new S,o={getContext:()=>An(n),setContext:s=>{Ti(s)?n=P(Rt(s,t,e)):o.clearContext(),r.notify()},setContextProperty:(s,i)=>{n=P(Rt({...n,[s]:i},t,e)),r.notify()},removeContextProperty:s=>{delete n[s],Rt(n,t,e),r.notify()},clearContext:()=>{n={},r.notify()},changeObservable:r};return o}function v(e,t,n,r){return b((...o)=>e()[t][n](...o))}function Lt(e,t,n){e.changeObservable.subscribe(()=>{const r=e.getContext();n.add(o=>o[t].setContext(r))})}const Oi="_dd_c",Ci=[];function Nt(e,t,n,r){const o=vi(n,r);Ci.push(Z(e,window,"storage",({key:u})=>{o===u&&i()})),t.changeObservable.subscribe(c);const s=ee(a(),t.getContext());Ie(s)||t.setContext(s);function i(){t.setContext(a())}function c(){localStorage.setItem(o,JSON.stringify(t.getContext()))}function a(){const u=localStorage.getItem(o);return u?JSON.parse(u):{}}}function vi(e,t){return`${Oi}_${e}_${t}`}function wi(e,t,n){const r=Vn();return t.storeContextsAcrossPages&&Nt(t,r,n,4),e.register(0,()=>{const o=r.getContext();return Ie(o)||!o.id?te:{account:o}}),r}function Vn(){return Ve("account",{propertiesConfig:{id:{type:"string",required:!0},name:{type:"string"}}})}function Ai(e,t,n,r){const o=Wn();return t.storeContextsAcrossPages&&Nt(t,o,n,2),e.register(0,()=>o.getContext()),o}function Wn(){return Ve("global context")}function Ii(e,t,n,r){const o=qn();return t.storeContextsAcrossPages&&Nt(t,o,r,1),e.register(0,({eventType:s,startTime:i})=>{const c=o.getContext(),a=n.findTrackedSession(i);return a&&a.anonymousId&&!c.anonymous_id&&t.trackAnonymousUser&&(c.anonymous_id=a.anonymousId),Ie(c)?te:{type:s,usr:c}}),e.register(1,({startTime:s})=>{var i;return{anonymous_id:(i=n.findTrackedSession(s))===null||i===void 0?void 0:i.anonymousId}}),o}function qn(){return Ve("user",{propertiesConfig:{id:{type:"string"},name:{type:"string"},email:{type:"string"}}})}const C={userContext:"userContext",globalContext:"globalContext",accountContext:"accountContext"},w={getContext:"getContext",setContext:"setContext",setContextProperty:"setContextProperty",removeContextProperty:"removeContextProperty",clearContext:"clearContext"};function Ri(e,t,n){const r=e.getReader(),o=[];let s=0;i();function i(){r.read().then(b(a=>{if(a.done){c();return}o.push(a.value),s+=a.value.length,s>n.bytesLimit?c():i()}),b(a=>t(a)))}function c(){r.cancel().catch(F);let a,u;{let d;if(o.length===1)d=o[0];else{d=new Uint8Array(s);let l=0;o.forEach(f=>{d.set(f,l),l+=f.length})}a=d.slice(0,n.bytesLimit),u=d.length>n.bytesLimit}t(void 0,a,u)}}const Jn={XHR:"xhr",FETCH:"fetch"},xt={FETCH:Jn.FETCH,XHR:Jn.XHR},Li=500;function Ni(e=Qo){const t=new qt(Li),n=e().subscribe(r=>{t.notify({type:0,error:r})});return{observable:t,stop:()=>{n.unsubscribe()}}}function We(e,t,n){const r=n.getHandler(),o=Array.isArray(r)?r:[r];return Xn[e]>=Xn[n.getLevel()]&&o.includes(t)}const h={ok:"ok",debug:"debug",info:"info",notice:"notice",warn:"warn",error:"error",critical:"critical",alert:"alert",emerg:"emerg"},Xn={[h.ok]:0,[h.debug]:1,[h.info]:2,[h.notice]:4,[h.warn]:5,[h.error]:6,[h.critical]:7,[h.alert]:8,[h.emerg]:9};function qe(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 xi=function(e,t,n,r){var o=arguments.length,s=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};const we={console:"console",http:"http"},ki=Object.keys(h);class I{constructor(t,n,r=we.http,o=h.debug,s={}){this.handleLogStrategy=t,this.handlerType=r,this.level=o,this.contextManager=Ve("logger"),this.tags=[],this.contextManager.setContext(s),n&&this.contextManager.setContextProperty("logger",{name:n})}logImplementation(t,n,r=h.info,o,s){const i=P(n);let c;if(o!=null){const a=bt({originalError:o,nonErrorPrefix:"Provided",source:A.LOGGER,handling:"handled",startClocks:x()});c=ee({error:qe(a,{includeMessage:!0})},a.context,i)}else c=i;this.handleLogStrategy({message:P(t),context:c,status:r},this,s)}log(t,n,r=h.info,o){let s;We(r,we.http,this)&&(s=He("log")),this.logImplementation(t,n,r,o,s)}setContext(t){this.contextManager.setContext(t)}getContext(){return this.contextManager.getContext()}setContextProperty(t,n){this.contextManager.setContextProperty(t,n)}removeContextProperty(t){this.contextManager.removeContextProperty(t)}clearContext(){this.contextManager.clearContext()}addTag(t,n){this.tags.push(Q(t,n))}removeTagsWithKey(t){const n=vn(t);this.tags=this.tags.filter(r=>r!==n&&!r.startsWith(`${n}:`))}getTags(){return this.tags.slice()}setHandler(t){this.handlerType=t}getHandler(){return this.handlerType}setLevel(t){this.level=t}getLevel(){return this.level}}xi([Er],I.prototype,"logImplementation",null),I.prototype.ok=M(h.ok),I.prototype.debug=M(h.debug),I.prototype.info=M(h.info),I.prototype.notice=M(h.notice),I.prototype.warn=M(h.warn),I.prototype.error=M(h.error),I.prototype.critical=M(h.critical),I.prototype.alert=M(h.alert),I.prototype.emerg=M(h.emerg);function M(e){return function(t,n,r){let o;We(e,we.http,this)&&(o=He("log")),this.logImplementation(t,n,e,r,o)}}function Zn(){return z?{}:{view:{referrer:document.referrer,url:window.location.href}}}const Ui=32*ie;function Pi(e,t){e.usePciIntake===!0&&e.site&&e.site!=="datadoghq.com"&&y.warn("PCI compliance for Logs is only available for Datadog organizations in the US1 site. Default intake will be used.");const n=To(e,t),r=Qn(e.forwardConsoleLogs,ke(T),"Forward Console Logs"),o=Qn(e.forwardReports,ke(Be),"Forward Reports");if(!(!n||!r||!o))return e.forwardErrorsToLogs&&!r.includes(T.error)&&r.push(T.error),{forwardErrorsToLogs:e.forwardErrorsToLogs!==!1,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:Ui,...n}}function Qn(e,t,n){if(e===void 0)return[];if(!(e==="all"||Array.isArray(e)&&e.every(r=>t.includes(r)))){y.error(`${n} should be "all" or an array with allowed values "${t.join('", "')}"`);return}return e==="all"?t:Gs(e)}function Mi(e){const t=Oo(e);return{forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports,use_pci_intake:e.usePciIntake,...t}}function Di(e,t,n){const r=_i(),o=Wn();Lt(o,C.globalContext,r);const s=Vn();Lt(s,C.accountContext,r);const i=qn();Lt(i,C.userContext,r);let c,a;const u=t.observable.subscribe(d);function d(){if(!a||!c||!t.isGranted())return;u.unsubscribe();const l=n(c,a);r.drain(l)}return{init(l,f){if(!l){y.error("Missing configuration");return}if(Co(l.enableExperimentalFeatures),Ke()&&(l=$i(l)),c=l,$s(Mi(l)),a){_n("DD_LOGS",l);return}const p=Pi(l,f);p&&(a=p,zn().subscribe(F),t.tryToInit(p.trackingConsent),d())},get initConfiguration(){return c},globalContext:o,accountContext:s,userContext:i,getInternalContext:F,handleLog(l,f,p,g=e(),O=U()){r.add(_=>_.handleLog(l,f,p,g,O))}}}function $i(e){return{...e,clientToken:"empty"}}function Fi(e){const t=eo(),n=Ni().observable;let r=Di(Zn,t,(c,a)=>{const u=e(a,Zn,t,n);return r=Hi(c,u),u});const o=()=>r,s={},i=new I((...c)=>r.handleLog(...c));return ns({logger:i,init:c=>{const a=new Error().stack;ae(()=>r.init(c,a))},setTrackingConsent:b(c=>{t.update(c),Fs({feature:"set-tracking-consent",tracking_consent:c})}),getGlobalContext:v(o,C.globalContext,w.getContext),setGlobalContext:v(o,C.globalContext,w.setContext),setGlobalContextProperty:v(o,C.globalContext,w.setContextProperty),removeGlobalContextProperty:v(o,C.globalContext,w.removeContextProperty),clearGlobalContext:v(o,C.globalContext,w.clearContext),createLogger:b((c,a={})=>(s[c]=new I((...u)=>r.handleLog(...u),P(c),a.handler,a.level,P(a.context)),s[c])),getLogger:b(c=>s[c]),getInitConfiguration:b(()=>An(r.initConfiguration)),getInternalContext:b(c=>r.getInternalContext(c)),setUser:v(o,C.userContext,w.setContext),getUser:v(o,C.userContext,w.getContext),setUserProperty:v(o,C.userContext,w.setContextProperty),removeUserProperty:v(o,C.userContext,w.removeContextProperty),clearUser:v(o,C.userContext,w.clearContext),setAccount:v(o,C.accountContext,w.setContext),getAccount:v(o,C.accountContext,w.getContext),setAccountProperty:v(o,C.accountContext,w.setContextProperty),removeAccountProperty:v(o,C.accountContext,w.removeContextProperty),clearAccount:v(o,C.accountContext,w.clearContext)})}function Hi(e,t){return{init:n=>{_n("DD_LOGS",n)},initConfiguration:e,...t}}const Bi="logs";function Gi(e,t){const n=ei(e,Bi,r=>er(e,r),t);return{findTrackedSession:(r,o={returnInactive:!1})=>{const s=n.findSession(r,o);return s&&s.trackingType==="1"?{id:s.id,anonymousId:s.anonymousId}:void 0},expireObservable:n.expireObservable}}function Ki(e){const n=er(e)==="1"?{}:void 0;return{findTrackedSession:()=>n,expireObservable:new S}}function er(e,t){return ji(t)?t:be(e.sessionSampleRate)?"1":"0"}function ji(e){return e==="0"||e==="1"}function zi(e,t,n,r,o){const s=ki.concat(["custom"]),i={};s.forEach(c=>{i[c]=ci(c,e.eventRateLimiterThreshold,o)}),t.subscribe(0,({rawLogsEvent:c,messageContext:a=void 0,savedCommonContext:u=void 0,domainContext:d,ddtags:l=[]})=>{var f,p;const g=fr(c.date),O=u||r(),_=n.triggerHook(0,{startTime:g});if(_===he)return;const G=Cn(e),Ee=ee({view:O.view},_,c,a,{ddtags:G.concat(l).join(",")});((f=e.beforeSend)===null||f===void 0?void 0:f.call(e,Ee,d))===!1||Ee.origin!==A.AGENT&&((p=i[Ee.status])!==null&&p!==void 0?p:i.custom).isLimitReached()||t.notify(1,Ee)})}const Yi={[T.log]:h.info,[T.debug]:h.debug,[T.info]:h.info,[T.warn]:h.warn,[T.error]:h.error};function Vi(e,t){const n=gi(e.forwardConsoleLogs).subscribe(r=>{var o;const s={rawLogsEvent:{date:U(),message:r.message,origin:A.CONSOLE,error:r.error&&qe(r.error),status:Yi[r.api]},messageContext:(o=r.error)===null||o===void 0?void 0:o.context,domainContext:{handlingStack:r.handlingStack}};t.notify(0,s)});return{stop:()=>{n.unsubscribe()}}}function Wi(e,t){const n=os(e,e.forwardReports).subscribe(r=>{let o=r.message,s;const i=r.originalError.type==="deprecation"?h.warn:h.error;i===h.error?s=qe(r):r.stack&&(o+=` Found in ${Xo(r.stack)}`),t.notify(0,{rawLogsEvent:{date:U(),message:o,origin:A.REPORT,error:s,status:i}})});return{stop:()=>{n.unsubscribe()}}}function qi(e,t){if(!e.forwardErrorsToLogs)return{stop:F};const n=(z?new S:ai(e)).subscribe(s=>{s.state==="complete"&&o(xt.XHR,s)}),r=zn().subscribe(s=>{s.state==="resolve"&&o(xt.FETCH,s)});function o(s,i){!So(i.url)&&(Qi(i)||In(i.status))&&("xhr"in i?Ji(i.xhr,e,c):i.response?Zi(i.response,e,c):i.error&&Xi(i.error,e,c));function c(a){const u={isAborted:i.isAborted,handlingStack:i.handlingStack};t.notify(0,{rawLogsEvent:{message:`${ec(s)} error ${i.method} ${i.url}`,date:i.startClocks.timeStamp,error:{stack:a||"Failed to load",handling:void 0},http:{method:i.method,status_code:i.status,url:i.url},status:h.error,origin:A.NETWORK},domainContext:u})}}return{stop:()=>{n.unsubscribe(),r.unsubscribe()}}}function Ji(e,t,n){typeof e.response=="string"?n(kt(e.response,t)):n(e.response)}function Xi(e,t,n){n(kt(me(de(e)),t))}function Zi(e,t,n){const r=ps(e);!r||!r.body?n():window.TextDecoder?tc(r.body,t.requestErrorResponseLengthLimit,(o,s)=>{n(o?`Unable to retrieve response: ${o}`:s)}):r.text().then(b(o=>n(kt(o,t))),b(o=>n(`Unable to retrieve response: ${o}`)))}function Qi(e){return e.status===0&&e.responseType!=="opaque"}function kt(e,t){return e.length>t.requestErrorResponseLengthLimit?`${e.substring(0,t.requestErrorResponseLengthLimit)}...`:e}function ec(e){return xt.XHR===e?"XHR":"Fetch"}function tc(e,t,n){Ri(e,(r,o,s)=>{if(r)n(r);else{let i=new TextDecoder().decode(o);s&&(i+="..."),n(void 0,i)}},{bytesLimit:t})}function nc(e,t,n){if(!e.forwardErrorsToLogs)return{stop:F};const r=n.subscribe(o=>{if(o.type===0){const s=o.error;t.notify(0,{rawLogsEvent:{message:s.message,date:s.startClocks.timeStamp,error:qe(s),origin:A.SOURCE,status:h.error},messageContext:s.context})}});return{stop:()=>{r.unsubscribe()}}}const rc=ii;function oc(e){function t(n,r,o,s,i){const c=ee(r.getContext(),n.context);if(We(n.status,we.console,r)&&ic(n,c),We(n.status,we.http,r)){const a={rawLogsEvent:{date:i||U(),message:n.message,status:n.status,origin:A.LOGGER},messageContext:c,savedCommonContext:s,ddtags:r.getTags()};o&&(a.domainContext={handlingStack:o}),e.notify(0,a)}}return{handleLog:t}}const sc={[h.ok]:T.debug,[h.debug]:T.debug,[h.info]:T.info,[h.notice]:T.info,[h.warn]:T.warn,[h.error]:T.error,[h.critical]:T.error,[h.alert]:T.error,[h.emerg]:T.error};function ic({status:e,message:t},n){j[sc[e]].call(N,t,n)}function cc(e,t,n,r,o){const s=[e.logsEndpointBuilder];e.replica&&s.push(e.replica.logsEndpointBuilder);const i=$n({encoder:jn(),request:Mn(s,e.batchBytesLimit,n),flushController:Hn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageMayExitObservable:r,sessionExpireObservable:o.expireObservable}),messageBytesLimit:e.messageBytesLimit});return t.subscribe(1,c=>{i.add(c)}),i}function ac(e){const t=Tt();e.subscribe(1,n=>{t.send("log",n)})}function uc(e){return{get:t=>{const n=e.findTrackedSession(t);if(n)return{session_id:n.id}}}}function lc(e){return t=>{e.notify(0,{rawLogsEvent:{message:t.message,date:t.startClocks.timeStamp,origin:A.AGENT,status:h.error}}),Ct("Error reported to customer",{"error.message":t.message})}}const dc=Is;function fc(e){const t=L;e.register(0,({startTime:o})=>{const s=n(o);return s||te}),e.register(1,({startTime:o})=>{var s,i;const c=n(o);return c?{application:{id:c.application_id},view:{id:(s=c.view)===null||s===void 0?void 0:s.id},action:{id:(i=c.user_action)===null||i===void 0?void 0:i.id}}:te});function n(o){const i=Gn()?t.DD_RUM_SYNTHETICS:t.DD_RUM,c=r(o,i);if(c)return c}function r(o,s){if(s&&s.getInternalContext)return s.getInternalContext(o)}}function mc(e,t,n){e.register(0,({startTime:r})=>{const o=n.findTrackedSession(r);return n.findTrackedSession(r,{returnInactive:!0})?{service:t.service,session_id:o?o.id:void 0,session:o?{id:o.id}:void 0}:he}),e.register(1,({startTime:r})=>{const o=n.findTrackedSession(r);return!o||!o.id?te:{session:{id:o.id}}})}function pc(e,t){function n(){return t.isGranted()?te:he}e.register(0,n),e.register(1,n)}const Ut="logs";function hc(e,t,n,r){const o=new rc,s=dc(),i=[];o.subscribe(1,_=>wn("logs",_));const c=lc(o),a=z?new S:ws(e),u=xs("browser-logs-sdk",e,s,c,a,jn);i.push(u.stop);const d=e.sessionStoreStrategyType&&!Ke()&&!Gn()?Gi(e,n):Ki(e);pc(s,n),mc(s,e,d);const l=wi(s,e,Ut),f=Ii(s,e,d,Ut),p=Ai(s,e,Ut);fc(s),qi(e,o),nc(e,o,r),r.unbuffer(),Vi(e,o),Wi(e,o);const{handleLog:g}=oc(o);if(zi(e,o,s,t,c),Ke())ac(o);else{const{stop:_}=cc(e,o,c,a,d);i.push(()=>_())}const O=uc(d);return{handleLog:g,getInternalContext:O.get,accountContext:l,globalContext:p,userContext:f,stop:()=>{i.forEach(_=>_())}}}const Je=Fi(hc);rs(R(),"DD_LOGS",Je),m.Environment=void 0,function(e){e.DEVELOPMENT="development",e.PRODUCTION="production",e.SANDBOX="sandbox",e.PRELIVE_SANDBOX="prelive-sandbox",e.PRELIVE_PRODUCTION="prelive-production"}(m.Environment||(m.Environment={}));class ge{constructor(){this.initialized=!1,this.configService=K.instance}static get instance(){return ge._instance||(ge._instance=new ge),ge._instance}initialize(t,n){if(this.initialized){try{Je.setGlobalContextProperty("sessionUuid",n),console.log("MONTONIO-JS: LoggingService: Session UUID updated:",n)}catch(r){console.error("MONTONIO-JS: LoggingService: Error updating sessionUuid:",r)}return}try{const r=this.configService.getConfig("datadogClientToken");Je.init({clientToken:r,site:"datadoghq.eu",env:t===m.Environment.PRODUCTION?"live-production":"live-sandbox",forwardErrorsToLogs:!0,service:"montonio-js",version:"1.0.59",silentMultipleInit:!0,forwardConsoleLogs:"all"}),Je.setGlobalContext({sessionUuid:n}),this.initialized=!0}catch(r){console.error("MONTONIO-JS: LoggingService: Error initializing Datadog Logs:",r)}}}class tr{constructor(t){var n;this.defaultStyles={border:"none",display:"block",width:"100%",height:"100%"},this.options=t,this.resizeOnHeightChange=(n=t.resizeOnHeightChange)!==null&&n!==void 0?n:!0,this.element=document.createElement("iframe"),this.messagingService=new Mt,this.setupIframe()}mount(){return this.options.mountElement.appendChild(this.element),this.resizeOnHeightChange&&this.startResizing(this.element),this.element}unmount(){this.element.contentWindow&&this.messagingService.clearAllSubscriptions(),this.element.parentNode&&this.element.parentNode.removeChild(this.element)}getContentWindow(){if(!this.element.contentWindow)throw new Error("Iframe contentWindow is not available. Make sure the iframe is mounted and loaded.");return this.element.contentWindow}startResizing(t){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_HEIGHT_CHANGED,n=>{t.style.height=n.payload.height+"px"},this)}setupIframe(){const{src:t,allow:n="camera; microphone; geolocation; payment",styles:r={}}=this.options;this.element.src=t,this.element.allow=n;const o={...this.defaultStyles,...r};Object.assign(this.element.style,o)}}class nr{constructor(){this.loaded=!1,this.mountElement=null,this._iframe=null,this.messagingService=new Mt,this.httpService=oe.instance,this.configService=K.instance}get iframe(){if(!this._iframe)throw new Error("Iframe not initialized");return this._iframe}set iframe(t){this._iframe=t}cleanup(){this.iframe&&(this.iframe.unmount(),this.iframe=null)}}function gc(e){if(typeof e=="string"){const t=document.querySelector(e);if(!t||!(t instanceof HTMLElement))throw new Error(`Element not found: ${e}`);return t}return e}function Ec(){const e=document.body.style.overflow||null;return document.body.style.overflow="hidden",{originalOverflow:e}}function yc(e){e?document.body.style.overflow=e:document.body.style.removeProperty("overflow")}m.LocaleEnum=void 0,function(e){e.EN="en",e.ET="et",e.LT="lt",e.LV="lv",e.PL="pl",e.RU="ru",e.FI="fi"}(m.LocaleEnum||(m.LocaleEnum={}));var rr;(function(e){e.PENDING="PENDING",e.AUTHORIZED="AUTHORIZED",e.PAID="PAID",e.PARTIALLY_REFUNDED="PARTIALLY_REFUNDED",e.REFUNDED="REFUNDED",e.VOIDED="VOIDED",e.ABANDONED="ABANDONED"})(rr||(rr={}));const bc=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Sc(e){const t=[];if(!e)throw new Xe(["CheckoutOptions object is required"]);if(e.sessionUuid===void 0||e.sessionUuid===null?t.push("sessionUuid is required"):typeof e.sessionUuid!="string"?t.push("sessionUuid must be a string"):bc.test(e.sessionUuid)||t.push(`sessionUuid must be a valid UUID format. Received: '${e.sessionUuid}'`),e.onSuccess?typeof e.onSuccess!="function"&&t.push("onSuccess must be a function"):t.push("onSuccess callback is required"),e.onError?typeof e.onError!="function"&&t.push("onError must be a function"):t.push("onError callback is required"),e.locale!==void 0&&e.locale!==null){const n=Object.values(m.LocaleEnum);n.includes(e.locale)||t.push(`locale must be one of: ${n.join(", ")}. Received: '${e.locale}'`)}if(e.environment!==void 0&&e.environment!==null&&(Object.values(m.Environment).includes(e.environment)||t.push(`environment must be one of: production, sandbox. Received: '${e.environment}'`)),t.length>0)throw new Xe(t)}function _c(e){const t=[];if(e.locale!==void 0&&e.locale!==null){const n=Object.values(m.LocaleEnum);n.includes(e.locale)||t.push(`locale must be one of: ${n.join(", ")}. Received: '${e.locale}'`)}if(t.length>0)throw new Xe(t)}class Tc extends nr{constructor(t){super(),this.originalBodyOverflow=null,this.options=t,this.mountElement=t.mountElement||document.body}async initialize(){try{if(this.options.paymentAuthData.type==="redirect"){await this.redirectViaPost(this.options.paymentAuthData);return}if(!this.options.paymentAuthData.embeddedUrl)throw new Error("Embedded URL is not set in paymentAuthData");const{originalOverflow:t}=Ec();this.originalBodyOverflow=t,this.iframe=new tr({src:this.options.paymentAuthData.embeddedUrl,mountElement:this.mountElement,styles:{width:"100dvw",height:"100dvh",position:"fixed",top:"0",left:"0",zIndex:"2147483647"},resizeOnHeightChange:!1}),this.iframe.mount(),await this.messagingService.waitForMessage(m.MessageTypeEnum.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY,this.iframe),this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_SEND_PAYMENT_AUTH_DATA,payload:{paymentAuthData:this.options.paymentAuthData}}),this.loaded=!0}catch(t){throw this.cleanup(),t}}cleanup(){this.loaded&&yc(this.originalBodyOverflow),super.cleanup()}async redirectViaPost(t){if(!t.redirectUrl)throw new Error("Redirect URL is not set in paymentAuthData");const n=document.createElement("form");if(n.method=t.redirectMethod||"get",n.action=t.redirectUrl,n.style.display="none",t.formData)for(const[r,o]of Object.entries(t.formData)){const s=document.createElement("input");s.type="hidden",s.name=r,s.value=o,n.appendChild(s)}throw document.body.appendChild(n),n.submit(),await new Promise(r=>setTimeout(r,3e4)),new Error("Redirect timeout: Expected redirect to occur within 30 seconds")}}class Oc extends nr{constructor(t){super(),this.isValid=!1,this.paymentAuth=null,this.options=t,this.environment=t.environment||m.Environment.PRODUCTION,ge.instance.initialize(this.environment,this.options.sessionUuid),console.log("MONTONIO-JS: MontonioCheckout: class created with options:",t),Sc(t)}async initialize(t){try{console.log("MONTONIO-JS: initialize: Initializing MontonioCheckout with mountTo:",t),this.mountElement=gc(t);const n=await this.fetchSession();return this.iframe=new tr({src:n.url,mountElement:this.mountElement}),this.iframe.mount(),await this.messagingService.waitForMessage(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPONENT_READY,this.iframe),this.setUpListeners(),this.loaded=!0,console.log("MONTONIO-JS: initialize: MontonioCheckout initialized successfully"),!0}catch(n){throw console.error("MONTONIO-JS: initialize: Error initializing MontonioCheckout:",n),this.cleanup(),n}}updateOptions(t){if(console.log("MONTONIO-JS: updateOptions: Updating options to:",t),!this.loaded)throw new re;_c(t),t.locale!==void 0&&(this.options.locale=t.locale,this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_CHANGE_LOCALE,payload:{locale:t.locale}}))}validateOrReject(){if(console.log("MONTONIO-JS: validateOrReject: Called validateOrReject, isValid:",this.isValid),!this.isValid)throw this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_VALIDATE_FIELDS}),new Pt}submitPayment(){if(!this.loaded)throw new re;this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_SUBMIT_PAYMENT})}async fetchSession(){const n=`${this.configService.getConfig("stargateUrl",this.environment)}/api/sessions/${this.options.sessionUuid}/gateway-url${this.options.locale?`?preferredLocale=${this.options.locale}`:""}`;return console.log("MONTONIO-JS: fetchSession: Fetching iframe URL from:",n),await this.httpService.get(n)}setUpListeners(){console.log("MONTONIO-JS: setUpListeners: Setting up listeners"),this.setUpFormChangeListener(),this.setUpPaymentCompletedListener(),this.setUpPaymentFailedListener(),this.setUpValidationListener(),this.setUpPaymentAuthListener()}setUpFormChangeListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_PAYMENT_FORM_CHANGED,t=>{this.isValid=t.payload.isValid},this.iframe)}setUpPaymentCompletedListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,async t=>{console.log("MONTONIO-JS: CHECKOUT_PAYMENT_COMPLETED (from main iframe)",t),this.cleanupPaymentAuth();try{const n=await this.getPaymentResult(t.payload.paymentIntentUuid);this.handlePaymentSuccess(n)}catch(n){this.handlePaymentError(n)}},this.iframe)}setUpPaymentFailedListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,t=>{console.error("MONTONIO-JS: CHECKOUT_PAYMENT_FAILED (from main iframe)",t),this.cleanupPaymentAuth(),this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_SEND_PAYMENT_FAILED_DATA,payload:t.payload}),this.handlePaymentError(new or(t.payload))},this.iframe)}setUpValidationListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_VALIDATE_FIELDS_RESULT,t=>{console.log("MONTONIO-JS: CHECKOUT_VALIDATE_FIELDS_RESULT",t),t.payload.isValid||this.handlePaymentError(new Pt)},this.iframe)}setUpPaymentAuthListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_START_PAYMENT_AUTH,async t=>{try{console.log("MONTONIO-JS: PAYMENT_AUTH_STARTED",t),this.paymentAuth=new Tc({paymentAuthData:t.payload.paymentAuthData}),await this.paymentAuth.initialize();const n=this.paymentAuth.iframe;this.messagingService.addIframeToSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,n),this.messagingService.addIframeToSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,n)}catch(n){this.handlePaymentError(n)}},this.iframe)}async getPaymentResult(t){const r=`${this.configService.getConfig("stargateUrl",this.environment)}/api/payment-intents/${t}/return-url`,o=10,s=1e3;let i=0;for(;i<o;){try{console.log("MONTONIO-JS: getPaymentResult: Fetching return URL from:",r);const c=await this.httpService.get(r);if(i++,c!=null&&c.merchantReturnUrl)return{returnUrl:c.merchantReturnUrl,orderToken:c.orderToken,paymentStatus:c.paymentStatus}}catch(c){console.error("MONTONIO-JS: getPaymentResult: Error fetching return URL:",c)}i<o&&await new Promise(c=>setTimeout(c,s))}throw new sr({attempts:i})}cleanupPaymentAuth(){this.paymentAuth&&(this.messagingService.removeIframeFromSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,this.paymentAuth.iframe),this.messagingService.removeIframeFromSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,this.paymentAuth.iframe),this.paymentAuth.cleanup(),this.paymentAuth=null)}handlePaymentSuccess(t){this.options.onSuccess(t),console.log("MONTONIO-JS: handlePaymentSuccess: onSuccess callback called with result:",t)}handlePaymentError(t){this.options.onError(t),console.error("MONTONIO-JS: handlePaymentError: onError callback called with error:",t)}}m.MontonioCheckout=Oc,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
13
|
+
${f}`),e.finish(O=>{g(Fn(O))})}return{flushController:n,add:u,upsert:u,stop:s.unsubscribe}}function Fn(e){let t;return typeof e.output=="string"?t=e.output:t=new Blob([e.output],{type:"text/plain"}),{data:t,bytesCount:e.outputBytesCount,encoding:e.encoding}}function Hn({messagesLimit:e,bytesLimit:t,durationLimit:n,pageMayExitObservable:r,sessionExpireObservable:o}){const s=r.subscribe(g=>d(g.reason)),i=o.subscribe(()=>d("session_expire")),c=new S(()=>()=>{s.unsubscribe(),i.unsubscribe()});let a=0,u=0;function d(g){if(u===0)return;const O=u,_=a;u=0,a=0,p(),c.notify({reason:g,messagesCount:O,bytesCount:_})}let l;function f(){l===void 0&&(l=Se(()=>{d("duration_limit")},n))}function p(){zt(l),l=void 0}return{flushObservable:c,get messagesCount(){return u},notifyBeforeAddMessage(g){a+g>=t&&d("bytes_limit"),u+=1,a+=g,f()},notifyAfterAddMessage(g=0){a+=g,u>=e?d("messages_limit"):a>=t&&d("bytes_limit")},notifyAfterRemoveMessage(g){a-=g,u-=1,u===0&&p()}}}const he="DISCARDED",te="SKIPPED";function Is(){const e={};return{register(t,n){return e[t]||(e[t]=[]),e[t].push(n),{unregister:()=>{e[t]=e[t].filter(r=>r!==n)}}},triggerHook(t,n){const r=e[t]||[],o=[];for(const s of r){const i=s(n);if(i===he)return he;i!==te&&o.push(i)}return ee(...o)}}}const ne={LOG:"log",CONFIGURATION:"configuration",USAGE:"usage"},Rs=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],Ls=1,Ns=[uo];let Ot;function Ce(){return Ot||(Ot=new qt(100)),Ot}function xs(e,t,n,r,o,s){const i=new S,{stop:c}=Us(t,r,o,s,i),{enabled:a,metricsEnabled:u}=ks(e,t,n,i);return{stop:c,enabled:a,metricsEnabled:u}}function ks(e,t,n,r,o=Ls){const s={},i=!Ns.includes(t.site)&&be(t.telemetrySampleRate),c={[ne.LOG]:i,[ne.CONFIGURATION]:i&&be(t.telemetryConfigurationSampleRate),[ne.USAGE]:i&&be(t.telemetryUsageSampleRate),metric:i&&be(o)},a=Ps(),u=Ce();return u.subscribe(({rawEvent:l,metricName:f})=>{if(f&&!c.metric||!c[l.type])return;const p=f||l.status||l.type;let g=s[p];if(g||(g=s[p]=new Set),g.size>=t.maxTelemetryEventsPerPage)return;const O=Oe(l);if(g.has(O))return;const _=n.triggerHook(1,{startTime:x().relative});if(_===he)return;const G=d(_,e,l,a);r.notify(G),wn("telemetry",G),g.add(O)}),u.unbuffer(),hr(Ds),{enabled:i,metricsEnabled:c.metric};function d(l,f,p,g){const _={type:"telemetry",date:x().timeStamp,service:f,version:"6.22.0",source:"browser",_dd:{format_version:2},telemetry:ee(p,{runtime_env:g,connectivity:ms(),sdk_setup:"npm"}),ddtags:Cn(t).join(","),experimental_features:Array.from(Ao())};return ee(_,l)}}function Us(e,t,n,r,o){const s=[];if(Ke()){const i=Tt(),c=o.subscribe(a=>i.send("internal_telemetry",a));s.push(c.unsubscribe)}else{const i=[e.rumEndpointBuilder];e.replica&&Ms(e)&&i.push(e.replica.rumEndpointBuilder);const c=$n({encoder:r(4),request:Mn(i,e.batchBytesLimit,t),flushController:Hn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageMayExitObservable:n,sessionExpireObservable:new S}),messageBytesLimit:e.messageBytesLimit});s.push(c.stop);const a=o.subscribe(c.add);s.push(a.unsubscribe)}return{stop:()=>s.forEach(i=>i())}}function Ps(){var e;return{is_local_file:((e=L.location)===null||e===void 0?void 0:e.protocol)==="file:",is_worker:z}}function Ms(e){return e.site===co}function Ct(e,t){nt(T.debug,e,t),Ce().notify({rawEvent:{type:ne.LOG,message:e,status:"debug",...t}})}function Ds(e,t){Ce().notify({rawEvent:{type:ne.LOG,status:"error",...Hs(e),...t}})}function $s(e){Ce().notify({rawEvent:{type:ne.CONFIGURATION,configuration:e}})}function Fs(e){Ce().notify({rawEvent:{type:ne.USAGE,usage:e}})}function Hs(e){if(X(e)){const t=de(e);return{error:{kind:t.name,stack:me(Bs(t))},message:t.message}}return{error:{stack:Sn},message:`Uncaught ${Oe(e)}`}}function Bs(e){return e.stack=e.stack.filter(t=>!t.url||Rs.some(n=>t.url.startsWith(n))),e}function Gs(e){const t=new Set;return e.forEach(n=>t.add(n)),Array.from(t)}function Bn(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}const ze=1/0,Ks=D;let ve=null;const Ye=new Set;function js(){Ye.forEach(e=>e())}function zs({expireDelay:e,maxEntries:t}){let n=[];ve||(ve=rt(()=>js(),Ks));const r=()=>{const d=Ae()-e;for(;n.length>0&&n[n.length-1].endTime<d;)n.pop()};Ye.add(r);function o(d,l){const f={value:d,startTime:l,endTime:ze,remove:()=>{Bn(n,f)},close:p=>{f.endTime=p}};return t&&n.length>=t&&n.pop(),n.unshift(f),f}function s(d=ze,l={returnInactive:!1}){for(const f of n)if(f.startTime<=d){if(l.returnInactive||d<=f.endTime)return f.value;break}}function i(d){const l=n[0];l&&l.endTime===ze&&l.close(d)}function c(d=ze,l=0){const f=dr(d,l);return n.filter(p=>p.startTime<=f&&d<=p.endTime).map(p=>p.value)}function a(){n=[]}function u(){Ye.delete(r),Ye.size===0&&ve&&(Yt(ve),ve=null)}return{add:o,find:s,closeActive:i,findAll:c,reset:a,stop:u}}const Ys="datadog-synthetics-public-id",Vs="datadog-synthetics-result-id",Ws="datadog-synthetics-injects-rum";function Gn(){return z?!1:!!(L._DATADOG_SYNTHETICS_INJECTS_RUM||Y(Ws))}function qs(){const e=window._DATADOG_SYNTHETICS_PUBLIC_ID||Y(Ys);return typeof e=="string"?e:void 0}function Js(){const e=window._DATADOG_SYNTHETICS_RESULT_ID||Y(Vs);return typeof e=="string"?e:void 0}function Xs(){return!!(qs()&&Js())}const Zs=D,Qs=ut;function ei(e,t,n,r){const o=new S,s=new S,i=Qr(e.sessionStoreStrategyType,e,t,n),c=zs({expireDelay:Qs});if(i.renewObservable.subscribe(()=>{c.add(a(),Ae()),o.notify()}),i.expireObservable.subscribe(()=>{s.notify(),c.closeActive(Ae())}),i.expandOrRenewSession(),c.add(a(),lr().relative),wo($e.SHORT_SESSION_INVESTIGATION)){const u=i.getSession();u&&si(e,u)}r.observable.subscribe(()=>{r.isGranted()?i.expandOrRenewSession():i.expire()}),ti(e,()=>{r.isGranted()&&i.expandOrRenewSession()}),ni(e,()=>i.expandSession()),ri(e,()=>i.restartSession());function a(){const u=i.getSession();return u?{id:u.id,trackingType:u[t],isReplayForced:!!u.forcedReplay,anonymousId:u.anonymousId}:(oi().catch(()=>{}),{id:"invalid",trackingType:en,isReplayForced:!1,anonymousId:void 0})}return{findSession:(u,d)=>c.find(u,d),renewObservable:o,expireObservable:s,sessionStateUpdateObservable:i.sessionStateUpdateObservable,expire:i.expire,updateSessionState:i.updateSessionState}}function ti(e,t){const{stop:n}=St(e,window,["click","touchstart","keydown","scroll"],t,{capture:!0,passive:!0})}function ni(e,t){const n=()=>{document.visibilityState==="visible"&&t()},{stop:r}=Z(e,document,"visibilitychange",n);rt(n,Zs)}function ri(e,t){const{stop:n}=Z(e,window,"resume",t,{capture:!0})}async function oi(){const e=an();Ct("Unexpected session state",{session:e,isSyntheticsTest:Xs(),createdTimestamp:e==null?void 0:e.created,expireTimestamp:e==null?void 0:e.expire,cookie:await Kn(),currentDomain:`${window.location.protocol}//${window.location.hostname}`})}function si(e,t){if(!window.cookieStore||!t.created)return;const n=Number(t.created),r=$(),{stop:o}=Z(e,cookieStore,"change",s);function s(i){const c=Ir(i.changed,u=>u.name===B);if(!c)return;const a=$()-n;if(a>14*D)o();else{const u=dt(c.value);if(u.id&&u.id!==t.id){o();const d=$()-r;Kn().then(l=>{Ct("Session cookie changed",{time:d,session_age:a,old:t,new:u,cookie:l})}).catch(tt)}}}}async function Kn(){let e;return"cookieStore"in window?e=await window.cookieStore.getAll(B):e=document.cookie.split(/\s*;\s*/).filter(t=>t.startsWith(B)),{count:e.length,domain:Zt()||"undefined",...e}}function jn(){let e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write(n,r){const o=Gt(n);t+=o,e+=n,r&&r(o)},finish(n){n(this.finishSync())},finishSync(){const n={output:e,outputBytesCount:t,rawBytesCount:t,pendingData:""};return e="",t=0,n},estimateEncodedBytesCount(n){return n.length}}}class ii{constructor(){this.callbacks={}}notify(t,n){const r=this.callbacks[t];r&&r.forEach(o=>o(n))}subscribe(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),{unsubscribe:()=>{this.callbacks[t]=this.callbacks[t].filter(r=>n!==r)}}}}function ci(e,t,n){let r=0,o=!1;return{isLimitReached(){if(r===0&&Se(()=>{r=0},D),r+=1,r<=t||o)return o=!1,!1;if(r===t+1){o=!0;try{n({message:`Reached max number of ${e}s by minute: ${t}`,source:A.AGENT,startClocks:x()})}finally{o=!1}}return!0}}}let vt;const wt=new WeakMap;function ai(e){return vt||(vt=ui(e)),vt}function ui(e){return new S(t=>{const{stop:n}=J(XMLHttpRequest.prototype,"open",li),{stop:r}=J(XMLHttpRequest.prototype,"send",s=>{di(s,e,t)},{computeHandlingStack:!0}),{stop:o}=J(XMLHttpRequest.prototype,"abort",fi);return()=>{n(),r(),o()}})}function li({target:e,parameters:[t,n]}){wt.set(e,{state:"open",method:String(t).toUpperCase(),url:ot(String(n))})}function di({target:e,parameters:[t],handlingStack:n},r,o){const s=wt.get(e);if(!s)return;const i=s;i.state="start",i.startClocks=x(),i.isAborted=!1,i.xhr=e,i.handlingStack=n,i.body=t;let c=!1;const{stop:a}=J(e,"onreadystatechange",()=>{e.readyState===XMLHttpRequest.DONE&&u()}),u=()=>{if(d(),a(),c)return;c=!0;const l=s;l.state="complete",l.duration=Ft(i.startClocks.timeStamp,U()),l.status=e.status,o.notify(pr(l))},{stop:d}=Z(r,e,"loadend",u);o.notify(i)}function fi({target:e}){const t=wt.get(e);t&&(t.isAborted=!0)}let At;function zn(){return At||(At=mi()),At}function mi(){return new S(e=>{if(!L.fetch)return;const{stop:t}=J(L,"fetch",n=>pi(n,e),{computeHandlingStack:!0});return t})}function pi({parameters:e,onPostCall:t,handlingStack:n},r){const[o,s]=e;let i=s&&s.method;i===void 0&&o instanceof Request&&(i=o.method);const c=i!==void 0?String(i).toUpperCase():"GET",a=o instanceof Request?o.url:ot(String(o)),u=x(),d={state:"start",init:s,input:o,method:c,startClocks:u,url:a,handlingStack:n};r.notify(d),e[0]=d.input,e[1]=d.init,t(l=>hi(r,l,d))}function hi(e,t,n){const r=n;function o(s){r.state="resolve",Object.assign(r,s),e.notify(r)}t.then(b(s=>{o({response:s,responseType:s.type,status:s.status,isAborted:!1})}),b(s=>{var i,c;o({status:0,isAborted:((c=(i=r.init)===null||i===void 0?void 0:i.signal)===null||c===void 0?void 0:c.aborted)||s instanceof DOMException&&s.code===DOMException.ABORT_ERR,error:s})}))}let It={};function gi(e){const t=e.map(n=>(It[n]||(It[n]=Ei(n)),It[n]));return Wt(...t)}function Ei(e){return new S(t=>{const n=N[e];return N[e]=(...r)=>{n.apply(console,r);const o=He("console error");ae(()=>{t.notify(yi(r,e,o))})},()=>{N[e]=n}})}function yi(e,t,n){const r=e.map(o=>bi(o)).join(" ");if(t===T.error){const o=e.find(X),s=bt({originalError:o,handlingStack:n,startClocks:x(),source:A.CONSOLE,handling:"handled",nonErrorPrefix:"Provided",useFallbackStack:!1});return s.message=r,{api:t,message:r,handlingStack:n,error:s}}return{api:t,message:r,error:void 0,handlingStack:n}}function bi(e){return typeof e=="string"?P(e):X(e)?bn(de(e)):Oe(P(e),void 0,2)}const Si=500;function _i(){const e=[];return{add:o=>{e.push(o)>Si&&e.splice(0,1)},remove:o=>{Bn(e,o)},drain:o=>{e.forEach(s=>s(o)),e.length=0}}}function Ti(e){const t=hn(e)==="object";return t||y.error("Unsupported context:",e),t}function Rt(e,t,n){const r={...e};for(const[o,{required:s,type:i}]of Object.entries(t))i==="string"&&!Yn(r[o])&&(r[o]=String(r[o])),s&&Yn(r[o])&&y.warn(`The property ${o} of ${n} is required; context will not be sent to the intake.`);return r}function Yn(e){return e==null||e===""}function Ve(e="",{propertiesConfig:t={}}={}){let n={};const r=new S,o={getContext:()=>An(n),setContext:s=>{Ti(s)?n=P(Rt(s,t,e)):o.clearContext(),r.notify()},setContextProperty:(s,i)=>{n=P(Rt({...n,[s]:i},t,e)),r.notify()},removeContextProperty:s=>{delete n[s],Rt(n,t,e),r.notify()},clearContext:()=>{n={},r.notify()},changeObservable:r};return o}function v(e,t,n,r){return b((...o)=>e()[t][n](...o))}function Lt(e,t,n){e.changeObservable.subscribe(()=>{const r=e.getContext();n.add(o=>o[t].setContext(r))})}const Oi="_dd_c",Ci=[];function Nt(e,t,n,r){const o=vi(n,r);Ci.push(Z(e,window,"storage",({key:u})=>{o===u&&i()})),t.changeObservable.subscribe(c);const s=ee(a(),t.getContext());Ie(s)||t.setContext(s);function i(){t.setContext(a())}function c(){localStorage.setItem(o,JSON.stringify(t.getContext()))}function a(){const u=localStorage.getItem(o);return u?JSON.parse(u):{}}}function vi(e,t){return`${Oi}_${e}_${t}`}function wi(e,t,n){const r=Vn();return t.storeContextsAcrossPages&&Nt(t,r,n,4),e.register(0,()=>{const o=r.getContext();return Ie(o)||!o.id?te:{account:o}}),r}function Vn(){return Ve("account",{propertiesConfig:{id:{type:"string",required:!0},name:{type:"string"}}})}function Ai(e,t,n,r){const o=Wn();return t.storeContextsAcrossPages&&Nt(t,o,n,2),e.register(0,()=>o.getContext()),o}function Wn(){return Ve("global context")}function Ii(e,t,n,r){const o=qn();return t.storeContextsAcrossPages&&Nt(t,o,r,1),e.register(0,({eventType:s,startTime:i})=>{const c=o.getContext(),a=n.findTrackedSession(i);return a&&a.anonymousId&&!c.anonymous_id&&t.trackAnonymousUser&&(c.anonymous_id=a.anonymousId),Ie(c)?te:{type:s,usr:c}}),e.register(1,({startTime:s})=>{var i;return{anonymous_id:(i=n.findTrackedSession(s))===null||i===void 0?void 0:i.anonymousId}}),o}function qn(){return Ve("user",{propertiesConfig:{id:{type:"string"},name:{type:"string"},email:{type:"string"}}})}const C={userContext:"userContext",globalContext:"globalContext",accountContext:"accountContext"},w={getContext:"getContext",setContext:"setContext",setContextProperty:"setContextProperty",removeContextProperty:"removeContextProperty",clearContext:"clearContext"};function Ri(e,t,n){const r=e.getReader(),o=[];let s=0;i();function i(){r.read().then(b(a=>{if(a.done){c();return}o.push(a.value),s+=a.value.length,s>n.bytesLimit?c():i()}),b(a=>t(a)))}function c(){r.cancel().catch(F);let a,u;{let d;if(o.length===1)d=o[0];else{d=new Uint8Array(s);let l=0;o.forEach(f=>{d.set(f,l),l+=f.length})}a=d.slice(0,n.bytesLimit),u=d.length>n.bytesLimit}t(void 0,a,u)}}const Jn={XHR:"xhr",FETCH:"fetch"},xt={FETCH:Jn.FETCH,XHR:Jn.XHR},Li=500;function Ni(e=Qo){const t=new qt(Li),n=e().subscribe(r=>{t.notify({type:0,error:r})});return{observable:t,stop:()=>{n.unsubscribe()}}}function We(e,t,n){const r=n.getHandler(),o=Array.isArray(r)?r:[r];return Xn[e]>=Xn[n.getLevel()]&&o.includes(t)}const h={ok:"ok",debug:"debug",info:"info",notice:"notice",warn:"warn",error:"error",critical:"critical",alert:"alert",emerg:"emerg"},Xn={[h.ok]:0,[h.debug]:1,[h.info]:2,[h.notice]:4,[h.warn]:5,[h.error]:6,[h.critical]:7,[h.alert]:8,[h.emerg]:9};function qe(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 xi=function(e,t,n,r){var o=arguments.length,s=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};const we={console:"console",http:"http"},ki=Object.keys(h);class I{constructor(t,n,r=we.http,o=h.debug,s={}){this.handleLogStrategy=t,this.handlerType=r,this.level=o,this.contextManager=Ve("logger"),this.tags=[],this.contextManager.setContext(s),n&&this.contextManager.setContextProperty("logger",{name:n})}logImplementation(t,n,r=h.info,o,s){const i=P(n);let c;if(o!=null){const a=bt({originalError:o,nonErrorPrefix:"Provided",source:A.LOGGER,handling:"handled",startClocks:x()});c=ee({error:qe(a,{includeMessage:!0})},a.context,i)}else c=i;this.handleLogStrategy({message:P(t),context:c,status:r},this,s)}log(t,n,r=h.info,o){let s;We(r,we.http,this)&&(s=He("log")),this.logImplementation(t,n,r,o,s)}setContext(t){this.contextManager.setContext(t)}getContext(){return this.contextManager.getContext()}setContextProperty(t,n){this.contextManager.setContextProperty(t,n)}removeContextProperty(t){this.contextManager.removeContextProperty(t)}clearContext(){this.contextManager.clearContext()}addTag(t,n){this.tags.push(Q(t,n))}removeTagsWithKey(t){const n=vn(t);this.tags=this.tags.filter(r=>r!==n&&!r.startsWith(`${n}:`))}getTags(){return this.tags.slice()}setHandler(t){this.handlerType=t}getHandler(){return this.handlerType}setLevel(t){this.level=t}getLevel(){return this.level}}xi([Er],I.prototype,"logImplementation",null),I.prototype.ok=M(h.ok),I.prototype.debug=M(h.debug),I.prototype.info=M(h.info),I.prototype.notice=M(h.notice),I.prototype.warn=M(h.warn),I.prototype.error=M(h.error),I.prototype.critical=M(h.critical),I.prototype.alert=M(h.alert),I.prototype.emerg=M(h.emerg);function M(e){return function(t,n,r){let o;We(e,we.http,this)&&(o=He("log")),this.logImplementation(t,n,e,r,o)}}function Zn(){return z?{}:{view:{referrer:document.referrer,url:window.location.href}}}const Ui=32*ie;function Pi(e,t){e.usePciIntake===!0&&e.site&&e.site!=="datadoghq.com"&&y.warn("PCI compliance for Logs is only available for Datadog organizations in the US1 site. Default intake will be used.");const n=To(e,t),r=Qn(e.forwardConsoleLogs,ke(T),"Forward Console Logs"),o=Qn(e.forwardReports,ke(Be),"Forward Reports");if(!(!n||!r||!o))return e.forwardErrorsToLogs&&!r.includes(T.error)&&r.push(T.error),{forwardErrorsToLogs:e.forwardErrorsToLogs!==!1,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:Ui,...n}}function Qn(e,t,n){if(e===void 0)return[];if(!(e==="all"||Array.isArray(e)&&e.every(r=>t.includes(r)))){y.error(`${n} should be "all" or an array with allowed values "${t.join('", "')}"`);return}return e==="all"?t:Gs(e)}function Mi(e){const t=Oo(e);return{forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports,use_pci_intake:e.usePciIntake,...t}}function Di(e,t,n){const r=_i(),o=Wn();Lt(o,C.globalContext,r);const s=Vn();Lt(s,C.accountContext,r);const i=qn();Lt(i,C.userContext,r);let c,a;const u=t.observable.subscribe(d);function d(){if(!a||!c||!t.isGranted())return;u.unsubscribe();const l=n(c,a);r.drain(l)}return{init(l,f){if(!l){y.error("Missing configuration");return}if(Co(l.enableExperimentalFeatures),Ke()&&(l=$i(l)),c=l,$s(Mi(l)),a){_n("DD_LOGS",l);return}const p=Pi(l,f);p&&(a=p,zn().subscribe(F),t.tryToInit(p.trackingConsent),d())},get initConfiguration(){return c},globalContext:o,accountContext:s,userContext:i,getInternalContext:F,handleLog(l,f,p,g=e(),O=U()){r.add(_=>_.handleLog(l,f,p,g,O))}}}function $i(e){return{...e,clientToken:"empty"}}function Fi(e){const t=eo(),n=Ni().observable;let r=Di(Zn,t,(c,a)=>{const u=e(a,Zn,t,n);return r=Hi(c,u),u});const o=()=>r,s={},i=new I((...c)=>r.handleLog(...c));return ns({logger:i,init:c=>{const a=new Error().stack;ae(()=>r.init(c,a))},setTrackingConsent:b(c=>{t.update(c),Fs({feature:"set-tracking-consent",tracking_consent:c})}),getGlobalContext:v(o,C.globalContext,w.getContext),setGlobalContext:v(o,C.globalContext,w.setContext),setGlobalContextProperty:v(o,C.globalContext,w.setContextProperty),removeGlobalContextProperty:v(o,C.globalContext,w.removeContextProperty),clearGlobalContext:v(o,C.globalContext,w.clearContext),createLogger:b((c,a={})=>(s[c]=new I((...u)=>r.handleLog(...u),P(c),a.handler,a.level,P(a.context)),s[c])),getLogger:b(c=>s[c]),getInitConfiguration:b(()=>An(r.initConfiguration)),getInternalContext:b(c=>r.getInternalContext(c)),setUser:v(o,C.userContext,w.setContext),getUser:v(o,C.userContext,w.getContext),setUserProperty:v(o,C.userContext,w.setContextProperty),removeUserProperty:v(o,C.userContext,w.removeContextProperty),clearUser:v(o,C.userContext,w.clearContext),setAccount:v(o,C.accountContext,w.setContext),getAccount:v(o,C.accountContext,w.getContext),setAccountProperty:v(o,C.accountContext,w.setContextProperty),removeAccountProperty:v(o,C.accountContext,w.removeContextProperty),clearAccount:v(o,C.accountContext,w.clearContext)})}function Hi(e,t){return{init:n=>{_n("DD_LOGS",n)},initConfiguration:e,...t}}const Bi="logs";function Gi(e,t){const n=ei(e,Bi,r=>er(e,r),t);return{findTrackedSession:(r,o={returnInactive:!1})=>{const s=n.findSession(r,o);return s&&s.trackingType==="1"?{id:s.id,anonymousId:s.anonymousId}:void 0},expireObservable:n.expireObservable}}function Ki(e){const n=er(e)==="1"?{}:void 0;return{findTrackedSession:()=>n,expireObservable:new S}}function er(e,t){return ji(t)?t:be(e.sessionSampleRate)?"1":"0"}function ji(e){return e==="0"||e==="1"}function zi(e,t,n,r,o){const s=ki.concat(["custom"]),i={};s.forEach(c=>{i[c]=ci(c,e.eventRateLimiterThreshold,o)}),t.subscribe(0,({rawLogsEvent:c,messageContext:a=void 0,savedCommonContext:u=void 0,domainContext:d,ddtags:l=[]})=>{var f,p;const g=fr(c.date),O=u||r(),_=n.triggerHook(0,{startTime:g});if(_===he)return;const G=Cn(e),Ee=ee({view:O.view},_,c,a,{ddtags:G.concat(l).join(",")});((f=e.beforeSend)===null||f===void 0?void 0:f.call(e,Ee,d))===!1||Ee.origin!==A.AGENT&&((p=i[Ee.status])!==null&&p!==void 0?p:i.custom).isLimitReached()||t.notify(1,Ee)})}const Yi={[T.log]:h.info,[T.debug]:h.debug,[T.info]:h.info,[T.warn]:h.warn,[T.error]:h.error};function Vi(e,t){const n=gi(e.forwardConsoleLogs).subscribe(r=>{var o;const s={rawLogsEvent:{date:U(),message:r.message,origin:A.CONSOLE,error:r.error&&qe(r.error),status:Yi[r.api]},messageContext:(o=r.error)===null||o===void 0?void 0:o.context,domainContext:{handlingStack:r.handlingStack}};t.notify(0,s)});return{stop:()=>{n.unsubscribe()}}}function Wi(e,t){const n=os(e,e.forwardReports).subscribe(r=>{let o=r.message,s;const i=r.originalError.type==="deprecation"?h.warn:h.error;i===h.error?s=qe(r):r.stack&&(o+=` Found in ${Xo(r.stack)}`),t.notify(0,{rawLogsEvent:{date:U(),message:o,origin:A.REPORT,error:s,status:i}})});return{stop:()=>{n.unsubscribe()}}}function qi(e,t){if(!e.forwardErrorsToLogs)return{stop:F};const n=(z?new S:ai(e)).subscribe(s=>{s.state==="complete"&&o(xt.XHR,s)}),r=zn().subscribe(s=>{s.state==="resolve"&&o(xt.FETCH,s)});function o(s,i){!So(i.url)&&(Qi(i)||In(i.status))&&("xhr"in i?Ji(i.xhr,e,c):i.response?Zi(i.response,e,c):i.error&&Xi(i.error,e,c));function c(a){const u={isAborted:i.isAborted,handlingStack:i.handlingStack};t.notify(0,{rawLogsEvent:{message:`${ec(s)} error ${i.method} ${i.url}`,date:i.startClocks.timeStamp,error:{stack:a||"Failed to load",handling:void 0},http:{method:i.method,status_code:i.status,url:i.url},status:h.error,origin:A.NETWORK},domainContext:u})}}return{stop:()=>{n.unsubscribe(),r.unsubscribe()}}}function Ji(e,t,n){typeof e.response=="string"?n(kt(e.response,t)):n(e.response)}function Xi(e,t,n){n(kt(me(de(e)),t))}function Zi(e,t,n){const r=ps(e);!r||!r.body?n():window.TextDecoder?tc(r.body,t.requestErrorResponseLengthLimit,(o,s)=>{n(o?`Unable to retrieve response: ${o}`:s)}):r.text().then(b(o=>n(kt(o,t))),b(o=>n(`Unable to retrieve response: ${o}`)))}function Qi(e){return e.status===0&&e.responseType!=="opaque"}function kt(e,t){return e.length>t.requestErrorResponseLengthLimit?`${e.substring(0,t.requestErrorResponseLengthLimit)}...`:e}function ec(e){return xt.XHR===e?"XHR":"Fetch"}function tc(e,t,n){Ri(e,(r,o,s)=>{if(r)n(r);else{let i=new TextDecoder().decode(o);s&&(i+="..."),n(void 0,i)}},{bytesLimit:t})}function nc(e,t,n){if(!e.forwardErrorsToLogs)return{stop:F};const r=n.subscribe(o=>{if(o.type===0){const s=o.error;t.notify(0,{rawLogsEvent:{message:s.message,date:s.startClocks.timeStamp,error:qe(s),origin:A.SOURCE,status:h.error},messageContext:s.context})}});return{stop:()=>{r.unsubscribe()}}}const rc=ii;function oc(e){function t(n,r,o,s,i){const c=ee(r.getContext(),n.context);if(We(n.status,we.console,r)&&ic(n,c),We(n.status,we.http,r)){const a={rawLogsEvent:{date:i||U(),message:n.message,status:n.status,origin:A.LOGGER},messageContext:c,savedCommonContext:s,ddtags:r.getTags()};o&&(a.domainContext={handlingStack:o}),e.notify(0,a)}}return{handleLog:t}}const sc={[h.ok]:T.debug,[h.debug]:T.debug,[h.info]:T.info,[h.notice]:T.info,[h.warn]:T.warn,[h.error]:T.error,[h.critical]:T.error,[h.alert]:T.error,[h.emerg]:T.error};function ic({status:e,message:t},n){j[sc[e]].call(N,t,n)}function cc(e,t,n,r,o){const s=[e.logsEndpointBuilder];e.replica&&s.push(e.replica.logsEndpointBuilder);const i=$n({encoder:jn(),request:Mn(s,e.batchBytesLimit,n),flushController:Hn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageMayExitObservable:r,sessionExpireObservable:o.expireObservable}),messageBytesLimit:e.messageBytesLimit});return t.subscribe(1,c=>{i.add(c)}),i}function ac(e){const t=Tt();e.subscribe(1,n=>{t.send("log",n)})}function uc(e){return{get:t=>{const n=e.findTrackedSession(t);if(n)return{session_id:n.id}}}}function lc(e){return t=>{e.notify(0,{rawLogsEvent:{message:t.message,date:t.startClocks.timeStamp,origin:A.AGENT,status:h.error}}),Ct("Error reported to customer",{"error.message":t.message})}}const dc=Is;function fc(e){const t=L;e.register(0,({startTime:o})=>{const s=n(o);return s||te}),e.register(1,({startTime:o})=>{var s,i;const c=n(o);return c?{application:{id:c.application_id},view:{id:(s=c.view)===null||s===void 0?void 0:s.id},action:{id:(i=c.user_action)===null||i===void 0?void 0:i.id}}:te});function n(o){const i=Gn()?t.DD_RUM_SYNTHETICS:t.DD_RUM,c=r(o,i);if(c)return c}function r(o,s){if(s&&s.getInternalContext)return s.getInternalContext(o)}}function mc(e,t,n){e.register(0,({startTime:r})=>{const o=n.findTrackedSession(r);return n.findTrackedSession(r,{returnInactive:!0})?{service:t.service,session_id:o?o.id:void 0,session:o?{id:o.id}:void 0}:he}),e.register(1,({startTime:r})=>{const o=n.findTrackedSession(r);return!o||!o.id?te:{session:{id:o.id}}})}function pc(e,t){function n(){return t.isGranted()?te:he}e.register(0,n),e.register(1,n)}const Ut="logs";function hc(e,t,n,r){const o=new rc,s=dc(),i=[];o.subscribe(1,_=>wn("logs",_));const c=lc(o),a=z?new S:ws(e),u=xs("browser-logs-sdk",e,s,c,a,jn);i.push(u.stop);const d=e.sessionStoreStrategyType&&!Ke()&&!Gn()?Gi(e,n):Ki(e);pc(s,n),mc(s,e,d);const l=wi(s,e,Ut),f=Ii(s,e,d,Ut),p=Ai(s,e,Ut);fc(s),qi(e,o),nc(e,o,r),r.unbuffer(),Vi(e,o),Wi(e,o);const{handleLog:g}=oc(o);if(zi(e,o,s,t,c),Ke())ac(o);else{const{stop:_}=cc(e,o,c,a,d);i.push(()=>_())}const O=uc(d);return{handleLog:g,getInternalContext:O.get,accountContext:l,globalContext:p,userContext:f,stop:()=>{i.forEach(_=>_())}}}const Je=Fi(hc);rs(R(),"DD_LOGS",Je),m.Environment=void 0,function(e){e.DEVELOPMENT="development",e.PRODUCTION="production",e.SANDBOX="sandbox",e.PRELIVE_SANDBOX="prelive-sandbox",e.PRELIVE_PRODUCTION="prelive-production"}(m.Environment||(m.Environment={}));class ge{constructor(){this.initialized=!1,this.configService=K.instance}static get instance(){return ge._instance||(ge._instance=new ge),ge._instance}initialize(t,n){if(this.initialized){try{Je.setGlobalContextProperty("sessionUuid",n),console.log("MONTONIO-JS: LoggingService: Session UUID updated:",n)}catch(r){console.error("MONTONIO-JS: LoggingService: Error updating sessionUuid:",r)}return}try{const r=this.configService.getConfig("datadogClientToken");Je.init({clientToken:r,site:"datadoghq.eu",env:t===m.Environment.PRODUCTION?"live-production":"live-sandbox",forwardErrorsToLogs:!0,service:"montonio-js",version:"1.1.0",silentMultipleInit:!0,forwardConsoleLogs:"all"}),Je.setGlobalContext({sessionUuid:n}),this.initialized=!0}catch(r){console.error("MONTONIO-JS: LoggingService: Error initializing Datadog Logs:",r)}}}class tr{constructor(t){var n;this.defaultStyles={border:"none",display:"block",width:"100%",height:"100%"},this.options=t,this.resizeOnHeightChange=(n=t.resizeOnHeightChange)!==null&&n!==void 0?n:!0,this.element=document.createElement("iframe"),this.messagingService=new Mt,this.setupIframe()}mount(){return this.options.mountElement.appendChild(this.element),this.resizeOnHeightChange&&this.startResizing(this.element),this.element}unmount(){this.element.contentWindow&&this.messagingService.clearAllSubscriptions(),this.element.parentNode&&this.element.parentNode.removeChild(this.element)}getContentWindow(){if(!this.element.contentWindow)throw new Error("Iframe contentWindow is not available. Make sure the iframe is mounted and loaded.");return this.element.contentWindow}startResizing(t){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_HEIGHT_CHANGED,n=>{t.style.height=n.payload.height+"px"},this)}setupIframe(){const{src:t,allow:n="camera; microphone; geolocation; payment",styles:r={}}=this.options;this.element.src=t,this.element.allow=n;const o={...this.defaultStyles,...r};Object.assign(this.element.style,o)}}class nr{constructor(){this.loaded=!1,this.mountElement=null,this._iframe=null,this.messagingService=new Mt,this.httpService=oe.instance,this.configService=K.instance}get iframe(){if(!this._iframe)throw new Error("Iframe not initialized");return this._iframe}set iframe(t){this._iframe=t}cleanup(){this.iframe&&(this.iframe.unmount(),this.iframe=null)}}function gc(e){if(typeof e=="string"){const t=document.querySelector(e);if(!t||!(t instanceof HTMLElement))throw new Error(`Element not found: ${e}`);return t}return e}function Ec(){const e=document.body.style.overflow||null;return document.body.style.overflow="hidden",{originalOverflow:e}}function yc(e){e?document.body.style.overflow=e:document.body.style.removeProperty("overflow")}m.LocaleEnum=void 0,function(e){e.EN="en",e.ET="et",e.LT="lt",e.LV="lv",e.PL="pl",e.RU="ru",e.FI="fi"}(m.LocaleEnum||(m.LocaleEnum={}));var rr;(function(e){e.PENDING="PENDING",e.AUTHORIZED="AUTHORIZED",e.PAID="PAID",e.PARTIALLY_REFUNDED="PARTIALLY_REFUNDED",e.REFUNDED="REFUNDED",e.VOIDED="VOIDED",e.ABANDONED="ABANDONED"})(rr||(rr={}));const bc=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Sc(e){const t=[];if(!e)throw new Xe(["CheckoutOptions object is required"]);if(e.sessionUuid===void 0||e.sessionUuid===null?t.push("sessionUuid is required"):typeof e.sessionUuid!="string"?t.push("sessionUuid must be a string"):bc.test(e.sessionUuid)||t.push(`sessionUuid must be a valid UUID format. Received: '${e.sessionUuid}'`),e.onSuccess?typeof e.onSuccess!="function"&&t.push("onSuccess must be a function"):t.push("onSuccess callback is required"),e.onError?typeof e.onError!="function"&&t.push("onError must be a function"):t.push("onError callback is required"),e.locale!==void 0&&e.locale!==null){const n=Object.values(m.LocaleEnum);n.includes(e.locale)||t.push(`locale must be one of: ${n.join(", ")}. Received: '${e.locale}'`)}if(e.environment!==void 0&&e.environment!==null&&(Object.values(m.Environment).includes(e.environment)||t.push(`environment must be one of: production, sandbox. Received: '${e.environment}'`)),t.length>0)throw new Xe(t)}function _c(e){const t=[];if(e.locale!==void 0&&e.locale!==null){const n=Object.values(m.LocaleEnum);n.includes(e.locale)||t.push(`locale must be one of: ${n.join(", ")}. Received: '${e.locale}'`)}if(t.length>0)throw new Xe(t)}class Tc extends nr{constructor(t){super(),this.originalBodyOverflow=null,this.options=t,this.mountElement=t.mountElement||document.body}async initialize(){try{if(this.options.paymentAuthData.type==="redirect"){await this.redirectViaPost(this.options.paymentAuthData);return}if(!this.options.paymentAuthData.embeddedUrl)throw new Error("Embedded URL is not set in paymentAuthData");const{originalOverflow:t}=Ec();this.originalBodyOverflow=t,this.iframe=new tr({src:this.options.paymentAuthData.embeddedUrl,mountElement:this.mountElement,styles:{width:"100dvw",height:"100dvh",position:"fixed",top:"0",left:"0",zIndex:"2147483647"},resizeOnHeightChange:!1}),this.iframe.mount(),await this.messagingService.waitForMessage(m.MessageTypeEnum.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY,this.iframe),this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_SEND_PAYMENT_AUTH_DATA,payload:{paymentAuthData:this.options.paymentAuthData}}),this.loaded=!0}catch(t){throw this.cleanup(),t}}cleanup(){this.loaded&&yc(this.originalBodyOverflow),super.cleanup()}async redirectViaPost(t){if(!t.redirectUrl)throw new Error("Redirect URL is not set in paymentAuthData");const n=document.createElement("form");if(n.method=t.redirectMethod||"get",n.action=t.redirectUrl,n.style.display="none",t.formData)for(const[r,o]of Object.entries(t.formData)){const s=document.createElement("input");s.type="hidden",s.name=r,s.value=o,n.appendChild(s)}throw document.body.appendChild(n),n.submit(),await new Promise(r=>setTimeout(r,3e4)),new Error("Redirect timeout: Expected redirect to occur within 30 seconds")}}class Oc extends nr{constructor(t){super(),this.isValid=!1,this.paymentAuth=null,this.options=t,this.environment=t.environment||m.Environment.PRODUCTION,ge.instance.initialize(this.environment,this.options.sessionUuid),console.log("MONTONIO-JS: MontonioCheckout: class created with options:",t),Sc(t)}async initialize(t){try{console.log("MONTONIO-JS: initialize: Initializing MontonioCheckout with mountTo:",t),this.mountElement=gc(t);const n=await this.fetchSession();return this.iframe=new tr({src:n.url,mountElement:this.mountElement}),this.iframe.mount(),await this.messagingService.waitForMessage(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPONENT_READY,this.iframe),this.setUpListeners(),this.loaded=!0,console.log("MONTONIO-JS: initialize: MontonioCheckout initialized successfully"),!0}catch(n){throw console.error("MONTONIO-JS: initialize: Error initializing MontonioCheckout:",n),this.cleanup(),n}}updateOptions(t){if(console.log("MONTONIO-JS: updateOptions: Updating options to:",t),!this.loaded)throw new re;_c(t),t.locale!==void 0&&(this.options.locale=t.locale,this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_CHANGE_LOCALE,payload:{locale:t.locale}}))}validateOrReject(){if(console.log("MONTONIO-JS: validateOrReject: Called validateOrReject, isValid:",this.isValid),!this.isValid)throw this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_VALIDATE_FIELDS}),new Pt}submitPayment(){if(!this.loaded)throw new re;this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_SUBMIT_PAYMENT})}async fetchSession(){const n=`${this.configService.getConfig("stargateUrl",this.environment)}/api/sessions/${this.options.sessionUuid}/gateway-url${this.options.locale?`?preferredLocale=${this.options.locale}`:""}`;return console.log("MONTONIO-JS: fetchSession: Fetching iframe URL from:",n),await this.httpService.get(n)}setUpListeners(){console.log("MONTONIO-JS: setUpListeners: Setting up listeners"),this.setUpFormChangeListener(),this.setUpPaymentCompletedListener(),this.setUpPaymentFailedListener(),this.setUpValidationListener(),this.setUpPaymentAuthListener()}setUpFormChangeListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_PAYMENT_FORM_CHANGED,t=>{this.isValid=t.payload.isValid},this.iframe)}setUpPaymentCompletedListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,async t=>{console.log("MONTONIO-JS: CHECKOUT_PAYMENT_COMPLETED (from main iframe)",t),this.cleanupPaymentAuth();try{const n=await this.getPaymentResult(t.payload.paymentIntentUuid);this.handlePaymentSuccess(n)}catch(n){this.handlePaymentError(n)}},this.iframe)}setUpPaymentFailedListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,t=>{console.error("MONTONIO-JS: CHECKOUT_PAYMENT_FAILED (from main iframe)",t),this.cleanupPaymentAuth(),this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_SEND_PAYMENT_FAILED_DATA,payload:t.payload}),this.handlePaymentError(new or(t.payload))},this.iframe)}setUpValidationListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_VALIDATE_FIELDS_RESULT,t=>{console.log("MONTONIO-JS: CHECKOUT_VALIDATE_FIELDS_RESULT",t),t.payload.isValid||this.handlePaymentError(new Pt)},this.iframe)}setUpPaymentAuthListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_START_PAYMENT_AUTH,async t=>{try{console.log("MONTONIO-JS: PAYMENT_AUTH_STARTED",t),this.paymentAuth=new Tc({paymentAuthData:t.payload.paymentAuthData}),await this.paymentAuth.initialize();const n=this.paymentAuth.iframe;this.messagingService.addIframeToSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,n),this.messagingService.addIframeToSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,n)}catch(n){this.handlePaymentError(n)}},this.iframe)}async getPaymentResult(t){const r=`${this.configService.getConfig("stargateUrl",this.environment)}/api/payment-intents/${t}/return-url`,o=10,s=1e3;let i=0;for(;i<o;){try{console.log("MONTONIO-JS: getPaymentResult: Fetching return URL from:",r);const c=await this.httpService.get(r);if(i++,c!=null&&c.merchantReturnUrl)return{returnUrl:c.merchantReturnUrl,orderToken:c.orderToken,paymentStatus:c.paymentStatus}}catch(c){console.error("MONTONIO-JS: getPaymentResult: Error fetching return URL:",c)}i<o&&await new Promise(c=>setTimeout(c,s))}throw new sr({attempts:i})}cleanupPaymentAuth(){this.paymentAuth&&(this.messagingService.removeIframeFromSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,this.paymentAuth.iframe),this.messagingService.removeIframeFromSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,this.paymentAuth.iframe),this.paymentAuth.cleanup(),this.paymentAuth=null)}handlePaymentSuccess(t){this.options.onSuccess(t),console.log("MONTONIO-JS: handlePaymentSuccess: onSuccess callback called with result:",t)}handlePaymentError(t){this.options.onError(t),console.error("MONTONIO-JS: handlePaymentError: onError callback called with error:",t)}}m.MontonioCheckout=Oc,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
14
14
|
//# sourceMappingURL=montonio.umd.js.map
|