1var pricing;(()=>{"use strict";var e=function(e){return e.SIGNUP_STARTED="Signup Started",e.LANGUAGE_SELECTED="Language Selected",e.LANGUAGE_SELECTED_SUCCESS="Language Selected Success",e.LEVEL_SELECTED="Level Selected",e.LEVEL_SELECTED_SUCCESS="Level Selected Success",e.AGE_SELECTED="Age Selected",e.AGE_SELECTED_SUCCESS="Age Selected Success",e.SOURCE_SELECTED="How did you hear about us",e.SOURCE_SELECTED_SUCCESS="How did you hear about us Success",e.DAILY_GOAL_SELECTED="Daily Goal",e.DAILY_GOAL_SELECTED_SUCCESS="Daily Goal Success",e.PLAN_SELECTED="Plan Selected",e.PLAN_SELECTED_SUCCESS="Plan Selected Success",e.VIEWED_CHECKOUT_PAGE="Viewed Checkout Page",e.EMAIL_FORM_PAGE="Email-form Page",e.PASSWORD_FORM_PAGE="Password-form Page",e.DOWNLOAD_APP_PAGE="Download App Page",e.PICK_FAVORITE_GENRES="Pick your favorite genres",e.PICK_VIDEO_TO_GET_STARTED="Pick a video to get started",e.VISITED_MARKETING_HOMEPAGE="Visited Marketing Homepage",e.QUICK_WORD_LOOK_UP_IN_FIRST_5_DAYS_OF_TRIAL="Quick Word Lookup in First 5 Days of Trial",e.DETAILED_WORD_LOOK_UP_IN_FIRST_5_DAYS_OF_TRIAL="Detailed Word Lookup in First 5 Days of Trial",e.SIGNUP_EDUCATION_PAGE_SUCCESS="Signup Education Page Success",e}({});function t(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function n(e){return function n(r){return 0===arguments.length||t(r)?n:e.apply(this,arguments)}}function r(e){return function r(i,s){switch(arguments.length){case 0:return r;case 1:return t(i)?r:n(function(t){return e(i,t)});default:return t(i)&&t(s)?r:t(i)?n(function(t){return e(t,s)}):t(s)?n(function(t){return e(i,t)}):e(i,s)}}}function i(e){return function i(s,o,a){switch(arguments.length){case 0:return i;case 1:return t(s)?i:r(function(t,n){return e(s,t,n)});case 2:return t(s)&&t(o)?i:t(s)?r(function(t,n){return e(t,o,n)}):t(o)?r(function(t,n){return e(s,t,n)}):n(function(t){return e(s,o,t)});default:return t(s)&&t(o)&&t(a)?i:t(s)&&t(o)?r(function(t,n){return e(t,n,a)}):t(s)&&t(a)?r(function(t,n){return e(t,o,n)}):t(o)&&t(a)?r(function(t,n){return e(s,t,n)}):t(s)?n(function(t){return e(t,o,a)}):t(o)?n(function(t){return e(s,t,a)}):t(a)?n(function(t){return e(s,o,t)}):e(s,o,a)}}}function s(e,t){return Object.prototype.hasOwnProperty.call(t,e)}var o=n(function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});function a(e){return"[object Object]"===Object.prototype.toString.call(e)}const l=Number.isInteger||function(e){return(e|0)===e};function u(e,t){return t[e<0?t.length+e:e]}function c(e,t,n){if(n||(n=new d),function(e){var t=typeof e;return null==e||"object"!=t&&"function"!=t}(e))return e;var r,i=function(t){var r=n.get(e);if(r)return r;for(var i in n.set(e,t),e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=c(e[i],!0,n));return t};switch(o(e)){case"Object":return i(Object.create(Object.getPrototypeOf(e)));case"Array":return i(Array(e.length));case"Date":return new Date(e.valueOf());case"RegExp":return r=e,new RegExp(r.source,r.flags?r.flags:(r.global?"g":"")+(r.ignoreCase?"i":"")+(r.multiline?"m":"")+(r.sticky?"y":"")+(r.unicode?"u":"")+(r.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 e.slice();default:return e}}var d=function(){function e(){this.map={},this.length=0}return e.prototype.set=function(e,t){var n=this.hash(e),r=this.map[n];r||(this.map[n]=r=[]),r.push([e,t]),this.length+=1},e.prototype.hash=function(e){var t=[];for(var n in e)t.push(Object.prototype.toString.call(e[n]));return t.join()},e.prototype.get=function(e){if(this.length<=180)for(var t in this.map)for(var n=this.map[t],r=0;r<n.length;r+=1){if((s=n[r])[0]===e)return s[1]}else{var i=this.hash(e);if(n=this.map[i])for(r=0;r<n.length;r+=1){var s;if((s=n[r])[0]===e)return s[1]}}},e}(),g=n(function(e){return null!=e&&"function"==typeof e.clone?e.clone():c(e)});function h(e,t){for(var n=t,r=0;r<e.length;r+=1){if(null==n)return;var i=e[r];n=l(i)?u(i,n):n[i]}return n}var p=i(function(e,t,n){var r,i={};for(r in n=n||{},t=t||{})s(r,t)&&(i[r]=s(r,n)?e(r,t[r],n[r]):t[r]);for(r in n)s(r,n)&&!s(r,i)&&(i[r]=n[r]);return i}),f=i(function e(t,n,r){return p(function(n,r,i){return a(r)&&a(i)?e(t,r,i):t(n,r,i)},n,r)}),v=i(function(e,t,n){return f(function(t,n,r){return e(n,r)},t,n)}),y=r(h),m=r(function(e,t){var n={};for(var r in t)e(t[r],r,t)&&(n[r]=t[r]);return n});const b=e=>"function"==typeof e&&Boolean(e.constructor&&e.call&&e.apply),E=e=>"string"==typeof e,S=e=>null===e,k=e=>void 0===e,I=e=>S(e)||k(e),T=e=>!k(e),A=e=>!I(e),w=e=>{switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object E
1xception]":case"[object DOMException]":return!0;default:return e instanceof Error}},C=(e,t)=>{const n=t.split(".");return y(n,e)},P=e=>!S(e)&&"[object Object]"===Object.prototype.toString.call(e),O=(e,t)=>{if(!Array.isArray(e)||!Array.isArray(t))return g(t);const n=g(e);return t.forEach((e,t)=>{n[t]=Array.isArray(e)||(e=>!S(e)&&(e=>"object"==typeof e)(e)&&!Array.isArray(e))(e)?D(n[t],e):e}),n},D=(e,t)=>v(O,e,t),_=e=>P(e)&&Object.keys(e).length>0,R=e=>{const t=m(T,e);return Object.keys(t).forEach(e=>{const n=t[e];P(n)&&(t[e]=R(n))}),t},L=e=>{const t=m(A,e);return Object.keys(t).forEach(e=>{const n=t[e];P(n)&&(t[e]=L(n))}),t},N=e=>{if(_(e))return L(e)},x=(e,t)=>"boolean"==typeof e?e:t,M=e=>(Object.getOwnPropertyNames(e).forEach(function(t){e[t]&&"object"==typeof e[t]&&M(e[t])}),Object.freeze(e)),U=e=>e.replace(/^\.+/,""),B=e=>{let t=e;if(!E(e)&&!I(e))try{t=JSON.stringify(e)}catch(e){t=null}return t},j=e=>(e=>{const t=Array.from(e,e=>String.fromCodePoint(e)).join("");return globalThis.btoa(t)})((new TextEncoder).encode(e)),G=(e,t,n,r,i)=>{const s={category:e,name:t,properties:n,options:r,callback:void 0};b(i)&&(s.callback=i),b(r)&&(s.category=e,s.name=t,s.properties=n,s.options=void 0,s.callback=r),b(n)&&(s.category=e,s.name=t,s.properties=void 0,s.options=void 0,s.callback=n),b(t)&&(s.category=e,s.name=void 0,s.properties=void 0,s.options=void 0,s.callback=t),b(e)&&(s.category=void 0,s.name=void 0,s.properties=void 0,s.options=void 0,s.callback=e),P(e)?(s.name=void 0,s.category=void 0,s.properties=e,b(t)?s.options=void 0:s.options=t):P(t)&&(s.name=void 0,s.properties=t,b(n)?s.options=void 0:s.options=n),E(e)&&!E(t)&&(s.category=void 0,s.name=e),T(s.category)||(s.category=void 0),T(s.name)||(s.name=void 0),s.properties=s.properties?g(s.properties):{},T(s.options)?s.options=g(s.options):s.options=void 0;const o=E(s.name)?s.name:s.properties.name,a=E(s.category)?s.category:s.properties.category;return s.properties=D(P(s.properties)?s.properties:{},{...o&&{name:o},...a&&{category:a}}),s},H=(e,t,n,r)=>{const i={name:e,properties:t,options:n,callback:void 0};return b(r)&&(i.callback=r),b(n)&&(i.properties=t,i.options=void 0,i.callback=n),b(t)&&(i.properties=void 0,i.options=void 0,i.callback=t),i.properties=A(i.properties)?g(i.properties):{},T(i.options)?i.options=g(i.options):i.options=void 0,i},F=(e,t,n,r)=>{const i={userId:e,traits:t,options:n,callback:void 0};return b(r)&&(i.callback=r),b(n)&&(i.userId=e,i.traits=t,i.options=void 0,i.callback=n),b(t)&&(i.userId=e,i.traits=void 0,i.options=void 0,i.callback=t),(P(e)||S(e))&&(i.userId=null,i.traits=e,b(t)?i.options=void 0:i.options=t),i.userId=B(i.userId),P(i.traits)?i.traits=g(i.traits):i.traits=void 0,T(i.options)?i.options=g(i.options):i.options=void 0,i},K=(e,t,n,r)=>{const i={to:e,from:t,options:n,callback:void 0};return b(r)&&(i.callback=r),b(n)&&(i.to=e,i.from=t,i.options=void 0,i.callback=n),b(t)?(i.to=e,i.from=void 0,i.options=void 0,i.callback=t):(P(t)||S(t))&&(i.to=e,i.from=void 0,i.options=t),T(i.to)&&(i.to=B(i.to)),T(i.from)?i.from=B(i.from):i.from=void 0,T(i.options)?i.options=g(i.options):i.options=void 0,i},V=(e,t,n,r)=>{const i={groupId:e,traits:t,options:n,callback:void 0};return b(r)&&(i.callback=r),b(n)&&(i.groupId=e,i.traits=t,i.options=void 0,i.callback=n),b(t)&&(i.groupId=e,i.traits=void 0,i.options=void 0,i.callback=t),(P(e)||S(e))&&(i.groupId=null,i.traits=e,b(t)?i.options=void 0:i.options=t),i.groupId=B(i.groupId),P(i.traits)?i.traits=g(i.traits):i.traits=void 0,T(i.options)?i.options=g(i.options):i.options=void 0,i};let W=function(e){return e.UNLOADED="Page Unloaded",e}({});const Q="API",z="CapabilitiesManager",q="ConfigManager",J="EventManager",X="PluginsManager",Z="UserSessionManager",Y="ErrorHandler",ee="PluginEngine",te=`Ready${Q}`,ne=`Load${Q}`,re="AnalyticsCore";for(var ie,se=[],oe=0;oe<256;oe++)se[oe]=(oe+256).toString(16).substring(1);function ae(){var e;(!ie||oe+16>4096)&&(e=4096,ie=crypto.getRandomValues(new Uint8Array(e)),oe=0);for(var t,n=0,r="";n<16;n++)t=ie[oe+n],r+=6==n?se[15&t|64]:8==n?se[63&t|128]:se[t],1&n&&n>1&&n<11&&(r+="-");return oe+=16,r}for(var le,ue=256,ce=[];ue--;)ce[ue]=(ue+256).toString(16).substring(1);const de=()=>!I(globalThis.crypto)&&b(globalThis.crypto.getRandomValues)?ae():function(){var e,t=0,n="";if(!le||ue+16>256){for(le=Array(t=256);t--;)le[t]=256*Math.random()|0;t=ue=0}for(;t<16;t++)e=le[ue+t],n+=6==t?ce[15&e|64]:8==t?ce[63&e|128]:ce[e],1&t&&t>1&&t<11&&(n+="-");return ue++,n}(),ge=(e,t=!1)=>{let n=!1,r=!1;function i(){n||(n=!0,e(r),setTimeout(()=>{n=!1},0))}(t||E(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent))&&globalThis.addEventListener("beforeunload",()=>{r=!1,i()}),globalThis.addEventListener("blur",()=>{r=!0,i()}),globalThis.addEventListener("focus",()=>{n=!1}),document.addEventListener("pagehide",()=>{r="hidden"===document.visibilityState,i()}),document.addEventListener("visibilitychange",()=>{r=!0,"hidden"===document.visibilityState?i():n=!1})},he=e=>
1e.toISOString(),pe=":: ",fe=(e,t,n)=>`Unable to load (${E(n)?n:n.type}) the script with the id "${e}" from URL "${t}"`,ve=(e,t)=>`${e}${pe}A bad data (like circular reference, BigInt) has been detected in the object and the property "${t}" has been dropped from the output.`,ye="JSON",me="[Circular Reference]",be=(e,t,n)=>{const r=[];return function(i,s){if(!(t?.includes(i)||e&&I(s))){if("object"!=typeof s||S(s))return s;for(;r.length>0&&r[r.length-1]!==this;)r.pop();return r.includes(s)?(n?.warn(((e,t)=>`${e}${pe}A circular reference has been detected in the object and the property "${t}" has been dropped from the output.`)("JSONStringify",i)),me):(r.push(s),s)}}},Ee=(e,t,n,r)=>{try{return JSON.stringify(e,be(t,n,r))}catch(e){return r?.warn("Failed to convert the value to a JSON string.",e),null}},Se=e=>{const t=[];return function(n,r){if((e=>"bigint"==typeof e)(r))return e?.warn(ve(ye,n)),"[BigInt]";for(;t.length>0&&t[t.length-1]!==this;)t.pop();return t.includes(r)?(e?.warn(ve(ye,n)),me):(t.push(r),r)}},ke=(e,t)=>{const n=Array.isArray(e)?[]:{};for(const r in e)if(Object.hasOwnProperty.call(e,r)){const i=e[r],s=t.call(e,r,i);P(s)||Array.isArray(s)?n[r]=ke(s,t):n[r]=s}return n},Ie=(e,t)=>{const n=Se(t),r=n.call(e,"",e);return P(e)||Array.isArray(e)?ke(e,n):r},Te="[SDK DISPATCHED ERROR]",Ae=e=>{const{stack:t}=e;if("string"==typeof t&&t)return t},we=(e,t)=>{if(!w(e))return new Error(`${t}: ${Ee(e)}`);try{const n=new(0,e.constructor)(`${t}: ${e.message}`),r=Ae(e);return r&&(n.stack=r),Object.getOwnPropertyNames(e).forEach(t=>{if("message"!==t&&"stack"!==t&&"name"!==t)try{n[t]=e[t]}catch{}}),n}catch{return new Error(`${t}: ${Ee(e)}`)}},Ce=e=>{if(w(e)){const t=Ae(e);t&&(e.stack=`${t}\n${Te}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:e,bubbles:!0,cancelable:!0,composed:!0}))},Pe="RudderLabs JavaScript SDK",Oe="3.32.0",De="RudderJS-Initiated",_e="preloadedEventsBuffer",$e="ajs_aid",Re="ajs_event",Le=432e5,Ne=18e5,xe=(e="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[e]||(globalThis.RudderStackGlobals[e]={})},Me=(e,t,n="app")=>{xe(n),globalThis.RudderStackGlobals[n][e]=t},Ue=(e,t="app")=>(xe(t),globalThis.RudderStackGlobals[t][e]);const Be=(e,t)=>{const n={};return e.forEach((r,i)=>{if(i.startsWith(t)){const r=i.substring(t.length);n[r]=e.get(i)}}),n},je=e=>{const t=Ue(_e)||[];((e=[])=>{const t="ajs_trait_",n="ajs_prop_",r=new URLSearchParams(globalThis.location.search);r.get(Re)&&e.unshift(["track",r.get(Re),Be(r,n)]);const i=r.get("ajs_uid"),s=Be(r,t);if(i||_(s)){const t=[...i?[i]:[],s];e.unshift(["identify",...t])}r.get($e)&&e.unshift(["setAnonymousId",r.get($e)])})(t),t.length>0&&(e.enqueuePreloadBufferEvents(t),Me(_e,[]))},Ge=(e,t)=>{const n=e.shift();let r;if(b(t[n])){switch(n){case"page":r=G(...e);break;case"track":r=H(...e);break;case"identify":r=F(...e);break;case"alias":r=K(...e);break;case"group":r=V(...e);break;default:t[n](...e)}r&&t[n](r)}},He=(e,t,n,r=!0,i)=>new Promise((s,o)=>{document.getElementById(t)&&o(new Error((e=>`A script with the id "${e}" is already loaded. Skipping the loading of this script to prevent conflicts`)(t)));try{let a;(e=>{const t=document.getElementsByTagName("head");if(t.length>0)return void t[0]?.insertBefore(e,t[0]?.firstChild);const n=document.getElementsByTagName("script");if(n.length>0&&n[0]?.parentNode)return void n[0]?.parentNode.insertBefore(e,n[0]);const r=document.createElement("head");r.appendChild(e);const i=document.getElementsByTagName("html")[0];i?.insertBefore(r,i.firstChild)})(((e,t,n=!0,r=null,i=null,s={})=>{const o=document.createElement("script");return o.type="text/javascript",o.onload=r,o.onerror=i,o.src=e,o.id=t,o.async=n,Object.keys(s).forEach(e=>{o.setAttribute(e,s[e])}),o.setAttribute("data-loader","RS_JS_SDK"),o})(e,t,r,()=>{globalThis.clearTimeout(a),s(t)},n=>{globalThis.clearTimeout(a),o(new Error(fe(t,e,n)))},i)),a=globalThis.setTimeout(()=>{o(new Error(((e,t,n)=>`A timeout of ${n} ms occurred while trying to load the script with id "${e}" from URL "${t}"`)(t,e,n)))},n)}catch(n){o(we(n,fe(t,e,"unknown")))}});class Fe{constructor(e,t=1e4){this.logger=e,this.timeout=t}loadJSFile(e){const{url:t,id:n,timeout:r,async:i,callback:s,extraAttributes:o}=e,a=!b(s);He(t,n,r||this.timeout,i,o).then(e=>{a||s(e)}).catch(e=>{a||s(n,e)})}}var Ke=Symbol.for("preact-signals");
1function Ve(){if(Xe>1)Xe--;else{var e,t=!1;for(!function(){var e=tt;for(tt=void 0;void 0!==e;){var t=e.S;if(t.v===e.v)for(var n=t.t;void 0!==n;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}}();void 0!==Je;){var n=Je;for(Je=void 0,Ze++;void 0!==n;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ot(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(Ze=0,Xe--,t)throw e}}function We(e){if(Xe>0)return e();et=++Ye,Xe++;try{return e()}finally{Ve()}}var Qe,ze=void 0;function qe(e){var t=ze,n=Qe;ze=void 0,Qe=void 0;try{return e()}finally{ze=t,Qe=n}}var Je=void 0,Xe=0,Ze=0,Ye=0,et=0,tt=void 0,nt=0;function rt(e){if(void 0!==ze){var t=e.n;if(void 0===t||t.t!==ze)return t={i:0,S:e,p:ze.s,n:void 0,t:ze,e:void 0,x:void 0,r:t},void 0!==ze.s&&(ze.s.n=t),ze.s=t,e.n=t,32&ze.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=ze.s,t.n=void 0,ze.s.n=t,ze.s=t),t}}function it(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=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 st(e,t){return new it(e,t)}function ot(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 at(e){for(var t=e.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function lt(e){for(var t=e.s,n=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)):n=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=r}e.s=n}function ut(e,t){it.call(this,void 0,t),this.x=e,this.s=void 0,this.g=nt-1,this.f=4}function ct(e){var t=e.m;if(e.m=void 0,"function"==typeof t){Xe++;var n=ze;ze=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,dt(e),t}finally{ze=n,Ve()}}}function dt(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ct(e)}function gt(e){if(ze!==this)throw new Error("Out-of-order effect");lt(this),ze=e,this.f&=-2,8&this.f&&dt(this),Ve()}function ht(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==t?void 0:t.name,Qe&&Qe.push(this)}function pt(e,t){var n=new ht(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}it.prototype.brand=Ke,it.prototype.h=function(){return!0},it.prototype.S=function(e){var t=this,n=this.t;n!==e&&void 0===e.e&&(e.x=n,this.t=e,void 0!==n?n.e=e:qe(function(){var e;null==(e=t.W)||e.call(t)}))},it.prototype.U=function(e){var t=this;if(void 0!==this.t){var n=e.e,r=e.x;void 0!==n&&(n.x=r,e.e=void 0),void 0!==r&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&qe(function(){var e;null==(e=t.Z)||e.call(t)}))}},it.prototype.subscribe=function(e){var t=this;return pt(function(){var n=t.value;qe(function(){return e(n)})},{name:"sub"})},it.prototype.valueOf=function(){return this.value},it.prototype.toString=function(){return this.value+""},it.prototype.toJSON=function(){return this.value},it.prototype.peek=function(){var e=this;return qe(function(){return e.value})},Object.defineProperty(it.prototype,"value",{get:function(){var e=rt(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ze>100)throw new Error("Cycle detected");!function(e){0!==Xe&&0===Ze&&e.l!==et&&(e.l=et,tt={S:e,v:e.v,i:e.i,o:tt})}(this),this.v=e,this.i++,nt++,Xe++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{Ve()}}}}),ut.prototype=new it,ut.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===nt)return!0;if(this.g=nt,this.f|=1,this.i>0&&!ot(this))return this.f&=-2,!0;var e=ze;try{at(this),ze=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 ze=e,lt(this),this.f&=-2,!0},ut.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)}it.prototype.S.call(this,e)},ut.prototype.U=function(e){if(void 0!==this.t&&(it.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)}},ut.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(ut.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=rt(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),ht.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.m=t)}finally{e()}},ht.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ct(this),at(this),Xe++;var e=ze;return ze=this,gt.bind(this,e)},ht.prototype.N=function(){2&this.f||(this.f|=2,this.u=Je,Je=this)},ht.prototype.d=function(){this.f|=8,1&this.f||dt(this)},ht.prototype.dispose=function(){this.d()};class ft{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=[]}}const vt={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},yt="ERROR";const mt=new class{constructor(e="LOG",t="",n=console){this.minLogLevel=vt[e],this.scope=t,this.logProvider=n}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<=vt[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=vt[e],k(this.minLogLevel)&&(this.minLogLevel=vt.LOG)}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t="%c RS SDK";this.scope&&(t=`${t} - ${this.scope}`);t=`${t} %c ${E(e[0])?e[0].trim():""}`;const n=[t,"font-weight: bold; background: black; color: white;","font-weight: normal;"];return E(e[0])||n.push(e[0]),n.push(...e.slice(1)),n}return e}};let bt=function(e){return e.HANDLEDEXCEPTION="handledException",e.UNHANDLEDEXCEPTION="unhandledException",e.UNHANDLEDREJECTION="unhandledPromiseRejection",e}({});const Et=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],St="cookieStorage",kt="Unable to process/parse source configuration response",It="Failed to log breadcrumb",Tt="Failed to fetch the source config",At=e=>`${e}${pe}
1The provided callback parameter is not a function.`,wt=(e,t,n)=>`${e} due to timeout or no connection (${t?t.type:""}) at the client side for URL: ${n}`,Ct="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",Pt=e=>`${e}${pe}Invalid custom context. Use a plain object without prototype pollution keys.`,Ot={All:!0},Dt="js-integrations",_t="plugins",$t=new 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_]*)?$"),Rt="modern",Lt="https://cdn.rudderlabs.com",Nt="v3",xt=`${Lt}/${Nt}/${Rt}/${Dt}`,Mt=`${Lt}/${Nt}/${Rt}/${_t}`,Ut="https://api.rudderstack.com",Bt="v3",jt="xhr",Gt={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Ht={[Bt]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},Ft={[jt]:"XhrQueue",beacon:"BeaconQueue"},Kt=st(g({configUrl:Ut,loadIntegration:!0,sessions:{autoTrack:!0,timeout:Ne,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:Ot,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:1e4,storage:{encryption:{version:Bt},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1})),Vt=M({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),Wt=M({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Qt={userId:st(Vt.userId),userTraits:st(Vt.userTraits),anonymousId:st(Vt.anonymousId),groupId:st(Vt.groupId),groupTraits:st(Vt.groupTraits),initialReferrer:st(Vt.initialReferrer),initialReferringDomain:st(Vt.initialReferringDomain),sessionInfo:st(Vt.sessionInfo),authToken:st(Vt.authToken)},zt={isOnline:st(!0),storage:{isLocalStorageAvailable:st(!1),isCookieStorageAvailable:st(!1),isSessionStorageAvailable:st(!1)},isBeaconAvailable:st(!1),isLegacyDOM:st(!1),isUaCHAvailable:st(!1),isCryptoAvailable:st(!1),isAdBlockerDetectionInProgress:st(!1),isAdBlocked:st(void 0),cspBlockedURLs:st([])},qt={isErrorReportingEnabled:st(!1),isMetricsReportingEnabled:st(!1),breadcrumbs:st([])},Jt=st(void 0),Xt={activeDataplaneUrl:st(void 0),integrationsCDNPath:st(xt),pluginsCDNPath:st(Mt),sourceConfigUrl:st(void 0),status:st(void 0),initialized:st(!1),logLevel:st(yt),loaded:st(!1),readyCallbacks:st([]),writeKey:st(void 0),dataPlaneUrl:st(void 0),safeAnalyticsInstance:st(void 0)},Zt={enabled:st(!1),initialized:st(!1),data:st({}),activeConsentManagerPluginName:st(void 0),preConsent:st({enabled:!1}),postConsent:st({}),resolutionStrategy:st("and"),provider:st(void 0),metadata:st(void 0)},Yt={retries:st(0),dropped:st(0),sent:st(0),queued:st(0),triggered:st(0),metricsServiceUrl:st(void 0)},en={app:st({name:Pe,namespace:"com.rudderlabs.javascript",version:Oe,installType:"npm"}),traits:st(null),library:st({name:Pe,version:Oe,snippetVersion:globalThis.RudderSnippetVersion,variant:"modern"}),userAgent:st(null),device:st(null),network:st(null),os:st({name:"",version:""}),locale:st(null),screen:st({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":st(void 0),timezone:st(void 0)},tn=st({}),nn={configuredDestinations:st([]),activeDestinations:st([]),loadOnlyIntegrations:st({}),failedDestinations:st([]),loadIntegration:st(!0),initializedDestinations:st([]),clientDestinationsReady:st(!1),integrationsConfig:st({})},rn={toBeProcessedArray:st([]),readyCallbacksArray:st([])},sn={ready:st(!1),loadedPlugins:st([]),failedPlugins:st([]),pluginsToLoadFromConfig:st([]),activePlugins:st([]),totalPluginsToLoad:st(0)},on={encryptionPluginName:st(void 0),migrate:st(!1),type:st(void 0),cookie:st(void 0),entries:st({}),trulyAnonymousTracking:st(!1)},an={isEnabledServerSideCookies:st(!1),dataServiceUrl:st(void 0)},ln={eventsQueuePluginName:st(void 0),deliveryEnabled:st(!0)},un={enabled:st(!1),pageLifecycle:{enabled:st(!1),pageViewId:st(void 0),pageLoadedTimestamp:st(void 0)}},cn={...g({capabilities:zt,consents:Zt,context:en,customContext:tn,eventBuffer:rn,lifecycle:Xt,loadOptions:Kt,metrics:Yt,nativeDestinations:nn,plugins:sn,reporting:qt,session:Qt,source:Jt,storage:on,serverCookies:an,dataPlaneEvents:ln,autoTrack:un})},dn=/^\s*at /,gn=/^(eval@)?(\[native code])?$/,hn=/(.+?)(?::(\d+))?(?::(\d+))?$/;function pn(e){if(!e?.includes(":"))return[e||void 0,void 0,void 0];const t=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,n=hn.exec(t);return n?[n[1]||void 0,void 0===n[2]?void 0:Number(n[2]),void 0===n[3]?void 0:Number(n[3])]:[void 0,void 0,void 0]}function fn(e){if(!dn.test(e))return null;e.includes("(eval ")&&(e=e.replaceAll("eval code","eval").replaceAll(/(\(eval at [^()]*)|(,.*$)/g,""));const t=e.replace(/^\s+/,"").replaceAll("(eval code","(").replace(/^.*?\s+/,""),n=/ (\(.+\)$)/.exec(t),r=n?t.replace(n[0],""):t,[i,s,o]=pn(n?n[1]:t);return{functionName:n&&r||void 0,fileName:"eval"===i||"<anonymous>"===i?void 0:i,lineNumber:s,columnNumber:o}}function vn(e){if(gn.test(e))return null;if(e.includes(" > eval")&&(e=e.replaceAll(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),!e.includes("@")&&!e.includes(":"))return{functionName:e,fileName:void 0,lineNumber:void 0,columnNumber:void 0};const t=e.lastIndexOf("@"),n=t>
10?e.slice(0,t):void 0,[r,i,s]=pn(e.slice(t+1));return{functionName:n,fileName:r,lineNumber:i,columnNumber:s}}const yn="global code",mn=e=>E(e)?e:"";function bn(e,t,n,r){return{errorClass:mn(e),message:`${n}${mn(t)}`,type:"browserjs",stacktrace:r.reduce((e,t)=>{const n=(e=>{const t={file:e.fileName,method:(n=e.functionName,T(n)&&/^global code$/i.test(n)?yn:n),lineNumber:e.lineNumber,columnNumber:e.columnNumber};var n;return t.lineNumber&&t.lineNumber>-1&&!t.file&&!t.method&&(t.file=yn),t})(t);try{return"{}"===JSON.stringify(n)?e:e.concat(n)}catch{return e}},[])}}const En=(e,t)=>{let n;var r,i;return w(e)&&E(Ae(e))?n=e:(t.warn((r=Y,i=Ee(e),`${r}${pe}Ignoring a non-error: ${i}.`)),n=void 0),n},Sn=(e,t)=>{try{const n=function(e){if(!e.stack)throw new Error("Cannot parse given Error object");const t=e.stack.split("\n");return t.some(e=>dn.test(e))?t.map(fn).filter(e=>null!==e):t.map(vn).filter(e=>null!==e)}(e);return bn(e.name,e.message,t,n)}catch{return bn(e.name,e.message,t,[])}},kn=(e,t)=>{try{return JSON.parse(e||"")}catch(e){t(we(e,"Failed to parse response data"))}},In="The request failed",Tn=[new RegExp(`${In}.*`),/A script with the id .* is already loaded\./],An=[/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 .*/],wn={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Cn=(e,t,n)=>{const r=D(wn,t||{});return n&&(r.headers=D(r.headers,{Authorization:n})),r.url=e,r},Pn=(e,t=1e4,n)=>new Promise((r,i)=>{let s;if(!0===e.sendRawData)s=e.data;else if(s=Ee(e.data,!1,[],n),S(s))return void i({error:new Error("Failed to prepare data for the request."),undefined:void 0,options:e});const o=new XMLHttpRequest,a=t=>{i({error:new Error(wt(In,t,e.url)),xhr:o,options:e,..."timeout"===t?.type?{timedOut:!0}:{}})};o.ontimeout=a,o.onerror=a,o.onload=()=>{var t,n,s,a,l;o.status>=200&&o.status<400?r({response:o.responseText,xhr:o,options:e}):i({error:new Error((t=In,n=o.status,s=o.statusText,a=e.url,l=o.responseText,`${t} with status ${n} (${s}) for URL: ${a}. Response: ${l.trim()}`)),xhr:o,options:e})},o.open(e.method,e.url,!0),!0===e.withCredentials&&(o.withCredentials=!0),o.timeout=t,Object.keys(e.headers).forEach(t=>{e.headers[t]&&o.setRequestHeader(t,e.headers[t])});try{o.send(s)}catch(t){i({error:we(t,(l=In,u=e.url,`${l} for URL: ${u}`)),xhr:o,options:e})}var l,u});const On=new class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){const{url:t,options:n,timeout:r,isRawResponse:i}=e;try{const e=await Pn(Cn(t,n,this.basicAuthHeader),r,this.logger);return{data:i?e.response:kn(e.response,this.onError),details:e}}catch(e){return{data:void 0,details:e}}}getAsyncData(e){const{callback:t,url:n,options:r,timeout:i,isRawResponse:s}=e,o=!b(t);Pn(Cn(n,r,this.basicAuthHeader),i,this.logger).then(e=>{o||t(s?e.response:kn(e.response,this.onError),e)}).catch(e=>{o||t(void 0,e)})}onError(e,t){this.errorHandler?.onError({error:e,context:"HttpClient",groupingHash:t})}setAuthHeader(e,t=!1){const n=t?e:j(`${e}:`);this.basicAuthHeader=`Basic ${n}`}resetAuthHeader(){this.basicAuthHeader=void 0}}(mt),Dn=["www.test-host.com","localhost","127.0.0.1","[::1]"],_n=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","customContext","traits","authToken"],$n=e=>{cn.capabilities.isAdBlockerDetectionInProgress.value=!0;try{const t=new URL(cn.lifecycle.sourceConfigUrl.value),n=`${t.origin}${t.pathname}?view=ad`;e.getAsyncData({url:n,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(e,t)=>{cn.capabilities.isAdBlockerDetectionInProgress.value=!1,cn.capabilities.isAdBlocked.value=void 0!==t?.error||t?.xhr?.responseURL!==n}})}catch(e){throw cn.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},Rn=(e=()=>window.location.hostname)=>{const t=e();return!t||t&&Dn.includes(t)?"development":"production"},Ln=e=>{const t=Ee(e,!1,_n);return null!==t?JSON.parse(t):{}},Nn=(e,t,n,r)=>({id:`${e.value?.id??n.writeKey.value}..${t.sessionInfo.value.id??"NA"}..${r.pageLifecycle.pageViewId.value??"NA"}`,name:e.value?.name??"NA"}),xn=(e,t)=>({locale:e.value??"NA",userAgent:t.value??"NA",time:new Date}),Mn=(e,t,n)=>{const r=e.message;return new Promise(e=>{if(An.some(e=>e.test(r))){const i=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(r)?.[0];E(i)?i.startsWith(Lt)?t.capabilities.cspBlockedURLs.value.includes(i)?e(!1):((e,t,n)=>{if(k(e.capabilities.isAdBlocked.value)){!1===e.capabilities.isAdBlockerDetectionInProgress.value&&$n(t);const r=pt(()=>{T(e.capabilities.isAdBlocked.value)&&(n(!1===e.capabilities.isAdBlocked.value),r())})}else n(!1===e.capabilities.isAdBlocked.value)})(t,n,e):e(!1):e(!0)}else e(!Tn.some(e=>e.test(r)))})},Un=e=>{if(!e)return;return e.split("/").at(-2)},Bn=e=>{const t=e.stacktrace[0]?.file;if(t&&"string"==typeof t)return t},jn=(e,t,n)=>{const r={version:"1",message_id:de(),source:{name:"js",sdk_version:t.context.app.value.version,write_key:t.lifecycle.writeKey.value,install_type:t.context.app.value.installType,category:n},errors:e};return Ee(r)};const Gn=new class{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:Y,errorType:bt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Y,errorType:bt.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{const t=E(e.blockedURI)?e.blockedURI:"";"enforce"===e.disposition&&t.startsWith(Lt)&&!cn.capabilities.cspBlockedURLs.value.includes(t)&&(cn.capabilities.cspBlockedURLs.value=[...cn.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{const{error:t,context:n,customMessage:r,groupingHash:i,category:s}=e,o=e.errorType??bt.HANDLEDEXCEPTION,a=((e,t)=>{switch(t){case bt.UNHANDLEDEXCEPTION:{const{error:t}=e;return t||e}case bt.UNHANDLEDREJECTION:return e.reason;case bt.HANDLEDEXCEPTION:default:return e}})(t,o),l=En(a,this.logger);if(k(l))return;const u=r?`${r} - `:"",c=Sn(l,`${n}${pe}${u}`),d=Ae(l).includes(Te);if(!d&&!(e=>{const t=Bn(e);if(!t)return!1;const n=t.substring(t.lastIndexOf("/")+1);return Un(t)===Dt||["rsa"].some(e=>n.startsWith(e)&&n.endsWith(".js"))})(c)&&o!==bt.HANDLEDEXCEPTION)return;if(cn.reporting.isErrorReportingEnabled.value){if(await Mn(c,cn,this.httpClient)){const e={severity:"error",unhandled:o!==bt.HANDLEDEXCEPTION,severityReason:{type:o}},t=((e,t,n)=>{let r;if(T(e))if(E(e))r=e;else{const i=En(e,n);r=T(i)?i.message:t}else r=t;return r})(i,c.message,this.logger),n=((e,t,n,r)=>{const{context:i,lifecycle:s,session:o,source:a,reporting:l,autoTrack:u}=n,{app:c,locale:d,userAgent:h,timezone:p,screen:f,library:v}=i;return{payloadVersion:"5",notifier:{name:"RudderStack JavaScript SDK",version:c.value.version,url:"git+https://github.com/rudderlabs/rudder-sdk-js.git"},events:[{exceptions:[g(e)],severity:t.severity,unhandled:t.unhandled,severityReason:t.severityReason,app:{version:c.value.version,releaseStage:Rn(),type:c.value.installType},device:xn(d,h),request:{url:globalThis.location.href.split("?")[0],clientIp:"[NOT COLLECTED]"}
1,breadcrumbs:g(l.breadcrumbs.value),context:e.message,groupingHash:r,metaData:{app:{snippetVersion:v.value.snippetVersion},device:{...f.value,timezone:p.value},...Ln(n)},user:Nn(a,o,s,u)}]}})(c,e,cn,t),r=((e,t)=>{if(t)return t;const n=Bn(e);return Un(n)===Dt?"integrations":"sdk"})(c,s);this.httpClient.getAsyncData({url:cn.metrics.metricsServiceUrl.value,options:{method:"POST",data:jn(n,cn,r),sendRawData:!0},isRawResponse:!0})}}(o===bt.HANDLEDEXCEPTION||d)&&this.logger.error(c.message)}catch(e){this.logger.error(`${Y}${pe}Failed to handle the error.`,e)}}leaveBreadcrumb(e){try{cn.reporting.breadcrumbs.value=[...cn.reporting.breadcrumbs.value,(t=e,{type:"manual",name:t,timestamp:new Date,metaData:{}})]}catch(e){this.onError({error:e,context:Y,customMessage:It,groupingHash:It})}var t}}(On,mt);const Hn=new class{plugins=[];byName={};cache={};config={throws:!0};constructor(e,t={}){this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){const t=`${ee}${pe}Plugin name is missing.`;if(this.config.throws)throw new Error(t);return void this.logger.error(t,e)}if(this.byName[e.name]){const t=((e,t)=>`${e}${pe}Plugin "${t}" already exists.`)(ee,e.name);if(this.config.throws)throw new Error(t);return void this.logger.error(t)}this.cache={},this.plugins=this.plugins.slice();let n=this.plugins.length;this.plugins.forEach((t,r)=>{t.deps?.includes(e.name)&&(n=Math.min(n,r))}),this.plugins.splice(n,0,e),this.byName[e.name]=e,b(e.initialize)&&e.initialize(t)}unregister(e){const t=this.byName[e];if(!t){const t=`${ee}${pe}Plugin "${e}" not found.`;if(this.config.throws)throw new Error(t);return void this.logger.error(t)}const n=this.plugins.indexOf(t);if(-1===n){const t=((e,t)=>`${e}${pe}Plugin "${t}" not found in plugins but found in byName. This indicates a bug in the plugin engine. Please report this issue to the development team.`)(ee,e);if(this.config.throws)throw new Error(t);return void this.logger.error(t)}this.cache={},delete this.byName[e],this.plugins=this.plugins.slice(),this.plugins.splice(n,1)}getPlugin(e){return this.byName[e]}getPlugins(e){const t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(e=>{if(e.deps?.some(e=>!this.byName[e])){const t=e.deps.filter(e=>!this.byName[e]);return this.logger.error(((e,t,n)=>`${e}${pe}Plugin "${t}" could not be loaded because some of its dependencies "${n}" do not exist.`)(ee,e.name,t)),!1}return"."===t||((e,t)=>Boolean(C(e,t)))(e,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...n){let r=e;if(!r)throw new Error("Failed to invoke plugin because the extension point name is missing.");const i=r.startsWith("!"),s=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error("Failed to invoke plugin because the extension point name is invalid.");const o=r.split(".");o.pop();const a=o.join(".");return(t?this.getPlugins(r):[this.getPlugins(r)[0]]).map(e=>{const t=C(e,r);if(!b(t)||i)return t;try{return t.apply(C(e,a),n)}catch(t){if(s)throw t;this.logger.error(((e,t,n)=>`${e}${pe}Failed to invoke the "${t}" extension point of plugin "${n}".`)(ee,r,e.name),t)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}}(mt,{throws:!0}),Fn=e=>Boolean("cloud"!==e.config.connectionMode||!0===e.config.useNativeSDKToSend||!0===e.config.useNativeSDK),Kn=e=>e.filter(Fn),Vn=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],Wn=["Bugsnag","ErrorReporting"],Qn={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"}};function zn(e,t){const n=Object.assign(e,t);for(const e of Object.keys(n))"object"==typeof n[e]&&"object"==typeof t[e]&&(n[e]=zn(n[e],t[e]));return n}const qn=e=>zn({},(globalThis.__federation_shared__||{}).default||{});function Jn(e,t){if(!e?.default&&t){let t=Object.create(null);return t.default=e,t.__esModule=!0,t}return e}function Xn(e,t){return async function(e){const t=Qn[e];return t.inited?t.lib:["esm","systemjs"].includes(t.format)?new Promise((e,n
1)=>{("function"==typeof t.url?t.url:()=>Promise.resolve(t.url))().then(r=>{import(r).then(n=>{if(!t.inited){const e=qn();n.init(e),t.lib=n,t.lib.init(e),t.inited=!0}e(t.lib)}).catch(n)})}):void 0}(e).then(e=>e.get(t).then(e=>e()))}const Zn=e=>{const t={};return e.forEach(e=>{if(Vn.includes(e)){const n=(e=>{switch(e){case"BeaconQueue":return()=>Xn("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>Jn(e,!0));case"CustomConsentManager":return()=>Xn("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>Jn(e,!0));case"DeviceModeDestinations":return()=>Xn("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>Jn(e,!0));case"DeviceModeTransformation":return()=>Xn("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>Jn(e,!0));case"ExternalAnonymousId":return()=>Xn("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>Jn(e,!0));case"GoogleLinker":return()=>Xn("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>Jn(e,!0));case"KetchConsentManager":return()=>Xn("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>Jn(e,!0));case"IubendaConsentManager":return()=>Xn("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>Jn(e,!0));case"NativeDestinationQueue":return()=>Xn("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>Jn(e,!0));case"OneTrustConsentManager":return()=>Xn("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>Jn(e,!0));case"StorageEncryption":return()=>Xn("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>Jn(e,!0));case"StorageEncryptionLegacy":return()=>Xn("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>Jn(e,!0));case"StorageMigrator":return()=>Xn("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>Jn(e,!0));case"XhrQueue":return()=>Xn("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>Jn(e,!0));default:return}})(e);n&&(t[e]=n)}}),t},Yn=e=>Zn?.(e)||{},er={};class tr{constructor(e,t,n){this.engine=e,this.errorHandler=t,this.logger=n,this.onError=this.onError.bind(this)}init(){cn.lifecycle.status.value="pluginsLoading",Me("pluginsCDNPath",cn.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){pt(()=>{(0===cn.plugins.activePlugins.value.length||cn.plugins.loadedPlugins.value.length+cn.plugins.failedPlugins.value.length===cn.plugins.totalPluginsToLoad.value)&&We(()=>{cn.plugins.ready.value=!0,cn.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=cn.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(e=>!Wn.includes(e)||(this.logger.warn(((e,t)=>`${e}${pe}${t} plugin is deprecated. Please exclude it from the load API options.`)(X,e)),!1));const t=[{configurationStatus:()=>T(cn.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:cn.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(Ft),shouldAddMissingPlugins:!0},{configurationStatus:()=>Kn(cn.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Kn(cn.nativeDestinations.configuredDestinations.value).some(e=>e.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>T(cn.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:cn.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Gt)},{configurationStatus:()=>T(cn.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:cn.storage.encryptionPluginName.value,supportedPlugins:Object.values(Ht)},{configurationStatus:()=>cn.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}];return t.forEach(t=>{t.configurationStatus()?(e=e.filter(t.activePluginName?e=>!(e!==t.activePluginName&&t.supportedPlugins.includes(e)):e=>T(e)),this.addMissingPlugins(t,false,e)):e=e.filter(void 0!==t.basePlugins?e=>!(t.basePlugins.includes(e)||t.supportedPlugins.includes(e)):e=>!t.supportedPlugins.includes(e))}),[...Object.keys({}),...e]}addMissingPlugins(e,t,n){const r=e.shouldAddMissingPlugins||t;let i;i=e.activePluginName?[...e.basePlugins||[],e.activePluginName]:[...e.supp
1ortedPlugins];const s=i.filter(e=>!n.includes(e));s.length>0&&(r&&n.push(...s),this.logger.warn(((e,t,n,r)=>{const i=1===n.length,s=i?` '${n[0]}' plugin was`:` ['${n.join("', '")}'] plugins were`,o=`${e}${pe}${t}, but${s} not configured to load.`;return r?`${o} So, ${i?"the plugin":"those plugins"} will be loaded automatically.`:`${o} Ignore if this was intentional. Otherwise, consider adding ${i?"it":"them"} to the 'plugins' load API option.`})(X,e.configurationStatusStr,s,r)))}setActivePlugins(){const e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(er),...Vn],n=[],r=[];e.forEach(e=>{t.includes(e)?n.push(e):r.push(e)}),r.length>0&&this.logger.warn(`${X}${pe}Ignoring unknown plugins: ${r.join(", ")}.`),We(()=>{cn.plugins.totalPluginsToLoad.value=e.length,cn.plugins.activePlugins.value=n,cn.plugins.failedPlugins.value=r})}registerLocalPlugins(){const e=[];Object.entries(er).forEach(([t,n])=>{cn.plugins.activePlugins.value.includes(t)&&(b(n)?this.register([n()]):e.push(t))}),e.length>0&&(cn.plugins.failedPlugins.value=[...cn.plugins.failedPlugins.value,...e],this.logger.error(((e,t)=>`${e}${pe}Failed to load the following unavailable local plugins: ${t.join(", ")}. Some features of the SDK may not work as expected. Make sure you are using the correct SDK bundle variant.`)(X,e)))}registerRemotePlugins(){const e=(t=cn.plugins.activePlugins.value,{...Yn(t)});var t;Promise.all(Object.keys(e).map(async t=>{await e[t]().then(e=>this.register([e.default()])).catch(e=>{cn.plugins.failedPlugins.value=[...cn.plugins.failedPlugins.value,t],this.onError(e,`Failed to load plugin "${t}"`,e)})})).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,cn)}catch(t){cn.plugins.failedPlugins.value=[...cn.plugins.failedPlugins.value,e.name],this.onError(t,`Failed to register plugin "${e.name}"`)}})}unregisterLocalPlugins(){Object.keys(er).forEach(e=>{try{this.engine.unregister(e)}catch(t){this.onError(t,`Failed to unregister plugin "${e}"`)}})}onError(e,t,n){this.errorHandler.onError({error:e,context:X,customMessage:t,groupingHash:n})}}const nr="cookieStorage",rr="localStorage",ir="sessionStorage",sr="memoryStorage",or="none",ar={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"},lr="clientDataInCookie",ur="clientDataInLocalStorage",cr="clientDataInSessionStorage",dr=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],gr={[nr]:lr,[rr]:ur,[sr]:"clientDataInMemory",[ir]:cr},hr=(e,t)=>{try{return encodeURIComponent(e)}catch(e){return void t?.error("Failed to encode the cookie data.",e)}},pr=e=>{try{return decodeURIComponent(e)}catch(e){return}},fr=()=>(e=>{const t={},n=e.split(/\s*;\s*/);let r;return n[0]?(n.forEach(e=>{r=e.split("=");const n=r[0]?pr(r[0]):void 0;n&&(t[n]=r[1]?pr(r[1]):void 0)}),t):t})(globalThis.document.cookie),vr=function(e,t,n,r){switch(arguments.length){case 4:case 3:case 2:return((e,t,n,r)=>{const i={...n||{}};let s=`${hr(e,r)}=${hr(t,r)}`;S(t)&&(i.maxage=-1),i.maxage&&(i.expires=new Date(+new Date+i.maxage)),i.path&&(s+=`; path=${i.path}`),i.domain&&(s+=`; domain=${i.domain}`),i.expires&&(s+=`; expires=${i.expires.toUTCString()}`),i.samesite&&(s+=`; samesite=${i.samesite}`),i.secure&&(s+="; secure"),globalThis.document.cookie=s})(e,t,n,r);case 1:return e?(e=>fr()[e])(e):fr();default:return fr()}},yr=e=>{const t="function"!=typeof globalThis.URL?(e=>{const t=document.createElement("a");return t.href=e,t.hostname})(e):new URL(e).hostname,n=t?.split(".")??[],r=n[n.length-1],i=[];if(4===n.length&&r&&r===parseInt(r,10).toString())return i;if(n.length<=1)return n[0]&&-1!==n[0].indexOf("localhost")?["localhost"]:i;for(let e=n.length-2;e>=0;e-=1)i.push(n.slice(e).join("."));return i},mr=()=>{const e=`.${(e=>{const t=yr(e);for(let e=0;e<t.length;e+=1){const n=t[e],r="__tld__",i={domain:`${-1!==n.indexOf("localhost")?""
1:"."}${n}`};try{if(vr(r,1,i),vr(r))return vr(r,null,i),n}catch{try{vr(r,null,i)}catch{}}}return""})(globalThis.location.href)}`;return{maxage:31536e6,path:"/",domain:e&&"."!==e?e:void 0,samesite:"Lax",enabled:!0}};const br=new class{isEnabled=!0;length=0;data={};constructor(e){this.options={enabled:!0},this.logger=e}configure(e){return this.options=D(this.options,e??{}),this.isEnabled=Boolean(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)}}(mt);function Er(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Sr,kr={exports:{}};var Ir=(Sr||(Sr=1,kr.exports=function(){function e(e){return e=JSON.stringify(e),!!/^\{[\s\S]*\}$/.test(e)}function t(e){return void 0===e||"function"==typeof e?e+"":JSON.stringify(e)}function n(e){if("string"==typeof e)try{return JSON.parse(e)}catch(t){return e}}function r(e){return"[object Function]"==={}.toString.call(e)}function i(e){return"[object Array]"===Object.prototype.toString.call(e)}function s(e){var t="_Is_Incognit",n="yes";try{e||(e=window.localStorage),e.setItem(t,n),e.removeItem(t)}catch(t){var r={_data:{},setItem:function(e,t){return r._data[e]=String(t)},getItem:function(e){return r._data.hasOwnProperty(e)?r._data[e]:void 0},removeItem:function(e){return delete r._data[e]},clear:function(){return r._data={}}};e=r}finally{e.getItem(t)===n&&e.removeItem(t)}return e}var o=s();function a(){if(!(this instanceof a))return new a}a.prototype={set:function(n,r){if(n&&!e(n))o.setItem(n,t(r));else if(e(n))for(var i in n)this.set(i,n[i]);return this},get:function(e){if(void 0===e){var t={};return this.forEach(function(e,n){return t[e]=n}),t}if("?"===e.charAt(0))return this.has(e.substr(1));var r=arguments;if(r.length>1){for(var i={},s=0,a=r.length;s<a;s++){var l=n(o.getItem(r[s]));this.has(r[s])&&(i[r[s]]=l)}return i}return n(o.getItem(e))},clear:function(){return o.clear(),this},remove:function(e){var t=this.get(e);return o.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,n=o.length;t<n;t++){var r=o.key(t);e(r,this.get(r))}return this},search:function(e){for(var t=this.keys(),n={},r=0,i=t.length;r<i;r++)t[r].indexOf(e)>-1&&(n[t[r]]=this.get(t[r]));return n},len:function(){return o.length}};var l=null;function u(t,n){var s=arguments,o=null;if(l||(l=a()),0===s.length)return l.get();if(1===s.length){if("string"==typeof t)return l.get(t);if(e(t))return l.set(t)}if(2===s.length&&"string"==typeof t){if(!n)return l.remove(t);if(n&&"string"==typeof n)return l.set(t,n);n&&r(n)&&(o=null,o=n(t,l.get(t)),u.set(t,o))}if(2===s.length&&i(t)&&r(n))for(var c=0,d=t.length;c<d;c++)o=n(t[c],l.get(t[c])),u.set(t[c],o);return u}for(var c in a.prototype)u[c]=a.prototype[c];return u}()),kr.exports);const Tr=Er(Ir),Ar=e=>{const t=[22,1014];return e instanceof DOMException&&(["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"].includes(e.name)||t.includes(e.code))},wr=(e=rr,t,n)=>{let r,i;const s=`${z}${pe}The "${e}" storage type is `;let o,a="unavailable",l=!0;try{switch(e){case sr:return!0;case nr:r=t,i="test_rudder_cookie";break;case rr:r=t??globalThis.localStorage,i="test_rudder_ls";break;case ir:r=t??globalThis.sessionStorage,i="test_rudder_ss";break;default:return!1}if(r&&(r.setItem(i,"true"),r.getItem(i)))return r.removeItem(i),!0;l=!1}catch(e){l=!1,o=e,Ar(e)&&(a="full")}return l||n?.warn(`${s}${a}.`,o),!1};const Cr=new class{isSupportAvailable=!0;isEnabled=!0;length=0;constructor(e){this.options={enabled:!0},this.logger=e}configure(e){return this.options=D(this.options,e??{}),this.isSupportAvailable=wr(rr),this.isEnabled=Boolean(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){Tr.set(e,t),this.length=Tr.len()}getItem(e){const t=Tr.get(e);return k(t)?null:t}removeItem(e){Tr.remove(e),this.length=Tr.len()}clear(){Tr.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Tr.keys()}}(mt);const Pr=new class{isSupportAvailable=!0;isEnabled=!0;length=0;constructor(e){this.options={enabled:!0},this.logger=e}configure(e){return this.options=D(this.options,e??{}),this.isSupportAvailable=wr(ir),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=Boolean(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;const t=this.store.getItem(e);return k(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(){const e=[];
1if(!this.store)return e;for(let t=0;t<this.store.length;t+=1){const n=this.store.key(t);null!==n&&e.push(n)}return e}}(mt);const Or=new class{isSupportAvailable=!0;isEnabled=!0;length=0;constructor(e){this.logger=e}configure(e){return this.options||(this.options=mr()),this.options=D(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=wr(nr,this),this.isEnabled=Boolean(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){return vr(e,t,this.options,this.logger),this.length=Object.keys(vr()).length,!0}getItem(e){const t=vr(e);return k(t)?null:t}removeItem(e){const t=this.setItem(e,null);return this.length=Object.keys(vr()).length,t}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(vr())}}(mt),Dr=e=>{switch(e){case rr:return Cr;case ir:return Pr;case sr:return br;case nr:return Or;default:return br}},_r=(e={},t={},n={},r={})=>{var i;(e=>{const t=Or.configure(e);cn.storage.cookie.value={maxage:t.maxage,path:t.path,domain:t.domain,samesite:t.samesite,expires:t.expires,secure:t.secure}})(e),i=t,Cr.configure(i),(e=>{br.configure(e)})(n),(e=>{Pr.configure(e)})(r)};class $r{constructor(e,t,n){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=n}createValidKey(e){const{name:t,id:n,validKeys:r,noKeyValidation:i,noCompoundKey:s}=this;if(i)return s?e:[t,n,e].join(".");let o;return Object.values(r).forEach(r=>{r===e&&(o=s?e:[t,n,e].join("."))}),o}swapQueueStoreToInMemoryEngine(){const{name:e,id:t,validKeys:n,noCompoundKey:r}=this,i=Dr(sr);Object.keys(n).forEach(s=>{const o=this.get(n[s]),a=r?s:[e,t,s].join(".");i.setItem(a,o),this.remove(s)}),this.engine=i}set(e,t){const n=this.createValidKey(e);if(n)try{this.engine.setItem(n,this.encrypt(Ee(t,!1,[],this.logger)))}catch(n){if(Ar(n))this.logger.warn(`${`Store ${this.id}`}${pe}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{const t=(e=>`Failed to save the value for "${e}" to storage`)(e);this.onError(n,t,t)}}}get(e){const t=this.createValidKey(e);let n;try{return t?(n=this.decrypt(this.engine.getItem(t)),I(n)||""===n?null:JSON.parse(n)):null}catch(t){const n=cn.storage.encryptionPluginName.value;if(!n||!cn.plugins.failedPlugins.value.includes(n)){const n=(e=>`Failed to retrieve or parse data for "${e}" from storage`)(e);this.onError(t,n,n)}return null}}remove(e){const t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return I(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){const n=!this.isEncrypted||!e||"string"!=typeof e||""===(e=>e.replace(/^\s+|\s+$/gm,""))(e);if(n)return e;const r=`storage.${t}`,i=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return void 0===i?e:i??""}onError(e,t,n){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:n})}}class Rr{stores={};isInitialized=!1;constructor(e,t,n){this.errorHandler=t,this.logger=n,this.pluginsManager=e}init(){if(this.isInitialized)return;const e=cn.loadOptions.value,t={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};_r(R(D(t.cookieStorageOptions??{},cn.storage.cookie?.value??{})),R(t.localStorageOptions),R(t.inMemoryStorageOptions),R(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState();[sr,rr,nr,ir].forEach(e=>{Dr(e)?.isEnabled&&this.setStore({id:gr[e],name:gr[e],isEncrypted:!0,noCompoundKey:!0,type:e,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=cn.storage.type.value,t=cn.loadOptions.value.storage?.entries;const n=cn.consents.postConsent.value.storage;
1(T(n?.type)||T(n?.entries))&&(e=n?.type,t=n?.entries);let r=!0,i={};dr.forEach(n=>{const s=n,o=n,a=t?.[s]?.type,l=((e,t)=>{let n;if(e.consents.preConsent.value.enabled)switch(e.consents.preConsent.value.storage?.strategy){case"none":n=or;break;case"session":"sessionInfo"!==t&&(n=or);break;case"anonymousId":"anonymousId"!==t&&(n=or)}return n})(cn,n),u=l??a??e??St,c=this.getResolvedStorageTypeForEntry(u,n);c!==or&&(r=!1),i={...i,[n]:{type:c,key:ar[o]}}}),We(()=>{cn.storage.type.value=e,cn.storage.entries.value=i,cn.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,t){let n=e;switch(e){case rr:Dr(rr)?.isEnabled||(n=sr);break;case ir:Dr(ir)?.isEnabled||(n=sr);break;case sr:case or:break;default:n=Dr(nr)?.isEnabled?nr:Dr(rr)?.isEnabled?rr:Dr(ir)?.isEnabled?ir:sr}return n!==e&&this.logger.warn(((e,t,n,r)=>`${e}${pe}The storage type "${n}" is not available for entry "${t}". The SDK will initialize the entry with "${r}" storage type instead.`)("StoreManager",t,e,n)),n}setStore(e){const t=Dr(e.type);return this.stores[e.id]=new $r(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}}const Lr=e=>{const t=new URL(e),{host:n,protocol:r}=t,i=n.split(".");let s;return s=i.length>2?`${i[i.length-2]}.${i[i.length-1]}`:n,{topDomain:s,protocol:r}},Nr=(e,t)=>`${t?window.location.origin:(e=>{const{topDomain:t,protocol:n}=Lr(e);return`${n}//${t}`})(window.location.href)}/${e.startsWith("/")?e.substring(1):e}`,xr=e=>e?.endsWith("/")?xr(e.substring(0,e.length-1)):e,Mr=e=>{try{return new URL(e).host}catch(e){return null}},Ur=e=>Mr(e)??"",Br=e=>{const t={};try{const n=new URL(e),r="utm_";n.searchParams.forEach((e,n)=>{if(n.startsWith(r)){let i=n.substring(r.length);"campaign"===i&&(i="name"),t[i]=e}})}catch(e){}return t},jr=e=>{if(!E(e))return!1;try{return b(globalThis.URL)&&new URL(e),$t.test(e)}catch(e){return!1}},Gr="none",Hr="immediate",Fr=e=>_(e)||Array.isArray(e),Kr=(e,t)=>{let{provider:n}=e;const r=n?Gt[n]:void 0;var i;return n&&!r&&(t.error((i=Gt,`${q}${pe}The consent manager "${n}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(i)}".`)),n=void 0),{provider:n,consentManagerPluginName:r}},Vr=(e,t)=>{let n,r,i=[],s=[],o=!1,a=!0===e?.enabled;_(e)&&a&&(({provider:r,consentManagerPluginName:n}=Kr(e,t)),Fr(e.allowedConsentIds)&&(i=e.allowedConsentIds,o=!0),Fr(e.deniedConsentIds)&&(s=e.deniedConsentIds,o=!0));const l={allowedConsentIds:i,deniedConsentIds:s};return a=a&&Boolean(n),{provider:r,consentManagerPluginName:n,initialized:o,enabled:a,consentsData:l}},Wr=e=>{var t;cn.reporting.isErrorReportingEnabled.value=(t=e.source.config,!0===t?.statsCollection?.errors?.enabled&&!window.chrome?.runtime?.id),cn.reporting.isMetricsReportingEnabled.value=(e=>!0===e?.statsCollection?.metrics?.enabled)(e.source.config)},Qr=e=>{const{useServerSideCookies:t,dataServiceEndpoint:n,storage:r,setCookieDomain:i,sameDomainCookiesOnly:s}=cn.loadOptions.value;let o,a=r?.cookie,l=!1;if(t){l=t;const r=a.domain??i,u=T(r)&&!(e=>{const{topDomain:t}=Lr(window.location.href);return t===e})(U(r))||s,c=Nr(n??"rsaRequest",u);if(jr(c)){o=xr(c);const t=Mr(window.location.href),n=Mr(c);t!==n&&(a={...a,samesite:"None",secure:!0}),!s&&u&&n!==U(r)&&(l=!1,e.warn(((e,t,n)=>`${e}${pe}The provided cookie domain (${t}) does not match the current webpage's domain (${n}). Hence, the cookies will be set client-side.`)(q,r,n)))}else l=!1}return{sscEnabled:l,cookieOptions:a,finalDataServiceUrl:o}},zr=e=>{const{storage:t}=cn.loadOptions.value;let n=t?.type;T(n)&&!(e=>"string"==typeof e&&Et.includes(e))(n)&&(e.warn(((e,t,n)=>`${e}${pe}The storage type "${t}" is not supported. Please choose one of the following supported types: "${Et}". The default type "${n}" will be used instead.`)(q,n,St)),n=St);let r=t?.encryption?.version;const i=r&&Ht[r];var s,o;!k(r)&&k(i)?(e.warn((s=Ht,o=Bt,`${q}${pe}The storage encryption version "${r}" is not supported. Please choose one of the following supported versions: "${Object.keys(s)}". The default version "${o}" will be used instead.`)),r=Bt):k(r)&&(r=Bt);const a=t?.migrate,l=a&&r===Bt;!0===a&&l!==a&&e.warn(((e,t,n)=>`${e}${pe}The storage data migration has been disabled because the configured storage encryption version (${t}) is not the latest (${n}). To enable storage data migration, please update the storage encryption version to the latest version.`)(q,r,Bt));const{sscEnabled:u,finalDataServiceUrl:c,cookieOptions:d}=Qr(e);We(()=>{cn.storage.type.value=n,cn.storage.cookie.value=d,cn.serverCookies.isEnabledServerSideCookies.value=u,cn.serverCookies.dataServiceUrl.value=c,cn.storage.encryptionPluginName.value=Ht[r],cn.storage.migrate.value=l})},qr=e=>{const{provider:t,consentManagerPluginName:n,initialized:r,enabled:i,consentsData:s}=Vr(cn.loadOptions.value.consentManagement,e),o=cn.loadOptions.value.preConsent;let a=o?.storage?.strategy??Gr;var l,u;T(a)&&!["none","session","anonymousId"].includes(a)&&(a=Gr,e.warn((l=q,u=o?.storage?.strategy,`${l}${pe}The pre-consent storage strategy "${u}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${Gr}" will be used instead.`)));let c=o?.events?.delivery??Hr;T(c)&&!["immediate","buffer"].includes(c)&&(c=Hr,e.warn(((e,t,n)=>`${e}${pe}The pre-consent events delivery type "${t}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${n}" will be used instead.`)(q,o?.events?.delivery,Hr))),We(()=>{cn.consents.activeConsentManagerPluginName.value=n,cn.consents.initialized.value=r,cn.consents.enabled.value=i,cn.consents.data.value=s,cn.consents.provider.value=t,cn.consents.preConsent.value={enabled:!0===cn.loadOptions.value.preConsent?.enabled&&!1===r&&!0===i,storage:{strategy:a},events:{delivery:c}}})},Jr=e=>{if(cn.dataPlaneEvents.deliveryEnabled.value){const t="XhrQueue";let n=t;cn.loadOptions.value.useBeacon&&(cn.capabilities.isBeaconAvailable.value?n="BeaconQueue":(n=t,e.warn(`${q}${pe}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`))),We(()=>{cn.dataPlaneEvents.eventsQueuePluginName.value=n})}},Xr=(e,t,n,r,i)=>{const s=new URLSearchParams({p:"npm",v:Oe,build:Rt,writeKey:t,lockIntegrationsVersion:n.toString(),lockPluginsVersion:r.toString()});let o=Ut,a=s,l="/sourceConfig/",u="";if(jr(e)){const t=new URL(e);
1xr(t.pathname).endsWith("/sourceConfig")||(t.pathname=`${xr(t.pathname)}/sourceConfig/`),t.pathname=t.pathname.replace(/\/{2,}/g,"/"),s.forEach((e,n)=>{null===t.searchParams.get(n)&&t.searchParams.set(n,e)}),o=t.origin,l=t.pathname,a=t.searchParams,u=t.hash}else i.warn(((e,t)=>`${e}${pe}The provided source config URL "${t}" is invalid. Using the default source config URL instead.`)(q,e));return`${o}${l}?${a}${u}`},Zr=(e,t,n,r,i,s,o)=>{let a;if(s){if(!jr(s))return o.error(`${q}${pe}The base URL "${s}" for ${e} is not valid.`),null;a=xr(s)}else if(a=n,"cdn"===cn.context.app.value.installType){const e=(()=>{const e=document.querySelector("script[data-rsa-write-key]");if(e&&e.dataset.rsaWriteKey===cn.lifecycle.writeKey.value)return e.src;const t=document.getElementsByTagName("script"),n=/(?:^|\/)rsa(\.min)?\.js$/;for(const e of t){const t=e.getAttribute("src");if(t&&n.test(t))return t}})();e&&(a=e.split("/").slice(0,-1).concat(t).join("/"))}return i&&(a=a.replace(new RegExp(`/${Nt}/${Rt}/${t}$`),`/${r}/${Rt}/${t}`)),a};class Yr{constructor(e,t,n){this.errorHandler=t,this.logger=n,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){pt(()=>{this.logger.setMinLogLevel(cn.lifecycle.logLevel.value)})}init(){const{logLevel:e,configUrl:t,lockIntegrationsVersion:n,lockPluginsVersion:r,destSDKBaseURL:i,pluginsSDKBaseURL:s,integrations:o}=cn.loadOptions.value,a=((e,t,n,r)=>Zr("integrations",Dt,xt,e,t,n,r))(Oe,n,i,this.logger);if(S(a))return;let l;l=((e,t,n,r)=>Zr("plugins",_t,Mt,e,t,n,r))(Oe,r,s,this.logger),null!==l&&(this.attachEffects(),cn.lifecycle.activeDataplaneUrl.value=xr(cn.lifecycle.dataPlaneUrl.value),zr(this.logger),qr(this.logger),Jr(this.logger),We(()=>{cn.lifecycle.integrationsCDNPath.value=a,cn.lifecycle.pluginsCDNPath.value=l,e&&(cn.lifecycle.logLevel.value=e),cn.lifecycle.sourceConfigUrl.value=Xr(t,cn.lifecycle.writeKey.value,n,r,this.logger),cn.metrics.metricsServiceUrl.value=`${cn.lifecycle.activeDataplaneUrl.value}/rsaMetrics`,cn.nativeDestinations.loadOnlyIntegrations.value=o}),this.getConfig())}onError(e,t,n){this.errorHandler.onError({error:e,context:q,customMessage:t,groupingHash:n})}processConfig(e,t){if(!T(e))return void(T(t)?this.onError(t.error,Tt):this.onError(new Error(Tt)));let n;try{n=E(e)?JSON.parse(e):e}catch(e){return void this.onError(e,kt)}if(!(e=>P(e)&&P(e.source)&&!I(e.source.id)&&P(e.source.config)&&Array.isArray(e.source.destinations))(n))return void this.onError(new Error(kt));if(!1===n.source.enabled)return void this.logger.error("The source is disabled. Please enable the source in the dashboard to send events.");Wr(n);const r=n.source.destinations.length>0?n.source.destinations.map(e=>{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,n=e.id,`${t.replaceAll(" ","-")}___${n}`),isCustomIntegration:"Custom Device Mode"===e.destinationDefinition.displayName};var t,n}):[];We(()=>{cn.source.value={config:n.source.config,name:n.source.name,id:n.source.id,workspaceId:n.source.workspaceId},cn.nativeDestinations.configuredDestinations.value=r,cn.plugins.pluginsToLoadFromConfig.value=cn.loadOptions.value.plugins??[],(e=>{let t,n=cn.consents.resolutionStrategy.value;P(e.consentManagementMetadata)&&(cn.consents.provider.value&&(n=e.consentManagementMetadata.providers.find(e=>e.provider===cn.consents.provider.value)?.resolutionStrategy??cn.consents.resolutionStrategy.value),t=e.consentManagementMetadata),"custom"===cn.consents.provider.value&&(n=void 0),We(()=>{cn.consents.metadata.value=g(t),cn.consents.resolutionStrategy.value=n})})(n),cn.lifecycle.status.value="configured"})}getConfig(){const e=cn.loadOptions.value.getSourceConfig;if(e){if(!b(e))return void this.logger.error((t=q,`${t}${pe}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`));const n=e();n instanceof Promise?n.then(e=>this.processConfig(e)).catch(e=>{this.onError(e,"SourceConfig")}):this.processConfig(n)}else this.httpClient.getAsyncData({url:cn.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig});var t}}const ei=(e=()=>document)=>e()?.referrer||"$direct",ti=(e=()=>globalThis.location,t=()=>document)=>{const n=e(),r=((e=()=>document)=>{const t=e().getElementsByTagName("link");let n="";for(let e=0;t[e];e+=1){const r=t[e];if("canonical"===r.getAttribute("rel")&&!n){n=r.getAttribute("href")??"";break}}return n})(t);let i=n.pathname;const{href:s}=n;let o=s;const{search:a}=n;if(r)try{const e=new URL(r);o=""===e.search?r+a:r,i=e.pathname}catch(e){}const l=(e=>{let t=e;try{const n=new URL(e);t=n.origin+n.pathname+n.search}catch(e){}return t})(o),{title:u}=t(),c=ei(t);return{path:i,referrer:c,referring_domain:Ur(c),search:a,title:u,url:l,tab_url:s}},ni={URL:()=>!b(globalThis.URL)||!b(globalThis.URLSearchParams),Promise:()=>!b(globalThis.Promise),"Number.isNaN":()=>!b(globalThis.Number.isNaN),"Number.isInteger":()=>!b(globalThis.Number.isInteger),"Array.from":()=>!b(globalThis.Array.from),"Array.prototype.find":()=>!b(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!b(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!b(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>
1!b(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!b(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!b(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!b(globalThis.String.fromCodePoint),"Object.entries":()=>!b(globalThis.Object.entries),"Object.values":()=>!b(globalThis.Object.values),"Object.assign":()=>!b(globalThis.Object.assign),"Object.fromEntries":()=>!b(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!(()=>{const e=globalThis.document.createElement("div");return e.setAttribute("data-a-b","c"),!!e.dataset&&"c"===e.dataset.aB})(),TextEncoder:()=>!b(globalThis.TextEncoder)||!b(globalThis.TextDecoder),requestAnimationFrame:()=>!b(globalThis.requestAnimationFrame)||!b(globalThis.cancelAnimationFrame),CustomEvent:()=>!b(globalThis.CustomEvent),"navigator.sendBeacon":()=>!b(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!b(globalThis.Uint8Array),Set:()=>!b(globalThis.Set),atob:()=>!b(globalThis.atob)},ri=`https://polyfill-fastly.io/v3/polyfill.min.js?version=3.111.0&features=${Object.keys(ni).join("%2C")}`,ii="rudderstackPolyfill",si=()=>!I(globalThis.navigator.userAgentData),oi=()=>{let e={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return e={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},e};class ai{constructor(e,t,n){this.httpClient=e,this.errorHandler=t,this.logger=n,this.externalSrcLoader=new Fe(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){We(()=>{cn.capabilities.storage.isCookieStorageAvailable.value=wr(nr,Dr(nr),this.logger),cn.capabilities.storage.isLocalStorageAvailable.value=wr(rr,void 0,this.logger),cn.capabilities.storage.isSessionStorageAvailable.value=wr(ir,void 0,this.logger),cn.capabilities.isBeaconAvailable.value=!I(globalThis.navigator.sendBeacon)&&b(globalThis.navigator.sendBeacon),cn.capabilities.isUaCHAvailable.value=si(),cn.capabilities.isCryptoAvailable.value=!I(globalThis.crypto)&&b(globalThis.crypto.getRandomValues),cn.capabilities.isOnline.value=globalThis.navigator.onLine,cn.context.userAgent.value=((e=()=>globalThis.navigator)=>{const t=e();if(k(t))return null;let{userAgent:n}=t;const{brave:r}=t;if(r&&Object.getPrototypeOf(r).isBrave){const e=n.match(/(chrome)\/([\w.]+)/i);e&&(n=`${n} Brave/${e[2]}`)}return n})(),cn.context.locale.value=((e=()=>globalThis.navigator)=>{const t=e();return k(t)?null:t.language??t.browserLanguage})(),cn.context.screen.value=oi(),cn.context.timezone.value=(()=>{const e=/([A-Z]+[+-]\d+)/.exec((new Date).toString());return e?.[1]?e[1]:"NA"})(),si()&&((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=>{cn.context["ua-ch"].value=e},cn.loadOptions.value.uaChTrackLevel)}),pt(()=>{!0===cn.loadOptions.value.sendAdblockPage&&void 0!==cn.lifecycle.sourceConfigUrl.value&&$n(this.httpClient)})}prepareBrowserCapabilities(){cn.capabilities.isLegacyDOM.value=(()=>{const e=Object.keys(ni);let t=!1;for(let n=0;n<e.length;n++){const r=ni[e[n]];if(b(r)&&r()){t=!0;break}}return t})();const e=cn.loadOptions.value.polyfillURL;let t=ri;A(e)&&(jr(e)?t=e:this.logger.warn(((e,t)=>`${e}${pe}The provided polyfill URL "${t}" is invalid. The default polyfill URL will be used instead.`)(z,e)));if(cn.loadOptions.value.polyfillIfRequired&&cn.capabilities.isLegacyDOM.value&&jr(t)){const e=t!==cn.loadOptions.value.polyfillURL;if(e){const e=`RS_polyfillCallback_${cn.lifecycle.writeKey.value}`,n=()=>{this.onReady(),delete globalThis[e]};globalThis[e]=n,t=`${t}&callback=${e}`}this.externalSrcLoader.loadJSFile({url:t,id:ii,async:!0,timeout:1e4,callback:n=>{n?e||this.onReady():this.onError(new Error(((e,t)=>`Failed to load the polyfill script with ID "${e}" from URL ${t}.`)(ii,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{cn.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{cn.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",function(e,t,n=250){let r;return(...i)=>{globalThis.clearTimeout(r),r=globalThis.setTimeout(()=>{e.apply(t,i)},n)}}(()=>{cn.context.screen.value=oi()},this))}onReady(){this.detectBrowserCapabilities(),cn.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:z,groupingHash:t})}}const li=["integrations","anonymousId","originalTimestamp"],ui=["library","consentManagement","userAgent","ua-ch","screen"],ci=["id","anonymous_id","user_id","sent_at","t
1imestamp","received_at","original_timestamp","event","event_text","channel","context_ip","context_request_ip","context_passed_ip","group_id","previous_id"],di="CustomContext",gi=new Set(["__proto__","constructor","prototype"]),hi=Function.prototype.toString.call(Object),pi=(e,t=new Set)=>{if(!P(e)&&!Array.isArray(e))return!1;const n=e;return!t.has(n)&&(t.add(n),Object.keys(n).some(e=>gi.has(e)||pi(n[e],t)))},fi=(e,t)=>{const n={};return Object.keys(e).forEach(r=>{ui.includes(r)?t.warn(`${di}${pe}The top-level custom context property "${r}" is reserved and was ignored.`):Object.defineProperty(n,r,{configurable:!0,enumerable:!0,value:e[r]===e?n:e[r],writable:!0})}),n},vi=(e,t)=>{try{if(!(e=>{if(!P(e))return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;const n=Object.prototype.hasOwnProperty.call(t,"constructor")?t.constructor:void 0;return"function"==typeof n&&n.prototype===t&&Function.prototype.toString.call(n)===hi})(e))return void t.warn(Pt(di));const n=fi(e,t);if(pi(n))return void t.warn(Pt(di));const r=Ie(n,t);return g(r)}catch{return void t.warn(Pt(di))}};class yi{constructor(e,t){this.state=e,this.logger=t}set(e){const t=vi(e,this.logger);if(!t)return;const n=D(g(this.state.value),t);this.state.value=L(n)}get(){return g(this.state.value)}clear(){this.state.value={}}}const mi=e=>"number"==typeof e&&!Number.isNaN(e),bi=e=>mi(e)&&e>=0&&Number.isInteger(e),Ei=e=>{const{cutOff:t}=e,n=Date.now();return Boolean(t?.enabled&&t.expiresAt&&n>t.expiresAt)},Si=e=>Boolean(!e.expiresAt||Date.now()>e.expiresAt)||Ei(e),ki=(e,t)=>{return!!(e&&bi(e)&&(n=10,r=e,r.toString().length>=n))||(t.warn(((e,t,n)=>`${e}${pe}The provided session ID (${t}) is either invalid, not a positive integer, or not at least "${n}" digits long. A new session ID will be auto-generated instead.`)(Z,e,10)),!1);var n,r},Ii=(e,t)=>({id:ki(e,t)?e:Date.now(),sessionStart:void 0,manualTrack:!0}),Ti=e=>Boolean(e===nr||e===rr||e===ir||e===sr),Ai=()=>de(),wi=e=>{const t=ti(),n={};return Object.keys(t).forEach(r=>{n[r]=e?.[r]||t[r]}),n.initial_referrer=e?.initial_referrer||cn.session.initialReferrer.value,n.initial_referring_domain=e?.initial_referring_domain||cn.session.initialReferringDomain.value,n},Ci=(e,t,n)=>{P(e)&&Object.keys(e).forEach(e=>{(ci.includes(e)||ci.includes(e.toLowerCase()))&&n.warn(((e,t,n,r)=>`${e}${pe}The "${t}" property defined under "${n}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${r}).`)(J,e,t,ci))})},Pi=(e,t,n)=>{let r=e;const i=e=>{const t=fi(e,n);pi(t)?n.warn(Pt(J)):r=D(r,t)};return Object.keys(t).forEach(e=>{li.includes(e)||("context"!==e?i({[e]:t[e]}):!k(t[e])&&P(t[e])?i(t[e]):n.warn(`${J}${pe}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`))}),r},Oi=(e,t,n)=>{P(t)&&(((e,t)=>{t.anonymousId&&E(t.anonymousId)&&(e.anonymousId=t.anonymousId),_(t.integrations)&&(e.integrations=t.integrations),t.originalTimestamp&&E(t.originalTimestamp)&&(e.originalTimestamp=t.originalTimestamp)})(e,t),e.context=Pi(e.context,t,n))},Di=(e,t,n,r,i={})=>{const s={channel:"web",context:{traits:g(cn.session.userTraits.value),sessionId:cn.session.sessionInfo.value.id||void 0,sessionStart:cn.session.sessionInfo.value.sessionStart||void 0,...cn.consents.enabled.value&&{consentManagement:{deniedConsentIds:g(cn.consents.data.value.deniedConsentIds),allowedConsentIds:g(cn.consents.data.value.allowedConsentIds),provider:cn.consents.provider.value,resolutionStrategy:cn.consents.resolutionStrategy.value}},"ua-ch":cn.context["ua-ch"].value,app:cn.context.app.value,library:cn.
1context.library.value,userAgent:cn.context.userAgent.value,os:cn.context.os.value,locale:cn.context.locale.value,screen:cn.context.screen.value,campaign:Br(globalThis.location.href),page:wi(n),timezone:cn.context.timezone.value,...cn.autoTrack.enabled.value&&{autoTrack:{...cn.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:cn.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:he(new Date),messageId:de(),userId:e.userId||cn.session.userId.value};Ti(cn.storage.entries.value.anonymousId?.type)?s.anonymousId=cn.session.anonymousId.value:s.anonymousId=Ai(),cn.storage.trulyAnonymousTracking.value&&(s.context.trulyAnonymousTracking=!0),"identify"===e.type&&(s.context.traits=cn.storage.entries.value.userTraits?.type!==or?g(cn.session.userTraits.value):e.context.traits),"group"===e.type&&((e.groupId||cn.session.groupId.value)&&(s.groupId=e.groupId||cn.session.groupId.value),(e.traits||cn.session.groupTraits.value)&&(s.traits=cn.storage.entries.value.groupTraits?.type!==or?g(cn.session.groupTraits.value):e.traits));const o=D(e,s),a=D(o,{context:i});return void 0===a.event&&(a.event=null),void 0===a.properties&&(a.properties=null),Oi(a,t,r),((e,t)=>{const{properties:n,traits:r,context:i}=e,{traits:s}=i;Ci(n,"properties",t),Ci(r,"traits",t),Ci(s,"context.traits",t)})(a,r),a.integrations=(e=>{let t;return t=cn.loadOptions.value.useGlobalIntegrationsConfigInEvents?cn.consents.postConsent.value.integrations??cn.nativeDestinations.loadOnlyIntegrations.value:e||Ot,g(t)})(a.integrations),a};class _i{constructor(e){this.logger=e}generatePageEvent(e,t,n,r,i={}){let s=n??{};s=((e,t)=>{const n=t?.page||{},r=e,i=ti();
1return Object.keys(i).forEach(e=>{k(r[e])&&(r[e]=n[e]||i[e])}),k(r.initial_referrer)&&(r.initial_referrer=n.initial_referrer||cn.session.initialReferrer.value),k(r.initial_referring_domain)&&(r.initial_referring_domain=n.initial_referring_domain||cn.session.initialReferringDomain.value),r})(s,r);return Di({properties:s,name:t,category:e,type:"page"},r,s,this.logger,i)}generateTrackEvent(e,t,n,r={}){return Di({properties:t,event:e,type:"track"},n,void 0,this.logger,r)}generateIdentifyEvent(e,t,n,r={}){return Di({userId:e,type:"identify",context:{traits:t}},n,void 0,this.logger,r)}generateAliasEvent(e,t,n,r={}){const i=Di({previousId:t,type:"alias"},n,void 0,this.logger,r);return i.userId=e??i.userId,i}generateGroupEvent(e,t,n,r={}){const i={type:"group"};return e&&(i.groupId=e),t&&(i.traits=t),Di(i,n,void 0,this.logger,r)}create(e,t={}){let n;const{type:r,name:i,properties:s,options:o,category:a,userId:l,traits:u,to:c,from:d,groupId:g}=e;switch(r){case"page":n=this.generatePageEvent(a,i,s,o,t);break;case"track":n=this.generateTrackEvent(i,s,o,t);break;case"identify":n=this.generateIdentifyEvent(l,u,o,t);break;case"alias":n=this.generateAliasEvent(c,d,o,t);break;default:n=this.generateGroupEvent(g,u,o,t)}return n}}class $i{constructor(e,t,n,r){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=n,this.logger=r,this.eventFactory=new _i(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e,t){this.userSessionManager.refreshSession();const n=this.eventFactory.create(e,t);this.eventRepository.enqueue(n,e.callback)}}class Ri{constructor(e,t,n,r,i){this.storeManager=t,this.pluginsManager=e,this.logger=i,this.errorHandler=r,this.httpClient=n,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());const{externalAnonymousIdCookieName:e,anonymousIdOptions:t}=cn.loadOptions.value;let n;A(e)&&"string"==typeof e&&(n=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(n??this.getAnonymousId(t)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){const t=this.getConfiguredSessionTrackingInfo(),n=this.getSessionInfo()??Vt.sessionInfo;e={autoTrack:t.autoTrack&&!0!==n.manualTrack,timeout:t.timeout,manualTrack:n.manualTrack,expiresAt:n.expiresAt,id:n.id,sessionStart:n.sessionStart},e.autoTrack||!0===e.manualTrack?!0===t.cutOff?.enabled&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:n.cutOff?.expiresAt}):e=Vt.sessionInfo}else e=Vt.sessionInfo;cn.session.sessionInfo.value=e,cn.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(cn.session.sessionInfo.value)}setInitialReferrerInfo(){const e=this.getInitialReferrer(),t=this.getInitialReferringDomain();if(e&&t)this.setInitialReferrer(e),this.setInitialReferringDomain(t);else{const t=e||ei();this.setInitialReferrer(t),this.setInitialReferringDomain(Ur(t))}}isPersistenceEnabledForStorageEntry(e){return Ti(cn.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){const e=cn.storage.entries.value,t=[nr,rr,ir];Object.keys(e).forEach(n=>{const r=n,i=e[r]?.type,s=this.storeManager?.getStore(gr[i]);s&&t.forEach(e=>{const t=this.storeManager?.getStore(gr[e]);if(t&&e!==i){const e=t.get(ar[r]);(e=>A(e)&&""!==e)(e)&&s.set(ar[r],e),t.remove(ar[r])}})})}migrateStorageIfNeeded(e,t){if(!cn.storage.migrate.value)return;let n=e??[];if(0===n.length){[lr,ur,cr].forEach(e=>{const t=this.storeManager?.getStore(e);t&&n.push(t)})}(t??Object.keys(ar)).forEach(e=>{const t=ar[e];n.forEach(e=>{const n=this.pluginsManager?.invokeSingle("storage.migrate",t,e.engine,this.errorHandler,this.logger);I(n)||e.set(t,n)})})}getConfiguredSessionTrackingInfo(){let e,t=!1!==cn.loadOptions.value.sessions.autoTrack;if(!t)return{autoTrack:t};const n=cn.loadOptions.value.sessions?.timeout;bi(n)?e=n:(this.logger.warn(((e,t,n)=>`${e}${pe}The session timeout value "${t}" is not a number. The default timeout of ${n} ms will be used instead.`)(Z,n,Ne)),e=Ne),0===e&&(this.logger.warn(`${Z}${pe}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.`),t=!1),e>0&&e<1e4&&this.logger.warn(((e,t,n)=>`${e}${pe}The session timeout value ${t} ms is less than the recommended minimum of ${n} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`)(Z,e,1e4));return{timeout:e,autoTrack:t,cutOff:this.getCutOffInfo(e)}}getCutOffInfo(e){const t=cn.loadOptions.value.sessions.cutOff;let n,r=!1;return!0===t.enabled&&(n=t.duration,r=!0,bi(n)?n<e&&(this.logger.warn(((e,t,n)=>`${e}${pe}The session cut off duration value "${t}" ms is less than the session timeout value "${n}" ms. The cut off functionality will be disabled.`)(Z,n,e)),r=!1):(this.logger.warn(((e,t,n)=>`${e}${pe}The session cut off duration value "${t}" is not a number. The default cut off duration of ${n} ms will be used instead.`)(Z,n,Le)),n=Le)),{enabled:r,duration:n}}onError(e,t,n){this.errorHandler.onError({error:e,context:Z,customMessage:t,groupingHash:n})}getEncryptedCookieData(e,t){const n=[];
1return e.forEach(e=>{const r=t?.encrypt(Ee(e.value,!1,[],this.logger));A(r)&&n.push({name:e.name,value:r})}),n}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:cn.serverCookies.dataServiceUrl.value,options:{method:"POST",data:Ee({reqType:"setCookies",workspaceId:cn.source.value?.workspaceId,data:{options:{maxAge:cn.storage.cookie.value?.maxage,path:cn.storage.cookie.value?.path,domain:cn.storage.cookie.value?.domain,sameSite:cn.storage.cookie.value?.samesite,secure:cn.storage.cookie.value?.secure,expires:cn.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:t})}setServerSideCookies(e,t,n){const r=Object.keys(e),i=()=>r.map(t=>({name:e[t].name,value:cn.session[t].value})),s={};r.forEach(t=>{s[e[t].name]=n?.get(e[t].name)});const o=()=>{r.forEach(e=>{this.serverSideCookiesRequestInProgress[e]=!1})},a=()=>{i().forEach(e=>{t&&t(e.name,e.value)})};try{const l={};r.forEach(t=>{l[e[t].name]=cn.session[t].value});const u=this.getEncryptedCookieData(i(),n);u.length>0?this.makeRequestToSetCookie(u,(e,r)=>{var u;o(),200===r?.xhr?.status?i().forEach(e=>{const r=s[e.name],i=n?.get(e.name);Ee(l[e.name],!1,[])!==Ee(i,!1,[])&&(S(r)&&S(i)&&this.logger.error(`The server failed to set the ${e.name} cookie. As a fallback, the cookies will be set client side.`),t&&t(e.name,e.value))}):(this.logger.error((u=r?.xhr?.status,`The server responded with status ${u} while setting the cookies. As a fallback, the cookies will be set client side.`)),a())}):(a(),o())}catch(e){this.onError(e,Ct,Ct),a(),o()}}syncValueToStorage(e){const t=cn.storage.entries.value,n=t[e]?.type;if(Ti(n)){const r=this.storeManager.getStore(gr[n]),i=t[e]?.key,s=cn.session[e].value;s&&(E(s)||_(s))?cn.serverCookies.isEnabledServerSideCookies.value&&n===nr?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{const t={[e]:{name:i}};this.setServerSideCookies(t,(e,t)=>{r?.set(e,t)},r)},10)):r?.set(i,s):r?.remove(i)}}registerEffects(){dr.forEach(e=>{pt(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let n=e;if(E(e)&&n||(n=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")){if(!n&&t){const e=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t);n=e}n=n||Ai()}else n=Vt.anonymousId;cn.session.anonymousId.value=n}getAnonymousId(e){const t=cn.storage.entries.value.anonymousId?.type;if(Ti(t)){let t=cn.session.anonymousId.value;if(t&&t!==Vt.anonymousId||(t=this.getEntryValue("anonymousId")),!t&&e){const n=this.pluginsManager?.invokeSingle("storage.getAnonymousId",Dr,e);t=n}cn.session.anonymousId.value=t||Ai()}return cn.session.anonymousId.value}getEntryValue(e){const t=cn.storage.entries.value,n=t[e]?.type;if(Ti(n)){const r=this.storeManager?.getStore(gr[n]);this.migrateStorageIfNeeded([r],[e]);const i=t[e]?.key;return r?.get(i)??null}return null}getExternalAnonymousIdByCookieName(e){const t=Dr(nr);return t?.isEnabled?t.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?cn.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(){const e=this.getSessionInfo()??Vt.sessionInfo;return e.autoTrack&&!Si(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??Vt.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=cn.session.sessionInfo.value),void 0===e.sessionStart?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),cn.session.sessionInfo.value=e,"readyExecuted"!==cn.lifecycle.status.value&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){const e=cn.session,{manualTrack:t,autoTrack:n,timeout:r,cutOff:i}=e.sessionInfo.value;if(n){const t={...Vt.sessionInfo,timeout:r};i&&(t.cutOff={enabled:i.enabled,duration:i.duration}),e.sessionInfo.value=t,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){const{session:t}=cn,n=(e=>{if("boolean"==typeof e){const{entries:t,...n}=Wt;return{...n,entries:{...t,anonymousId:e}}}return P(e)&&P(e.entries)?D(Wt,e):{...Wt}})(e);
1We(()=>{Object.keys(Vt).forEach(e=>{const r=e;if(!0===n.entries[r])switch(e){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[r].value=Vt[r]}})})}setUserId(e){cn.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:Vt.userId}setUserTraits(e){cn.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&P(e)?D(cn.session.userTraits.value??Vt.userTraits,e):Vt.userTraits}setGroupId(e){cn.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:Vt.groupId}setGroupTraits(e){cn.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&P(e)?D(cn.session.groupTraits.value??Vt.groupTraits,e):Vt.groupTraits}setInitialReferrer(e){cn.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:Vt.initialReferrer}setInitialReferringDomain(e){cn.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:Vt.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if(Si(e))t=(e=>{const{timeout:t,cutOff:n}=e,r=Date.now();return{id:r,expiresAt:r+t,timeout:t,autoTrack:!0,...n&&{cutOff:n}}})(e);else{const n=Date.now(),r=e.timeout;t.expiresAt=n+r}if(Ei(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){const e=(e=>{if(e?.enabled)return e.expiresAt??(bi(e.duration)?Date.now()+e.duration:void 0)})(t.cutOff);t.cutOff.expiresAt=e}cn.session.sessionInfo.value=t}start(e){cn.session.sessionInfo.value=Ii(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){cn.session.sessionInfo.value=Vt.sessionInfo}setAuthToken(e){cn.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:Vt.authToken}}const Li=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],Ni="dataplaneEventsQueue",xi="destinationsEventsQueue",Mi=(e,t)=>{const n=g(e),r=t.nativeDestinations.integrationsConfig.value,i=((e,t)=>Object.keys(e).filter(n=>!0!==e[n]||!t[n]).reduce((t,n)=>{const r=g(t);return r[n]=e[n],r},{}))(e.integrations,r);return n.integrations=D(r,i),n},Ui=(e,t,n,r)=>{if(T(e))if(b(e))try{e(...t)}catch(e){r.error(`${n}${pe}The callback threw an exception`,e)}else r.error(At(n))};class Bi{constructor(e,t,n,r,i){this.pluginsManager=e,this.errorHandler=r,this.httpClient=n,this.logger=i,this.storeManager=t}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${Ni}.init`,cn,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle("transformEvent.init",cn,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${xi}.init`,cn,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),pt(()=>{!0===cn.nativeDestinations.clientDestinationsReady.value&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});const e=(e=>e.consents.preConsent.value.enabled&&"buffer"===e.consents.preConsent.value.events?.delivery)(cn);let t;pt(()=>{const n=!0===cn.loadOptions.value.bufferDataPlaneEventsUntilReady&&!1===cn.nativeDestinations.clientDestinationsReady.value;!1!==cn.nativeDestinations.activeDestinations.value.some(e=>{return t=e,Boolean("hybrid"===t.config.connectionMode||!0===t.config.useNativeSDKToSend);var t})&&!1!==n||e||!0===this.dataplaneEventsQueue?.scheduleTimeoutActive||(globalThis.clearTimeout(t),this.dataplaneEventsQueue?.start())}),!0===cn.loadOptions.value.bufferDataPlaneEventsUntilReady&&(t=globalThis.setTimeout(()=>{!0!==this.dataplaneEventsQueue?.scheduleTimeoutActive&&this.dataplaneEventsQueue?.start()},cn.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){!0!==this.dataplaneEventsQueue?.scheduleTimeoutActive&&(cn.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,t){const n=Mi(e,cn);this.pluginsManager.invokeSingle(`${Ni}.enqueue`,cn,this.dataplaneEventsQueue,n,this.errorHandler,this.logger);const r=g(e);this.pluginsManager.invokeSingle(`${xi}.enqueue`,cn,this.destinationsEventsQueue,r,this.errorHandler,this.logger);const i=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${Q}`;Ui(t,[n],i,this.logger)}}const ji=e=>{const t=new CustomEvent(e,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(t)};class Gi{constructor(){this.preloadBuffer=new ft,this.initialized=!1,this.errorHandler=Gn,this.logger=mt,this.customContextStore=new yi(cn.customContext,this.logger),this.externalSrcLoader=new Fe(this.logger),this.httpClient=On,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new ai(this.httpClient,this.errorHandler,this.logger)}load(e,t,n={}){if(cn.lifecycle.status.value)return;if(!(e=>E(e)&&e.trim().length>0)(e))return void this.logger.error(((e,t)=>`${e}${pe}The write key "${t}
1" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`)(re,e));if(!(e=>jr(e))(t))return void this.logger.error(((e,t)=>`${e}${pe}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.`)(re,t));const{context:r,...i}=n,s=Ie(i);void 0!==r&&this.customContextStore.set(r),We(()=>{cn.lifecycle.writeKey.value=g(e),cn.lifecycle.dataPlaneUrl.value=g(t),cn.loadOptions.value=((e,t)=>{const n=g(t);return E(n.setCookieDomain)||(n.setCookieDomain=void 0),["Strict","Lax","None"].includes(n.sameSiteCookie)||(n.sameSiteCookie=void 0),n.secureCookie=x(n.secureCookie,e.secureCookie),n.sameDomainCookiesOnly=x(n.sameDomainCookiesOnly,e.sameDomainCookiesOnly),["none","default","full"].includes(n.uaChTrackLevel)||(n.uaChTrackLevel=void 0),n.integrations=N(n.integrations),Array.isArray(n.plugins)||(n.plugins=Li),n.useGlobalIntegrationsConfigInEvents=x(n.useGlobalIntegrationsConfigInEvents,e.useGlobalIntegrationsConfigInEvents),n.bufferDataPlaneEventsUntilReady=x(n.bufferDataPlaneEventsUntilReady,e.bufferDataPlaneEventsUntilReady),n.sendAdblockPage=x(n.sendAdblockPage,e.sendAdblockPage),n.useServerSideCookies=x(n.useServerSideCookies,e.useServerSideCookies),E(n.dataServiceEndpoint)||(n.dataServiceEndpoint=void 0),n.sendAdblockPageOptions=N(n.sendAdblockPageOptions),n.loadIntegration=x(n.loadIntegration,e.loadIntegration),_(n.storage)?(n.storage.migrate=x(n.storage.migrate,e.storage?.migrate),n.storage.cookie=N(n.storage.cookie),n.storage.encryption=N(n.storage.encryption),n.storage=L(n.storage)):n.storage=void 0,n.destinationsQueueOptions=N(n.destinationsQueueOptions),n.queueOptions=N(n.queueOptions),n.lockIntegrationsVersion=x(n.lockIntegrationsVersion,e.lockIntegrationsVersion),n.lockPluginsVersion=x(n.lockPluginsVersion,e.lockPluginsVersion),mi(n.dataPlaneEventsBufferTimeout)||(n.dataPlaneEventsBufferTimeout=void 0),n.beaconQueueOptions=N(n.beaconQueueOptions),n.preConsent=N(n.preConsent),n.sourceConfigurationOverride=N(n.sourceConfigurationOverride),D(e,L(n))})(cn.loadOptions.value,s),cn.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(cn.loadOptions.value.logLevel??yt),Me("state",cn,e),this.startLifecycle()}setCustomContext(e){cn.lifecycle.loaded.value?this.customContextStore.set(e):cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,["setCustomContext",e]]}getCustomContext(){return this.customContextStore.get()}clearCustomContext(){cn.lifecycle.loaded.value?this.customContextStore.clear():cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,["clearCustomContext"]]}startLifecycle(){pt(()=>{try{switch(cn.lifecycle.status.value){case"mounted":this.onMounted();break;case"browserCapabilitiesReady":this.onBrowserCapabilitiesReady();break;case"configured":this.onConfigured();break;case"pluginsLoading":case"destinationsLoading":case"readyExecuted":default: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(e){const t="Failed to load the SDK";this.errorHandler.onError({error:e,context:re,customMessage:t,groupingHash:t})}})}onBrowserCapabilitiesReady(){je(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),!0===cn.consents.preConsent.value.enabled?cn.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(e=>this.preloadBuffer.enqueue(g(e)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){const e=this.preloadBuffer.dequeue();e&&Ge([...e],this)}}prepareInternalServices(){this.pluginsManager=new tr(Hn,this.errorHandler,this.logger),this.storeManager=new Rr(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Yr(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Ri(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Bi(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new $i(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){cn.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(cn.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),cn.consents.enabled.value&&!cn.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",cn,this.logger),!1===cn.consents.preConsent.value.enabled&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",cn,this.storeManager,this.logger)),this.eventManager?.init(),cn.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),We(()=>{cn.lifecycle.loaded.value=!0,cn.lifecycle.status.value="loaded"}),this.initialized=!0;const e=cn.loadOptions.value.onLoaded;Ui(e,[globalThis.rudderanalytics],ne,this.logger),ji("RSA_Initialised")}onReady(){cn.lifecycle.status.value="readyExecuted",cn.eventBuffer.readyCallbacksArray.value.forEach(e
1=>{Ui(e,[],te,this.logger)}),ji("RSA_Ready")}processBufferedEvents(){let e=cn.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){const t=e.shift();cn.eventBuffer.toBeProcessedArray.value=e,t&&this.processBufferedEvent(t),e=cn.eventBuffer.toBeProcessedArray.value}}processBufferedEvent(e){switch(e[0]){case"setCustomContext":this.setCustomContext(e[1]);break;case"clearCustomContext":this.clearCustomContext();break;case"ready":this.ready(e[1],!0);break;case"page":this.page(e[1],!0,e[2]);break;case"track":this.track(e[1],!0,e[2]);break;case"identify":this.identify(e[1],!0,e[2]);break;case"alias":this.alias(e[1],!0,e[2]);break;case"group":this.group(e[1],!0,e[2]);break;case"reset":this.reset(e[1],!0);break;case"setAnonymousId":this.setAnonymousId(e[1],e[2],!0);break;case"startSession":this.startSession(e[1],!0);break;case"endSession":this.endSession(!0);break;case"consent":this.consent(e[1],!0);break;case"addCustomIntegration":this.addCustomIntegration(e[1],e[2],!0);break;default:return e}}getInvocationContext(e){if(void 0===e)return this.customContextStore.get();return vi(e,this.logger)??{}}loadDestinations(){if("destinationsLoading"===cn.lifecycle.status.value||!0===cn.nativeDestinations.clientDestinationsReady.value)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",cn,this.pluginsManager,this.errorHandler,this.logger);const e=cn.nativeDestinations.activeDestinations.value.length;0!==e?(cn.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",cn,this.externalSrcLoader,this.errorHandler,this.logger),pt(()=>{cn.nativeDestinations.initializedDestinations.value.length+cn.nativeDestinations.failedDestinations.value.length===e&&We(()=>{cn.lifecycle.status.value="destinationsReady",cn.nativeDestinations.clientDestinationsReady.value=!0})})):We(()=>{cn.nativeDestinations.clientDestinationsReady.value=!0,cn.lifecycle.status.value="destinationsReady"})}onDestinationsReady(){"ready"!==cn.lifecycle.status.value&&We(()=>{cn.lifecycle.status.value="ready"})}ready(e,t=!1){const n="ready";cn.lifecycle.loaded.value?(this.errorHandler.leaveBreadcrumb(`New ${n} invocation`),b(e)?"readyExecuted"===cn.lifecycle.status.value?Ui(e,[],te,this.logger):cn.eventBuffer.readyCallbacksArray.value=[...cn.eventBuffer.readyCallbacksArray.value,e]:this.logger.error(At(te))):cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[n,e]]}page(e,t=!1,n){const r="page";if(!cn.lifecycle.loaded.value)return void(cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[r,e]]);const i=this.getInvocationContext(n);this.errorHandler.leaveBreadcrumb(`New ${r} event`),cn.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback},i),!0===cn.capabilities.isAdBlocked.value&&e.category!==De&&this.page(G(De,"ad-block page request",{path:"/ad-blocked"},cn.loadOptions.value.sendAdblockPageOptions),t,i)}track(e,t=!1,n){const r="track";if(!cn.lifecycle.loaded.value)return void(cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[r,e]]);const i=this.getInvocationContext(n);this.errorHandler.leaveBreadcrumb(`New ${r} event - ${e.name}`),cn.metrics.triggered.value+=1,this.eventManager?.addEvent({type:r,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback},i)}identify(e,t=!1,n){const r="identify";if(!cn.lifecycle.loaded.value)return void(cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[r,e]]);const i=this.getInvocationContext(n);this.errorHandler.leaveBreadcrumb(`New ${r} event`),cn.metrics.triggered.value+=1;Boolean(e.userId&&cn.session.userId.value&&e.userId!==cn.session.userId.value)&&this.reset(),S(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:r,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback},i)}alias(e,t=!1,n){const r="alias";if(!cn.lifecycle.loaded.value)return void(cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[r,e]]);const i=this.getInvocationContext(n);this.errorHandler.leaveBreadcrumb(`New ${r} event`),cn.metrics.triggered.value+=1;const s=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:r,to:e.to,from:s,options:e.options,callback:e.callback},i)}group(e,t=!1,n){const r="group";if(!cn.lifecycle.loaded.value)return void(cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[r,e]]);const i=this.getInvocationContext(n);this.errorHandler.leaveBreadcrumb(`New ${r} event`),cn.metrics.triggered.value+=1,S(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:r,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback},i)}reset(e,t=!1){const n="reset";cn.lifecycle.loaded.value?(this.errorHandler.leaveBreadcrumb(`New ${n} invocation`),this.userSessionManager?.reset(e)):cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[n,e]]}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,t,n=!1){const r="setAnonymousId";cn.lifecycle.loaded.value?(this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,t)):cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[r,e,t]]}getUserId(){return cn.session.userId.value}getUserTraits(){return cn.session.userTraits.value}getGroupId(){return cn.session.groupId.value}getGroupTraits(){return cn.session.groupTraits.value}startSession(e,t=!1){const n="startSession";cn.lifecycle.loaded.value?(this.errorHandler.leaveBreadcrumb(`New ${n} invocation`),this.userSessionManager?.start(e)):cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[n,e]]}endSession(e=!1){const t="endSession";cn.lifecycle.loaded.value?(this.errorHandler.leaveBreadcrumb(`New ${t} invocation`),this.userSessionManager?.end()):cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[t]]}getSessionId(){const e=this.userSessionManager?.getSessionId();return e??null}consent(e,t=!1){cn.lifecycle.loaded.value?(this.errorHandler.leaveBreadcrumb("New consent invocation"),We(()=>{cn.consents.preConsent.value={...cn.consents.preConsent.value,enabled:!1},cn.consents.postConsent.value=(e=>{const t={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(P(e)){const n=g(e);t.storage=n.storage,_(n.integrations)&&(t.integrations=n.integrations),t.discardPreConsentEvents=!0===n.discardPreConsentEvents,t.sendPageEvent=!0===n.sendPageEvent,t.trackConsent=!0===n.trackConsent,_(n.consentManagement)&&(t.consentManagement=D(n.consentManagement,{enabled:cn.consents.enabled.value}))}return t})(e);const{initialized:t,consentsData:n}=Vr(cn.consents.postConsent.value.consentManagement,this.logger);cn.consents.initialized.value=t,cn.consents.data.value=n}),cn.consents.enabled.value&&!cn.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",cn,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(t)):cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,["consent",e]]}sendTrackingEvents(e){if(cn.consents.postConsent.value.trackConsent){const t=H("Consent Management Interaction");e?cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,["track",t,this.customContextStore.get()]]:this.track(t)}if(cn.consents.postConsent.value.sendPageEvent){const t=G();e?cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,["page",t,this.customContextStore.get()]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,n=!1){const r="addCustomIntegration";if(n)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,cn,this.logger);else{if(cn.lifecycle.loaded.value)return void this.logger.error(((e,t)=>`${e}${pe}Cannot add custom integration for destination ID "${t}" after the SDK is loaded.`)(re,e));cn.eventBuffer.toBeProcessedArray.value=[...cn.eventBuffer.toBeProcessedArray.value,[r,e,t]]}}}class Hi{static globalSingleton=null;analyticsInstances={};defaultAnalyticsKey="";logger=mt;constructor(){try{if(Hi.globalSingleton)return Hi.globalSingleton;Hi.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.setCustomContext=this.setCustomContext.bind(this),this.getCustomContext=this.getCustomContext.bind(this),this.clearCustomContext=this.clearCustomContext.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.get
1SessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),Hi.globalSingleton=this,cn.autoTrack.pageLifecycle.pageViewId.value=de(),cn.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){Ce(e)}}createSafeAnalyticsInstance(){cn.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(){Gn.init(),Or.configure(),Cr.configure(),Pr.configure(),br.configure()}setDefaultInstanceKey(e){E(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;E(t)&&t||(t=this.defaultAnalyticsKey);return Boolean(this.analyticsInstances[t])||(this.analyticsInstances[t]=new Gi),this.analyticsInstances[t]}catch(e){return void Ce(e)}}load(e,t,n){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(n);const r=Ue(_e);(e=>{const t="consent",n=e.filter(e=>e[0]===t),r=e.filter(e=>e[0]!==t);e.splice(0,e.length,...n,...r)})(r),Me(_e,g(r)),this.getAnalyticsInstance(e)?.load(e,t,n)}catch(e){Ce(e)}}trackPageLifecycleEvents(e){const{autoTrack:t,useBeacon:n}=e??{},{enabled:r=!1,options:i={},pageLifecycle:s}=t??{},{events:o=[W.UNLOADED],enabled:a=r,options:l=i}=s??{};cn.autoTrack.pageLifecycle.enabled.value=a,cn.autoTrack.enabled.value=r||a,a&&this.setupPageUnloadTracking(o,n,l)}setupPageUnloadTracking(e,t,n){(0===e.length||e.includes(W.UNLOADED))&&(!0===t?ge(e=>{if(!1===e&&cn.lifecycle.loaded.value){const e=Date.now(),t=e-cn.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(W.UNLOADED,{timeOnPage:t},{...n,originalTimestamp:he(new Date(e))})}},!0):this.logger.warn(`${"RudderStackAnalytics"}${pe}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`))}triggerBufferedLoadEvent(){const e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=(e=>{let t=[],n=0;for(;n<e.length;){if(e[n]&&"load"===e[n][0]){t=g(e[n]),e.splice(n,1);break}n+=1}return t})(e);Me(_e,g([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(Ie(e))}catch(e){Ce(e)}}page(e,t,n,r,i){try{this.getAnalyticsInstance()?.page(G(Ie(e),Ie(t),Ie(n),Ie(r),Ie(i)))}catch(e){Ce(e)}}track(e,t,n,r){try{this.getAnalyticsInstance()?.track(H(Ie(e),Ie(t),Ie(n),Ie(r)))}catch(e){Ce(e)}}identify(e,t,n,r){try{this.getAnalyticsInstance()?.identify(F(Ie(e),Ie(t),Ie(n),Ie(r)))}catch(e){Ce(e)}}alias(e,t,n,r){try{this.getAnalyticsInstance()?.alias(K(Ie(e),Ie(t),Ie(n),Ie(r)))}catch(e){Ce(e)}}group(e,t,n,r){try{this.getAnalyticsInstance()?.group(V(Ie(e),Ie(t),Ie(n),Ie(r)))}catch(e){Ce(e)}}reset(e){try{this.getAnalyticsInstance()?.reset(Ie(e))}catch(e){Ce(e)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(Ie(e))}catch(e){return void Ce(e)}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(Ie(e),Ie(t))}catch(e){Ce(e)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){return void Ce(e)}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){return void Ce(e)}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){return void Ce(e)}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){return void Ce(e)}}setCustomContext(e){try{this.getAnalyticsInstance()?.setCustomContext(e)}catch(e){Ce(e)}}getCustomContext(){try{return this.getAnalyticsInstance()?.getCustomContext()??{}}catch(e){return Ce(e),{}}}clearCustomContext(){try{this.getAnalyticsInstance()?.clearCustomContext()}catch(e){Ce(e)}}startSession(e){try{this.getAnalyticsInstance()?.startSession(Ie(e))}catch(e){Ce(e)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){Ce(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){return void Ce(e)}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(Ie(e))}catch(e){Ce(e)}}consent(e){try{this.getAnalyticsInstance()?.consent(Ie(e))}catch(e){Ce(e)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(Ie(e),Ie(t))}catch(e){Ce(e)}}}var Fi=null,Ki=function(){return null===Fi&&(Fi=new Promise(function(e){var t=new Hi;t.load(window.rudderstackClientSecret,window.rudderstackDataPlaneUrl),t.ready(function(){e(t)})})),Fi};function Vi(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(n,r,i,s){var l=r&&r.prototype instanceof a?r:a,u=Object.create(l.prototype);return Wi(u,"_invoke",function(n,r,i){var s,a,l,u=0,c=i||[],d=!1,g={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return s=t,a=0,l=e,g.n=n,o}};function h(n,r){for(a=n,l=r,t=0;!d&&u&&!i&&t<c.length;t++){var i,s=c[t],h=g.p,p=s[2];n>3?(i=p===r)&&(l=s[(a=s[4])?5:(a=3,3)],s[4]=s[5]=e):s[0]<=h&&((i=n<2&&h<s[1])?(a=0,g.v=r,g.n=s[1]):h<p&&(i=n<3||s[0]>r||r>p)&&(s[4]=n,s[5]=r,g.n=p,a=0))}if(i||n>1)return o;throw d=!0,r}return function(i,c,p){if(u>1)throw TypeError("Generator is already running");for(d&&1===c&&h(c,p),a=c,l=p;(t=a<2?e:l)||!d;
vendor: 5,462 bytes, line 1
1){s||(a?a<3?(a>1&&(g.n=-1),h(a,l)):g.n=l:g.v=l);try{if(u=2,s){if(a||(i="next"),t=s[i]){if(!(t=t.call(s,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,a<2&&(a=0)}else 1===a&&(t=s.return)&&t.call(s),a<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),a=1);s=e}else if((t=(d=g.n<0)?l:n.call(r,g))!==o)break}catch(t){s=e,a=1,l=t}finally{u=1}}return{value:t,done:d}}}(n,i,s),!0),u}var o={};function a(){}function l(){}function u(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Wi(t={},r,function(){return this}),t),d=u.prototype=a.prototype=Object.create(c);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,Wi(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=u,Wi(d,"constructor",u),Wi(u,"constructor",l),l.displayName="GeneratorFunction",Wi(u,i,"GeneratorFunction"),Wi(d),Wi(d,i,"Generator"),Wi(d,r,function(){return this}),Wi(d,"toString",function(){return"[object Generator]"}),(Vi=function(){return{w:s,m:g}})()}function Wi(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Wi=function(e,t,n,r){function s(t,n){Wi(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(s("next",0),s("throw",1),s("return",2))},Wi(e,t,n,r)}function Qi(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function zi(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(e){Qi(s,r,i,o,a,"next",e)}function a(e){Qi(s,r,i,o,a,"throw",e)}o(void 0)})}}function qi(e){return qi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qi(e)}function Ji(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Xi(r.key),r)}}function Xi(e){var t=function(e,t){if("object"!=qi(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=qi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==qi(t)?t:t+""}var Zi=new Set([e.SIGNUP_STARTED,e.SOURCE_SELECTED,e.VISITED_MARKETING_HOMEPAGE,e.LANGUAGE_SELECTED,e.LANGUAGE_SELECTED_SUCCESS,e.LEVEL_SELECTED,e.LEVEL_SELECTED_SUCCESS,e.AGE_SELECTED,e.AGE_SELECTED_SUCCESS,e.SOURCE_SELECTED,e.SOURCE_SELECTED_SUCCESS,e.DAILY_GOAL_SELECTED,e.DAILY_GOAL_SELECTED_SUCCESS,e.EMAIL_FORM_PAGE,e.PASSWORD_FORM_PAGE,e.PLAN_SELECTED,e.DOWNLOAD_APP_PAGE,e.PICK_FAVORITE_GENRES,e.PICK_VIDEO_TO_GET_STARTED,e.QUICK_WORD_LOOK_UP_IN_FIRST_5_DAYS_OF_TRIAL,e.DETAILED_WORD_LOOK_UP_IN_FIRST_5_DAYS_OF_TRIAL,e.VIEWED_CHECKOUT_PAGE]);var Yi,es=function(e,t,n){return t&&Ji(e.prototype,t),n&&Ji(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.clientProvider=t},[{key:"identify",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;this.clientProvider.identify(e,t,n,r)}},{key:"track",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;t=e,Zi.has(t)||this.clientProvider.track(e,n,r,i)}},{key:"page",value:function(e,t){}},{key:"group",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;this.clientProvider.group(e,t,n,r)}},{key:"alias",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;this.clientProvider.alias(e,t,n,r)}},{key:"reset",value:function(){this.clientProvider.reset()}},{key:"getUserId",value:function(){return this.clientProvider.getUserId()}},{key:"getAnonymousId",value:function(){return this.clientProvider.getAnonymousId()}},{key:"getUserTraits",value:function(){return this.clientProvider.getUserTraits()}}]),ts=null,ns=(Yi=zi(Vi().m(function e(){return Vi().w(function(e){for(;;)if(0===e.n)return null===ts&&(ts=zi(Vi().m(function e(){var t;return Vi().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,Ki();case 1:return t=e.v,e.a(2,new es(t))}},e)}))()),e.a(2,ts)},e)})),function(){return Yi.apply(this,arguments)});function rs(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(n,r,i,s){var l=r&&r.prototype instanceof a?r:a,u=Object.create(l.prototype);return is(u,"_invoke",function(n,r,i){var s,a,l,u=0,c=i||[],d=!1,g={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return s=t,a=0,l=e,g.n=n,o}};function h(n,r){for(a=n,l=r,t=0;!d&&u&&!i&&t<c.length;t++){var i,s=c[t],h=g.p,p=s[2];n>3?(i=p===r)&&(l=s[(a=s[4])?5:(a=3,3)],s[4]=s[5]=e):s[0]<=h&&((i=n<2&&h<s[1])?(a=0,g.v=r,g.n=s[1]):h<p&&(i=n<3||s[0]>r||r>p)&&(s[4]=n,s[5]=r,g.n=p,a=0))}if(i||n>1)return o;throw d=!0,r}return function(i,c,p){if(u>1)throw TypeError("Generator is already running");for(d&&1===c&&h(c,p),a=c,l=p;(t=a<2?e:l)||!d;
1){s||(a?a<3?(a>1&&(g.n=-1),h(a,l)):g.n=l:g.v=l);try{if(u=2,s){if(a||(i="next"),t=s[i]){if(!(t=t.call(s,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,a<2&&(a=0)}else 1===a&&(t=s.return)&&t.call(s),a<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),a=1);s=e}else if((t=(d=g.n<0)?l:n.call(r,g))!==o)break}catch(t){s=e,a=1,l=t}finally{u=1}}return{value:t,done:d}}}(n,i,s),!0),u}var o={};function a(){}function l(){}function u(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(is(t={},r,function(){return this}),t),d=u.prototype=a.prototype=Object.create(c);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,is(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=u,is(d,"constructor",u),is(u,"constructor",l),l.displayName="GeneratorFunction",is(u,i,"GeneratorFunction"),is(d),is(d,i,"Generator"),is(d,r,function(){return this}),is(d,"toString",function(){return"[object Generator]"}),(rs=function(){return{w:s,m:g}})()}function is(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}is=function(e,t,n,r){function s(t,n){is(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(s("next",0),s("throw",1),s("return",2))},is(e,t,n,r)}function ss(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function os(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(e){ss(s,r,i,o,a,"next",e)}function a(e){ss(s,r,i,o,a,"throw",e)}o(void 0)})}}(function(){var e=os(rs().m(function e(t){var n,r;return rs().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ns();case 1:n=e.v,r={platform:"Web"},n.track(t,r);case 2:return e.a(2)}},e)}))})(),as=os(rs().m(function e(t,n,r){return rs().w(function(e){for(;;)switch(e.n){case 0:if(r){e.n=1;break}return e.a(2);case 1:return e.n=2,ns();case 2:e.v.track(t,{page:n,platform:"Web"});case 3:return e.a(2)}},e)})),ls=os(rs().m(function t(){var n,r;return rs().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,ns();case 1:n=t.v,r={platform:"Web",mobile_version_of_website:window.mobileMode},n.track(e.SIGNUP_STARTED,r);case 2:return t.a(2)}},t)})),us=os(rs().m(function e(t,n){var r,i;return rs().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ns();case 1:r=e.v,i={language_selected:n,platform:"Web"},r.track(t,i);case 2:return e.a(2)}},e)})),cs=os(rs().m(function e(t,n){var r,i;return rs().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ns();case 1:r=e.v,i={level_selected:n,platform:"Web"},r.track(t,i);case 2:return e.a(2)}},e)})),ds=os(rs().m(function e(t,n){var r,i;return rs().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ns();case 1:r=e.v,i={age:n,platform:"Web"},r.track(t,i);case 2:return e.a(2)}},e)})),gs=os(rs().m(function e(t,n){var r,i;return rs().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ns();case 1:r=e.v,i={source:n,platform:"Web"},r.track(t,i);case 2:return e.a(2)}},e)})),hs=os(rs().m(function e(t,n){var r,i;return rs().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ns();case 1:r=e.v,i={daily_goal:n,platform:"Web"},r.track(t,i);case 2:return e.a(2)}},e)}));var as,ls,us,cs,ds,gs,hs,ps,fs,vs,ys,ms,bs,Es=(ps=os(rs().m(function e(t,n){var r,i;return rs().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ns();case 1:r=e.v,i={plan_name:n,platform:"Web"},r.track(t,i);case 2:return e.a(2)}},e)})),function(e,t){return ps.apply(this,arguments)});fs=os(rs().m(function t(){var n,r,i,s;return rs().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,ns();case 1:n=t.v,r=window.ACTIVE_LOCALE_NAME[0].toUpperCase()+window.ACTIVE_LOCALE_NAME.substring(1),i=window.ACTIVE_LANGUAGE_NAME[0].toUpperCase()+window.ACTIVE_LANGUAGE_NAME.substring(1),s={platform:"Web",language:r,locale:i},n.track(e.VISITED_MARKETING_HOMEPAGE,s);case 2:return t.a(2)}},t)})),vs=os(rs().m(function t(){var n,r;return rs().w(function(t){for(;;)switch(t.n){case 0:if(!window.currentUserId){t.n=2;break}return t.n=1,ns();case 1:n=t.v,r={platform:"Web"},n.track(e.VIEWED_CHECKOUT_PAGE,r);case 2:return t.a(2)}},t)})),ys=os(rs().m(function t(n,r){var i,s;return rs().w(function(t){for(;;)switch(t.n){case 0:if(!window.currentUserId){t.n=2;break}return t.n=1,ns();case 1:i=t.v,s={genre:n,displayed_genres_name:r,platform:"Web"},i.track(e.PICK_FAVORITE_GENRES,s);case 2:return t.a(2)}},t)})),ms=os(rs().m(function t(n,r,i,s,o,a,l){var u,c;return rs().w(function(t){for(;;)switch(t.n){case 0:if(!window.currentUserId){t.n=2;break}return t.n=1,ns();case 1:u=t.v,c={content_id:n,content_type:r,content_publish_date:i,difficulty:s,displayed_content_name:o,english_content_name:a,language:l.anal
1yticsName,platform:"Web"},u.track(e.PICK_VIDEO_TO_GET_STARTED,c);case 2:return t.a(2)}},t)})),bs=os(rs().m(function t(){var n,r,i,s,o,a,l=arguments;return rs().w(function(t){for(;;)switch(t.n){case 0:return n=l.length>0&&void 0!==l[0]&&l[0],r=l.length>1&&void 0!==l[1]&&l[1],i=l.length>2&&void 0!==l[2]&&l[2],s=l.length>3&&void 0!==l[3]&&l[3],t.n=1,ns();case 1:o=t.v,a={logo_click:n,continue_to_website_click:r,download_on_App_Store_click:s,get_in_on_Google_Play_click:i,platform:"Web"},o.track(e.DOWNLOAD_APP_PAGE,a);case 2:return t.a(2)}},t)}));function Ss(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(n,r,i,s){var l=r&&r.prototype instanceof a?r:a,u=Object.create(l.prototype);return ks(u,"_invoke",function(n,r,i){var s,a,l,u=0,c=i||[],d=!1,g={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return s=t,a=0,l=e,g.n=n,o}};function h(n,r){for(a=n,l=r,t=0;!d&&u&&!i&&t<c.length;t++){var i,s=c[t],h=g.p,p=s[2];n>3?(i=p===r)&&(l=s[(a=s[4])?5:(a=3,3)],s[4]=s[5]=e):s[0]<=h&&((i=n<2&&h<s[1])?(a=0,g.v=r,g.n=s[1]):h<p&&(i=n<3||s[0]>r||r>p)&&(s[4]=n,s[5]=r,g.n=p,a=0))}if(i||n>1)return o;throw d=!0,r}return function(i,c,p){if(u>1)throw TypeError("Generator is already running");for(d&&1===c&&h(c,p),a=c,l=p;(t=a<2?e:l)||!d;){s||(a?a<3?(a>1&&(g.n=-1),h(a,l)):g.n=l:g.v=l);try{if(u=2,s){if(a||(i="next"),t=s[i]){if(!(t=t.call(s,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,a<2&&(a=0)}else 1===a&&(t=s.return)&&t.call(s),a<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),a=1);s=e}else if((t=(d=g.n<0)?l:n.call(r,g))!==o)break}catch(t){s=e,a=1,l=t}finally{u=1}}return{value:t,done:d}}}(n,i,s),!0),u}var o={};function a(){}function l(){}function u(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(ks(t={},r,function(){return this}),t),d=u.prototype=a.prototype=Object.create(c);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,ks(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=u,ks(d,"constructor",u),ks(u,"constructor",l),l.displayName="GeneratorFunction",ks(u,i,"GeneratorFunction"),ks(d),ks(d,i,"Generator"),ks(d,r,function(){return this}),ks(d,"toString",function(){return"[object Generator]"}),(Ss=function(){return{w:s,m:g}})()}function ks(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ks=function(e,t,n,r){function s(t,n){ks(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(s("next",0),s("throw",1),s("return",2))},ks(e,t,n,r)}function Is(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}$(document).ready(function(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(e){Is(s,r,i,o,a,"next",e)}function a(e){Is(s,r,i,o,a,"throw",e)}o(void 0)})}}(Ss().m(function e(){var t;return Ss().w(function(e){for(;;)switch(e.n){case 0:(t=$(".pricing-reviews.js-owl-carousel")).length>0&&t.owlCarousel({items:1,nav:!0,dots:!0,loop:!0,slideBy:2,itemElement:"div",navContainer:".js-carousel-nav",navClass:["js-prev-nav-hidden","js-next-nav-hidden"],onResized:function(){t.trigger("refresh.owl.carousel")},responsive:{750:{items:2},0:{items:1}}});case 1:return e.a(2)}},e)}))),Array.from(document.querySelectorAll(".signup-button__js-continue")).forEac
1h(function(t){t.addEventListener("click",function(){t.dataset.type&&Es(e.PLAN_SELECTED,t.dataset.type)})}),pricing={}})();
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.