@safaricom-mxl/web-sdk 0.0.2 → 0.0.3
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/mxl-web-sdk.js +1 -1
- package/dist/mxl-web-sdk.js.map +1 -1
- package/dist/resources/constants/index.cjs +1 -1
- package/dist/resources/constants/index.cjs.map +1 -1
- package/dist/resources/constants/index.d.cts +1 -1
- package/dist/resources/constants/index.d.ts +1 -1
- package/dist/resources/constants/index.js +1 -1
- package/dist/resources/constants/index.js.map +1 -1
- package/dist/sdk/utils.cjs +0 -1
- package/dist/sdk/utils.cjs.map +1 -1
- package/dist/sdk/utils.d.cts.map +1 -1
- package/dist/sdk/utils.d.ts.map +1 -1
- package/dist/sdk/utils.js +0 -1
- package/dist/sdk/utils.js.map +1 -1
- package/package.json +2 -2
package/dist/mxl-web-sdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";window.MXLWebSdk=window.MXLWebSdk||(function(e){var t=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},n=`1.9.0`,r=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function i(e){var t=new Set([e]),n=new Set,i=e.match(r);if(!i)return function(){return!1};var a={major:+i[1],minor:+i[2],patch:+i[3],prerelease:i[4]};if(a.prerelease!=null)return function(t){return t===e};function o(e){return n.add(e),!1}function s(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;var i=e.match(r);if(!i)return o(e);var c={major:+i[1],minor:+i[2],patch:+i[3],prerelease:i[4]};return c.prerelease!=null||a.major!==c.major?o(e):a.major===0?a.minor===c.minor&&a.patch<=c.patch?s(e):o(e):a.minor<=c.minor?s(e):o(e)}}var a=i(n),o=n.split(`.`)[0],s=Symbol.for(`opentelemetry.js.api.`+o),c=t;function l(e,t,r,i){var a;i===void 0&&(i=!1);var o=c[s]=(a=c[s])==null?{version:n}:a;if(!i&&o[e]){var l=Error(`@opentelemetry/api: Attempted duplicate registration of API: `+e);return r.error(l.stack||l.message),!1}if(o.version!==n){var l=Error(`@opentelemetry/api: Registration of version v`+o.version+` for `+e+` does not match previously registered API v`+n);return r.error(l.stack||l.message),!1}return o[e]=t,r.debug(`@opentelemetry/api: Registered a global for `+e+` v`+n+`.`),!0}function u(e){var t,n,r=(t=c[s])==null?void 0:t.version;if(!(!r||!a(r)))return(n=c[s])==null?void 0:n[e]}function d(e,t){t.debug(`@opentelemetry/api: Unregistering a global for `+e+` v`+n+`.`);var r=c[s];r&&delete r[e]}var f=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},p=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},ee=function(){function e(e){this._namespace=e.namespace||`DiagComponentLogger`}return e.prototype.debug=function(){var e=[...arguments];return m(`debug`,this._namespace,e)},e.prototype.error=function(){var e=[...arguments];return m(`error`,this._namespace,e)},e.prototype.info=function(){var e=[...arguments];return m(`info`,this._namespace,e)},e.prototype.warn=function(){var e=[...arguments];return m(`warn`,this._namespace,e)},e.prototype.verbose=function(){var e=[...arguments];return m(`verbose`,this._namespace,e)},e}();function m(e,t,n){var r=u(`diag`);if(r)return n.unshift(t),r[e].apply(r,p([],f(n),!1))}var h;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(h||(h={}));function te(e,t){e<h.NONE?e=h.NONE:e>h.ALL&&(e=h.ALL),t=t||{};function n(n,r){var i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,h.ERROR),warn:n(`warn`,h.WARN),info:n(`info`,h.INFO),debug:n(`debug`,h.DEBUG),verbose:n(`verbose`,h.VERBOSE)}}var g=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},ne=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},re=`diag`,_=function(){function e(){function e(e){return function(){var t=[...arguments],n=u(`diag`);if(n)return n[e].apply(n,ne([],g(t),!1))}}var t=this;t.setLogger=function(e,n){var r,i,a;if(n===void 0&&(n={logLevel:h.INFO}),e===t){var o=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error((r=o.stack)==null?o.message:r),!1}typeof n==`number`&&(n={logLevel:n});var s=u(`diag`),c=te((i=n.logLevel)==null?h.INFO:i,e);if(s&&!n.suppressOverrideMessage){var d=(a=Error().stack)==null?`<failed to generate stacktrace>`:a;s.warn(`Current logger will be overwritten from `+d),c.warn(`Current logger will overwrite one already registered from `+d)}return l(`diag`,c,t,!0)},t.disable=function(){d(re,t)},t.createComponentLogger=function(e){return new ee(e)},t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e}(),ie=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},ae=function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)},oe=function(){function e(e){this._entries=e?new Map(e):new Map}return e.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},e.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=ie(e,2);return[t[0],t[1]]})},e.prototype.setEntry=function(t,n){var r=new e(this._entries);return r._entries.set(t,n),r},e.prototype.removeEntry=function(t){var n=new e(this._entries);return n._entries.delete(t),n},e.prototype.removeEntries=function(){for(var t,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=new e(this._entries);try{for(var o=ae(r),s=o.next();!s.done;s=o.next()){var c=s.value;a._entries.delete(c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},e.prototype.clear=function(){return new e},e}(),se=Symbol(`BaggageEntryMetadata`),v=_.instance();function ce(e){return e===void 0&&(e={}),new oe(new Map(Object.entries(e)))}function le(e){return typeof e!=`string`&&(v.error(`Cannot create baggage metadata from unknown type: `+typeof e),e=``),{__TYPE__:se,toString:function(){return e}}}function ue(e){return Symbol.for(e)}var y=new(function(){function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(e){return n._currentContext.get(e)},n.setValue=function(t,r){var i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=function(t){var r=new e(n._currentContext);return r._currentContext.delete(t),r}}return e}()),de=[{n:`error`,c:`error`},{n:`warn`,c:`warn`},{n:`info`,c:`info`},{n:`debug`,c:`debug`},{n:`verbose`,c:`trace`}],fe=function(){function e(){function e(e){return function(){var t=[...arguments];if(console){var n=console[e];if(typeof n!=`function`&&(n=console.log),typeof n==`function`)return n.apply(console,t)}}}for(var t=0;t<de.length;t++)this[de[t].n]=e(de[t].c)}return e}(),b=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),pe=function(){function e(){}return e.prototype.createGauge=function(e,t){return Ce},e.prototype.createHistogram=function(e,t){return we},e.prototype.createCounter=function(e,t){return Se},e.prototype.createUpDownCounter=function(e,t){return Te},e.prototype.createObservableGauge=function(e,t){return De},e.prototype.createObservableCounter=function(e,t){return Ee},e.prototype.createObservableUpDownCounter=function(e,t){return Oe},e.prototype.addBatchObservableCallback=function(e,t){},e.prototype.removeBatchObservableCallback=function(e){},e}(),x=function(){function e(){}return e}(),me=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.add=function(e,t){},t}(x),he=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.add=function(e,t){},t}(x),ge=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.record=function(e,t){},t}(x),_e=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.record=function(e,t){},t}(x),ve=function(){function e(){}return e.prototype.addCallback=function(e){},e.prototype.removeCallback=function(e){},e}(),ye=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(ve),be=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(ve),S=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(ve),xe=new pe,Se=new me,Ce=new ge,we=new _e,Te=new he,Ee=new ye,De=new be,Oe=new S,ke={get:function(e,t){if(e!=null)return e[t]},keys:function(e){return e==null?[]:Object.keys(e)}},Ae={set:function(e,t,n){e!=null&&(e[t]=n)}},je=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Me=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},Ne=function(){function e(){}return e.prototype.active=function(){return y},e.prototype.with=function(e,t,n){var r=[...arguments].slice(3);return t.call.apply(t,Me([n],je(r),!1))},e.prototype.bind=function(e,t){return t},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}(),Pe=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Fe=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},Ie=`context`,Le=new Ne,Re=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(e){return l(Ie,e,_.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(e,t,n){for(var r,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(r=this._getContextManager()).with.apply(r,Fe([e,t,n],Pe(i),!1))},e.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},e.prototype._getContextManager=function(){return u(Ie)||Le},e.prototype.disable=function(){this._getContextManager().disable(),d(Ie,_.instance())},e}(),C;(function(e){e[e.NONE=0]=`NONE`,e[e.SAMPLED=1]=`SAMPLED`})(C||(C={}));var ze=`0000000000000000`,Be=`00000000000000000000000000000000`,Ve={traceId:Be,spanId:ze,traceFlags:C.NONE},He=function(){function e(e){e===void 0&&(e=Ve),this._spanContext=e}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(e,t){return this},e.prototype.setAttributes=function(e){return this},e.prototype.addEvent=function(e,t){return this},e.prototype.addLink=function(e){return this},e.prototype.addLinks=function(e){return this},e.prototype.setStatus=function(e){return this},e.prototype.updateName=function(e){return this},e.prototype.end=function(e){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(e,t){},e}(),Ue=ue(`OpenTelemetry Context Key SPAN`);function We(e){return e.getValue(Ue)||void 0}function Ge(){return We(Re.getInstance().active())}function Ke(e,t){return e.setValue(Ue,t)}function qe(e){return e.deleteValue(Ue)}function Je(e,t){return Ke(e,new He(t))}function Ye(e){var t;return(t=We(e))==null?void 0:t.spanContext()}var Xe=/^([0-9a-f]{32})$/i,Ze=/^[0-9a-f]{16}$/i;function Qe(e){return Xe.test(e)&&e!==Be}function $e(e){return Ze.test(e)&&e!==ze}function et(e){return Qe(e.traceId)&&$e(e.spanId)}function tt(e){return new He(e)}var nt=Re.getInstance(),rt=function(){function e(){}return e.prototype.startSpan=function(e,t,n){if(n===void 0&&(n=nt.active()),t!=null&&t.root)return new He;var r=n&&Ye(n);return it(r)&&et(r)?new He(r):new He},e.prototype.startActiveSpan=function(e,t,n,r){var i,a,o;if(!(arguments.length<2)){arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);var s=a==null?nt.active():a,c=this.startSpan(e,i,s),l=Ke(s,c);return nt.with(l,o,void 0,c)}},e}();function it(e){return typeof e==`object`&&typeof e.spanId==`string`&&typeof e.traceId==`string`&&typeof e.traceFlags==`number`}var at=new rt,ot=function(){function e(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}return e.prototype.startSpan=function(e,t,n){return this._getTracer().startSpan(e,t,n)},e.prototype.startActiveSpan=function(e,t,n,r){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):at},e}(),st=new(function(){function e(){}return e.prototype.getTracer=function(e,t,n){return new rt},e}()),ct=function(){function e(){}return e.prototype.getTracer=function(e,t,n){var r;return(r=this.getDelegateTracer(e,t,n))==null?new ot(this,e,t,n):r},e.prototype.getDelegate=function(){var e;return(e=this._delegate)==null?st:e},e.prototype.setDelegate=function(e){this._delegate=e},e.prototype.getDelegateTracer=function(e,t,n){var r;return(r=this._delegate)==null?void 0:r.getTracer(e,t,n)},e}(),lt;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(lt||(lt={}));var ut;(function(e){e[e.INTERNAL=0]=`INTERNAL`,e[e.SERVER=1]=`SERVER`,e[e.CLIENT=2]=`CLIENT`,e[e.PRODUCER=3]=`PRODUCER`,e[e.CONSUMER=4]=`CONSUMER`})(ut||(ut={}));var dt;(function(e){e[e.UNSET=0]=`UNSET`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`})(dt||(dt={}));var w=Re.getInstance(),T=_.instance(),ft=new(function(){function e(){}return e.prototype.getMeter=function(e,t,n){return xe},e}()),pt=`metrics`,mt=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalMeterProvider=function(e){return l(pt,e,_.instance())},e.prototype.getMeterProvider=function(){return u(pt)||ft},e.prototype.getMeter=function(e,t,n){return this.getMeterProvider().getMeter(e,t,n)},e.prototype.disable=function(){d(pt,_.instance())},e}().getInstance(),ht=function(){function e(){}return e.prototype.inject=function(e,t){},e.prototype.extract=function(e,t){return e},e.prototype.fields=function(){return[]},e}(),gt=ue(`OpenTelemetry Baggage Key`);function _t(e){return e.getValue(gt)||void 0}function vt(){return _t(Re.getInstance().active())}function yt(e,t){return e.setValue(gt,t)}function bt(e){return e.deleteValue(gt)}var xt=`propagation`,St=new ht,E=function(){function e(){this.createBaggage=ce,this.getBaggage=_t,this.getActiveBaggage=vt,this.setBaggage=yt,this.deleteBaggage=bt}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalPropagator=function(e){return l(xt,e,_.instance())},e.prototype.inject=function(e,t,n){return n===void 0&&(n=Ae),this._getGlobalPropagator().inject(e,t,n)},e.prototype.extract=function(e,t,n){return n===void 0&&(n=ke),this._getGlobalPropagator().extract(e,t,n)},e.prototype.fields=function(){return this._getGlobalPropagator().fields()},e.prototype.disable=function(){d(xt,_.instance())},e.prototype._getGlobalPropagator=function(){return u(xt)||St},e}().getInstance(),Ct=`trace`,D=function(){function e(){this._proxyTracerProvider=new ct,this.wrapSpanContext=tt,this.isSpanContextValid=et,this.deleteSpan=qe,this.getSpan=We,this.getActiveSpan=Ge,this.getSpanContext=Ye,this.setSpan=Ke,this.setSpanContext=Je}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(e){var t=l(Ct,this._proxyTracerProvider,_.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},e.prototype.getTracerProvider=function(){return u(Ct)||this._proxyTracerProvider},e.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},e.prototype.disable=function(){d(Ct,_.instance()),this._proxyTracerProvider=new ct},e}().getInstance();let wt=({target:e,events:t,callback:n})=>{t.forEach(t=>{e.addEventListener(t,n)})},Tt=({target:e,events:t,callback:n})=>{t.forEach(t=>{e.removeEventListener(t,n)})};function Et(e,t,n,r=new Set){return new Proxy(e,{get(e,i,a){let o=Reflect.get(e,i,a);return typeof o!=`function`||r.has(i)?o:(...r)=>{try{return o.apply(e,r)}catch(e){let a=e instanceof Error?e.message:`Unknown error`;n.error(`${String(i)}: ${a}`);let o=t[i];return typeof o==`function`?o.apply(t,r):void 0}}}})}let Dt=new Uint8Array(16),Ot=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`).toUpperCase()),kt=()=>{crypto.getRandomValues(Dt);let e=``;for(let t=0;t<16;t++)e+=Ot[Dt[t]];return e},At=(e,t,n)=>{try{let n=e.getItem(t),r=n?parseInt(n,10):0;return r++,e.setItem(t,r.toString()),r}catch(e){return n.warn(`Failed to retrieve ${t} from storage: `,e),1}},O=`mxl.type`,jt=`mxl.state`,Mt=`mxl.properties.`,Nt=`mxl.js_file_bundle_ids`,Pt=`app.surface.name`,Ft=`app.surface.id`,k=function(e){return e.Session=`ux.session`,e.Network=`perf.network_request`,e.Perf=`perf`,e.SystemLog=`sys.log`,e.SystemException=`sys.exception`,e.WebVital=`ux.web_vital`,e.ResourceFetch=`ux.resource_fetch`,e.DocumentLoad=`ux.document_load`,e.Surface=`ux.surface`,e}({}),It=function(e){return e.Foreground=`foreground`,e.Background=`background`,e}({}),Lt=function(e){return e.DeclarativeLegacy=`react_router_declarative_legacy`,e.Declarative=`react_router_declarative`,e.Data=`react_router_data`,e.Manual=`manual`,e}({}),Rt=e=>e.visibilityState===`hidden`?It.Background:It.Foreground,zt=globalThis,Bt=(e,t)=>!t||t<=0||t>100?!1:t>=Vt(e),Vt=e=>{if(e.length<6)return 0;let t=e.slice(-6),n=Math.pow(16,6)-1;return parseInt(t,16)/n*100},Ht=ue(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`);function Ut(e){return e.setValue(Ht,!0)}function Wt(e){return e.getValue(Ht)===!0}let Gt=`baggage`;function Kt(e){return e.reduce((e,t)=>{let n=`${e}${e===``?``:`,`}${t}`;return n.length>8192?e:n},``)}function qt(e){return e.getAllEntries().map(([e,t])=>{let n=`${encodeURIComponent(e)}=${encodeURIComponent(t.value)}`;return t.metadata!==void 0&&(n+=`;`+t.metadata.toString()),n})}function Jt(e){if(!e)return;let t=e.indexOf(`;`),n=t===-1?e:e.substring(0,t),r=n.indexOf(`=`);if(r<=0)return;let i=n.substring(0,r).trim(),a=n.substring(r+1).trim();if(!i||!a)return;let o,s;try{o=decodeURIComponent(i),s=decodeURIComponent(a)}catch(e){return}let c;return t!==-1&&t<e.length-1&&(c=le(e.substring(t+1))),{key:o,value:s,metadata:c}}var Yt=class{inject(e,t,n){let r=E.getBaggage(e);if(!r||Wt(e))return;let i=Kt(qt(r).filter(e=>e.length<=4096).slice(0,180));i.length>0&&n.set(t,Gt,i)}extract(e,t,n){let r=n.get(t,Gt),i=Array.isArray(r)?r.join(`,`):r;if(!i)return e;let a={};return i.length===0||(i.split(`,`).forEach(e=>{let t=Jt(e);if(t){let e={value:t.value};t.metadata&&(e.metadata=t.metadata),a[t.key]=e}}),Object.entries(a).length===0)?e:E.setBaggage(e,E.createBaggage(a))}fields(){return[Gt]}};function Xt(e){"@babel/helpers - typeof";return Xt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Xt(e)}function Zt(e,t){if(Xt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Xt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Qt(e){var t=Zt(e,`string`);return Xt(t)==`symbol`?t:t+``}function A(e,t,n){return(t=Qt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $t(e){let t={};if(typeof e!=`object`||!e)return t;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!en(n)){T.warn(`Invalid attribute key: ${n}`);continue}let r=e[n];if(!tn(r)){T.warn(`Invalid attribute value set for key: ${n}`);continue}Array.isArray(r)?t[n]=r.slice():t[n]=r}return t}function en(e){return typeof e==`string`&&e!==``}function tn(e){return e==null?!0:Array.isArray(e)?nn(e):rn(typeof e)}function nn(e){let t;for(let n of e){if(n==null)continue;let e=typeof n;if(e!==t){if(!t){if(rn(e)){t=e;continue}return!1}return!1}}return!0}function rn(e){switch(e){case`number`:case`boolean`:case`string`:return!0}return!1}function an(){return e=>{T.error(on(e))}}function on(e){return typeof e==`string`?e:JSON.stringify(sn(e))}function sn(e){let t={},n=e;for(;n!==null;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;let r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}let cn=an();function ln(e){cn=e}function j(e){try{cn(e)}catch(e){}}let un=`http.method`,dn=`http.url`,fn=`http.status_code`,pn=`error.type`,mn=`exception.message`,hn=`exception.stacktrace`,gn=`exception.type`,_n=`http.request.method`,vn=`http.request.method_original`,yn=`http.response.status_code`,bn=`server.address`,xn=`server.port`,Sn=`service.name`,Cn=`telemetry.sdk.language`,wn=`telemetry.sdk.name`,Tn=`telemetry.sdk.version`,M=`url.full`,En=`user_agent.original`,Dn={[wn]:`opentelemetry`,"process.runtime.name":`browser`,[Cn]:`webjs`,[Tn]:`2.5.0`},N=performance,On=Math.pow(10,6),kn=Math.pow(10,9);function P(e){let t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*On)]}function An(e){return Fn(P(N.timeOrigin),P(typeof e==`number`?e:N.now()))}function F(e){if(Nn(e))return e;if(typeof e==`number`)return e<N.timeOrigin?An(e):P(e);if(e instanceof Date)return P(e.getTime());throw TypeError(`Invalid input type`)}function jn(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(--n,r+=kn),[n,r]}function I(e){return e[0]*kn+e[1]}function Mn(e){return e[0]*1e3+e[1]/1e6}function Nn(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function Pn(e){return Nn(e)||typeof e==`number`||e instanceof Date}function Fn(e,t){let n=[e[0]+t[0],e[1]+t[1]];return n[1]>=kn&&(n[1]-=kn,n[0]+=1),n}var L;(function(e){e[e.SUCCESS=0]=`SUCCESS`,e[e.FAILED=1]=`FAILED`})(L||(L={}));var In=class{constructor(e={}){var t;A(this,`_propagators`,void 0),A(this,`_fields`,void 0),this._propagators=(t=e.propagators)==null?[]:t,this._fields=Array.from(new Set(this._propagators.map(e=>typeof e.fields==`function`?e.fields():[]).reduce((e,t)=>e.concat(t),[])))}inject(e,t,n){for(let r of this._propagators)try{r.inject(e,t,n)}catch(e){T.warn(`Failed to inject with ${r.constructor.name}. Err: ${e.message}`)}}extract(e,t,n){return this._propagators.reduce((e,r)=>{try{return r.extract(e,t,n)}catch(e){T.warn(`Failed to extract with ${r.constructor.name}. Err: ${e.message}`)}return e},e)}fields(){return this._fields.slice()}};let Ln=`[_0-9a-z-*/]`,Rn=`[a-z]${Ln}{0,255}`,zn=`[a-z0-9]${Ln}{0,240}@[a-z]${Ln}{0,13}`,Bn=RegExp(`^(?:${Rn}|${zn})$`),Vn=/^[ -~]{0,255}[!-~]$/,Hn=/,|=/;function Un(e){return Bn.test(e)}function Wn(e){return Vn.test(e)&&!Hn.test(e)}var Gn=class e{constructor(e){A(this,`_internalState`,new Map),e&&this._parse(e)}set(e,t){let n=this._clone();return n._internalState.has(e)&&n._internalState.delete(e),n._internalState.set(e,t),n}unset(e){let t=this._clone();return t._internalState.delete(e),t}get(e){return this._internalState.get(e)}serialize(){return this._keys().reduce((e,t)=>(e.push(t+`=`+this.get(t)),e),[]).join(`,`)}_parse(e){e.length>512||(this._internalState=e.split(`,`).reverse().reduce((e,t)=>{let n=t.trim(),r=n.indexOf(`=`);if(r!==-1){let i=n.slice(0,r),a=n.slice(r+1,t.length);Un(i)&&Wn(a)&&e.set(i,a)}return e},new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){let t=new e;return t._internalState=new Map(this._internalState),t}};let Kn=`traceparent`,qn=`tracestate`,Jn=RegExp(`^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$`);function Yn(e){let t=Jn.exec(e);return!t||t[1]===`00`&&t[5]?null:{traceId:t[2],spanId:t[3],traceFlags:parseInt(t[4],16)}}var Xn=class{inject(e,t,n){let r=D.getSpanContext(e);if(!r||Wt(e)||!et(r))return;let i=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||C.NONE).toString(16)}`;n.set(t,Kn,i),r.traceState&&n.set(t,qn,r.traceState.serialize())}extract(e,t,n){let r=n.get(t,Kn);if(!r)return e;let i=Array.isArray(r)?r[0]:r;if(typeof i!=`string`)return e;let a=Yn(i);if(!a)return e;a.isRemote=!0;let o=n.get(t,qn);if(o){let e=Array.isArray(o)?o.join(`,`):o;a.traceState=new Gn(typeof e==`string`?e:void 0)}return D.setSpanContext(e,a)}fields(){return[Kn,qn]}};let Zn=Function.prototype.toString,Qn=Zn.call(Object),$n=Object.getPrototypeOf,er=Object.prototype,tr=er.hasOwnProperty,R=Symbol?Symbol.toStringTag:void 0,nr=er.toString;function rr(e){if(!ir(e)||ar(e)!==`[object Object]`)return!1;let t=$n(e);if(t===null)return!0;let n=tr.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Zn.call(n)===Qn}function ir(e){return typeof e==`object`&&!!e}function ar(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:R&&R in Object(e)?or(e):sr(e)}function or(e){let t=tr.call(e,R),n=e[R],r=!1;try{e[R]=void 0,r=!0}catch(e){}let i=nr.call(e);return r&&(t?e[R]=n:delete e[R]),i}function sr(e){return nr.call(e)}function cr(...e){let t=e.shift(),n=new WeakMap;for(;e.length>0;)t=ur(t,e.shift(),0,n);return t}function lr(e){return fr(e)?e.slice():e}function ur(e,t,n=0,r){let i;if(!(n>20)){if(n++,hr(e)||hr(t)||pr(t))i=lr(t);else if(fr(e)){if(i=e.slice(),fr(t))for(let e=0,n=t.length;e<n;e++)i.push(lr(t[e]));else if(mr(t)){let e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){let r=e[n];i[r]=lr(t[r])}}}else if(mr(e))if(mr(t)){if(!gr(e,t))return t;i=Object.assign({},e);let a=Object.keys(t);for(let o=0,s=a.length;o<s;o++){let s=a[o],c=t[s];if(hr(c))c===void 0?delete i[s]:i[s]=c;else{let a=i[s],o=c;if(dr(e,s,r)||dr(t,s,r))delete i[s];else{if(mr(a)&&mr(o)){let n=r.get(a)||[],i=r.get(o)||[];n.push({obj:e,key:s}),i.push({obj:t,key:s}),r.set(a,n),r.set(o,i)}i[s]=ur(i[s],c,n,r)}}}}else i=t;return i}}function dr(e,t,n){let r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function fr(e){return Array.isArray(e)}function pr(e){return typeof e==`function`}function mr(e){return!hr(e)&&!fr(e)&&!pr(e)&&typeof e==`object`}function hr(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===void 0||e instanceof Date||e instanceof RegExp||e===null}function gr(e,t){return!(!rr(e)||!rr(t))}var _r=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function vr(e,t){let n,r=new Promise(function(e,r){n=setTimeout(function(){r(new _r(`Operation timed out.`))},t)});return Promise.race([e,r]).then(e=>(clearTimeout(n),e),e=>{throw clearTimeout(n),e})}function yr(e,t){return typeof t==`string`?e===t:!!e.match(t)}function br(e,t){if(!t)return!1;for(let n of t)if(yr(e,n))return!0;return!1}var xr=class{constructor(){A(this,`_promise`,void 0),A(this,`_resolve`,void 0),A(this,`_reject`,void 0),this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}},Sr=class{constructor(e,t){A(this,`_isCalled`,!1),A(this,`_deferred`,new xr),A(this,`_callback`,void 0),A(this,`_that`,void 0),this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}};function Cr(e,t){return new Promise(n=>{w.with(Ut(w.active()),()=>{e.export(t,e=>{n(e)})})})}let wr={_export:Cr},Tr;function Er(){if(Tr===void 0)try{let e=globalThis.process.argv0;Tr=e?`unknown_service:${e}`:`unknown_service`}catch(e){Tr=`unknown_service`}return Tr}let Dr=e=>typeof e==`object`&&!!e&&typeof e.then==`function`;function Or(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function z(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Or(a,r,i,o,s,`next`,e)}function s(e){Or(a,r,i,o,s,`throw`,e)}o(void 0)})}}var kr=class e{static FromAttributeList(t,n){let r=new e({},n);return r._rawAttributes=Nr(t),r._asyncAttributesPending=t.filter(([e,t])=>Dr(t)).length>0,r}constructor(e,t){var n;A(this,`_rawAttributes`,void 0),A(this,`_asyncAttributesPending`,!1),A(this,`_schemaUrl`,void 0),A(this,`_memoizedAttributes`,void 0);let r=(n=e.attributes)==null?{}:n;this._rawAttributes=Object.entries(r).map(([e,t])=>(Dr(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=Nr(this._rawAttributes),this._schemaUrl=Pr(t==null?void 0:t.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}waitForAsyncAttributes(){var e=this;return z(function*(){if(e.asyncAttributesPending){for(let t=0;t<e._rawAttributes.length;t++){let[n,r]=e._rawAttributes[t];e._rawAttributes[t]=[n,Dr(r)?yield r:r]}e._asyncAttributesPending=!1}})()}get attributes(){if(this.asyncAttributesPending&&T.error(`Accessing resource attributes before async attributes settled`),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[t,n]of this._rawAttributes){if(Dr(n)){T.debug(`Unsettled resource attribute ${t} skipped`);continue}n!=null&&(e[t]!=null||(e[t]=n))}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(t==null)return this;let n=Fr(this,t),r=n?{schemaUrl:n}:void 0;return e.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],r)}};function Ar(e,t){return kr.FromAttributeList(Object.entries(e),t)}function jr(){return Ar({})}function Mr(){return Ar({[Sn]:Er(),[Cn]:Dn[Cn],[wn]:Dn[wn],[Tn]:Dn[Tn]})}function Nr(e){return e.map(([e,t])=>Dr(t)?[e,t.catch(t=>{T.debug(`promise rejection for resource attribute: %s - %s`,e,t)})]:[e,t])}function Pr(e){if(typeof e==`string`||e===void 0)return e;T.warn(`Schema URL must be string or undefined, got %s. Schema URL will be ignored.`,e)}function Fr(e,t){let n=e==null?void 0:e.schemaUrl,r=t==null?void 0:t.schemaUrl,i=n===void 0||n===``,a=r===void 0||r===``;if(i)return r;if(a||n===r)return n;T.warn(`Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.`,n,r)}function Ir(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function B(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ir(Object(n),!0).forEach(function(t){A(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ir(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Lr=class{constructor(e){var t;A(this,`_spanContext`,void 0),A(this,`kind`,void 0),A(this,`parentSpanContext`,void 0),A(this,`attributes`,{}),A(this,`links`,[]),A(this,`events`,[]),A(this,`startTime`,void 0),A(this,`resource`,void 0),A(this,`instrumentationScope`,void 0),A(this,`_droppedAttributesCount`,0),A(this,`_droppedEventsCount`,0),A(this,`_droppedLinksCount`,0),A(this,`name`,void 0),A(this,`status`,{code:dt.UNSET}),A(this,`endTime`,[0,0]),A(this,`_ended`,!1),A(this,`_duration`,[-1,-1]),A(this,`_spanProcessor`,void 0),A(this,`_spanLimits`,void 0),A(this,`_attributeValueLengthLimit`,void 0),A(this,`_performanceStartTime`,void 0),A(this,`_performanceOffset`,void 0),A(this,`_startTimeProvided`,void 0);let n=Date.now();this._spanContext=e.spanContext,this._performanceStartTime=N.now(),this._performanceOffset=n-(this._performanceStartTime+N.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit||0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,this.links=e.links||[],this.startTime=this._getTime((t=e.startTime)==null?n:t),this.resource=e.resource,this.instrumentationScope=e.scope,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return T.warn(`Invalid attribute key: ${e}`),this;if(!tn(t))return T.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits;return n!==void 0&&Object.keys(this.attributes).length>=n&&!Object.prototype.hasOwnProperty.call(this.attributes,e)?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return T.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&T.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),Pn(t)&&(Pn(n)||(n=t),t=void 0);let i=$t(t);return this.events.push({name:e,attributes:i,time:this._getTime(n),droppedAttributesCount:0}),this}addLink(e){return this.links.push(e),this}addLinks(e){return this.links.push(...e),this}setStatus(e){return this._isSpanEnded()?this:(this.status=B({},e),this.status.message!=null&&typeof e.message!=`string`&&(T.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`),delete this.status.message),this)}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){if(this._isSpanEnded()){T.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this.endTime=this._getTime(e),this._duration=jn(this.startTime,this.endTime),this._duration[0]<0&&(T.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&T.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e==`number`&&e<=N.now())return An(e+this._performanceOffset);if(typeof e==`number`)return P(e);if(e instanceof Date)return P(e.getTime());if(Nn(e))return e;if(this._startTimeProvided)return P(Date.now());let t=N.now()-this._performanceStartTime;return Fn(this.startTime,P(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[mn]=e:e&&(e.code?n[gn]=e.code.toString():e.name&&(n[gn]=e.name),e.message&&(n[mn]=e.message),e.stack&&(n[hn]=e.stack)),n[gn]||n[mn]?this.addEvent(`exception`,n,t):T.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);T.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(T.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}},Rr;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(Rr||(Rr={}));var zr=class{shouldSample(){return{decision:Rr.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},Br=class{shouldSample(){return{decision:Rr.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}},Vr=class{constructor(e){var t,n,r,i;A(this,`_root`,void 0),A(this,`_remoteParentSampled`,void 0),A(this,`_remoteParentNotSampled`,void 0),A(this,`_localParentSampled`,void 0),A(this,`_localParentNotSampled`,void 0),this._root=e.root,this._root||(j(Error(`ParentBasedSampler must have a root sampler configured`)),this._root=new Br),this._remoteParentSampled=(t=e.remoteParentSampled)==null?new Br:t,this._remoteParentNotSampled=(n=e.remoteParentNotSampled)==null?new zr:n,this._localParentSampled=(r=e.localParentSampled)==null?new Br:r,this._localParentNotSampled=(i=e.localParentNotSampled)==null?new zr:i}shouldSample(e,t,n,r,i,a){let o=D.getSpanContext(e);return!o||!et(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&C.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&C.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}},Hr=class{constructor(e=0){A(this,`_ratio`,void 0),A(this,`_upperBound`,void 0),this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:Qe(t)&&this._accumulate(t)<this._upperBound?Rr.RECORD_AND_SAMPLED:Rr.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<e.length/8;n++){let r=n*8,i=parseInt(e.slice(r,r+8),16);t=(t^i)>>>0}return t}},V;(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(V||(V={}));function Ur(){var e,t,n,r,i,a,o,s;return{sampler:Wr(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:(e=void 0)==null?1/0:e,attributeCountLimit:(t=void 0)==null?128:t},spanLimits:{attributeValueLengthLimit:(n=void 0)==null?1/0:n,attributeCountLimit:(r=void 0)==null?128:r,linkCountLimit:(i=void 0)==null?128:i,eventCountLimit:(a=void 0)==null?128:a,attributePerEventCountLimit:(o=void 0)==null?128:o,attributePerLinkCountLimit:(s=void 0)==null?128:s}}}function Wr(){var e;let t=(e=void 0)==null?V.ParentBasedAlwaysOn:e;switch(t){case V.AlwaysOn:return new Br;case V.AlwaysOff:return new zr;case V.ParentBasedAlwaysOn:return new Vr({root:new Br});case V.ParentBasedAlwaysOff:return new Vr({root:new zr});case V.TraceIdRatio:return new Hr(Gr());case V.ParentBasedTraceIdRatio:return new Vr({root:new Hr(Gr())});default:return T.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${V.ParentBasedAlwaysOn}".`),new Vr({root:new Br})}}function Gr(){return T.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to 1.`),1}function Kr(e){let t={sampler:Wr()},n=Ur(),r=Object.assign({},n,t,e);return r.generalLimits=Object.assign({},n.generalLimits,e.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,e.spanLimits||{}),r}function qr(e){var t,n,r,i,a,o,s,c,l,u,d,f;let p=Object.assign({},e.spanLimits);return p.attributeCountLimit=(t=(n=(r=(i=(a=e.spanLimits)==null?void 0:a.attributeCountLimit)==null?(o=e.generalLimits)==null?void 0:o.attributeCountLimit:i)==null?void 0:r)==null?void 0:n)==null?128:t,p.attributeValueLengthLimit=(s=(c=(l=(u=(d=e.spanLimits)==null?void 0:d.attributeValueLengthLimit)==null?(f=e.generalLimits)==null?void 0:f.attributeValueLengthLimit:u)==null?void 0:l)==null?void 0:c)==null?1/0:s,Object.assign({},e,{spanLimits:p})}var Jr=class{constructor(e,t){var n,r,i,a;A(this,`_maxExportBatchSize`,void 0),A(this,`_maxQueueSize`,void 0),A(this,`_scheduledDelayMillis`,void 0),A(this,`_exportTimeoutMillis`,void 0),A(this,`_exporter`,void 0),A(this,`_isExporting`,!1),A(this,`_finishedSpans`,[]),A(this,`_timer`,void 0),A(this,`_shutdownOnce`,void 0),A(this,`_droppedSpansCount`,0),this._exporter=e,this._maxExportBatchSize=typeof(t==null?void 0:t.maxExportBatchSize)==`number`?t.maxExportBatchSize:(n=void 0)==null?512:n,this._maxQueueSize=typeof(t==null?void 0:t.maxQueueSize)==`number`?t.maxQueueSize:(r=void 0)==null?2048:r,this._scheduledDelayMillis=typeof(t==null?void 0:t.scheduledDelayMillis)==`number`?t.scheduledDelayMillis:(i=void 0)==null?5e3:i,this._exportTimeoutMillis=typeof(t==null?void 0:t.exportTimeoutMillis)==`number`?t.exportTimeoutMillis:(a=void 0)==null?3e4:a,this._shutdownOnce=new Sr(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(T.warn(`BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&C.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>this._exporter.shutdown())}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize){this._droppedSpansCount===0&&T.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++;return}this._droppedSpansCount>0&&(T.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let e=0,t=r;e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout`))},this._exportTimeoutMillis);w.with(Ut(w.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);let i=()=>this._exporter.export(r,r=>{if(clearTimeout(n),r.code===L.SUCCESS)e();else{var i;t((i=r.error)==null?Error(`BatchSpanProcessor: span export failed`):i)}}),a=null;for(let e=0,t=r.length;e<t;e++){let t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a!=null||(a=[]),a.push(t.resource.waitForAsyncAttributes()))}a===null?i():Promise.all(a).then(i,e=>{j(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,j(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}},Yr=class extends Jr{constructor(e,t){super(e,t),A(this,`_visibilityChangeListener`,void 0),A(this,`_pageHideListener`,void 0),this.onInit(t)}onInit(e){(e==null?void 0:e.disableAutoFlushOnDocumentHide)!==!0&&typeof document<`u`&&(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush().catch(e=>{j(e)})},this._pageHideListener=()=>{this.forceFlush().catch(e=>{j(e)})},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}onShutdown(){typeof document<`u`&&(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}},Xr=class{constructor(){A(this,`generateTraceId`,Qr(16)),A(this,`generateSpanId`,Qr(8))}};let Zr=Array(32);function Qr(e){return function(){for(let t=0;t<e*2;t++)Zr[t]=Math.floor(Math.random()*16)+48,Zr[t]>=58&&(Zr[t]+=39);return String.fromCharCode.apply(null,Zr.slice(0,e*2))}}var $r=class{constructor(e,t,n,r){A(this,`_sampler`,void 0),A(this,`_generalLimits`,void 0),A(this,`_spanLimits`,void 0),A(this,`_idGenerator`,void 0),A(this,`instrumentationScope`,void 0),A(this,`_resource`,void 0),A(this,`_spanProcessor`,void 0);let i=Kr(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new Xr,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e}startSpan(e,t={},n=w.active()){var r,i,a;t.root&&(n=D.deleteSpan(n));let o=D.getSpan(n);if(Wt(n))return T.debug(`Instrumentation suppressed, returning Noop Span`),D.wrapSpanContext(Ve);let s=o==null?void 0:o.spanContext(),c=this._idGenerator.generateSpanId(),l,u,d;!s||!D.isSpanContextValid(s)?u=this._idGenerator.generateTraceId():(u=s.traceId,d=s.traceState,l=s);let f=(r=t.kind)==null?ut.INTERNAL:r,p=((i=t.links)==null?[]:i).map(e=>({context:e.context,attributes:$t(e.attributes)})),ee=$t(t.attributes),m=this._sampler.shouldSample(n,u,e,f,ee,p);d=(a=m.traceState)==null?d:a;let h=m.decision===lt.RECORD_AND_SAMPLED?C.SAMPLED:C.NONE,te={traceId:u,spanId:c,traceFlags:h,traceState:d};if(m.decision===lt.NOT_RECORD)return T.debug(`Recording is off, propagating context in a non-recording span`),D.wrapSpanContext(te);let g=$t(Object.assign(ee,m.attributes));return new Lr({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:te,name:e,kind:f,links:p,parentSpanContext:l,attributes:g,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits})}startActiveSpan(e,t,n,r){var i;let a,o,s;if(arguments.length<2)return;arguments.length===2?s=t:arguments.length===3?(a=t,s=n):(a=t,o=n,s=r);let c=(i=o)==null?w.active():i,l=this.startSpan(e,a,c),u=D.setSpan(c,l);return w.with(u,s,void 0,l)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}},ei=class{constructor(e){A(this,`_spanProcessors`,void 0),this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{j(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}},H;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(H||(H={}));var ti=class{constructor(e={}){var t,n;A(this,`_config`,void 0),A(this,`_tracers`,new Map),A(this,`_resource`,void 0),A(this,`_activeSpanProcessor`,void 0);let r=cr({},Ur(),qr(e));this._resource=(t=r.resource)==null?Mr():t,this._config=Object.assign({},r,{resource:this._resource});let i=[];(n=e.spanProcessors)!=null&&n.length&&i.push(...e.spanProcessors),this._activeSpanProcessor=new ei(i)}getTracer(e,t,n){let r=`${e}@${t||``}:${(n==null?void 0:n.schemaUrl)||``}`;return this._tracers.has(r)||this._tracers.set(r,new $r({name:e,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){let e=this._config.forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${e} ms`)),r=H.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==H.timeout&&(r=H.resolved,n(r))}).catch(e=>{clearTimeout(i),r=H.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==H.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}},ni=class{constructor(){A(this,`_enabled`,!1),A(this,`_currentContext`,y)}_bindFunction(e=y,t){let n=this,r=function(...r){return n.with(e,()=>t.apply(this,r))};return Object.defineProperty(r,`length`,{enumerable:!1,configurable:!0,writable:!1,value:t.length}),r}active(){return this._currentContext}bind(e,t){return e===void 0&&(e=this.active()),typeof t==`function`?this._bindFunction(e,t):t}disable(){return this._currentContext=y,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=y,this)}with(e,t,n,...r){let i=this._currentContext;this._currentContext=e||y;try{return t.call(n,...r)}finally{this._currentContext=i}}};function ri(e){if(e!==null){if(e===void 0){let e=new ni;e.enable(),w.setGlobalContextManager(e);return}e.enable(),w.setGlobalContextManager(e)}}function ii(e){if(e!==null){if(e===void 0){E.setGlobalPropagator(new In({propagators:[new Xn,new Yt]}));return}E.setGlobalPropagator(e)}}var ai=class extends ti{constructor(e={}){super(e)}register(e={}){D.setGlobalTracerProvider(this),ii(e.propagator),ri(e.contextManager)}},U;(function(e){e.CONNECT_END=`connectEnd`,e.CONNECT_START=`connectStart`,e.DECODED_BODY_SIZE=`decodedBodySize`,e.DOM_COMPLETE=`domComplete`,e.DOM_CONTENT_LOADED_EVENT_END=`domContentLoadedEventEnd`,e.DOM_CONTENT_LOADED_EVENT_START=`domContentLoadedEventStart`,e.DOM_INTERACTIVE=`domInteractive`,e.DOMAIN_LOOKUP_END=`domainLookupEnd`,e.DOMAIN_LOOKUP_START=`domainLookupStart`,e.ENCODED_BODY_SIZE=`encodedBodySize`,e.FETCH_START=`fetchStart`,e.LOAD_EVENT_END=`loadEventEnd`,e.LOAD_EVENT_START=`loadEventStart`,e.NAVIGATION_START=`navigationStart`,e.REDIRECT_END=`redirectEnd`,e.REDIRECT_START=`redirectStart`,e.REQUEST_START=`requestStart`,e.RESPONSE_END=`responseEnd`,e.RESPONSE_START=`responseStart`,e.SECURE_CONNECTION_START=`secureConnectionStart`,e.START_TIME=`startTime`,e.UNLOAD_EVENT_END=`unloadEventEnd`,e.UNLOAD_EVENT_START=`unloadEventStart`})(U||(U={}));let oi;function si(){return oi||(oi=document.createElement(`a`)),oi}function ci(e,t){return t in e}function W(e,t,n,r=!0){if(ci(n,t)&&typeof n[t]==`number`&&!(r&&n[t]===0))return e.addEvent(t,n[t])}function li(e,t,n=!1,r,i){if(r===void 0&&(r=t[U.START_TIME]!==0),n||(W(e,U.FETCH_START,t,r),W(e,U.DOMAIN_LOOKUP_START,t,r),W(e,U.DOMAIN_LOOKUP_END,t,r),W(e,U.CONNECT_START,t,r),W(e,U.SECURE_CONNECTION_START,t,r),W(e,U.CONNECT_END,t,r),W(e,U.REQUEST_START,t,r),W(e,U.RESPONSE_START,t,r),W(e,U.RESPONSE_END,t,r)),!i){let n=t[U.ENCODED_BODY_SIZE];n!==void 0&&e.setAttribute(`http.response_content_length`,n);let r=t[U.DECODED_BODY_SIZE];r!==void 0&&n!==r&&e.setAttribute(`http.response_content_length_uncompressed`,r)}}function ui(e){return e.slice().sort((e,t)=>{let n=e[U.FETCH_START],r=t[U.FETCH_START];return n>r?1:n<r?-1:0})}function di(){return typeof location<`u`?location.origin:void 0}function fi(e,t,n,r,i=new WeakSet,a){let o=G(e);e=o.toString();let s=mi(e,t,n,r,i,a);if(s.length===0)return{mainRequest:void 0};if(s.length===1)return{mainRequest:s[0]};let c=ui(s);if(o.origin!==di()&&c.length>1){let e=c[0],t=pi(c,e[U.RESPONSE_END],n),r=e[U.RESPONSE_END];return t[U.FETCH_START]<r&&(t=e,e=void 0),{corsPreFlightRequest:e,mainRequest:t}}else return{mainRequest:s[0]}}function pi(e,t,n){let r=I(n),i=I(F(t)),a=e[1],o,s=e.length;for(let t=1;t<s;t++){let n=e[t],s=I(F(n[U.FETCH_START])),c=r-I(F(n[U.RESPONSE_END]));s>=i&&(!o||c<o)&&(o=c,a=n)}return a}function mi(e,t,n,r,i,a){let o=I(t),s=I(n),c=r.filter(t=>{let n=I(F(t[U.FETCH_START])),r=I(F(t[U.RESPONSE_END]));return t.initiatorType.toLowerCase()===(a||`xmlhttprequest`)&&t.name===e&&n>=o&&r<=s});return c.length>0&&(c=c.filter(e=>!i.has(e))),c}function G(e){if(typeof URL==`function`)return new URL(e,typeof document<`u`?document.baseURI:typeof location<`u`?location.href:void 0);let t=si();return t.href=e,t}function hi(e,t){let n=t||[];return(typeof n==`string`||n instanceof RegExp)&&(n=[n]),G(e).origin===di()?!0:n.some(t=>yr(e,t))}let gi=`mxl_pending_`;var _i=class{constructor({resource:e=jr(),storage:t=window.localStorage,diag:n=T.createComponentLogger({namespace:`MXLSpanStorage`}),storedSpansExpireTimeoutMS:r=3600*1e3,onExpiredSpansExport:i,spanSessionManager:a}){A(this,`_noExportTracer`,void 0),A(this,`_storage`,void 0),A(this,`_diag`,void 0),A(this,`_onExpiredSpansExport`,void 0),A(this,`_storedSpansExpireTimeoutMS`,void 0),A(this,`_spanSessionManager`,void 0),A(this,`_checkExpiredSpansInterval`,void 0),this._noExportTracer=new ti({resource:e}).getTracer(`mxl-web-sdk-sessions`),this._storage=t,this._diag=n,this._storedSpansExpireTimeoutMS=r,this._onExpiredSpansExport=i,this._spanSessionManager=a,this.startExpiredSpansCheck()}storePendingSpans(e,t,n){try{if(this.clearStoredSpans(e),this._getPendingSpansKeys().length>=10){this._spanSessionManager.incrSessionCountForKey(`mxl.max_pending_spans_reached`),this._diag.warn(`Not storing pending spans as the max number of items was reached`);return}let r=`${gi}${e}_${Date.now()}`;this._storage.setItem(r,JSON.stringify([t,...n],(e,t)=>e.startsWith(`_`)?void 0:t)),this._diag.debug(`Stored pending span: ${r}`)}catch(e){this._diag.error(`Failed to store spans to storage:`,e)}}clearStoredSpans(e){try{let t=`${gi}${e}_`;this._getPendingSpansKeys().forEach(e=>{e.startsWith(t)&&this._storage.removeItem(e)})}catch(e){this._diag.error(`Failed to clear stored spans from storage:`,e)}}startExpiredSpansCheck(){this._checkExpiredSpansInterval=setInterval(()=>{this.checkAndExportExpiredSpans()},300*1e3)}stopExpiredSpansCheck(){this._checkExpiredSpansInterval&&(clearInterval(this._checkExpiredSpansInterval),this._checkExpiredSpansInterval=void 0)}checkAndExportExpiredSpans(){try{let e=this._getPendingSpansKeys();if(e.length===0)return;let t=Date.now();e.forEach(e=>{let n=e.split(`_`),r=parseInt(n[n.length-1],10);if(Number.isNaN(r)&&(this._diag.error(`Found invalid timestamp in stored span:`,r),this._storage.removeItem(e)),t-r<=this._storedSpansExpireTimeoutMS)return;let i=this._storage.getItem(e);if(i){try{let e=[];for(let t of JSON.parse(i)){let n=this._noExportTracer.startSpan(t.name,{kind:t.kind,attributes:t.attributes,links:t.links,startTime:t.startTime});n.setStatus(t.status),n.end(t.endTime),e.push(n)}this._onExpiredSpansExport&&e.length>0&&this._onExpiredSpansExport(e)}catch(e){this._diag.error(`Failed to process expired spans:`,e)}this._storage.removeItem(e)}})}catch(e){this._diag.error(`Failed to check and export expired spans:`,e)}}_getPendingSpansKeys(){let e=[];for(let t=0;t<this._storage.length;t++){let n=this._storage.key(t);n!=null&&n.startsWith(gi)&&e.push(n)}return e}destroy(){this.stopExpiredSpansCheck()}},vi=class{constructor(e,t){A(this,`_keyPrefix`,void 0),A(this,`_storage`,void 0),this._keyPrefix=`${e}_`,this._storage=t}getNamespacedKeys(){let e=[];for(let t=0;t<this._storage.length;t++){let n=this._storage.key(t);n!=null&&n.startsWith(this._keyPrefix)&&e.push(n.substring(this._keyPrefix.length))}return e}get length(){return this.getNamespacedKeys().length}clear(){this.getNamespacedKeys().forEach(e=>{this._storage.removeItem(`${this._keyPrefix}${e}`)})}getItem(e){return this._storage.getItem(`${this._keyPrefix}${e}`)}key(e){return this.getNamespacedKeys()[e]||null}removeItem(e){this._storage.removeItem(`${this._keyPrefix}${e}`)}setItem(e,t){this._storage.setItem(`${this._keyPrefix}${e}`,t)}};let yi=({diag:e,featureManager:t,registerGlobally:n,propagator:r,defaultInstrumentationConfig:i})=>{var a;if(!t.isNetworkSpanForwardingEnabled())return!1;let o=[];return n||o.push("Network span forwarding cannot be used when `registerGlobally` is set to false. Turning off network span forwarding."),r&&o.push("Network span forwarding cannot be used alongside a custom `propagator`. Turning off network span forwarding."),!(i==null||(a=i.omit)==null)&&a.has(`@opentelemetry/instrumentation-xml-http-request`)&&i.omit.has(`@opentelemetry/instrumentation-fetch`)&&o.push(`Network span forwarding cannot be used when both '@opentelemetry/instrumentation-xml-http-request' and '@opentelemetry/instrumentation-fetch' are omitted. Turning off network span forwarding.`),o.forEach(t=>{e.warn(t)}),o.length===0};var bi=class{constructor(e=window.performance){A(this,`_clock`,void 0),A(this,`epochMillisFromOriginOffset`,e=>this._clock.timeOrigin+e),A(this,`getNowHRTime`,()=>P(this.getNowMillis())),A(this,`getNowMillis`,()=>this.epochMillisFromOriginOffset(this._clock.now())),A(this,`millisSinceHRTime`,e=>this.getNowMillis()-Mn(e)),this._clock=e}};let xi=(e,t=1e3)=>{let n=!1;return(...r)=>{n||(e(...r),setTimeout(()=>{n=!1},t),n=!0)}};var Si=class{logException(e,t){}message(e,t,n){}};let Ci=new Si;var wi=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Ci:e}setDelegate(e){this._delegate=e}logException(e,t){this.getDelegate().logException(e,t)}message(e,t,n){this.getDelegate().message(e,t,n)}};let Ti=new Si,Ei=new Set([`setDelegate`,`getDelegate`]);var Di=class e{static getInstance(){if(!e._instance){let t=new wi,n=Et(t,Ti,T.createComponentLogger({namespace:`LogAPI`}),Ei);e._instance=Object.assign(n,{setGlobalLogManager(e){t.setDelegate(e)},getLogManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(Di,`_instance`,void 0);let Oi=Di.getInstance();var ki=class{setCurrentRoute(e){}getCurrentRoute(){return null}getCurrentPageId(){return``}clearCurrentRoute(){}};let Ai=new ki;var ji=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Ai:e}setDelegate(e){this._delegate=e}setCurrentRoute(e){this.getDelegate().setCurrentRoute(e)}getCurrentRoute(){return this.getDelegate().getCurrentRoute()}getCurrentPageId(){return this.getDelegate().getCurrentPageId()}clearCurrentRoute(){this.getDelegate().clearCurrentRoute()}};let Mi=new ki,Ni=new Set([`setDelegate`,`getDelegate`]);var Pi=class e{static getInstance(){if(!e._instance){let t=new ji,n=Et(t,Mi,T.createComponentLogger({namespace:`PageAPI`}),Ni);e._instance=Object.assign(n,{setGlobalPageManager(e){t.setDelegate(e)},getPageManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(Pi,`_instance`,void 0);let K=Pi.getInstance();var Fi=class{constructor(){A(this,`getSessionId`,()=>null),A(this,`getPreviousSessionId`,()=>null)}addBreadcrumb(e){}addProperty(e,t,n){}removeProperty(e){}endSessionSpan(){}endSessionSpanInternal(e){}currentSessionAsReadableSpan(e){return null}getSessionSpan(){return null}getSessionStartTime(){return null}startSessionSpan(){}addSessionStartedListener(e){return()=>{}}addSessionEndedListener(e){return()=>{}}};let Ii=new Fi;var Li=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Ii:e}setDelegate(e){this._delegate=e}addBreadcrumb(e){this.getDelegate().addBreadcrumb(e)}addProperty(e,t,n){this.getDelegate().addProperty(e,t,n)}removeProperty(e){this.getDelegate().removeProperty(e)}endSessionSpan(){this.getDelegate().endSessionSpan()}endSessionSpanInternal(e){this.getDelegate().endSessionSpanInternal(e)}currentSessionAsReadableSpan(e){return this.getDelegate().currentSessionAsReadableSpan(e)}getSessionId(){return this.getDelegate().getSessionId()}getPreviousSessionId(){return this.getDelegate().getPreviousSessionId()}getSessionSpan(){return this.getDelegate().getSessionSpan()}getSessionStartTime(){return this.getDelegate().getSessionStartTime()}startSessionSpan(e){this.getDelegate().startSessionSpan(e)}addSessionStartedListener(e){return this.getDelegate().addSessionStartedListener(e)}addSessionEndedListener(e){return this.getDelegate().addSessionEndedListener(e)}};let Ri=new Fi,zi=new Set([`setDelegate`,`getDelegate`]);var Bi=class e{static getInstance(){if(!e._instance){let t=new Li,n=Et(t,Ri,T.createComponentLogger({namespace:`SessionAPI`}),zi);e._instance=Object.assign(n,{setGlobalSessionManager(e){t.setDelegate(e)},getSpanSessionManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(Bi,`_instance`,void 0);let Vi=Bi.getInstance();var Hi=class{constructor(e=Ve){A(this,`_spanContext`,void 0),A(this,`attributes`,{}),this._spanContext=e}fail(e){}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}removeAttribute(e){return this}addEvent(e,t,n){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}},Ui=class{startSpan(e,t){return new Hi}setSpan(e,t){return y}getSpan(e){}};let Wi=new Ui;var Gi=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Wi:e}setDelegate(e){this._delegate=e}startSpan(e,t,n){return this.getDelegate().startSpan(e,t,n)}setSpan(e,t){return this.getDelegate().setSpan(e,t)}getSpan(e){return this.getDelegate().getSpan(e)}};let Ki=new Ui,qi=new Set([`setDelegate`,`getDelegate`]);var Ji=class e{static getInstance(){if(!e._instance){let t=new Gi,n=Et(t,Ki,T.createComponentLogger({namespace:`TraceAPI`}),qi);e._instance=Object.assign(n,{setGlobalTraceManager(e){t.setDelegate(e)},getTraceManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(Ji,`_instance`,void 0);let Yi=Ji.getInstance(),Xi=`enduser.pseudo.id`;var Zi=class{getMXLUserId(){return``}getUserId(){return null}setUserId(){}clearUserId(){}};let Qi=new Zi;var $i=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Qi:e}setDelegate(e){this._delegate=e}getMXLUserId(){return this.getDelegate().getMXLUserId()}getUserId(){return this.getDelegate().getUserId()}setUserId(e){this.getDelegate().setUserId(e)}clearUserId(){this.getDelegate().clearUserId()}};let ea=new Zi,ta=new Set([`setDelegate`,`getDelegate`]);var na=class e{static getInstance(){if(!e._instance){let t=new $i,n=Et(t,ea,T.createComponentLogger({namespace:`UserAPI`}),ta);e._instance=Object.assign(n,{setGlobalUserManager(e){t.setDelegate(e)},getUserManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(na,`_instance`,void 0);let ra=na.getInstance(),ia={compression:`gzip`,keepalive:!0,concurrencyLimit:5,timeoutMillis:30*1e3},aa=(e,t)=>({"X-MXL-AID":e,"X-MXL-DID":t}),oa=(e,t)=>t||`http://mxl-otelcol.service-availability.apps.ocpthikadev01.safaricom.net`,sa=Math.pow(10,9);function ca(e){return e[0]*sa+e[1]}function la(e){return e>=48&&e<=57?e-48:e>=97&&e<=102?e-87:e-55}function ua(e){let t=new Uint8Array(e.length/2),n=0;for(let r=0;r<e.length;r+=2){let i=la(e.charCodeAt(r)),a=la(e.charCodeAt(r+1));t[n++]=i<<4|a}return t}function da(e){let t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function fa(e){return{low:Number(BigInt.asUintN(32,e)),high:Number(BigInt.asUintN(32,e>>BigInt(32)))}}function pa(e){return fa(da(e))}function ma(e){return da(e).toString()}let ha=typeof BigInt<`u`?ma:ca;function ga(e){return e}function _a(e){if(e!==void 0)return ua(e)}let va={encodeHrTime:pa,encodeSpanContext:ua,encodeOptionalSpanContext:_a};function ya(e){var t,n;if(e===void 0)return va;let r=(t=e.useLongBits)==null?!0:t,i=(n=e.useHex)==null?!1:n;return{encodeHrTime:r?pa:ha,encodeSpanContext:i?ga:ua,encodeOptionalSpanContext:i?ga:_a}}function ba(e){let t={attributes:Sa(e.attributes),droppedAttributesCount:0},n=e.schemaUrl;return n&&n!==``&&(t.schemaUrl=n),t}function xa(e){return{name:e.name,version:e.version}}function Sa(e){return Object.keys(e).map(t=>Ca(t,e[t]))}function Ca(e,t){return{key:e,value:wa(t)}}function wa(e){let t=typeof e;return t===`string`?{stringValue:e}:t===`number`?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:t===`boolean`?{boolValue:e}:e instanceof Uint8Array?{bytesValue:e}:Array.isArray(e)?{arrayValue:{values:e.map(wa)}}:t===`object`&&e!=null?{kvlistValue:{values:Object.entries(e).map(([e,t])=>Ca(e,t))}}:{}}function Ta(e,t){return{resourceLogs:Da(e,ya(t))}}function Ea(e){let t=new Map;for(let n of e){let{resource:e,instrumentationScope:{name:r,version:i=``,schemaUrl:a=``}}=n,o=t.get(e);o||(o=new Map,t.set(e,o));let s=`${r}@${i}:${a}`,c=o.get(s);c||(c=[],o.set(s,c)),c.push(n)}return t}function Da(e,t){let n=Ea(e);return Array.from(n,([e,n])=>{let r=ba(e);return{resource:r,scopeLogs:Array.from(n,([,e])=>({scope:xa(e[0].instrumentationScope),logRecords:e.map(e=>Oa(e,t)),schemaUrl:e[0].instrumentationScope.schemaUrl})),schemaUrl:r.schemaUrl}})}function Oa(e,t){var n,r,i;return{timeUnixNano:t.encodeHrTime(e.hrTime),observedTimeUnixNano:t.encodeHrTime(e.hrTimeObserved),severityNumber:ka(e.severityNumber),severityText:e.severityText,body:wa(e.body),eventName:e.eventName,attributes:Aa(e.attributes),droppedAttributesCount:e.droppedAttributesCount,flags:(n=e.spanContext)==null?void 0:n.traceFlags,traceId:t.encodeOptionalSpanContext((r=e.spanContext)==null?void 0:r.traceId),spanId:t.encodeOptionalSpanContext((i=e.spanContext)==null?void 0:i.spanId)}}function ka(e){return e}function Aa(e){return Object.keys(e).map(t=>Ca(t,e[t]))}function ja(e,t){let n=e&255|256;return t&&(n|=512),n}function Ma(e,t){var n,r,i,a;let o=e.spanContext(),s=e.status,c=(n=e.parentSpanContext)!=null&&n.spanId?t.encodeSpanContext((r=e.parentSpanContext)==null?void 0:r.spanId):void 0;return{traceId:t.encodeSpanContext(o.traceId),spanId:t.encodeSpanContext(o.spanId),parentSpanId:c,traceState:(i=o.traceState)==null?void 0:i.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:Sa(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Pa(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:s.code,message:s.message},links:e.links.map(e=>Na(e,t)),droppedLinksCount:e.droppedLinksCount,flags:ja(o.traceFlags,(a=e.parentSpanContext)==null?void 0:a.isRemote)}}function Na(e,t){var n;return{attributes:e.attributes?Sa(e.attributes):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(n=e.context.traceState)==null?void 0:n.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:ja(e.context.traceFlags,e.context.isRemote)}}function Pa(e,t){return{attributes:e.attributes?Sa(e.attributes):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Fa(e,t){return{resourceSpans:La(e,ya(t))}}function Ia(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function La(e,t){let n=Ia(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>Ma(e,t));o.push({scope:xa(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=ba(e),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}let Ra={serializeRequest:e=>{let t=Ta(e,{useHex:!0,useLongBits:!1});return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;return JSON.parse(t.decode(e))}},za={serializeRequest:e=>{let t=Fa(e,{useHex:!0,useLongBits:!1});return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;return JSON.parse(t.decode(e))}};var Ba=class{constructor(e){this._delegate=e}export(e,t){this._delegate.export(e,t)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}},Va=class extends Error{constructor(e,t,n){super(e),A(this,`code`,void 0),A(this,`name`,`OTLPExporterError`),A(this,`data`,void 0),this.data=n,this.code=t}},Ha=class{constructor(e){A(this,`_concurrencyLimit`,void 0),A(this,`_sendingPromises`,[]),this._concurrencyLimit=e}pushPromise(e){if(this.hasReachedLimit())throw Error(`Concurrency Limit reached`);this._sendingPromises.push(e);let t=()=>{let t=this._sendingPromises.indexOf(e);this._sendingPromises.splice(t,1)};e.then(t,t)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}awaitAll(){var e=this;return z(function*(){yield Promise.all(e._sendingPromises)})()}};function Ua(e){return new Ha(e.concurrencyLimit)}function Wa(e){return Object.prototype.hasOwnProperty.call(e,`partialSuccess`)}function Ga(){return{handleResponse(e){e==null||!Wa(e)||e.partialSuccess==null||Object.keys(e.partialSuccess).length===0||T.warn(`Received Partial Success response:`,JSON.stringify(e.partialSuccess))}}}var Ka=class{constructor(e,t,n,r,i){A(this,`_diagLogger`,void 0),A(this,`_transport`,void 0),A(this,`_serializer`,void 0),A(this,`_responseHandler`,void 0),A(this,`_promiseQueue`,void 0),A(this,`_timeout`,void 0),this._transport=e,this._serializer=t,this._responseHandler=n,this._promiseQueue=r,this._timeout=i,this._diagLogger=T.createComponentLogger({namespace:`OTLPExportDelegate`})}export(e,t){if(this._diagLogger.debug(`items to be sent`,e),this._promiseQueue.hasReachedLimit()){t({code:L.FAILED,error:Error(`Concurrent export limit reached`)});return}let n=this._serializer.serializeRequest(e);if(n==null){t({code:L.FAILED,error:Error(`Nothing to send`)});return}this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(e=>{if(e.status===`success`){if(e.data!=null)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(e.data))}catch(t){this._diagLogger.warn(`Export succeeded but could not deserialize response - is the response specification compliant?`,t,e.data)}t({code:L.SUCCESS});return}else if(e.status===`failure`&&e.error){t({code:L.FAILED,error:e.error});return}else if(e.status===`retryable`){var n;t({code:L.FAILED,error:(n=e.error)==null?new Va(`Export failed with retryable status`):n})}else t({code:L.FAILED,error:new Va(`Export failed with unknown error`)})},e=>t({code:L.FAILED,error:e})))}forceFlush(){return this._promiseQueue.awaitAll()}shutdown(){var e=this;return z(function*(){e._diagLogger.debug(`shutdown started`),yield e.forceFlush(),e._transport.shutdown()})()}};function qa(e,t){return new Ka(e.transport,e.serializer,Ga(),e.promiseHandler,t.timeout)}function Ja(e,t,n){return qa({transport:n,serializer:t,promiseHandler:Ua(e)},{timeout:e.timeoutMillis})}var Ya=class e{constructor(e){this._config=e}static _compressRequest(e){return z(function*(){let t=new CompressionStream(`gzip`),n=t.writable.getWriter();n.write(e),n.close();let r=[],i=t.readable.getReader(),a=!1;for(;!a;){let e=yield i.read();e.value&&r.push(e.value),a=e.done}let o=new Uint8Array(r.reduce((e,t)=>e+t.length,0)),s=0;for(let e of r)o.set(e,s),s+=e.length;return o})()}send(e,t){return this._asyncSend(e,t)}shutdown(){}_asyncSend(t,n){var r=this;return z(function*(){let i=t,a=B({"Content-Type":`application/json`},r._config.headers);r._config.compression===`gzip`&&(i=yield e._compressRequest(t),a[`Content-Encoding`]=`gzip`,a[`Content-Length`]=i.length.toString());let o,s,c=`timeout`in AbortSignal,l=Number.isFinite(n)&&n>=0?Math.floor(n):1e4;if(c&&Number.isFinite(n)&&n>=0)o=AbortSignal.timeout(l);else{let e=new AbortController;o=e.signal,s=setTimeout(()=>{e.abort(new DOMException(`TimeoutError`,`TimeoutError`))},l)}try{var u;let t=Ut(w.active()),n=(u=e._baseFetch)==null?globalThis.fetch:u,s=yield w.with(t,()=>n(r._config.url,{method:`POST`,keepalive:!0,headers:a,body:i,signal:o}));return s.ok?{status:`success`}:{status:`failure`,error:Error(`${s.status} Fetch request failed`)}}catch(e){let t=Error(e instanceof Error?e.message:String(e));return t.name=`MXLExporterError`,t.cause=e,t.mxlExporter=!0,t.url=r._config.url,{status:`failure`,error:t}}finally{s!==void 0&&clearTimeout(s)}})()}};A(Ya,`_baseFetch`,typeof globalThis.fetch==`function`?globalThis.fetch.bind(globalThis):void 0);let Xa=e=>new Ya(e),Za=()=>Math.random()*40-20;var Qa=class{constructor(e,t=new bi){this._transport=e,this._perf=t}send(e,t){var n=this;return z(function*(){let r=n._perf.getNowMillis()+t,i=yield n._transport.send(e,t),a=5,o=1e3;for(;i.status===`retryable`&&a>0;){var s;a--;let t=Math.max(Math.min(o,5e3)+Za(),0);o*=1.5;let c=(s=i.retryInMillis)==null?t:s,l=r-n._perf.getNowMillis();if(c>l)return i;i=yield n._retry(e,l,c)}return i})()}shutdown(){this._transport.shutdown()}_retry(e,t,n){return new Promise((r,i)=>{setTimeout(()=>{this._transport.send(e,t).then(r,i)},n)})}};let $a=e=>{var t;return new Qa(e.transport,(t=e.perf)==null?new bi:t)},eo=(e,t)=>Ja(e,t,$a({transport:Xa(e)}));var to=class extends Ba{constructor(e){super(eo(e,Ra))}};let no=(e,t)=>`${oa(e,t)}/v1/logs`;var ro=class extends to{constructor({appID:e,userID:t,mxlDataURL:n}){super(B(B({},ia),{},{headers:aa(e,t),url:no(e,n)}))}},io=class extends Ba{constructor(e){super(eo(B(B({},e),{},{compression:`gzip`}),za))}};let ao=(e,t)=>`${oa(e,t)}/v1/traces`;var oo=class extends io{constructor({appID:e,userID:t,mxlDataURL:n}){super(B(B({},ia),{},{headers:aa(e,t),url:ao(e,n)}))}},q;(function(e){e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRACE=1]=`TRACE`,e[e.TRACE2=2]=`TRACE2`,e[e.TRACE3=3]=`TRACE3`,e[e.TRACE4=4]=`TRACE4`,e[e.DEBUG=5]=`DEBUG`,e[e.DEBUG2=6]=`DEBUG2`,e[e.DEBUG3=7]=`DEBUG3`,e[e.DEBUG4=8]=`DEBUG4`,e[e.INFO=9]=`INFO`,e[e.INFO2=10]=`INFO2`,e[e.INFO3=11]=`INFO3`,e[e.INFO4=12]=`INFO4`,e[e.WARN=13]=`WARN`,e[e.WARN2=14]=`WARN2`,e[e.WARN3=15]=`WARN3`,e[e.WARN4=16]=`WARN4`,e[e.ERROR=17]=`ERROR`,e[e.ERROR2=18]=`ERROR2`,e[e.ERROR3=19]=`ERROR3`,e[e.ERROR4=20]=`ERROR4`,e[e.FATAL=21]=`FATAL`,e[e.FATAL2=22]=`FATAL2`,e[e.FATAL3=23]=`FATAL3`,e[e.FATAL4=24]=`FATAL4`})(q||(q={}));var so=class{emit(e){}};let co=new so,lo=Symbol.for(`io.opentelemetry.js.api.logs`),uo=globalThis;function fo(e,t,n){return r=>r===e?t:n}let po=new class{getLogger(e,t,n){return new so}};var mo=class{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}emit(e){this._getLogger().emit(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):co}},ho=class{getLogger(e,t,n){var r;return(r=this._getDelegateLogger(e,t,n))==null?new mo(this,e,t,n):r}_getDelegate(){var e;return(e=this._delegate)==null?po:e}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,t,n){var r;return(r=this._delegate)==null?void 0:r.getLogger(e,t,n)}};let go=class e{constructor(){this._proxyLoggerProvider=new ho}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalLoggerProvider(e){return uo[lo]?this.getLoggerProvider():(uo[lo]=fo(1,e,po),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,t;return(t=(e=uo[lo])==null?void 0:e.call(uo,1))==null?this._proxyLoggerProvider:t}getLogger(e,t,n){return this.getLoggerProvider().getLogger(e,t,n)}disable(){delete uo[lo],this._proxyLoggerProvider=new ho}}.getInstance();function _o(e,t,n,r){for(let i=0,a=e.length;i<a;i++){let a=e[i];t&&a.setTracerProvider(t),n&&a.setMeterProvider(n),r&&a.setLoggerProvider&&a.setLoggerProvider(r),a.getConfig().enabled||a.enable()}}function vo(e){e.forEach(e=>e.disable())}function yo(e){var t,n;let r=e.tracerProvider||D.getTracerProvider(),i=e.meterProvider||mt.getMeterProvider(),a=e.loggerProvider||go.getLoggerProvider(),o=(t=(n=e.instrumentations)==null?void 0:n.flat())==null?[]:t;return _o(o,r,i,a),()=>{vo(o)}}let J=console.error.bind(console);function bo(e,t,n){let r=!!e[t]&&Object.prototype.propertyIsEnumerable.call(e,t);Object.defineProperty(e,t,{configurable:!0,enumerable:r,writable:!0,value:n})}let xo=(e,t,n)=>{if(!e||!e[t]){J(`no original function `+String(t)+` to wrap`);return}if(!n){J(`no wrapper function`),J(Error().stack);return}let r=e[t];if(typeof r!=`function`||typeof n!=`function`){J(`original object and wrapper must be functions`);return}let i=n(r,t);return bo(i,`__original`,r),bo(i,`__unwrap`,()=>{e[t]===i&&bo(e,t,r)}),bo(i,`__wrapped`,!0),bo(e,t,i),i},So=(e,t,n)=>{if(e)Array.isArray(e)||(e=[e]);else{J(`must provide one or more modules to patch`),J(Error().stack);return}if(!(t&&Array.isArray(t))){J(`must provide one or more functions to wrap on modules`);return}e.forEach(e=>{t.forEach(t=>{xo(e,t,n)})})},Co=(e,t)=>{if(!e||!e[t]){J(`no function to unwrap.`),J(Error().stack);return}let n=e[t];if(!n.__unwrap)J(`no original to unwrap to -- has `+String(t)+` already been unwrapped?`);else{n.__unwrap();return}},wo=(e,t)=>{if(e)Array.isArray(e)||(e=[e]);else{J(`must provide one or more modules to patch`),J(Error().stack);return}if(!(t&&Array.isArray(t))){J(`must provide one or more functions to unwrap on modules`);return}e.forEach(e=>{t.forEach(t=>{Co(e,t)})})};function To(e){e&&e.logger&&(typeof e.logger==`function`?J=e.logger:J(`new logger isn't a function, not replacing`))}To.wrap=xo,To.massWrap=So,To.unwrap=Co,To.massUnwrap=wo;var Eo=class{constructor(e,t,n){A(this,`_config`,{}),A(this,`_tracer`,void 0),A(this,`_meter`,void 0),A(this,`_logger`,void 0),A(this,`_diag`,void 0),A(this,`instrumentationName`,void 0),A(this,`instrumentationVersion`,void 0),A(this,`_wrap`,xo),A(this,`_unwrap`,Co),A(this,`_massWrap`,So),A(this,`_massUnwrap`,wo),this.instrumentationName=e,this.instrumentationVersion=t,this.setConfig(n),this._diag=T.createComponentLogger({namespace:e}),this._tracer=D.getTracer(e,t),this._meter=mt.getMeter(e,t),this._logger=go.getLogger(e,t),this._updateMetricInstruments()}get meter(){return this._meter}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){var e;let t=(e=this.init())==null?[]:e;return Array.isArray(t)?t:[t]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(e){this._config=B({enabled:!0},e)}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(e,t,n,r){if(e)try{e(n,r)}catch(e){this._diag.error(`Error running span customization hook due to exception in handler`,{triggerName:t},e)}}},Do=class extends Eo{constructor(e,t,n){super(e,t,n),this._config.enabled&&this.enable()}};function Oo(e,t,n){let r,i;try{i=e()}catch(e){r=e}finally{if(t(r,i),r&&!n)throw r;return i}}function ko(e){return typeof e==`function`&&typeof e.__original==`function`&&typeof e.__unwrap==`function`&&e.__wrapped===!0}var Y;(function(e){e[e.STABLE=1]=`STABLE`,e[e.OLD=2]=`OLD`,e[e.DUPLICATE=3]=`DUPLICATE`})(Y||(Y={}));function Ao(e,t){let n=Y.OLD,r=t==null?void 0:t.split(`,`).map(e=>e.trim()).filter(e=>e!==``);for(let t of r==null?[]:r)if(t.toLowerCase()===e+`/dup`){n=Y.DUPLICATE;break}else t.toLowerCase()===e&&(n=Y.STABLE);return n}let jo=`http.request.body.size`,Mo=`http.response.body.size`,No=`session.id`,Po=`user.id`;var Fo=class{constructor(e,t,n){this.instrumentationName=e,this.instrumentationVersion=t,A(this,`_config`,{}),A(this,`_diag`,void 0),A(this,`_tracer`,void 0),A(this,`_meter`,void 0),A(this,`_logger`,void 0),this.setConfig(n),this._diag=T.createComponentLogger({namespace:e}),this._tracer=D.getTracer(e,t),this._meter=mt.getMeter(e,t),this._logger=go.getLogger(e,t),this._updateMetricInstruments()}get tracer(){return this._tracer}get meter(){return this._meter}get logger(){return this._logger}getModuleDefinitions(){var e;let t=(e=this.init())==null?[]:e;return Array.isArray(t)?t:[t]}getConfig(){return this._config}setConfig(e){this._config=B({enabled:!0},e)}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}_updateMetricInstruments(){}_runSpanCustomizationHook(e,t,n,r){if(e)try{e(n,r)}catch(e){this._diag.error(`Error running span customization hook due to exception in handler`,{triggerName:t},e)}}},X=class extends Fo{constructor({instrumentationName:e,instrumentationVersion:t,config:n,diag:r,perf:i}){super(e,t,n),A(this,`_sessionManager`,void 0),A(this,`_logManager`,void 0),A(this,`_perf`,void 0),r&&(this._diag=r),this._perf=i==null?new bi:i,this._sessionManager=Vi.getSpanSessionManager(),this._logManager=Oi.getLogManager()}get sessionManager(){return this._sessionManager}get logManager(){return this._logManager}get perf(){return this._perf}init(){}setLogManager(e){this._logManager=e}setSessionManager(e){this._sessionManager=e}};let Io=function(e){return e.DOCUMENT_LOAD=`documentLoad`,e.DOCUMENT_FETCH=`documentFetch`,e.RESOURCE_FETCH=`resourceFetch`,e}({}),Lo=function(e){return e.FIRST_PAINT=`firstPaint`,e.FIRST_CONTENTFUL_PAINT=`firstContentfulPaint`,e}({}),Ro=()=>{let e={},t=window.performance.getEntriesByType(`navigation`)[0];return Object.values(U).forEach(n=>{if(ci(t,n)){let r=t[n];typeof r==`number`&&(e[n]=r)}}),e},zo={"first-paint":Lo.FIRST_PAINT,"first-contentful-paint":Lo.FIRST_CONTENTFUL_PAINT},Bo=e=>{window.performance.getEntriesByType(`paint`).forEach(({name:t,startTime:n})=>{ci(zo,t)&&e.addEvent(zo[t],n)})};var Vo=class extends X{constructor({diag:e,perf:t,enabled:n,applyCustomAttributesOnSpan:r,ignorePerformancePaintEvents:i=!1,ignoreNetworkEvents:a=!1}={}){super({instrumentationName:`DocumentLoadInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{enabled:n,applyCustomAttributesOnSpan:r,ignorePerformancePaintEvents:i,ignoreNetworkEvents:a}}),A(this,`_onDocumentLoaded`,void 0),A(this,`_performanceCollected`,!1),this._onDocumentLoaded=()=>{window.setTimeout(()=>{this._collectPerformance()},0)},this._config.enabled&&this.enable()}init(){this._diag.debug(`Initializing document load instrumentation`)}_addResourcesSpans(e){performance.getEntriesByType(`resource`).forEach(t=>{this._initResourceSpan(t,e)})}_collectPerformance(){if(this._performanceCollected)return;this._performanceCollected=!0;let e=Array.from(document.getElementsByTagName(`meta`)).find(e=>e.getAttribute(`name`)===Kn),t=Ro(),n=(e==null?void 0:e.content)||``;w.with(E.extract(y,{traceparent:n}),()=>{var e;let n=this._startSpan(Io.DOCUMENT_LOAD,U.FETCH_START,t);n&&(w.with(D.setSpan(w.active(),n),()=>{let e=this._startSpan(Io.DOCUMENT_FETCH,U.FETCH_START,t);e&&(e.setAttribute(M,location.href),w.with(D.setSpan(w.active(),e),()=>{var n;li(e,t,this.getConfig().ignoreNetworkEvents),this._addCustomAttributesOnSpan(e,(n=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:n.documentFetch),this._endSpan(e,U.RESPONSE_END,t)}))}),n.setAttribute(O,k.DocumentLoad),n.setAttribute(M,location.href),n.setAttribute(En,navigator.userAgent),this._addResourcesSpans(n),this.getConfig().ignoreNetworkEvents||(W(n,U.FETCH_START,t),W(n,U.UNLOAD_EVENT_START,t),W(n,U.UNLOAD_EVENT_END,t),W(n,U.DOM_INTERACTIVE,t),W(n,U.DOM_CONTENT_LOADED_EVENT_START,t),W(n,U.DOM_CONTENT_LOADED_EVENT_END,t),W(n,U.DOM_COMPLETE,t),W(n,U.LOAD_EVENT_START,t),W(n,U.LOAD_EVENT_END,t)),this.getConfig().ignorePerformancePaintEvents||Bo(n),this._addCustomAttributesOnSpan(n,(e=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:e.documentLoad),this._endSpan(n,U.LOAD_EVENT_END,t))})}_endSpan(e,t,n){e&&(ci(n,t)&&typeof n[t]==`number`?e.end(n[t]):e.end())}_initResourceSpan(e,t){var n;let r=this._startSpan(Io.RESOURCE_FETCH,U.FETCH_START,e,t);r&&(r.setAttribute(O,k.ResourceFetch),r.setAttribute(M,e.name),li(r,e,this.getConfig().ignoreNetworkEvents),e.deliveryType&&r.setAttribute(`http.response.delivery_type`,e.deliveryType),e.initiatorType&&r.setAttribute(`http.request.initiator_type`,e.initiatorType),e.renderBlockingStatus&&r.setAttribute(`http.request.render_blocking_status`,e.renderBlockingStatus),e.responseStatus&&r.setAttribute(yn,e.responseStatus),typeof e.encodedBodySize==`number`&&e.encodedBodySize>=0&&r.setAttribute(Mo,e.encodedBodySize),typeof e.transferSize==`number`&&e.transferSize>=0&&r.setAttribute(`http.response.size`,e.transferSize),typeof e.decodedBodySize==`number`&&e.decodedBodySize>=0&&r.setAttribute(`http.response.decoded_body_size`,e.decodedBodySize),this._addResourceDiagnosticAttributes(r,e),this._addCustomAttributesOnResourceSpan(r,e,(n=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:n.resourceFetch),this._endSpan(r,U.RESPONSE_END,e))}_startSpan(e,t,n,r){if(ci(n,t)&&typeof n[t]==`number`)return this.tracer.startSpan(e,{startTime:n[t]},r?D.setSpan(w.active(),r):void 0)}_waitForPageLoad(){window.document.readyState===`complete`?this._onDocumentLoaded():window.addEventListener(`load`,this._onDocumentLoaded)}_addCustomAttributesOnSpan(e,t){t&&Oo(()=>{t(e)},e=>{e&&this._diag.error(`addCustomAttributesOnSpan`,e)},!0)}_addCustomAttributesOnResourceSpan(e,t,n){n&&Oo(()=>{n(e,t)},e=>{e&&this._diag.error(`addCustomAttributesOnResourceSpan`,e)},!0)}_hasNoSizeData(e){let t=typeof e.transferSize==`number`?e.transferSize:0,n=typeof e.decodedBodySize==`number`?e.decodedBodySize:0,r=typeof e.encodedBodySize==`number`?e.encodedBodySize:0;return t===0&&n===0&&r===0}_hasTimingData(e){let t=typeof e.fetchStart==`number`?e.fetchStart:0,n=typeof e.responseEnd==`number`?e.responseEnd:0;return t>0&&n>0}_isCorsRestricted(e){return this._hasNoSizeData(e)&&this._hasTimingData(e)}_isFetchIncomplete(e){let t=typeof e.fetchStart==`number`?e.fetchStart:0,n=typeof e.responseEnd==`number`?e.responseEnd:0;return this._hasNoSizeData(e)&&t>0&&n===0}_isFetchPrevented(e){let t=typeof e.fetchStart==`number`?e.fetchStart:0;return this._hasNoSizeData(e)&&t===0}_isCacheValidated(e){let t=typeof e.transferSize==`number`?e.transferSize:0,n=typeof e.deliveryType==`string`?e.deliveryType:``;return t===300&&n!==`cache`}_addResourceDiagnosticAttributes(e,t){this._isCorsRestricted(t)?e.setAttribute(`http.response.cors_opaque`,!0):this._isFetchIncomplete(t)?e.setAttribute(`http.request.incomplete`,!0):this._isFetchPrevented(t)&&e.setAttribute(`http.request.prevented`,!0),this._isCacheValidated(t)&&e.setAttribute(`http.response.cache_revalidated`,!0)}enable(){window.removeEventListener(`load`,this._onDocumentLoaded),this._waitForPageLoad()}disable(){window.removeEventListener(`load`,this._onDocumentLoaded)}},Ho=class extends X{constructor({diag:e,perf:t,rootNode:n,emptyCheckDelayMs:r=500}){super({instrumentationName:`EmptyRootInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_observer`,void 0),A(this,`_emptyCheckDelayMs`,void 0),A(this,`_rootNode`,void 0),this._rootNode=n,this._emptyCheckDelayMs=r,this._observer=new MutationObserver((e,t)=>{this._observerCallback(e)}),this._config.enabled&&this._rootNode?this.enable():this._rootNode||this._diag.warn(`supplied root node was null, this instrumentation won't be enabled`)}disable(){this._observer.disconnect()}enable(){this._rootNode&&this._observer.observe(this._rootNode,{childList:!0})}_observerCallback(e){let t=!1,n=!1;for(let r of e)r.target===this._rootNode&&(r.removedNodes.length>0&&(t=!0),r.addedNodes.length>0&&(n=!0));t&&!n&&(this._diag.debug(`root node had child nodes removed without new ones being added, checking if it's empty in ${this._emptyCheckDelayMs}ms`),window.setTimeout(()=>{this._checkForEmptyRootNode()},this._emptyCheckDelayMs))}_checkForEmptyRootNode(){var e;if(((e=this._rootNode)==null?void 0:e.childNodes.length)===0){this._diag.debug(`root node was found to be empty`);let e=this.sessionManager.getSessionSpan();e?e.addEvent(`empty-root-node`,{"mxl.type":`ux.empty_root_node`}):this._diag.debug(`no active session found to emit event on`)}}};let Uo=(e,t)=>{let n=e.nodeName.toLowerCase(),r=t.substring(0,30),i=t.length>30?`...`:``;return`<${n}${e.className?` class="${e.className}"`:``}>${r}${i}</${n}>`};var Wo=class extends X{constructor({diag:e,perf:t,shouldTrack:n,innerTextForElement:r}={}){super({instrumentationName:`ClicksInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_onClickHandler`,void 0),this._onClickHandler=e=>{let t=e.target;if(t instanceof HTMLElement&&!t.hasAttribute(`disabled`)&&!(n&&!n(t)))try{let n=this.sessionManager.getSessionSpan();n&&n.addEvent(`click`,{"mxl.type":`ux.tap`,"view.name":Uo(t,r?r(t):t.innerText),"tap.coords":`${e.x.toString()},${e.y.toString()}`},this.perf.epochMillisFromOriginOffset(e.timeStamp))}catch(e){this._diag.error(`failed to create new user interaction span event`,e)}},this._config.enabled&&this.enable()}disable(){document.removeEventListener(`click`,this._onClickHandler)}enable(){document.addEventListener(`click`,this._onClickHandler)}},Go=class extends X{constructor({diag:e,perf:t}={}){super({instrumentationName:`GlobalExceptionInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_onErrorHandler`,void 0),A(this,`_onUnhandledRejectionHandler`,void 0),this._onErrorHandler=e=>{this.logManager.logException(e.error||e.message,{handled:!1,timestamp:this.perf.epochMillisFromOriginOffset(e.timeStamp),handler:`global_exception`})},this._onUnhandledRejectionHandler=e=>{this.logManager.logException(e.reason,{handled:!1,timestamp:this.perf.epochMillisFromOriginOffset(e.timeStamp),handler:`promise_rejection`})},this._config.enabled&&this.enable()}disable(){window.removeEventListener(`error`,this._onErrorHandler),window.removeEventListener(`unhandledrejection`,this._onUnhandledRejectionHandler)}enable(){window.addEventListener(`error`,this._onErrorHandler),window.addEventListener(`unhandledrejection`,this._onUnhandledRejectionHandler)}},Ko;(function(e){e.COMPONENT=`component`,e.HTTP_STATUS_TEXT=`http.status_text`})(Ko||(Ko={}));let qo=T.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-fetch/utils`});function Jo(...e){if(e[0]instanceof URL||typeof e[0]==`string`){let t=e[1];if(!(t!=null&&t.body))return Promise.resolve();if(t.body instanceof ReadableStream){let{body:e,length:n}=Yo(t.body);return t.body=e,n}else return Promise.resolve(Zo(t.body))}else{let t=e[0];return t!=null&&t.body?t.clone().text().then(e=>$o(e)):Promise.resolve()}}function Yo(e){if(!e.pipeThrough)return qo.warn(`Platform has ReadableStream but not pipeThrough!`),{body:e,length:Promise.resolve(void 0)};let t=0,n,r=new Promise(e=>{n=e}),i=new TransformStream({start(){},transform(e,n){return z(function*(){let r=yield e;t+=r.byteLength,n.enqueue(e)})()},flush(){n(t)}});return{body:e.pipeThrough(i),length:r}}function Xo(e){return typeof Document<`u`&&e instanceof Document}function Zo(e){if(Xo(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return $o(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return es(e);if(e instanceof URLSearchParams)return $o(e.toString());if(e.byteLength!==void 0)return e.byteLength;qo.warn(`unknown body type`)}let Qo=new TextEncoder;function $o(e){return Qo.encode(e).byteLength}function es(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function ts(e){let t=is(),n=e.toUpperCase();return n in t?n:`_OTHER`}let ns={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},rs;function is(){return rs===void 0&&(rs=ns),rs}let as={"https:":`443`,"http:":`80`};function os(e){let t=Number(e.port||as[e.protocol]);if(t&&!isNaN(t))return t}let ss=`0.211.0`,cs=typeof PerformanceObserver<`u`;var ls=class extends Do{constructor(e={}){super(`@opentelemetry/instrumentation-fetch`,ss,e),A(this,`component`,`fetch`),A(this,`version`,ss),A(this,`moduleName`,this.component),A(this,`_usedResources`,new WeakSet),A(this,`_tasksCount`,0),A(this,`_semconvStability`,void 0),this._semconvStability=Ao(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_addChildSpan(e,t){let n=this.tracer.startSpan(`CORS Preflight`,{startTime:t[U.FETCH_START]},D.setSpan(w.active(),e)),r=!(this._semconvStability&Y.OLD);li(n,t,this.getConfig().ignoreNetworkEvents,void 0,r),n.end(t[U.RESPONSE_END])}_addFinalSpanAttributes(e,t){let n=G(t.url);if(this._semconvStability&Y.OLD&&(e.setAttribute(`http.status_code`,t.status),t.statusText!=null&&e.setAttribute(Ko.HTTP_STATUS_TEXT,t.statusText),e.setAttribute(`http.host`,n.host),e.setAttribute(`http.scheme`,n.protocol.replace(`:`,``)),typeof navigator<`u`&&e.setAttribute(`http.user_agent`,navigator.userAgent)),this._semconvStability&Y.STABLE){e.setAttribute(yn,t.status),e.setAttribute(bn,n.hostname);let r=os(n);r&&e.setAttribute(xn,r)}}_addHeaders(e,t){if(!hi(t,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};E.inject(w.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}if(e instanceof Request)E.inject(w.active(),e.headers,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))});else if(e.headers instanceof Headers)E.inject(w.active(),e.headers,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))});else if(e.headers instanceof Map)E.inject(w.active(),e.headers,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))});else{let t={};E.inject(w.active(),t),e.headers=Object.assign({},t,e.headers||{})}}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(e,t={}){if(br(e,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let n=``,r={};if(this._semconvStability&Y.OLD){let i=(t.method||`GET`).toUpperCase();n=`HTTP ${i}`,r[Ko.COMPONENT]=this.moduleName,r[`http.method`]=i,r[`http.url`]=e}if(this._semconvStability&Y.STABLE){let i=t.method,a=ts(t.method||`GET`);n||(n=a),r[_n]=a,a!==i&&(r[vn]=i),r[M]=e}return this.tracer.startSpan(n,{kind:ut.CLIENT,attributes:r})}_findResourceAndAddNetworkEvents(e,t,n){let r=t.entries;if(!r.length){if(!performance.getEntriesByType)return;r=performance.getEntriesByType(`resource`)}let i=fi(t.spanUrl,t.startTime,n,r,this._usedResources,`fetch`);if(i.mainRequest){let t=i.mainRequest;this._markResourceAsUsed(t);let n=i.corsPreFlightRequest;n&&(this._addChildSpan(e,n),this._markResourceAsUsed(n));let r=!(this._semconvStability&Y.OLD);li(e,t,this.getConfig().ignoreNetworkEvents,void 0,r)}}_markResourceAsUsed(e){this._usedResources.add(e)}_endSpan(e,t,n){let r=P(Date.now()),i=An();this._addFinalSpanAttributes(e,n),this._semconvStability&Y.STABLE&&n.status>=400&&(e.setStatus({code:dt.ERROR}),e.setAttribute(pn,String(n.status))),setTimeout(()=>{var n;(n=t.observer)==null||n.disconnect(),this._findResourceAndAddNetworkEvents(e,t,i),this._tasksCount--,this._clearResources(),e.end(r)},300)}_patchConstructor(){return e=>{let t=this;return function(...n){let r=this,i=G(n[0]instanceof Request?n[0].url:String(n[0])).href,a=n[0]instanceof Request?n[0]:n[1]||{},o=t._createSpan(i,a);if(!o)return e.apply(this,n);let s=t._prepareSpanData(i);t.getConfig().measureRequestSize&&Jo(...n).then(e=>{e&&(t._semconvStability&Y.OLD&&o.setAttribute(`http.request_content_length_uncompressed`,e),t._semconvStability&Y.STABLE&&o.setAttribute(`http.request.body.size`,e))}).catch(e=>{t._diag.warn(`getFetchBodyLength`,e)});function c(e,n){t._applyAttributesAfterFetch(e,a,n),t._endSpan(e,s,{status:n.status||0,statusText:n.message,url:i})}function l(e,n){t._applyAttributesAfterFetch(e,a,n),n.status>=200&&n.status<400?t._endSpan(e,s,n):t._endSpan(e,s,{status:n.status,statusText:n.statusText,url:i})}function u(e,t){if(!e)return null;let n=e.getReader();return new ReadableStream({pull(e){return z(function*(){try{let{value:t,done:r}=yield n.read();r?(n.releaseLock(),e.close()):e.enqueue(t)}catch(t){e.error(t),n.cancel(t).catch(e=>{});try{n.releaseLock()}catch(e){}}})()},cancel(e){return t.cancel(e).catch(e=>{}),n.cancel(e)}})}function d(e,t,n){let r=null;try{let t=n.clone().body;if(t){let i=t.getReader(),a=n.status===204||n.status===205||n.status===304?null:u(n.body,i);r=new Response(a,{status:n.status,statusText:n.statusText,headers:n.headers});let o=()=>{i.read().then(({done:t})=>{t?l(e,n):o()},t=>{c(e,t)})};o()}else l(e,n)}finally{var i;t((i=r)==null?n:i)}}function f(e,t,n){try{c(e,n)}finally{t(n)}}return new Promise((n,s)=>w.with(D.setSpan(w.active(),o),()=>(t._addHeaders(a,i),t._callRequestHook(o,a),t._tasksCount++,e.apply(r,a instanceof Request?[a]:[i,a]).then(d.bind(r,o,n),f.bind(r,o,s)))))}}}_applyAttributesAfterFetch(e,t,n){let r=this.getConfig().applyCustomAttributesOnSpan;r&&Oo(()=>r(e,t,n),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_callRequestHook(e,t){let n=this.getConfig().requestHook;n&&Oo(()=>n(e,t),e=>{e&&this._diag.error(`requestHook`,e)},!0)}_prepareSpanData(e){let t=An(),n=[];if(typeof PerformanceObserver!=`function`)return{entries:n,startTime:t,spanUrl:e};let r=new PerformanceObserver(t=>{t.getEntries().forEach(t=>{t.initiatorType===`fetch`&&t.name===e&&n.push(t)})});return r.observe({entryTypes:[`resource`]}),{entries:n,observer:r,startTime:t,spanUrl:e}}enable(){if(!cs){this._diag.warn(`this instrumentation is intended for web usage only, it does not instrument server-side fetch()`);return}ko(fetch)&&(this._unwrap(globalThis,`fetch`),this._diag.debug(`removing previous patch for constructor`)),this._wrap(globalThis,`fetch`,this._patchConstructor())}disable(){cs&&(this._unwrap(globalThis,`fetch`),this._usedResources=new WeakSet)}};function us(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function ds(e,t){if(e==null)return{};var n,r,i=us(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}let fs=[`omitIfAlreadyPatched`];var ps=class extends ls{constructor(e={}){let{omitIfAlreadyPatched:t}=e,n=ds(e,fs);super(B(B({},n),{},{enabled:!1})),A(this,`_omitIfAlreadyPatched`,void 0),this._omitIfAlreadyPatched=t,n.enabled&&this.enable()}enable(){if(this._omitIfAlreadyPatched&&ko(fetch)){this._diag.debug("fetch is already passed and `omitIfAlreadyPatched` is true, skipping enabling this instrumentation");return}super.enable()}};let ms=/\([^()]+\)/g;var hs=class extends X{constructor({diag:e,shouldCleanupPathOptionsFromRouteName:t=!0}){super({instrumentationName:`NavigationInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,config:{}}),A(this,`_shouldCleanupPathOptionsFromRouteName`,!0),A(this,`_currentRouteSpan`,null),A(this,`_instrumentationType`,Lt.Manual),A(this,`_removeSessionStartedFn`,null),A(this,`_removeSessionEndedFn`,null),A(this,`setInstrumentationType`,e=>{this._instrumentationType=e}),A(this,`setCurrentRoute`,e=>{if(!this._config.enabled)return;let t=K.getCurrentRoute();e.url!==(t==null?void 0:t.url)&&(K.setCurrentRoute(e),this._endRouteSpan(t),this._startRouteSpan(e))}),A(this,`_setupSessionListeners`,()=>{this._removeSessionStartedFn||(this._removeSessionStartedFn=this.sessionManager.addSessionStartedListener(()=>{let e=K.getCurrentRoute();e&&!this._currentRouteSpan&&(this._diag.debug(`Session started, starting route span.`),this._startRouteSpan(e))})),this._removeSessionEndedFn||(this._removeSessionEndedFn=this.sessionManager.addSessionEndedListener(()=>{this._currentRouteSpan&&(this._diag.debug(`Session ended, ending route span.`),this._endRouteSpan(K.getCurrentRoute()))}))}),A(this,`_cleanUpSessionListeners`,()=>{this._removeSessionStartedFn&&(this._removeSessionStartedFn(),this._removeSessionStartedFn=null),this._removeSessionEndedFn&&(this._removeSessionEndedFn(),this._removeSessionEndedFn=null)}),A(this,`_startRouteSpan`,e=>{this._diag.debug(`Starting route span for url: ${e.url}`),this._setupSessionListeners();let t=this._shouldCleanupPathOptionsFromRouteName?e.path.replace(ms,``):e.path;return this._currentRouteSpan=this.tracer.startSpan(t,{attributes:{[O]:k.Surface,[Pt]:t,[Ft]:K.getCurrentPageId()||void 0}}),this._currentRouteSpan.setAttribute(`mxl.instrumentation`,this._instrumentationType),this._currentRouteSpan}),A(this,`_endRouteSpan`,e=>{this._currentRouteSpan&&(e&&this._diag.debug(`Ending route span for url: ${e.url}`),this._currentRouteSpan.end(),this._currentRouteSpan=null)}),A(this,`enable`,()=>{this.setConfig({enabled:!0}),this._diag.debug(`NavigationInstrumentation enabled, listening for navigation events.`)}),A(this,`disable`,()=>{this._cleanUpSessionListeners(),this.setConfig({enabled:!1}),this._diag.debug(`NavigationInstrumentation disabled, stopped listening for navigation events.`)}),this._shouldCleanupPathOptionsFromRouteName=t,this._config.enabled&&this.enable()}};let gs,_s=(e={})=>(gs||(gs=new hs(e)),gs),vs={samplingPct:100,networkSpansForwardingThreshold:0},ys=`mxl_remote_config`,bs=(e,{osVersion:t,appVersion:n,deviceId:r},i)=>`${i||`https://mxl-basket.apps.ocpthikadev01.safaricom.net`}/config?appId=${e}&osVersion=${t}&appVersion=${n}&deviceId=${r}`,xs=e=>{let t={samplingPct:e.threshold};return e.network_span_forwarding!==void 0&&(t.networkSpansForwardingThreshold=e.network_span_forwarding.pct_enabled),e.empty_session_avoidance_enabled_pct!==void 0&&(t.emptySessionAvoidanceEnabledPct=e.empty_session_avoidance_enabled_pct),t};var Ss=class{constructor({appID:e,appVersion:t,deviceId:n,diag:r=T.createComponentLogger({namespace:`mxl-config-manager`}),storage:i=window.localStorage,defaultConfig:a={},mxlConfigURL:o}={}){A(this,`_remoteConfigURL`,null),A(this,`_diag`,void 0),A(this,`_storage`,void 0),A(this,`_sdkConfig`,void 0),A(this,`_etag`,null),e&&t&&n&&(this._remoteConfigURL=bs(e,{appVersion:t,deviceId:n,osVersion:`1`},o)),this._diag=r,this._storage=i;let s=this._getRemoteConfigFromStorage();s&&(this._etag=s.etag),this._sdkConfig=B(B(B({},vs),a),s?xs(s.config):{})}setConfig(e){this._sdkConfig=B(B({},this._sdkConfig),e)}getConfig(){return this._sdkConfig}refreshRemoteConfig(){var e=this;return z(function*(){if(e._remoteConfigURL)try{let t=yield e._fetchRemoteConfig(e._remoteConfigURL);if(!t){e._diag.debug(`No changes in remote config, skipping update`);return}let[n,r]=t;e._storage.setItem(ys,JSON.stringify({config:n,etag:r})),e._sdkConfig=xs(n),e._etag=r}catch(t){e._diag.warn(`Failed to refresh remote config: ${t instanceof Error?t.message:String(t)}`)}})()}_getRemoteConfigFromStorage(){try{let e=this._storage.getItem(ys);return e?JSON.parse(e):null}catch(e){return this._diag.warn(`Failed to parse remote config from storage: ${e instanceof Error?e.message:String(e)}`),null}}_fetchRemoteConfig(e){var t=this;return z(function*(){let n=yield fetch(e,{headers:t._etag?{"If-None-Match":t._etag}:{}}),r=n.headers.get(`etag`);return n.status===304?null:n.ok?[yield n.json(),r]:(t._diag.warn(`Failed to fetch remote config from ${e}: ${n.statusText}`),null)})()}};let Cs={maxAllowed:{error_log:500,warning_log:200,info_log:100,exception:500,breadcrumb:100,session_property:100,span:1e3,network_request:1e4},maxLength:{error_log:128,warning_log:128,info_log:128,exception:1024,breadcrumb:256,session_property_key:128,session_property_value:256,log_attribute_key:128,log_attribute_value:256,exception_attribute_key:128,exception_attribute_value:256},maxAttributes:{error_log:50,warning_log:50,info_log:50,exception:50}},ws={info:`info_log`,warning:`warning_log`,error:`error_log`};var Ts=class{constructor({diag:e,maxAllowed:t,maxLength:n,maxAttributes:r}){A(this,`_diag`,void 0),A(this,`_diagnosticCounts`,{}),A(this,`_currentCount`,{exception:0,error_log:0,warning_log:0,info_log:0,breadcrumb:0,session_property:0,span:0,network_request:0}),A(this,`_maxAllowed`,void 0),A(this,`_maxLength`,void 0),A(this,`_maxAttributes`,void 0),this._diag=e==null?T.createComponentLogger({namespace:`MXLLimitManager`}):e,this._maxAllowed=t,this._maxLength=n,this._maxAttributes=r}_dropIfMaxReached(e){return this._currentCount[e]>=this._maxAllowed[e]?(this._diag.warn(`disallowing ${e} because the maximum number of ${this._maxAllowed[e].toString()} has already been reached for this session`),this._incrDiagnosticCount(e,`drop`),!0):(this._currentCount[e]=(this._currentCount[e]||0)+1,!1)}truncateString(e,t){return t.length>this._maxLength[e]?(this._diag.warn(`truncating ${e} because it is longer than ${this._maxLength[e].toString()} characters: "${t}"`),this._incrDiagnosticCount(e,`truncate_string`),t.substring(0,this._maxLength[e])):t}_truncateAttributes(e,t,n,r){let i=Object.keys(t);i.length>this._maxAttributes[e]&&(this._diag.warn(`truncating ${e} attributes because there are more than ${this._maxAttributes[e].toString()} set`),this._incrDiagnosticCount(e,`truncate_attributes`));let a={};for(let s=0;s<Math.min(i.length,this._maxAttributes[e]);s++){var o;let e=this.truncateString(n,i[s]);a[e]=this.truncateString(r,((o=t[i[s]])==null?void 0:o.toString())||``)}return a}limitBreadcrumb(e){return this._dropIfMaxReached(`breadcrumb`)?`dropped`:{name:this.truncateString(`breadcrumb`,e)}}limitException(e,t){return this._dropIfMaxReached(`exception`)?`dropped`:{message:this.truncateString(`exception`,e),attributes:this._truncateAttributes(`exception`,t,`exception_attribute_key`,`exception_attribute_value`)}}limitLog(e,t,n){let r=ws[t];return this._dropIfMaxReached(r)?`dropped`:{message:this.truncateString(r,e),attributes:this._truncateAttributes(r,n,`log_attribute_key`,`log_attribute_value`)}}limitSessionProperty(e,t){return this._dropIfMaxReached(`session_property`)?`dropped`:{key:this.truncateString(`session_property_key`,e),value:this.truncateString(`session_property_value`,t)}}dropReadableSpan(e){let t=e.attributes[O]===k.Network?`network_request`:`span`;return this._dropIfMaxReached(t)}reset(){this._diagnosticCounts={},this._currentCount={exception:0,error_log:0,warning_log:0,info_log:0,breadcrumb:0,session_property:0,span:0,network_request:0}}_incrDiagnosticCount(e,t){let n=`mxl.app.applied_limit.${e}.${t}.count`;this._diagnosticCounts[n]=(this._diagnosticCounts[n]||0)+1}getDiagnosticCounts(){return this._diagnosticCounts}};let Es=()=>JSON.stringify(zt._MXLFileBundleIDs||{});var Ds=class e{constructor({diag:e,perf:t,spanSessionManager:n,limitManager:r,loggerProvider:i,visibilityDoc:a=window.document,storage:o=window.localStorage}){A(this,`_diag`,void 0),A(this,`_perf`,void 0),A(this,`_logger`,void 0),A(this,`_spanSessionManager`,void 0),A(this,`_limitManager`,void 0),A(this,`_visibilityDoc`,void 0),A(this,`_storage`,void 0);let s=i==null?go:i;this._diag=e==null?T.createComponentLogger({namespace:`MXLLogManager`}):e,this._perf=t==null?new bi:t,this._logger=s.getLogger(`mxl-web-sdk-logs`),this._spanSessionManager=n,this._limitManager=r,this._visibilityDoc=a,this._storage=o}_validateAttributes(e){return Object.prototype.toString.call(e)===`[object Object]`?e:(this._diag.warn(`attributes must be a plain object`,e),{})}static _logSeverityToSeverityNumber(e){switch(e){case`info`:return q.INFO;case`warning`:return q.WARN;default:return q.ERROR}}logException(t,{handled:n=!0,attributes:r={},timestamp:i=this._perf.getNowMillis(),handler:a=`manual`}={}){var o;let s=this._validateAttributes(r);n||this._spanSessionManager.incrSessionCountForKey(`mxl.unhandled_exceptions_count`);let c=(t==null||(o=t.constructor)==null?void 0:o.name)||typeof t,l=``,u=c,d=``,f=``;if(t instanceof Error)l=String(t.message||``).trim(),u=t.name||``,d=t.stack||``,f=t.cause?`present`:``;else if(t&&typeof t==`object`)try{l=JSON.stringify(t)}catch(e){l=String(t).trim()}else l=String(t).trim();let p=this._limitManager.limitException(l,s);p!==`dropped`&&this._logger.emit({timestamp:i,severityNumber:q.ERROR,severityText:`ERROR`,body:p.message,attributes:B(B({},p.attributes),{},{[O]:k.SystemException,"mxl.exception_handling":e._exceptionHandlingType(n,a),"mxl.exception_cause":f,[gn]:c,"exception.name":u,[mn]:p.message,[hn]:d,[Nt]:Es(),[jt]:Rt(this._visibilityDoc),"mxl.exception_number":At(this._storage,`mxl_exception_number`,this._diag)})})}message(e,t,{attributes:n={},includeStacktrace:r=!0,stacktrace:i}={}){if(typeof e!=`string`||!e.trim()){this._diag.warn(`Message must be a non-empty string`);return}if(![`info`,`warning`,`error`].includes(t)){this._diag.warn(`Severity must be info, warning, or error`);return}let a=this._validateAttributes(n);t===`error`&&this._spanSessionManager.incrSessionCountForKey(`mxl.error_log_count`);let o=``;t!==`info`&&(typeof i==`string`?o=i:r&&(o=Error().stack||``)),this._logMessage({message:e.trim(),severity:t,timestamp:this._perf.getNowMillis(),attributes:a,stack:o})}_logMessage({message:t,severity:n,timestamp:r,attributes:i={},stack:a}){let o=this._limitManager.limitLog(t,n,i);o!==`dropped`&&this._logger.emit({timestamp:r,severityNumber:e._logSeverityToSeverityNumber(n),severityText:n.toUpperCase(),body:o.message,attributes:B(B(B({},o.attributes),{},{[O]:k.SystemLog},a?{"mxl.stacktrace.js":a,[Nt]:Es()}:{}),{},{[jt]:Rt(this._visibilityDoc)})})}static _exceptionHandlingType(e,t){return e?`handled`:t===`global_exception`?`unhandled_error`:t===`promise_rejection`?`unhandled_rejection`:`unhandled`}},Os=class{constructor(){A(this,`_currentRoute`,null),A(this,`_currentPageId`,null),A(this,`getCurrentPageId`,()=>this._currentPageId),A(this,`getCurrentRoute`,()=>this._currentRoute),A(this,`setCurrentRoute`,e=>{(!this._currentRoute||this._currentRoute.url!==e.url)&&(this._currentPageId=kt()),this._currentRoute=e}),A(this,`clearCurrentRoute`,()=>{this._currentRoute=null,this._currentPageId=null})}},ks=class{constructor({dynamicConfigManager:e,deviceId:t,blockNetworkSpanForwarding:n}){A(this,`_dynamicConfigManager`,void 0),A(this,`_deviceId`,void 0),A(this,`_blockNetworkSpanForwarding`,void 0),this._dynamicConfigManager=e,this._deviceId=t,this._blockNetworkSpanForwarding=n}isSDKEnabled(){let e=this._dynamicConfigManager.getConfig();return Bt(this._deviceId,e.samplingPct)}isNetworkSpanForwardingEnabled(){if(this._blockNetworkSpanForwarding)return!1;let e=this._dynamicConfigManager.getConfig();return Bt(this._deviceId,e.networkSpansForwardingThreshold)}isEmptySessionAvoidanceEnabled(){let e=this._dynamicConfigManager.getConfig();return Bt(this._deviceId,e.emptySessionAvoidanceEnabledPct)}};let As=`0.0.0`,js=`mxl-web-sdk`,Ms=`mxl_app_instance_id`,Ns=(e,t)=>{let n=null;try{n=e.getItem(Ms)}catch(e){t.warn(`Failed to retrieve app instance ID from session storage`,e)}if(!n){t.debug(`No existing app instance ID found in session storage, creating a new one`),n=kt();try{e.setItem(Ms,n)}catch(e){t.warn(`Failed to persist app instance ID to session storage`,e)}}return n},Ps=({diagLogger:e,appVersion:t,pageSessionStorage:n})=>Ar({[Sn]:js,[wn]:js,app_version:t,app_framework:1,sdk_version:As,[Tn]:As,sdk_simple_version:1,sdk_platform:`web`,[Cn]:`webjs`,"mxl.app_instance_id":Ns(n,e),[En]:window.navigator.userAgent,screen_resolution:`${window.screen.width}x${window.screen.height}`});var Fs=class{constructor(e){A(this,`_span`,void 0),this._span=e}get attributes(){return this._span.attributes}addEvent(e,t,n){return this._span.addEvent(e,t,n),this}addLink(e){return this._span.addLink(e),this}addLinks(e){return this._span.addLinks(e),this}end(e){this._span.end(e)}isRecording(){return this._span.isRecording()}recordException(e,t){this._span.recordException(e,t)}setAttribute(e,t){return this._span.setAttribute(e,t),this}setAttributes(e){return this._span.setAttributes(e),this}removeAttribute(e){let t=this._span.attributes,{[e]:n}=t,r=ds(t,[e].map(Qt));return this._span.attributes=r,this}setStatus(e){return this._span.setStatus(e),this}spanContext(){return this._span.spanContext()}updateName(e){return this._span.updateName(e),this}fail(e={code:`failure`}){e.code&&this._span.setAttribute(`mxl.error_code`,e.code.toUpperCase()),this._span.end(e.endTime)}};let Is=`mxl_tab`,Ls=`mxl_tab_activity`;var Rs=class{constructor({diag:e,perf:t,visibilityDoc:n=window.document,storage:r=window.localStorage,sessionStorage:i=window.sessionStorage,limitManager:a,referrer:o=document.referrer}){A(this,`_previousSessionId`,null),A(this,`_activeSessionId`,null),A(this,`_activeSessionStartTime`,null),A(this,`_sessionSpan`,null),A(this,`_activeSessionCounts`,null),A(this,`_nextSessionCounts`,{}),A(this,`_coldStart`,!0),A(this,`_sdkStartupDuration`,0),A(this,`_sessionStartedListeners`,[]),A(this,`_sessionEndedListeners`,[]),A(this,`_tab`,void 0),A(this,`_navigationSource`,void 0),A(this,`_referrerInfo`,void 0),A(this,`_tracer`,void 0),A(this,`_noExportTracer`,void 0),A(this,`_diag`,void 0),A(this,`_perf`,void 0),A(this,`_visibilityDoc`,void 0),A(this,`_storage`,void 0),A(this,`_sessionStorage`,void 0),A(this,`_limitManager`,void 0),A(this,`_referrer`,void 0),this._diag=e==null?T.createComponentLogger({namespace:`MXLSpanSessionManager`}):e,this._perf=t==null?new bi:t,this._visibilityDoc=n,this._storage=r,this._sessionStorage=i,this._limitManager=a,this._referrer=o,this._tracer=D.getTracer(`mxl-web-sdk-sessions`),this._noExportTracer=new ti().getTracer(`mxl-web-sdk-sessions`),this._referrerInfo=this._processReferrer();let s=this._initTab();this._tab=s.tab,this._navigationSource=s.navigationSource,this._setupNewTabClickListeners()}_getPermanentAttributes(){let e=new Map;try{for(let t=0;t<this._storage.length;t++){let n=this._storage.key(t);if(n!=null&&n.startsWith(Mt)){let t=this._storage.getItem(n);t&&e.set(n,t)}}}catch(e){this._diag.warn(`Error loading permanent session properties`,e)}return Object.fromEntries(e.entries())}addBreadcrumb(e){if(!this._sessionSpan){this._diag.debug(`trying to add breadcrumb to a session, but there is no session in progress. This is a no-op.`);return}let t=this._limitManager.limitBreadcrumb(e);t!==`dropped`&&this._sessionSpan.addEvent(`mxl-breadcrumb`,{message:t.name},this._perf.getNowMillis())}addProperty(e,t,n){if(!this._sessionSpan){this._diag.debug(`trying to add properties to a session, but there is no session in progress. This is a no-op.`);return}let r=this._limitManager.limitSessionProperty(e,t);if(r===`dropped`)return;let i=Mt+r.key;if(this._sessionSpan.setAttribute(i,r.value),(n==null?void 0:n.lifespan)===`permanent`)try{this._storage.setItem(i,t)}catch(e){this._diag.warn(`Failed to set permanent session property`,e)}}removeProperty(e){if(!this._sessionSpan){this._diag.debug(`trying to remove a session property, but there is no session in progress. This is a no-op.`);return}let t=Mt+this._limitManager.truncateString(`session_property_key`,e);this._sessionSpan.removeAttribute(t);try{this._storage.getItem(t)&&this._storage.removeItem(t)}catch(e){this._diag.warn(`Error removing permanent session property`,e)}}endSessionSpan(){this.endSessionSpanInternal(`manual`)}endSessionSpanInternal(e){if(!this._sessionSpan){this._diag.debug(`trying to end a session, but there is no session in progress. This is a no-op.`);return}for(let e of this._sessionEndedListeners)try{e()}catch(e){this._diag.warn(`Error while executing session ended listener`,e)}this._sessionSpan.setAttributes(this._endSessionSpanAttributes(e)),this._sessionSpan.end(),this._sessionSpan=null,this._activeSessionStartTime=null,this._previousSessionId=this._activeSessionId,this._activeSessionId=null,this._activeSessionCounts=null,this._limitManager.reset()}_endSessionSpanAttributes(e){return B(B(B(B({},this._getPermanentAttributes()),{},{"mxl.session_end_type":e},this._activeSessionCounts),this._limitManager.getDiagnosticCounts()),{},{"mxl.sdk_startup_duration":this._sdkStartupDuration})}currentSessionAsReadableSpan(e){if(!this._sessionSpan||!this._activeSessionStartTime)return this._diag.debug(`trying to end a session, but there is no session in progress. This is a no-op.`),null;let t=this._noExportTracer.startSpan(`mxl-session`,{startTime:this._activeSessionStartTime,attributes:B(B(B({},this._sessionSpan.attributes),this._endSessionSpanAttributes(e)),{},{"mxl.from_storage":!0})});return t.end(),t}getSessionId(){return this._activeSessionId}getPreviousSessionId(){return this._previousSessionId}getSessionSpan(){return this._sessionSpan}getSessionStartTime(){return this._activeSessionStartTime}startSessionSpan(e){this._sessionSpan&&this.endSessionSpanInternal(`manual`),this._activeSessionId=kt(),this._activeSessionStartTime=this._perf.getNowHRTime(),this._activeSessionCounts={};let t=this._nextSessionCounts;this._nextSessionCounts={};let n=B(B({},this._getPermanentAttributes()),{},{[O]:k.Session,[jt]:Rt(this._visibilityDoc),[No]:this._activeSessionId,"mxl.cold_start":this._coldStart,"mxl.session_number":At(this._storage,`mxl_session_number`,this._diag),"mxl.experience_id":this._tab.experienceId,"mxl.tab_id":this._tab.tabId,"mxl.navigation_source":this._navigationSource},t);this._referrerInfo.isValid&&this._referrerInfo.scrubbedUrl&&(n[`mxl.referrer_url`]=this._referrerInfo.scrubbedUrl),this._tab.sourceTabId&&(n[`mxl.source_tab_id`]=this._tab.sourceTabId),e!=null&&e.reason&&(n[`mxl.session_start_type`]=e.reason),this._sessionSpan=new Fs(this._tracer.startSpan(`mxl-session`,{attributes:n})),this._coldStart=!1;for(let e of this._sessionStartedListeners)try{e()}catch(e){this._diag.warn(`Error while executing session started listener`,e)}}incrSessionCountForKey(e){if(!this._sessionSpan||!this._activeSessionCounts){this._diag.debug(`trying to increment a count for the active session, but there is no session in progress. This is a no-op.`);return}this._activeSessionCounts[e]=(this._activeSessionCounts[e]||0)+1}incrNextSessionCountForKey(e){this._nextSessionCounts[e]=(this._nextSessionCounts[e]||0)+1}addSessionStartedListener(e){let t=this._sessionStartedListeners.push(e);return()=>{this._sessionStartedListeners.splice(t-1,1)}}addSessionEndedListener(e){let t=this._sessionEndedListeners.push(e);return()=>{this._sessionEndedListeners.splice(t-1,1)}}recordSDKStartupDuration(e){this._sdkStartupDuration=Math.ceil(e)}setTracerProvider(e){this._tracer=e.getTracer(`mxl-web-sdk-sessions`)}_determineNavigationSource(){try{let e=window.performance.getEntriesByType(`navigation`);if(e.length>0&&e[0]){let t=e[0];if(t.type===`reload`)return`reload`;if(t.type===`back_forward`)return`back_forward`}}catch(e){this._diag.warn(`Failed to get navigation type`,e)}return this._referrerInfo.isValid?this._referrerInfo.isSameOrigin?`same_origin`:`external`:`direct`}_processReferrer(){if(!this._referrer)return{isValid:!1,isSameOrigin:!1};try{let e=new URL(this._referrer),t=window.location.origin;return{isValid:!0,isSameOrigin:e.origin===t,scrubbedUrl:e.origin+e.pathname}}catch(e){return{isValid:!1,isSameOrigin:!1}}}_getTabContext(e){let t=Ns(this._sessionStorage,this._diag),n,r;if(e===`same_origin`){let e=this._getTabActivity();e&&Date.now()-e.lastActivityMs<=1e4&&(n=e.tabId,r=e.experienceId)}return r!=null||(r=kt()),{sourceTabId:n,experienceId:r,tabId:t}}_initTab(){let e=this._determineNavigationSource();try{let t=this._sessionStorage.getItem(Is);if(t)return{tab:JSON.parse(t),navigationSource:e}}catch(e){this._diag.warn(`Failed to retrieve tab data`,e)}let t=this._getTabContext(e),n={experienceId:t.experienceId,sourceTabId:t.sourceTabId,tabId:t.tabId};try{this._sessionStorage.setItem(Is,JSON.stringify(n))}catch(e){this._diag.warn(`Failed to store tab data`,e)}return{tab:n,navigationSource:e}}_getTabActivity(){try{let e=this._storage.getItem(Ls);return e?JSON.parse(e):null}catch(e){return this._diag.warn(`Failed to retrieve tab activity`,e),null}}_storeTabActivity(e){try{this._storage.setItem(Ls,JSON.stringify(e))}catch(e){this._diag.warn(`Failed to save tab activity`,e)}}_storeCurrentTabAsSource(){let e={tabId:this._tab.tabId,experienceId:this._tab.experienceId,lastActivityMs:Date.now()};this._storeTabActivity(e)}_setupNewTabClickListeners(){let e=e=>{var t;if(e.button===1||e.ctrlKey||e.metaKey||e.shiftKey){this._storeCurrentTabAsSource();return}(t=e.target)!=null&&t.closest(`a[target="_blank"], form[target="_blank"], a[rel*="noopener"], a[rel*="noreferrer"]`)&&this._storeCurrentTabAsSource()},t={capture:!0,passive:!0};document.addEventListener(`auxclick`,e,t),document.addEventListener(`click`,e,t)}},zs=class{constructor({tracerProvider:e}={}){A(this,`_tracer`,void 0),A(this,`setSpan`,D.setSpan),this._tracer=(e==null?D:e).getTracer(`mxl-web-sdk-traces`)}startSpan(e,t={},n){t.attributes=t.attributes?t.attributes:{},t.attributes[O]=k.Perf;let r=t.parentSpan?D.setSpan(w.active(),t.parentSpan):n;return new Fs(this._tracer.startSpan(e,t,r))}getSpan(e){let t=D.getSpan(e);if(t)return new Fs(t)}};let Bs=`mxl_user`,Vs=`mxl_user_id`,Hs=`mxl_external_user_id`,Us=e=>typeof e[Xi]==`string`&&e[Xi].length===32,Ws=e=>typeof e==`string`&&e.length===32;var Gs=class{constructor({diag:e,storage:t=window.localStorage}={}){A(this,`_diag`,void 0),A(this,`_storage`,void 0),A(this,`_mxlUserId`,null),this._diag=e==null?T.createComponentLogger({namespace:`MXLUserManager`}):e,this._storage=t,this._migrateOldLocalStorageKey(),this._initialSetup()}getMXLUserId(){return this._mxlUserId||this._generateNewMXLUserId()}setMXLUserId(e){this._mxlUserId=e;try{this._storage.setItem(Vs,e)}catch(e){this._diag.warn(`Failed to persist user object for storage, keeping it in-memory only`,e)}}clearMXLUserId(){this._mxlUserId=null;try{this._storage.removeItem(Vs)}catch(e){this._diag.warn(`Failed to remove mxl user in storage`,e)}}_migrateOldLocalStorageKey(){try{let e=this._storage.getItem(Bs);if(e){let t=JSON.parse(e);Us(t)?(this._diag.debug(`Migrating old user data from storage`),this._storage.setItem(Vs,t[Xi]),this._storage.removeItem(Bs)):(this._diag.warn(`Invalid user data found in storage, clearing old user data`),this._storage.removeItem(Bs))}}catch(e){this._diag.warn(`Failed to get old user data from storage`,e)}}_initialSetup(){try{let e=this._storage.getItem(Vs);e?Ws(e)?this._mxlUserId=e:(this._diag.warn(`Invalid mxl user id, generating a new one`),this.clearMXLUserId()):this._diag.debug(`No existing user found in storage, creating a new one`)}catch(e){this._diag.warn(`Failed to get mxl user id from storage, defaulting to a new one`,e)}this._mxlUserId||(this._mxlUserId=this._generateNewMXLUserId())}_generateNewMXLUserId(){let e=kt();return this.setMXLUserId(e),e}getUserId(){try{return this._storage.getItem(Hs)}catch(e){return this._diag.warn(`Failed to retrieve user id from storage`,e),null}}setUserId(e){try{this._storage.setItem(Hs,e)}catch(e){this._diag.warn(`Failed to store user id`,e)}}clearUserId(){try{this._storage.removeItem(Hs)}catch(e){this._diag.warn(`Failed to clear user id`,e)}}};let Ks=[`keydown`,`mousedown`,`mousemove`,`scroll`];var qs=class extends X{constructor({diag:e}={}){super({instrumentationName:`SpanSessionBrowserActivityInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,config:{}}),A(this,`_onActivityThrottled`,void 0),A(this,`_activityTimeout`,void 0),A(this,`disable`,()=>{Tt({target:window,events:Ks,callback:this._onActivityThrottled}),this._activityTimeout&&clearTimeout(this._activityTimeout),this._activityTimeout=null}),A(this,`enable`,()=>{wt({target:window,events:Ks,callback:this._onActivityThrottled})}),A(this,`_onInactivity`,()=>{this._diag.debug(`Inactivity detected`),this._activityTimeout&&clearTimeout(this._activityTimeout),this._activityTimeout=null,this.sessionManager.endSessionSpanInternal(`inactivity`)}),A(this,`_onActivity`,()=>{this._diag.debug(`Activity detected`),this._activityTimeout&&clearTimeout(this._activityTimeout),this.sessionManager.getSessionId()||this.sessionManager.startSessionSpan({reason:`activity`}),this._activityTimeout=setTimeout(this._onInactivity,18e5)}),this._activityTimeout=null,this._onActivityThrottled=xi(this._onActivity,3e4),this._config.enabled&&this.enable()}},Js=class extends X{constructor({diag:e}={}){super({instrumentationName:`SpanSessionOnLoadInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,config:{}}),this._config.enabled&&this.enable()}disable(){this.sessionManager.endSessionSpanInternal(`unknown`)}enable(){this.sessionManager.startSessionSpan({reason:`init`})}};let Ys=14400*1e3;var Xs=class extends X{constructor({diag:e,perf:t}={}){super({instrumentationName:`SpanSessionTimeoutInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_sessionTimeout`,void 0),A(this,`disable`,()=>{this._sessionTimeout&&clearTimeout(this._sessionTimeout),this._sessionTimeout=null}),A(this,`enable`,()=>{this._checkTimeout()}),A(this,`_onTimeout`,()=>{this._diag.debug(`Timeout detected`),this._sessionTimeout&&clearTimeout(this._sessionTimeout),this.sessionManager.endSessionSpanInternal(`timer`),this.sessionManager.startSessionSpan({reason:`timer`}),this._sessionTimeout=setTimeout(this._checkTimeout,Ys)}),A(this,`_checkTimeout`,()=>{let e=this.sessionManager.getSessionStartTime();if(e){let t=Ys-this.perf.millisSinceHRTime(e);if(t<=0){this._onTimeout();return}this._sessionTimeout&&clearTimeout(this._sessionTimeout),this._sessionTimeout=setTimeout(this._checkTimeout,t);return}this._sessionTimeout&&clearTimeout(this._sessionTimeout),this._sessionTimeout=setTimeout(this._checkTimeout,Ys)}),this._sessionTimeout=null,this._config.enabled&&this.enable()}};let Zs=[`mousedown`];var Qs=class extends X{constructor({diag:e,perf:t,visibilityWaitTimeMs:n=0,limitedSessionMaxDurationMs:r=5e3,backgroundSessions:i=!1,maxPendingSpanCount:a=5,visibilityDoc:o=window.document}={},s,c){super({instrumentationName:`SpanSessionVisibilityInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_currentVisibilityState`,void 0),A(this,`_checkVisibilityTimeout`,void 0),A(this,`_interactionSinceLastVisibilityChange`,void 0),A(this,`_avoidEndingLimitedSessions`,void 0),A(this,`_mxlSpanProcessor`,void 0),A(this,`_checkVisibilityChange`,void 0),A(this,`_onVisibilityChange`,void 0),A(this,`_onInteractionThrottled`,void 0),this._currentVisibilityState=o.visibilityState,this._checkVisibilityTimeout=null,this._interactionSinceLastVisibilityChange=!1,this._avoidEndingLimitedSessions=r>0&&s.isEmptySessionAvoidanceEnabled(),this._mxlSpanProcessor=c,this._checkVisibilityChange=()=>{if(n<=0){this._currentVisibilityState=o.visibilityState,this._onVisibilityChange();return}if(this._checkVisibilityTimeout&&clearTimeout(this._checkVisibilityTimeout),o.visibilityState===`visible`&&this._currentVisibilityState!==o.visibilityState){this._currentVisibilityState=o.visibilityState,this._onVisibilityChange();return}this._diag.debug(`Visibility changed to ${o.visibilityState}. Will wait ${(n/1e3).toString()}s, and check if visibility changed`),this._checkVisibilityTimeout=setTimeout(()=>{this._currentVisibilityState===o.visibilityState?this._diag.debug(`Visibility was not changed after timeout happened: ${o.visibilityState}`):(this._currentVisibilityState=o.visibilityState,this._onVisibilityChange())},n)},this._onVisibilityChange=()=>{this._diag.debug(`Visibility change detected: ${o.visibilityState}`);let e=this.sessionManager.getSessionStartTime();if(this._avoidEndingLimitedSessions&&e!==null&&this.perf.millisSinceHRTime(e)<r&&!this._interactionSinceLastVisibilityChange&&this._mxlSpanProcessor&&this._mxlSpanProcessor.getPendingSpansCount()<a){this._diag.debug(`Not ending the session since it is considered limited`),this.sessionManager.addBreadcrumb(`Tab visibility changed to ${o.visibilityState}`);let e=this.sessionManager.getSessionId();if(e){let t=this.sessionManager.currentSessionAsReadableSpan(`state_changed`);t&&this._mxlSpanProcessor.storePendingSpans(e,t)}}else{let e=this.sessionManager.getSessionId();this._mxlSpanProcessor&&e&&this._mxlSpanProcessor.clearStoredSpans(e),this.sessionManager.endSessionSpanInternal(`state_changed`),o.visibilityState===`hidden`&&i?(this._diag.debug("Starting a session since document visibility switched to hidden and `backgroundSessions` is enabled"),this.sessionManager.startSessionSpan({reason:`hidden`})):o.visibilityState===`visible`&&(this._diag.debug(`Starting a session since document visibility switched to visible`),this.sessionManager.startSessionSpan({reason:`visible`}))}this._interactionSinceLastVisibilityChange=!1},this._onInteractionThrottled=xi(()=>{this._interactionSinceLastVisibilityChange=!0},1e3),this._config.enabled&&this.enable()}disable(){window.removeEventListener(`visibilitychange`,this._checkVisibilityChange),this._avoidEndingLimitedSessions&&Tt({target:window,events:Zs,callback:this._onInteractionThrottled})}enable(){window.addEventListener(`visibilitychange`,this._checkVisibilityChange),this._avoidEndingLimitedSessions&&wt({target:window,events:Zs,callback:this._onInteractionThrottled})}},$s=class{constructor(){A(this,`t`,void 0),A(this,`o`,0),A(this,`i`,[])}u(e){var t;if(e.hadRecentInput)return;let n=this.i[0],r=this.i.at(-1);this.o&&n&&r&&e.startTime-r.startTime<1e3&&e.startTime-n.startTime<5e3?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),(t=this.t)==null||t.call(this,e)}};let ec=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},tc=e=>{if(document.readyState===`loading`)return`loading`;{let t=ec();if(t){if(e<t.domInteractive)return`loading`;if(t.domContentLoadedEventStart===0||e<t.domContentLoadedEventStart)return`dom-interactive`;if(t.domComplete===0||e<t.domComplete)return`dom-content-loaded`}}return`complete`},nc=e=>{let t=e.nodeName;return e.nodeType===1?t.toLowerCase():t.toUpperCase().replace(/^#/,``)},rc=e=>{let t=``;try{for(;(e==null?void 0:e.nodeType)!==9;){let n=e,r=n.id?`#`+n.id:[nc(n),...Array.from(n.classList).sort()].join(`.`);if(t.length+r.length>99)return t||r;if(t=t?r+`>`+t:r,n.id)break;e=n.parentNode}}catch(e){}return t},ic=new WeakMap;function ac(e,t){return ic.get(e)||ic.set(e,new t),ic.get(e)}let oc=-1,sc=()=>oc,cc=e=>{addEventListener(`pageshow`,(t=>{t.persisted&&(oc=t.timeStamp,e(t))}),!0)},Z=(e,t,n,r)=>{let i,a;return o=>{var s;t.value>=0&&(o||r)&&(a=t.value-((s=i)==null?0:s),(a||i===void 0)&&(i=t.value,t.delta=a,t.rating=((e,t)=>e>t[1]?`poor`:e>t[0]?`needs-improvement`:`good`)(t.value,n),e(t)))}},lc=e=>{requestAnimationFrame((()=>requestAnimationFrame((()=>e()))))},uc=()=>{var e;let t=ec();return(e=t==null?void 0:t.activationStart)==null?0:e},Q=(e,t=-1)=>{let n=ec(),r=`navigate`;return sc()>=0?r=`back-forward-cache`:n&&(document.prerendering||uc()>0?r=`prerender`:document.wasDiscarded?r=`restore`:n.type&&(r=n.type.replace(/_/g,`-`))),{name:e,value:t,rating:`good`,delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+0xe8d4a51000}`,navigationType:r}},dc=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let r=new PerformanceObserver((e=>{Promise.resolve().then((()=>{t(e.getEntries())}))}));return r.observe(B({type:e,buffered:!0},n)),r}}catch(e){}},fc=e=>{let t=!1;return()=>{t||(e(),t=!0)}},pc=-1,mc=new Set,hc=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,gc=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of mc)e();isFinite(pc)||(pc=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,gc,!0))}},_c=()=>{if(pc<0){var e;let t=uc(),n=document.prerendering||(e=globalThis.performance.getEntriesByType(`visibility-state`).filter((e=>e.name===`hidden`&&e.startTime>t))[0])==null?void 0:e.startTime;pc=n==null?hc():n,addEventListener(`visibilitychange`,gc,!0),addEventListener(`prerenderingchange`,gc,!0),cc((()=>{setTimeout((()=>{pc=hc()}))}))}return{get firstHiddenTime(){return pc},onHidden(e){mc.add(e)}}},vc=e=>{document.prerendering?addEventListener(`prerenderingchange`,(()=>e()),!0):e()},yc=[1800,3e3],bc=(e,t={})=>{vc((()=>{let n=_c(),r,i=Q(`FCP`),a=dc(`paint`,(e=>{for(let t of e)t.name===`first-contentful-paint`&&(a.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-uc(),0),i.entries.push(t),r(!0)))}));a&&(r=Z(e,i,yc,t.reportAllChanges),cc((n=>{i=Q(`FCP`),r=Z(e,i,yc,t.reportAllChanges),lc((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))})))}))},xc=[.1,.25],Sc=e=>e.find((e=>{var t;return((t=e.node)==null?void 0:t.nodeType)===1}))||e[0],Cc=(e,t={})=>{let n=ac(t=Object.assign({},t),$s),r=new WeakMap;n.t=e=>{var n;if(!(e==null||(n=e.sources)==null)&&n.length){let n=Sc(e.sources),o=n==null?void 0:n.node;if(o){var i,a;let e=(i=(a=t.generateTarget)==null?void 0:a.call(t,o))==null?rc(o):i;r.set(n,e)}}},((e,t={})=>{let n=_c();bc(fc((()=>{let r,i=Q(`CLS`,0),a=ac(t,$s),o=e=>{for(let t of e)a.u(t);a.o>i.value&&(i.value=a.o,i.entries=a.i,r())},s=dc(`layout-shift`,o);s&&(r=Z(e,i,xc,t.reportAllChanges),n.onHidden((()=>{o(s.takeRecords()),r(!0)})),cc((()=>{a.o=0,i=Q(`CLS`,0),r=Z(e,i,xc,t.reportAllChanges),lc((()=>r()))})),setTimeout(r))})))})((t=>{e((e=>{let t={};if(e.entries.length){var n;let i=e.entries.reduce(((e,t)=>e.value>t.value?e:t));if(!(i==null||(n=i.sources)==null)&&n.length){let e=Sc(i.sources);e&&(t={largestShiftTarget:r.get(e),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:e,largestShiftEntry:i,loadState:tc(i.startTime)})}}return Object.assign(e,{attribution:t})})(t))}),t)},wc=(e,t={})=>{bc((t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:tc(sc())};if(e.entries.length){let n=ec(),r=e.entries.at(-1);if(n){let i=n.activationStart||0,a=Math.max(0,n.responseStart-i);t={timeToFirstByte:a,firstByteToFCP:e.value-a,loadState:tc(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}return Object.assign(e,{attribution:t})})(t))}),t)},Tc=0,Ec=1/0,Dc=0,Oc=e=>{for(let t of e)t.interactionId&&(Ec=Math.min(Ec,t.interactionId),Dc=Math.max(Dc,t.interactionId),Tc=Dc?(Dc-Ec)/7+1:0)},kc,Ac=()=>{var e;return kc?Tc:(e=performance.interactionCount)==null?0:e},jc=()=>{`interactionCount`in performance||kc||(kc=dc(`event`,Oc,{type:`event`,buffered:!0,durationThreshold:0}))},Mc=0;var Nc=class{constructor(){A(this,`l`,[]),A(this,`h`,new Map),A(this,`m`,void 0),A(this,`p`,void 0)}v(){Mc=Ac(),this.l.length=0,this.h.clear()}M(){let e=Math.min(this.l.length-1,Math.floor((Ac()-Mc)/50));return this.l[e]}u(e){var t;if((t=this.m)==null||t.call(this,e),!e.interactionId&&e.entryType!==`first-input`)return;let n=this.l.at(-1),r=this.h.get(e.interactionId);if(r||this.l.length<10||e.duration>n.T){var i;if(r?e.duration>r.T?(r.entries=[e],r.T=e.duration):e.duration===r.T&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],T:e.duration},this.h.set(r.id,r),this.l.push(r)),this.l.sort(((e,t)=>t.T-e.T)),this.l.length>10){let e=this.l.splice(10);for(let t of e)this.h.delete(t.id)}(i=this.p)==null||i.call(this,r)}}};let Pc=e=>{let t=globalThis.requestIdleCallback||setTimeout;document.visibilityState===`hidden`?e():(e=fc(e),addEventListener(`visibilitychange`,e,{once:!0,capture:!0}),t((()=>{e(),removeEventListener(`visibilitychange`,e,{capture:!0})})))},Fc=[200,500],Ic=(e,t={})=>{let n=ac(t=Object.assign({},t),Nc),r=[],i=[],a=0,o=new WeakMap,s=new WeakMap,c=!1,l=()=>{c||(Pc(u),c=!0)},u=()=>{let e=n.l.map((e=>o.get(e.entries[0]))),t=i.length-50;i=i.filter(((n,r)=>r>=t||e.includes(n)));let s=new Set;for(let e of i){let t=d(e.startTime,e.processingEnd);for(let e of t)s.add(e)}let l=r.length-1-50;r=r.filter(((e,t)=>e.startTime>a&&t>l||s.has(e))),c=!1};n.m=e=>{let t=e.startTime+e.duration,n;a=Math.max(a,e.processingEnd);for(let r=i.length-1;r>=0;r--){let a=i[r];if(Math.abs(t-a.renderTime)<=8){n=a,n.startTime=Math.min(e.startTime,n.startTime),n.processingStart=Math.min(e.processingStart,n.processingStart),n.processingEnd=Math.max(e.processingEnd,n.processingEnd),n.entries.push(e);break}}n||(n={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:t,entries:[e]},i.push(n)),(e.interactionId||e.entryType===`first-input`)&&o.set(e,n),l()},n.p=e=>{if(!s.get(e)){let i=e.entries[0].target;if(i){var n,r;let a=(n=(r=t.generateTarget)==null?void 0:r.call(t,i))==null?rc(i):n;s.set(e,a)}}};let d=(e,t)=>{let n=[];for(let i of r)if(!(i.startTime+i.duration<e)){if(i.startTime>t)break;n.push(i)}return n},f=e=>{let t=e.entries[0],r=o.get(t),i=t.processingStart,a=Math.max(t.startTime+t.duration,i),c=Math.min(r.processingEnd,a),l=r.entries.sort(((e,t)=>e.processingStart-t.processingStart)),u=d(t.startTime,c),f=n.h.get(t.interactionId),p={interactionTarget:s.get(f),interactionType:t.name.startsWith(`key`)?`keyboard`:`pointer`,interactionTime:t.startTime,nextPaintTime:a,processedEventEntries:l,longAnimationFrameEntries:u,inputDelay:i-t.startTime,processingDuration:c-i,presentationDelay:a-c,loadState:tc(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{var t;if(!((t=e.longAnimationFrameEntries)!=null&&t.length))return;let n=e.interactionTime,r=e.inputDelay,i=e.processingDuration,a,o,s=0,c=0,l=0,u=0;for(let t of e.longAnimationFrameEntries){c=c+t.startTime+t.duration-t.styleAndLayoutStart;for(let e of t.scripts){let t=e.startTime+e.duration;if(t<n)continue;let l=t-Math.max(n,e.startTime),d=e.duration?l/e.duration*e.forcedStyleAndLayoutDuration:0;s+=l-d,c+=d,l>u&&(o=e.startTime<n+r?`input-delay`:e.startTime>=n+r+i?`presentation-delay`:`processing-duration`,a=e,u=l)}}let d=e.longAnimationFrameEntries.at(-1),f=d?d.startTime+d.duration:0;f>=n+r+i&&(l=e.nextPaintTime-f),a&&o&&(e.longestScript={entry:a,subpart:o,intersectingDuration:u}),e.totalScriptDuration=s,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=l,e.totalUnattributedDuration=e.nextPaintTime-n-s-c-l})(p),Object.assign(e,{attribution:p})};dc(`long-animation-frame`,(e=>{r=r.concat(e),l()})),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=_c();vc((()=>{var r;jc();let i,a=Q(`INP`),o=ac(t,Nc),s=e=>{Pc((()=>{for(let t of e)o.u(t);let t=o.M();t&&t.T!==a.value&&(a.value=t.T,a.entries=t.entries,i())}))},c=dc(`event`,s,{durationThreshold:(r=t.durationThreshold)==null?40:r});i=Z(e,a,Fc,t.reportAllChanges),c&&(c.observe({type:`first-input`,buffered:!0}),n.onHidden((()=>{s(c.takeRecords()),i(!0)})),cc((()=>{o.v(),a=Q(`INP`),i=Z(e,a,Fc,t.reportAllChanges)})))}))})((t=>{e(f(t))}),t)};var Lc=class{constructor(){A(this,`m`,void 0)}u(e){var t;(t=this.m)==null||t.call(this,e)}};let Rc=[2500,4e3],zc=(e,t={})=>{let n=ac(t=Object.assign({},t),Lc),r=new WeakMap;n.m=e=>{let n=e.element;if(n){var i,a;let o=(i=(a=t.generateTarget)==null?void 0:a.call(t,n))==null?rc(n):i;r.set(e,o)}},((e,t={})=>{vc((()=>{let n=_c(),r,i=Q(`LCP`),a=ac(t,Lc),o=e=>{t.reportAllChanges||(e=e.slice(-1));for(let t of e)a.u(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-uc(),0),i.entries=[t],r())},s=dc(`largest-contentful-paint`,o);if(s){r=Z(e,i,Rc,t.reportAllChanges);let n=fc((()=>{o(s.takeRecords()),s.disconnect(),r(!0)})),a=e=>{e.isTrusted&&(Pc(n),removeEventListener(e.type,a,{capture:!0}))};for(let e of[`keydown`,`click`,`visibilitychange`])addEventListener(e,a,{capture:!0});cc((n=>{i=Q(`LCP`),r=Z(e,i,Rc,t.reportAllChanges),lc((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))}))}}))})((t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){let n=ec();if(n){let i=n.activationStart||0,a=e.entries.at(-1),o=a.url&&performance.getEntriesByType(`resource`).filter((e=>e.name===a.url))[0],s=Math.max(0,n.responseStart-i),c=Math.max(s,o?(o.requestStart||o.startTime)-i:0),l=Math.min(e.value,Math.max(c,o?o.responseEnd-i:0));t={target:r.get(a),timeToFirstByte:s,resourceLoadDelay:c-s,resourceLoadDuration:l-c,elementRenderDelay:e.value-l,navigationEntry:n,lcpEntry:a},a.url&&(t.url=a.url),o&&(t.lcpResourceEntry=o)}}return Object.assign(e,{attribution:t})})(t))}),t)},Bc=[800,1800],Vc=e=>{document.prerendering?vc((()=>Vc(e))):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,(()=>Vc(e)),!0)},Hc=(e,t={})=>{((e,t={})=>{let n=Q(`TTFB`),r=Z(e,n,Bc,t.reportAllChanges);Vc((()=>{let i=ec();i&&(n.value=Math.max(i.responseStart-uc(),0),n.entries=[i],r(!0),cc((()=>{n=Q(`TTFB`,0),r=Z(e,n,Bc,t.reportAllChanges),r(!0)})))}))})((t=>{e((e=>{let t={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(e.entries.length){let n=e.entries[0],r=n.activationStart||0,i=Math.max((n.workerStart||n.fetchStart)-r,0),a=Math.max(n.domainLookupStart-r,0),o=Math.max(n.connectStart-r,0),s=Math.max(n.connectEnd-r,0);t={waitingDuration:i,cacheDuration:a-i,dnsDuration:o-a,connectionDuration:s-o,requestDuration:e.value-s,navigationEntry:n}}return Object.assign(e,{attribution:t})})(t))}),t)},Uc=[`CLS`,`INP`,`LCP`],Wc=[`CLS`,`INP`,`LCP`,`FCP`,`TTFB`],Gc={CLS:Cc,FCP:wc,LCP:zc,INP:Ic,TTFB:Hc,FID:void 0},Kc=(e,t)=>{let n={},r=[];if(e===`CLS`){let e=t.attribution;r.push({key:`largestShiftTarget`,value:e.largestShiftTarget},{key:`largestShiftValue`,value:e.largestShiftValue})}else if(e===`INP`){let e=t.attribution;r.push({key:`interactionTarget`,value:e.interactionTarget},{key:`interactionType`,value:e.interactionType},{key:`nextPaintTime`,value:e.nextPaintTime},{key:`inputDelay`,value:e.inputDelay},{key:`processingDuration`,value:e.processingDuration},{key:`presentationDelay`,value:e.presentationDelay},{key:`totalScriptDuration`,value:e.totalScriptDuration},{key:`totalStyleAndLayoutDuration`,value:e.totalStyleAndLayoutDuration},{key:`totalPaintDuration`,value:e.totalPaintDuration},{key:`totalUnattributedDuration`,value:e.totalUnattributedDuration},{key:`loadState`,value:e.loadState})}else if(e===`LCP`){let e=t.attribution;r.push({key:`target`,value:e.target},{key:`url`,value:e.url},{key:`timeToFirstByte`,value:e.timeToFirstByte},{key:`resourceLoadDelay`,value:e.resourceLoadDelay},{key:`resourceLoadDuration`,value:e.resourceLoadDuration},{key:`elementRenderDelay`,value:e.elementRenderDelay})}return r.forEach(e=>{e.value!==void 0&&(n[`mxl.web_vital.attribution.${e.key}`]=e.value)}),n};var qc=class extends X{constructor({diag:e,perf:t,trackingLevel:n=`core`,listeners:r=Gc,urlDocument:i=window.document,urlAttribution:a=!0,pageManager:o}={}){super({instrumentationName:`WebVitalsInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_metricsToTrack`,void 0),A(this,`_listeners`,void 0),A(this,`_urlDocument`,void 0),A(this,`_urlAttribution`,void 0),A(this,`_pageManager`,void 0),A(this,`_attributedPage`,{INP:void 0,LCP:void 0,CLS:void 0,FCP:void 0,TTFB:void 0}),A(this,`_largestShiftTargetForCLS`,void 0),A(this,`_listenersRegistered`,!1),this._listeners=r,this._urlDocument=i,this._metricsToTrack=n===`all`?[...Wc]:[...Uc],this._urlAttribution=a,this._pageManager=o==null?K.getPageManager():o,this._config.enabled&&this.enable()}disable(){}enable(){if(!this._listenersRegistered&&(this._listenersRegistered=!0,this._metricsToTrack.forEach(e=>{var t,n;(t=(n=this._listeners)[e])==null||t.call(n,t=>{let n=this.sessionManager.getSessionSpan();if(!n)return;let r=this._getTimeForMetric(t),i=this._getAttributedPageForMetric(t),a=B({[O]:k.WebVital,[M]:i.fullURL,"mxl.web_vital.navigation_type":t.navigationType,"mxl.web_vital.name":t.name,"mxl.web_vital.rating":t.rating,"mxl.web_vital.id":t.id,"mxl.web_vital.delta":t.delta,"mxl.web_vital.value":t.value},Kc(e,t));i.path&&i.pageID&&(a[Pt]=i.path,a[Ft]=i.pageID),n.addEvent(`mxl-web-vitals-report-${e}`,a,r)})}),this._urlAttribution)){var e,t,n,r,i,a;(e=(t=this._listeners).INP)==null||e.call(t,()=>{this._attributedPage.INP=this._currentAttributedPage()},{reportAllChanges:!0}),(n=(r=this._listeners).LCP)==null||n.call(r,()=>{this._attributedPage.LCP=this._currentAttributedPage()},{reportAllChanges:!0}),(i=(a=this._listeners).CLS)==null||i.call(a,e=>{let t=e;this._largestShiftTargetForCLS!==t.attribution.largestShiftTarget&&(this._largestShiftTargetForCLS=t.attribution.largestShiftTarget,this._attributedPage.CLS=this._currentAttributedPage())},{reportAllChanges:!0})}}_getTimeForMetric(e){return e.name===`CLS`&&e.attribution.largestShiftTime?this.perf.epochMillisFromOriginOffset(e.attribution.largestShiftTime):e.name===`INP`&&e.attribution.interactionTime?this.perf.epochMillisFromOriginOffset(e.attribution.interactionTime):this.perf.getNowMillis()}_currentAttributedPage(){let e={fullURL:this._urlDocument.URL},t=this._pageManager.getCurrentRoute(),n=this._pageManager.getCurrentPageId();return t&&n&&(e.path=t.path,e.pageID=n),e}_getAttributedPageForMetric(e){return e.name===`INP`&&this._attributedPage.INP?this._attributedPage.INP:e.name===`LCP`&&this._attributedPage.LCP?this._attributedPage.LCP:e.name===`CLS`&&this._attributedPage.CLS&&e.attribution.largestShiftTarget===this._largestShiftTargetForCLS?this._attributedPage.CLS:this._currentAttributedPage()}},$;(function(e){e.METHOD_OPEN=`open`,e.METHOD_SEND=`send`,e.EVENT_ABORT=`abort`,e.EVENT_ERROR=`error`,e.EVENT_LOAD=`loaded`,e.EVENT_TIMEOUT=`timeout`})($||($={}));let Jc=T.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils`});function Yc(e){return typeof Document<`u`&&e instanceof Document}function Xc(e){if(Yc(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return Qc(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return $c(e);if(e instanceof URLSearchParams)return Qc(e.toString());if(e.byteLength!==void 0)return e.byteLength;Jc.warn(`unknown body type`)}let Zc=new TextEncoder;function Qc(e){return Zc.encode(e).byteLength}function $c(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function el(e){let t=rl(),n=e.toUpperCase();return n in t?n:`_OTHER`}let tl={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},nl;function rl(){return nl===void 0&&(nl=tl),nl}let il={"https:":`443`,"http:":`80`};function al(e){let t=Number(e.port||il[e.protocol]);if(t&&!isNaN(t))return t}let ol=`0.211.0`;var sl;(function(e){e.HTTP_STATUS_TEXT=`http.status_text`})(sl||(sl={}));var cl=class extends Do{constructor(e={}){super(`@opentelemetry/instrumentation-xml-http-request`,ol,e),A(this,`component`,`xml-http-request`),A(this,`version`,ol),A(this,`moduleName`,this.component),A(this,`_tasksCount`,0),A(this,`_xhrMem`,new WeakMap),A(this,`_usedResources`,new WeakSet),A(this,`_semconvStability`,void 0),this._semconvStability=Ao(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_addHeaders(e,t){let n=G(t).href;if(!hi(n,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};E.inject(w.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}let r={};E.inject(w.active(),r),Object.keys(r).forEach(t=>{e.setRequestHeader(t,String(r[t]))})}_addChildSpan(e,t){w.with(D.setSpan(w.active(),e),()=>{let e=this.tracer.startSpan(`CORS Preflight`,{startTime:t[U.FETCH_START]}),n=!(this._semconvStability&Y.OLD);li(e,t,this.getConfig().ignoreNetworkEvents,void 0,n),e.end(t[U.RESPONSE_END])})}_addFinalSpanAttributes(e,t,n){if(this._semconvStability&Y.OLD){if(t.status!==void 0&&e.setAttribute(`http.status_code`,t.status),t.statusText!==void 0&&e.setAttribute(sl.HTTP_STATUS_TEXT,t.statusText),typeof n==`string`){let t=G(n);e.setAttribute(`http.host`,t.host),e.setAttribute(`http.scheme`,t.protocol.replace(`:`,``))}e.setAttribute(`http.user_agent`,navigator.userAgent)}this._semconvStability&Y.STABLE&&t.status&&e.setAttribute(yn,t.status)}_applyAttributesAfterXHR(e,t){let n=this.getConfig().applyCustomAttributesOnSpan;typeof n==`function`&&Oo(()=>n(e,t),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_addResourceObserver(e,t){let n=this._xhrMem.get(e);!n||typeof PerformanceObserver!=`function`||typeof PerformanceResourceTiming!=`function`||(n.createdResources={observer:new PerformanceObserver(e=>{let r=e.getEntries(),i=G(t);r.forEach(e=>{e.initiatorType===`xmlhttprequest`&&e.name===i.href&&n.createdResources&&n.createdResources.entries.push(e)})}),entries:[]},n.createdResources.observer.observe({entryTypes:[`resource`]}))}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(N.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(e,t,n,r,i){if(!n||!r||!i||!e.createdResources)return;let a=e.createdResources.entries;(!a||!a.length)&&(a=N.getEntriesByType(`resource`));let o=fi(G(n).href,r,i,a,this._usedResources);if(o.mainRequest){let e=o.mainRequest;this._markResourceAsUsed(e);let n=o.corsPreFlightRequest;n&&(this._addChildSpan(t,n),this._markResourceAsUsed(n));let r=!(this._semconvStability&Y.OLD);li(t,e,this.getConfig().ignoreNetworkEvents,void 0,r)}}_cleanPreviousSpanInformation(e){let t=this._xhrMem.get(e);if(t){let n=t.callbackToRemoveEvents;n&&n(),this._xhrMem.delete(e)}}_createSpan(e,t,n){if(br(t,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let r=``,i=G(t),a={};if(this._semconvStability&Y.OLD&&(r=n.toUpperCase(),a[`http.method`]=n,a[`http.url`]=i.toString()),this._semconvStability&Y.STABLE){let e=n,t=el(n);r||(r=t),a[_n]=t,t!==e&&(a[vn]=e),a[M]=i.toString(),a[bn]=i.hostname;let o=al(i);o&&(a[xn]=o)}let o=this.tracer.startSpan(r,{kind:ut.CLIENT,attributes:a});return o.addEvent($.METHOD_OPEN),this._cleanPreviousSpanInformation(e),this._xhrMem.set(e,{span:o,spanUrl:t}),o}_markResourceAsUsed(e){this._usedResources.add(e)}_patchOpen(){return e=>{let t=this;return function(...n){let r=n[0],i=n[1];return t._createSpan(this,i,r),e.apply(this,n)}}}_patchSend(){let e=this;function t(t,n,r,i){let a=n.callbackToRemoveEvents;typeof a==`function`&&a();let{span:o,spanUrl:s,sendStartTime:c}=n;o&&(e._findResourceAndAddNetworkEvents(n,o,s,c,r),o.addEvent(t,i),e._addFinalSpanAttributes(o,n,s),o.end(i),e._tasksCount--),e._clearResources()}function n(n,r,i,a){let o=e._xhrMem.get(r);if(!o)return;if(o.status=r.status,o.statusText=r.statusText,e._xhrMem.delete(r),o.span){let t=o.span;e._applyAttributesAfterXHR(t,r),e._semconvStability&Y.STABLE&&(i?a&&(t.setStatus({code:dt.ERROR,message:a}),t.setAttribute(pn,a)):o.status&&o.status>=400&&(t.setStatus({code:dt.ERROR}),t.setAttribute(pn,String(o.status))))}let s=An(),c=Date.now();setTimeout(()=>{t(n,o,s,c)},300)}function r(){n($.EVENT_ERROR,this,!0,`error`)}function i(){n($.EVENT_ABORT,this,!1)}function a(){n($.EVENT_TIMEOUT,this,!0,`timeout`)}function o(){this.status<299?n($.EVENT_LOAD,this,!1):n($.EVENT_ERROR,this,!1)}function s(t){t.removeEventListener(`abort`,i),t.removeEventListener(`error`,r),t.removeEventListener(`load`,o),t.removeEventListener(`timeout`,a);let n=e._xhrMem.get(t);n&&(n.callbackToRemoveEvents=void 0)}return t=>function(...n){let c=e._xhrMem.get(this);if(!c)return t.apply(this,n);let l=c.span,u=c.spanUrl;if(l&&u){if(e.getConfig().measureRequestSize&&n!=null&&n[0]){let t=n[0],r=Xc(t);r!==void 0&&(e._semconvStability&Y.OLD&&l.setAttribute(`http.request_content_length_uncompressed`,r),e._semconvStability&Y.STABLE&&l.setAttribute(`http.request.body.size`,r))}w.with(D.setSpan(w.active(),l),()=>{e._tasksCount++,c.sendStartTime=An(),l.addEvent($.METHOD_SEND),this.addEventListener(`abort`,i),this.addEventListener(`error`,r),this.addEventListener(`load`,o),this.addEventListener(`timeout`,a),c.callbackToRemoveEvents=()=>{s(this),c.createdResources&&c.createdResources.observer.disconnect()},e._addHeaders(this,u),e._addResourceObserver(this,u)})}return t.apply(this,n)}}enable(){this._diag.debug(`applying patch to`,this.moduleName,this.version),ko(XMLHttpRequest.prototype.open)&&(this._unwrap(XMLHttpRequest.prototype,`open`),this._diag.debug(`removing previous patch from method open`)),ko(XMLHttpRequest.prototype.send)&&(this._unwrap(XMLHttpRequest.prototype,`send`),this._diag.debug(`removing previous patch from method send`)),this._wrap(XMLHttpRequest.prototype,`open`,this._patchOpen()),this._wrap(XMLHttpRequest.prototype,`send`,this._patchSend())}disable(){this._diag.debug(`removing patch from`,this.moduleName,this.version),this._unwrap(XMLHttpRequest.prototype,`open`),this._unwrap(XMLHttpRequest.prototype,`send`),this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet}};let ll=[`omitIfAlreadyPatched`];var ul=class extends cl{constructor(e={}){let{omitIfAlreadyPatched:t}=e,n=ds(e,ll);super(B(B({},n),{},{enabled:!1})),A(this,`_omitIfAlreadyPatched`,void 0),this._omitIfAlreadyPatched=t,n.enabled&&this.enable()}enable(){if(this._omitIfAlreadyPatched&&(ko(XMLHttpRequest.prototype.open)||ko(XMLHttpRequest.prototype.send))){this._diag.debug("XMLHttpRequest is already passed and `omitIfAlreadyPatched` is true, skipping enabling this instrumentation");return}super.enable()}};function dl(e){return fl(e,new WeakSet)}function fl(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>fl(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>fl(e,t))}return!1}var pl=class{set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this.totalAttributesCount-Object.keys(this.attributes).length}constructor(e,t,n){A(this,`hrTime`,void 0),A(this,`hrTimeObserved`,void 0),A(this,`spanContext`,void 0),A(this,`resource`,void 0),A(this,`instrumentationScope`,void 0),A(this,`attributes`,{}),A(this,`_severityText`,void 0),A(this,`_severityNumber`,void 0),A(this,`_body`,void 0),A(this,`_eventName`,void 0),A(this,`totalAttributesCount`,0),A(this,`_isReadonly`,!1),A(this,`_logRecordLimits`,void 0);let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:o,severityText:s,body:c,attributes:l={},context:u}=n,d=Date.now();if(this.hrTime=F(r==null?d:r),this.hrTimeObserved=F(i==null?d:i),u){let e=D.getSpanContext(u);e&&et(e)&&(this.spanContext=e)}this.severityNumber=o,this.severityText=s,this.body=c,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(l)}setAttribute(e,t){return this._isLogRecordReadonly()?this:e.length===0?(T.warn(`Invalid attribute key: ${e}`),this):dl(t)?(this.totalAttributesCount+=1,Object.keys(this.attributes).length>=this._logRecordLimits.attributeCountLimit&&!Object.prototype.hasOwnProperty.call(this.attributes,e)?(this.droppedAttributesCount===1&&T.warn(`Dropping extra attributes.`),this):(this.attributes[e]=this._truncateToSize(t),this)):(T.warn(`Invalid attribute value set for key: ${e}`),this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(e){let t=this._logRecordLimits.attributeValueLengthLimit;if(t<=0)return T.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return this._truncateToLimitUtil(e,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>this._truncateToSize(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this._truncateToSize(r);return t}return e}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&T.warn(`Can not execute the operation on emitted log record`),this._isReadonly}},ml=class{constructor(e,t){A(this,`instrumentationScope`,void 0),A(this,`_sharedState`,void 0),A(this,`_loggerConfig`,void 0),this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){var t;let n=this._loggerConfig,r=e.context||w.active(),i=(t=e.severityNumber)==null?q.UNSPECIFIED:t;if(i!==q.UNSPECIFIED&&i<n.minimumSeverity)return;if(n.traceBased){let e=D.getSpanContext(r);if(e&&et(e)&&(e.traceFlags&C.SAMPLED)!==C.SAMPLED)return}let a=new pl(this._sharedState,this.instrumentationScope,B({context:r},e));this._sharedState.activeProcessor.onEmit(a,r),a._makeReadonly()}};function hl(){var e,t;return{forceFlushTimeoutMillis:3e4,logRecordLimits:{attributeValueLengthLimit:(e=void 0)==null?1/0:e,attributeCountLimit:(t=void 0)==null?128:t},includeTraceContext:!0}}function gl(e){var t,n,r,i,a,o;return{attributeCountLimit:(t=(n=(r=e.attributeCountLimit)==null?void 0:r)==null?void 0:n)==null?128:t,attributeValueLengthLimit:(i=(a=(o=e.attributeValueLengthLimit)==null?void 0:o)==null?void 0:a)==null?1/0:i}}var _l=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}},vl=class{constructor(e,t){A(this,`processors`,void 0),A(this,`forceFlushTimeoutMillis`,void 0),this.processors=e,this.forceFlushTimeoutMillis=t}forceFlush(){var e=this;return z(function*(){let t=e.forceFlushTimeoutMillis;yield Promise.all(e.processors.map(e=>vr(e.forceFlush(),t)))})()}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}shutdown(){var e=this;return z(function*(){yield Promise.all(e.processors.map(e=>e.shutdown()))})()}};function yl(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}let bl={disabled:!1,minimumSeverity:q.UNSPECIFIED,traceBased:!1},xl=()=>B({},bl);var Sl=class{constructor(e,t,n,r,i){A(this,`loggers`,new Map),A(this,`activeProcessor`,void 0),A(this,`registeredLogRecordProcessors`,[]),A(this,`resource`,void 0),A(this,`forceFlushTimeoutMillis`,void 0),A(this,`logRecordLimits`,void 0),A(this,`processors`,void 0),A(this,`_loggerConfigurator`,void 0),A(this,`_loggerConfigs`,new Map),this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=n,this.processors=r,r.length>0?(this.registeredLogRecordProcessors=r,this.activeProcessor=new vl(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new _l,this._loggerConfigurator=i==null?xl:i}getLoggerConfig(e){let t=yl(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}},Cl=class{constructor(e={}){var t,n;A(this,`_shutdownOnce`,void 0),A(this,`_sharedState`,void 0);let r=cr({},hl(),e);this._sharedState=new Sl((t=e.resource)==null?Mr():t,r.forceFlushTimeoutMillis,gl(r.logRecordLimits),(n=e==null?void 0:e.processors)==null?[]:n,e==null?void 0:e.loggerConfigurator),this._shutdownOnce=new Sr(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return T.warn(`A shutdown LoggerProvider cannot provide a Logger`),co;e||T.warn(`Logger requested without instrumentation scope name.`);let r=e||`unknown`,i=`${r}@${t||``}:${(n==null?void 0:n.schemaUrl)||``}`;return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new ml({name:r,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(T.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(T.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}},wl=class{constructor(e,t){var n,r,i,a,o,s,c,l;A(this,`_maxExportBatchSize`,void 0),A(this,`_maxQueueSize`,void 0),A(this,`_scheduledDelayMillis`,void 0),A(this,`_exportTimeoutMillis`,void 0),A(this,`_exporter`,void 0),A(this,`_isExporting`,!1),A(this,`_finishedLogRecords`,[]),A(this,`_timer`,void 0),A(this,`_shutdownOnce`,void 0),this._exporter=e,this._maxExportBatchSize=(n=(r=t==null?void 0:t.maxExportBatchSize)==null?void 0:r)==null?512:n,this._maxQueueSize=(i=(a=t==null?void 0:t.maxQueueSize)==null?void 0:a)==null?2048:i,this._scheduledDelayMillis=(o=(s=t==null?void 0:t.scheduledDelayMillis)==null?void 0:s)==null?5e3:o,this._exportTimeoutMillis=(c=(l=t==null?void 0:t.exportTimeoutMillis)==null?void 0:l)==null?3e4:c,this._shutdownOnce=new Sr(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(T.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}shutdown(){return this._shutdownOnce.call()}_shutdown(){var e=this;return z(function*(){e.onShutdown(),yield e._flushAll(),yield e._exporter.shutdown()})()}_addToBuffer(e){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(e),this._maybeStartTimer())}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedLogRecords.length/this._maxExportBatchSize);for(let e=0;e<r;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedLogRecords.length===0?Promise.resolve():vr(this._export(this._finishedLogRecords.splice(0,this._maxExportBatchSize)),this._exportTimeoutMillis)}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().then(()=>{this._isExporting=!1,this._finishedLogRecords.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,j(e)})};if(this._finishedLogRecords.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}_export(e){let t=()=>wr._export(this._exporter,e).then(e=>{if(e.code!==L.SUCCESS){var t;j((t=e.error)==null?Error(`BatchLogRecordProcessor: log record export failed (status ${e})`):t)}}).catch(j),n=[];for(let t=0;t<e.length;t++){let r=e[t].resource;r.asyncAttributesPending&&typeof r.waitForAsyncAttributes==`function`&&n.push(r.waitForAsyncAttributes())}return n.length===0?t():Promise.all(n).then(t,j)}},Tl=class extends wl{constructor(e,t){super(e,t),A(this,`_visibilityChangeListener`,void 0),A(this,`_pageHideListener`,void 0),this._onInit(t)}onShutdown(){typeof document>`u`||(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}_onInit(e){(e==null?void 0:e.disableAutoFlushOnDocumentHide)===!0||typeof document>`u`||(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush()},this._pageHideListener=()=>{this.forceFlush()},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}},El=class{constructor(e){A(this,`_sessionIdProvider`,void 0),this._sessionIdProvider=e}forceFlush(){return z(function*(){})()}onStart(e,t){var n;let r=(n=this._sessionIdProvider)==null?void 0:n.getSessionId();r&&e.setAttribute(`session.id`,r)}onEnd(e){}shutdown(){return z(function*(){})()}};function Dl(e){return new El(e)}var Ol=class{constructor({spanSessionManager:e}){A(this,`_spanSessionManager`,void 0),this._spanSessionManager=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){e.setAttributes({"log.record.uid":kt(),[No]:this._spanSessionManager.getSessionId(),"session.previous_id":this._spanSessionManager.getPreviousSessionId()})}shutdown(){return Promise.resolve(void 0)}},kl=class{constructor({attributeScrubbers:e}){A(this,`_attributeScrubbers`,void 0),this._attributeScrubbers=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){this._attributeScrubbers.forEach(t=>{let n=e.attributes[t.key];n&&typeof n==`string`&&e.setAttribute(t.key,t.scrub(n))})}shutdown(){return Promise.resolve(void 0)}},Al=class{constructor({urlDocument:e=window.document}={}){A(this,`_urlDocument`,void 0),this._urlDocument=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){e.attributes[O]||e.setAttribute(O,k.SystemLog),e.setAttribute(M,this._urlDocument.URL)}shutdown(){return Promise.resolve(void 0)}};let jl=e=>{if((e.attributes[_n]||e.attributes[un])&&(typeof e.attributes[yn]==`number`||typeof e.attributes[fn]==`number`)){var t;let n=(t=e.attributes[M])==null?e.attributes[dn]:t;return typeof n==`string`&&n.includes(`://`)}return!1};var Ml=class{forceFlush(){return Promise.resolve(void 0)}onEnd(e){if(jl(e)){var t,n,r,i,a;e.attributes[O]=k.Network,(t=e.attributes)[M]!=null||(t[M]=e.attributes[dn]),(n=e.attributes)[yn]!=null||(n[yn]=e.attributes[fn]),(r=e.attributes)[_n]!=null||(r[_n]=e.attributes[un]),(i=e.attributes)[Mo]!=null||(i[Mo]=e.attributes[`http.response_content_length`]),(a=e.attributes)[jo]!=null||(a[jo]=e.attributes[`http.request_content_length`])}}onStart(){}shutdown(){return Promise.resolve(void 0)}};let Nl=e=>e.attributes[O]===k.Session,Pl=(e,t)=>`mxl.${t===`current`?`export_failed`:`previous_export_failed`}.${e}`;var Fl=class{constructor({resource:e,exporter:t,limitManager:n,spanSessionManager:r,storage:i=window.localStorage,storedSpansExpireTimeoutMS:a,diag:o=T.createComponentLogger({namespace:`MXLSessionBatchedSpanProcessor`})}){A(this,`_shutdownOnce`,void 0),A(this,`_pendingSpans`,[]),A(this,`_exporter`,void 0),A(this,`_limitManager`,void 0),A(this,`_spanStorage`,void 0),A(this,`_spanSessionManager`,void 0),A(this,`_diag`,void 0),A(this,`_shutdown`,()=>(this._spanStorage.destroy(),this._exporter.shutdown())),this._diag=o,this._exporter=t,this._shutdownOnce=new Sr(this._shutdown,this),this._limitManager=n,this._spanSessionManager=r,this._spanStorage=new _i({resource:e,storage:i,diag:o,onExpiredSpansExport:e=>{this._exportSpans(e)},storedSpansExpireTimeoutMS:a,spanSessionManager:r})}forceFlush(){return this._diag.debug(`forceFlush called for MXLSessionBatchedSpanProcessor. This is a no op`),Promise.resolve(void 0)}onEnd(e){if(this._shutdownOnce.isCalled){this._diag.debug(`span ended after processor shutdown. Ignoring span.`);return}if(Nl(e))this._diag.debug(`session span ended. Exporting all pending spans.`),this._exportSpans([e,...this._pendingSpans]),this._pendingSpans=[];else{if(this._diag.debug(`non-session span ended. Adding to pending spans queue.`),this._limitManager.dropReadableSpan(e))return;this._pendingSpans.push(e)}}_exportSpans(e){wr._export(this._exporter,e).then(e=>{if(e.code===L.FAILED){var t;let n=((t=e.error)==null?void 0:t.message)||`unknown error`,r=`unknown`;n===`Concurrent export limit reached`?r=`concurrent_limit`:n===`Fetch request errored`&&(r=`fetch_error`),this._spanSessionManager.incrSessionCountForKey(Pl(r,`current`)),this._spanSessionManager.incrNextSessionCountForKey(Pl(r,`previous`)),this._diag.error(`spans failed to export: ${n}`)}}).catch(e=>{let t=`unknown error`;e&&e instanceof Error?t=e.message:typeof e==`string`&&(t=e),this._spanSessionManager.incrSessionCountForKey(Pl(`unknown`,`current`)),this._spanSessionManager.incrNextSessionCountForKey(Pl(`unknown`,`previous`)),this._diag.error(`spans failed to export: ${t}`)})}onStart(){}getPendingSpansCount(){return this._pendingSpans.length}storePendingSpans(e,t){this._spanStorage.storePendingSpans(e,t,this._pendingSpans)}clearStoredSpans(e){this._spanStorage.clearStoredSpans(e)}shutdown(){return this._shutdownOnce.call()}},Il=class{constructor({pageManager:e}){A(this,`_pageManager`,void 0),this._pageManager=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){if(e.attributes[Pt]||e.attributes[Ft])return;let t=this._pageManager.getCurrentRoute();t&&(e.setAttribute(Pt,t.path),e.setAttribute(Ft,this._pageManager.getCurrentPageId()))}shutdown(){return Promise.resolve(void 0)}},Ll=class{constructor({pageManager:e}){A(this,`_pageManager`,void 0),this._pageManager=e}forceFlush(){return Promise.resolve(void 0)}onEnd(e){if(e.attributes[Pt]||e.attributes[Ft])return;let t=this._pageManager.getCurrentRoute(),n=this._pageManager.getCurrentPageId();t&&n&&(e.attributes[Pt]=t.path,e.attributes[Ft]=n)}onStart(){}shutdown(){return Promise.resolve(void 0)}},Rl=class{constructor({attributeScrubbers:e}){A(this,`_attributeScrubbers`,void 0),this._attributeScrubbers=e}forceFlush(){return Promise.resolve(void 0)}onEnd(e){this._attributeScrubbers.forEach(t=>{let n=e.attributes[t.key];n&&typeof n==`string`&&(e.attributes[t.key]=t.scrub(n))})}onStart(){}shutdown(){return Promise.resolve(void 0)}},zl=class{constructor({userManager:e}){A(this,`_userManager`,void 0),this._userManager=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){this._userManager.getUserId()&&e.setAttributes({[Po]:this._userManager.getUserId()})}shutdown(){return Promise.resolve(void 0)}},Bl=class{constructor({userManager:e}){A(this,`_userManager`,void 0),this._userManager=e}forceFlush(){return Promise.resolve(void 0)}onEnd(e){let t=this._userManager.getUserId();t&&(e.attributes[Po]=t)}onStart(){}shutdown(){return Promise.resolve(void 0)}},Vl=class extends Xn{inject(e,t,n){super.inject(e,t,n);let r=D.getSpan(e);if(r){let e=ke.get(t,`traceparent`);e&&r.setAttribute(`mxl.w3c_traceparent`,e)}}};let Hl=/\/\/(.+):(.+)@(.+)\//,Ul=[`AWSAccessKeyId`,`Signature`,`sig`,"`X-Goog-Signature",`password`,`auth`,`pw`,`token`],Wl=({value:e,queryParamRegex:t,scrubPath:n,scrubQuery:r})=>{let i=e;return n&&(i=i.replace(Hl,`//REDACTED:REDACTED@$3/`)),r&&(i=i.replaceAll(t,`$1$2=REDACTED`)),i},Gl=e=>{let t=[...Ul,...e||[]],n=RegExp(`(^|&|\\?)(${t.join(`|`)})=[^&]+`,`g`);return[{key:M,scrub:e=>Wl({value:e,queryParamRegex:n,scrubPath:!0,scrubQuery:!0})},{key:dn,scrub:e=>Wl({value:e,queryParamRegex:n,scrubPath:!0,scrubQuery:!0})},{key:`url.path`,scrub:e=>Wl({value:e,queryParamRegex:n,scrubPath:!0,scrubQuery:!1})},{key:`url.query`,scrub:e=>Wl({value:e,queryParamRegex:n,scrubPath:!1,scrubQuery:!0})}]},Kl=new class{constructor({diagLogger:e=T.createComponentLogger({namespace:`mxl-registry`})}={}){A(this,`_sdk`,null),A(this,`_diag`,void 0),A(this,`register`,e=>{this._sdk!==null&&this._diag.warn(`previously registered sdk will be overwritten`),this._sdk=e}),A(this,`clear`,()=>{this._sdk===null&&this._diag.warn(`sdk already cleared, this is a no-op`),this._sdk=null}),A(this,`registered`,()=>this._sdk),this._diag=e}},ql=(e={},{featureManager:t,logManager:n,spanSessionManager:r,mxlSpanProcessor:i,pageManager:a})=>{var o,s,c,l,u,d;let f=[new Js(e[`session-on-load`]),new Qs(e[`session-visibility`],t,i),new qs(e[`session-activity`]),new Xs(e[`session-timeout`])];(o=e.omit)!=null&&o.has(`exception`)||f.push(new Go(e.exception)),(s=e.omit)!=null&&s.has(`click`)||f.push(new Wo(e.click)),(c=e.omit)!=null&&c.has(`web-vital`)||f.push(new qc(B(B({},e[`web-vital`]),{},{pageManager:a}))),(l=e.omit)!=null&&l.has(`document-load`)||f.push(new Vo(e[`document-load`])),(u=e.omit)!=null&&u.has(`@opentelemetry/instrumentation-fetch`)||f.push(new ps(B(B({},e.network),e[`@opentelemetry/instrumentation-fetch`]))),(d=e.omit)!=null&&d.has(`@opentelemetry/instrumentation-xml-http-request`)||f.push(new ul(B(B({},e.network),e[`@opentelemetry/instrumentation-xml-http-request`]))),e[`empty-root`]&&f.push(new Ho(B({},e[`empty-root`])));for(let e of f)e instanceof X&&(r&&e.setSessionManager(r),n&&e.setLogManager(n));return f},Jl=e=>{if(e!==void 0){if(typeof e!=`string`)throw Error(`appID must be a string, or omitted if not using MXL. Received ${String(e)}`);if(e.length!==5)throw Error(`appID should be 5 characters long, or omitted if not using MXL. Received "${e}"`);return e}},Yl=e=>{if(e===void 0){let e=`MXLAppVersionX.X.X`;return e===``?`unspecified`:e}if(typeof e!=`string`)throw Error(`if appVersion is specified, it must be a string. Received ${String(e)}`);let t=e.trim();if(t===``)throw Error(`if appVersion is specified, it cannot be an empty string.`);return t},Xl=(e,t)=>{var n,r,i,a;if(!t.size)return e;let o=[...(n=e==null||(r=e.network)==null?void 0:r.ignoreUrls)==null?[]:n,...(i=e==null||(a=e[`@opentelemetry/instrumentation-fetch`])==null?void 0:a.ignoreUrls)==null?[]:i,...Array.from(t)];return o.length?B(B({},e),{},{network:B(B({},e==null?void 0:e.network),{},{ignoreUrls:o}),"@opentelemetry/instrumentation-fetch":(e==null?void 0:e[`@opentelemetry/instrumentation-fetch`])===void 0?void 0:B(B({},e[`@opentelemetry/instrumentation-fetch`]),{},{ignoreUrls:o})}):e},Zl=e=>{if(e&&typeof e==`object`){let t=e;if(t.mxlExporter||t.name===`MXLExporterError`)return!0}return!1},Ql=e=>{if(e instanceof Error)return e.stack||e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch(t){return String(e)}},$l=({appID:e,appVersion:t,resource:n=jr(),spanExporters:r=[],logExporters:i=[],spanProcessors:a=[],propagator:o=null,defaultInstrumentationConfig:s,instrumentations:c=[],contextManager:l=null,logProcessors:u=[],attributeScrubbers:d=[],enableDefaultAttributeScrubbing:f=!0,additionalQueryParamsToScrub:p=[],logLevel:ee=h.ERROR,mxlDataURL:m,mxlConfigURL:te,diagLogger:g=T.createComponentLogger({namespace:`mxl-sdk`}),dynamicSDKConfigManager:ne,dynamicSDKConfig:re,registerGlobally:_=!0,blockNetworkSpanForwarding:ie=!1,restrictedProtocols:ae=new Set([`file:`])}={})=>{try{let h=new bi,se=h.getNowMillis();if(_){let e=Kl.registered();if(e!==null)return g.warn(`SDK has already been successfully initialized, skipping this invocation of initSDK`),e}T.setLogger(new fe,{logLevel:ee}),ln(e=>{Zl(e)||T.error(Ql(e))});let v=Jl(e),ce=Yl(t),le=v!==void 0;if(!le&&!i.length&&!r.length)throw Error(`when appID is omitted, at least one logExporter or spanExporter must be set`);if(ae.has(window.location.protocol))throw Error(`not initializing due to restricted protocol: ${window.location.protocol}`);if(le&&typeof CompressionStream>`u`)throw Error(`CompressionStream is not supported in this browser and required for data compression.`);let ue=!_&&e,y=ue?new vi(e,window.localStorage):window.localStorage,de=ue?new vi(e,window.sessionStorage):window.sessionStorage,b=n.merge(Ps({diagLogger:g,appVersion:ce,pageSessionStorage:de})),pe=eu({registerGlobally:_,sdkLocalStorage:y}),x=pe.getMXLUserId();if(le&&!x)throw Error(`userID is required when using MXL exporter`);let me=ne==null?new Ss({appID:v,appVersion:ce,mxlConfigURL:te,defaultConfig:re,deviceId:x,storage:y}):ne;me.refreshRemoteConfig();let he=new ks({dynamicConfigManager:me,deviceId:x,blockNetworkSpanForwarding:ie});if(!he.isSDKEnabled())return g.debug(`SDK is disabled, skipping initialization.`),!1;let ge=new Set;for(let e of[...r,...i])e&&typeof e.url==`string`&&ge.add(e.url);le&&v&&(ge.add(ao(v,m)),ge.add(no(v,m)));let _e=Xl(s,ge),ve=yi({featureManager:he,diag:g,registerGlobally:_,defaultInstrumentationConfig:_e,propagator:o}),ye=new Ts(Cs),be=[...f?Gl(p):[],...d],S=tu({limitManager:ye,registerGlobally:_,sdkLocalStorage:y,sdkSessionStorage:de}),xe,Se;if(le){var oe;xe=new Fl({resource:b,exporter:new oo({appID:v,mxlDataURL:m,userID:x}),limitManager:ye,storedSpansExpireTimeoutMS:s==null||(oe=s[`session-visibility`])==null?void 0:oe.storedSpansExpireTimeoutMS,storage:y,spanSessionManager:S}),Se=new Tl(new ro({appID:v,mxlDataURL:m,userID:x}))}let Ce=iu({registerGlobally:_}),{tracerProvider:we,mxlTraceManager:Te}=nu({resource:b,spanSessionManager:S,userManager:pe,spanExporters:r,spanProcessors:a,propagator:ve?new Vl:o,contextManager:l,attributeScrubbers:be,registerGlobally:_,mxlSpanProcessor:xe,pageManager:Ce});S.setTracerProvider(we);let{loggerProvider:Ee,mxlLogManager:De}=ru({resource:b,userManager:pe,logExporters:i,logProcessors:u,spanSessionManager:S,limitManager:ye,attributeScrubbers:be,registerGlobally:_,mxlLogProcessor:Se,sdkLocalStorage:y,pageManager:Ce});yo(_?{instrumentations:[ql(_e,{featureManager:he,mxlSpanProcessor:xe,pageManager:Ce}),...c]}:{tracerProvider:we,loggerProvider:Ee,instrumentations:[ql(_e,{featureManager:he,logManager:De,spanSessionManager:S,mxlSpanProcessor:xe,pageManager:Ce}),...c]}),g.info(`successfully initialized the SDK`);let Oe={setDynamicConfig:e=>{me.setConfig(e)},flush:function(){var e=z(function*(){yield we.forceFlush(),yield Ee.forceFlush()});return function(){return e.apply(this,arguments)}}(),log:De,trace:Te,session:S,user:pe,page:Ce};return _&&Kl.register(Oe),S.recordSDKStartupDuration(h.getNowMillis()-se),Oe}catch(e){let t=e instanceof Error?e.message:`Unknown error.`;return g.error(`failed to initialize the SDK: ${t}`),!1}},eu=({registerGlobally:e,sdkLocalStorage:t})=>{let n=new Gs({storage:t});return e&&ra.setGlobalUserManager(n),n},tu=({limitManager:e,registerGlobally:t,sdkLocalStorage:n,sdkSessionStorage:r})=>{let i=new Rs({limitManager:e,storage:n,sessionStorage:r});return t&&Vi.setGlobalSessionManager(i),i},nu=({resource:e,spanSessionManager:t,userManager:n,spanExporters:r,spanProcessors:i=[],propagator:a=null,contextManager:o=null,attributeScrubbers:s,registerGlobally:c,mxlSpanProcessor:l,pageManager:u})=>{let d=[...i,Dl(t),new Ml,new Bl({userManager:n}),new Ll({pageManager:u}),new Rl({attributeScrubbers:s})];r==null||r.forEach(e=>{d.push(new Yr(e))}),l&&d.push(l);let f=new ai({resource:e,spanProcessors:d,spanLimits:{attributeCountLimit:Cs.maxAllowed.session_property*2,attributePerEventCountLimit:20,eventCountLimit:Cs.maxAllowed.breadcrumb*2,attributeValueLengthLimit:1024}}),p=new zs({tracerProvider:c?void 0:f});return c&&(Yi.setGlobalTraceManager(p),f.register({contextManager:o||new ni,propagator:a})),{tracerProvider:f,mxlTraceManager:p}},ru=({resource:e,userManager:t,logExporters:n,logProcessors:r,spanSessionManager:i,limitManager:a,attributeScrubbers:o,registerGlobally:s,mxlLogProcessor:c,sdkLocalStorage:l,pageManager:u})=>{let d=[...r,new Ol({spanSessionManager:i}),new Al,new zl({userManager:t}),new kl({attributeScrubbers:o}),new Il({pageManager:u})];n==null||n.forEach(e=>{d.push(new Tl(e))}),c&&d.push(c);let f=new Cl({resource:e,processors:d}),p=new Ds({spanSessionManager:i,limitManager:a,loggerProvider:s?void 0:f,storage:l});return s&&(go.setGlobalLoggerProvider(f),Oi.setGlobalLogManager(p)),{loggerProvider:f,mxlLogManager:p}},iu=({registerGlobally:e})=>{let t=new Os;return e&&K.setGlobalPageManager(t),t};return e.DEFAULT_MXL_EXPORTER_CONFIG=ia,Object.defineProperty(e,`DiagLogLevel`,{enumerable:!0,get:function(){return h}}),e.MXLLogExporter=ro,e.MXLTraceExporter=oo,e.OTLPFetchLogExporter=to,e.OTLPFetchTraceExporter=io,e.getNavigationInstrumentation=_s,e.initSDK=$l,e.log=Oi,e.page=K,e.session=Vi,e.trace=Yi,e.user=ra,e})({});
|
|
1
|
+
"use strict";window.MXLWebSdk=window.MXLWebSdk||(function(e){var t=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},n=`1.9.0`,r=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function i(e){var t=new Set([e]),n=new Set,i=e.match(r);if(!i)return function(){return!1};var a={major:+i[1],minor:+i[2],patch:+i[3],prerelease:i[4]};if(a.prerelease!=null)return function(t){return t===e};function o(e){return n.add(e),!1}function s(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;var i=e.match(r);if(!i)return o(e);var c={major:+i[1],minor:+i[2],patch:+i[3],prerelease:i[4]};return c.prerelease!=null||a.major!==c.major?o(e):a.major===0?a.minor===c.minor&&a.patch<=c.patch?s(e):o(e):a.minor<=c.minor?s(e):o(e)}}var a=i(n),o=n.split(`.`)[0],s=Symbol.for(`opentelemetry.js.api.`+o),c=t;function l(e,t,r,i){var a;i===void 0&&(i=!1);var o=c[s]=(a=c[s])==null?{version:n}:a;if(!i&&o[e]){var l=Error(`@opentelemetry/api: Attempted duplicate registration of API: `+e);return r.error(l.stack||l.message),!1}if(o.version!==n){var l=Error(`@opentelemetry/api: Registration of version v`+o.version+` for `+e+` does not match previously registered API v`+n);return r.error(l.stack||l.message),!1}return o[e]=t,r.debug(`@opentelemetry/api: Registered a global for `+e+` v`+n+`.`),!0}function u(e){var t,n,r=(t=c[s])==null?void 0:t.version;if(!(!r||!a(r)))return(n=c[s])==null?void 0:n[e]}function d(e,t){t.debug(`@opentelemetry/api: Unregistering a global for `+e+` v`+n+`.`);var r=c[s];r&&delete r[e]}var f=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},p=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},ee=function(){function e(e){this._namespace=e.namespace||`DiagComponentLogger`}return e.prototype.debug=function(){var e=[...arguments];return m(`debug`,this._namespace,e)},e.prototype.error=function(){var e=[...arguments];return m(`error`,this._namespace,e)},e.prototype.info=function(){var e=[...arguments];return m(`info`,this._namespace,e)},e.prototype.warn=function(){var e=[...arguments];return m(`warn`,this._namespace,e)},e.prototype.verbose=function(){var e=[...arguments];return m(`verbose`,this._namespace,e)},e}();function m(e,t,n){var r=u(`diag`);if(r)return n.unshift(t),r[e].apply(r,p([],f(n),!1))}var h;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(h||(h={}));function te(e,t){e<h.NONE?e=h.NONE:e>h.ALL&&(e=h.ALL),t=t||{};function n(n,r){var i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,h.ERROR),warn:n(`warn`,h.WARN),info:n(`info`,h.INFO),debug:n(`debug`,h.DEBUG),verbose:n(`verbose`,h.VERBOSE)}}var g=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},ne=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},re=`diag`,_=function(){function e(){function e(e){return function(){var t=[...arguments],n=u(`diag`);if(n)return n[e].apply(n,ne([],g(t),!1))}}var t=this;t.setLogger=function(e,n){var r,i,a;if(n===void 0&&(n={logLevel:h.INFO}),e===t){var o=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error((r=o.stack)==null?o.message:r),!1}typeof n==`number`&&(n={logLevel:n});var s=u(`diag`),c=te((i=n.logLevel)==null?h.INFO:i,e);if(s&&!n.suppressOverrideMessage){var d=(a=Error().stack)==null?`<failed to generate stacktrace>`:a;s.warn(`Current logger will be overwritten from `+d),c.warn(`Current logger will overwrite one already registered from `+d)}return l(`diag`,c,t,!0)},t.disable=function(){d(re,t)},t.createComponentLogger=function(e){return new ee(e)},t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e}(),ie=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},ae=function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)},oe=function(){function e(e){this._entries=e?new Map(e):new Map}return e.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},e.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=ie(e,2);return[t[0],t[1]]})},e.prototype.setEntry=function(t,n){var r=new e(this._entries);return r._entries.set(t,n),r},e.prototype.removeEntry=function(t){var n=new e(this._entries);return n._entries.delete(t),n},e.prototype.removeEntries=function(){for(var t,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=new e(this._entries);try{for(var o=ae(r),s=o.next();!s.done;s=o.next()){var c=s.value;a._entries.delete(c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},e.prototype.clear=function(){return new e},e}(),se=Symbol(`BaggageEntryMetadata`),v=_.instance();function ce(e){return e===void 0&&(e={}),new oe(new Map(Object.entries(e)))}function le(e){return typeof e!=`string`&&(v.error(`Cannot create baggage metadata from unknown type: `+typeof e),e=``),{__TYPE__:se,toString:function(){return e}}}function ue(e){return Symbol.for(e)}var y=new(function(){function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(e){return n._currentContext.get(e)},n.setValue=function(t,r){var i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=function(t){var r=new e(n._currentContext);return r._currentContext.delete(t),r}}return e}()),de=[{n:`error`,c:`error`},{n:`warn`,c:`warn`},{n:`info`,c:`info`},{n:`debug`,c:`debug`},{n:`verbose`,c:`trace`}],fe=function(){function e(){function e(e){return function(){var t=[...arguments];if(console){var n=console[e];if(typeof n!=`function`&&(n=console.log),typeof n==`function`)return n.apply(console,t)}}}for(var t=0;t<de.length;t++)this[de[t].n]=e(de[t].c)}return e}(),b=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),pe=function(){function e(){}return e.prototype.createGauge=function(e,t){return Ce},e.prototype.createHistogram=function(e,t){return we},e.prototype.createCounter=function(e,t){return Se},e.prototype.createUpDownCounter=function(e,t){return Te},e.prototype.createObservableGauge=function(e,t){return De},e.prototype.createObservableCounter=function(e,t){return Ee},e.prototype.createObservableUpDownCounter=function(e,t){return Oe},e.prototype.addBatchObservableCallback=function(e,t){},e.prototype.removeBatchObservableCallback=function(e){},e}(),x=function(){function e(){}return e}(),me=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.add=function(e,t){},t}(x),he=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.add=function(e,t){},t}(x),ge=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.record=function(e,t){},t}(x),_e=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.record=function(e,t){},t}(x),ve=function(){function e(){}return e.prototype.addCallback=function(e){},e.prototype.removeCallback=function(e){},e}(),ye=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(ve),be=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(ve),S=function(e){b(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(ve),xe=new pe,Se=new me,Ce=new ge,we=new _e,Te=new he,Ee=new ye,De=new be,Oe=new S,ke={get:function(e,t){if(e!=null)return e[t]},keys:function(e){return e==null?[]:Object.keys(e)}},Ae={set:function(e,t,n){e!=null&&(e[t]=n)}},je=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Me=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},Ne=function(){function e(){}return e.prototype.active=function(){return y},e.prototype.with=function(e,t,n){var r=[...arguments].slice(3);return t.call.apply(t,Me([n],je(r),!1))},e.prototype.bind=function(e,t){return t},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}(),Pe=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Fe=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},Ie=`context`,Le=new Ne,Re=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(e){return l(Ie,e,_.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(e,t,n){for(var r,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(r=this._getContextManager()).with.apply(r,Fe([e,t,n],Pe(i),!1))},e.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},e.prototype._getContextManager=function(){return u(Ie)||Le},e.prototype.disable=function(){this._getContextManager().disable(),d(Ie,_.instance())},e}(),C;(function(e){e[e.NONE=0]=`NONE`,e[e.SAMPLED=1]=`SAMPLED`})(C||(C={}));var ze=`0000000000000000`,Be=`00000000000000000000000000000000`,Ve={traceId:Be,spanId:ze,traceFlags:C.NONE},He=function(){function e(e){e===void 0&&(e=Ve),this._spanContext=e}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(e,t){return this},e.prototype.setAttributes=function(e){return this},e.prototype.addEvent=function(e,t){return this},e.prototype.addLink=function(e){return this},e.prototype.addLinks=function(e){return this},e.prototype.setStatus=function(e){return this},e.prototype.updateName=function(e){return this},e.prototype.end=function(e){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(e,t){},e}(),Ue=ue(`OpenTelemetry Context Key SPAN`);function We(e){return e.getValue(Ue)||void 0}function Ge(){return We(Re.getInstance().active())}function Ke(e,t){return e.setValue(Ue,t)}function qe(e){return e.deleteValue(Ue)}function Je(e,t){return Ke(e,new He(t))}function Ye(e){var t;return(t=We(e))==null?void 0:t.spanContext()}var Xe=/^([0-9a-f]{32})$/i,Ze=/^[0-9a-f]{16}$/i;function Qe(e){return Xe.test(e)&&e!==Be}function $e(e){return Ze.test(e)&&e!==ze}function et(e){return Qe(e.traceId)&&$e(e.spanId)}function tt(e){return new He(e)}var nt=Re.getInstance(),rt=function(){function e(){}return e.prototype.startSpan=function(e,t,n){if(n===void 0&&(n=nt.active()),t!=null&&t.root)return new He;var r=n&&Ye(n);return it(r)&&et(r)?new He(r):new He},e.prototype.startActiveSpan=function(e,t,n,r){var i,a,o;if(!(arguments.length<2)){arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);var s=a==null?nt.active():a,c=this.startSpan(e,i,s),l=Ke(s,c);return nt.with(l,o,void 0,c)}},e}();function it(e){return typeof e==`object`&&typeof e.spanId==`string`&&typeof e.traceId==`string`&&typeof e.traceFlags==`number`}var at=new rt,ot=function(){function e(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}return e.prototype.startSpan=function(e,t,n){return this._getTracer().startSpan(e,t,n)},e.prototype.startActiveSpan=function(e,t,n,r){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):at},e}(),st=new(function(){function e(){}return e.prototype.getTracer=function(e,t,n){return new rt},e}()),ct=function(){function e(){}return e.prototype.getTracer=function(e,t,n){var r;return(r=this.getDelegateTracer(e,t,n))==null?new ot(this,e,t,n):r},e.prototype.getDelegate=function(){var e;return(e=this._delegate)==null?st:e},e.prototype.setDelegate=function(e){this._delegate=e},e.prototype.getDelegateTracer=function(e,t,n){var r;return(r=this._delegate)==null?void 0:r.getTracer(e,t,n)},e}(),lt;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(lt||(lt={}));var ut;(function(e){e[e.INTERNAL=0]=`INTERNAL`,e[e.SERVER=1]=`SERVER`,e[e.CLIENT=2]=`CLIENT`,e[e.PRODUCER=3]=`PRODUCER`,e[e.CONSUMER=4]=`CONSUMER`})(ut||(ut={}));var dt;(function(e){e[e.UNSET=0]=`UNSET`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`})(dt||(dt={}));var w=Re.getInstance(),T=_.instance(),ft=new(function(){function e(){}return e.prototype.getMeter=function(e,t,n){return xe},e}()),pt=`metrics`,mt=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalMeterProvider=function(e){return l(pt,e,_.instance())},e.prototype.getMeterProvider=function(){return u(pt)||ft},e.prototype.getMeter=function(e,t,n){return this.getMeterProvider().getMeter(e,t,n)},e.prototype.disable=function(){d(pt,_.instance())},e}().getInstance(),ht=function(){function e(){}return e.prototype.inject=function(e,t){},e.prototype.extract=function(e,t){return e},e.prototype.fields=function(){return[]},e}(),gt=ue(`OpenTelemetry Baggage Key`);function _t(e){return e.getValue(gt)||void 0}function vt(){return _t(Re.getInstance().active())}function yt(e,t){return e.setValue(gt,t)}function bt(e){return e.deleteValue(gt)}var xt=`propagation`,St=new ht,E=function(){function e(){this.createBaggage=ce,this.getBaggage=_t,this.getActiveBaggage=vt,this.setBaggage=yt,this.deleteBaggage=bt}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalPropagator=function(e){return l(xt,e,_.instance())},e.prototype.inject=function(e,t,n){return n===void 0&&(n=Ae),this._getGlobalPropagator().inject(e,t,n)},e.prototype.extract=function(e,t,n){return n===void 0&&(n=ke),this._getGlobalPropagator().extract(e,t,n)},e.prototype.fields=function(){return this._getGlobalPropagator().fields()},e.prototype.disable=function(){d(xt,_.instance())},e.prototype._getGlobalPropagator=function(){return u(xt)||St},e}().getInstance(),Ct=`trace`,D=function(){function e(){this._proxyTracerProvider=new ct,this.wrapSpanContext=tt,this.isSpanContextValid=et,this.deleteSpan=qe,this.getSpan=We,this.getActiveSpan=Ge,this.getSpanContext=Ye,this.setSpan=Ke,this.setSpanContext=Je}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(e){var t=l(Ct,this._proxyTracerProvider,_.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},e.prototype.getTracerProvider=function(){return u(Ct)||this._proxyTracerProvider},e.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},e.prototype.disable=function(){d(Ct,_.instance()),this._proxyTracerProvider=new ct},e}().getInstance();let wt=({target:e,events:t,callback:n})=>{t.forEach(t=>{e.addEventListener(t,n)})},Tt=({target:e,events:t,callback:n})=>{t.forEach(t=>{e.removeEventListener(t,n)})};function Et(e,t,n,r=new Set){return new Proxy(e,{get(e,i,a){let o=Reflect.get(e,i,a);return typeof o!=`function`||r.has(i)?o:(...r)=>{try{return o.apply(e,r)}catch(e){let a=e instanceof Error?e.message:`Unknown error`;n.error(`${String(i)}: ${a}`);let o=t[i];return typeof o==`function`?o.apply(t,r):void 0}}}})}let Dt=new Uint8Array(16),Ot=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`).toUpperCase()),kt=()=>{crypto.getRandomValues(Dt);let e=``;for(let t=0;t<16;t++)e+=Ot[Dt[t]];return e},At=(e,t,n)=>{try{let n=e.getItem(t),r=n?parseInt(n,10):0;return r++,e.setItem(t,r.toString()),r}catch(e){return n.warn(`Failed to retrieve ${t} from storage: `,e),1}},O=`mxl.type`,jt=`mxl.state`,Mt=`mxl.properties.`,Nt=`mxl.js_file_bundle_ids`,Pt=`app.surface.name`,Ft=`app.surface.id`,k=function(e){return e.Session=`ux.session`,e.Network=`perf.network_request`,e.Perf=`perf`,e.SystemLog=`sys.log`,e.SystemException=`sys.exception`,e.WebVital=`ux.web_vital`,e.ResourceFetch=`ux.resource_fetch`,e.DocumentLoad=`ux.document_load`,e.Surface=`ux.surface`,e}({}),It=function(e){return e.Foreground=`foreground`,e.Background=`background`,e}({}),Lt=function(e){return e.DeclarativeLegacy=`react_router_declarative_legacy`,e.Declarative=`react_router_declarative`,e.Data=`react_router_data`,e.Manual=`manual`,e}({}),Rt=e=>e.visibilityState===`hidden`?It.Background:It.Foreground,zt=globalThis,Bt=(e,t)=>!t||t<=0||t>100?!1:t>=Vt(e),Vt=e=>{if(e.length<6)return 0;let t=e.slice(-6),n=Math.pow(16,6)-1;return parseInt(t,16)/n*100},Ht=ue(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`);function Ut(e){return e.setValue(Ht,!0)}function Wt(e){return e.getValue(Ht)===!0}let Gt=`baggage`;function Kt(e){return e.reduce((e,t)=>{let n=`${e}${e===``?``:`,`}${t}`;return n.length>8192?e:n},``)}function qt(e){return e.getAllEntries().map(([e,t])=>{let n=`${encodeURIComponent(e)}=${encodeURIComponent(t.value)}`;return t.metadata!==void 0&&(n+=`;`+t.metadata.toString()),n})}function Jt(e){if(!e)return;let t=e.indexOf(`;`),n=t===-1?e:e.substring(0,t),r=n.indexOf(`=`);if(r<=0)return;let i=n.substring(0,r).trim(),a=n.substring(r+1).trim();if(!i||!a)return;let o,s;try{o=decodeURIComponent(i),s=decodeURIComponent(a)}catch(e){return}let c;return t!==-1&&t<e.length-1&&(c=le(e.substring(t+1))),{key:o,value:s,metadata:c}}var Yt=class{inject(e,t,n){let r=E.getBaggage(e);if(!r||Wt(e))return;let i=Kt(qt(r).filter(e=>e.length<=4096).slice(0,180));i.length>0&&n.set(t,Gt,i)}extract(e,t,n){let r=n.get(t,Gt),i=Array.isArray(r)?r.join(`,`):r;if(!i)return e;let a={};return i.length===0||(i.split(`,`).forEach(e=>{let t=Jt(e);if(t){let e={value:t.value};t.metadata&&(e.metadata=t.metadata),a[t.key]=e}}),Object.entries(a).length===0)?e:E.setBaggage(e,E.createBaggage(a))}fields(){return[Gt]}};function Xt(e){"@babel/helpers - typeof";return Xt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Xt(e)}function Zt(e,t){if(Xt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Xt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Qt(e){var t=Zt(e,`string`);return Xt(t)==`symbol`?t:t+``}function A(e,t,n){return(t=Qt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $t(e){let t={};if(typeof e!=`object`||!e)return t;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!en(n)){T.warn(`Invalid attribute key: ${n}`);continue}let r=e[n];if(!tn(r)){T.warn(`Invalid attribute value set for key: ${n}`);continue}Array.isArray(r)?t[n]=r.slice():t[n]=r}return t}function en(e){return typeof e==`string`&&e!==``}function tn(e){return e==null?!0:Array.isArray(e)?nn(e):rn(typeof e)}function nn(e){let t;for(let n of e){if(n==null)continue;let e=typeof n;if(e!==t){if(!t){if(rn(e)){t=e;continue}return!1}return!1}}return!0}function rn(e){switch(e){case`number`:case`boolean`:case`string`:return!0}return!1}function an(){return e=>{T.error(on(e))}}function on(e){return typeof e==`string`?e:JSON.stringify(sn(e))}function sn(e){let t={},n=e;for(;n!==null;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;let r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}let cn=an();function ln(e){cn=e}function j(e){try{cn(e)}catch(e){}}let un=`http.method`,dn=`http.url`,fn=`http.status_code`,pn=`error.type`,mn=`exception.message`,hn=`exception.stacktrace`,gn=`exception.type`,_n=`http.request.method`,vn=`http.request.method_original`,yn=`http.response.status_code`,bn=`server.address`,xn=`server.port`,Sn=`service.name`,Cn=`telemetry.sdk.language`,wn=`telemetry.sdk.name`,Tn=`telemetry.sdk.version`,M=`url.full`,En=`user_agent.original`,Dn={[wn]:`opentelemetry`,"process.runtime.name":`browser`,[Cn]:`webjs`,[Tn]:`2.5.0`},N=performance,On=Math.pow(10,6),kn=Math.pow(10,9);function P(e){let t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*On)]}function An(e){return Fn(P(N.timeOrigin),P(typeof e==`number`?e:N.now()))}function F(e){if(Nn(e))return e;if(typeof e==`number`)return e<N.timeOrigin?An(e):P(e);if(e instanceof Date)return P(e.getTime());throw TypeError(`Invalid input type`)}function jn(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(--n,r+=kn),[n,r]}function I(e){return e[0]*kn+e[1]}function Mn(e){return e[0]*1e3+e[1]/1e6}function Nn(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function Pn(e){return Nn(e)||typeof e==`number`||e instanceof Date}function Fn(e,t){let n=[e[0]+t[0],e[1]+t[1]];return n[1]>=kn&&(n[1]-=kn,n[0]+=1),n}var L;(function(e){e[e.SUCCESS=0]=`SUCCESS`,e[e.FAILED=1]=`FAILED`})(L||(L={}));var In=class{constructor(e={}){var t;A(this,`_propagators`,void 0),A(this,`_fields`,void 0),this._propagators=(t=e.propagators)==null?[]:t,this._fields=Array.from(new Set(this._propagators.map(e=>typeof e.fields==`function`?e.fields():[]).reduce((e,t)=>e.concat(t),[])))}inject(e,t,n){for(let r of this._propagators)try{r.inject(e,t,n)}catch(e){T.warn(`Failed to inject with ${r.constructor.name}. Err: ${e.message}`)}}extract(e,t,n){return this._propagators.reduce((e,r)=>{try{return r.extract(e,t,n)}catch(e){T.warn(`Failed to extract with ${r.constructor.name}. Err: ${e.message}`)}return e},e)}fields(){return this._fields.slice()}};let Ln=`[_0-9a-z-*/]`,Rn=`[a-z]${Ln}{0,255}`,zn=`[a-z0-9]${Ln}{0,240}@[a-z]${Ln}{0,13}`,Bn=RegExp(`^(?:${Rn}|${zn})$`),Vn=/^[ -~]{0,255}[!-~]$/,Hn=/,|=/;function Un(e){return Bn.test(e)}function Wn(e){return Vn.test(e)&&!Hn.test(e)}var Gn=class e{constructor(e){A(this,`_internalState`,new Map),e&&this._parse(e)}set(e,t){let n=this._clone();return n._internalState.has(e)&&n._internalState.delete(e),n._internalState.set(e,t),n}unset(e){let t=this._clone();return t._internalState.delete(e),t}get(e){return this._internalState.get(e)}serialize(){return this._keys().reduce((e,t)=>(e.push(t+`=`+this.get(t)),e),[]).join(`,`)}_parse(e){e.length>512||(this._internalState=e.split(`,`).reverse().reduce((e,t)=>{let n=t.trim(),r=n.indexOf(`=`);if(r!==-1){let i=n.slice(0,r),a=n.slice(r+1,t.length);Un(i)&&Wn(a)&&e.set(i,a)}return e},new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){let t=new e;return t._internalState=new Map(this._internalState),t}};let Kn=`traceparent`,qn=`tracestate`,Jn=RegExp(`^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$`);function Yn(e){let t=Jn.exec(e);return!t||t[1]===`00`&&t[5]?null:{traceId:t[2],spanId:t[3],traceFlags:parseInt(t[4],16)}}var Xn=class{inject(e,t,n){let r=D.getSpanContext(e);if(!r||Wt(e)||!et(r))return;let i=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||C.NONE).toString(16)}`;n.set(t,Kn,i),r.traceState&&n.set(t,qn,r.traceState.serialize())}extract(e,t,n){let r=n.get(t,Kn);if(!r)return e;let i=Array.isArray(r)?r[0]:r;if(typeof i!=`string`)return e;let a=Yn(i);if(!a)return e;a.isRemote=!0;let o=n.get(t,qn);if(o){let e=Array.isArray(o)?o.join(`,`):o;a.traceState=new Gn(typeof e==`string`?e:void 0)}return D.setSpanContext(e,a)}fields(){return[Kn,qn]}};let Zn=Function.prototype.toString,Qn=Zn.call(Object),$n=Object.getPrototypeOf,er=Object.prototype,tr=er.hasOwnProperty,R=Symbol?Symbol.toStringTag:void 0,nr=er.toString;function rr(e){if(!ir(e)||ar(e)!==`[object Object]`)return!1;let t=$n(e);if(t===null)return!0;let n=tr.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Zn.call(n)===Qn}function ir(e){return typeof e==`object`&&!!e}function ar(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:R&&R in Object(e)?or(e):sr(e)}function or(e){let t=tr.call(e,R),n=e[R],r=!1;try{e[R]=void 0,r=!0}catch(e){}let i=nr.call(e);return r&&(t?e[R]=n:delete e[R]),i}function sr(e){return nr.call(e)}function cr(...e){let t=e.shift(),n=new WeakMap;for(;e.length>0;)t=ur(t,e.shift(),0,n);return t}function lr(e){return fr(e)?e.slice():e}function ur(e,t,n=0,r){let i;if(!(n>20)){if(n++,hr(e)||hr(t)||pr(t))i=lr(t);else if(fr(e)){if(i=e.slice(),fr(t))for(let e=0,n=t.length;e<n;e++)i.push(lr(t[e]));else if(mr(t)){let e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){let r=e[n];i[r]=lr(t[r])}}}else if(mr(e))if(mr(t)){if(!gr(e,t))return t;i=Object.assign({},e);let a=Object.keys(t);for(let o=0,s=a.length;o<s;o++){let s=a[o],c=t[s];if(hr(c))c===void 0?delete i[s]:i[s]=c;else{let a=i[s],o=c;if(dr(e,s,r)||dr(t,s,r))delete i[s];else{if(mr(a)&&mr(o)){let n=r.get(a)||[],i=r.get(o)||[];n.push({obj:e,key:s}),i.push({obj:t,key:s}),r.set(a,n),r.set(o,i)}i[s]=ur(i[s],c,n,r)}}}}else i=t;return i}}function dr(e,t,n){let r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function fr(e){return Array.isArray(e)}function pr(e){return typeof e==`function`}function mr(e){return!hr(e)&&!fr(e)&&!pr(e)&&typeof e==`object`}function hr(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===void 0||e instanceof Date||e instanceof RegExp||e===null}function gr(e,t){return!(!rr(e)||!rr(t))}var _r=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function vr(e,t){let n,r=new Promise(function(e,r){n=setTimeout(function(){r(new _r(`Operation timed out.`))},t)});return Promise.race([e,r]).then(e=>(clearTimeout(n),e),e=>{throw clearTimeout(n),e})}function yr(e,t){return typeof t==`string`?e===t:!!e.match(t)}function br(e,t){if(!t)return!1;for(let n of t)if(yr(e,n))return!0;return!1}var xr=class{constructor(){A(this,`_promise`,void 0),A(this,`_resolve`,void 0),A(this,`_reject`,void 0),this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}},Sr=class{constructor(e,t){A(this,`_isCalled`,!1),A(this,`_deferred`,new xr),A(this,`_callback`,void 0),A(this,`_that`,void 0),this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}};function Cr(e,t){return new Promise(n=>{w.with(Ut(w.active()),()=>{e.export(t,e=>{n(e)})})})}let wr={_export:Cr},Tr;function Er(){if(Tr===void 0)try{let e=globalThis.process.argv0;Tr=e?`unknown_service:${e}`:`unknown_service`}catch(e){Tr=`unknown_service`}return Tr}let Dr=e=>typeof e==`object`&&!!e&&typeof e.then==`function`;function Or(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function z(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Or(a,r,i,o,s,`next`,e)}function s(e){Or(a,r,i,o,s,`throw`,e)}o(void 0)})}}var kr=class e{static FromAttributeList(t,n){let r=new e({},n);return r._rawAttributes=Nr(t),r._asyncAttributesPending=t.filter(([e,t])=>Dr(t)).length>0,r}constructor(e,t){var n;A(this,`_rawAttributes`,void 0),A(this,`_asyncAttributesPending`,!1),A(this,`_schemaUrl`,void 0),A(this,`_memoizedAttributes`,void 0);let r=(n=e.attributes)==null?{}:n;this._rawAttributes=Object.entries(r).map(([e,t])=>(Dr(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=Nr(this._rawAttributes),this._schemaUrl=Pr(t==null?void 0:t.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}waitForAsyncAttributes(){var e=this;return z(function*(){if(e.asyncAttributesPending){for(let t=0;t<e._rawAttributes.length;t++){let[n,r]=e._rawAttributes[t];e._rawAttributes[t]=[n,Dr(r)?yield r:r]}e._asyncAttributesPending=!1}})()}get attributes(){if(this.asyncAttributesPending&&T.error(`Accessing resource attributes before async attributes settled`),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[t,n]of this._rawAttributes){if(Dr(n)){T.debug(`Unsettled resource attribute ${t} skipped`);continue}n!=null&&(e[t]!=null||(e[t]=n))}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(t==null)return this;let n=Fr(this,t),r=n?{schemaUrl:n}:void 0;return e.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],r)}};function Ar(e,t){return kr.FromAttributeList(Object.entries(e),t)}function jr(){return Ar({})}function Mr(){return Ar({[Sn]:Er(),[Cn]:Dn[Cn],[wn]:Dn[wn],[Tn]:Dn[Tn]})}function Nr(e){return e.map(([e,t])=>Dr(t)?[e,t.catch(t=>{T.debug(`promise rejection for resource attribute: %s - %s`,e,t)})]:[e,t])}function Pr(e){if(typeof e==`string`||e===void 0)return e;T.warn(`Schema URL must be string or undefined, got %s. Schema URL will be ignored.`,e)}function Fr(e,t){let n=e==null?void 0:e.schemaUrl,r=t==null?void 0:t.schemaUrl,i=n===void 0||n===``,a=r===void 0||r===``;if(i)return r;if(a||n===r)return n;T.warn(`Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.`,n,r)}function Ir(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function B(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ir(Object(n),!0).forEach(function(t){A(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ir(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Lr=class{constructor(e){var t;A(this,`_spanContext`,void 0),A(this,`kind`,void 0),A(this,`parentSpanContext`,void 0),A(this,`attributes`,{}),A(this,`links`,[]),A(this,`events`,[]),A(this,`startTime`,void 0),A(this,`resource`,void 0),A(this,`instrumentationScope`,void 0),A(this,`_droppedAttributesCount`,0),A(this,`_droppedEventsCount`,0),A(this,`_droppedLinksCount`,0),A(this,`name`,void 0),A(this,`status`,{code:dt.UNSET}),A(this,`endTime`,[0,0]),A(this,`_ended`,!1),A(this,`_duration`,[-1,-1]),A(this,`_spanProcessor`,void 0),A(this,`_spanLimits`,void 0),A(this,`_attributeValueLengthLimit`,void 0),A(this,`_performanceStartTime`,void 0),A(this,`_performanceOffset`,void 0),A(this,`_startTimeProvided`,void 0);let n=Date.now();this._spanContext=e.spanContext,this._performanceStartTime=N.now(),this._performanceOffset=n-(this._performanceStartTime+N.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit||0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,this.links=e.links||[],this.startTime=this._getTime((t=e.startTime)==null?n:t),this.resource=e.resource,this.instrumentationScope=e.scope,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return T.warn(`Invalid attribute key: ${e}`),this;if(!tn(t))return T.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits;return n!==void 0&&Object.keys(this.attributes).length>=n&&!Object.prototype.hasOwnProperty.call(this.attributes,e)?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return T.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&T.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),Pn(t)&&(Pn(n)||(n=t),t=void 0);let i=$t(t);return this.events.push({name:e,attributes:i,time:this._getTime(n),droppedAttributesCount:0}),this}addLink(e){return this.links.push(e),this}addLinks(e){return this.links.push(...e),this}setStatus(e){return this._isSpanEnded()?this:(this.status=B({},e),this.status.message!=null&&typeof e.message!=`string`&&(T.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`),delete this.status.message),this)}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){if(this._isSpanEnded()){T.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this.endTime=this._getTime(e),this._duration=jn(this.startTime,this.endTime),this._duration[0]<0&&(T.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&T.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e==`number`&&e<=N.now())return An(e+this._performanceOffset);if(typeof e==`number`)return P(e);if(e instanceof Date)return P(e.getTime());if(Nn(e))return e;if(this._startTimeProvided)return P(Date.now());let t=N.now()-this._performanceStartTime;return Fn(this.startTime,P(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[mn]=e:e&&(e.code?n[gn]=e.code.toString():e.name&&(n[gn]=e.name),e.message&&(n[mn]=e.message),e.stack&&(n[hn]=e.stack)),n[gn]||n[mn]?this.addEvent(`exception`,n,t):T.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);T.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(T.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}},Rr;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(Rr||(Rr={}));var zr=class{shouldSample(){return{decision:Rr.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},Br=class{shouldSample(){return{decision:Rr.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}},Vr=class{constructor(e){var t,n,r,i;A(this,`_root`,void 0),A(this,`_remoteParentSampled`,void 0),A(this,`_remoteParentNotSampled`,void 0),A(this,`_localParentSampled`,void 0),A(this,`_localParentNotSampled`,void 0),this._root=e.root,this._root||(j(Error(`ParentBasedSampler must have a root sampler configured`)),this._root=new Br),this._remoteParentSampled=(t=e.remoteParentSampled)==null?new Br:t,this._remoteParentNotSampled=(n=e.remoteParentNotSampled)==null?new zr:n,this._localParentSampled=(r=e.localParentSampled)==null?new Br:r,this._localParentNotSampled=(i=e.localParentNotSampled)==null?new zr:i}shouldSample(e,t,n,r,i,a){let o=D.getSpanContext(e);return!o||!et(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&C.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&C.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}},Hr=class{constructor(e=0){A(this,`_ratio`,void 0),A(this,`_upperBound`,void 0),this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:Qe(t)&&this._accumulate(t)<this._upperBound?Rr.RECORD_AND_SAMPLED:Rr.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<e.length/8;n++){let r=n*8,i=parseInt(e.slice(r,r+8),16);t=(t^i)>>>0}return t}},V;(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(V||(V={}));function Ur(){var e,t,n,r,i,a,o,s;return{sampler:Wr(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:(e=void 0)==null?1/0:e,attributeCountLimit:(t=void 0)==null?128:t},spanLimits:{attributeValueLengthLimit:(n=void 0)==null?1/0:n,attributeCountLimit:(r=void 0)==null?128:r,linkCountLimit:(i=void 0)==null?128:i,eventCountLimit:(a=void 0)==null?128:a,attributePerEventCountLimit:(o=void 0)==null?128:o,attributePerLinkCountLimit:(s=void 0)==null?128:s}}}function Wr(){var e;let t=(e=void 0)==null?V.ParentBasedAlwaysOn:e;switch(t){case V.AlwaysOn:return new Br;case V.AlwaysOff:return new zr;case V.ParentBasedAlwaysOn:return new Vr({root:new Br});case V.ParentBasedAlwaysOff:return new Vr({root:new zr});case V.TraceIdRatio:return new Hr(Gr());case V.ParentBasedTraceIdRatio:return new Vr({root:new Hr(Gr())});default:return T.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${V.ParentBasedAlwaysOn}".`),new Vr({root:new Br})}}function Gr(){return T.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to 1.`),1}function Kr(e){let t={sampler:Wr()},n=Ur(),r=Object.assign({},n,t,e);return r.generalLimits=Object.assign({},n.generalLimits,e.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,e.spanLimits||{}),r}function qr(e){var t,n,r,i,a,o,s,c,l,u,d,f;let p=Object.assign({},e.spanLimits);return p.attributeCountLimit=(t=(n=(r=(i=(a=e.spanLimits)==null?void 0:a.attributeCountLimit)==null?(o=e.generalLimits)==null?void 0:o.attributeCountLimit:i)==null?void 0:r)==null?void 0:n)==null?128:t,p.attributeValueLengthLimit=(s=(c=(l=(u=(d=e.spanLimits)==null?void 0:d.attributeValueLengthLimit)==null?(f=e.generalLimits)==null?void 0:f.attributeValueLengthLimit:u)==null?void 0:l)==null?void 0:c)==null?1/0:s,Object.assign({},e,{spanLimits:p})}var Jr=class{constructor(e,t){var n,r,i,a;A(this,`_maxExportBatchSize`,void 0),A(this,`_maxQueueSize`,void 0),A(this,`_scheduledDelayMillis`,void 0),A(this,`_exportTimeoutMillis`,void 0),A(this,`_exporter`,void 0),A(this,`_isExporting`,!1),A(this,`_finishedSpans`,[]),A(this,`_timer`,void 0),A(this,`_shutdownOnce`,void 0),A(this,`_droppedSpansCount`,0),this._exporter=e,this._maxExportBatchSize=typeof(t==null?void 0:t.maxExportBatchSize)==`number`?t.maxExportBatchSize:(n=void 0)==null?512:n,this._maxQueueSize=typeof(t==null?void 0:t.maxQueueSize)==`number`?t.maxQueueSize:(r=void 0)==null?2048:r,this._scheduledDelayMillis=typeof(t==null?void 0:t.scheduledDelayMillis)==`number`?t.scheduledDelayMillis:(i=void 0)==null?5e3:i,this._exportTimeoutMillis=typeof(t==null?void 0:t.exportTimeoutMillis)==`number`?t.exportTimeoutMillis:(a=void 0)==null?3e4:a,this._shutdownOnce=new Sr(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(T.warn(`BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&C.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>this._exporter.shutdown())}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize){this._droppedSpansCount===0&&T.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++;return}this._droppedSpansCount>0&&(T.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let e=0,t=r;e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout`))},this._exportTimeoutMillis);w.with(Ut(w.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);let i=()=>this._exporter.export(r,r=>{if(clearTimeout(n),r.code===L.SUCCESS)e();else{var i;t((i=r.error)==null?Error(`BatchSpanProcessor: span export failed`):i)}}),a=null;for(let e=0,t=r.length;e<t;e++){let t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a!=null||(a=[]),a.push(t.resource.waitForAsyncAttributes()))}a===null?i():Promise.all(a).then(i,e=>{j(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,j(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}},Yr=class extends Jr{constructor(e,t){super(e,t),A(this,`_visibilityChangeListener`,void 0),A(this,`_pageHideListener`,void 0),this.onInit(t)}onInit(e){(e==null?void 0:e.disableAutoFlushOnDocumentHide)!==!0&&typeof document<`u`&&(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush().catch(e=>{j(e)})},this._pageHideListener=()=>{this.forceFlush().catch(e=>{j(e)})},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}onShutdown(){typeof document<`u`&&(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}},Xr=class{constructor(){A(this,`generateTraceId`,Qr(16)),A(this,`generateSpanId`,Qr(8))}};let Zr=Array(32);function Qr(e){return function(){for(let t=0;t<e*2;t++)Zr[t]=Math.floor(Math.random()*16)+48,Zr[t]>=58&&(Zr[t]+=39);return String.fromCharCode.apply(null,Zr.slice(0,e*2))}}var $r=class{constructor(e,t,n,r){A(this,`_sampler`,void 0),A(this,`_generalLimits`,void 0),A(this,`_spanLimits`,void 0),A(this,`_idGenerator`,void 0),A(this,`instrumentationScope`,void 0),A(this,`_resource`,void 0),A(this,`_spanProcessor`,void 0);let i=Kr(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new Xr,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e}startSpan(e,t={},n=w.active()){var r,i,a;t.root&&(n=D.deleteSpan(n));let o=D.getSpan(n);if(Wt(n))return T.debug(`Instrumentation suppressed, returning Noop Span`),D.wrapSpanContext(Ve);let s=o==null?void 0:o.spanContext(),c=this._idGenerator.generateSpanId(),l,u,d;!s||!D.isSpanContextValid(s)?u=this._idGenerator.generateTraceId():(u=s.traceId,d=s.traceState,l=s);let f=(r=t.kind)==null?ut.INTERNAL:r,p=((i=t.links)==null?[]:i).map(e=>({context:e.context,attributes:$t(e.attributes)})),ee=$t(t.attributes),m=this._sampler.shouldSample(n,u,e,f,ee,p);d=(a=m.traceState)==null?d:a;let h=m.decision===lt.RECORD_AND_SAMPLED?C.SAMPLED:C.NONE,te={traceId:u,spanId:c,traceFlags:h,traceState:d};if(m.decision===lt.NOT_RECORD)return T.debug(`Recording is off, propagating context in a non-recording span`),D.wrapSpanContext(te);let g=$t(Object.assign(ee,m.attributes));return new Lr({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:te,name:e,kind:f,links:p,parentSpanContext:l,attributes:g,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits})}startActiveSpan(e,t,n,r){var i;let a,o,s;if(arguments.length<2)return;arguments.length===2?s=t:arguments.length===3?(a=t,s=n):(a=t,o=n,s=r);let c=(i=o)==null?w.active():i,l=this.startSpan(e,a,c),u=D.setSpan(c,l);return w.with(u,s,void 0,l)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}},ei=class{constructor(e){A(this,`_spanProcessors`,void 0),this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{j(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}},H;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(H||(H={}));var ti=class{constructor(e={}){var t,n;A(this,`_config`,void 0),A(this,`_tracers`,new Map),A(this,`_resource`,void 0),A(this,`_activeSpanProcessor`,void 0);let r=cr({},Ur(),qr(e));this._resource=(t=r.resource)==null?Mr():t,this._config=Object.assign({},r,{resource:this._resource});let i=[];(n=e.spanProcessors)!=null&&n.length&&i.push(...e.spanProcessors),this._activeSpanProcessor=new ei(i)}getTracer(e,t,n){let r=`${e}@${t||``}:${(n==null?void 0:n.schemaUrl)||``}`;return this._tracers.has(r)||this._tracers.set(r,new $r({name:e,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){let e=this._config.forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${e} ms`)),r=H.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==H.timeout&&(r=H.resolved,n(r))}).catch(e=>{clearTimeout(i),r=H.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==H.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}},ni=class{constructor(){A(this,`_enabled`,!1),A(this,`_currentContext`,y)}_bindFunction(e=y,t){let n=this,r=function(...r){return n.with(e,()=>t.apply(this,r))};return Object.defineProperty(r,`length`,{enumerable:!1,configurable:!0,writable:!1,value:t.length}),r}active(){return this._currentContext}bind(e,t){return e===void 0&&(e=this.active()),typeof t==`function`?this._bindFunction(e,t):t}disable(){return this._currentContext=y,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=y,this)}with(e,t,n,...r){let i=this._currentContext;this._currentContext=e||y;try{return t.call(n,...r)}finally{this._currentContext=i}}};function ri(e){if(e!==null){if(e===void 0){let e=new ni;e.enable(),w.setGlobalContextManager(e);return}e.enable(),w.setGlobalContextManager(e)}}function ii(e){if(e!==null){if(e===void 0){E.setGlobalPropagator(new In({propagators:[new Xn,new Yt]}));return}E.setGlobalPropagator(e)}}var ai=class extends ti{constructor(e={}){super(e)}register(e={}){D.setGlobalTracerProvider(this),ii(e.propagator),ri(e.contextManager)}},U;(function(e){e.CONNECT_END=`connectEnd`,e.CONNECT_START=`connectStart`,e.DECODED_BODY_SIZE=`decodedBodySize`,e.DOM_COMPLETE=`domComplete`,e.DOM_CONTENT_LOADED_EVENT_END=`domContentLoadedEventEnd`,e.DOM_CONTENT_LOADED_EVENT_START=`domContentLoadedEventStart`,e.DOM_INTERACTIVE=`domInteractive`,e.DOMAIN_LOOKUP_END=`domainLookupEnd`,e.DOMAIN_LOOKUP_START=`domainLookupStart`,e.ENCODED_BODY_SIZE=`encodedBodySize`,e.FETCH_START=`fetchStart`,e.LOAD_EVENT_END=`loadEventEnd`,e.LOAD_EVENT_START=`loadEventStart`,e.NAVIGATION_START=`navigationStart`,e.REDIRECT_END=`redirectEnd`,e.REDIRECT_START=`redirectStart`,e.REQUEST_START=`requestStart`,e.RESPONSE_END=`responseEnd`,e.RESPONSE_START=`responseStart`,e.SECURE_CONNECTION_START=`secureConnectionStart`,e.START_TIME=`startTime`,e.UNLOAD_EVENT_END=`unloadEventEnd`,e.UNLOAD_EVENT_START=`unloadEventStart`})(U||(U={}));let oi;function si(){return oi||(oi=document.createElement(`a`)),oi}function ci(e,t){return t in e}function W(e,t,n,r=!0){if(ci(n,t)&&typeof n[t]==`number`&&!(r&&n[t]===0))return e.addEvent(t,n[t])}function li(e,t,n=!1,r,i){if(r===void 0&&(r=t[U.START_TIME]!==0),n||(W(e,U.FETCH_START,t,r),W(e,U.DOMAIN_LOOKUP_START,t,r),W(e,U.DOMAIN_LOOKUP_END,t,r),W(e,U.CONNECT_START,t,r),W(e,U.SECURE_CONNECTION_START,t,r),W(e,U.CONNECT_END,t,r),W(e,U.REQUEST_START,t,r),W(e,U.RESPONSE_START,t,r),W(e,U.RESPONSE_END,t,r)),!i){let n=t[U.ENCODED_BODY_SIZE];n!==void 0&&e.setAttribute(`http.response_content_length`,n);let r=t[U.DECODED_BODY_SIZE];r!==void 0&&n!==r&&e.setAttribute(`http.response_content_length_uncompressed`,r)}}function ui(e){return e.slice().sort((e,t)=>{let n=e[U.FETCH_START],r=t[U.FETCH_START];return n>r?1:n<r?-1:0})}function di(){return typeof location<`u`?location.origin:void 0}function fi(e,t,n,r,i=new WeakSet,a){let o=G(e);e=o.toString();let s=mi(e,t,n,r,i,a);if(s.length===0)return{mainRequest:void 0};if(s.length===1)return{mainRequest:s[0]};let c=ui(s);if(o.origin!==di()&&c.length>1){let e=c[0],t=pi(c,e[U.RESPONSE_END],n),r=e[U.RESPONSE_END];return t[U.FETCH_START]<r&&(t=e,e=void 0),{corsPreFlightRequest:e,mainRequest:t}}else return{mainRequest:s[0]}}function pi(e,t,n){let r=I(n),i=I(F(t)),a=e[1],o,s=e.length;for(let t=1;t<s;t++){let n=e[t],s=I(F(n[U.FETCH_START])),c=r-I(F(n[U.RESPONSE_END]));s>=i&&(!o||c<o)&&(o=c,a=n)}return a}function mi(e,t,n,r,i,a){let o=I(t),s=I(n),c=r.filter(t=>{let n=I(F(t[U.FETCH_START])),r=I(F(t[U.RESPONSE_END]));return t.initiatorType.toLowerCase()===(a||`xmlhttprequest`)&&t.name===e&&n>=o&&r<=s});return c.length>0&&(c=c.filter(e=>!i.has(e))),c}function G(e){if(typeof URL==`function`)return new URL(e,typeof document<`u`?document.baseURI:typeof location<`u`?location.href:void 0);let t=si();return t.href=e,t}function hi(e,t){let n=t||[];return(typeof n==`string`||n instanceof RegExp)&&(n=[n]),G(e).origin===di()?!0:n.some(t=>yr(e,t))}let gi=`mxl_pending_`;var _i=class{constructor({resource:e=jr(),storage:t=window.localStorage,diag:n=T.createComponentLogger({namespace:`MXLSpanStorage`}),storedSpansExpireTimeoutMS:r=3600*1e3,onExpiredSpansExport:i,spanSessionManager:a}){A(this,`_noExportTracer`,void 0),A(this,`_storage`,void 0),A(this,`_diag`,void 0),A(this,`_onExpiredSpansExport`,void 0),A(this,`_storedSpansExpireTimeoutMS`,void 0),A(this,`_spanSessionManager`,void 0),A(this,`_checkExpiredSpansInterval`,void 0),this._noExportTracer=new ti({resource:e}).getTracer(`mxl-web-sdk-sessions`),this._storage=t,this._diag=n,this._storedSpansExpireTimeoutMS=r,this._onExpiredSpansExport=i,this._spanSessionManager=a,this.startExpiredSpansCheck()}storePendingSpans(e,t,n){try{if(this.clearStoredSpans(e),this._getPendingSpansKeys().length>=10){this._spanSessionManager.incrSessionCountForKey(`mxl.max_pending_spans_reached`),this._diag.warn(`Not storing pending spans as the max number of items was reached`);return}let r=`${gi}${e}_${Date.now()}`;this._storage.setItem(r,JSON.stringify([t,...n],(e,t)=>e.startsWith(`_`)?void 0:t)),this._diag.debug(`Stored pending span: ${r}`)}catch(e){this._diag.error(`Failed to store spans to storage:`,e)}}clearStoredSpans(e){try{let t=`${gi}${e}_`;this._getPendingSpansKeys().forEach(e=>{e.startsWith(t)&&this._storage.removeItem(e)})}catch(e){this._diag.error(`Failed to clear stored spans from storage:`,e)}}startExpiredSpansCheck(){this._checkExpiredSpansInterval=setInterval(()=>{this.checkAndExportExpiredSpans()},300*1e3)}stopExpiredSpansCheck(){this._checkExpiredSpansInterval&&(clearInterval(this._checkExpiredSpansInterval),this._checkExpiredSpansInterval=void 0)}checkAndExportExpiredSpans(){try{let e=this._getPendingSpansKeys();if(e.length===0)return;let t=Date.now();e.forEach(e=>{let n=e.split(`_`),r=parseInt(n[n.length-1],10);if(Number.isNaN(r)&&(this._diag.error(`Found invalid timestamp in stored span:`,r),this._storage.removeItem(e)),t-r<=this._storedSpansExpireTimeoutMS)return;let i=this._storage.getItem(e);if(i){try{let e=[];for(let t of JSON.parse(i)){let n=this._noExportTracer.startSpan(t.name,{kind:t.kind,attributes:t.attributes,links:t.links,startTime:t.startTime});n.setStatus(t.status),n.end(t.endTime),e.push(n)}this._onExpiredSpansExport&&e.length>0&&this._onExpiredSpansExport(e)}catch(e){this._diag.error(`Failed to process expired spans:`,e)}this._storage.removeItem(e)}})}catch(e){this._diag.error(`Failed to check and export expired spans:`,e)}}_getPendingSpansKeys(){let e=[];for(let t=0;t<this._storage.length;t++){let n=this._storage.key(t);n!=null&&n.startsWith(gi)&&e.push(n)}return e}destroy(){this.stopExpiredSpansCheck()}},vi=class{constructor(e,t){A(this,`_keyPrefix`,void 0),A(this,`_storage`,void 0),this._keyPrefix=`${e}_`,this._storage=t}getNamespacedKeys(){let e=[];for(let t=0;t<this._storage.length;t++){let n=this._storage.key(t);n!=null&&n.startsWith(this._keyPrefix)&&e.push(n.substring(this._keyPrefix.length))}return e}get length(){return this.getNamespacedKeys().length}clear(){this.getNamespacedKeys().forEach(e=>{this._storage.removeItem(`${this._keyPrefix}${e}`)})}getItem(e){return this._storage.getItem(`${this._keyPrefix}${e}`)}key(e){return this.getNamespacedKeys()[e]||null}removeItem(e){this._storage.removeItem(`${this._keyPrefix}${e}`)}setItem(e,t){this._storage.setItem(`${this._keyPrefix}${e}`,t)}};let yi=({diag:e,featureManager:t,registerGlobally:n,propagator:r,defaultInstrumentationConfig:i})=>{var a;if(!t.isNetworkSpanForwardingEnabled())return!1;let o=[];return n||o.push("Network span forwarding cannot be used when `registerGlobally` is set to false. Turning off network span forwarding."),r&&o.push("Network span forwarding cannot be used alongside a custom `propagator`. Turning off network span forwarding."),!(i==null||(a=i.omit)==null)&&a.has(`@opentelemetry/instrumentation-xml-http-request`)&&i.omit.has(`@opentelemetry/instrumentation-fetch`)&&o.push(`Network span forwarding cannot be used when both '@opentelemetry/instrumentation-xml-http-request' and '@opentelemetry/instrumentation-fetch' are omitted. Turning off network span forwarding.`),o.forEach(t=>{e.warn(t)}),o.length===0};var bi=class{constructor(e=window.performance){A(this,`_clock`,void 0),A(this,`epochMillisFromOriginOffset`,e=>this._clock.timeOrigin+e),A(this,`getNowHRTime`,()=>P(this.getNowMillis())),A(this,`getNowMillis`,()=>this.epochMillisFromOriginOffset(this._clock.now())),A(this,`millisSinceHRTime`,e=>this.getNowMillis()-Mn(e)),this._clock=e}};let xi=(e,t=1e3)=>{let n=!1;return(...r)=>{n||(e(...r),setTimeout(()=>{n=!1},t),n=!0)}};var Si=class{logException(e,t){}message(e,t,n){}};let Ci=new Si;var wi=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Ci:e}setDelegate(e){this._delegate=e}logException(e,t){this.getDelegate().logException(e,t)}message(e,t,n){this.getDelegate().message(e,t,n)}};let Ti=new Si,Ei=new Set([`setDelegate`,`getDelegate`]);var Di=class e{static getInstance(){if(!e._instance){let t=new wi,n=Et(t,Ti,T.createComponentLogger({namespace:`LogAPI`}),Ei);e._instance=Object.assign(n,{setGlobalLogManager(e){t.setDelegate(e)},getLogManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(Di,`_instance`,void 0);let Oi=Di.getInstance();var ki=class{setCurrentRoute(e){}getCurrentRoute(){return null}getCurrentPageId(){return``}clearCurrentRoute(){}};let Ai=new ki;var ji=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Ai:e}setDelegate(e){this._delegate=e}setCurrentRoute(e){this.getDelegate().setCurrentRoute(e)}getCurrentRoute(){return this.getDelegate().getCurrentRoute()}getCurrentPageId(){return this.getDelegate().getCurrentPageId()}clearCurrentRoute(){this.getDelegate().clearCurrentRoute()}};let Mi=new ki,Ni=new Set([`setDelegate`,`getDelegate`]);var Pi=class e{static getInstance(){if(!e._instance){let t=new ji,n=Et(t,Mi,T.createComponentLogger({namespace:`PageAPI`}),Ni);e._instance=Object.assign(n,{setGlobalPageManager(e){t.setDelegate(e)},getPageManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(Pi,`_instance`,void 0);let K=Pi.getInstance();var Fi=class{constructor(){A(this,`getSessionId`,()=>null),A(this,`getPreviousSessionId`,()=>null)}addBreadcrumb(e){}addProperty(e,t,n){}removeProperty(e){}endSessionSpan(){}endSessionSpanInternal(e){}currentSessionAsReadableSpan(e){return null}getSessionSpan(){return null}getSessionStartTime(){return null}startSessionSpan(){}addSessionStartedListener(e){return()=>{}}addSessionEndedListener(e){return()=>{}}};let Ii=new Fi;var Li=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Ii:e}setDelegate(e){this._delegate=e}addBreadcrumb(e){this.getDelegate().addBreadcrumb(e)}addProperty(e,t,n){this.getDelegate().addProperty(e,t,n)}removeProperty(e){this.getDelegate().removeProperty(e)}endSessionSpan(){this.getDelegate().endSessionSpan()}endSessionSpanInternal(e){this.getDelegate().endSessionSpanInternal(e)}currentSessionAsReadableSpan(e){return this.getDelegate().currentSessionAsReadableSpan(e)}getSessionId(){return this.getDelegate().getSessionId()}getPreviousSessionId(){return this.getDelegate().getPreviousSessionId()}getSessionSpan(){return this.getDelegate().getSessionSpan()}getSessionStartTime(){return this.getDelegate().getSessionStartTime()}startSessionSpan(e){this.getDelegate().startSessionSpan(e)}addSessionStartedListener(e){return this.getDelegate().addSessionStartedListener(e)}addSessionEndedListener(e){return this.getDelegate().addSessionEndedListener(e)}};let Ri=new Fi,zi=new Set([`setDelegate`,`getDelegate`]);var Bi=class e{static getInstance(){if(!e._instance){let t=new Li,n=Et(t,Ri,T.createComponentLogger({namespace:`SessionAPI`}),zi);e._instance=Object.assign(n,{setGlobalSessionManager(e){t.setDelegate(e)},getSpanSessionManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(Bi,`_instance`,void 0);let Vi=Bi.getInstance();var Hi=class{constructor(e=Ve){A(this,`_spanContext`,void 0),A(this,`attributes`,{}),this._spanContext=e}fail(e){}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}removeAttribute(e){return this}addEvent(e,t,n){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}},Ui=class{startSpan(e,t){return new Hi}setSpan(e,t){return y}getSpan(e){}};let Wi=new Ui;var Gi=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Wi:e}setDelegate(e){this._delegate=e}startSpan(e,t,n){return this.getDelegate().startSpan(e,t,n)}setSpan(e,t){return this.getDelegate().setSpan(e,t)}getSpan(e){return this.getDelegate().getSpan(e)}};let Ki=new Ui,qi=new Set([`setDelegate`,`getDelegate`]);var Ji=class e{static getInstance(){if(!e._instance){let t=new Gi,n=Et(t,Ki,T.createComponentLogger({namespace:`TraceAPI`}),qi);e._instance=Object.assign(n,{setGlobalTraceManager(e){t.setDelegate(e)},getTraceManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(Ji,`_instance`,void 0);let Yi=Ji.getInstance(),Xi=`enduser.pseudo.id`;var Zi=class{getMXLUserId(){return``}getUserId(){return null}setUserId(){}clearUserId(){}};let Qi=new Zi;var $i=class{constructor(){A(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Qi:e}setDelegate(e){this._delegate=e}getMXLUserId(){return this.getDelegate().getMXLUserId()}getUserId(){return this.getDelegate().getUserId()}setUserId(e){this.getDelegate().setUserId(e)}clearUserId(){this.getDelegate().clearUserId()}};let ea=new Zi,ta=new Set([`setDelegate`,`getDelegate`]);var na=class e{static getInstance(){if(!e._instance){let t=new $i,n=Et(t,ea,T.createComponentLogger({namespace:`UserAPI`}),ta);e._instance=Object.assign(n,{setGlobalUserManager(e){t.setDelegate(e)},getUserManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};A(na,`_instance`,void 0);let ra=na.getInstance(),ia={compression:`gzip`,keepalive:!0,concurrencyLimit:5,timeoutMillis:30*1e3},aa=(e,t)=>({"X-MXL-AID":e,"X-MXL-DID":t}),oa=(e,t)=>t||`http://mxl-otelcol.service-availability.apps.ocpthikadev01.safaricom.net`,sa=Math.pow(10,9);function ca(e){return e[0]*sa+e[1]}function la(e){return e>=48&&e<=57?e-48:e>=97&&e<=102?e-87:e-55}function ua(e){let t=new Uint8Array(e.length/2),n=0;for(let r=0;r<e.length;r+=2){let i=la(e.charCodeAt(r)),a=la(e.charCodeAt(r+1));t[n++]=i<<4|a}return t}function da(e){let t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function fa(e){return{low:Number(BigInt.asUintN(32,e)),high:Number(BigInt.asUintN(32,e>>BigInt(32)))}}function pa(e){return fa(da(e))}function ma(e){return da(e).toString()}let ha=typeof BigInt<`u`?ma:ca;function ga(e){return e}function _a(e){if(e!==void 0)return ua(e)}let va={encodeHrTime:pa,encodeSpanContext:ua,encodeOptionalSpanContext:_a};function ya(e){var t,n;if(e===void 0)return va;let r=(t=e.useLongBits)==null?!0:t,i=(n=e.useHex)==null?!1:n;return{encodeHrTime:r?pa:ha,encodeSpanContext:i?ga:ua,encodeOptionalSpanContext:i?ga:_a}}function ba(e){let t={attributes:Sa(e.attributes),droppedAttributesCount:0},n=e.schemaUrl;return n&&n!==``&&(t.schemaUrl=n),t}function xa(e){return{name:e.name,version:e.version}}function Sa(e){return Object.keys(e).map(t=>Ca(t,e[t]))}function Ca(e,t){return{key:e,value:wa(t)}}function wa(e){let t=typeof e;return t===`string`?{stringValue:e}:t===`number`?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:t===`boolean`?{boolValue:e}:e instanceof Uint8Array?{bytesValue:e}:Array.isArray(e)?{arrayValue:{values:e.map(wa)}}:t===`object`&&e!=null?{kvlistValue:{values:Object.entries(e).map(([e,t])=>Ca(e,t))}}:{}}function Ta(e,t){return{resourceLogs:Da(e,ya(t))}}function Ea(e){let t=new Map;for(let n of e){let{resource:e,instrumentationScope:{name:r,version:i=``,schemaUrl:a=``}}=n,o=t.get(e);o||(o=new Map,t.set(e,o));let s=`${r}@${i}:${a}`,c=o.get(s);c||(c=[],o.set(s,c)),c.push(n)}return t}function Da(e,t){let n=Ea(e);return Array.from(n,([e,n])=>{let r=ba(e);return{resource:r,scopeLogs:Array.from(n,([,e])=>({scope:xa(e[0].instrumentationScope),logRecords:e.map(e=>Oa(e,t)),schemaUrl:e[0].instrumentationScope.schemaUrl})),schemaUrl:r.schemaUrl}})}function Oa(e,t){var n,r,i;return{timeUnixNano:t.encodeHrTime(e.hrTime),observedTimeUnixNano:t.encodeHrTime(e.hrTimeObserved),severityNumber:ka(e.severityNumber),severityText:e.severityText,body:wa(e.body),eventName:e.eventName,attributes:Aa(e.attributes),droppedAttributesCount:e.droppedAttributesCount,flags:(n=e.spanContext)==null?void 0:n.traceFlags,traceId:t.encodeOptionalSpanContext((r=e.spanContext)==null?void 0:r.traceId),spanId:t.encodeOptionalSpanContext((i=e.spanContext)==null?void 0:i.spanId)}}function ka(e){return e}function Aa(e){return Object.keys(e).map(t=>Ca(t,e[t]))}function ja(e,t){let n=e&255|256;return t&&(n|=512),n}function Ma(e,t){var n,r,i,a;let o=e.spanContext(),s=e.status,c=(n=e.parentSpanContext)!=null&&n.spanId?t.encodeSpanContext((r=e.parentSpanContext)==null?void 0:r.spanId):void 0;return{traceId:t.encodeSpanContext(o.traceId),spanId:t.encodeSpanContext(o.spanId),parentSpanId:c,traceState:(i=o.traceState)==null?void 0:i.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:Sa(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Pa(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:s.code,message:s.message},links:e.links.map(e=>Na(e,t)),droppedLinksCount:e.droppedLinksCount,flags:ja(o.traceFlags,(a=e.parentSpanContext)==null?void 0:a.isRemote)}}function Na(e,t){var n;return{attributes:e.attributes?Sa(e.attributes):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(n=e.context.traceState)==null?void 0:n.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:ja(e.context.traceFlags,e.context.isRemote)}}function Pa(e,t){return{attributes:e.attributes?Sa(e.attributes):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Fa(e,t){return{resourceSpans:La(e,ya(t))}}function Ia(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function La(e,t){let n=Ia(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>Ma(e,t));o.push({scope:xa(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=ba(e),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}let Ra={serializeRequest:e=>{let t=Ta(e,{useHex:!0,useLongBits:!1});return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;return JSON.parse(t.decode(e))}},za={serializeRequest:e=>{let t=Fa(e,{useHex:!0,useLongBits:!1});return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;return JSON.parse(t.decode(e))}};var Ba=class{constructor(e){this._delegate=e}export(e,t){this._delegate.export(e,t)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}},Va=class extends Error{constructor(e,t,n){super(e),A(this,`code`,void 0),A(this,`name`,`OTLPExporterError`),A(this,`data`,void 0),this.data=n,this.code=t}},Ha=class{constructor(e){A(this,`_concurrencyLimit`,void 0),A(this,`_sendingPromises`,[]),this._concurrencyLimit=e}pushPromise(e){if(this.hasReachedLimit())throw Error(`Concurrency Limit reached`);this._sendingPromises.push(e);let t=()=>{let t=this._sendingPromises.indexOf(e);this._sendingPromises.splice(t,1)};e.then(t,t)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}awaitAll(){var e=this;return z(function*(){yield Promise.all(e._sendingPromises)})()}};function Ua(e){return new Ha(e.concurrencyLimit)}function Wa(e){return Object.prototype.hasOwnProperty.call(e,`partialSuccess`)}function Ga(){return{handleResponse(e){e==null||!Wa(e)||e.partialSuccess==null||Object.keys(e.partialSuccess).length===0||T.warn(`Received Partial Success response:`,JSON.stringify(e.partialSuccess))}}}var Ka=class{constructor(e,t,n,r,i){A(this,`_diagLogger`,void 0),A(this,`_transport`,void 0),A(this,`_serializer`,void 0),A(this,`_responseHandler`,void 0),A(this,`_promiseQueue`,void 0),A(this,`_timeout`,void 0),this._transport=e,this._serializer=t,this._responseHandler=n,this._promiseQueue=r,this._timeout=i,this._diagLogger=T.createComponentLogger({namespace:`OTLPExportDelegate`})}export(e,t){if(this._diagLogger.debug(`items to be sent`,e),this._promiseQueue.hasReachedLimit()){t({code:L.FAILED,error:Error(`Concurrent export limit reached`)});return}let n=this._serializer.serializeRequest(e);if(n==null){t({code:L.FAILED,error:Error(`Nothing to send`)});return}this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(e=>{if(e.status===`success`){if(e.data!=null)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(e.data))}catch(t){this._diagLogger.warn(`Export succeeded but could not deserialize response - is the response specification compliant?`,t,e.data)}t({code:L.SUCCESS});return}else if(e.status===`failure`&&e.error){t({code:L.FAILED,error:e.error});return}else if(e.status===`retryable`){var n;t({code:L.FAILED,error:(n=e.error)==null?new Va(`Export failed with retryable status`):n})}else t({code:L.FAILED,error:new Va(`Export failed with unknown error`)})},e=>t({code:L.FAILED,error:e})))}forceFlush(){return this._promiseQueue.awaitAll()}shutdown(){var e=this;return z(function*(){e._diagLogger.debug(`shutdown started`),yield e.forceFlush(),e._transport.shutdown()})()}};function qa(e,t){return new Ka(e.transport,e.serializer,Ga(),e.promiseHandler,t.timeout)}function Ja(e,t,n){return qa({transport:n,serializer:t,promiseHandler:Ua(e)},{timeout:e.timeoutMillis})}var Ya=class e{constructor(e){this._config=e}static _compressRequest(e){return z(function*(){let t=new CompressionStream(`gzip`),n=t.writable.getWriter();n.write(e),n.close();let r=[],i=t.readable.getReader(),a=!1;for(;!a;){let e=yield i.read();e.value&&r.push(e.value),a=e.done}let o=new Uint8Array(r.reduce((e,t)=>e+t.length,0)),s=0;for(let e of r)o.set(e,s),s+=e.length;return o})()}send(e,t){return this._asyncSend(e,t)}shutdown(){}_asyncSend(t,n){var r=this;return z(function*(){let i=t,a=B({"Content-Type":`application/json`},r._config.headers);r._config.compression===`gzip`&&(i=yield e._compressRequest(t),a[`Content-Encoding`]=`gzip`,a[`Content-Length`]=i.length.toString());let o,s,c=`timeout`in AbortSignal,l=Number.isFinite(n)&&n>=0?Math.floor(n):1e4;if(c&&Number.isFinite(n)&&n>=0)o=AbortSignal.timeout(l);else{let e=new AbortController;o=e.signal,s=setTimeout(()=>{e.abort(new DOMException(`TimeoutError`,`TimeoutError`))},l)}try{var u;let t=Ut(w.active()),n=(u=e._baseFetch)==null?globalThis.fetch:u,s=yield w.with(t,()=>n(r._config.url,{method:`POST`,keepalive:!0,headers:a,body:i,signal:o}));return s.ok?{status:`success`}:{status:`failure`,error:Error(`${s.status} Fetch request failed`)}}catch(e){let t=Error(e instanceof Error?e.message:String(e));return t.name=`MXLExporterError`,t.cause=e,t.mxlExporter=!0,t.url=r._config.url,{status:`failure`,error:t}}finally{s!==void 0&&clearTimeout(s)}})()}};A(Ya,`_baseFetch`,typeof globalThis.fetch==`function`?globalThis.fetch.bind(globalThis):void 0);let Xa=e=>new Ya(e),Za=()=>Math.random()*40-20;var Qa=class{constructor(e,t=new bi){this._transport=e,this._perf=t}send(e,t){var n=this;return z(function*(){let r=n._perf.getNowMillis()+t,i=yield n._transport.send(e,t),a=5,o=1e3;for(;i.status===`retryable`&&a>0;){var s;a--;let t=Math.max(Math.min(o,5e3)+Za(),0);o*=1.5;let c=(s=i.retryInMillis)==null?t:s,l=r-n._perf.getNowMillis();if(c>l)return i;i=yield n._retry(e,l,c)}return i})()}shutdown(){this._transport.shutdown()}_retry(e,t,n){return new Promise((r,i)=>{setTimeout(()=>{this._transport.send(e,t).then(r,i)},n)})}};let $a=e=>{var t;return new Qa(e.transport,(t=e.perf)==null?new bi:t)},eo=(e,t)=>Ja(e,t,$a({transport:Xa(e)}));var to=class extends Ba{constructor(e){super(eo(e,Ra))}};let no=(e,t)=>`${oa(e,t)}/v1/logs`;var ro=class extends to{constructor({appID:e,userID:t,mxlDataURL:n}){super(B(B({},ia),{},{headers:aa(e,t),url:no(e,n)}))}},io=class extends Ba{constructor(e){super(eo(B(B({},e),{},{compression:`gzip`}),za))}};let ao=(e,t)=>`${oa(e,t)}/v1/traces`;var oo=class extends io{constructor({appID:e,userID:t,mxlDataURL:n}){super(B(B({},ia),{},{headers:aa(e,t),url:ao(e,n)}))}},q;(function(e){e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRACE=1]=`TRACE`,e[e.TRACE2=2]=`TRACE2`,e[e.TRACE3=3]=`TRACE3`,e[e.TRACE4=4]=`TRACE4`,e[e.DEBUG=5]=`DEBUG`,e[e.DEBUG2=6]=`DEBUG2`,e[e.DEBUG3=7]=`DEBUG3`,e[e.DEBUG4=8]=`DEBUG4`,e[e.INFO=9]=`INFO`,e[e.INFO2=10]=`INFO2`,e[e.INFO3=11]=`INFO3`,e[e.INFO4=12]=`INFO4`,e[e.WARN=13]=`WARN`,e[e.WARN2=14]=`WARN2`,e[e.WARN3=15]=`WARN3`,e[e.WARN4=16]=`WARN4`,e[e.ERROR=17]=`ERROR`,e[e.ERROR2=18]=`ERROR2`,e[e.ERROR3=19]=`ERROR3`,e[e.ERROR4=20]=`ERROR4`,e[e.FATAL=21]=`FATAL`,e[e.FATAL2=22]=`FATAL2`,e[e.FATAL3=23]=`FATAL3`,e[e.FATAL4=24]=`FATAL4`})(q||(q={}));var so=class{emit(e){}};let co=new so,lo=Symbol.for(`io.opentelemetry.js.api.logs`),uo=globalThis;function fo(e,t,n){return r=>r===e?t:n}let po=new class{getLogger(e,t,n){return new so}};var mo=class{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}emit(e){this._getLogger().emit(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):co}},ho=class{getLogger(e,t,n){var r;return(r=this._getDelegateLogger(e,t,n))==null?new mo(this,e,t,n):r}_getDelegate(){var e;return(e=this._delegate)==null?po:e}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,t,n){var r;return(r=this._delegate)==null?void 0:r.getLogger(e,t,n)}};let go=class e{constructor(){this._proxyLoggerProvider=new ho}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalLoggerProvider(e){return uo[lo]?this.getLoggerProvider():(uo[lo]=fo(1,e,po),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,t;return(t=(e=uo[lo])==null?void 0:e.call(uo,1))==null?this._proxyLoggerProvider:t}getLogger(e,t,n){return this.getLoggerProvider().getLogger(e,t,n)}disable(){delete uo[lo],this._proxyLoggerProvider=new ho}}.getInstance();function _o(e,t,n,r){for(let i=0,a=e.length;i<a;i++){let a=e[i];t&&a.setTracerProvider(t),n&&a.setMeterProvider(n),r&&a.setLoggerProvider&&a.setLoggerProvider(r),a.getConfig().enabled||a.enable()}}function vo(e){e.forEach(e=>e.disable())}function yo(e){var t,n;let r=e.tracerProvider||D.getTracerProvider(),i=e.meterProvider||mt.getMeterProvider(),a=e.loggerProvider||go.getLoggerProvider(),o=(t=(n=e.instrumentations)==null?void 0:n.flat())==null?[]:t;return _o(o,r,i,a),()=>{vo(o)}}let J=console.error.bind(console);function bo(e,t,n){let r=!!e[t]&&Object.prototype.propertyIsEnumerable.call(e,t);Object.defineProperty(e,t,{configurable:!0,enumerable:r,writable:!0,value:n})}let xo=(e,t,n)=>{if(!e||!e[t]){J(`no original function `+String(t)+` to wrap`);return}if(!n){J(`no wrapper function`),J(Error().stack);return}let r=e[t];if(typeof r!=`function`||typeof n!=`function`){J(`original object and wrapper must be functions`);return}let i=n(r,t);return bo(i,`__original`,r),bo(i,`__unwrap`,()=>{e[t]===i&&bo(e,t,r)}),bo(i,`__wrapped`,!0),bo(e,t,i),i},So=(e,t,n)=>{if(e)Array.isArray(e)||(e=[e]);else{J(`must provide one or more modules to patch`),J(Error().stack);return}if(!(t&&Array.isArray(t))){J(`must provide one or more functions to wrap on modules`);return}e.forEach(e=>{t.forEach(t=>{xo(e,t,n)})})},Co=(e,t)=>{if(!e||!e[t]){J(`no function to unwrap.`),J(Error().stack);return}let n=e[t];if(!n.__unwrap)J(`no original to unwrap to -- has `+String(t)+` already been unwrapped?`);else{n.__unwrap();return}},wo=(e,t)=>{if(e)Array.isArray(e)||(e=[e]);else{J(`must provide one or more modules to patch`),J(Error().stack);return}if(!(t&&Array.isArray(t))){J(`must provide one or more functions to unwrap on modules`);return}e.forEach(e=>{t.forEach(t=>{Co(e,t)})})};function To(e){e&&e.logger&&(typeof e.logger==`function`?J=e.logger:J(`new logger isn't a function, not replacing`))}To.wrap=xo,To.massWrap=So,To.unwrap=Co,To.massUnwrap=wo;var Eo=class{constructor(e,t,n){A(this,`_config`,{}),A(this,`_tracer`,void 0),A(this,`_meter`,void 0),A(this,`_logger`,void 0),A(this,`_diag`,void 0),A(this,`instrumentationName`,void 0),A(this,`instrumentationVersion`,void 0),A(this,`_wrap`,xo),A(this,`_unwrap`,Co),A(this,`_massWrap`,So),A(this,`_massUnwrap`,wo),this.instrumentationName=e,this.instrumentationVersion=t,this.setConfig(n),this._diag=T.createComponentLogger({namespace:e}),this._tracer=D.getTracer(e,t),this._meter=mt.getMeter(e,t),this._logger=go.getLogger(e,t),this._updateMetricInstruments()}get meter(){return this._meter}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){var e;let t=(e=this.init())==null?[]:e;return Array.isArray(t)?t:[t]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(e){this._config=B({enabled:!0},e)}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(e,t,n,r){if(e)try{e(n,r)}catch(e){this._diag.error(`Error running span customization hook due to exception in handler`,{triggerName:t},e)}}},Do=class extends Eo{constructor(e,t,n){super(e,t,n),this._config.enabled&&this.enable()}};function Oo(e,t,n){let r,i;try{i=e()}catch(e){r=e}finally{if(t(r,i),r&&!n)throw r;return i}}function ko(e){return typeof e==`function`&&typeof e.__original==`function`&&typeof e.__unwrap==`function`&&e.__wrapped===!0}var Y;(function(e){e[e.STABLE=1]=`STABLE`,e[e.OLD=2]=`OLD`,e[e.DUPLICATE=3]=`DUPLICATE`})(Y||(Y={}));function Ao(e,t){let n=Y.OLD,r=t==null?void 0:t.split(`,`).map(e=>e.trim()).filter(e=>e!==``);for(let t of r==null?[]:r)if(t.toLowerCase()===e+`/dup`){n=Y.DUPLICATE;break}else t.toLowerCase()===e&&(n=Y.STABLE);return n}let jo=`http.request.body.size`,Mo=`http.response.body.size`,No=`session.id`,Po=`user.id`;var Fo=class{constructor(e,t,n){this.instrumentationName=e,this.instrumentationVersion=t,A(this,`_config`,{}),A(this,`_diag`,void 0),A(this,`_tracer`,void 0),A(this,`_meter`,void 0),A(this,`_logger`,void 0),this.setConfig(n),this._diag=T.createComponentLogger({namespace:e}),this._tracer=D.getTracer(e,t),this._meter=mt.getMeter(e,t),this._logger=go.getLogger(e,t),this._updateMetricInstruments()}get tracer(){return this._tracer}get meter(){return this._meter}get logger(){return this._logger}getModuleDefinitions(){var e;let t=(e=this.init())==null?[]:e;return Array.isArray(t)?t:[t]}getConfig(){return this._config}setConfig(e){this._config=B({enabled:!0},e)}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}_updateMetricInstruments(){}_runSpanCustomizationHook(e,t,n,r){if(e)try{e(n,r)}catch(e){this._diag.error(`Error running span customization hook due to exception in handler`,{triggerName:t},e)}}},X=class extends Fo{constructor({instrumentationName:e,instrumentationVersion:t,config:n,diag:r,perf:i}){super(e,t,n),A(this,`_sessionManager`,void 0),A(this,`_logManager`,void 0),A(this,`_perf`,void 0),r&&(this._diag=r),this._perf=i==null?new bi:i,this._sessionManager=Vi.getSpanSessionManager(),this._logManager=Oi.getLogManager()}get sessionManager(){return this._sessionManager}get logManager(){return this._logManager}get perf(){return this._perf}init(){}setLogManager(e){this._logManager=e}setSessionManager(e){this._sessionManager=e}};let Io=function(e){return e.DOCUMENT_LOAD=`documentLoad`,e.DOCUMENT_FETCH=`documentFetch`,e.RESOURCE_FETCH=`resourceFetch`,e}({}),Lo=function(e){return e.FIRST_PAINT=`firstPaint`,e.FIRST_CONTENTFUL_PAINT=`firstContentfulPaint`,e}({}),Ro=()=>{let e={},t=window.performance.getEntriesByType(`navigation`)[0];return Object.values(U).forEach(n=>{if(ci(t,n)){let r=t[n];typeof r==`number`&&(e[n]=r)}}),e},zo={"first-paint":Lo.FIRST_PAINT,"first-contentful-paint":Lo.FIRST_CONTENTFUL_PAINT},Bo=e=>{window.performance.getEntriesByType(`paint`).forEach(({name:t,startTime:n})=>{ci(zo,t)&&e.addEvent(zo[t],n)})};var Vo=class extends X{constructor({diag:e,perf:t,enabled:n,applyCustomAttributesOnSpan:r,ignorePerformancePaintEvents:i=!1,ignoreNetworkEvents:a=!1}={}){super({instrumentationName:`DocumentLoadInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{enabled:n,applyCustomAttributesOnSpan:r,ignorePerformancePaintEvents:i,ignoreNetworkEvents:a}}),A(this,`_onDocumentLoaded`,void 0),A(this,`_performanceCollected`,!1),this._onDocumentLoaded=()=>{window.setTimeout(()=>{this._collectPerformance()},0)},this._config.enabled&&this.enable()}init(){this._diag.debug(`Initializing document load instrumentation`)}_addResourcesSpans(e){performance.getEntriesByType(`resource`).forEach(t=>{this._initResourceSpan(t,e)})}_collectPerformance(){if(this._performanceCollected)return;this._performanceCollected=!0;let e=Array.from(document.getElementsByTagName(`meta`)).find(e=>e.getAttribute(`name`)===Kn),t=Ro(),n=(e==null?void 0:e.content)||``;w.with(E.extract(y,{traceparent:n}),()=>{var e;let n=this._startSpan(Io.DOCUMENT_LOAD,U.FETCH_START,t);n&&(w.with(D.setSpan(w.active(),n),()=>{let e=this._startSpan(Io.DOCUMENT_FETCH,U.FETCH_START,t);e&&(e.setAttribute(M,location.href),w.with(D.setSpan(w.active(),e),()=>{var n;li(e,t,this.getConfig().ignoreNetworkEvents),this._addCustomAttributesOnSpan(e,(n=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:n.documentFetch),this._endSpan(e,U.RESPONSE_END,t)}))}),n.setAttribute(O,k.DocumentLoad),n.setAttribute(M,location.href),n.setAttribute(En,navigator.userAgent),this._addResourcesSpans(n),this.getConfig().ignoreNetworkEvents||(W(n,U.FETCH_START,t),W(n,U.UNLOAD_EVENT_START,t),W(n,U.UNLOAD_EVENT_END,t),W(n,U.DOM_INTERACTIVE,t),W(n,U.DOM_CONTENT_LOADED_EVENT_START,t),W(n,U.DOM_CONTENT_LOADED_EVENT_END,t),W(n,U.DOM_COMPLETE,t),W(n,U.LOAD_EVENT_START,t),W(n,U.LOAD_EVENT_END,t)),this.getConfig().ignorePerformancePaintEvents||Bo(n),this._addCustomAttributesOnSpan(n,(e=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:e.documentLoad),this._endSpan(n,U.LOAD_EVENT_END,t))})}_endSpan(e,t,n){e&&(ci(n,t)&&typeof n[t]==`number`?e.end(n[t]):e.end())}_initResourceSpan(e,t){var n;let r=this._startSpan(Io.RESOURCE_FETCH,U.FETCH_START,e,t);r&&(r.setAttribute(O,k.ResourceFetch),r.setAttribute(M,e.name),li(r,e,this.getConfig().ignoreNetworkEvents),e.deliveryType&&r.setAttribute(`http.response.delivery_type`,e.deliveryType),e.initiatorType&&r.setAttribute(`http.request.initiator_type`,e.initiatorType),e.renderBlockingStatus&&r.setAttribute(`http.request.render_blocking_status`,e.renderBlockingStatus),e.responseStatus&&r.setAttribute(yn,e.responseStatus),typeof e.encodedBodySize==`number`&&e.encodedBodySize>=0&&r.setAttribute(Mo,e.encodedBodySize),typeof e.transferSize==`number`&&e.transferSize>=0&&r.setAttribute(`http.response.size`,e.transferSize),typeof e.decodedBodySize==`number`&&e.decodedBodySize>=0&&r.setAttribute(`http.response.decoded_body_size`,e.decodedBodySize),this._addResourceDiagnosticAttributes(r,e),this._addCustomAttributesOnResourceSpan(r,e,(n=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:n.resourceFetch),this._endSpan(r,U.RESPONSE_END,e))}_startSpan(e,t,n,r){if(ci(n,t)&&typeof n[t]==`number`)return this.tracer.startSpan(e,{startTime:n[t]},r?D.setSpan(w.active(),r):void 0)}_waitForPageLoad(){window.document.readyState===`complete`?this._onDocumentLoaded():window.addEventListener(`load`,this._onDocumentLoaded)}_addCustomAttributesOnSpan(e,t){t&&Oo(()=>{t(e)},e=>{e&&this._diag.error(`addCustomAttributesOnSpan`,e)},!0)}_addCustomAttributesOnResourceSpan(e,t,n){n&&Oo(()=>{n(e,t)},e=>{e&&this._diag.error(`addCustomAttributesOnResourceSpan`,e)},!0)}_hasNoSizeData(e){let t=typeof e.transferSize==`number`?e.transferSize:0,n=typeof e.decodedBodySize==`number`?e.decodedBodySize:0,r=typeof e.encodedBodySize==`number`?e.encodedBodySize:0;return t===0&&n===0&&r===0}_hasTimingData(e){let t=typeof e.fetchStart==`number`?e.fetchStart:0,n=typeof e.responseEnd==`number`?e.responseEnd:0;return t>0&&n>0}_isCorsRestricted(e){return this._hasNoSizeData(e)&&this._hasTimingData(e)}_isFetchIncomplete(e){let t=typeof e.fetchStart==`number`?e.fetchStart:0,n=typeof e.responseEnd==`number`?e.responseEnd:0;return this._hasNoSizeData(e)&&t>0&&n===0}_isFetchPrevented(e){let t=typeof e.fetchStart==`number`?e.fetchStart:0;return this._hasNoSizeData(e)&&t===0}_isCacheValidated(e){let t=typeof e.transferSize==`number`?e.transferSize:0,n=typeof e.deliveryType==`string`?e.deliveryType:``;return t===300&&n!==`cache`}_addResourceDiagnosticAttributes(e,t){this._isCorsRestricted(t)?e.setAttribute(`http.response.cors_opaque`,!0):this._isFetchIncomplete(t)?e.setAttribute(`http.request.incomplete`,!0):this._isFetchPrevented(t)&&e.setAttribute(`http.request.prevented`,!0),this._isCacheValidated(t)&&e.setAttribute(`http.response.cache_revalidated`,!0)}enable(){window.removeEventListener(`load`,this._onDocumentLoaded),this._waitForPageLoad()}disable(){window.removeEventListener(`load`,this._onDocumentLoaded)}},Ho=class extends X{constructor({diag:e,perf:t,rootNode:n,emptyCheckDelayMs:r=500}){super({instrumentationName:`EmptyRootInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_observer`,void 0),A(this,`_emptyCheckDelayMs`,void 0),A(this,`_rootNode`,void 0),this._rootNode=n,this._emptyCheckDelayMs=r,this._observer=new MutationObserver((e,t)=>{this._observerCallback(e)}),this._config.enabled&&this._rootNode?this.enable():this._rootNode||this._diag.warn(`supplied root node was null, this instrumentation won't be enabled`)}disable(){this._observer.disconnect()}enable(){this._rootNode&&this._observer.observe(this._rootNode,{childList:!0})}_observerCallback(e){let t=!1,n=!1;for(let r of e)r.target===this._rootNode&&(r.removedNodes.length>0&&(t=!0),r.addedNodes.length>0&&(n=!0));t&&!n&&(this._diag.debug(`root node had child nodes removed without new ones being added, checking if it's empty in ${this._emptyCheckDelayMs}ms`),window.setTimeout(()=>{this._checkForEmptyRootNode()},this._emptyCheckDelayMs))}_checkForEmptyRootNode(){var e;if(((e=this._rootNode)==null?void 0:e.childNodes.length)===0){this._diag.debug(`root node was found to be empty`);let e=this.sessionManager.getSessionSpan();e?e.addEvent(`empty-root-node`,{"mxl.type":`ux.empty_root_node`}):this._diag.debug(`no active session found to emit event on`)}}};let Uo=(e,t)=>{let n=e.nodeName.toLowerCase(),r=t.substring(0,30),i=t.length>30?`...`:``;return`<${n}${e.className?` class="${e.className}"`:``}>${r}${i}</${n}>`};var Wo=class extends X{constructor({diag:e,perf:t,shouldTrack:n,innerTextForElement:r}={}){super({instrumentationName:`ClicksInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_onClickHandler`,void 0),this._onClickHandler=e=>{let t=e.target;if(t instanceof HTMLElement&&!t.hasAttribute(`disabled`)&&!(n&&!n(t)))try{let n=this.sessionManager.getSessionSpan();n&&n.addEvent(`click`,{"mxl.type":`ux.tap`,"view.name":Uo(t,r?r(t):t.innerText),"tap.coords":`${e.x.toString()},${e.y.toString()}`},this.perf.epochMillisFromOriginOffset(e.timeStamp))}catch(e){this._diag.error(`failed to create new user interaction span event`,e)}},this._config.enabled&&this.enable()}disable(){document.removeEventListener(`click`,this._onClickHandler)}enable(){document.addEventListener(`click`,this._onClickHandler)}},Go=class extends X{constructor({diag:e,perf:t}={}){super({instrumentationName:`GlobalExceptionInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_onErrorHandler`,void 0),A(this,`_onUnhandledRejectionHandler`,void 0),this._onErrorHandler=e=>{this.logManager.logException(e.error||e.message,{handled:!1,timestamp:this.perf.epochMillisFromOriginOffset(e.timeStamp),handler:`global_exception`})},this._onUnhandledRejectionHandler=e=>{this.logManager.logException(e.reason,{handled:!1,timestamp:this.perf.epochMillisFromOriginOffset(e.timeStamp),handler:`promise_rejection`})},this._config.enabled&&this.enable()}disable(){window.removeEventListener(`error`,this._onErrorHandler),window.removeEventListener(`unhandledrejection`,this._onUnhandledRejectionHandler)}enable(){window.addEventListener(`error`,this._onErrorHandler),window.addEventListener(`unhandledrejection`,this._onUnhandledRejectionHandler)}},Ko;(function(e){e.COMPONENT=`component`,e.HTTP_STATUS_TEXT=`http.status_text`})(Ko||(Ko={}));let qo=T.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-fetch/utils`});function Jo(...e){if(e[0]instanceof URL||typeof e[0]==`string`){let t=e[1];if(!(t!=null&&t.body))return Promise.resolve();if(t.body instanceof ReadableStream){let{body:e,length:n}=Yo(t.body);return t.body=e,n}else return Promise.resolve(Zo(t.body))}else{let t=e[0];return t!=null&&t.body?t.clone().text().then(e=>$o(e)):Promise.resolve()}}function Yo(e){if(!e.pipeThrough)return qo.warn(`Platform has ReadableStream but not pipeThrough!`),{body:e,length:Promise.resolve(void 0)};let t=0,n,r=new Promise(e=>{n=e}),i=new TransformStream({start(){},transform(e,n){return z(function*(){let r=yield e;t+=r.byteLength,n.enqueue(e)})()},flush(){n(t)}});return{body:e.pipeThrough(i),length:r}}function Xo(e){return typeof Document<`u`&&e instanceof Document}function Zo(e){if(Xo(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return $o(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return es(e);if(e instanceof URLSearchParams)return $o(e.toString());if(e.byteLength!==void 0)return e.byteLength;qo.warn(`unknown body type`)}let Qo=new TextEncoder;function $o(e){return Qo.encode(e).byteLength}function es(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function ts(e){let t=is(),n=e.toUpperCase();return n in t?n:`_OTHER`}let ns={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},rs;function is(){return rs===void 0&&(rs=ns),rs}let as={"https:":`443`,"http:":`80`};function os(e){let t=Number(e.port||as[e.protocol]);if(t&&!isNaN(t))return t}let ss=`0.211.0`,cs=typeof PerformanceObserver<`u`;var ls=class extends Do{constructor(e={}){super(`@opentelemetry/instrumentation-fetch`,ss,e),A(this,`component`,`fetch`),A(this,`version`,ss),A(this,`moduleName`,this.component),A(this,`_usedResources`,new WeakSet),A(this,`_tasksCount`,0),A(this,`_semconvStability`,void 0),this._semconvStability=Ao(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_addChildSpan(e,t){let n=this.tracer.startSpan(`CORS Preflight`,{startTime:t[U.FETCH_START]},D.setSpan(w.active(),e)),r=!(this._semconvStability&Y.OLD);li(n,t,this.getConfig().ignoreNetworkEvents,void 0,r),n.end(t[U.RESPONSE_END])}_addFinalSpanAttributes(e,t){let n=G(t.url);if(this._semconvStability&Y.OLD&&(e.setAttribute(`http.status_code`,t.status),t.statusText!=null&&e.setAttribute(Ko.HTTP_STATUS_TEXT,t.statusText),e.setAttribute(`http.host`,n.host),e.setAttribute(`http.scheme`,n.protocol.replace(`:`,``)),typeof navigator<`u`&&e.setAttribute(`http.user_agent`,navigator.userAgent)),this._semconvStability&Y.STABLE){e.setAttribute(yn,t.status),e.setAttribute(bn,n.hostname);let r=os(n);r&&e.setAttribute(xn,r)}}_addHeaders(e,t){if(!hi(t,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};E.inject(w.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}if(e instanceof Request)E.inject(w.active(),e.headers,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))});else if(e.headers instanceof Headers)E.inject(w.active(),e.headers,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))});else if(e.headers instanceof Map)E.inject(w.active(),e.headers,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))});else{let t={};E.inject(w.active(),t),e.headers=Object.assign({},t,e.headers||{})}}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(e,t={}){if(br(e,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let n=``,r={};if(this._semconvStability&Y.OLD){let i=(t.method||`GET`).toUpperCase();n=`HTTP ${i}`,r[Ko.COMPONENT]=this.moduleName,r[`http.method`]=i,r[`http.url`]=e}if(this._semconvStability&Y.STABLE){let i=t.method,a=ts(t.method||`GET`);n||(n=a),r[_n]=a,a!==i&&(r[vn]=i),r[M]=e}return this.tracer.startSpan(n,{kind:ut.CLIENT,attributes:r})}_findResourceAndAddNetworkEvents(e,t,n){let r=t.entries;if(!r.length){if(!performance.getEntriesByType)return;r=performance.getEntriesByType(`resource`)}let i=fi(t.spanUrl,t.startTime,n,r,this._usedResources,`fetch`);if(i.mainRequest){let t=i.mainRequest;this._markResourceAsUsed(t);let n=i.corsPreFlightRequest;n&&(this._addChildSpan(e,n),this._markResourceAsUsed(n));let r=!(this._semconvStability&Y.OLD);li(e,t,this.getConfig().ignoreNetworkEvents,void 0,r)}}_markResourceAsUsed(e){this._usedResources.add(e)}_endSpan(e,t,n){let r=P(Date.now()),i=An();this._addFinalSpanAttributes(e,n),this._semconvStability&Y.STABLE&&n.status>=400&&(e.setStatus({code:dt.ERROR}),e.setAttribute(pn,String(n.status))),setTimeout(()=>{var n;(n=t.observer)==null||n.disconnect(),this._findResourceAndAddNetworkEvents(e,t,i),this._tasksCount--,this._clearResources(),e.end(r)},300)}_patchConstructor(){return e=>{let t=this;return function(...n){let r=this,i=G(n[0]instanceof Request?n[0].url:String(n[0])).href,a=n[0]instanceof Request?n[0]:n[1]||{},o=t._createSpan(i,a);if(!o)return e.apply(this,n);let s=t._prepareSpanData(i);t.getConfig().measureRequestSize&&Jo(...n).then(e=>{e&&(t._semconvStability&Y.OLD&&o.setAttribute(`http.request_content_length_uncompressed`,e),t._semconvStability&Y.STABLE&&o.setAttribute(`http.request.body.size`,e))}).catch(e=>{t._diag.warn(`getFetchBodyLength`,e)});function c(e,n){t._applyAttributesAfterFetch(e,a,n),t._endSpan(e,s,{status:n.status||0,statusText:n.message,url:i})}function l(e,n){t._applyAttributesAfterFetch(e,a,n),n.status>=200&&n.status<400?t._endSpan(e,s,n):t._endSpan(e,s,{status:n.status,statusText:n.statusText,url:i})}function u(e,t){if(!e)return null;let n=e.getReader();return new ReadableStream({pull(e){return z(function*(){try{let{value:t,done:r}=yield n.read();r?(n.releaseLock(),e.close()):e.enqueue(t)}catch(t){e.error(t),n.cancel(t).catch(e=>{});try{n.releaseLock()}catch(e){}}})()},cancel(e){return t.cancel(e).catch(e=>{}),n.cancel(e)}})}function d(e,t,n){let r=null;try{let t=n.clone().body;if(t){let i=t.getReader(),a=n.status===204||n.status===205||n.status===304?null:u(n.body,i);r=new Response(a,{status:n.status,statusText:n.statusText,headers:n.headers});let o=()=>{i.read().then(({done:t})=>{t?l(e,n):o()},t=>{c(e,t)})};o()}else l(e,n)}finally{var i;t((i=r)==null?n:i)}}function f(e,t,n){try{c(e,n)}finally{t(n)}}return new Promise((n,s)=>w.with(D.setSpan(w.active(),o),()=>(t._addHeaders(a,i),t._callRequestHook(o,a),t._tasksCount++,e.apply(r,a instanceof Request?[a]:[i,a]).then(d.bind(r,o,n),f.bind(r,o,s)))))}}}_applyAttributesAfterFetch(e,t,n){let r=this.getConfig().applyCustomAttributesOnSpan;r&&Oo(()=>r(e,t,n),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_callRequestHook(e,t){let n=this.getConfig().requestHook;n&&Oo(()=>n(e,t),e=>{e&&this._diag.error(`requestHook`,e)},!0)}_prepareSpanData(e){let t=An(),n=[];if(typeof PerformanceObserver!=`function`)return{entries:n,startTime:t,spanUrl:e};let r=new PerformanceObserver(t=>{t.getEntries().forEach(t=>{t.initiatorType===`fetch`&&t.name===e&&n.push(t)})});return r.observe({entryTypes:[`resource`]}),{entries:n,observer:r,startTime:t,spanUrl:e}}enable(){if(!cs){this._diag.warn(`this instrumentation is intended for web usage only, it does not instrument server-side fetch()`);return}ko(fetch)&&(this._unwrap(globalThis,`fetch`),this._diag.debug(`removing previous patch for constructor`)),this._wrap(globalThis,`fetch`,this._patchConstructor())}disable(){cs&&(this._unwrap(globalThis,`fetch`),this._usedResources=new WeakSet)}};function us(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function ds(e,t){if(e==null)return{};var n,r,i=us(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}let fs=[`omitIfAlreadyPatched`];var ps=class extends ls{constructor(e={}){let{omitIfAlreadyPatched:t}=e,n=ds(e,fs);super(B(B({},n),{},{enabled:!1})),A(this,`_omitIfAlreadyPatched`,void 0),this._omitIfAlreadyPatched=t,n.enabled&&this.enable()}enable(){if(this._omitIfAlreadyPatched&&ko(fetch)){this._diag.debug("fetch is already passed and `omitIfAlreadyPatched` is true, skipping enabling this instrumentation");return}super.enable()}};let ms=/\([^()]+\)/g;var hs=class extends X{constructor({diag:e,shouldCleanupPathOptionsFromRouteName:t=!0}){super({instrumentationName:`NavigationInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,config:{}}),A(this,`_shouldCleanupPathOptionsFromRouteName`,!0),A(this,`_currentRouteSpan`,null),A(this,`_instrumentationType`,Lt.Manual),A(this,`_removeSessionStartedFn`,null),A(this,`_removeSessionEndedFn`,null),A(this,`setInstrumentationType`,e=>{this._instrumentationType=e}),A(this,`setCurrentRoute`,e=>{if(!this._config.enabled)return;let t=K.getCurrentRoute();e.url!==(t==null?void 0:t.url)&&(K.setCurrentRoute(e),this._endRouteSpan(t),this._startRouteSpan(e))}),A(this,`_setupSessionListeners`,()=>{this._removeSessionStartedFn||(this._removeSessionStartedFn=this.sessionManager.addSessionStartedListener(()=>{let e=K.getCurrentRoute();e&&!this._currentRouteSpan&&(this._diag.debug(`Session started, starting route span.`),this._startRouteSpan(e))})),this._removeSessionEndedFn||(this._removeSessionEndedFn=this.sessionManager.addSessionEndedListener(()=>{this._currentRouteSpan&&(this._diag.debug(`Session ended, ending route span.`),this._endRouteSpan(K.getCurrentRoute()))}))}),A(this,`_cleanUpSessionListeners`,()=>{this._removeSessionStartedFn&&(this._removeSessionStartedFn(),this._removeSessionStartedFn=null),this._removeSessionEndedFn&&(this._removeSessionEndedFn(),this._removeSessionEndedFn=null)}),A(this,`_startRouteSpan`,e=>{this._diag.debug(`Starting route span for url: ${e.url}`),this._setupSessionListeners();let t=this._shouldCleanupPathOptionsFromRouteName?e.path.replace(ms,``):e.path;return this._currentRouteSpan=this.tracer.startSpan(t,{attributes:{[O]:k.Surface,[Pt]:t,[Ft]:K.getCurrentPageId()||void 0}}),this._currentRouteSpan.setAttribute(`mxl.instrumentation`,this._instrumentationType),this._currentRouteSpan}),A(this,`_endRouteSpan`,e=>{this._currentRouteSpan&&(e&&this._diag.debug(`Ending route span for url: ${e.url}`),this._currentRouteSpan.end(),this._currentRouteSpan=null)}),A(this,`enable`,()=>{this.setConfig({enabled:!0}),this._diag.debug(`NavigationInstrumentation enabled, listening for navigation events.`)}),A(this,`disable`,()=>{this._cleanUpSessionListeners(),this.setConfig({enabled:!1}),this._diag.debug(`NavigationInstrumentation disabled, stopped listening for navigation events.`)}),this._shouldCleanupPathOptionsFromRouteName=t,this._config.enabled&&this.enable()}};let gs,_s=(e={})=>(gs||(gs=new hs(e)),gs),vs={samplingPct:100,networkSpansForwardingThreshold:0},ys=`mxl_remote_config`,bs=(e,{osVersion:t,appVersion:n,deviceId:r},i)=>`${i||`https://mxl-basket.apps.ocpthikadev01.safaricom.net`}/config?appId=${e}&osVersion=${t}&appVersion=${n}&deviceId=${r}`,xs=e=>{let t={samplingPct:e.threshold};return e.network_span_forwarding!==void 0&&(t.networkSpansForwardingThreshold=e.network_span_forwarding.pct_enabled),e.empty_session_avoidance_enabled_pct!==void 0&&(t.emptySessionAvoidanceEnabledPct=e.empty_session_avoidance_enabled_pct),t};var Ss=class{constructor({appID:e,appVersion:t,deviceId:n,diag:r=T.createComponentLogger({namespace:`mxl-config-manager`}),storage:i=window.localStorage,defaultConfig:a={},mxlConfigURL:o}={}){A(this,`_remoteConfigURL`,null),A(this,`_diag`,void 0),A(this,`_storage`,void 0),A(this,`_sdkConfig`,void 0),A(this,`_etag`,null),e&&t&&n&&(this._remoteConfigURL=bs(e,{appVersion:t,deviceId:n,osVersion:`1`},o)),this._diag=r,this._storage=i;let s=this._getRemoteConfigFromStorage();s&&(this._etag=s.etag),this._sdkConfig=B(B(B({},vs),a),s?xs(s.config):{})}setConfig(e){this._sdkConfig=B(B({},this._sdkConfig),e)}getConfig(){return this._sdkConfig}refreshRemoteConfig(){var e=this;return z(function*(){if(e._remoteConfigURL)try{let t=yield e._fetchRemoteConfig(e._remoteConfigURL);if(!t){e._diag.debug(`No changes in remote config, skipping update`);return}let[n,r]=t;e._storage.setItem(ys,JSON.stringify({config:n,etag:r})),e._sdkConfig=xs(n),e._etag=r}catch(t){e._diag.warn(`Failed to refresh remote config: ${t instanceof Error?t.message:String(t)}`)}})()}_getRemoteConfigFromStorage(){try{let e=this._storage.getItem(ys);return e?JSON.parse(e):null}catch(e){return this._diag.warn(`Failed to parse remote config from storage: ${e instanceof Error?e.message:String(e)}`),null}}_fetchRemoteConfig(e){var t=this;return z(function*(){let n=yield fetch(e,{headers:t._etag?{"If-None-Match":t._etag}:{}}),r=n.headers.get(`etag`);return n.status===304?null:n.ok?[yield n.json(),r]:(t._diag.warn(`Failed to fetch remote config from ${e}: ${n.statusText}`),null)})()}};let Cs={maxAllowed:{error_log:500,warning_log:200,info_log:100,exception:500,breadcrumb:100,session_property:100,span:1e3,network_request:1e4},maxLength:{error_log:128,warning_log:128,info_log:128,exception:1024,breadcrumb:256,session_property_key:128,session_property_value:256,log_attribute_key:128,log_attribute_value:256,exception_attribute_key:128,exception_attribute_value:256},maxAttributes:{error_log:50,warning_log:50,info_log:50,exception:50}},ws={info:`info_log`,warning:`warning_log`,error:`error_log`};var Ts=class{constructor({diag:e,maxAllowed:t,maxLength:n,maxAttributes:r}){A(this,`_diag`,void 0),A(this,`_diagnosticCounts`,{}),A(this,`_currentCount`,{exception:0,error_log:0,warning_log:0,info_log:0,breadcrumb:0,session_property:0,span:0,network_request:0}),A(this,`_maxAllowed`,void 0),A(this,`_maxLength`,void 0),A(this,`_maxAttributes`,void 0),this._diag=e==null?T.createComponentLogger({namespace:`MXLLimitManager`}):e,this._maxAllowed=t,this._maxLength=n,this._maxAttributes=r}_dropIfMaxReached(e){return this._currentCount[e]>=this._maxAllowed[e]?(this._diag.warn(`disallowing ${e} because the maximum number of ${this._maxAllowed[e].toString()} has already been reached for this session`),this._incrDiagnosticCount(e,`drop`),!0):(this._currentCount[e]=(this._currentCount[e]||0)+1,!1)}truncateString(e,t){return t.length>this._maxLength[e]?(this._diag.warn(`truncating ${e} because it is longer than ${this._maxLength[e].toString()} characters: "${t}"`),this._incrDiagnosticCount(e,`truncate_string`),t.substring(0,this._maxLength[e])):t}_truncateAttributes(e,t,n,r){let i=Object.keys(t);i.length>this._maxAttributes[e]&&(this._diag.warn(`truncating ${e} attributes because there are more than ${this._maxAttributes[e].toString()} set`),this._incrDiagnosticCount(e,`truncate_attributes`));let a={};for(let s=0;s<Math.min(i.length,this._maxAttributes[e]);s++){var o;let e=this.truncateString(n,i[s]);a[e]=this.truncateString(r,((o=t[i[s]])==null?void 0:o.toString())||``)}return a}limitBreadcrumb(e){return this._dropIfMaxReached(`breadcrumb`)?`dropped`:{name:this.truncateString(`breadcrumb`,e)}}limitException(e,t){return this._dropIfMaxReached(`exception`)?`dropped`:{message:this.truncateString(`exception`,e),attributes:this._truncateAttributes(`exception`,t,`exception_attribute_key`,`exception_attribute_value`)}}limitLog(e,t,n){let r=ws[t];return this._dropIfMaxReached(r)?`dropped`:{message:this.truncateString(r,e),attributes:this._truncateAttributes(r,n,`log_attribute_key`,`log_attribute_value`)}}limitSessionProperty(e,t){return this._dropIfMaxReached(`session_property`)?`dropped`:{key:this.truncateString(`session_property_key`,e),value:this.truncateString(`session_property_value`,t)}}dropReadableSpan(e){let t=e.attributes[O]===k.Network?`network_request`:`span`;return this._dropIfMaxReached(t)}reset(){this._diagnosticCounts={},this._currentCount={exception:0,error_log:0,warning_log:0,info_log:0,breadcrumb:0,session_property:0,span:0,network_request:0}}_incrDiagnosticCount(e,t){let n=`mxl.app.applied_limit.${e}.${t}.count`;this._diagnosticCounts[n]=(this._diagnosticCounts[n]||0)+1}getDiagnosticCounts(){return this._diagnosticCounts}};let Es=()=>JSON.stringify(zt._MXLFileBundleIDs||{});var Ds=class e{constructor({diag:e,perf:t,spanSessionManager:n,limitManager:r,loggerProvider:i,visibilityDoc:a=window.document,storage:o=window.localStorage}){A(this,`_diag`,void 0),A(this,`_perf`,void 0),A(this,`_logger`,void 0),A(this,`_spanSessionManager`,void 0),A(this,`_limitManager`,void 0),A(this,`_visibilityDoc`,void 0),A(this,`_storage`,void 0);let s=i==null?go:i;this._diag=e==null?T.createComponentLogger({namespace:`MXLLogManager`}):e,this._perf=t==null?new bi:t,this._logger=s.getLogger(`mxl-web-sdk-logs`),this._spanSessionManager=n,this._limitManager=r,this._visibilityDoc=a,this._storage=o}_validateAttributes(e){return Object.prototype.toString.call(e)===`[object Object]`?e:(this._diag.warn(`attributes must be a plain object`,e),{})}static _logSeverityToSeverityNumber(e){switch(e){case`info`:return q.INFO;case`warning`:return q.WARN;default:return q.ERROR}}logException(t,{handled:n=!0,attributes:r={},timestamp:i=this._perf.getNowMillis(),handler:a=`manual`}={}){var o;let s=this._validateAttributes(r);n||this._spanSessionManager.incrSessionCountForKey(`mxl.unhandled_exceptions_count`);let c=(t==null||(o=t.constructor)==null?void 0:o.name)||typeof t,l=``,u=c,d=``,f=``;if(t instanceof Error)l=String(t.message||``).trim(),u=t.name||``,d=t.stack||``,f=t.cause?`present`:``;else if(t&&typeof t==`object`)try{l=JSON.stringify(t)}catch(e){l=String(t).trim()}else l=String(t).trim();let p=this._limitManager.limitException(l,s);p!==`dropped`&&this._logger.emit({timestamp:i,severityNumber:q.ERROR,severityText:`ERROR`,body:p.message,attributes:B(B({},p.attributes),{},{[O]:k.SystemException,"mxl.exception_handling":e._exceptionHandlingType(n,a),"mxl.exception_cause":f,[gn]:c,"exception.name":u,[mn]:p.message,[hn]:d,[Nt]:Es(),[jt]:Rt(this._visibilityDoc),"mxl.exception_number":At(this._storage,`mxl_exception_number`,this._diag)})})}message(e,t,{attributes:n={},includeStacktrace:r=!0,stacktrace:i}={}){if(typeof e!=`string`||!e.trim()){this._diag.warn(`Message must be a non-empty string`);return}if(![`info`,`warning`,`error`].includes(t)){this._diag.warn(`Severity must be info, warning, or error`);return}let a=this._validateAttributes(n);t===`error`&&this._spanSessionManager.incrSessionCountForKey(`mxl.error_log_count`);let o=``;t!==`info`&&(typeof i==`string`?o=i:r&&(o=Error().stack||``)),this._logMessage({message:e.trim(),severity:t,timestamp:this._perf.getNowMillis(),attributes:a,stack:o})}_logMessage({message:t,severity:n,timestamp:r,attributes:i={},stack:a}){let o=this._limitManager.limitLog(t,n,i);o!==`dropped`&&this._logger.emit({timestamp:r,severityNumber:e._logSeverityToSeverityNumber(n),severityText:n.toUpperCase(),body:o.message,attributes:B(B(B({},o.attributes),{},{[O]:k.SystemLog},a?{"mxl.stacktrace.js":a,[Nt]:Es()}:{}),{},{[jt]:Rt(this._visibilityDoc)})})}static _exceptionHandlingType(e,t){return e?`handled`:t===`global_exception`?`unhandled_error`:t===`promise_rejection`?`unhandled_rejection`:`unhandled`}},Os=class{constructor(){A(this,`_currentRoute`,null),A(this,`_currentPageId`,null),A(this,`getCurrentPageId`,()=>this._currentPageId),A(this,`getCurrentRoute`,()=>this._currentRoute),A(this,`setCurrentRoute`,e=>{(!this._currentRoute||this._currentRoute.url!==e.url)&&(this._currentPageId=kt()),this._currentRoute=e}),A(this,`clearCurrentRoute`,()=>{this._currentRoute=null,this._currentPageId=null})}},ks=class{constructor({dynamicConfigManager:e,deviceId:t,blockNetworkSpanForwarding:n}){A(this,`_dynamicConfigManager`,void 0),A(this,`_deviceId`,void 0),A(this,`_blockNetworkSpanForwarding`,void 0),this._dynamicConfigManager=e,this._deviceId=t,this._blockNetworkSpanForwarding=n}isSDKEnabled(){let e=this._dynamicConfigManager.getConfig();return Bt(this._deviceId,e.samplingPct)}isNetworkSpanForwardingEnabled(){if(this._blockNetworkSpanForwarding)return!1;let e=this._dynamicConfigManager.getConfig();return Bt(this._deviceId,e.networkSpansForwardingThreshold)}isEmptySessionAvoidanceEnabled(){let e=this._dynamicConfigManager.getConfig();return Bt(this._deviceId,e.emptySessionAvoidanceEnabledPct)}};let As=`0.0.3`,js=`mxl-web-sdk`,Ms=`mxl_app_instance_id`,Ns=(e,t)=>{let n=null;try{n=e.getItem(Ms)}catch(e){t.warn(`Failed to retrieve app instance ID from session storage`,e)}if(!n){t.debug(`No existing app instance ID found in session storage, creating a new one`),n=kt();try{e.setItem(Ms,n)}catch(e){t.warn(`Failed to persist app instance ID to session storage`,e)}}return n},Ps=({diagLogger:e,appVersion:t,pageSessionStorage:n})=>Ar({[Sn]:js,[wn]:js,app_version:t,app_framework:1,sdk_version:As,[Tn]:As,sdk_simple_version:1,sdk_platform:`web`,[Cn]:`webjs`,"mxl.app_instance_id":Ns(n,e),[En]:window.navigator.userAgent,screen_resolution:`${window.screen.width}x${window.screen.height}`});var Fs=class{constructor(e){A(this,`_span`,void 0),this._span=e}get attributes(){return this._span.attributes}addEvent(e,t,n){return this._span.addEvent(e,t,n),this}addLink(e){return this._span.addLink(e),this}addLinks(e){return this._span.addLinks(e),this}end(e){this._span.end(e)}isRecording(){return this._span.isRecording()}recordException(e,t){this._span.recordException(e,t)}setAttribute(e,t){return this._span.setAttribute(e,t),this}setAttributes(e){return this._span.setAttributes(e),this}removeAttribute(e){let t=this._span.attributes,{[e]:n}=t,r=ds(t,[e].map(Qt));return this._span.attributes=r,this}setStatus(e){return this._span.setStatus(e),this}spanContext(){return this._span.spanContext()}updateName(e){return this._span.updateName(e),this}fail(e={code:`failure`}){e.code&&this._span.setAttribute(`mxl.error_code`,e.code.toUpperCase()),this._span.end(e.endTime)}};let Is=`mxl_tab`,Ls=`mxl_tab_activity`;var Rs=class{constructor({diag:e,perf:t,visibilityDoc:n=window.document,storage:r=window.localStorage,sessionStorage:i=window.sessionStorage,limitManager:a,referrer:o=document.referrer}){A(this,`_previousSessionId`,null),A(this,`_activeSessionId`,null),A(this,`_activeSessionStartTime`,null),A(this,`_sessionSpan`,null),A(this,`_activeSessionCounts`,null),A(this,`_nextSessionCounts`,{}),A(this,`_coldStart`,!0),A(this,`_sdkStartupDuration`,0),A(this,`_sessionStartedListeners`,[]),A(this,`_sessionEndedListeners`,[]),A(this,`_tab`,void 0),A(this,`_navigationSource`,void 0),A(this,`_referrerInfo`,void 0),A(this,`_tracer`,void 0),A(this,`_noExportTracer`,void 0),A(this,`_diag`,void 0),A(this,`_perf`,void 0),A(this,`_visibilityDoc`,void 0),A(this,`_storage`,void 0),A(this,`_sessionStorage`,void 0),A(this,`_limitManager`,void 0),A(this,`_referrer`,void 0),this._diag=e==null?T.createComponentLogger({namespace:`MXLSpanSessionManager`}):e,this._perf=t==null?new bi:t,this._visibilityDoc=n,this._storage=r,this._sessionStorage=i,this._limitManager=a,this._referrer=o,this._tracer=D.getTracer(`mxl-web-sdk-sessions`),this._noExportTracer=new ti().getTracer(`mxl-web-sdk-sessions`),this._referrerInfo=this._processReferrer();let s=this._initTab();this._tab=s.tab,this._navigationSource=s.navigationSource,this._setupNewTabClickListeners()}_getPermanentAttributes(){let e=new Map;try{for(let t=0;t<this._storage.length;t++){let n=this._storage.key(t);if(n!=null&&n.startsWith(Mt)){let t=this._storage.getItem(n);t&&e.set(n,t)}}}catch(e){this._diag.warn(`Error loading permanent session properties`,e)}return Object.fromEntries(e.entries())}addBreadcrumb(e){if(!this._sessionSpan){this._diag.debug(`trying to add breadcrumb to a session, but there is no session in progress. This is a no-op.`);return}let t=this._limitManager.limitBreadcrumb(e);t!==`dropped`&&this._sessionSpan.addEvent(`mxl-breadcrumb`,{message:t.name},this._perf.getNowMillis())}addProperty(e,t,n){if(!this._sessionSpan){this._diag.debug(`trying to add properties to a session, but there is no session in progress. This is a no-op.`);return}let r=this._limitManager.limitSessionProperty(e,t);if(r===`dropped`)return;let i=Mt+r.key;if(this._sessionSpan.setAttribute(i,r.value),(n==null?void 0:n.lifespan)===`permanent`)try{this._storage.setItem(i,t)}catch(e){this._diag.warn(`Failed to set permanent session property`,e)}}removeProperty(e){if(!this._sessionSpan){this._diag.debug(`trying to remove a session property, but there is no session in progress. This is a no-op.`);return}let t=Mt+this._limitManager.truncateString(`session_property_key`,e);this._sessionSpan.removeAttribute(t);try{this._storage.getItem(t)&&this._storage.removeItem(t)}catch(e){this._diag.warn(`Error removing permanent session property`,e)}}endSessionSpan(){this.endSessionSpanInternal(`manual`)}endSessionSpanInternal(e){if(!this._sessionSpan){this._diag.debug(`trying to end a session, but there is no session in progress. This is a no-op.`);return}for(let e of this._sessionEndedListeners)try{e()}catch(e){this._diag.warn(`Error while executing session ended listener`,e)}this._sessionSpan.setAttributes(this._endSessionSpanAttributes(e)),this._sessionSpan.end(),this._sessionSpan=null,this._activeSessionStartTime=null,this._previousSessionId=this._activeSessionId,this._activeSessionId=null,this._activeSessionCounts=null,this._limitManager.reset()}_endSessionSpanAttributes(e){return B(B(B(B({},this._getPermanentAttributes()),{},{"mxl.session_end_type":e},this._activeSessionCounts),this._limitManager.getDiagnosticCounts()),{},{"mxl.sdk_startup_duration":this._sdkStartupDuration})}currentSessionAsReadableSpan(e){if(!this._sessionSpan||!this._activeSessionStartTime)return this._diag.debug(`trying to end a session, but there is no session in progress. This is a no-op.`),null;let t=this._noExportTracer.startSpan(`mxl-session`,{startTime:this._activeSessionStartTime,attributes:B(B(B({},this._sessionSpan.attributes),this._endSessionSpanAttributes(e)),{},{"mxl.from_storage":!0})});return t.end(),t}getSessionId(){return this._activeSessionId}getPreviousSessionId(){return this._previousSessionId}getSessionSpan(){return this._sessionSpan}getSessionStartTime(){return this._activeSessionStartTime}startSessionSpan(e){this._sessionSpan&&this.endSessionSpanInternal(`manual`),this._activeSessionId=kt(),this._activeSessionStartTime=this._perf.getNowHRTime(),this._activeSessionCounts={};let t=this._nextSessionCounts;this._nextSessionCounts={};let n=B(B({},this._getPermanentAttributes()),{},{[O]:k.Session,[jt]:Rt(this._visibilityDoc),[No]:this._activeSessionId,"mxl.cold_start":this._coldStart,"mxl.session_number":At(this._storage,`mxl_session_number`,this._diag),"mxl.experience_id":this._tab.experienceId,"mxl.tab_id":this._tab.tabId,"mxl.navigation_source":this._navigationSource},t);this._referrerInfo.isValid&&this._referrerInfo.scrubbedUrl&&(n[`mxl.referrer_url`]=this._referrerInfo.scrubbedUrl),this._tab.sourceTabId&&(n[`mxl.source_tab_id`]=this._tab.sourceTabId),e!=null&&e.reason&&(n[`mxl.session_start_type`]=e.reason),this._sessionSpan=new Fs(this._tracer.startSpan(`mxl-session`,{attributes:n})),this._coldStart=!1;for(let e of this._sessionStartedListeners)try{e()}catch(e){this._diag.warn(`Error while executing session started listener`,e)}}incrSessionCountForKey(e){if(!this._sessionSpan||!this._activeSessionCounts){this._diag.debug(`trying to increment a count for the active session, but there is no session in progress. This is a no-op.`);return}this._activeSessionCounts[e]=(this._activeSessionCounts[e]||0)+1}incrNextSessionCountForKey(e){this._nextSessionCounts[e]=(this._nextSessionCounts[e]||0)+1}addSessionStartedListener(e){let t=this._sessionStartedListeners.push(e);return()=>{this._sessionStartedListeners.splice(t-1,1)}}addSessionEndedListener(e){let t=this._sessionEndedListeners.push(e);return()=>{this._sessionEndedListeners.splice(t-1,1)}}recordSDKStartupDuration(e){this._sdkStartupDuration=Math.ceil(e)}setTracerProvider(e){this._tracer=e.getTracer(`mxl-web-sdk-sessions`)}_determineNavigationSource(){try{let e=window.performance.getEntriesByType(`navigation`);if(e.length>0&&e[0]){let t=e[0];if(t.type===`reload`)return`reload`;if(t.type===`back_forward`)return`back_forward`}}catch(e){this._diag.warn(`Failed to get navigation type`,e)}return this._referrerInfo.isValid?this._referrerInfo.isSameOrigin?`same_origin`:`external`:`direct`}_processReferrer(){if(!this._referrer)return{isValid:!1,isSameOrigin:!1};try{let e=new URL(this._referrer),t=window.location.origin;return{isValid:!0,isSameOrigin:e.origin===t,scrubbedUrl:e.origin+e.pathname}}catch(e){return{isValid:!1,isSameOrigin:!1}}}_getTabContext(e){let t=Ns(this._sessionStorage,this._diag),n,r;if(e===`same_origin`){let e=this._getTabActivity();e&&Date.now()-e.lastActivityMs<=1e4&&(n=e.tabId,r=e.experienceId)}return r!=null||(r=kt()),{sourceTabId:n,experienceId:r,tabId:t}}_initTab(){let e=this._determineNavigationSource();try{let t=this._sessionStorage.getItem(Is);if(t)return{tab:JSON.parse(t),navigationSource:e}}catch(e){this._diag.warn(`Failed to retrieve tab data`,e)}let t=this._getTabContext(e),n={experienceId:t.experienceId,sourceTabId:t.sourceTabId,tabId:t.tabId};try{this._sessionStorage.setItem(Is,JSON.stringify(n))}catch(e){this._diag.warn(`Failed to store tab data`,e)}return{tab:n,navigationSource:e}}_getTabActivity(){try{let e=this._storage.getItem(Ls);return e?JSON.parse(e):null}catch(e){return this._diag.warn(`Failed to retrieve tab activity`,e),null}}_storeTabActivity(e){try{this._storage.setItem(Ls,JSON.stringify(e))}catch(e){this._diag.warn(`Failed to save tab activity`,e)}}_storeCurrentTabAsSource(){let e={tabId:this._tab.tabId,experienceId:this._tab.experienceId,lastActivityMs:Date.now()};this._storeTabActivity(e)}_setupNewTabClickListeners(){let e=e=>{var t;if(e.button===1||e.ctrlKey||e.metaKey||e.shiftKey){this._storeCurrentTabAsSource();return}(t=e.target)!=null&&t.closest(`a[target="_blank"], form[target="_blank"], a[rel*="noopener"], a[rel*="noreferrer"]`)&&this._storeCurrentTabAsSource()},t={capture:!0,passive:!0};document.addEventListener(`auxclick`,e,t),document.addEventListener(`click`,e,t)}},zs=class{constructor({tracerProvider:e}={}){A(this,`_tracer`,void 0),A(this,`setSpan`,D.setSpan),this._tracer=(e==null?D:e).getTracer(`mxl-web-sdk-traces`)}startSpan(e,t={},n){t.attributes=t.attributes?t.attributes:{},t.attributes[O]=k.Perf;let r=t.parentSpan?D.setSpan(w.active(),t.parentSpan):n;return new Fs(this._tracer.startSpan(e,t,r))}getSpan(e){let t=D.getSpan(e);if(t)return new Fs(t)}};let Bs=`mxl_user`,Vs=`mxl_user_id`,Hs=`mxl_external_user_id`,Us=e=>typeof e[Xi]==`string`&&e[Xi].length===32,Ws=e=>typeof e==`string`&&e.length===32;var Gs=class{constructor({diag:e,storage:t=window.localStorage}={}){A(this,`_diag`,void 0),A(this,`_storage`,void 0),A(this,`_mxlUserId`,null),this._diag=e==null?T.createComponentLogger({namespace:`MXLUserManager`}):e,this._storage=t,this._migrateOldLocalStorageKey(),this._initialSetup()}getMXLUserId(){return this._mxlUserId||this._generateNewMXLUserId()}setMXLUserId(e){this._mxlUserId=e;try{this._storage.setItem(Vs,e)}catch(e){this._diag.warn(`Failed to persist user object for storage, keeping it in-memory only`,e)}}clearMXLUserId(){this._mxlUserId=null;try{this._storage.removeItem(Vs)}catch(e){this._diag.warn(`Failed to remove mxl user in storage`,e)}}_migrateOldLocalStorageKey(){try{let e=this._storage.getItem(Bs);if(e){let t=JSON.parse(e);Us(t)?(this._diag.debug(`Migrating old user data from storage`),this._storage.setItem(Vs,t[Xi]),this._storage.removeItem(Bs)):(this._diag.warn(`Invalid user data found in storage, clearing old user data`),this._storage.removeItem(Bs))}}catch(e){this._diag.warn(`Failed to get old user data from storage`,e)}}_initialSetup(){try{let e=this._storage.getItem(Vs);e?Ws(e)?this._mxlUserId=e:(this._diag.warn(`Invalid mxl user id, generating a new one`),this.clearMXLUserId()):this._diag.debug(`No existing user found in storage, creating a new one`)}catch(e){this._diag.warn(`Failed to get mxl user id from storage, defaulting to a new one`,e)}this._mxlUserId||(this._mxlUserId=this._generateNewMXLUserId())}_generateNewMXLUserId(){let e=kt();return this.setMXLUserId(e),e}getUserId(){try{return this._storage.getItem(Hs)}catch(e){return this._diag.warn(`Failed to retrieve user id from storage`,e),null}}setUserId(e){try{this._storage.setItem(Hs,e)}catch(e){this._diag.warn(`Failed to store user id`,e)}}clearUserId(){try{this._storage.removeItem(Hs)}catch(e){this._diag.warn(`Failed to clear user id`,e)}}};let Ks=[`keydown`,`mousedown`,`mousemove`,`scroll`];var qs=class extends X{constructor({diag:e}={}){super({instrumentationName:`SpanSessionBrowserActivityInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,config:{}}),A(this,`_onActivityThrottled`,void 0),A(this,`_activityTimeout`,void 0),A(this,`disable`,()=>{Tt({target:window,events:Ks,callback:this._onActivityThrottled}),this._activityTimeout&&clearTimeout(this._activityTimeout),this._activityTimeout=null}),A(this,`enable`,()=>{wt({target:window,events:Ks,callback:this._onActivityThrottled})}),A(this,`_onInactivity`,()=>{this._diag.debug(`Inactivity detected`),this._activityTimeout&&clearTimeout(this._activityTimeout),this._activityTimeout=null,this.sessionManager.endSessionSpanInternal(`inactivity`)}),A(this,`_onActivity`,()=>{this._diag.debug(`Activity detected`),this._activityTimeout&&clearTimeout(this._activityTimeout),this.sessionManager.getSessionId()||this.sessionManager.startSessionSpan({reason:`activity`}),this._activityTimeout=setTimeout(this._onInactivity,18e5)}),this._activityTimeout=null,this._onActivityThrottled=xi(this._onActivity,3e4),this._config.enabled&&this.enable()}},Js=class extends X{constructor({diag:e}={}){super({instrumentationName:`SpanSessionOnLoadInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,config:{}}),this._config.enabled&&this.enable()}disable(){this.sessionManager.endSessionSpanInternal(`unknown`)}enable(){this.sessionManager.startSessionSpan({reason:`init`})}};let Ys=14400*1e3;var Xs=class extends X{constructor({diag:e,perf:t}={}){super({instrumentationName:`SpanSessionTimeoutInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_sessionTimeout`,void 0),A(this,`disable`,()=>{this._sessionTimeout&&clearTimeout(this._sessionTimeout),this._sessionTimeout=null}),A(this,`enable`,()=>{this._checkTimeout()}),A(this,`_onTimeout`,()=>{this._diag.debug(`Timeout detected`),this._sessionTimeout&&clearTimeout(this._sessionTimeout),this.sessionManager.endSessionSpanInternal(`timer`),this.sessionManager.startSessionSpan({reason:`timer`}),this._sessionTimeout=setTimeout(this._checkTimeout,Ys)}),A(this,`_checkTimeout`,()=>{let e=this.sessionManager.getSessionStartTime();if(e){let t=Ys-this.perf.millisSinceHRTime(e);if(t<=0){this._onTimeout();return}this._sessionTimeout&&clearTimeout(this._sessionTimeout),this._sessionTimeout=setTimeout(this._checkTimeout,t);return}this._sessionTimeout&&clearTimeout(this._sessionTimeout),this._sessionTimeout=setTimeout(this._checkTimeout,Ys)}),this._sessionTimeout=null,this._config.enabled&&this.enable()}};let Zs=[`mousedown`];var Qs=class extends X{constructor({diag:e,perf:t,visibilityWaitTimeMs:n=0,limitedSessionMaxDurationMs:r=5e3,backgroundSessions:i=!1,maxPendingSpanCount:a=5,visibilityDoc:o=window.document}={},s,c){super({instrumentationName:`SpanSessionVisibilityInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_currentVisibilityState`,void 0),A(this,`_checkVisibilityTimeout`,void 0),A(this,`_interactionSinceLastVisibilityChange`,void 0),A(this,`_avoidEndingLimitedSessions`,void 0),A(this,`_mxlSpanProcessor`,void 0),A(this,`_checkVisibilityChange`,void 0),A(this,`_onVisibilityChange`,void 0),A(this,`_onInteractionThrottled`,void 0),this._currentVisibilityState=o.visibilityState,this._checkVisibilityTimeout=null,this._interactionSinceLastVisibilityChange=!1,this._avoidEndingLimitedSessions=r>0&&s.isEmptySessionAvoidanceEnabled(),this._mxlSpanProcessor=c,this._checkVisibilityChange=()=>{if(n<=0){this._currentVisibilityState=o.visibilityState,this._onVisibilityChange();return}if(this._checkVisibilityTimeout&&clearTimeout(this._checkVisibilityTimeout),o.visibilityState===`visible`&&this._currentVisibilityState!==o.visibilityState){this._currentVisibilityState=o.visibilityState,this._onVisibilityChange();return}this._diag.debug(`Visibility changed to ${o.visibilityState}. Will wait ${(n/1e3).toString()}s, and check if visibility changed`),this._checkVisibilityTimeout=setTimeout(()=>{this._currentVisibilityState===o.visibilityState?this._diag.debug(`Visibility was not changed after timeout happened: ${o.visibilityState}`):(this._currentVisibilityState=o.visibilityState,this._onVisibilityChange())},n)},this._onVisibilityChange=()=>{this._diag.debug(`Visibility change detected: ${o.visibilityState}`);let e=this.sessionManager.getSessionStartTime();if(this._avoidEndingLimitedSessions&&e!==null&&this.perf.millisSinceHRTime(e)<r&&!this._interactionSinceLastVisibilityChange&&this._mxlSpanProcessor&&this._mxlSpanProcessor.getPendingSpansCount()<a){this._diag.debug(`Not ending the session since it is considered limited`),this.sessionManager.addBreadcrumb(`Tab visibility changed to ${o.visibilityState}`);let e=this.sessionManager.getSessionId();if(e){let t=this.sessionManager.currentSessionAsReadableSpan(`state_changed`);t&&this._mxlSpanProcessor.storePendingSpans(e,t)}}else{let e=this.sessionManager.getSessionId();this._mxlSpanProcessor&&e&&this._mxlSpanProcessor.clearStoredSpans(e),this.sessionManager.endSessionSpanInternal(`state_changed`),o.visibilityState===`hidden`&&i?(this._diag.debug("Starting a session since document visibility switched to hidden and `backgroundSessions` is enabled"),this.sessionManager.startSessionSpan({reason:`hidden`})):o.visibilityState===`visible`&&(this._diag.debug(`Starting a session since document visibility switched to visible`),this.sessionManager.startSessionSpan({reason:`visible`}))}this._interactionSinceLastVisibilityChange=!1},this._onInteractionThrottled=xi(()=>{this._interactionSinceLastVisibilityChange=!0},1e3),this._config.enabled&&this.enable()}disable(){window.removeEventListener(`visibilitychange`,this._checkVisibilityChange),this._avoidEndingLimitedSessions&&Tt({target:window,events:Zs,callback:this._onInteractionThrottled})}enable(){window.addEventListener(`visibilitychange`,this._checkVisibilityChange),this._avoidEndingLimitedSessions&&wt({target:window,events:Zs,callback:this._onInteractionThrottled})}},$s=class{constructor(){A(this,`t`,void 0),A(this,`o`,0),A(this,`i`,[])}u(e){var t;if(e.hadRecentInput)return;let n=this.i[0],r=this.i.at(-1);this.o&&n&&r&&e.startTime-r.startTime<1e3&&e.startTime-n.startTime<5e3?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),(t=this.t)==null||t.call(this,e)}};let ec=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},tc=e=>{if(document.readyState===`loading`)return`loading`;{let t=ec();if(t){if(e<t.domInteractive)return`loading`;if(t.domContentLoadedEventStart===0||e<t.domContentLoadedEventStart)return`dom-interactive`;if(t.domComplete===0||e<t.domComplete)return`dom-content-loaded`}}return`complete`},nc=e=>{let t=e.nodeName;return e.nodeType===1?t.toLowerCase():t.toUpperCase().replace(/^#/,``)},rc=e=>{let t=``;try{for(;(e==null?void 0:e.nodeType)!==9;){let n=e,r=n.id?`#`+n.id:[nc(n),...Array.from(n.classList).sort()].join(`.`);if(t.length+r.length>99)return t||r;if(t=t?r+`>`+t:r,n.id)break;e=n.parentNode}}catch(e){}return t},ic=new WeakMap;function ac(e,t){return ic.get(e)||ic.set(e,new t),ic.get(e)}let oc=-1,sc=()=>oc,cc=e=>{addEventListener(`pageshow`,(t=>{t.persisted&&(oc=t.timeStamp,e(t))}),!0)},Z=(e,t,n,r)=>{let i,a;return o=>{var s;t.value>=0&&(o||r)&&(a=t.value-((s=i)==null?0:s),(a||i===void 0)&&(i=t.value,t.delta=a,t.rating=((e,t)=>e>t[1]?`poor`:e>t[0]?`needs-improvement`:`good`)(t.value,n),e(t)))}},lc=e=>{requestAnimationFrame((()=>requestAnimationFrame((()=>e()))))},uc=()=>{var e;let t=ec();return(e=t==null?void 0:t.activationStart)==null?0:e},Q=(e,t=-1)=>{let n=ec(),r=`navigate`;return sc()>=0?r=`back-forward-cache`:n&&(document.prerendering||uc()>0?r=`prerender`:document.wasDiscarded?r=`restore`:n.type&&(r=n.type.replace(/_/g,`-`))),{name:e,value:t,rating:`good`,delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+0xe8d4a51000}`,navigationType:r}},dc=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let r=new PerformanceObserver((e=>{Promise.resolve().then((()=>{t(e.getEntries())}))}));return r.observe(B({type:e,buffered:!0},n)),r}}catch(e){}},fc=e=>{let t=!1;return()=>{t||(e(),t=!0)}},pc=-1,mc=new Set,hc=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,gc=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of mc)e();isFinite(pc)||(pc=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,gc,!0))}},_c=()=>{if(pc<0){var e;let t=uc(),n=document.prerendering||(e=globalThis.performance.getEntriesByType(`visibility-state`).filter((e=>e.name===`hidden`&&e.startTime>t))[0])==null?void 0:e.startTime;pc=n==null?hc():n,addEventListener(`visibilitychange`,gc,!0),addEventListener(`prerenderingchange`,gc,!0),cc((()=>{setTimeout((()=>{pc=hc()}))}))}return{get firstHiddenTime(){return pc},onHidden(e){mc.add(e)}}},vc=e=>{document.prerendering?addEventListener(`prerenderingchange`,(()=>e()),!0):e()},yc=[1800,3e3],bc=(e,t={})=>{vc((()=>{let n=_c(),r,i=Q(`FCP`),a=dc(`paint`,(e=>{for(let t of e)t.name===`first-contentful-paint`&&(a.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-uc(),0),i.entries.push(t),r(!0)))}));a&&(r=Z(e,i,yc,t.reportAllChanges),cc((n=>{i=Q(`FCP`),r=Z(e,i,yc,t.reportAllChanges),lc((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))})))}))},xc=[.1,.25],Sc=e=>e.find((e=>{var t;return((t=e.node)==null?void 0:t.nodeType)===1}))||e[0],Cc=(e,t={})=>{let n=ac(t=Object.assign({},t),$s),r=new WeakMap;n.t=e=>{var n;if(!(e==null||(n=e.sources)==null)&&n.length){let n=Sc(e.sources),o=n==null?void 0:n.node;if(o){var i,a;let e=(i=(a=t.generateTarget)==null?void 0:a.call(t,o))==null?rc(o):i;r.set(n,e)}}},((e,t={})=>{let n=_c();bc(fc((()=>{let r,i=Q(`CLS`,0),a=ac(t,$s),o=e=>{for(let t of e)a.u(t);a.o>i.value&&(i.value=a.o,i.entries=a.i,r())},s=dc(`layout-shift`,o);s&&(r=Z(e,i,xc,t.reportAllChanges),n.onHidden((()=>{o(s.takeRecords()),r(!0)})),cc((()=>{a.o=0,i=Q(`CLS`,0),r=Z(e,i,xc,t.reportAllChanges),lc((()=>r()))})),setTimeout(r))})))})((t=>{e((e=>{let t={};if(e.entries.length){var n;let i=e.entries.reduce(((e,t)=>e.value>t.value?e:t));if(!(i==null||(n=i.sources)==null)&&n.length){let e=Sc(i.sources);e&&(t={largestShiftTarget:r.get(e),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:e,largestShiftEntry:i,loadState:tc(i.startTime)})}}return Object.assign(e,{attribution:t})})(t))}),t)},wc=(e,t={})=>{bc((t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:tc(sc())};if(e.entries.length){let n=ec(),r=e.entries.at(-1);if(n){let i=n.activationStart||0,a=Math.max(0,n.responseStart-i);t={timeToFirstByte:a,firstByteToFCP:e.value-a,loadState:tc(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}return Object.assign(e,{attribution:t})})(t))}),t)},Tc=0,Ec=1/0,Dc=0,Oc=e=>{for(let t of e)t.interactionId&&(Ec=Math.min(Ec,t.interactionId),Dc=Math.max(Dc,t.interactionId),Tc=Dc?(Dc-Ec)/7+1:0)},kc,Ac=()=>{var e;return kc?Tc:(e=performance.interactionCount)==null?0:e},jc=()=>{`interactionCount`in performance||kc||(kc=dc(`event`,Oc,{type:`event`,buffered:!0,durationThreshold:0}))},Mc=0;var Nc=class{constructor(){A(this,`l`,[]),A(this,`h`,new Map),A(this,`m`,void 0),A(this,`p`,void 0)}v(){Mc=Ac(),this.l.length=0,this.h.clear()}M(){let e=Math.min(this.l.length-1,Math.floor((Ac()-Mc)/50));return this.l[e]}u(e){var t;if((t=this.m)==null||t.call(this,e),!e.interactionId&&e.entryType!==`first-input`)return;let n=this.l.at(-1),r=this.h.get(e.interactionId);if(r||this.l.length<10||e.duration>n.T){var i;if(r?e.duration>r.T?(r.entries=[e],r.T=e.duration):e.duration===r.T&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],T:e.duration},this.h.set(r.id,r),this.l.push(r)),this.l.sort(((e,t)=>t.T-e.T)),this.l.length>10){let e=this.l.splice(10);for(let t of e)this.h.delete(t.id)}(i=this.p)==null||i.call(this,r)}}};let Pc=e=>{let t=globalThis.requestIdleCallback||setTimeout;document.visibilityState===`hidden`?e():(e=fc(e),addEventListener(`visibilitychange`,e,{once:!0,capture:!0}),t((()=>{e(),removeEventListener(`visibilitychange`,e,{capture:!0})})))},Fc=[200,500],Ic=(e,t={})=>{let n=ac(t=Object.assign({},t),Nc),r=[],i=[],a=0,o=new WeakMap,s=new WeakMap,c=!1,l=()=>{c||(Pc(u),c=!0)},u=()=>{let e=n.l.map((e=>o.get(e.entries[0]))),t=i.length-50;i=i.filter(((n,r)=>r>=t||e.includes(n)));let s=new Set;for(let e of i){let t=d(e.startTime,e.processingEnd);for(let e of t)s.add(e)}let l=r.length-1-50;r=r.filter(((e,t)=>e.startTime>a&&t>l||s.has(e))),c=!1};n.m=e=>{let t=e.startTime+e.duration,n;a=Math.max(a,e.processingEnd);for(let r=i.length-1;r>=0;r--){let a=i[r];if(Math.abs(t-a.renderTime)<=8){n=a,n.startTime=Math.min(e.startTime,n.startTime),n.processingStart=Math.min(e.processingStart,n.processingStart),n.processingEnd=Math.max(e.processingEnd,n.processingEnd),n.entries.push(e);break}}n||(n={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:t,entries:[e]},i.push(n)),(e.interactionId||e.entryType===`first-input`)&&o.set(e,n),l()},n.p=e=>{if(!s.get(e)){let i=e.entries[0].target;if(i){var n,r;let a=(n=(r=t.generateTarget)==null?void 0:r.call(t,i))==null?rc(i):n;s.set(e,a)}}};let d=(e,t)=>{let n=[];for(let i of r)if(!(i.startTime+i.duration<e)){if(i.startTime>t)break;n.push(i)}return n},f=e=>{let t=e.entries[0],r=o.get(t),i=t.processingStart,a=Math.max(t.startTime+t.duration,i),c=Math.min(r.processingEnd,a),l=r.entries.sort(((e,t)=>e.processingStart-t.processingStart)),u=d(t.startTime,c),f=n.h.get(t.interactionId),p={interactionTarget:s.get(f),interactionType:t.name.startsWith(`key`)?`keyboard`:`pointer`,interactionTime:t.startTime,nextPaintTime:a,processedEventEntries:l,longAnimationFrameEntries:u,inputDelay:i-t.startTime,processingDuration:c-i,presentationDelay:a-c,loadState:tc(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{var t;if(!((t=e.longAnimationFrameEntries)!=null&&t.length))return;let n=e.interactionTime,r=e.inputDelay,i=e.processingDuration,a,o,s=0,c=0,l=0,u=0;for(let t of e.longAnimationFrameEntries){c=c+t.startTime+t.duration-t.styleAndLayoutStart;for(let e of t.scripts){let t=e.startTime+e.duration;if(t<n)continue;let l=t-Math.max(n,e.startTime),d=e.duration?l/e.duration*e.forcedStyleAndLayoutDuration:0;s+=l-d,c+=d,l>u&&(o=e.startTime<n+r?`input-delay`:e.startTime>=n+r+i?`presentation-delay`:`processing-duration`,a=e,u=l)}}let d=e.longAnimationFrameEntries.at(-1),f=d?d.startTime+d.duration:0;f>=n+r+i&&(l=e.nextPaintTime-f),a&&o&&(e.longestScript={entry:a,subpart:o,intersectingDuration:u}),e.totalScriptDuration=s,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=l,e.totalUnattributedDuration=e.nextPaintTime-n-s-c-l})(p),Object.assign(e,{attribution:p})};dc(`long-animation-frame`,(e=>{r=r.concat(e),l()})),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=_c();vc((()=>{var r;jc();let i,a=Q(`INP`),o=ac(t,Nc),s=e=>{Pc((()=>{for(let t of e)o.u(t);let t=o.M();t&&t.T!==a.value&&(a.value=t.T,a.entries=t.entries,i())}))},c=dc(`event`,s,{durationThreshold:(r=t.durationThreshold)==null?40:r});i=Z(e,a,Fc,t.reportAllChanges),c&&(c.observe({type:`first-input`,buffered:!0}),n.onHidden((()=>{s(c.takeRecords()),i(!0)})),cc((()=>{o.v(),a=Q(`INP`),i=Z(e,a,Fc,t.reportAllChanges)})))}))})((t=>{e(f(t))}),t)};var Lc=class{constructor(){A(this,`m`,void 0)}u(e){var t;(t=this.m)==null||t.call(this,e)}};let Rc=[2500,4e3],zc=(e,t={})=>{let n=ac(t=Object.assign({},t),Lc),r=new WeakMap;n.m=e=>{let n=e.element;if(n){var i,a;let o=(i=(a=t.generateTarget)==null?void 0:a.call(t,n))==null?rc(n):i;r.set(e,o)}},((e,t={})=>{vc((()=>{let n=_c(),r,i=Q(`LCP`),a=ac(t,Lc),o=e=>{t.reportAllChanges||(e=e.slice(-1));for(let t of e)a.u(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-uc(),0),i.entries=[t],r())},s=dc(`largest-contentful-paint`,o);if(s){r=Z(e,i,Rc,t.reportAllChanges);let n=fc((()=>{o(s.takeRecords()),s.disconnect(),r(!0)})),a=e=>{e.isTrusted&&(Pc(n),removeEventListener(e.type,a,{capture:!0}))};for(let e of[`keydown`,`click`,`visibilitychange`])addEventListener(e,a,{capture:!0});cc((n=>{i=Q(`LCP`),r=Z(e,i,Rc,t.reportAllChanges),lc((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))}))}}))})((t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){let n=ec();if(n){let i=n.activationStart||0,a=e.entries.at(-1),o=a.url&&performance.getEntriesByType(`resource`).filter((e=>e.name===a.url))[0],s=Math.max(0,n.responseStart-i),c=Math.max(s,o?(o.requestStart||o.startTime)-i:0),l=Math.min(e.value,Math.max(c,o?o.responseEnd-i:0));t={target:r.get(a),timeToFirstByte:s,resourceLoadDelay:c-s,resourceLoadDuration:l-c,elementRenderDelay:e.value-l,navigationEntry:n,lcpEntry:a},a.url&&(t.url=a.url),o&&(t.lcpResourceEntry=o)}}return Object.assign(e,{attribution:t})})(t))}),t)},Bc=[800,1800],Vc=e=>{document.prerendering?vc((()=>Vc(e))):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,(()=>Vc(e)),!0)},Hc=(e,t={})=>{((e,t={})=>{let n=Q(`TTFB`),r=Z(e,n,Bc,t.reportAllChanges);Vc((()=>{let i=ec();i&&(n.value=Math.max(i.responseStart-uc(),0),n.entries=[i],r(!0),cc((()=>{n=Q(`TTFB`,0),r=Z(e,n,Bc,t.reportAllChanges),r(!0)})))}))})((t=>{e((e=>{let t={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(e.entries.length){let n=e.entries[0],r=n.activationStart||0,i=Math.max((n.workerStart||n.fetchStart)-r,0),a=Math.max(n.domainLookupStart-r,0),o=Math.max(n.connectStart-r,0),s=Math.max(n.connectEnd-r,0);t={waitingDuration:i,cacheDuration:a-i,dnsDuration:o-a,connectionDuration:s-o,requestDuration:e.value-s,navigationEntry:n}}return Object.assign(e,{attribution:t})})(t))}),t)},Uc=[`CLS`,`INP`,`LCP`],Wc=[`CLS`,`INP`,`LCP`,`FCP`,`TTFB`],Gc={CLS:Cc,FCP:wc,LCP:zc,INP:Ic,TTFB:Hc,FID:void 0},Kc=(e,t)=>{let n={},r=[];if(e===`CLS`){let e=t.attribution;r.push({key:`largestShiftTarget`,value:e.largestShiftTarget},{key:`largestShiftValue`,value:e.largestShiftValue})}else if(e===`INP`){let e=t.attribution;r.push({key:`interactionTarget`,value:e.interactionTarget},{key:`interactionType`,value:e.interactionType},{key:`nextPaintTime`,value:e.nextPaintTime},{key:`inputDelay`,value:e.inputDelay},{key:`processingDuration`,value:e.processingDuration},{key:`presentationDelay`,value:e.presentationDelay},{key:`totalScriptDuration`,value:e.totalScriptDuration},{key:`totalStyleAndLayoutDuration`,value:e.totalStyleAndLayoutDuration},{key:`totalPaintDuration`,value:e.totalPaintDuration},{key:`totalUnattributedDuration`,value:e.totalUnattributedDuration},{key:`loadState`,value:e.loadState})}else if(e===`LCP`){let e=t.attribution;r.push({key:`target`,value:e.target},{key:`url`,value:e.url},{key:`timeToFirstByte`,value:e.timeToFirstByte},{key:`resourceLoadDelay`,value:e.resourceLoadDelay},{key:`resourceLoadDuration`,value:e.resourceLoadDuration},{key:`elementRenderDelay`,value:e.elementRenderDelay})}return r.forEach(e=>{e.value!==void 0&&(n[`mxl.web_vital.attribution.${e.key}`]=e.value)}),n};var qc=class extends X{constructor({diag:e,perf:t,trackingLevel:n=`core`,listeners:r=Gc,urlDocument:i=window.document,urlAttribution:a=!0,pageManager:o}={}){super({instrumentationName:`WebVitalsInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),A(this,`_metricsToTrack`,void 0),A(this,`_listeners`,void 0),A(this,`_urlDocument`,void 0),A(this,`_urlAttribution`,void 0),A(this,`_pageManager`,void 0),A(this,`_attributedPage`,{INP:void 0,LCP:void 0,CLS:void 0,FCP:void 0,TTFB:void 0}),A(this,`_largestShiftTargetForCLS`,void 0),A(this,`_listenersRegistered`,!1),this._listeners=r,this._urlDocument=i,this._metricsToTrack=n===`all`?[...Wc]:[...Uc],this._urlAttribution=a,this._pageManager=o==null?K.getPageManager():o,this._config.enabled&&this.enable()}disable(){}enable(){if(!this._listenersRegistered&&(this._listenersRegistered=!0,this._metricsToTrack.forEach(e=>{var t,n;(t=(n=this._listeners)[e])==null||t.call(n,t=>{let n=this.sessionManager.getSessionSpan();if(!n)return;let r=this._getTimeForMetric(t),i=this._getAttributedPageForMetric(t),a=B({[O]:k.WebVital,[M]:i.fullURL,"mxl.web_vital.navigation_type":t.navigationType,"mxl.web_vital.name":t.name,"mxl.web_vital.rating":t.rating,"mxl.web_vital.id":t.id,"mxl.web_vital.delta":t.delta,"mxl.web_vital.value":t.value},Kc(e,t));i.path&&i.pageID&&(a[Pt]=i.path,a[Ft]=i.pageID),n.addEvent(`mxl-web-vitals-report-${e}`,a,r)})}),this._urlAttribution)){var e,t,n,r,i,a;(e=(t=this._listeners).INP)==null||e.call(t,()=>{this._attributedPage.INP=this._currentAttributedPage()},{reportAllChanges:!0}),(n=(r=this._listeners).LCP)==null||n.call(r,()=>{this._attributedPage.LCP=this._currentAttributedPage()},{reportAllChanges:!0}),(i=(a=this._listeners).CLS)==null||i.call(a,e=>{let t=e;this._largestShiftTargetForCLS!==t.attribution.largestShiftTarget&&(this._largestShiftTargetForCLS=t.attribution.largestShiftTarget,this._attributedPage.CLS=this._currentAttributedPage())},{reportAllChanges:!0})}}_getTimeForMetric(e){return e.name===`CLS`&&e.attribution.largestShiftTime?this.perf.epochMillisFromOriginOffset(e.attribution.largestShiftTime):e.name===`INP`&&e.attribution.interactionTime?this.perf.epochMillisFromOriginOffset(e.attribution.interactionTime):this.perf.getNowMillis()}_currentAttributedPage(){let e={fullURL:this._urlDocument.URL},t=this._pageManager.getCurrentRoute(),n=this._pageManager.getCurrentPageId();return t&&n&&(e.path=t.path,e.pageID=n),e}_getAttributedPageForMetric(e){return e.name===`INP`&&this._attributedPage.INP?this._attributedPage.INP:e.name===`LCP`&&this._attributedPage.LCP?this._attributedPage.LCP:e.name===`CLS`&&this._attributedPage.CLS&&e.attribution.largestShiftTarget===this._largestShiftTargetForCLS?this._attributedPage.CLS:this._currentAttributedPage()}},$;(function(e){e.METHOD_OPEN=`open`,e.METHOD_SEND=`send`,e.EVENT_ABORT=`abort`,e.EVENT_ERROR=`error`,e.EVENT_LOAD=`loaded`,e.EVENT_TIMEOUT=`timeout`})($||($={}));let Jc=T.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils`});function Yc(e){return typeof Document<`u`&&e instanceof Document}function Xc(e){if(Yc(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return Qc(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return $c(e);if(e instanceof URLSearchParams)return Qc(e.toString());if(e.byteLength!==void 0)return e.byteLength;Jc.warn(`unknown body type`)}let Zc=new TextEncoder;function Qc(e){return Zc.encode(e).byteLength}function $c(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function el(e){let t=rl(),n=e.toUpperCase();return n in t?n:`_OTHER`}let tl={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},nl;function rl(){return nl===void 0&&(nl=tl),nl}let il={"https:":`443`,"http:":`80`};function al(e){let t=Number(e.port||il[e.protocol]);if(t&&!isNaN(t))return t}let ol=`0.211.0`;var sl;(function(e){e.HTTP_STATUS_TEXT=`http.status_text`})(sl||(sl={}));var cl=class extends Do{constructor(e={}){super(`@opentelemetry/instrumentation-xml-http-request`,ol,e),A(this,`component`,`xml-http-request`),A(this,`version`,ol),A(this,`moduleName`,this.component),A(this,`_tasksCount`,0),A(this,`_xhrMem`,new WeakMap),A(this,`_usedResources`,new WeakSet),A(this,`_semconvStability`,void 0),this._semconvStability=Ao(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_addHeaders(e,t){let n=G(t).href;if(!hi(n,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};E.inject(w.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}let r={};E.inject(w.active(),r),Object.keys(r).forEach(t=>{e.setRequestHeader(t,String(r[t]))})}_addChildSpan(e,t){w.with(D.setSpan(w.active(),e),()=>{let e=this.tracer.startSpan(`CORS Preflight`,{startTime:t[U.FETCH_START]}),n=!(this._semconvStability&Y.OLD);li(e,t,this.getConfig().ignoreNetworkEvents,void 0,n),e.end(t[U.RESPONSE_END])})}_addFinalSpanAttributes(e,t,n){if(this._semconvStability&Y.OLD){if(t.status!==void 0&&e.setAttribute(`http.status_code`,t.status),t.statusText!==void 0&&e.setAttribute(sl.HTTP_STATUS_TEXT,t.statusText),typeof n==`string`){let t=G(n);e.setAttribute(`http.host`,t.host),e.setAttribute(`http.scheme`,t.protocol.replace(`:`,``))}e.setAttribute(`http.user_agent`,navigator.userAgent)}this._semconvStability&Y.STABLE&&t.status&&e.setAttribute(yn,t.status)}_applyAttributesAfterXHR(e,t){let n=this.getConfig().applyCustomAttributesOnSpan;typeof n==`function`&&Oo(()=>n(e,t),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_addResourceObserver(e,t){let n=this._xhrMem.get(e);!n||typeof PerformanceObserver!=`function`||typeof PerformanceResourceTiming!=`function`||(n.createdResources={observer:new PerformanceObserver(e=>{let r=e.getEntries(),i=G(t);r.forEach(e=>{e.initiatorType===`xmlhttprequest`&&e.name===i.href&&n.createdResources&&n.createdResources.entries.push(e)})}),entries:[]},n.createdResources.observer.observe({entryTypes:[`resource`]}))}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(N.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(e,t,n,r,i){if(!n||!r||!i||!e.createdResources)return;let a=e.createdResources.entries;(!a||!a.length)&&(a=N.getEntriesByType(`resource`));let o=fi(G(n).href,r,i,a,this._usedResources);if(o.mainRequest){let e=o.mainRequest;this._markResourceAsUsed(e);let n=o.corsPreFlightRequest;n&&(this._addChildSpan(t,n),this._markResourceAsUsed(n));let r=!(this._semconvStability&Y.OLD);li(t,e,this.getConfig().ignoreNetworkEvents,void 0,r)}}_cleanPreviousSpanInformation(e){let t=this._xhrMem.get(e);if(t){let n=t.callbackToRemoveEvents;n&&n(),this._xhrMem.delete(e)}}_createSpan(e,t,n){if(br(t,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let r=``,i=G(t),a={};if(this._semconvStability&Y.OLD&&(r=n.toUpperCase(),a[`http.method`]=n,a[`http.url`]=i.toString()),this._semconvStability&Y.STABLE){let e=n,t=el(n);r||(r=t),a[_n]=t,t!==e&&(a[vn]=e),a[M]=i.toString(),a[bn]=i.hostname;let o=al(i);o&&(a[xn]=o)}let o=this.tracer.startSpan(r,{kind:ut.CLIENT,attributes:a});return o.addEvent($.METHOD_OPEN),this._cleanPreviousSpanInformation(e),this._xhrMem.set(e,{span:o,spanUrl:t}),o}_markResourceAsUsed(e){this._usedResources.add(e)}_patchOpen(){return e=>{let t=this;return function(...n){let r=n[0],i=n[1];return t._createSpan(this,i,r),e.apply(this,n)}}}_patchSend(){let e=this;function t(t,n,r,i){let a=n.callbackToRemoveEvents;typeof a==`function`&&a();let{span:o,spanUrl:s,sendStartTime:c}=n;o&&(e._findResourceAndAddNetworkEvents(n,o,s,c,r),o.addEvent(t,i),e._addFinalSpanAttributes(o,n,s),o.end(i),e._tasksCount--),e._clearResources()}function n(n,r,i,a){let o=e._xhrMem.get(r);if(!o)return;if(o.status=r.status,o.statusText=r.statusText,e._xhrMem.delete(r),o.span){let t=o.span;e._applyAttributesAfterXHR(t,r),e._semconvStability&Y.STABLE&&(i?a&&(t.setStatus({code:dt.ERROR,message:a}),t.setAttribute(pn,a)):o.status&&o.status>=400&&(t.setStatus({code:dt.ERROR}),t.setAttribute(pn,String(o.status))))}let s=An(),c=Date.now();setTimeout(()=>{t(n,o,s,c)},300)}function r(){n($.EVENT_ERROR,this,!0,`error`)}function i(){n($.EVENT_ABORT,this,!1)}function a(){n($.EVENT_TIMEOUT,this,!0,`timeout`)}function o(){this.status<299?n($.EVENT_LOAD,this,!1):n($.EVENT_ERROR,this,!1)}function s(t){t.removeEventListener(`abort`,i),t.removeEventListener(`error`,r),t.removeEventListener(`load`,o),t.removeEventListener(`timeout`,a);let n=e._xhrMem.get(t);n&&(n.callbackToRemoveEvents=void 0)}return t=>function(...n){let c=e._xhrMem.get(this);if(!c)return t.apply(this,n);let l=c.span,u=c.spanUrl;if(l&&u){if(e.getConfig().measureRequestSize&&n!=null&&n[0]){let t=n[0],r=Xc(t);r!==void 0&&(e._semconvStability&Y.OLD&&l.setAttribute(`http.request_content_length_uncompressed`,r),e._semconvStability&Y.STABLE&&l.setAttribute(`http.request.body.size`,r))}w.with(D.setSpan(w.active(),l),()=>{e._tasksCount++,c.sendStartTime=An(),l.addEvent($.METHOD_SEND),this.addEventListener(`abort`,i),this.addEventListener(`error`,r),this.addEventListener(`load`,o),this.addEventListener(`timeout`,a),c.callbackToRemoveEvents=()=>{s(this),c.createdResources&&c.createdResources.observer.disconnect()},e._addHeaders(this,u),e._addResourceObserver(this,u)})}return t.apply(this,n)}}enable(){this._diag.debug(`applying patch to`,this.moduleName,this.version),ko(XMLHttpRequest.prototype.open)&&(this._unwrap(XMLHttpRequest.prototype,`open`),this._diag.debug(`removing previous patch from method open`)),ko(XMLHttpRequest.prototype.send)&&(this._unwrap(XMLHttpRequest.prototype,`send`),this._diag.debug(`removing previous patch from method send`)),this._wrap(XMLHttpRequest.prototype,`open`,this._patchOpen()),this._wrap(XMLHttpRequest.prototype,`send`,this._patchSend())}disable(){this._diag.debug(`removing patch from`,this.moduleName,this.version),this._unwrap(XMLHttpRequest.prototype,`open`),this._unwrap(XMLHttpRequest.prototype,`send`),this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet}};let ll=[`omitIfAlreadyPatched`];var ul=class extends cl{constructor(e={}){let{omitIfAlreadyPatched:t}=e,n=ds(e,ll);super(B(B({},n),{},{enabled:!1})),A(this,`_omitIfAlreadyPatched`,void 0),this._omitIfAlreadyPatched=t,n.enabled&&this.enable()}enable(){if(this._omitIfAlreadyPatched&&(ko(XMLHttpRequest.prototype.open)||ko(XMLHttpRequest.prototype.send))){this._diag.debug("XMLHttpRequest is already passed and `omitIfAlreadyPatched` is true, skipping enabling this instrumentation");return}super.enable()}};function dl(e){return fl(e,new WeakSet)}function fl(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>fl(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>fl(e,t))}return!1}var pl=class{set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this.totalAttributesCount-Object.keys(this.attributes).length}constructor(e,t,n){A(this,`hrTime`,void 0),A(this,`hrTimeObserved`,void 0),A(this,`spanContext`,void 0),A(this,`resource`,void 0),A(this,`instrumentationScope`,void 0),A(this,`attributes`,{}),A(this,`_severityText`,void 0),A(this,`_severityNumber`,void 0),A(this,`_body`,void 0),A(this,`_eventName`,void 0),A(this,`totalAttributesCount`,0),A(this,`_isReadonly`,!1),A(this,`_logRecordLimits`,void 0);let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:o,severityText:s,body:c,attributes:l={},context:u}=n,d=Date.now();if(this.hrTime=F(r==null?d:r),this.hrTimeObserved=F(i==null?d:i),u){let e=D.getSpanContext(u);e&&et(e)&&(this.spanContext=e)}this.severityNumber=o,this.severityText=s,this.body=c,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(l)}setAttribute(e,t){return this._isLogRecordReadonly()?this:e.length===0?(T.warn(`Invalid attribute key: ${e}`),this):dl(t)?(this.totalAttributesCount+=1,Object.keys(this.attributes).length>=this._logRecordLimits.attributeCountLimit&&!Object.prototype.hasOwnProperty.call(this.attributes,e)?(this.droppedAttributesCount===1&&T.warn(`Dropping extra attributes.`),this):(this.attributes[e]=this._truncateToSize(t),this)):(T.warn(`Invalid attribute value set for key: ${e}`),this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(e){let t=this._logRecordLimits.attributeValueLengthLimit;if(t<=0)return T.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return this._truncateToLimitUtil(e,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>this._truncateToSize(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this._truncateToSize(r);return t}return e}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&T.warn(`Can not execute the operation on emitted log record`),this._isReadonly}},ml=class{constructor(e,t){A(this,`instrumentationScope`,void 0),A(this,`_sharedState`,void 0),A(this,`_loggerConfig`,void 0),this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){var t;let n=this._loggerConfig,r=e.context||w.active(),i=(t=e.severityNumber)==null?q.UNSPECIFIED:t;if(i!==q.UNSPECIFIED&&i<n.minimumSeverity)return;if(n.traceBased){let e=D.getSpanContext(r);if(e&&et(e)&&(e.traceFlags&C.SAMPLED)!==C.SAMPLED)return}let a=new pl(this._sharedState,this.instrumentationScope,B({context:r},e));this._sharedState.activeProcessor.onEmit(a,r),a._makeReadonly()}};function hl(){var e,t;return{forceFlushTimeoutMillis:3e4,logRecordLimits:{attributeValueLengthLimit:(e=void 0)==null?1/0:e,attributeCountLimit:(t=void 0)==null?128:t},includeTraceContext:!0}}function gl(e){var t,n,r,i,a,o;return{attributeCountLimit:(t=(n=(r=e.attributeCountLimit)==null?void 0:r)==null?void 0:n)==null?128:t,attributeValueLengthLimit:(i=(a=(o=e.attributeValueLengthLimit)==null?void 0:o)==null?void 0:a)==null?1/0:i}}var _l=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}},vl=class{constructor(e,t){A(this,`processors`,void 0),A(this,`forceFlushTimeoutMillis`,void 0),this.processors=e,this.forceFlushTimeoutMillis=t}forceFlush(){var e=this;return z(function*(){let t=e.forceFlushTimeoutMillis;yield Promise.all(e.processors.map(e=>vr(e.forceFlush(),t)))})()}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}shutdown(){var e=this;return z(function*(){yield Promise.all(e.processors.map(e=>e.shutdown()))})()}};function yl(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}let bl={disabled:!1,minimumSeverity:q.UNSPECIFIED,traceBased:!1},xl=()=>B({},bl);var Sl=class{constructor(e,t,n,r,i){A(this,`loggers`,new Map),A(this,`activeProcessor`,void 0),A(this,`registeredLogRecordProcessors`,[]),A(this,`resource`,void 0),A(this,`forceFlushTimeoutMillis`,void 0),A(this,`logRecordLimits`,void 0),A(this,`processors`,void 0),A(this,`_loggerConfigurator`,void 0),A(this,`_loggerConfigs`,new Map),this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=n,this.processors=r,r.length>0?(this.registeredLogRecordProcessors=r,this.activeProcessor=new vl(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new _l,this._loggerConfigurator=i==null?xl:i}getLoggerConfig(e){let t=yl(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}},Cl=class{constructor(e={}){var t,n;A(this,`_shutdownOnce`,void 0),A(this,`_sharedState`,void 0);let r=cr({},hl(),e);this._sharedState=new Sl((t=e.resource)==null?Mr():t,r.forceFlushTimeoutMillis,gl(r.logRecordLimits),(n=e==null?void 0:e.processors)==null?[]:n,e==null?void 0:e.loggerConfigurator),this._shutdownOnce=new Sr(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return T.warn(`A shutdown LoggerProvider cannot provide a Logger`),co;e||T.warn(`Logger requested without instrumentation scope name.`);let r=e||`unknown`,i=`${r}@${t||``}:${(n==null?void 0:n.schemaUrl)||``}`;return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new ml({name:r,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(T.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(T.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}},wl=class{constructor(e,t){var n,r,i,a,o,s,c,l;A(this,`_maxExportBatchSize`,void 0),A(this,`_maxQueueSize`,void 0),A(this,`_scheduledDelayMillis`,void 0),A(this,`_exportTimeoutMillis`,void 0),A(this,`_exporter`,void 0),A(this,`_isExporting`,!1),A(this,`_finishedLogRecords`,[]),A(this,`_timer`,void 0),A(this,`_shutdownOnce`,void 0),this._exporter=e,this._maxExportBatchSize=(n=(r=t==null?void 0:t.maxExportBatchSize)==null?void 0:r)==null?512:n,this._maxQueueSize=(i=(a=t==null?void 0:t.maxQueueSize)==null?void 0:a)==null?2048:i,this._scheduledDelayMillis=(o=(s=t==null?void 0:t.scheduledDelayMillis)==null?void 0:s)==null?5e3:o,this._exportTimeoutMillis=(c=(l=t==null?void 0:t.exportTimeoutMillis)==null?void 0:l)==null?3e4:c,this._shutdownOnce=new Sr(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(T.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}shutdown(){return this._shutdownOnce.call()}_shutdown(){var e=this;return z(function*(){e.onShutdown(),yield e._flushAll(),yield e._exporter.shutdown()})()}_addToBuffer(e){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(e),this._maybeStartTimer())}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedLogRecords.length/this._maxExportBatchSize);for(let e=0;e<r;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedLogRecords.length===0?Promise.resolve():vr(this._export(this._finishedLogRecords.splice(0,this._maxExportBatchSize)),this._exportTimeoutMillis)}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().then(()=>{this._isExporting=!1,this._finishedLogRecords.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,j(e)})};if(this._finishedLogRecords.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}_export(e){let t=()=>wr._export(this._exporter,e).then(e=>{if(e.code!==L.SUCCESS){var t;j((t=e.error)==null?Error(`BatchLogRecordProcessor: log record export failed (status ${e})`):t)}}).catch(j),n=[];for(let t=0;t<e.length;t++){let r=e[t].resource;r.asyncAttributesPending&&typeof r.waitForAsyncAttributes==`function`&&n.push(r.waitForAsyncAttributes())}return n.length===0?t():Promise.all(n).then(t,j)}},Tl=class extends wl{constructor(e,t){super(e,t),A(this,`_visibilityChangeListener`,void 0),A(this,`_pageHideListener`,void 0),this._onInit(t)}onShutdown(){typeof document>`u`||(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}_onInit(e){(e==null?void 0:e.disableAutoFlushOnDocumentHide)===!0||typeof document>`u`||(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush()},this._pageHideListener=()=>{this.forceFlush()},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}},El=class{constructor(e){A(this,`_sessionIdProvider`,void 0),this._sessionIdProvider=e}forceFlush(){return z(function*(){})()}onStart(e,t){var n;let r=(n=this._sessionIdProvider)==null?void 0:n.getSessionId();r&&e.setAttribute(`session.id`,r)}onEnd(e){}shutdown(){return z(function*(){})()}};function Dl(e){return new El(e)}var Ol=class{constructor({spanSessionManager:e}){A(this,`_spanSessionManager`,void 0),this._spanSessionManager=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){e.setAttributes({"log.record.uid":kt(),[No]:this._spanSessionManager.getSessionId(),"session.previous_id":this._spanSessionManager.getPreviousSessionId()})}shutdown(){return Promise.resolve(void 0)}},kl=class{constructor({attributeScrubbers:e}){A(this,`_attributeScrubbers`,void 0),this._attributeScrubbers=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){this._attributeScrubbers.forEach(t=>{let n=e.attributes[t.key];n&&typeof n==`string`&&e.setAttribute(t.key,t.scrub(n))})}shutdown(){return Promise.resolve(void 0)}},Al=class{constructor({urlDocument:e=window.document}={}){A(this,`_urlDocument`,void 0),this._urlDocument=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){e.attributes[O]||e.setAttribute(O,k.SystemLog),e.setAttribute(M,this._urlDocument.URL)}shutdown(){return Promise.resolve(void 0)}};let jl=e=>{if((e.attributes[_n]||e.attributes[un])&&(typeof e.attributes[yn]==`number`||typeof e.attributes[fn]==`number`)){var t;let n=(t=e.attributes[M])==null?e.attributes[dn]:t;return typeof n==`string`&&n.includes(`://`)}return!1};var Ml=class{forceFlush(){return Promise.resolve(void 0)}onEnd(e){if(jl(e)){var t,n,r,i,a;e.attributes[O]=k.Network,(t=e.attributes)[M]!=null||(t[M]=e.attributes[dn]),(n=e.attributes)[yn]!=null||(n[yn]=e.attributes[fn]),(r=e.attributes)[_n]!=null||(r[_n]=e.attributes[un]),(i=e.attributes)[Mo]!=null||(i[Mo]=e.attributes[`http.response_content_length`]),(a=e.attributes)[jo]!=null||(a[jo]=e.attributes[`http.request_content_length`])}}onStart(){}shutdown(){return Promise.resolve(void 0)}};let Nl=e=>e.attributes[O]===k.Session,Pl=(e,t)=>`mxl.${t===`current`?`export_failed`:`previous_export_failed`}.${e}`;var Fl=class{constructor({resource:e,exporter:t,limitManager:n,spanSessionManager:r,storage:i=window.localStorage,storedSpansExpireTimeoutMS:a,diag:o=T.createComponentLogger({namespace:`MXLSessionBatchedSpanProcessor`})}){A(this,`_shutdownOnce`,void 0),A(this,`_pendingSpans`,[]),A(this,`_exporter`,void 0),A(this,`_limitManager`,void 0),A(this,`_spanStorage`,void 0),A(this,`_spanSessionManager`,void 0),A(this,`_diag`,void 0),A(this,`_shutdown`,()=>(this._spanStorage.destroy(),this._exporter.shutdown())),this._diag=o,this._exporter=t,this._shutdownOnce=new Sr(this._shutdown,this),this._limitManager=n,this._spanSessionManager=r,this._spanStorage=new _i({resource:e,storage:i,diag:o,onExpiredSpansExport:e=>{this._exportSpans(e)},storedSpansExpireTimeoutMS:a,spanSessionManager:r})}forceFlush(){return this._diag.debug(`forceFlush called for MXLSessionBatchedSpanProcessor. This is a no op`),Promise.resolve(void 0)}onEnd(e){if(this._shutdownOnce.isCalled){this._diag.debug(`span ended after processor shutdown. Ignoring span.`);return}if(Nl(e))this._diag.debug(`session span ended. Exporting all pending spans.`),this._exportSpans([e,...this._pendingSpans]),this._pendingSpans=[];else{if(this._diag.debug(`non-session span ended. Adding to pending spans queue.`),this._limitManager.dropReadableSpan(e))return;this._pendingSpans.push(e)}}_exportSpans(e){wr._export(this._exporter,e).then(e=>{if(e.code===L.FAILED){var t;let n=((t=e.error)==null?void 0:t.message)||`unknown error`,r=`unknown`;n===`Concurrent export limit reached`?r=`concurrent_limit`:n===`Fetch request errored`&&(r=`fetch_error`),this._spanSessionManager.incrSessionCountForKey(Pl(r,`current`)),this._spanSessionManager.incrNextSessionCountForKey(Pl(r,`previous`)),this._diag.error(`spans failed to export: ${n}`)}}).catch(e=>{let t=`unknown error`;e&&e instanceof Error?t=e.message:typeof e==`string`&&(t=e),this._spanSessionManager.incrSessionCountForKey(Pl(`unknown`,`current`)),this._spanSessionManager.incrNextSessionCountForKey(Pl(`unknown`,`previous`)),this._diag.error(`spans failed to export: ${t}`)})}onStart(){}getPendingSpansCount(){return this._pendingSpans.length}storePendingSpans(e,t){this._spanStorage.storePendingSpans(e,t,this._pendingSpans)}clearStoredSpans(e){this._spanStorage.clearStoredSpans(e)}shutdown(){return this._shutdownOnce.call()}},Il=class{constructor({pageManager:e}){A(this,`_pageManager`,void 0),this._pageManager=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){if(e.attributes[Pt]||e.attributes[Ft])return;let t=this._pageManager.getCurrentRoute();t&&(e.setAttribute(Pt,t.path),e.setAttribute(Ft,this._pageManager.getCurrentPageId()))}shutdown(){return Promise.resolve(void 0)}},Ll=class{constructor({pageManager:e}){A(this,`_pageManager`,void 0),this._pageManager=e}forceFlush(){return Promise.resolve(void 0)}onEnd(e){if(e.attributes[Pt]||e.attributes[Ft])return;let t=this._pageManager.getCurrentRoute(),n=this._pageManager.getCurrentPageId();t&&n&&(e.attributes[Pt]=t.path,e.attributes[Ft]=n)}onStart(){}shutdown(){return Promise.resolve(void 0)}},Rl=class{constructor({attributeScrubbers:e}){A(this,`_attributeScrubbers`,void 0),this._attributeScrubbers=e}forceFlush(){return Promise.resolve(void 0)}onEnd(e){this._attributeScrubbers.forEach(t=>{let n=e.attributes[t.key];n&&typeof n==`string`&&(e.attributes[t.key]=t.scrub(n))})}onStart(){}shutdown(){return Promise.resolve(void 0)}},zl=class{constructor({userManager:e}){A(this,`_userManager`,void 0),this._userManager=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){this._userManager.getUserId()&&e.setAttributes({[Po]:this._userManager.getUserId()})}shutdown(){return Promise.resolve(void 0)}},Bl=class{constructor({userManager:e}){A(this,`_userManager`,void 0),this._userManager=e}forceFlush(){return Promise.resolve(void 0)}onEnd(e){let t=this._userManager.getUserId();t&&(e.attributes[Po]=t)}onStart(){}shutdown(){return Promise.resolve(void 0)}},Vl=class extends Xn{inject(e,t,n){super.inject(e,t,n);let r=D.getSpan(e);if(r){let e=ke.get(t,`traceparent`);e&&r.setAttribute(`mxl.w3c_traceparent`,e)}}};let Hl=/\/\/(.+):(.+)@(.+)\//,Ul=[`AWSAccessKeyId`,`Signature`,`sig`,"`X-Goog-Signature",`password`,`auth`,`pw`,`token`],Wl=({value:e,queryParamRegex:t,scrubPath:n,scrubQuery:r})=>{let i=e;return n&&(i=i.replace(Hl,`//REDACTED:REDACTED@$3/`)),r&&(i=i.replaceAll(t,`$1$2=REDACTED`)),i},Gl=e=>{let t=[...Ul,...e||[]],n=RegExp(`(^|&|\\?)(${t.join(`|`)})=[^&]+`,`g`);return[{key:M,scrub:e=>Wl({value:e,queryParamRegex:n,scrubPath:!0,scrubQuery:!0})},{key:dn,scrub:e=>Wl({value:e,queryParamRegex:n,scrubPath:!0,scrubQuery:!0})},{key:`url.path`,scrub:e=>Wl({value:e,queryParamRegex:n,scrubPath:!0,scrubQuery:!1})},{key:`url.query`,scrub:e=>Wl({value:e,queryParamRegex:n,scrubPath:!1,scrubQuery:!0})}]},Kl=new class{constructor({diagLogger:e=T.createComponentLogger({namespace:`mxl-registry`})}={}){A(this,`_sdk`,null),A(this,`_diag`,void 0),A(this,`register`,e=>{this._sdk!==null&&this._diag.warn(`previously registered sdk will be overwritten`),this._sdk=e}),A(this,`clear`,()=>{this._sdk===null&&this._diag.warn(`sdk already cleared, this is a no-op`),this._sdk=null}),A(this,`registered`,()=>this._sdk),this._diag=e}},ql=(e={},{featureManager:t,logManager:n,spanSessionManager:r,mxlSpanProcessor:i,pageManager:a})=>{var o,s,c,l,u,d;let f=[new Js(e[`session-on-load`]),new Qs(e[`session-visibility`],t,i),new qs(e[`session-activity`]),new Xs(e[`session-timeout`])];(o=e.omit)!=null&&o.has(`exception`)||f.push(new Go(e.exception)),(s=e.omit)!=null&&s.has(`click`)||f.push(new Wo(e.click)),(c=e.omit)!=null&&c.has(`web-vital`)||f.push(new qc(B(B({},e[`web-vital`]),{},{pageManager:a}))),(l=e.omit)!=null&&l.has(`document-load`)||f.push(new Vo(e[`document-load`])),(u=e.omit)!=null&&u.has(`@opentelemetry/instrumentation-fetch`)||f.push(new ps(B(B({},e.network),e[`@opentelemetry/instrumentation-fetch`]))),(d=e.omit)!=null&&d.has(`@opentelemetry/instrumentation-xml-http-request`)||f.push(new ul(B(B({},e.network),e[`@opentelemetry/instrumentation-xml-http-request`]))),e[`empty-root`]&&f.push(new Ho(B({},e[`empty-root`])));for(let e of f)e instanceof X&&(r&&e.setSessionManager(r),n&&e.setLogManager(n));return f},Jl=e=>{if(e!==void 0){if(typeof e!=`string`)throw Error(`appID must be a string, or omitted if not using MXL. Received ${String(e)}`);return e}},Yl=e=>{if(e===void 0){let e=`MXLAppVersionX.X.X`;return e===``?`unspecified`:e}if(typeof e!=`string`)throw Error(`if appVersion is specified, it must be a string. Received ${String(e)}`);let t=e.trim();if(t===``)throw Error(`if appVersion is specified, it cannot be an empty string.`);return t},Xl=(e,t)=>{var n,r,i,a;if(!t.size)return e;let o=[...(n=e==null||(r=e.network)==null?void 0:r.ignoreUrls)==null?[]:n,...(i=e==null||(a=e[`@opentelemetry/instrumentation-fetch`])==null?void 0:a.ignoreUrls)==null?[]:i,...Array.from(t)];return o.length?B(B({},e),{},{network:B(B({},e==null?void 0:e.network),{},{ignoreUrls:o}),"@opentelemetry/instrumentation-fetch":(e==null?void 0:e[`@opentelemetry/instrumentation-fetch`])===void 0?void 0:B(B({},e[`@opentelemetry/instrumentation-fetch`]),{},{ignoreUrls:o})}):e},Zl=e=>{if(e&&typeof e==`object`){let t=e;if(t.mxlExporter||t.name===`MXLExporterError`)return!0}return!1},Ql=e=>{if(e instanceof Error)return e.stack||e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch(t){return String(e)}},$l=({appID:e,appVersion:t,resource:n=jr(),spanExporters:r=[],logExporters:i=[],spanProcessors:a=[],propagator:o=null,defaultInstrumentationConfig:s,instrumentations:c=[],contextManager:l=null,logProcessors:u=[],attributeScrubbers:d=[],enableDefaultAttributeScrubbing:f=!0,additionalQueryParamsToScrub:p=[],logLevel:ee=h.ERROR,mxlDataURL:m,mxlConfigURL:te,diagLogger:g=T.createComponentLogger({namespace:`mxl-sdk`}),dynamicSDKConfigManager:ne,dynamicSDKConfig:re,registerGlobally:_=!0,blockNetworkSpanForwarding:ie=!1,restrictedProtocols:ae=new Set([`file:`])}={})=>{try{let h=new bi,se=h.getNowMillis();if(_){let e=Kl.registered();if(e!==null)return g.warn(`SDK has already been successfully initialized, skipping this invocation of initSDK`),e}T.setLogger(new fe,{logLevel:ee}),ln(e=>{Zl(e)||T.error(Ql(e))});let v=Jl(e),ce=Yl(t),le=v!==void 0;if(!le&&!i.length&&!r.length)throw Error(`when appID is omitted, at least one logExporter or spanExporter must be set`);if(ae.has(window.location.protocol))throw Error(`not initializing due to restricted protocol: ${window.location.protocol}`);if(le&&typeof CompressionStream>`u`)throw Error(`CompressionStream is not supported in this browser and required for data compression.`);let ue=!_&&e,y=ue?new vi(e,window.localStorage):window.localStorage,de=ue?new vi(e,window.sessionStorage):window.sessionStorage,b=n.merge(Ps({diagLogger:g,appVersion:ce,pageSessionStorage:de})),pe=eu({registerGlobally:_,sdkLocalStorage:y}),x=pe.getMXLUserId();if(le&&!x)throw Error(`userID is required when using MXL exporter`);let me=ne==null?new Ss({appID:v,appVersion:ce,mxlConfigURL:te,defaultConfig:re,deviceId:x,storage:y}):ne;me.refreshRemoteConfig();let he=new ks({dynamicConfigManager:me,deviceId:x,blockNetworkSpanForwarding:ie});if(!he.isSDKEnabled())return g.debug(`SDK is disabled, skipping initialization.`),!1;let ge=new Set;for(let e of[...r,...i])e&&typeof e.url==`string`&&ge.add(e.url);le&&v&&(ge.add(ao(v,m)),ge.add(no(v,m)));let _e=Xl(s,ge),ve=yi({featureManager:he,diag:g,registerGlobally:_,defaultInstrumentationConfig:_e,propagator:o}),ye=new Ts(Cs),be=[...f?Gl(p):[],...d],S=tu({limitManager:ye,registerGlobally:_,sdkLocalStorage:y,sdkSessionStorage:de}),xe,Se;if(le){var oe;xe=new Fl({resource:b,exporter:new oo({appID:v,mxlDataURL:m,userID:x}),limitManager:ye,storedSpansExpireTimeoutMS:s==null||(oe=s[`session-visibility`])==null?void 0:oe.storedSpansExpireTimeoutMS,storage:y,spanSessionManager:S}),Se=new Tl(new ro({appID:v,mxlDataURL:m,userID:x}))}let Ce=iu({registerGlobally:_}),{tracerProvider:we,mxlTraceManager:Te}=nu({resource:b,spanSessionManager:S,userManager:pe,spanExporters:r,spanProcessors:a,propagator:ve?new Vl:o,contextManager:l,attributeScrubbers:be,registerGlobally:_,mxlSpanProcessor:xe,pageManager:Ce});S.setTracerProvider(we);let{loggerProvider:Ee,mxlLogManager:De}=ru({resource:b,userManager:pe,logExporters:i,logProcessors:u,spanSessionManager:S,limitManager:ye,attributeScrubbers:be,registerGlobally:_,mxlLogProcessor:Se,sdkLocalStorage:y,pageManager:Ce});yo(_?{instrumentations:[ql(_e,{featureManager:he,mxlSpanProcessor:xe,pageManager:Ce}),...c]}:{tracerProvider:we,loggerProvider:Ee,instrumentations:[ql(_e,{featureManager:he,logManager:De,spanSessionManager:S,mxlSpanProcessor:xe,pageManager:Ce}),...c]}),g.info(`successfully initialized the SDK`);let Oe={setDynamicConfig:e=>{me.setConfig(e)},flush:function(){var e=z(function*(){yield we.forceFlush(),yield Ee.forceFlush()});return function(){return e.apply(this,arguments)}}(),log:De,trace:Te,session:S,user:pe,page:Ce};return _&&Kl.register(Oe),S.recordSDKStartupDuration(h.getNowMillis()-se),Oe}catch(e){let t=e instanceof Error?e.message:`Unknown error.`;return g.error(`failed to initialize the SDK: ${t}`),!1}},eu=({registerGlobally:e,sdkLocalStorage:t})=>{let n=new Gs({storage:t});return e&&ra.setGlobalUserManager(n),n},tu=({limitManager:e,registerGlobally:t,sdkLocalStorage:n,sdkSessionStorage:r})=>{let i=new Rs({limitManager:e,storage:n,sessionStorage:r});return t&&Vi.setGlobalSessionManager(i),i},nu=({resource:e,spanSessionManager:t,userManager:n,spanExporters:r,spanProcessors:i=[],propagator:a=null,contextManager:o=null,attributeScrubbers:s,registerGlobally:c,mxlSpanProcessor:l,pageManager:u})=>{let d=[...i,Dl(t),new Ml,new Bl({userManager:n}),new Ll({pageManager:u}),new Rl({attributeScrubbers:s})];r==null||r.forEach(e=>{d.push(new Yr(e))}),l&&d.push(l);let f=new ai({resource:e,spanProcessors:d,spanLimits:{attributeCountLimit:Cs.maxAllowed.session_property*2,attributePerEventCountLimit:20,eventCountLimit:Cs.maxAllowed.breadcrumb*2,attributeValueLengthLimit:1024}}),p=new zs({tracerProvider:c?void 0:f});return c&&(Yi.setGlobalTraceManager(p),f.register({contextManager:o||new ni,propagator:a})),{tracerProvider:f,mxlTraceManager:p}},ru=({resource:e,userManager:t,logExporters:n,logProcessors:r,spanSessionManager:i,limitManager:a,attributeScrubbers:o,registerGlobally:s,mxlLogProcessor:c,sdkLocalStorage:l,pageManager:u})=>{let d=[...r,new Ol({spanSessionManager:i}),new Al,new zl({userManager:t}),new kl({attributeScrubbers:o}),new Il({pageManager:u})];n==null||n.forEach(e=>{d.push(new Tl(e))}),c&&d.push(c);let f=new Cl({resource:e,processors:d}),p=new Ds({spanSessionManager:i,limitManager:a,loggerProvider:s?void 0:f,storage:l});return s&&(go.setGlobalLoggerProvider(f),Oi.setGlobalLogManager(p)),{loggerProvider:f,mxlLogManager:p}},iu=({registerGlobally:e})=>{let t=new Os;return e&&K.setGlobalPageManager(t),t};return e.DEFAULT_MXL_EXPORTER_CONFIG=ia,Object.defineProperty(e,`DiagLogLevel`,{enumerable:!0,get:function(){return h}}),e.MXLLogExporter=ro,e.MXLTraceExporter=oo,e.OTLPFetchLogExporter=to,e.OTLPFetchTraceExporter=io,e.getNavigationInstrumentation=_s,e.initSDK=$l,e.log=Oi,e.page=K,e.session=Vi,e.trace=Yi,e.user=ra,e})({});
|
|
2
2
|
//# sourceMappingURL=mxl-web-sdk.js.map
|