PageSourceSearch

https://alpariforexfa.org/_next/static/chunks/4d41f019.0a05a415b2061b1e.js

js alpariforexfa.org collected 2026-10-08 20:34:45 UTC 110,412 bytes, 4 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[354],{99913:(e,t,i)=>{function r(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function n(e){return function t(i){return 0==arguments.length||r(i)?t:e.apply(this,arguments)}}function s(e){return function t(i,s){switch(arguments.length){case 0:return t;case 1:return r(i)?t:n(function(t){return e(i,t)});default:return r(i)&&r(s)?t:r(i)?n(function(t){return e(t,s)}):r(s)?n(function(t){return e(i,t)}):e(i,s)}}}function a(e){return function t(i,a,o){switch(arguments.length){case 0:return t;case 1:return r(i)?t:s(function(t,r){return e(i,t,r)});case 2:return r(i)&&r(a)?t:r(i)?s(function(t,i){return e(t,a,i)}):r(a)?s(function(t,r){return e(i,t,r)}):n(function(t){return e(i,a,t)});default:return r(i)&&r(a)&&r(o)?t:r(i)&&r(a)?s(function(t,i){return e(t,i,o)}):r(i)&&r(o)?s(function(t,i){return e(t,a,i)}):r(a)&&r(o)?s(function(t,r){return e(i,t,r)}):r(i)?n(function(t){return e(t,a,o)}):r(a)?n(function(t){return e(i,t,o)}):r(o)?n(function(t){return e(i,a,t)}):e(i,a,o)}}}function o(e,t){return Object.prototype.hasOwnProperty.call(t,e)}i.d(t,{RudderAnalytics:()=>ru});var l,u,c,d=n(function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});function g(e){return"[object Object]"===Object.prototype.toString.call(e)}let h=Number.isInteger||function(e){return(0|e)===e};var p=function(){function e(){this.map={},this.length=0}return e.prototype.set=function(e,t){var i=this.hash(e),r=this.map[i];r||(this.map[i]=r=[]),r.push([e,t]),this.length+=1},e.prototype.hash=function(e){var t=[];for(var i in e)t.push(Object.prototype.toString.call(e[i]));return t.join()},e.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var i=this.map[t],r=0;r<i.length;r+=1){var n=i[r];if(n[0]===e)return n[1]}return}var s=this.hash(e),i=this.map[s];if(i)for(var r=0;r<i.length;r+=1){var n=i[r];if(n[0]===e)return n[1]}},e}(),f=n(function(e){return null!=e&&"function"==typeof e.clone?e.clone():function e(t,i,r){if(r||(r=new p),s=typeof(n=t),null==n||"object"!=s&&"function"!=s)return t;var n,s,a=function(i){var n=r.get(t);if(n)return n;for(var s in r.set(t,i),t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=e(t[s],!0,r));return i};switch(d(t)){case"Object":return a(Object.create(Object.getPrototypeOf(t)));case"Array":return a(Array(t.length));case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,t.flags?t.flags:(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":"")+(t.dotAll?"s":""));case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return t.slice();default:return t}}(e)}),v=a(function(e,t,i){var r,n={};for(r in i=i||{},t=t||{})o(r,t)&&(n[r]=o(r,i)?e(r,t[r],i[r]):t[r]);for(r in i)o(r,i)&&!o(r,n)&&(n[r]=i[r]);return n}),y=a(function e(t,i,r){return v(function(i,r,n){return g(r)&&g(n)?e(t,r,n):t(i,r,n)},i,r)}),m=a(function(e,t,i){return y(function(t,i,r){return e(i,r)},t,i)}),b=s(function(e,t){for(var i=t,r=0;r<e.length;r+=1){if(null==i)return;var n=e[r];i=h(n)?function(e,t){var i=e<0?t.length+e:e;return t[i]}(n,i):i[n]}return i}),k=s(function(e,t){var i={};for(var r in t)e(t[r],r,t)&&(i[r]=t[r]);return i});let I=e=>"function"==typeof e&&!!(e.constructor&&e.call&&e.apply),S=e=>void 0!==e,E=e=>!(e=>null==e)(e),T=e=>{switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return e instanceof Error}},A=(e,t)=>b(t.split("."),e),w=e=>null!==e&&"[object Object]"===Object.prototype.toString.call(e),C=(e,t)=>{if(!Array.isArray(e)||!Array.isArray(t))return f(t);let i=f(e);return t.forEach((e,t)=>{i[t]=Array.isArray(e)||(e=>null!==e&&"object"==typeof e&&!Array.isArray(e))(e)?P(i[t],e):e}),i},P=(e,t)=>m(C,e,t),O=e=>w(e)&&Object.keys(e).length>0,D=e=>{let t=k(S,e);return Object.keys(t).forEach(e=>{let i=t[e];w(i)&&(t[e]=D(i))}),t},R=e=>{let t=k(E,e);
1return Object.keys(t).forEach(e=>{let i=t[e];w(i)&&(t[e]=R(i))}),t},$=e=>{if(O(e))return R(e)},N=(e,t)=>"boolean"==typeof e?e:t,L=e=>(Object.getOwnPropertyNames(e).forEach(function(t){e[t]&&"object"==typeof e[t]&&L(e[t])}),Object.freeze(e)),M=e=>e.replace(/^\.+/,""),x=e=>{let t=e;if("string"!=typeof e&&!(e=>null==e)(e))try{t=JSON.stringify(e)}catch(e){t=null}return t},B=(e,t,i,r,n)=>{let s={category:e,name:t,properties:i,options:r,callback:void 0};I(n)&&(s.callback=n),I(r)&&(s.category=e,s.name=t,s.properties=i,s.options=void 0,s.callback=r),I(i)&&(s.category=e,s.name=t,s.properties=void 0,s.options=void 0,s.callback=i),I(t)&&(s.category=e,s.name=void 0,s.properties=void 0,s.options=void 0,s.callback=t),I(e)&&(s.category=void 0,s.name=void 0,s.properties=void 0,s.options=void 0,s.callback=e),w(e)?(s.name=void 0,s.category=void 0,s.properties=e,I(t)?s.options=void 0:s.options=t):w(t)&&(s.name=void 0,s.properties=t,I(i)?s.options=void 0:s.options=i),"string"==typeof e&&"string"!=typeof t&&(s.category=void 0,s.name=e),S(s.category)||(s.category=void 0),S(s.name)||(s.name=void 0),s.properties=s.properties?f(s.properties):{},S(s.options)?s.options=f(s.options):s.options=void 0;let a="string"==typeof s.name?s.name:s.properties.name,o="string"==typeof s.category?s.category:s.properties.category;return s.properties=P(w(s.properties)?s.properties:{},{...a&&{name:a},...o&&{category:o}}),s},U=(e,t,i,r)=>{let n={name:e,properties:t,options:i,callback:void 0};return I(r)&&(n.callback=r),I(i)&&(n.properties=t,n.options=void 0,n.callback=i),I(t)&&(n.properties=void 0,n.options=void 0,n.callback=t),n.properties=E(n.properties)?f(n.properties):{},S(n.options)?n.options=f(n.options):n.options=void 0,n},j=(e,t,i,r)=>{let n={userId:e,traits:t,options:i,callback:void 0};return I(r)&&(n.callback=r),I(i)&&(n.userId=e,n.traits=t,n.options=void 0,n.callback=i),I(t)&&(n.userId=e,n.traits=void 0,n.options=void 0,n.callback=t),(w(e)||null===e)&&(n.userId=null,n.traits=e,I(t)?n.options=void 0:n.options=t),n.userId=x(n.userId),w(n.traits)?n.traits=f(n.traits):n.traits=void 0,S(n.options)?n.options=f(n.options):n.options=void 0,n},_=(e,t,i,r)=>{let n={to:e,from:t,options:i,callback:void 0};return(I(r)&&(n.callback=r),I(i)&&(n.to=e,n.from=t,n.options=void 0,n.callback=i),I(t))?(n.to=e,n.from=void 0,n.options=void 0,n.callback=t):(w(t)||null===t)&&(n.to=e,n.from=void 0,n.options=t),S(n.to)&&(n.to=x(n.to)),S(n.from)?n.from=x(n.from):n.from=void 0,S(n.options)?n.options=f(n.options):n.options=void 0,n},H=(e,t,i,r)=>{let n={groupId:e,traits:t,options:i,callback:void 0};return I(r)&&(n.callback=r),I(i)&&(n.groupId=e,n.traits=t,n.options=void 0,n.callback=i),I(t)&&(n.groupId=e,n.traits=void 0,n.options=void 0,n.callback=t),(w(e)||null===e)&&(n.groupId=null,n.traits=e,I(t)?n.options=void 0:n.options=t),n.groupId=x(n.groupId),w(n.traits)?n.traits=f(n.traits):n.traits=void 0,S(n.options)?n.options=f(n.options):n.options=void 0,n},F=function(e){return e.UNLOADED="Page Unloaded",e}({}),G="CapabilitiesManager",Q="ConfigManager",V="EventManager",z="PluginsManager",K="UserSessionManager",q="ErrorHandler",W="PluginEngine",J="ReadyAPI",X="AnalyticsCore";for(var Z,Y=[],ee=0;ee<256;ee++)Y[ee]=(ee+256).toString(16).substring(1);for(var et,ei=256,er=[];ei--;)er[ei]=(ei+256).toString(16).substring(1);let en=()=>!(e=>null==e)(globalThis.crypto)&&I(globalThis.crypto.getRandomValues)?function(){(!Z||ee+16>4096)&&(Z=crypto.getRandomValues(new Uint8Array(4096)),ee=0);for(var e,t=0,i="";t<16;t++)e=Z[ee+t],6==t?i+=Y[15&e|64]:8==t?i+=Y[63&e|128]:i+=Y[e],1&t&&t>1&&t<11&&(i+="-");return ee+=16,i}():function(){var e,t=0,i="";if(!et||ei+16>256){for(et=Array(t=256);t--;)et[t]=256*Math.random()|0;t=ei=0}for(;t<16;t++)e=et[ei+t],6==t?i+=er[15&e|64]:8==t?i+=er[63&e|128]:i+=er[e],1&t&&t>1&&t<11&&(i+="-");return ei++,i}(),es=()=>"string"==typeof globalThis.navigator.userAgent&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),ea=e=>e.toISOString(),eo=(e,t,i)=>`Unable to load (${"string"==typeof i?i:i.type}) the script with the id "${e}" from URL "${t}"`,el="[Circular Reference]",eu=(e,t,i,r)=>{try{return JSON.stringify(e,((e,t,i)=>{let r=[];return function(n,s){if(!t?.includes(n)){let t;if(!(e&&null==(t=s))){if("object"!=typeof s||null===s)return s;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(s))return i?.warn(`JSONStringify:: A circular reference has been detected in the object and the property "${n}" has been dropped from the output.`),el;return r.push(s),s}}}})(t,i,r))}catch(e){return r?.warn("Failed to convert the value to a JSON string.",e),null}},ec=(e,t)=>{let i=Array.isArray(e)?[]:{};for(let r in e)if(Object.hasOwnProperty.call(e,r)){let n=e[r],s=t.call(e,r,n);w(s)||Array.isArray(s)?i[r]=ec(s,t):i[r]=s}return i},ed=(e,t)=>{let i=(e=>{let t=[];return function(e,i){if("bigint"==typeof i)return"[BigInt]";for(;t.length>0&&t[t.length-1]!==this;)t.pop();return t.includes(i)?el:(t.push(i),i)}})(),r=i.call(e,"",e);return w(e)||Array.isArray(e)?ec(e,i):r},eg="[SDK DISPATCHED ERROR]",eh=e=>{let{stack:t,stacktrace:i,"opera#sourceloc":r}=e,n=t??i??r;if(n&&"string"==typeof n)return n},ep=(e,t)=>{if(!T(e))return Error(`${t}: ${eu(e)}`);try{let i=new e.constructor(`${t}: ${e.message}`),r=eh(e);return r&&(i.stack=r),Object.getOwnPropertyNames(e).forEach(t=>{if("message"!==t&&"stack"!==t&&"name"!==t)try{i[t]=e[t]}catch{}}),i}catch{return Error(`${t}: ${eu(e)}`)}},ef=e=>{if(T(e)){let t=eh(e);if(t){let{stack:i,stacktrace:r,"opera#sourceloc":n}=e;switch(t){case i:e.stack=`${i}
2${eg}`;break;case r:e.stacktrace=`${r}
3${eg}`;break;default:e["opera#sourceloc"]=`${n}
4${eg}`}}}globalThis.dispatchEvent(new ErrorEvent("error",{error:e,bubbles:!0,cancelable:!0,composed:!0}))},ev="RudderLabs JavaScript SDK",ey="3.27.0",em="RudderJS-Initiated",eb="preloadedEventsBuffer",ek="ajs_aid",eI="ajs_event",eS=1e4,eE=(e="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[e]||(globalThis.RudderStackGlobals[e]={})},eT=(e,t,i="app")=>{eE(i),globalThis.RudderStackGlobals[i][e]=t},eA=(e,t="app")=>(eE(t),globalThis.RudderStackGlobals[t][e]),ew=(e,t)=>{let i={};return e.forEach((r,n)=>{n.startsWith(t)&&(i[n.substring(t.length)]=e.get(n))}),i},eC=(e,t)=>{let i,r=e.shift();if(I(t[r])){switch(r){case"page":i=B(...e);break;case"track":i=U(...e);break;case"identify":i=j(...e);break;case"alias":i=_(...e);break;case"group":i=H(...e);break;default:t[r](...e)}i&&t[r](i)}};class eP{constructor(e,t=1e4){this.logger=e,this.timeout=t}loadJSFile(e){let{url:t,id:i,timeout:r,async:n,callback:s,extraAttributes:a}=e,o=!I(s);((e,t,i,r=!0,n)=>new Promise((s,a)=>{document.getElementById(t)&&a(Error(`A script with the id "${t}" is already loaded. Skipping the loading of this script to prevent conflicts`));try{let o;(e=>{let t=document.getElementsByTagName("head");if(t.length>0)return t[0]?.insertBefore(e,t[0]?.firstChild);let i=document.getElementsByTagName("script");
4if(i.length>0&&i[0]?.parentNode)return i[0]?.parentNode.insertBefore(e,i[0]);let r=document.createElement("head");r.appendChild(e);let n=document.getElementsByTagName("html")[0];n?.insertBefore(r,n.firstChild)})(((e,t,i=!0,r=null,n=null,s={})=>{let a=document.createElement("script");return a.type="text/javascript",a.onload=r,a.onerror=n,a.src=e,a.id=t,a.async=i,Object.keys(s).forEach(e=>{a.setAttribute(e,s[e])}),a.setAttribute("data-loader","RS_JS_SDK"),a})(e,t,r,()=>{globalThis.clearTimeout(o),s(t)},i=>{globalThis.clearTimeout(o),a(Error(eo(t,e,i)))},n)),o=globalThis.setTimeout(()=>{a(Error(`A timeout of ${i} ms occurred while trying to load the script with id "${t}" from URL "${e}"`))},i)}catch(i){a(ep(i,eo(t,e,"unknown")))}}))(t,i,r||this.timeout,n,a).then(e=>{o||s(e)}).catch(e=>{o||s(i,e)})}}var eO=Symbol.for("preact-signals");function eD(){if(eM>1)eM--;else{for(var e,t=!1;void 0!==eL;){var i=eL;for(eL=void 0,ex++;void 0!==i;){var r=i.o;if(i.o=void 0,i.f&=-3,!(8&i.f)&&eH(i))try{i.c()}catch(i){t||(e=i,t=!0)}i=r}}if(ex=0,eM--,t)throw e}}function eR(e){if(eM>0)return e();eM++;try{return e()}finally{eD()}}var e$=void 0;function eN(e){var t=e$;e$=void 0;try{return e()}finally{e$=t}}var eL=void 0,eM=0,ex=0,eB=0;function eU(e){if(void 0!==e$){var t=e.n;if(void 0===t||t.t!==e$)return t={i:0,S:e,p:e$.s,n:void 0,t:e$,e:void 0,x:void 0,r:t},void 0!==e$.s&&(e$.s.n=t),e$.s=t,e.n=t,32&e$.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=e$.s,t.n=void 0,e$.s.n=t,e$.s=t),t}}function ej(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function e_(e,t){return new ej(e,t)}function eH(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function eF(e){for(var t=e.s;void 0!==t;t=t.n){var i=t.S.n;if(void 0!==i&&(t.r=i),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function eG(e){for(var t=e.s,i=void 0;void 0!==t;){var r=t.p;-1===t.i?(t.S.U(t),void 0!==r&&(r.n=t.n),void 0!==t.n&&(t.n.p=r)):i=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=r}e.s=i}function eQ(e,t){ej.call(this,void 0),this.x=e,this.s=void 0,this.g=eB-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function eV(e){var t=e.u;if(e.u=void 0,"function"==typeof t){eM++;var i=e$;e$=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,ez(e),t}finally{e$=i,eD()}}}function ez(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,eV(e)}function eK(e){if(e$!==this)throw Error("Out-of-order effect");eG(this),e$=e,this.f&=-2,8&this.f&&ez(this),eD()}function eq(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==t?void 0:t.name}function eW(e,t){var i=new eq(e,t);try{i.c()}catch(e){throw i.d(),e}var r=i.d.bind(i);return r[Symbol.dispose]=r,r}ej.prototype.brand=eO,ej.prototype.h=function(){return!0},ej.prototype.S=function(e){var t=this,i=this.t;i!==e&&void 0===e.e&&(e.x=i,this.t=e,void 0!==i?i.e=e:eN(function(){var e;null==(e=t.W)||e.call(t)}))},ej.prototype.U=function(e){var t=this;if(void 0!==this.t){var i=e.e,r=e.x;void 0!==i&&(i.x=r,e.e=void 0),void 0!==r&&(r.e=i,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&eN(function(){var e;null==(e=t.Z)||e.call(t)}))}},ej.prototype.subscribe=function(e){var t=this;return eW(function(){var i=t.value,r=e$;e$=void 0;try{e(i)}finally{e$=r}},{name:"sub"})},ej.prototype.valueOf=function(){return this.value},ej.prototype.toString=function(){return this.value+""},ej.prototype.toJSON=function(){return this.value},ej.prototype.peek=function(){var e=e$;e$=void 0;try{return this.value}finally{e$=e}},Object.defineProperty(ej.prototype,"value",{get:function(){var e=eU(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ex>100)throw Error("Cycle detected");this.v=e,this.i++,eB++,eM++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{eD()}}}}),eQ.prototype=new ej,eQ.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f)||(this.f&=-5,this.g===eB))return!0;if(this.g=eB,this.f|=1,this.i>0&&!eH(this))return this.f&=-2,!0;var e=e$;try{eF(this),e$=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return e$=e,eG(this),this.f&=-2,!0},eQ.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}ej.prototype.S.call(this,e)},eQ.prototype.U=function(e){if(void 0!==this.t&&(ej.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},eQ.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(eQ.prototype,"value",{get:function(){if(1&this.f)throw Error("Cycle detected");var e=eU(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),eq.prototype.c=function(){var e=this.S();try{if(8&this.f||void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.u=t)}finally{e()}},eq.prototype.S=function(){if(1&this.f)throw Error("Cycle detected");this.f|=1,this.f&=-9,eV(this),eF(this),eM++;var e=e$;return e$=this,eK.bind(this,e)},eq.prototype.N=function(){2&this.f||(this.f|=2,this.o=eL,eL=this)},eq.prototype.d=function(){this.f|=8,1&this.f||ez(this)},eq.prototype.dispose=function(){this.d()};class eJ{constructor(){this.items=[]}enqueue(e){this.items.push(e)}dequeue(){return 0===this.items.length?null:this.items.shift()}isEmpty(){return 0===this.items.length}size(){return this.items.length}clear(){this.items=[]}}let eX={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},eZ="ERROR";class eY{constructor(e="LOG",t="",i=console){this.minLogLevel=eX[e],this.scope=t,this.logProvider=i}log(...e){this.outputLog("LOG",e)}info(...e){this.outputLog("INFO",e)}debug(...e){this.outputLog("DEBUG",e)}warn(...e){this.outputLog("WARN",e)}error(...e){this.outputLog("ERROR",e)}outputLog(e,t){this.minLogLevel<=eX[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=eX[e],void 0===this.minLogLevel&&(this.minLogLevel=eX.LOG)}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t="%c RS SDK";this.scope&&(t=`${t} - ${this.scope}`);let i="string"==typeof e[0]?e[0].trim():"",r=[t=`${t} %c ${i}`,"font-weight: bold; background: black; color: white;","font-weight: normal;"];return"string"!=typeof e[0]&&r.push(e[0]),r.push(...e.slice(1)),r}return e}}let e0=new eY,e1=function(e){return e.HANDLEDEXCEPTION="handledException",e.UNHANDLEDEXCEPTION="unhandledException",e.UNHANDLEDREJECTION="unhandledPromiseRejection",e}({}),e2=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],e3="cookieStorage",e6="Unable to process/parse source configuration response",e4="Failed to log breadcrumb",e5="Failed to fetch the source config",e8=e=>`${e}:: The provided callback parameter is not a function.`,e9="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",e7={All:!0},te="js-integrations",tt="plugins",ti=RegExp("^(https?:\\/\\/)(((([a-zA-Z\\d]([a-zA-Z\\d-]*[a-zA-Z\\d])*)\\.)+[a-zA-Z]{2,}|localhost|((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9]?)))(\\:\\d+)?(\\/[-a-zA-Z\\d%_.~+]*)*(\\?[;&a-zA-Z\\d%_.~+=-]*)?(\\#[-a-zA-Z\\d_]*)?$"),tr="modern",tn="https://cdn.rudderlabs.com",ts=`${tn}/v3/${tr}/${te}`,ta=`${tn}/v3/${tr}/${tt}`,to="https://api.rudderstack.com",tl={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},tu={v3:"StorageEncryption",legacy:"StorageEncryptionLegacy"},tc={xhr:"XhrQueue",beacon:"BeaconQueue"},td=e_(f({configUrl:to,loadIntegration:!0,sessions:{autoTrack:!0,timeout:18e5,cutOff:{enabled:!1}}
4,sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:e7,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:1e4,storage:{encryption:{version:"v3"},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1})),tg=L({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),th=L({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),tp={userId:e_(tg.userId),userTraits:e_(tg.userTraits),anonymousId:e_(tg.anonymousId),groupId:e_(tg.groupId),groupTraits:e_(tg.groupTraits),initialReferrer:e_(tg.initialReferrer),initialReferringDomain:e_(tg.initialReferringDomain),sessionInfo:e_(tg.sessionInfo),authToken:e_(tg.authToken)},tf={isOnline:e_(!0),storage:{isLocalStorageAvailable:e_(!1),isCookieStorageAvailable:e_(!1),isSessionStorageAvailable:e_(!1)},isBeaconAvailable:e_(!1),isLegacyDOM:e_(!1),isUaCHAvailable:e_(!1),isCryptoAvailable:e_(!1),isIE11:e_(!1),isAdBlockerDetectionInProgress:e_(!1),isAdBlocked:e_(void 0),cspBlockedURLs:e_([])},tv={isErrorReportingEnabled:e_(!1),isMetricsReportingEnabled:e_(!1),breadcrumbs:e_([])},ty=e_(void 0),tm={activeDataplaneUrl:e_(void 0),integrationsCDNPath:e_(ts),pluginsCDNPath:e_(ta),sourceConfigUrl:e_(void 0),status:e_(void 0),initialized:e_(!1),logLevel:e_(eZ),loaded:e_(!1),readyCallbacks:e_([]),writeKey:e_(void 0),dataPlaneUrl:e_(void 0),safeAnalyticsInstance:e_(void 0)},tb={enabled:e_(!1),initialized:e_(!1),data:e_({}),activeConsentManagerPluginName:e_(void 0),preConsent:e_({enabled:!1}),postConsent:e_({}),resolutionStrategy:e_("and"),provider:e_(void 0),metadata:e_(void 0)},tk={retries:e_(0),dropped:e_(0),sent:e_(0),queued:e_(0),triggered:e_(0),metricsServiceUrl:e_(void 0)},tI={app:e_({name:ev,namespace:"com.rudderlabs.javascript",version:ey,installType:"npm"}),traits:e_(null),library:e_({name:ev,version:ey,snippetVersion:globalThis.RudderSnippetVersion}),userAgent:e_(null),device:e_(null),network:e_(null),os:e_({name:"",version:""}),locale:e_(null),screen:e_({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":e_(void 0),timezone:e_(void 0)},tS={configuredDestinations:e_([]),activeDestinations:e_([]),loadOnlyIntegrations:e_({}),failedDestinations:e_([]),loadIntegration:e_(!0),initializedDestinations:e_([]),clientDestinationsReady:e_(!1),integrationsConfig:e_({})},tE={toBeProcessedArray:e_([]),readyCallbacksArray:e_([])},tT={ready:e_(!1),loadedPlugins:e_([]),failedPlugins:e_([]),pluginsToLoadFromConfig:e_([]),activePlugins:e_([]),totalPluginsToLoad:e_(0)},tA={encryptionPluginName:e_(void 0),migrate:e_(!1),type:e_(void 0),cookie:e_(void 0),entries:e_({}),trulyAnonymousTracking:e_(!1)},tw={isEnabledServerSideCookies:e_(!1),dataServiceUrl:e_(void 0)},tC={eventsQueuePluginName:e_(void 0),deliveryEnabled:e_(!0)},tP={...f({capabilities:tf,consents:tb,context:tI,eventBuffer:tE,lifecycle:tm,loadOptions:td,metrics:tk,nativeDestinations:tS,plugins:tT,reporting:tv,session:tp,source:ty,storage:tA,serverCookies:tw,dataPlaneEvents:tC,autoTrack:{enabled:e_(!1),pageLifecycle:{enabled:e_(!1),pageViewId:e_(void 0),pageLoadedTimestamp:e_(void 0)}}})};function tO(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var tD={exports:{}},tR={exports:{}};tR.exports,tD.exports;let t$=tO(function(){var e,t,i,r;if(u)return tD.exports;return u=1,e=function(){return l?tR.exports:(l=1,tR.exports=function(){function e(e){return e.charAt(0).toUpperCase()+e.substring(1)}function t(e){return function(){return this[e]}}var i=["isConstructor","isEval","isNative","isToplevel"],r=["columnNumber","lineNumber"],n=["fileName","functionName","source"],s=i.concat(r,n,["args"],["evalOrigin"]);function a(t){if(t)for(var i=0;i<s.length;i++)void 0!==t[s[i]]&&this["set"+e(s[i])](t[s[i]])}a.prototype={getArgs:function(){return this.args},setArgs:function(e){if("[object Array]"!==Object.prototype.toString.call(e))throw TypeError("Args must be an Array");this.args=e},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(e){if(e instanceof a)this.evalOrigin=e;else if(e instanceof Object)this.evalOrigin=new a(e);else throw TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var e=this.getFileName()||"",t=this.getLineNumber()||"",i=this.getColumnNumber()||"",r=this.getFunctionName()||"";return this.getIsEval()?e?"[eval] ("+e+":"+t+":"+i+")":"[eval]:"+t+":"+i:r?r+" ("+e+":"+t+":"+i+")":e+":"+t+":"+i}},a.fromString=function(e){var t=e.indexOf("("),i=e.lastIndexOf(")"),r=e.substring(0,t),n=e.substring(t+1,i).split(","),s=e.substring(i+1);if(0===s.indexOf("@"))var o=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(s,""),l=o[1],u=o[2],c=o[3];return new a({functionName:r,args:n||void 0,fileName:l,lineNumber:u||void 0,columnNumber:c||void 0})};for(var o=0;o<i.length;o++)a.prototype["get"+e(i[o])]=t(i[o]),a.prototype["set"+e(i[o])]=function(e){return function(t){this[e]=!!t}}(i[o]);for(var l=0;l<r.length;l++)a.prototype["get"+e(r[l])]=t(r[l]),a.prototype["set"+e(r[l])]=function(e){return function(t){if(!(!isNaN(parseFloat(t))&&isFinite(t)))throw TypeError(e+" must be a Number");this[e]=Number(t)}}(r[l]);for(var u=0;u<n.length;u++)a.prototype["get"+e(n[u])]=t(n[u]),a.prototype["set"+e(n[u])]=function(e){return function(t){this[e]=String(t)}}(n[u]);return a}
4(),tR.exports)}(),t=/(^|@)\S+:\d+/,i=/^\s*at .*(\S+:\d+|\(native\))/m,r=/^(eval@)?(\[native code])?$/,tD.exports={parse:function(e){if(void 0!==e.stacktrace||void 0!==e["opera#sourceloc"])return this.parseOpera(e);if(e.stack&&e.stack.match(i))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw Error("Cannot parse given Error object")},extractLocation:function(e){if(-1===e.indexOf(":"))return[e];var t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE:function(t){return t.stack.split("\n").filter(function(e){return!!e.match(i)},this).map(function(t){t.indexOf("(eval ")>-1&&(t=t.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var i=t.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),r=i.match(/ (\(.+\)$)/);i=r?i.replace(r[0],""):i;var n=this.extractLocation(r?r[1]:i);return new e({functionName:r&&i||void 0,fileName:["eval","<anonymous>"].indexOf(n[0])>-1?void 0:n[0],lineNumber:n[1],columnNumber:n[2],source:t})},this)},parseFFOrSafari:function(t){return t.stack.split("\n").filter(function(e){return!e.match(r)},this).map(function(t){if(t.indexOf(" > eval")>-1&&(t=t.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===t.indexOf("@")&&-1===t.indexOf(":"))return new e({functionName:t});var i=/((.*".+"[^@]*)?[^@]*)(?:@)/,r=t.match(i),n=r&&r[1]?r[1]:void 0,s=this.extractLocation(t.replace(i,""));return new e({functionName:n,fileName:s[0],lineNumber:s[1],columnNumber:s[2],source:t})},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(t){for(var i=/Line (\d+).*script (?:in )?(\S+)/i,r=t.message.split("\n"),n=[],s=2,a=r.length;s<a;s+=2){var o=i.exec(r[s]);o&&n.push(new e({fileName:o[2],lineNumber:o[1],source:r[s]}))}return n},parseOpera10:function(t){for(var i=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,r=t.stacktrace.split("\n"),n=[],s=0,a=r.length;s<a;s+=2){var o=i.exec(r[s]);o&&n.push(new e({functionName:o[3]||void 0,fileName:o[2],lineNumber:o[1],source:r[s]}))}return n},parseOpera11:function(i){return i.stack.split("\n").filter(function(e){return!!e.match(t)&&!e.match(/^Error created at/)},this).map(function(t){var i,r=t.split("@"),n=this.extractLocation(r.pop()),s=r.shift()||"",a=s.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return s.match(/\(([^)]*)\)/)&&(i=s.replace(/^[^(]+\(([^)]*)\)$/,"$1")),new e({functionName:a,args:void 0===i||"[arguments not available]"===i?void 0:i.split(","),fileName:n[0],lineNumber:n[1],columnNumber:n[2],source:t})},this)}},tD.exports}()),tN="global code",tL=e=>"string"==typeof e?e:"";function tM(e,t,i,r){return{errorClass:tL(e),message:`${i}${tL(t)}`,type:"browserjs",stacktrace:r.reduce((e,t)=>{let i=(e=>{let t,i={file:e.fileName,method:S(t=e.functionName)&&/^global code$/i.test(t)?tN:t,lineNumber:e.lineNumber,columnNumber:e.columnNumber};return i.lineNumber&&i.lineNumber>-1&&!i.file&&!i.method&&(i.file=tN),i})(t);try{if("{}"===JSON.stringify(i))return e;return e.concat(i)}catch{return e}},[])}}let tx=(e,t)=>{let i;if(T(e)&&"string"==typeof eh(e))i=e;else{let r;t.warn((r=eu(e),`${q}:: Ignoring a non-error: ${r}.`)),i=void 0}return i},tB=(e,t)=>{try{return JSON.parse(e||"")}catch(e){t(ep(e,"Failed to parse response data"))}},tU="The request failed",tj=[RegExp(`${tU}.*`),/A script with the id .* is already loaded\./],t_=[/Failed to fetch dynamically imported module: .*/,/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],tH={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},tF=(e,t,i)=>{let r=P(tH,t||{});return i&&(r.headers=P(r.headers,{Authorization:i})),r.url=e,r},tG=(e,t=eS,i)=>new Promise((r,n)=>{let s;if(!0===e.sendRawData)s=e.data;else if(null===(s=eu(e.data,!1,[],i)))return void n({error:Error("Failed to prepare data for the request."),undefined,options:e});let a=new XMLHttpRequest,o=t=>{n({error:Error(((e,t,i)=>`${e} due to timeout or no connection (${t?t.type:""}) at the client side for URL: ${i}`)(tU,t,e.url)),xhr:a,options:e,...t?.type==="timeout"?{timedOut:!0}:{}})};a.ontimeout=o,a.onerror=o,a.onload=()=>{a.status>=200&&a.status<400?r({response:a.responseText,xhr:a,options:e}):(t=>{let i,r,s,o;n({error:Error((i=a.status,r=a.statusText,s=e.url,o=a.responseText,`${tU} with status ${i} (${r}) for URL: ${s}. Response: ${o.trim()}`)),xhr:a,options:e})})()},a.open(e.method,e.url,!0),!0===e.withCredentials&&(a.withCredentials=!0),a.timeout=t,Object.keys(e.headers).forEac
4h(t=>{e.headers[t]&&a.setRequestHeader(t,e.headers[t])});try{a.send(s)}catch(i){let t;n({error:ep(i,(t=e.url,`${tU} for URL: ${t}`)),xhr:a,options:e})}});class tQ{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:t,options:i,timeout:r,isRawResponse:n}=e;try{let e=await tG(tF(t,i,this.basicAuthHeader),r,this.logger);return{data:n?e.response:tB(e.response,this.onError),details:e}}catch(e){return{data:void 0,details:e}}}getAsyncData(e){let{callback:t,url:i,options:r,timeout:n,isRawResponse:s}=e,a=!I(t);tG(tF(i,r,this.basicAuthHeader),n,this.logger).then(e=>{a||t(s?e.response:tB(e.response,this.onError),e)}).catch(e=>{a||t(void 0,e)})}onError(e,t){this.errorHandler?.onError({error:e,context:"HttpClient",groupingHash:t})}setAuthHeader(e,t=!1){let i,r=t?e:(i=`${e}:`,globalThis.btoa(Array.from(new TextEncoder().encode(i),e=>String.fromCodePoint(e)).join("")));this.basicAuthHeader=`Basic ${r}`}resetAuthHeader(){this.basicAuthHeader=void 0}}let tV=new tQ(e0),tz=["www.test-host.com","localhost","127.0.0.1","[::1]"],tK=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],tq=e=>{tP.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let t=new URL(tP.lifecycle.sourceConfigUrl.value),i=`${t.origin}${t.pathname}?view=ad`;e.getAsyncData({url:i,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(e,t)=>{tP.capabilities.isAdBlockerDetectionInProgress.value=!1,tP.capabilities.isAdBlocked.value=t?.error!==void 0||t?.xhr?.responseURL!==i}})}catch(e){throw tP.capabilities.isAdBlockerDetectionInProgress.value=!1,e}};class tW{initialized=!1;constructor(e,t){this.httpClient=e,this.logger=t}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:q,errorType:e1.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:q,errorType:e1.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let t="string"==typeof e.blockedURI?e.blockedURI:"";"enforce"===e.disposition&&t.startsWith(tn)&&!tP.capabilities.cspBlockedURLs.value.includes(t)&&(tP.capabilities.cspBlockedURLs.value=[...tP.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{let{error:t,context:i,customMessage:r,groupingHash:n,category:s}=e,a=e.errorType??e1.HANDLEDEXCEPTION,o=((e,t)=>{switch(t){case e1.UNHANDLEDEXCEPTION:{let{error:t}=e;return t||e}case e1.UNHANDLEDREJECTION:return e.reason;case e1.HANDLEDEXCEPTION:default:return e}})(t,a),l=tx(o,this.logger);if(void 0===l)return;let u=r?`${r} - `:"",c=`${i}:: ${u}`,d=((e,t)=>{try{let i=t$.parse(e);return tM(e.name,e.message,t,i)}catch{return tM(e.name,e.message,t,[])}})(l,c),g=eh(l).includes(eg);if(!g&&!(e=>{let t=e.stacktrace[0]?.file;if(!t||"string"!=typeof t)return!1;let i=t.substring(t.lastIndexOf("/")+1),r=t.split("/");return r[r.length-2]===te||["rsa"].some(e=>i.startsWith(e)&&i.endsWith(".js"))})(d)&&a!==e1.HANDLEDEXCEPTION)return;if(tP.reporting.isErrorReportingEnabled.value&&await ((e,t,i)=>{let r=e.message;return new Promise(e=>{if(t_.some(e=>e.test(r))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(r)?.[0];"string"==typeof n?n.startsWith(tn)?t.capabilities.cspBlockedURLs.value.includes(n)?e(!1):((e,t,i)=>{if(void 0===e.capabilities.isAdBlocked.value){!1===e.capabilities.isAdBlockerDetectionInProgress.value&&tq(t);let r=eW(()=>{S(e.capabilities.isAdBlocked.value)&&(i(!1===e.capabilities.isAdBlocked.value),r())})}else i(!1===e.capabilities.isAdBlocked.value)})(t,i,e):e(!1):e(!0)}else e(!tj.some(e=>e.test(r)))})})(d,tP,this.httpClient)){let e={severity:"error",unhandled:a!==e1.HANDLEDEXCEPTION,severityReason:{type:a}},t=((e,t,i)=>{let r;if(S(e))if("string"==typeof e)r=e;else{let n=tx(e,i);r=S(n)?n.message:t}else r=t;return r})(n,d.message,this.logger),i=((e,t,i,r)=>{let n,s,a,o,{context:l,lifecycle:u,session:c,source:d,reporting:g,autoTrack:h}=i,{app:p,locale:v,userAgent:y,timezone:m,screen:b,library:k}=l;return{payloadVersion:"5",notifier:{name:"RudderStack JavaScript SDK",version:p.value.version,url:"git+https://github.com/rudderlabs/rudder-sdk-js.git"},events:[{exceptions:[f(e)],severity:t.severity,unhandled:t.unhandled,severityReason:t.severityReason,app:{version:p.value.version,releaseStage:((e=()=>window.location.hostname)=>{let t=e();return!t||t&&tz.includes(t)?"development":"production"})(),type:p.value.installType},device:{locale:v.value??"NA",userAgent:y.value??"NA",time:new Date},request:{url:globalThis.location.href.split("?")[0],clientIp:"[NOT COLLECTED]"}
4,breadcrumbs:f(g.breadcrumbs.value),context:e.message,groupingHash:r,metaData:{app:{snippetVersion:k.value.snippetVersion},device:{...b.value,timezone:m.value},...(e=>{let t=eu(e,!1,tK);return null!==t?JSON.parse(t):{}})(i)},user:(n=d,s=c,a=u,o=h,{id:`${n.value?.id??a.writeKey.value}..${s.sessionInfo.value.id??"NA"}..${o.pageLifecycle.pageViewId.value??"NA"}`,name:n.value?.name??"NA"})}]}})(d,e,tP,t);this.httpClient.getAsyncData({url:tP.metrics.metricsServiceUrl.value,options:{method:"POST",data:eu({version:"1",message_id:en(),source:{name:"js",sdk_version:tP.context.app.value.version,write_key:tP.lifecycle.writeKey.value,install_type:tP.context.app.value.installType,category:s??"sdk"},errors:i}),sendRawData:!0},isRawResponse:!0})}(a===e1.HANDLEDEXCEPTION||g)&&this.logger.error(d.message)}catch(e){this.logger.error(`${q}:: Failed to handle the error.`,e)}}leaveBreadcrumb(e){try{tP.reporting.breadcrumbs.value=[...tP.reporting.breadcrumbs.value,{type:"manual",name:e,timestamp:new Date,metaData:{}}]}catch(e){this.onError({error:e,context:q,customMessage:e4,groupingHash:e4})}}}let tJ=new tW(tV,e0);class tX{plugins=[];byName={};cache={};config={throws:!0};constructor(e,t={}){this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){let t=`${W}:: Plugin name is missing.`;if(!this.config.throws)return void this.logger.error(t,e);throw Error(t)}if(this.byName[e.name]){let t,i=(t=e.name,`${W}:: Plugin "${t}" already exists.`);if(!this.config.throws)return void this.logger.error(i);throw Error(i)}this.cache={},this.plugins=this.plugins.slice();let i=this.plugins.length;this.plugins.forEach((t,r)=>{t.deps?.includes(e.name)&&(i=Math.min(i,r))}),this.plugins.splice(i,0,e),this.byName[e.name]=e,I(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let t=`${W}:: Plugin "${e}" not found.`;if(!this.config.throws)return void this.logger.error(t);throw Error(t)}let i=this.plugins.indexOf(t);if(-1===i){let t=`${W}:: Plugin "${e}" not found in plugins but found in byName. This indicates a bug in the plugin engine. Please report this issue to the development team.`;if(!this.config.throws)return void this.logger.error(t);throw Error(t)}this.cache={},delete this.byName[e],this.plugins=this.plugins.slice(),this.plugins.splice(i,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(e=>{if(e.deps?.some(e=>!this.byName[e])){let t,i=e.deps.filter(e=>!this.byName[e]);return this.logger.error((t=e.name,`${W}:: Plugin "${t}" could not be loaded because some of its dependencies "${i}" do not exist.`)),!1}return"."===t||!!A(e,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...i){let r=e;if(!r)throw Error("Failed to invoke plugin because the extension point name is missing.");let n=r.startsWith("!"),s=this.config.throws??r.endsWith("!");if(!(r=r.replace(/(^!|!$)/g,"")))throw Error("Failed to invoke plugin because the extension point name is invalid.");let a=r.split(".");a.pop();let o=a.join(".");return(t?this.getPlugins(r):[this.getPlugins(r)[0]]).map(e=>{let t=A(e,r);if(!I(t)||n)return t;try{return t.apply(A(e,o),i)}catch(n){let t,i;if(s)throw n;this.logger.error((t=r,i=e.name,`${W}:: Failed to invoke the "${t}" extension point of plugin "${i}".`),n)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}}let tZ=new tX(e0,{throws:!0}),tY=e=>"cloud"!==e.config.connectionMode||!0===e.config.useNativeSDKToSend||!0===e.config.useNativeSDK,t0=e=>e.filter(tY),t1=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],t2=["Bugsnag","ErrorReporting"],t3={rudderAnalyticsRemotePlugins:{url:()=>Promise.resolve(window.RudderStackGlobals&&window.RudderStackGlobals.app&&window.RudderStackGlobals.app.pluginsCDNPath?`${window.RudderStackGlobals.app.pluginsCDNPath}/rsa-plugins.js`:"https://cdn.rudderlabs.com/v3/modern/plugins//rsa-plugins.js"),format:"esm",from:"vite"}};async function t6(e){let t=t3[e];return t.inited?t.lib:["esm","systemjs"].includes(t.format)?new Promise((e,i)=>{("function"==typeof t.url?t.url:()=>Promise.resolve(t.url))().then(r=>{import(r).then(i=>{if(!t.inited){let e=function e(t,i){let r=Object.assign(t,i);for(let t of Object.keys(r))"object"==typeof r[t]&&"object"==typeof i[t]&&(r[t]=e(r[t],i[t]));return r}({},(globalThis.__federation_shared__||{}).default||{});i.init(e),t.lib=i,t.lib.init(e),t.inited=!0}e(t.lib)}).catch(i)})}):void 0}function t4(e,t){if(!e?.default&&t){let t=Object.create(null);return t.default=e,t.__esModule=!0,t}return e}function t5(e,t){return t6(e).then(e=>e.get(t).then(e=>e()))}let t8=e=>{let t={};
4return e.forEach(e=>{if(t1.includes(e)){let i=(e=>{switch(e){case"BeaconQueue":return()=>t5("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>t4(e,!0));case"CustomConsentManager":return()=>t5("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>t4(e,!0));case"DeviceModeDestinations":return()=>t5("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>t4(e,!0));case"DeviceModeTransformation":return()=>t5("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>t4(e,!0));case"ExternalAnonymousId":return()=>t5("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>t4(e,!0));case"GoogleLinker":return()=>t5("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>t4(e,!0));case"KetchConsentManager":return()=>t5("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>t4(e,!0));case"IubendaConsentManager":return()=>t5("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>t4(e,!0));case"NativeDestinationQueue":return()=>t5("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>t4(e,!0));case"OneTrustConsentManager":return()=>t5("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>t4(e,!0));case"StorageEncryption":return()=>t5("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>t4(e,!0));case"StorageEncryptionLegacy":return()=>t5("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>t4(e,!0));case"StorageMigrator":return()=>t5("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>t4(e,!0));case"XhrQueue":return()=>t5("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>t4(e,!0));default:return}})(e);i&&(t[e]=i)}}),t},t9=()=>({}),t7={...t9()};class ie{constructor(e,t,i){this.engine=e,this.errorHandler=t,this.logger=i,this.onError=this.onError.bind(this)}init(){tP.lifecycle.status.value="pluginsLoading",eT("pluginsCDNPath",tP.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){eW(()=>{(0===tP.plugins.activePlugins.value.length||tP.plugins.loadedPlugins.value.length+tP.plugins.failedPlugins.value.length===tP.plugins.totalPluginsToLoad.value)&&eR(()=>{tP.plugins.ready.value=!0,tP.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=tP.plugins.pluginsToLoadFromConfig.value;return e?(e=e.filter(e=>{if(t2.includes(e))return this.logger.warn(`${z}:: ${e} plugin is deprecated. Please exclude it from the load API options.`),!1;return!0}),[{configurationStatus:()=>S(tP.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:tP.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(tc),shouldAddMissingPlugins:!0},{configurationStatus:()=>t0(tP.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>t0(tP.nativeDestinations.configuredDestinations.value).some(e=>e.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>S(tP.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:tP.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(tl)},{configurationStatus:()=>S(tP.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:tP.storage.encryptionPluginName.value,supportedPlugins:Object.values(tu)},{configurationStatus:()=>tP.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}].forEach(t=>{t.configurationStatus()?(e=e.filter(t.activePluginName?e=>!(e!==t.activePluginName&&t.supportedPlugins.includes(e)):e=>S(e)),this.addMissingPlugins(t,!1,e)):e=e.filter(void 0!==t.basePlugins?e=>!(t.basePlugins.includes(e)||t.supportedPlugins.includes(e)):e=>!t.supportedPlugins.includes(e))}),[...Object.keys(t9()),...e]):[]}addMissingPlugins(e,t,i){let r=e.shouldAddMissingPlugins||t,n=(e.activePluginName?[...e.basePlugins||[],e.activePluginName]:[...e.supp
4ortedPlugins]).filter(e=>!i.includes(e));n.length>0&&(r&&i.push(...n),this.logger.warn(((e,t,i,r)=>{let n=1===i.length,s=n?` '${i[0]}' plugin was`:` ['${i.join("', '")}'] plugins were`,a=`${e}:: ${t}, but${s} not configured to load.`;return r?`${a} So, ${n?"the plugin":"those plugins"} will be loaded automatically.`:`${a} Ignore if this was intentional. Otherwise, consider adding ${n?"it":"them"} to the 'plugins' load API option.`})(z,e.configurationStatusStr,n,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(t7),...t1],i=[],r=[];e.forEach(e=>{t.includes(e)?i.push(e):r.push(e)}),r.length>0&&this.logger.warn(`${z}:: Ignoring unknown plugins: ${r.join(", ")}.`),eR(()=>{tP.plugins.totalPluginsToLoad.value=e.length,tP.plugins.activePlugins.value=i,tP.plugins.failedPlugins.value=r})}registerLocalPlugins(){Object.values(t7).forEach(e=>{I(e)&&tP.plugins.activePlugins.value.includes(e().name)&&this.register([e()])})}registerRemotePlugins(){let e,t={...(e=tP.plugins.activePlugins.value,t8?.(e)||{})};Promise.all(Object.keys(t).map(async e=>{await t[e]().then(e=>this.register([e.default()])).catch(t=>{tP.plugins.failedPlugins.value=[...tP.plugins.failedPlugins.value,e],this.onError(t,`Failed to load plugin "${e}"`,t)})})).catch(e=>{this.onError(e)})}invokeMultiple(e,...t){try{return this.engine.invokeMultiple(e,...t)}catch(t){return this.onError(t,e),[]}}invokeSingle(e,...t){try{return this.engine.invokeSingle(e,...t)}catch(t){return this.onError(t,e),null}}register(e){e.forEach(e=>{try{this.engine.register(e,tP)}catch(t){tP.plugins.failedPlugins.value=[...tP.plugins.failedPlugins.value,e.name],this.onError(t,`Failed to register plugin "${e.name}"`)}})}unregisterLocalPlugins(){Object.values(t7).forEach(e=>{try{this.engine.unregister(e().name)}catch(t){this.onError(t,`Failed to unregister plugin "${e().name}"`)}})}onError(e,t,i){this.errorHandler.onError({error:e,context:z,customMessage:t,groupingHash:i})}}let it="cookieStorage",ii="localStorage",ir="sessionStorage",is="memoryStorage",ia="none",io={userId:"rl_user_id",userTraits:"rl_trait",anonymousId:"rl_anonymous_id",groupId:"rl_group_id",groupTraits:"rl_group_trait",initialReferrer:"rl_page_init_referrer",initialReferringDomain:"rl_page_init_referring_domain",sessionInfo:"rl_session",authToken:"rl_auth_token"},il="clientDataInCookie",iu="clientDataInLocalStorage",ic="clientDataInSessionStorage",id=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ig={[it]:il,[ii]:iu,[is]:"clientDataInMemory",[ir]:ic},ih=(e,t)=>{try{return encodeURIComponent(e)}catch(e){t?.error("Failed to encode the cookie data.",e);return}},ip=e=>{try{return decodeURIComponent(e)}catch(e){return}},iv=()=>(e=>{let t,i={},r=e.split(/\s*;\s*/);return r[0]&&r.forEach(e=>{let r=(t=e.split("="))[0]?ip(t[0]):void 0;r&&(i[r]=t[1]?ip(t[1]):void 0)}),i})(globalThis.document.cookie),iy=function(e,t,i,r){switch(arguments.length){case 4:case 3:case 2:let n={...i||{}},s=`${ih(e,r)}=${ih(t,r)}`;null===t&&(n.maxage=-1),n.maxage&&(n.expires=new Date(+new Date+n.maxage)),n.path&&(s+=`; path=${n.path}`),n.domain&&(s+=`; domain=${n.domain}`),n.expires&&(s+=`; expires=${n.expires.toUTCString()}`),n.samesite&&(s+=`; samesite=${n.samesite}`),n.secure&&(s+="; secure"),globalThis.document.cookie=s;return;case 1:if(e)return iv()[e];return iv();default:return iv()}};class im{isEnabled=!0;length=0;data={};constructor(e){this.options={enabled:!0},this.logger=e}configure(e){return this.options=P(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,t){return this.data[e]=t,this.length=Object.keys(this.data).length,t}getItem(e){return e in this.data?this.data[e]:null}removeItem(e){return e in this.data&&delete this.data[e],this.length=Object.keys(this.data).length,null}clear(){this.data={},this.length=0}key(e){return this.keys()[e]??null}keys(){return Object.keys(this.data)}}let ib=new im(e0);var ik={exports:{}};ik.exports;let iI=tO(function(){return c?ik.exports:(c=1,ik.exports=function(){function e(e){return e=JSON.stringify(e),!!/^\{[\s\S]*\}$/.test(e)}function t(e){if("string"==typeof e)try{return JSON.parse(e)}catch(t){return e}}function i(e){return"[object Function]"===({}).toString.call(e)}var r=function(e){var t="_Is_Incognit";try{e||(e=window.localStorage),e.setItem(t,"yes"),e.removeItem(t)}catch(t){var i={};i._data={},i.setItem=function(e,t){return i._data[e]=String(t)},i.getItem=function(e){return i._data.hasOwnProperty(e)?i._data[e]:void 0},i.removeItem=function(e){return delete i._data[e]},i.clear=function(){return i._data={}},e=i}finally{"yes"===e.getItem(t)&&e.removeItem(t)}return e}();function n(){if(!(this instanceof n))return new n}n.prototype={set:function(t,i){if(t&&!e(t))r.setItem(t,void 0===i||"function"==typeof i?i+"":JSON.stringify(i));else if(e(t))for(var n in t)this.set(n,t[n]);return this},get:function(e){if(void 0===e){var i={};return this.forEach(function(e,t){return i[e]=t}),i}if("?"===e.charAt(0))return this.has(e.substr(1));var n=arguments;if(n.length>1){for(var s={},a=0,o=n.length;a<o;
4a++){var l=t(r.getItem(n[a]));this.has(n[a])&&(s[n[a]]=l)}return s}return t(r.getItem(e))},clear:function(){return r.clear(),this},remove:function(e){var t=this.get(e);return r.removeItem(e),t},has:function(e){return({}).hasOwnProperty.call(this.get(),e)},keys:function(){var e=[];return this.forEach(function(t){e.push(t)}),e},forEach:function(e){for(var t=0,i=r.length;t<i;t++){var n=r.key(t);e(n,this.get(n))}return this},search:function(e){for(var t=this.keys(),i={},r=0,n=t.length;r<n;r++)t[r].indexOf(e)>-1&&(i[t[r]]=this.get(t[r]));return i},len:function(){return r.length}};var s=null;function a(t,r){var o=arguments,l=null;if(s||(s=n()),0===o.length)return s.get();if(1===o.length){if("string"==typeof t)return s.get(t);if(e(t))return s.set(t)}if(2===o.length&&"string"==typeof t){if(!r)return s.remove(t);if(r&&"string"==typeof r)return s.set(t,r);r&&i(r)&&(l=null,l=r(t,s.get(t)),a.set(t,l))}if(2===o.length&&"[object Array]"===Object.prototype.toString.call(t)&&i(r))for(var u=0,c=t.length;u<c;u++)l=r(t[u],s.get(t[u])),a.set(t[u],l);return a}for(var o in n.prototype)a[o]=n.prototype[o];return a}(),ik.exports)}()),iS=e=>e instanceof DOMException&&(["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"].includes(e.name)||[22,1014].includes(e.code)),iE=(e=ii,t,i)=>{let r,n,s,a=`${G}:: The "${e}" storage type is `,o="unavailable",l=!0;try{switch(e){case is:return!0;case it:r=t,n="test_rudder_cookie";break;case ii:r=t??globalThis.localStorage,n="test_rudder_ls";break;case ir:r=t??globalThis.sessionStorage,n="test_rudder_ss";break;default:return!1}if(r&&(r.setItem(n,"true"),r.getItem(n)))return r.removeItem(n),!0;l=!1}catch(e){l=!1,s=e,iS(e)&&(o="full")}return l||i?.warn(`${a}${o}.`,s),!1};class iT{isSupportAvailable=!0;isEnabled=!0;length=0;constructor(e){this.options={enabled:!0},this.logger=e}configure(e){return this.options=P(this.options,e??{}),this.isSupportAvailable=iE(ii),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){iI.set(e,t),this.length=iI.len()}getItem(e){let t=iI.get(e);return void 0===t?null:t}removeItem(e){iI.remove(e),this.length=iI.len()}clear(){iI.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return iI.keys()}}let iA=new iT(e0);class iw{isSupportAvailable=!0;isEnabled=!0;length=0;constructor(e){this.options={enabled:!0},this.logger=e}configure(e){return this.options=P(this.options,e??{}),this.isSupportAvailable=iE(ir),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){this.store&&(this.store.setItem(e,t),this.length=this.store.length)}getItem(e){if(!this.store)return null;let t=this.store.getItem(e);return void 0===t?null:t}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){this.store?.clear(),this.length=0}key(e){return this.store?.key(e)??null}keys(){let e=[];
4if(!this.store)return e;for(let t=0;t<this.store.length;t+=1){let i=this.store.key(t);null!==i&&e.push(i)}return e}}let iC=new iw(e0);class iP{isSupportAvailable=!0;isEnabled=!0;length=0;constructor(e){this.logger=e}configure(e){return this.options||(this.options=(()=>{let e=`.${(e=>{let t=(e=>{let t="function"!=typeof globalThis.URL?(e=>{let t=document.createElement("a");return t.href=e,t.hostname})(e):new URL(e).hostname,i=t?.split(".")??[],r=i[i.length-1],n=[];if(4===i.length&&r&&r===parseInt(r,10).toString())return n;if(i.length<=1)return i[0]&&-1!==i[0].indexOf("localhost")?["localhost"]:n;for(let e=i.length-2;e>=0;e-=1)n.push(i.slice(e).join("."));return n})(e);for(let e=0;e<t.length;e+=1){let i=t[e],r="__tld__",n={domain:`${-1!==i.indexOf("localhost")?"":"."}${i}`};try{if(iy(r,1,n),iy(r))return iy(r,null,n),i}catch{try{iy(r,null,n)}catch{}}}return""})(globalThis.location.href)}`;return{maxage:31536e6,path:"/",domain:e&&"."!==e?e:void 0,samesite:"Lax",enabled:!0}})()),this.options=P(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=iE(it,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){return iy(e,t,this.options,this.logger),this.length=Object.keys(iy()).length,!0}getItem(e){let t=iy(e);return void 0===t?null:t}removeItem(e){let t=this.setItem(e,null);return this.length=Object.keys(iy()).length,t}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(iy())}}let iO=new iP(e0),iD=e=>{switch(e){case ii:return iA;case ir:return iC;case is:return ib;case it:return iO;default:return ib}};class iR{constructor(e,t,i){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=t,this.noKeyValidation=0===Object.keys(this.validKeys).length,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=i}createValidKey(e){let t,{name:i,id:r,validKeys:n,noKeyValidation:s,noCompoundKey:a}=this;return s?a?e:[i,r,e].join("."):(Object.values(n).forEach(n=>{n===e&&(t=a?e:[i,r,e].join("."))}),t)}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:i,noCompoundKey:r}=this,n=iD(is);
4Object.keys(i).forEach(s=>{let a=this.get(i[s]),o=r?s:[e,t,s].join(".");n.setItem(o,a),this.remove(s)}),this.engine=n}set(e,t){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(eu(t,!1,[],this.logger)))}catch(i){if(iS(i)){let i;this.logger.warn((i=`Store ${this.id}`,`${i}:: The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,t)}else{let t=`Failed to save the value for "${e}" to storage`;this.onError(i,t,t)}}}get(e){let t,i=this.createValidKey(e);try{if(!i)return null;if(t=this.decrypt(this.engine.getItem(i)),null==t||""===t)return null;return JSON.parse(t)}catch(i){let t=`Failed to retrieve or parse data for "${e}" from storage`;return this.onError(i,t,t),null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return null==e?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||"string"!=typeof e||""===e.replace(/^\s+|\s+$/gm,""))return e;let i=`storage.${t}`,r=this.pluginsManager?this.pluginsManager.invokeSingle(i,e):e;return void 0===r?e:r??""}onError(e,t,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:i})}}class i${stores={};isInitialized=!1;constructor(e,t,i){this.errorHandler=t,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=tP.loadOptions.value,t={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};((e={},t={},i={},r={})=>{(e=>{let t=iO.configure(e);tP.storage.cookie.value={maxage:t.maxage,path:t.path,domain:t.domain,samesite:t.samesite,expires:t.expires,secure:t.secure}})(e),iA.configure(t),ib.configure(i),iC.configure(r)})(D(P(t.cookieStorageOptions??{},tP.storage.cookie?.value??{})),D(t.localStorageOptions),D(t.inMemoryStorageOptions),D(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[is,ii,it,ir].forEach(e=>{iD(e)?.isEnabled&&this.setStore({id:ig[e],name:ig[e],isEncrypted:!0,noCompoundKey:!0,type:e,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=tP.storage.type.value,t=tP.loadOptions.value.storage?.entries,i=tP.consents.postConsent.value.storage;(S(i?.type)||S(i?.entries))&&(e=i?.type,t=i?.entries);let r=!0,n={};id.forEach(i=>{let s=t?.[i]?.type,a=((e,t)=>{let i;if(e.consents.preConsent.value.enabled)switch(e.consents.preConsent.value.storage?.strategy){case"none":i=ia;break;case"session":"sessionInfo"!==t&&(i=ia);break;case"anonymousId":"anonymousId"!==t&&(i=ia)}return i})(tP,i)??s??e??e3,o=this.getResolvedStorageTypeForEntry(a,i);o!==ia&&(r=!1),n={...n,[i]:{type:o,key:io[i]}}}),eR(()=>{tP.storage.type.value=e,tP.storage.entries.value=n,tP.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,t){let i,r=e;switch(e){case ii:iD(ii)?.isEnabled||(r=is);break;case ir:iD(ir)?.isEnabled||(r=is);break;case is:case ia:break;default:r=iD(it)?.isEnabled?it:iD(ii)?.isEnabled?ii:iD(ir)?.isEnabled?ir:is}return r!==e&&this.logger.warn((i=r,`StoreManager:: The storage type "${e}" is not available for entry "${t}". The SDK will initialize the entry with "${i}" storage type instead.`)),r}setStore(e){let t=iD(e.type);return this.stores[e.id]=new iR(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}}let iN=e=>{let{host:t,protocol:i}=new URL(e),r=t.split(".");return{topDomain:r.length>2?`${r[r.length-2]}.${r[r.length-1]}`:t,protocol:i}},iL=e=>e?.endsWith("/")?iL(e.substring(0,e.length-1)):e,iM=e=>{try{return new URL(e).host}catch(e){return null}},ix=e=>iM(e)??"",iB=e=>{if("string"!=typeof e)return!1;try{return I(globalThis.URL)&&new URL(e),ti.test(e)}catch(e){return!1}},iU="none",ij="immediate",i_=e=>O(e)||Array.isArray(e),iH=(e,t)=>{let i,r,n=[],s=[],a=!1,o=e?.enabled===!0;O(e)&&o&&({provider:r,consentManagerPluginName:i}=((e,t)=>{let{provider:i}=e,r=i?tl[i]:void 0;if(i&&!r){let e;t.error((e=i,`${Q}:: The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(tl)}".`)),i=void 0}return{provider:i,consentManagerPluginName:r}})(e,t),i_(e.allowedConsentIds)&&(n=e.allowedConsentIds,a=!0),i_(e.deniedConsentIds)&&(s=e.deniedConsentIds,a=!0));let l={allowedConsentIds:n,deniedConsentIds:s};return o=o&&!!i,{provider:r,consentManagerPluginName:i,initialized:a,enabled:o,consentsData:l}},iF=(e,t,i,r,n,s,a)=>{let o;if(s){if(!iB(s))return a.error(`${Q}:: The base URL "${s}" for ${e}
4 is not valid.`),null;o=iL(s)}else if(o=i,"cdn"===tP.context.app.value.installType){let e=(()=>{let e=document.querySelector("script[data-rsa-write-key]");if(e&&e.dataset.rsaWriteKey===tP.lifecycle.writeKey.value)return e.src;let t=document.getElementsByTagName("script"),i=/(?:^|\/)rsa(\.min)?\.js$/;for(let e of t){let t=e.getAttribute("src");if(t&&i.test(t))return t}})();e&&(o=e.split("/").slice(0,-1).concat(t).join("/"))}return n&&(o=o.replace(RegExp(`/v3/${tr}/${t}$`),`/${r}/${tr}/${t}`)),o};class iG{constructor(e,t,i){this.errorHandler=t,this.logger=i,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){eW(()=>{this.logger.setMinLogLevel(tP.lifecycle.logLevel.value)})}init(){let e,{logLevel:t,configUrl:i,lockIntegrationsVersion:r,lockPluginsVersion:n,destSDKBaseURL:s,pluginsSDKBaseURL:a,integrations:o}=tP.loadOptions.value,l=iF("integrations",te,ts,ey,r,s,this.logger);null!==l&&null!==(e=iF("plugins",tt,ta,ey,n,a,this.logger))&&(this.attachEffects(),tP.lifecycle.activeDataplaneUrl.value=iL(tP.lifecycle.dataPlaneUrl.value),(e=>{let t,i,{storage:r}=tP.loadOptions.value,n=r?.type;if(S(n)&&!("string"==typeof(i=n)&&e2.includes(i))){let t;e.warn((t=n,`${Q}:: The storage type "${t}" is not supported. Please choose one of the following supported types: "${e2}". The default type "${e3}" will be used instead.`)),n=e3}let s=r?.encryption?.version,a=s&&tu[s];if(void 0===s||void 0!==a)void 0===s&&(s="v3");else{let t;e.warn((t=s,`${Q}:: The storage encryption version "${t}" is not supported. Please choose one of the following supported versions: "${Object.keys(tu)}". The default version "v3" will be used instead.`)),s="v3"}let o=r?.migrate,l=o&&"v3"===s;!0===o&&l!==o&&e.warn((t=s,`${Q}:: The storage data migration has been disabled because the configured storage encryption version (${t}) is not the latest (v3). To enable storage data migration, please update the storage encryption version to the latest version.`));let{sscEnabled:u,finalDataServiceUrl:c,cookieOptions:d}=(e=>{let t,{useServerSideCookies:i,dataServiceEndpoint:r,storage:n,setCookieDomain:s,sameDomainCookiesOnly:a}=tP.loadOptions.value,o=n?.cookie,l=!1;if(i){l=i;let n=o.domain??s,u=S(n)&&!(e=>{let{topDomain:t}=iN(window.location.href);return t===e})(M(n))||a,c=((e,t)=>{let i=t?window.location.origin:(e=>{let{topDomain:t,protocol:i}=iN(e);return`${i}//${t}`})(window.location.href),r=e.startsWith("/")?e.substring(1):e;return`${i}/${r}`})(r??"rsaRequest",u);if(iB(c)){t=iL(c);let i=iM(window.location.href),r=iM(c);(i!==r&&(o={...o,samesite:"None",secure:!0}),!a&&u&&r!==M(n))&&(l=!1,e.warn(`${Q}:: The provided cookie domain (${n}) does not match the current webpage's domain (${r}). Hence, the cookies will be set client-side.`))}else l=!1}return{sscEnabled:l,cookieOptions:o,finalDataServiceUrl:t}})(e);eR(()=>{tP.storage.type.value=n,tP.storage.cookie.value=d,tP.serverCookies.isEnabledServerSideCookies.value=u,tP.serverCookies.dataServiceUrl.value=c,tP.storage.encryptionPluginName.value=tu[s],tP.storage.migrate.value=l})})(this.logger),(e=>{let{provider:t,consentManagerPluginName:i,initialized:r,enabled:n,consentsData:s}=iH(tP.loadOptions.value.consentManagement,e),a=tP.loadOptions.value.preConsent,o=a?.storage?.strategy??iU;if(S(o)&&!["none","session","anonymousId"].includes(o)){let t;o=iU,e.warn((t=a?.storage?.strategy,`${Q}:: The pre-consent storage strategy "${t}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${iU}" will be used instead.`))}let l=a?.events?.delivery??ij;if(S(l)&&!["immediate","buffer"].includes(l)){let t;l=ij,e.warn((t=a?.events?.delivery,`${Q}:: The pre-consent events delivery type "${t}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${ij}" will be used instead.`))}eR(()=>{tP.consents.activeConsentManagerPluginName.value=i,tP.consents.initialized.value=r,tP.consents.enabled.value=n,tP.consents.data.value=s,tP.consents.provider.value=t,tP.consents.preConsent.value={enabled:tP.loadOptions.value.preConsent?.enabled===!0&&!1===r&&!0===n,storage:{strategy:o},events:{delivery:l}}})})(this.logger),(e=>{if(tP.dataPlaneEvents.deliveryEnabled.value){let t="XhrQueue",i=t;if(tP.loadOptions.value.useBeacon)if(tP.capabilities.isBeaconAvailable.value)i="BeaconQueue";else i=t,e.warn(`${Q}:: The Beacon API is not supported by your browser. The events will be sent using XHR instead.`);eR(()=>{tP.dataPlaneEvents.eventsQueuePluginName.value=i})}})(this.logger),eR(()=>{tP.lifecycle.integrationsCDNPath.value=l,tP.lifecycle.pluginsCDNPath.value=e,t&&(tP.lifecycle.logLevel.value=t),tP.lifecycle.sourceConfigUrl.value=((e,t,i,r,n)=>{let s=new URLSearchParams({p:"npm",v:ey,build:tr,writeKey:t,lockIntegrationsVersion:i.toString(),lockPluginsVersion:r.toString()}),a=to,o=s,l="/sourceConfig/",u="";if(iB(e)){let t=new URL(e);iL(t.pathname).endsWith("/sourceConfig")||(t.pathname=`${iL(t.pathname)}
4/sourceConfig/`),t.pathname=t.pathname.replace(/\/{2,}/g,"/"),s.forEach((e,i)=>{null===t.searchParams.get(i)&&t.searchParams.set(i,e)}),a=t.origin,l=t.pathname,o=t.searchParams,u=t.hash}else n.warn(`${Q}:: The provided source config URL "${e}" is invalid. Using the default source config URL instead.`);return`${a}${l}?${o}${u}`})(i,tP.lifecycle.writeKey.value,r,n,this.logger),tP.metrics.metricsServiceUrl.value=`${tP.lifecycle.activeDataplaneUrl.value}/rsaMetrics`,tP.nativeDestinations.loadOnlyIntegrations.value=o}),this.getConfig())}onError(e,t,i){this.errorHandler.onError({error:e,context:Q,customMessage:t,groupingHash:i})}processConfig(e,t){var i;let r,n,s,a,o;if(!S(e))return void(S(t)?this.onError(t.error,e5):this.onError(Error(e5)));try{r="string"==typeof e?JSON.parse(e):e}catch(e){this.onError(e,e6);return}if(!(w(n=r)&&w(n.source)&&null!=(o=n.source.id)&&w(n.source.config)&&Array.isArray(n.source.destinations)))return void this.onError(Error(e6));if(!1===r.source.enabled)return void this.logger.error("The source is disabled. Please enable the source in the dashboard to send events.");i=r,tP.reporting.isErrorReportingEnabled.value=(s=i.source.config,s?.statsCollection?.errors?.enabled===!0&&!window.chrome?.runtime?.id),tP.reporting.isMetricsReportingEnabled.value=(a=i.source.config,a?.statsCollection?.metrics?.enabled===!0);let l=r.source.destinations.length>0?r.source.destinations.map(e=>{let t,i;return{id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:(t=e.destinationDefinition.displayName,i=e.id,`${t.replaceAll(" ","-")}___${i}`),isCustomIntegration:"Custom Device Mode"===e.destinationDefinition.displayName}}):[];eR(()=>{var e;let t,i;tP.source.value={config:r.source.config,name:r.source.name,id:r.source.id,workspaceId:r.source.workspaceId},tP.nativeDestinations.configuredDestinations.value=l,tP.plugins.pluginsToLoadFromConfig.value=tP.loadOptions.value.plugins??[],e=r,i=tP.consents.resolutionStrategy.value,w(e.consentManagementMetadata)&&(tP.consents.provider.value&&(i=e.consentManagementMetadata.providers.find(e=>e.provider===tP.consents.provider.value)?.resolutionStrategy??tP.consents.resolutionStrategy.value),t=e.consentManagementMetadata),"custom"===tP.consents.provider.value&&(i=void 0),eR(()=>{tP.consents.metadata.value=f(t),tP.consents.resolutionStrategy.value=i}),tP.lifecycle.status.value="configured"})}getConfig(){let e=tP.loadOptions.value.getSourceConfig;if(e){if(!I(e))return void this.logger.error(`${Q}:: The "getSourceConfig" load API option must be a function that returns valid source configuration data.`);let t=e();t instanceof Promise?t.then(e=>this.processConfig(e)).catch(e=>{this.onError(e,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:tP.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}}let iQ=(e=()=>document)=>e()?.referrer||"$direct",iV=(e=()=>globalThis.location,t=()=>document)=>{let i=e(),r=((e=()=>document)=>{let t=e().getElementsByTagName("link"),i="";for(let e=0;t[e];e+=1){let r=t[e];if("canonical"===r.getAttribute("rel")&&!i){i=r.getAttribute("href")??"";break}}return i})(t),n=i.pathname,{href:s}=i,a=s,{search:o}=i;if(r)try{let e=new URL(r);a=""===e.search?r+o:r,n=e.pathname}catch(e){}let l=(e=>{let t=e;try{let i=new URL(e);t=i.origin+i.pathname+i.search}catch(e){}return t})(a),{title:u}=t(),c=iQ(t);return{path:n,referrer:c,referring_domain:ix(c),search:o,title:u,url:l,tab_url:s}},iz={URL:()=>!I(globalThis.URL)||!I(globalThis.URLSearchParams),Promise:()=>!I(globalThis.Promise),"Number.isNaN":()=>!I(globalThis.Number.isNaN),"Number.isInteger":()=>!I(globalThis.Number.isInteger),"Array.from":()=>!I(globalThis.Array.from),"Array.prototype.find":()=>!I(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!I(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!I(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>
4!I(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!I(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!I(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!I(globalThis.String.fromCodePoint),"Object.entries":()=>!I(globalThis.Object.entries),"Object.values":()=>!I(globalThis.Object.values),"Object.assign":()=>!I(globalThis.Object.assign),"Object.fromEntries":()=>!I(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!(()=>{let e=globalThis.document.createElement("div");return e.setAttribute("data-a-b","c"),!!e.dataset&&"c"===e.dataset.aB})(),TextEncoder:()=>!I(globalThis.TextEncoder)||!I(globalThis.TextDecoder),requestAnimationFrame:()=>!I(globalThis.requestAnimationFrame)||!I(globalThis.cancelAnimationFrame),CustomEvent:()=>!I(globalThis.CustomEvent),"navigator.sendBeacon":()=>!I(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!I(globalThis.Uint8Array),Set:()=>!I(globalThis.Set),atob:()=>!I(globalThis.atob)},iK=`https://polyfill-fastly.io/v3/polyfill.min.js?version=3.111.0&features=${Object.keys(iz).join("%2C")}`,iq="rudderstackPolyfill",iW=()=>!(e=>null==e)(globalThis.navigator.userAgentData),iJ=()=>({width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight});class iX{constructor(e,t,i){this.httpClient=e,this.errorHandler=t,this.logger=i,this.externalSrcLoader=new eP(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){eR(()=>{let e,t;tP.capabilities.storage.isCookieStorageAvailable.value=iE(it,iD(it),this.logger),tP.capabilities.storage.isLocalStorageAvailable.value=iE(ii,void 0,this.logger),tP.capabilities.storage.isSessionStorageAvailable.value=iE(ir,void 0,this.logger),tP.capabilities.isBeaconAvailable.value=null!=(e=globalThis.navigator.sendBeacon)&&I(globalThis.navigator.sendBeacon),tP.capabilities.isUaCHAvailable.value=iW(),tP.capabilities.isCryptoAvailable.value=null!=(t=globalThis.crypto)&&I(globalThis.crypto.getRandomValues),tP.capabilities.isIE11.value=es(),tP.capabilities.isOnline.value=globalThis.navigator.onLine,tP.context.userAgent.value=((e=()=>globalThis.navigator)=>{let t=e();if(void 0===t)return null;let{userAgent:i}=t,{brave:r}=t;if(r&&Object.getPrototypeOf(r).isBrave){let e=i.match(/(chrome)\/([\w.]+)/i);e&&(i=`${i} Brave/${e[2]}`)}return i})(),tP.context.locale.value=((e=()=>globalThis.navigator)=>{let t=e();return void 0===t?null:t.language??t.browserLanguage})(),tP.context.screen.value=iJ(),tP.context.timezone.value=(()=>{let e=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return e?.[1]?e[1]:"NA"})(),iW()&&((e,t="none")=>{"none"===t&&e(void 0),"default"===t&&e(navigator.userAgentData),"full"===t&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(t=>{e(t)}).catch(()=>{e()})})(e=>{tP.context["ua-ch"].value=e},tP.loadOptions.value.uaChTrackLevel)}),eW(()=>{!0===tP.loadOptions.value.sendAdblockPage&&void 0!==tP.lifecycle.sourceConfigUrl.value&&tq(this.httpClient)})}prepareBrowserCapabilities(){tP.capabilities.isLegacyDOM.value=(()=>{let e=Object.keys(iz),t=!1;for(let i=0;i<e.length;i++){let r=iz[e[i]];if(I(r)&&r()){t=!0;break}}return t})();let e=tP.loadOptions.value.polyfillURL,t=iK;if(E(e))if(iB(e))t=e;else this.logger.warn(`${G}:: The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`);if(tP.loadOptions.value.polyfillIfRequired&&tP.capabilities.isLegacyDOM.value&&iB(t)){let e=t!==tP.loadOptions.value.polyfillURL;if(e){let e=`RS_polyfillCallback_${tP.lifecycle.writeKey.value}`,i=()=>{this.onReady(),delete globalThis[e]};globalThis[e]=i,t=`${t}&callback=${e}`}this.externalSrcLoader.loadJSFile({url:t,id:iq,async:!0,timeout:1e4,callback:i=>{if(i)e||this.onReady();else{let e;this.onError(Error((e=t,`Failed to load the polyfill script with ID "${iq}" from URL ${e}.`)))}}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{tP.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{tP.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",function(e,t,i=250){let r;return(...n)=>{globalThis.clearTimeout(r),r=globalThis.setTimeout(()=>{e.apply(t,n)},i)}}(()=>{tP.context.screen.value=iJ()},this))}onReady(){this.detectBrowserCapabilities(),tP.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:G,groupingHash:t})}}let iZ=["integrations","anonymousId","originalTimestamp"],iY=["library","consentManagement","userAgent","ua-ch","screen"],i0=["id","anonymous_id","user_id","sent_at","t
4imestamp","received_at","original_timestamp","event","event_text","channel","context_ip","context_request_ip","context_passed_ip","group_id","previous_id"],i1=e=>"number"==typeof e&&!Number.isNaN(e),i2=e=>i1(e)&&e>=0&&Number.isInteger(e),i3=e=>{let{cutOff:t}=e,i=Date.now();return!!(t?.enabled&&t.expiresAt&&i>t.expiresAt)},i6=e=>!!(!e.expiresAt||Date.now()>e.expiresAt)||i3(e),i4=e=>e===it||e===ii||e===ir||e===is,i5=()=>en(),i8=(e,t,i)=>{w(e)&&Object.keys(e).forEach(e=>{(i0.includes(e)||i0.includes(e.toLowerCase()))&&i.warn(`${V}:: The "${e}" property defined under "${t}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i0}).`)})},i9=(e,t,i,r)=>{let n={channel:"web",context:{traits:f(tP.session.userTraits.value),sessionId:tP.session.sessionInfo.value.id||void 0,sessionStart:tP.session.sessionInfo.value.sessionStart||void 0,...tP.consents.enabled.value&&{consentManagement:{deniedConsentIds:f(tP.consents.data.value.deniedConsentIds),allowedConsentIds:f(tP.consents.data.value.allowedConsentIds),provider:tP.consents.provider.value,resolutionStrategy:tP.consents.resolutionStrategy.value}},"ua-ch":tP.context["ua-ch"].value,app:tP.context.app.value,library:tP.context.library.value,userAgent:tP.context.userAgent.value,os:tP.context.os.value,locale:tP.context.locale.value,screen:tP.context.screen.value,campaign:(e=>{let t={};try{let i=new URL(e),r="utm_";i.searchParams.forEach((e,i)=>{if(i.startsWith(r)){let n=i.substring(r.length);"campaign"===n&&(n="name"),t[n]=e}})}catch(e){}return t})(globalThis.location.href),page:(e=>{let t=iV(),i={};return Object.keys(t).forEach(r=>{i[r]=e?.[r]||t[r]}),i.initial_referrer=e?.initial_referrer||tP.session.initialReferrer.value,i.initial_referring_domain=e?.initial_referring_domain||tP.session.initialReferringDomain.value,i})(i),timezone:tP.context.timezone.value,...tP.autoTrack.enabled.value&&{autoTrack:{...tP.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:tP.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:ea(new Date),messageId:en(),userId:e.userId||tP.session.userId.value};i4(tP.storage.entries.value.anonymousId?.type)?n.anonymousId=tP.session.anonymousId.value:n.anonymousId=i5(),tP.storage.trulyAnonymousTracking.value&&(n.context.trulyAnonymousTracking=!0),"identify"===e.type&&(n.context.traits=tP.storage.entries.value.userTraits?.type!==ia?f(tP.session.userTraits.value):e.context.traits),"group"===e.type&&((e.groupId||tP.session.groupId.value)&&(n.groupId=e.groupId||tP.session.groupId.value),(e.traits||tP.session.groupTraits.value)&&(n.traits=tP.storage.entries.value.groupTraits?.type!==ia?f(tP.session.groupTraits.value):e.traits));let s=P(e,n);return void 0===s.event&&(s.event=null),void 0===s.properties&&(s.properties=null),((e,t,i)=>{w(t)&&(((e,t)=>{t.anonymousId&&"string"==typeof t.anonymousId&&(e.anonymousId=t.anonymousId),O(t.integrations)&&(e.integrations=t.integrations),t.originalTimestamp&&"string"==typeof t.originalTimestamp&&(e.originalTimestamp=t.originalTimestamp)})(e,t),e.context=((e,t,i)=>{let r=e;return Object.keys(t).forEach(e=>{if(!iZ.includes(e)&&!iY.includes(e))if("context"!==e)r=P(r,{[e]:t[e]});else if(void 0!==t[e]&&w(t[e])){let i={};Object.keys(t[e]).forEach(r=>{iY.includes(r)||(i[r]=t[e][r])}),r=P(r,{...i})}else i.warn(`${V}:: Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`)}),r})(e.context,t,i))})(s,t,r),((e,t)=>{let{properties:i,traits:r,context:n}=e,{traits:s}=n;i8(i,"properties",t),i8(r,"traits",t),i8(s,"context.traits",t)})(s,r),s.integrations=(e=>f(tP.loadOptions.value.useGlobalIntegrationsConfigInEvents?tP.consents.postConsent.value.integrations??tP.nativeDestinations.loadOnlyIntegrations.value:e||e7))(s.integrations),s};class i7{constructor(e){this.logger=e}generatePageEvent(e,t,i,r){let n=i??{};return i9({properties:n=((e,t)=>{let i=t?.page||{},r=iV();return Object.keys(r).forEach(t=>{void 0===e[t]&&(e[t]=i[t]||r[t])}),void 0===e.initial_referrer&&(e.initial_referrer=i.initial_referrer||tP.session.initialReferrer.value),void 0===e.initial_referring_domain&&(e.initial_referring_domain=i.initial_referring_domain||tP.session.initialReferringDomain.value),e})(n,r),name:t,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,t,i){return i9({properties:t,event:e,type:"track"},i,void 0,this.logger)}generateIdentifyEvent(e,t,i){return i9({userId:e,type:"identify",context:{traits:t}},i,void 0,this.logger)}generateAliasEvent(e,t,i){let r=i9({previousId:t,type:"alias"},i,void 0,this.logger);return r.userId=e??r.userId,r}generateGroupEvent(e,t,i){let r={type:"group"};return e&&(r.groupId=e),t&&(r.traits=t),i9(r,i,void 0,this.logger)}create(e){let t;switch(e.type){case"page":t=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":t=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":t=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":t=this.generateAliasEvent(e.to,e.from,e.options);break;default:t=this.generateGroupEvent(e.groupId,e.traits,e.options)}return t}}class re{constructor(e,t,i,r){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=i,this.logger=r,this.eventFactory=new i7(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let t=this.eventFactory.create(e);this.eventRepository.enqueue(t,e.callback)}}class rt{constructor(e,t,i,r,n){this.storeManager=t,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=i,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){let e;this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:t,anonymousIdOptions:i}=tP.loadOptions.value;E(t)&&"string"==typeof t&&(e=this.getExternalAnonymousIdByCookieName(t)),this.setAnonymousId(e??this.getAnonymousId(i)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),i=this.getSessionInfo()??tg.sessionInfo;(e={autoTrack:t.autoTrack&&!0!==i.manualTrack,timeout:t.timeout,manualTrack:i.manualTrack,expiresAt:i.expiresAt,id:i.id,sessionStart:i.sessionStart}).autoTrack||!0===e.manualTrack?t.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:i.cutOff?.expiresAt}):e=tg.sessionInfo}else e=tg.sessionInfo;tP.session.sessionInfo.value=e,tP.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(tP.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),t=this.getInitialReferringDomain();if(e&&t)this.setInitialReferrer(e),this.setInitialReferringDomain(t);else{let t=e||iQ();this.setInitialReferrer(t),this.setInitialReferringDomain(ix(t))}}isPersistenceEnabledForStorageEntry(e){return i4(tP.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=tP.storage.entries.value,t=[it,ii,ir];Object.keys(e).forEach(i=>
4{let r=e[i]?.type,n=this.storeManager?.getStore(ig[r]);n&&t.forEach(e=>{let t=this.storeManager?.getStore(ig[e]);if(t&&e!==r){let e=t.get(io[i]);E(e)&&""!==e&&n.set(io[i],e),t.remove(io[i])}})})}migrateStorageIfNeeded(e,t){if(!tP.storage.migrate.value)return;let i=e??[];0===i.length&&[il,iu,ic].forEach(e=>{let t=this.storeManager?.getStore(e);t&&i.push(t)}),(t??Object.keys(io)).forEach(e=>{let t=io[e];i.forEach(e=>{let i=this.pluginsManager?.invokeSingle("storage.migrate",t,e.engine,this.errorHandler,this.logger);null==i||e.set(t,i)})})}getConfiguredSessionTrackingInfo(){let e,t,i=!1!==tP.loadOptions.value.sessions.autoTrack;if(!i)return{autoTrack:i};let r=tP.loadOptions.value.sessions?.timeout;if(i2(r))t=r;else this.logger.warn(`${K}:: The session timeout value "${r}" is not a number. The default timeout of 1800000 ms will be used instead.`),t=18e5;0===t&&(this.logger.warn(`${K}:: The session timeout value is 0, which disables the automatic session tracking feature. If you want to enable session tracking, please provide a positive integer value for the timeout.`),i=!1);t>0&&t<1e4&&this.logger.warn((e=t,`${K}:: The session timeout value ${e} ms is less than the recommended minimum of 10000 ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`));let n=this.getCutOffInfo(t);return{timeout:t,autoTrack:i,cutOff:n}}getCutOffInfo(e){let t,i=tP.loadOptions.value.sessions.cutOff,r=!1;if(!0===i.enabled)if(t=i.duration,r=!0,i2(t)){if(t<e){let i;this.logger.warn((i=t,`${K}:: The session cut off duration value "${i}" ms is less than the session timeout value "${e}" ms. The cut off functionality will be disabled.`)),r=!1}}else{let e;this.logger.warn((e=t,`${K}:: The session cut off duration value "${e}" is not a number. The default cut off duration of 43200000 ms will be used instead.`)),t=432e5}return{enabled:r,duration:t}}onError(e,t,i){this.errorHandler.onError({error:e,context:K,customMessage:t,groupingHash:i})}getEncryptedCookieData(e,t){let i=[];return e.forEach(e=>{let r=t?.encrypt(eu(e.value,!1,[],this.logger));E(r)&&i.push({name:e.name,value:r})}),i}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:tP.serverCookies.dataServiceUrl.value,options:{method:"POST",data:eu({reqType:"setCookies",workspaceId:tP.source.value?.workspaceId,data:{options:{maxAge:tP.storage.cookie.value?.maxage,path:tP.storage.cookie.value?.path,domain:tP.storage.cookie.value?.domain,sameSite:tP.storage.cookie.value?.samesite,secure:tP.storage.cookie.value?.secure,expires:tP.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:t})}setServerSideCookies(e,t,i){let r=Object.keys(e),n=()=>r.map(t=>({name:e[t].name,value:tP.session[t].value})),s={};r.forEach(t=>{s[e[t].name]=i?.get(e[t].name)});let a=()=>{r.forEach(e=>{this.serverSideCookiesRequestInProgress[e]=!1})},o=()=>{n().forEach(e=>{t&&t(e.name,e.value)})};try{let l={};r.forEach(t=>{l[e[t].name]=tP.session[t].value});let u=this.getEncryptedCookieData(n(),i);u.length>0?this.makeRequestToSetCookie(u,(e,r)=>{if(a(),r?.xhr?.status===200)n().forEach(e=>{let r=s[e.name],n=i?.get(e.name);if(eu(l[e.name],!1,[])!==eu(n,!1,[])){let i;null===r&&null===n&&this.logger.error((i=e.name,`The server failed to set the ${i} cookie. As a fallback, the cookies will be set client side.`)),t&&t(e.name,e.value)}});else{let e;this.logger.error((e=r?.xhr?.status,`The server responded with status ${e} while setting the cookies. As a fallback, the cookies will be set client side.`)),o()}}):(o(),a())}catch(e){this.onError(e,e9,e9),o(),a()}}syncValueToStorage(e){let t=tP.storage.entries.value,i=t[e]?.type;if(i4(i)){let r=this.storeManager.getStore(ig[i]),n=t[e]?.key,s=tP.session[e].value;s&&("string"==typeof s||O(s))?tP.serverCookies.isEnabledServerSideCookies.value&&i===it?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{this.setServerSideCookies({[e]:{name:n}},(e,t)=>{r?.set(e,t)},r)},10)):r?.set(n,s):r?.remove(n)}}
4registerEffects(){id.forEach(e=>{eW(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let i=e;"string"==typeof e&&i||(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&t&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t)),i=i||i5()):i=tg.anonymousId,tP.session.anonymousId.value=i}getAnonymousId(e){if(i4(tP.storage.entries.value.anonymousId?.type)){let t=tP.session.anonymousId.value;t&&t!==tg.anonymousId||(t=this.getEntryValue("anonymousId")),!t&&e&&(t=this.pluginsManager?.invokeSingle("storage.getAnonymousId",iD,e)),tP.session.anonymousId.value=t||i5()}return tP.session.anonymousId.value}getEntryValue(e){let t=tP.storage.entries.value,i=t[e]?.type;if(i4(i)){let r=this.storeManager?.getStore(ig[i]);this.migrateStorageIfNeeded([r],[e]);let n=t[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let t=iD(it);return t?.isEnabled?t.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?tP.session[e].value:this.getEntryValue(e)}getUserId(){return this.getUserSessionValue("userId")}getUserTraits(){return this.getUserSessionValue("userTraits")}getGroupId(){return this.getUserSessionValue("groupId")}getGroupTraits(){return this.getUserSessionValue("groupTraits")}getInitialReferrer(){return this.getUserSessionValue("initialReferrer")}getInitialReferringDomain(){return this.getUserSessionValue("initialReferringDomain")}getSessionInfo(){return this.getUserSessionValue("sessionInfo")}getAuthToken(){return this.getUserSessionValue("authToken")}getSessionId(){let e=this.getSessionInfo()??tg.sessionInfo;return e.autoTrack&&!i6(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??tg.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=tP.session.sessionInfo.value),void 0===e.sessionStart?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),tP.session.sessionInfo.value=e,"readyExecuted"!==tP.lifecycle.status.value&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=tP.session,{manualTrack:t,autoTrack:i,timeout:r,cutOff:n}=e.sessionInfo.value;if(i){let t={...tg.sessionInfo,timeout:r};n&&(t.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=t,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){let{session:t}=tP,i=(e=>{if("boolean"==typeof e){let{entries:t,...i}=th;return{...i,entries:{...t,anonymousId:e}}}return w(e)&&w(e.entries)?P(th,e):{...th}})(e);eR(()=>{Object.keys(tg).forEach(e=>{if(!0===i.entries[e])switch(e){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[e].value=tg[e]}})})}setUserId(e){tP.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:tg.userId}setUserTraits(e){tP.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&w(e)?P(tP.session.userTraits.value??tg.userTraits,e):tg.userTraits}setGroupId(e){tP.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:tg.groupId}setGroupTraits(e){tP.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&w(e)?P(tP.session.groupTraits.value??tg.groupTraits,e):tg.groupTraits}setInitialReferrer(e){tP.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:tg.initialReferrer}setInitialReferringDomain(e){tP.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:tg.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if(i6(e))t=(e=>{let{timeout:t,cutOff:i}=e,r=Date.now();return{id:r,expiresAt:r+t,timeout:t,autoTrack:!0,...i&&{cutOff:i}}})(e);else{let i=Date.now(),r=e.timeout;t.expiresAt=i+r}if(i3(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){let e=(e=>{if(e?.enabled)return e.expiresAt??(i2(e.duration)?Date.now()+e.duration:void 0)})(t.cutOff);t.cutOff.expiresAt=e}tP.session.sessionInfo.value=t}start(e){tP.session.sessionInfo.value={id:((e,t)=>{if(!e||!i2(e)||!(e.toString().length>=10))return t.warn(`${K}:: The provided session ID (${e}) is either invalid, not a positive integer, or not at least "10" digits long. A new session ID will be auto-generated instead.`),!1;return!0})(e,this.logger)?e:Date.now(),sessionStart:void 0,manualTrack:!0}}startManualTrackingInternal(){this.start(Date.now())}end(){tP.session.sessionInfo.value=tg.sessionInfo}setAuthToken(e){tP.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:tg.authToken}}let ri=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],rr="dataplaneEventsQueue",rn="destinationsEventsQueue",rs=(e,t,i,r)=>{if(S(e))if(I(e))try{e(...t)}catch(e){r.error(`${i}:: The callback threw an exception`,e)}else r.error(e8(i))};class ra{constructor(e,t,i,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=i,this.logger=n,this.storeManager=t}init(){let e;this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${rr}.init`,tP,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle("transformEvent.init",tP,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${rn}.init`,tP,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),eW(()=>{!0===tP.nativeDestinations.clientDestinationsReady.value&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let t=tP.consents.preConsent.value.enabled&&tP.consents.preConsent.value.events?.delivery==="buffer";eW(()=>{let i=!0===tP.loadOptions.value.bufferDataPlaneEventsUntilReady&&!1===tP.nativeDestinations.clientDestinationsReady.value;!1!==tP.nativeDestinations.activeDestinations.value.some(e=>"hybrid"===e.config.connectionMode||!0===e.config.useNativeSDKToSend)&&!1!==i||t||this.dataplaneEventsQueue?.scheduleTimeoutActive===!0||(globalThis.clearTimeout(e),this.dataplaneEventsQueue?.start())}),!0===tP.loadOptions.value.bufferDataPlaneEventsUntilReady&&(e=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},tP.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(tP.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,t){let i=((e,t)=>{let i,r,n=f(e),s=t.nativeDestinations.integrationsConfig.value,a=(i=e.integrations,r=s,Object.keys(i).filter(e=>!0!==i[e]||!r[e]).reduce((e,t)=>
4{let r=f(e);return r[t]=i[t],r},{}));return n.integrations=P(s,a),n})(e,tP);this.pluginsManager.invokeSingle(`${rr}.enqueue`,tP,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let r=f(e);this.pluginsManager.invokeSingle(`${rn}.enqueue`,tP,this.destinationsEventsQueue,r,this.errorHandler,this.logger),rs(t,[i],`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}API`,this.logger)}}let ro=e=>{let t=new CustomEvent(e,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(t)};class rl{constructor(){this.preloadBuffer=new eJ,this.initialized=!1,this.errorHandler=tJ,this.logger=e0,this.externalSrcLoader=new eP(this.logger),this.httpClient=tV,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new iX(this.httpClient,this.errorHandler,this.logger)}load(e,t,i={}){if(!tP.lifecycle.status.value){let r;if(!("string"==typeof(r=e)&&r.trim().length>0))return void this.logger.error(`${X}:: The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`);if(!iB(t))return void this.logger.error(`${X}:: The data plane URL "${t}" is invalid. It must be a valid URL string. Please check that the data plane URL is correct and try again.`);eR(()=>{tP.lifecycle.writeKey.value=f(e),tP.lifecycle.dataPlaneUrl.value=f(t),tP.loadOptions.value=((e,t)=>{let i=f(t);return"string"!=typeof i.setCookieDomain&&(i.setCookieDomain=void 0),["Strict","Lax","None"].includes(i.sameSiteCookie)||(i.sameSiteCookie=void 0),i.secureCookie=N(i.secureCookie,e.secureCookie),i.sameDomainCookiesOnly=N(i.sameDomainCookiesOnly,e.sameDomainCookiesOnly),["none","default","full"].includes(i.uaChTrackLevel)||(i.uaChTrackLevel=void 0),i.integrations=$(i.integrations),Array.isArray(i.plugins)||(i.plugins=ri),i.useGlobalIntegrationsConfigInEvents=N(i.useGlobalIntegrationsConfigInEvents,e.useGlobalIntegrationsConfigInEvents),i.bufferDataPlaneEventsUntilReady=N(i.bufferDataPlaneEventsUntilReady,e.bufferDataPlaneEventsUntilReady),i.sendAdblockPage=N(i.sendAdblockPage,e.sendAdblockPage),i.useServerSideCookies=N(i.useServerSideCookies,e.useServerSideCookies),"string"!=typeof i.dataServiceEndpoint&&(i.dataServiceEndpoint=void 0),i.sendAdblockPageOptions=$(i.sendAdblockPageOptions),i.loadIntegration=N(i.loadIntegration,e.loadIntegration),O(i.storage)?(i.storage.migrate=N(i.storage.migrate,e.storage?.migrate),i.storage.cookie=$(i.storage.cookie),i.storage.encryption=$(i.storage.encryption),i.storage=R(i.storage)):i.storage=void 0,i.destinationsQueueOptions=$(i.destinationsQueueOptions),i.queueOptions=$(i.queueOptions),i.lockIntegrationsVersion=N(i.lockIntegrationsVersion,e.lockIntegrationsVersion),i.lockPluginsVersion=N(i.lockPluginsVersion,e.lockPluginsVersion),i1(i.dataPlaneEventsBufferTimeout)||(i.dataPlaneEventsBufferTimeout=void 0),i.beaconQueueOptions=$(i.beaconQueueOptions),i.preConsent=$(i.preConsent),i.sourceConfigurationOverride=$(i.sourceConfigurationOverride),P(e,R(i))})(tP.loadOptions.value,i),tP.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(tP.loadOptions.value.logLevel??eZ),eT("state",tP,e),this.startLifecycle()}}startLifecycle(){eW(()=>{try{switch(tP.lifecycle.status.value){case"mounted":this.onMounted();break;case"browserCapabilitiesReady":this.onBrowserCapabilitiesReady();break;case"configured":this.onConfigured();break;case"pluginsLoading":case"destinationsLoading":break;case"pluginsReady":this.onPluginsReady();break;case"initialized":this.onInitialized();break;case"loaded":this.onLoaded();break;case"destinationsReady":this.onDestinationsReady();break;case"ready":this.onReady()}}catch(t){let e="Failed to load the SDK";this.errorHandler.onError({error:t,context:X,customMessage:e,groupingHash:e})}})}onBrowserCapabilitiesReady(){let e=eA(eb)||[];((e=[])=>{let t="ajs_trait_",i="ajs_prop_",r=new URLSearchParams(globalThis.location.search);r.get(eI)&&e.unshift(["track",r.get(eI),ew(r,i)]);let n=r.get("ajs_uid"),s=ew(r,t);if(n||O(s)){let t=[...n?[n]:[],s];e.unshift(["identify",...t])}r.get(ek)&&e.unshift(["setAnonymousId",r.get(ek)])})(e),e.length>0&&(this.enqueuePreloadBufferEvents(e),eT(eb,[])),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),!0===tP.consents.preConsent.value.enabled?tP.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}
4enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(e=>this.preloadBuffer.enqueue(f(e)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&eC([...e],this)}}prepareInternalServices(){this.pluginsManager=new ie(tZ,this.errorHandler,this.logger),this.storeManager=new i$(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new iG(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new rt(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new ra(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new re(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){tP.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(tP.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),tP.consents.enabled.value&&!tP.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",tP,this.logger),!1===tP.consents.preConsent.value.enabled&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",tP,this.storeManager,this.logger)),this.eventManager?.init(),tP.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),eR(()=>{tP.lifecycle.loaded.value=!0,tP.lifecycle.status.value="loaded"}),this.initialized=!0,rs(tP.loadOptions.value.onLoaded,[globalThis.rudderanalytics],"LoadAPI",this.logger),ro("RSA_Initialised")}onReady(){tP.lifecycle.status.value="readyExecuted",tP.eventBuffer.readyCallbacksArray.value.forEach(e=>{rs(e,[],J,this.logger)}),ro("RSA_Ready")}processBufferedEvents(){let e=tP.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let t=e.shift();if(tP.eventBuffer.toBeProcessedArray.value=e,t){let e=t[0];I(this[e])&&this[e](...t.slice(1),!0)}e=tP.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if("destinationsLoading"===tP.lifecycle.status.value||"destinationsReady"===tP.lifecycle.status.value)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",tP,this.pluginsManager,this.errorHandler,this.logger);let e=tP.nativeDestinations.activeDestinations.value.length;if(0===e){tP.lifecycle.status.value="destinationsReady";return}tP.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",tP,this.externalSrcLoader,this.errorHandler,this.logger),eW(()=>{(0===e||tP.nativeDestinations.initializedDestinations.value.length+tP.nativeDestinations.failedDestinations.value.length===e)&&eR(()=>{tP.lifecycle.status.value="destinationsReady",tP.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){"ready"!==tP.lifecycle.status.value&&(tP.lifecycle.status.value="ready")}ready(e,t=!1){let i="ready";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[i,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),!I(e))return void this.logger.error(e8(J));"readyExecuted"===tP.lifecycle.status.value?rs(e,[],J,this.logger):tP.eventBuffer.readyCallbacksArray.value=[...tP.eventBuffer.readyCallbacksArray.value,e]}page(e,t=!1){let i="page";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),tP.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),!0===tP.capabilities.isAdBlocked.value&&e.category!==em&&this.page(B(em,"ad-block page request",{path:"/ad-blocked"},tP.loadOptions.value.sendAdblockPageOptions))}track(e,t=!1){let i="track";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event - ${e.name}`),tP.metrics.triggered.value+=1,this.eventManager?.addEvent({type:i,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,t=!1){let i="identify";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),tP.metrics.triggered.value+=1,e.userId&&tP.session.userId.value&&e.userId!==tP.session.userId.value&&this.reset(),null!==e.userId&&this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:i,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,t=!1){let i="alias";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),tP.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:i,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,t=!1){let i="group";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),tP.metrics.triggered.value+=1,null!==e.groupId&&this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:i,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,t=!1){let i="reset";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,t,i=!1){let r="setAnonymousId";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[r,e,t]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,t)}getUserId(){return tP.session.userId.value}getUserTraits(){return tP.session.userTraits.value}getGroupId(){return tP.session.groupId.value}getGroupTraits(){return tP.session.groupTraits.value}startSession(e,t=!1){let i="startSession";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let t="endSession";if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[t]];return}this.errorHandler.leaveBreadcrumb(`New ${t} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,t=!1){if(!tP.lifecycle.loaded.value){tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,["consent",e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),eR(()=>{tP.consents.preConsent.value={...tP.consents.preConsent.value,enabled:!1},tP.consents.postConsent.value=(e=>{let t={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(w(e)){let i=f(e);t.storage=i.storage,O(i.integrations)&&(t.integrations=i.integrations),t.discardPreConsentEvents=!0===i.discardPreConsentEvents,t.sendPageEvent=!0===i.sendPageEvent,t.trackConsent=!0===i.trackConsent,O(i.consentManagement)&&(t.consentManagement=P(i.consentManagement,{enabled:tP.consents.enabled.value}))}return t})(e);let{initialized:t,consentsData:i}=iH(tP.consents.postConsent.value.consentManagement,this.logger);tP.consents.initialized.value=t,tP.consents.data.value=i}),tP.consents.enabled.value&&!tP.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",tP,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(t)}sendTrackingEvents(e){if(tP.consents.postConsent.value.trackConsent){let t=U("Consent Management Interaction");e?tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(tP.consents.postConsent.value.sendPageEvent){let t=B();e?tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,i=!1){let r="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,tP,this.logger);else{if(tP.lifecycle.loaded.value)return void this.logger.error(`${X}:: Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`);tP.eventBuffer.toBeProcessedArray.value=[...tP.eventBuffer.toBeProcessedArray.value,[r,e,t]]}}}class ru{static globalSingleton=null;analyticsInstances={};defaultAnalyticsKey="";logger=e0;constructor(){try{if(ru.globalSingleton)return ru.globalSingleton;ru.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.get
4SessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),ru.globalSingleton=this,tP.autoTrack.pageLifecycle.pageViewId.value=en(),tP.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){ef(e)}}createSafeAnalyticsInstance(){tP.lifecycle.safeAnalyticsInstance.value={page:this.page.bind(this),track:this.track.bind(this),identify:this.identify.bind(this),alias:this.alias.bind(this),group:this.group.bind(this),getAnonymousId:this.getAnonymousId.bind(this),getUserId:this.getUserId.bind(this),getUserTraits:this.getUserTraits.bind(this),getGroupId:this.getGroupId.bind(this),getGroupTraits:this.getGroupTraits.bind(this),getSessionId:this.getSessionId.bind(this)}}static initializeGlobalResources(){tJ.init(),iO.configure(),iA.configure(),iC.configure(),ib.configure()}setDefaultInstanceKey(e){"string"==typeof e&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t,i=e;return t=i,"string"==typeof t&&i||(i=this.defaultAnalyticsKey),this.analyticsInstances[i]||(this.analyticsInstances[i]=new rl),this.analyticsInstances[i]}catch(e){ef(e);return}}load(e,t,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let r=eA(eb),n="consent",s=r.filter(e=>e[0]===n),a=r.filter(e=>e[0]!==n);r.splice(0,r.length,...s,...a),eT(eb,f(r)),this.getAnalyticsInstance(e)?.load(e,t,ed(i))}catch(e){ef(e)}}trackPageLifecycleEvents(e){let{autoTrack:t,useBeacon:i}=e??{},{enabled:r=!1,options:n={},pageLifecycle:s}=t??{},{events:a=[F.UNLOADED],enabled:o=r,options:l=n}=s??{};tP.autoTrack.pageLifecycle.enabled.value=o,tP.autoTrack.enabled.value=r||o,o&&this.setupPageUnloadTracking(a,i,l)}setupPageUnloadTracking(e,t,i){(0===e.length||e.includes(F.UNLOADED))&&(!0===t?((e,t=!1)=>{let i=!1,r=!1;function n(){i||(i=!0,e(r),setTimeout(()=>{i=!1},0))}(t||es())&&globalThis.addEventListener("beforeunload",()=>{r=!1,n()}),globalThis.addEventListener("blur",()=>{r=!0,n()}),globalThis.addEventListener("focus",()=>{i=!1}),document.addEventListener("pagehide",()=>{r="hidden"===document.visibilityState,n()}),document.addEventListener("visibilitychange",()=>{r=!0,"hidden"===document.visibilityState?n():i=!1})})(e=>{if(!1===e&&tP.lifecycle.loaded.value){let e=Date.now(),t=e-tP.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(F.UNLOADED,{timeOnPage:t},{...i,originalTimestamp:ea(new Date(e))})}},!0):this.logger.warn('RudderStackAnalytics:: Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.'))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=(e=>{let t=[],i=0;for(;i<e.length;){if(e[i]&&"load"===e[i][0]){t=f(e[i]),e.splice(i,1);break}i+=1}return t})(e);eT(eb,f([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(ed(e))}catch(e){ef(e)}}page(e,t,i,r,n){try{this.getAnalyticsInstance()?.page(B(ed(e),ed(t),ed(i),ed(r),ed(n)))}catch(e){ef(e)}}track(e,t,i,r){try{this.getAnalyticsInstance()?.track(U(ed(e),ed(t),ed(i),ed(r)))}catch(e){ef(e)}}identify(e,t,i,r){try{this.getAnalyticsInstance()?.identify(j(ed(e),ed(t),ed(i),ed(r)))}catch(e){ef(e)}}alias(e,t,i,r){try{this.getAnalyticsInstance()?.alias(_(ed(e),ed(t),ed(i),ed(r)))}catch(e){ef(e)}}group(e,t,i,r){try{this.getAnalyticsInstance()?.group(H(ed(e),ed(t),ed(i),ed(r)))}catch(e){ef(e)}}reset(e){try{this.getAnalyticsInstance()?.reset(ed(e))}catch(e){ef(e)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(ed(e))}catch(e){ef(e);return}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(ed(e),ed(t))}catch(e){ef(e)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){ef(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){ef(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){ef(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){ef(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(ed(e))}catch(e){ef(e)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){ef(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){ef(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(ed(e))}catch(e){ef(e)}}consent(e){try{this.getAnalyticsInstance()?.consent(ed(e))}catch(e){ef(e)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(ed(e),ed(t))}catch(e){ef(e)}}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.