UNPKG

@deriv-com/analytics

Version:

Comprehensive analytics package for Deriv applications. Provides unified event tracking, A/B testing, and user analytics through RudderStack, PostHog and GrowthBook integrations with built-in caching and offline support.

4 lines 371 kB
/* @deriv-com/analytics - Browser IIFE Bundle (RudderStack + PostHog) - Built with tsup */ "use strict";var DerivAnalytics=(()=>{var $s=Object.defineProperty;var Bg=Object.getOwnPropertyDescriptor;var Vg=Object.getOwnPropertyNames;var Gg=Object.prototype.hasOwnProperty;var qg=(t,e,i)=>e in t?$s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var Ue=(t,e)=>()=>(t&&(e=t(t=0)),e);var Sn=(t,e)=>{for(var i in e)$s(t,i,{get:e[i],enumerable:!0})},jg=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Vg(e))!Gg.call(t,r)&&r!==i&&$s(t,r,{get:()=>e[r],enumerable:!(s=Bg(e,r))||s.enumerable});return t};var Hg=t=>jg($s({},"__esModule",{value:!0}),t);var ae=(t,e,i)=>qg(t,typeof e!="symbol"?e+"":e,i);function de(t){return t!=null&&typeof t=="object"&&t["@@functional/placeholder"]===!0}function yt(t){return function e(i){return arguments.length===0||de(i)?e:t.apply(this,arguments)}}function Dt(t){return function e(i,s){switch(arguments.length){case 0:return e;case 1:return de(i)?e:yt(function(r){return t(i,r)});default:return de(i)&&de(s)?e:de(i)?yt(function(r){return t(r,s)}):de(s)?yt(function(r){return t(i,r)}):t(i,s)}}}function ao(t){return function e(i,s,r){switch(arguments.length){case 0:return e;case 1:return de(i)?e:Dt(function(n,o){return t(i,n,o)});case 2:return de(i)&&de(s)?e:de(i)?Dt(function(n,o){return t(n,s,o)}):de(s)?Dt(function(n,o){return t(i,n,o)}):yt(function(n){return t(i,s,n)});default:return de(i)&&de(s)&&de(r)?e:de(i)&&de(s)?Dt(function(n,o){return t(n,o,r)}):de(i)&&de(r)?Dt(function(n,o){return t(n,s,o)}):de(s)&&de(r)?Dt(function(n,o){return t(i,n,o)}):de(i)?yt(function(n){return t(n,s,r)}):de(s)?yt(function(n){return t(i,n,r)}):de(r)?yt(function(n){return t(i,s,n)}):t(i,s,r)}}}function Fs(t,e){return Object.prototype.hasOwnProperty.call(e,t)}function Ml(t){return Object.prototype.toString.call(t)==="[object Object]"}function Wg(t,e){var i=t<0?e.length+t:t;return e[i]}function Yg(t){return new RegExp(t.source,t.flags?t.flags:(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":"")+(t.dotAll?"s":""))}function yu(t,e,i){if(i||(i=new Jg),Xg(t))return t;var s=function(n){var o=i.get(t);if(o)return o;i.set(t,n);for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(n[a]=yu(t[a],!0,i));return n};switch(zg(t)){case"Object":return s(Object.create(Object.getPrototypeOf(t)));case"Array":return s(Array(t.length));case"Date":return new Date(t.valueOf());case"RegExp":return Yg(t);case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return t.slice();default:return t}}function Xg(t){var e=typeof t;return t==null||e!="object"&&e!="function"}function Qg(t,e){for(var i=e,s=0;s<t.length;s+=1){if(i==null)return;var r=t[s];Kg(r)?i=Wg(r,i):i=i[r]}return i}function mf(t){return crypto.getRandomValues(new Uint8Array(t))}function yf(){(!An||Nt+16>Bl)&&(An=mf(Bl),Nt=0);for(var t=0,e,i="";t<16;t++)e=An[Nt+t],t==6?i+=Vs[e&15|64]:t==8?i+=Vs[e&63|128]:i+=Vs[e],t&1&&t>1&&t<11&&(i+="-");return Nt+=16,i}function bf(){var t=0,e,i="";if(!Us||zt+16>256){for(Us=Array(t=256);t--;)Us[t]=256*Math.random()|0;t=zt=0}for(;t<16;t++)e=Us[zt+t],t==6?i+=Gs[e&15|64]:t==8?i+=Gs[e&63|128]:i+=Gs[e],t&1&&t>1&&t<11&&(i+="-");return zt++,i}function Wf(t,e,i=Kf){let s;return(...r)=>{globalThis.clearTimeout(s),s=globalThis.setTimeout(()=>{t.apply(e,r)},i)}}function rr(){if(bt>1)bt--;else{var t,e=!1;for((function(){var r=Qs;for(Qs=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o})();Yi!==void 0;){var i=Yi;for(Yi=void 0,Js++;i!==void 0;){var s=i.u;if(i.u=void 0,i.f&=-3,!(8&i.f)&&Nu(i))try{i.c()}catch(r){e||(t=r,e=!0)}i=s}}if(Js=0,bt--,e)throw t}}function Ie(t){if(bt>0)return t();Ln=++op,bt++;try{return t()}finally{rr()}}function xu(t){var e=J;J=void 0;try{return t()}finally{J=e}}function Du(t){if(J!==void 0){var e=t.n;if(e===void 0||e.t!==J)return e={i:0,S:t,p:J.s,n:void 0,t:J,e:void 0,x:void 0,r:e},J.s!==void 0&&(J.s.n=e),J.s=e,t.n=e,32&J.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=J.s,e.n=void 0,J.s.n=e,J.s=e),e}}function De(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function E(t,e){return new De(t,e)}function Nu(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Lu(t){for(var e=t.s;e!==void 0;e=e.n){var i=e.S.n;if(i!==void 0&&(e.r=i),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function $u(t){for(var e=t.s,i=void 0;e!==void 0;){var s=e.p;e.i===-1?(e.S.U(e),s!==void 0&&(s.n=e.n),e.n!==void 0&&(e.n.p=s)):i=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=s}t.s=i}function vi(t,e){De.call(this,void 0),this.x=t,this.s=void 0,this.g=Zs-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function Fu(t){var e=t.m;if(t.m=void 0,typeof e=="function"){bt++;var i=J;J=void 0;try{e()}catch(s){throw t.f&=-2,t.f|=8,fo(t),s}finally{J=i,rr()}}}function fo(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Fu(t)}function ap(t){if(J!==this)throw new Error("Out-of-order effect");$u(this),J=t,this.f&=-2,8&this.f&&fo(this),rr()}function _i(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name}function ut(t,e){var i=new _i(t,e);try{i.c()}catch(r){throw i.d(),r}var s=i.d.bind(i);return s[Symbol.dispose]=s,s}function Ku(t){if(!t?.includes(":"))return[t||void 0,void 0,void 0];let e=t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1):t,i=Lv.exec(e);return i?[i[1]||void 0,i[2]===void 0?void 0:Number(i[2]),i[3]===void 0?void 0:Number(i[3])]:[void 0,void 0,void 0]}function $v(t){if(!zu.test(t))return null;t.includes("(eval ")&&(t=t.replaceAll("eval code","eval").replaceAll(/(\(eval at [^()]*)|(,.*$)/g,""));let e=t.replace(/^\s+/,"").replaceAll("(eval code","(").replace(/^.*?\s+/,""),i=/ (\(.+\)$)/.exec(e),s=i?e.replace(i[0],""):e,[r,n,o]=Ku(i?i[1]:e);return{functionName:i&&s||void 0,fileName:r==="eval"||r==="<anonymous>"?void 0:r,lineNumber:n,columnNumber:o}}function Fv(t){if(Nv.test(t))return null;if(t.includes(" > eval")&&(t=t.replaceAll(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),!t.includes("@")&&!t.includes(":"))return{functionName:t,fileName:void 0,lineNumber:void 0,columnNumber:void 0};let e=t.lastIndexOf("@"),i=e>0?t.slice(0,e):void 0,[s,r,n]=Ku(t.slice(e+1));return{functionName:i,fileName:s,lineNumber:r,columnNumber:n}}function Mv(t){if(!t.stack)throw new Error("Cannot parse given Error object");let e=t.stack.split(` `);return e.some(i=>zu.test(i))?e.map($v).filter(i=>i!==null):e.map(Fv).filter(i=>i!==null)}function tu(t,e,i,s){return{errorClass:eu(t),message:`${i}${eu(e)}`,type:"browserjs",stacktrace:s.reduce((r,n)=>{let o=Bv(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function ic(t,e){let i=Object.assign(t,e);for(let s of Object.keys(i))typeof i[s]=="object"&&typeof e[s]=="object"&&(i[s]=ic(i[s],e[s]));return i}async function w_(t){let e=S_[t];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((i,s)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=k_();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}i(e.lib)}).catch(s)})})}function Be(t,e){if(!t?.default&&e){let i=Object.create(null);return i.default=t,i.__esModule=!0,i}return t}function Ve(t,e){return w_(t).then(i=>i.get(e).then(s=>s()))}function em(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function im(){return lu||(lu=1,(function(t,e){(function(i,s){t.exports=s()})(tm,function(){function i(g){return g=JSON.stringify(g),!!/^\{[\s\S]*\}$/.test(g)}function s(g){return g===void 0||typeof g=="function"?g+"":JSON.stringify(g)}function r(g){if(typeof g=="string")try{return JSON.parse(g)}catch{return g}}function n(g){return{}.toString.call(g)==="[object Function]"}function o(g){return Object.prototype.toString.call(g)==="[object Array]"}function a(g){var p="_Is_Incognit",v="yes";try{g||(g=window.localStorage),g.setItem(p,v),g.removeItem(p)}catch{var m={};m._data={},m.setItem=function(w,R){return m._data[w]=String(R)},m.getItem=function(w){return m._data.hasOwnProperty(w)?m._data[w]:void 0},m.removeItem=function(w){return delete m._data[w]},m.clear=function(){return m._data={}},g=m}finally{g.getItem(p)===v&&g.removeItem(p)}return g}var l=a();function u(){if(!(this instanceof u))return new u}u.prototype={set:function(p,v){if(p&&!i(p))l.setItem(p,s(v));else if(i(p))for(var m in p)this.set(m,p[m]);return this},get:function(p){if(p===void 0){var v={};return this.forEach(function(b,x){return v[b]=x}),v}if(p.charAt(0)==="?")return this.has(p.substr(1));var m=arguments;if(m.length>1){for(var y={},w=0,R=m.length;w<R;w++){var D=r(l.getItem(m[w]));this.has(m[w])&&(y[m[w]]=D)}return y}return r(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var v=this.get(p);return l.removeItem(p),v},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(v){p.push(v)}),p},forEach:function(p){for(var v=0,m=l.length;v<m;v++){var y=l.key(v);p(y,this.get(y))}return this},search:function(p){for(var v=this.keys(),m={},y=0,w=v.length;y<w;y++)v[y].indexOf(p)>-1&&(m[v[y]]=this.get(v[y]));return m},len:function(){return l.length}};var c=null;function h(g,p){var v=arguments,m=null;if(c||(c=u()),v.length===0)return c.get();if(v.length===1){if(typeof g=="string")return c.get(g);if(i(g))return c.set(g)}if(v.length===2&&typeof g=="string"){if(!p)return c.remove(g);if(p&&typeof p=="string")return c.set(g,p);p&&n(p)&&(m=null,m=p(g,c.get(g)),h.set(g,m))}if(v.length===2&&o(g)&&n(p))for(var y=0,w=g.length;y<w;y++)m=p(g[y],c.get(g[y])),h.set(g[y],m);return h}for(var f in u.prototype)h[f]=u.prototype[f];return h})})(Hs)),Hs.exports}var zg,Kg,Jg,W,Zg,ef,tf,sf,bu,N,re,qe,Te,rt,rf,te,hi,nf,lo,of,xn,af,lf,uf,ne,cf,Ae,Et,Hi,Ks,vt,at,uo,df,Ul,Ws,hf,gf,Ys,co,Eu,Su,ku,kn,ho,Dn,Xe,wu,qi,qt,zi,li,ff,wn,pf,vf,_f,Ms,Bl,Vs,Nt,An,zt,Gs,Us,Ef,ir,Sf,kf,wf,Au,Af,V,If,Vl,Tf,Rf,Pf,Of,Cf,xf,Df,Iu,Nf,st,Lf,Tu,X,Ru,sr,go,fe,Gl,Xi,$f,Pu,Ff,ql,Mf,Uf,Wi,Bf,Vf,Gf,jl,qf,Hl,jf,Hf,zl,Nn,Kl,zf,Kf,Ou,Ji,Cu,Wl,Yf,Xf,Jf,Qf,Zf,ep,tp,ip,sp,rp,Xs,np,J,Yi,bt,Js,op,Ln,Qs,Zs,$n,Bs,Yl,Mu,lp,up,cp,Fn,St,_t,Uu,Mn,Xl,dp,hp,gp,fp,pp,vp,_p,mp,Jl,yp,bp,Ep,Sp,kp,wp,Ap,Ql,Ip,Tp,Bu,Rp,Pp,Op,Cp,xp,Dp,Np,Zl,Lp,$p,Fp,Mp,Up,Bp,Vp,Gp,qp,jp,Hp,zp,Kp,Wp,Yp,Xp,Jp,Qp,Zp,ev,tv,iv,sv,rv,nv,ov,av,Vu,nr,Gu,lv,Qi,or,po,qu,ju,Hu,jt,uv,Un,qs,cv,dv,hv,gv,fv,pv,Q,In,vv,_v,mv,yv,bv,Ev,Sv,kv,wv,Av,Iv,Tv,Rv,Pv,Ov,Cv,xv,Dv,d,zu,Nv,Lv,Wu,Uv,Bv,eu,Yu,Vv,iu,js,Gv,qv,jv,Hv,zv,Kv,Wv,Yv,su,ru,Bn,Xu,Xv,Jv,Qv,Zv,e_,t_,i_,Ju,s_,r_,n_,o_,a_,l_,u_,c_,d_,h_,Qu,Zu,g_,f_,p_,v_,Vn,ec,Gn,__,m_,y_,nu,b_,tc,E_,S_,k_,A_,I_,sc,T_,R_,Tn,P_,qn,Ge,He,Ye,lt,Kt,O_,C_,x_,D_,N_,L_,$_,F_,M_,U_,B_,V_,ui,G_,rc,nc,q_,oc,ac,ci,ou,au,j_,H_,jn,z_,mt,K_,W_,Y_,X_,J_,Q_,Z_,Hn,er,Hs,tm,lu,sm,Gt,lc,di,zn,vo,Kn,_o,Wn,mo,it,rm,nm,om,am,lm,Yn,um,Xn,cm,dm,uc,hm,gm,fm,gi,Jn,cc,pm,vm,_m,fi,Rn,Pn,mm,ym,bm,uu,Em,dc,Sm,km,wm,Am,Im,Tm,Rm,Pm,Om,hc,Cm,xm,Qn,Dm,gc,Nm,Lm,$m,fc,Fm,Mm,Zn,Um,Bm,Vm,Gm,cu,qm,du,jm,hu,eo,Hm,zm,gu,On,pc,Km,tr,fu,vc,pu,Wm,Ym,Xm,Jm,Qm,Ki,to,Zm,ey,ty,Cn,iy,sy,ry,ny,oy,ji,io,so,ro,ay,ly,uy,vu,_u,cy,dy,hy,gy,zs,no,mu,fy,py,oo,Ht,pi,yo=Ue(()=>{"use strict";zg=yt(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Kg=Number.isInteger||function(e){return e<<0===e};Jg=(function(){function t(){this.map={},this.length=0}return t.prototype.set=function(e,i){var s=this.hash(e),r=this.map[s];r||(this.map[s]=r=[]),r.push([e,i]),this.length+=1},t.prototype.hash=function(e){var i=[];for(var s in e)i.push(Object.prototype.toString.call(e[s]));return i.join()},t.prototype.get=function(e){if(this.length<=180){for(var i in this.map)for(var o=this.map[i],s=0;s<o.length;s+=1){var r=o[s];if(r[0]===e)return r[1]}return}var n=this.hash(e),o=this.map[n];if(o)for(var s=0;s<o.length;s+=1){var r=o[s];if(r[0]===e)return r[1]}},t})(),W=yt(function(e){return e!=null&&typeof e.clone=="function"?e.clone():yu(e)});Zg=ao(function(e,i,s){var r={},n;i=i||{},s=s||{};for(n in i)Fs(n,i)&&(r[n]=Fs(n,s)?e(n,i[n],s[n]):i[n]);for(n in s)Fs(n,s)&&!Fs(n,r)&&(r[n]=s[n]);return r}),ef=ao(function t(e,i,s){return Zg(function(r,n,o){return Ml(n)&&Ml(o)?t(e,n,o):e(r,n,o)},i,s)}),tf=ao(function(e,i,s){return ef(function(r,n,o){return e(n,o)},i,s)}),sf=Dt(Qg),bu=Dt(function(e,i){var s={};for(var r in i)e(i[r],r,i)&&(s[r]=i[r]);return s}),N=t=>typeof t=="function"&&!!(t.constructor&&t.call&&t.apply),re=t=>typeof t=="string",qe=t=>t===null,Te=t=>typeof t>"u",rt=t=>qe(t)||Te(t),rf=t=>typeof t=="bigint",te=t=>!Te(t),hi=t=>!rt(t),nf=t=>hi(t)&&t!=="",lo=t=>{switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return t instanceof Error}},of=t=>typeof t=="boolean",xn=(t,e)=>{let i=e.split(".");return sf(i,t)},af=(t,e)=>!!xn(t,e),lf=t=>typeof t=="object",uf=t=>!qe(t)&&lf(t)&&!Array.isArray(t),ne=t=>!qe(t)&&Object.prototype.toString.call(t)==="[object Object]",cf=(t,e)=>{if(!Array.isArray(t)||!Array.isArray(e))return W(e);let i=W(t);return e.forEach((s,r)=>{i[r]=Array.isArray(s)||uf(s)?Ae(i[r],s):s}),i},Ae=(t,e)=>tf(cf,t,e),Et=t=>ne(t)&&Object.keys(t).length>0,Hi=t=>{let e=bu(te,t);return Object.keys(e).forEach(i=>{let s=e[i];ne(s)&&(e[i]=Hi(s))}),e},Ks=t=>{let e=bu(hi,t);return Object.keys(e).forEach(i=>{let s=e[i];ne(s)&&(e[i]=Ks(s))}),e},vt=t=>{if(Et(t))return Ks(t)},at=(t,e)=>typeof t=="boolean"?t:e,uo=t=>(Object.getOwnPropertyNames(t).forEach(function(e){t[e]&&typeof t[e]=="object"&&uo(t[e])}),Object.freeze(t)),df=t=>t.replace(/^\s+|\s+$/gm,""),Ul=t=>t.replace(/^\.+/,""),Ws=t=>{let e=t;if(!re(t)&&!rt(t))try{e=JSON.stringify(t)}catch{e=null}return e},hf=t=>{let e=Array.from(t,i=>String.fromCodePoint(i)).join("");return globalThis.btoa(e)},gf=t=>hf(new TextEncoder().encode(t)),Ys=(t,e,i,s,r)=>{let n={category:t,name:e,properties:i,options:s,callback:void 0};N(r)&&(n.callback=r),N(s)&&(n.category=t,n.name=e,n.properties=i,n.options=void 0,n.callback=s),N(i)&&(n.category=t,n.name=e,n.properties=void 0,n.options=void 0,n.callback=i),N(e)&&(n.category=t,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),N(t)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=t),ne(t)?(n.name=void 0,n.category=void 0,n.properties=t,N(e)?n.options=void 0:n.options=e):ne(e)&&(n.name=void 0,n.properties=e,N(i)?n.options=void 0:n.options=i),re(t)&&!re(e)&&(n.category=void 0,n.name=t),te(n.category)||(n.category=void 0),te(n.name)||(n.name=void 0),n.properties=n.properties?W(n.properties):{},te(n.options)?n.options=W(n.options):n.options=void 0;let o=re(n.name)?n.name:n.properties.name,a=re(n.category)?n.category:n.properties.category;return n.properties=Ae(ne(n.properties)?n.properties:{},{...o&&{name:o},...a&&{category:a}}),n},co=(t,e,i,s)=>{let r={name:t,properties:e,options:i,callback:void 0};return N(s)&&(r.callback=s),N(i)&&(r.properties=e,r.options=void 0,r.callback=i),N(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=hi(r.properties)?W(r.properties):{},te(r.options)?r.options=W(r.options):r.options=void 0,r},Eu=(t,e,i,s)=>{let r={userId:t,traits:e,options:i,callback:void 0};return N(s)&&(r.callback=s),N(i)&&(r.userId=t,r.traits=e,r.options=void 0,r.callback=i),N(e)&&(r.userId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ne(t)||qe(t))&&(r.userId=null,r.traits=t,N(e)?r.options=void 0:r.options=e),r.userId=Ws(r.userId),ne(r.traits)?r.traits=W(r.traits):r.traits=void 0,te(r.options)?r.options=W(r.options):r.options=void 0,r},Su=(t,e,i,s)=>{let r={to:t,from:e,options:i,callback:void 0};return N(s)&&(r.callback=s),N(i)&&(r.to=t,r.from=e,r.options=void 0,r.callback=i),N(e)?(r.to=t,r.from=void 0,r.options=void 0,r.callback=e):(ne(e)||qe(e))&&(r.to=t,r.from=void 0,r.options=e),te(r.to)&&(r.to=Ws(r.to)),te(r.from)?r.from=Ws(r.from):r.from=void 0,te(r.options)?r.options=W(r.options):r.options=void 0,r},ku=(t,e,i,s)=>{let r={groupId:t,traits:e,options:i,callback:void 0};return N(s)&&(r.callback=s),N(i)&&(r.groupId=t,r.traits=e,r.options=void 0,r.callback=i),N(e)&&(r.groupId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ne(t)||qe(t))&&(r.groupId=null,r.traits=t,N(e)?r.options=void 0:r.options=e),r.groupId=Ws(r.groupId),ne(r.traits)?r.traits=W(r.traits):r.traits=void 0,te(r.options)?r.options=W(r.options):r.options=void 0,r},kn=(function(t){return t.UNLOADED="Page Unloaded",t})({}),ho="API",Dn="CapabilitiesManager",Xe="ConfigManager",wu="EventManager",qi="PluginsManager",qt="UserSessionManager",zi="ErrorHandler",li="PluginEngine",ff="StoreManager",wn=`Ready${ho}`,pf=`Load${ho}`,vf="HttpClient",_f="RudderStackAnalytics",Ms="AnalyticsCore";Bl=4096,Vs=[],Nt=0;for(;Nt<256;Nt++)Vs[Nt]=(Nt+256).toString(16).substring(1);zt=256,Gs=[];for(;zt--;)Gs[zt]=(zt+256).toString(16).substring(1);Ef=()=>!rt(globalThis.crypto)&&N(globalThis.crypto.getRandomValues),ir=()=>Ef()?yf():bf(),Sf=()=>!!window.chrome?.runtime?.id,kf=()=>re(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),wf=(t,e=!1)=>{let i=!1,s=!1;function r(){i||(i=!0,t(s),setTimeout(()=>{i=!1},0))}(e||kf())&&globalThis.addEventListener("beforeunload",()=>{s=!1,r()}),globalThis.addEventListener("blur",()=>{s=!0,r()}),globalThis.addEventListener("focus",()=>{i=!1}),document.addEventListener("pagehide",()=>{s=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{s=!0,document.visibilityState==="hidden"?r():i=!1})},Au=t=>t.toISOString(),Af=()=>Au(new Date),V=":: ",If=t=>`A script with the id "${t}" is already loaded. Skipping the loading of this script to prevent conflicts`,Vl=(t,e,i)=>`Unable to load (${re(i)?i:i.type}) the script with the id "${t}" from URL "${e}"`,Tf=(t,e,i)=>`A timeout of ${i} ms occurred while trying to load the script with id "${t}" from URL "${e}"`,Rf=(t,e)=>`${t}${V}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,Pf="Failed to convert the value to a JSON string.",Of="Failed to encode the cookie data.",Cf=(t,e)=>`${t}${V}The "${e}" storage type is `,xf="JSONStringify",Df="[BigInt]",Iu="[Circular Reference]",Nf=(t,e,i)=>{let s=[];return function(r,n){if(!e?.includes(r)&&!(t&&rt(n))){if(typeof n!="object"||qe(n))return n;for(;s.length>0&&s[s.length-1]!==this;)s.pop();return s.includes(n)?(i?.warn(Rf(xf,r)),Iu):(s.push(n),n)}}},st=(t,e,i,s)=>{try{return JSON.stringify(t,Nf(e,i,s))}catch(r){return s?.warn(Pf,r),null}},Lf=t=>{let e=[];return function(s,r){if(rf(r))return Df;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?Iu:(e.push(r),r)}},Tu=(t,e)=>{let i=Array.isArray(t)?[]:{};for(let s in t)if(Object.hasOwnProperty.call(t,s)){let r=t[s],n=e.call(t,s,r);ne(n)||Array.isArray(n)?i[s]=Tu(n,e):i[s]=n}return i},X=(t,e)=>{let i=Lf(),s=i.call(t,"",t);return ne(t)||Array.isArray(t)?Tu(t,i):s},Ru="[SDK DISPATCHED ERROR]",sr=t=>{let{stack:e}=t;if(typeof e=="string"&&e)return e},go=(t,e)=>{if(!lo(t))return new Error(`${e}: ${st(t)}`);try{let i=t.constructor,s=new i(`${e}: ${t.message}`),r=sr(t);return r&&(s.stack=r),Object.getOwnPropertyNames(t).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{s[n]=t[n]}catch{}}),s}catch{return new Error(`${e}: ${st(t)}`)}},fe=t=>{if(lo(t)){let e=sr(t);e&&(t.stack=`${e} ${Ru}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:t,bubbles:!0,cancelable:!0,composed:!0}))},Gl="RudderLabs JavaScript SDK",Xi="3.31.1",$f="com.rudderlabs.javascript",Pu="npm",Ff="modern",ql="RudderJS-Initiated",Mf="ad-block page request",Uf="/ad-blocked",Wi="preloadedEventsBuffer",Bf="Consent Management Interaction",Vf="ajs_trait_",Gf="ajs_prop_",jl="ajs_aid",qf="ajs_uid",Hl="ajs_event",jf=10*1e3,Hf=31536e3*1e3,zl=720*60*1e3,Nn=1800*1e3,Kl=10*1e3,zf=10*1e3,Kf=250,Ou=(t="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[t]||(globalThis.RudderStackGlobals[t]={})},Ji=(t,e,i="app")=>{Ou(i),globalThis.RudderStackGlobals[i][t]=e},Cu=(t,e="app")=>(Ou(e),globalThis.RudderStackGlobals[e][t]);Wl=(t,e)=>{let i={};return t.forEach((s,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);i[n]=t.get(r)}}),i},Yf=(t=[])=>{let e={trait:Vf,properties:Gf},i=new URLSearchParams(globalThis.location.search);i.get(Hl)&&t.unshift(["track",i.get(Hl),Wl(i,e.properties)]);let s=i.get(qf),r=Wl(i,e.trait);if(s||Et(r)){let n=[...s?[s]:[],r];t.unshift(["identify",...n])}i.get(jl)&&t.unshift(["setAnonymousId",i.get(jl)])},Xf=t=>{let e="load",i=[],s=0;for(;s<t.length;){if(t[s]&&t[s][0]===e){i=W(t[s]),t.splice(s,1);break}s+=1}return i},Jf=t=>{let e="consent",i=t.filter(r=>r[0]===e),s=t.filter(r=>r[0]!==e);t.splice(0,t.length,...i,...s)},Qf=t=>{let e=Cu(Wi)||[];Yf(e),e.length>0&&(t.enqueuePreloadBufferEvents(e),Ji(Wi,[]))},Zf=(t,e)=>{let i=t.shift(),s;if(N(e[i])){switch(i){case"page":s=Ys(...t);break;case"track":s=co(...t);break;case"identify":s=Eu(...t);break;case"alias":s=Su(...t);break;case"group":s=ku(...t);break;default:e[i](...t);break}s&&e[i](s)}},ep=10*1e3,tp="RS_JS_SDK",ip=(t,e,i=!0,s=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=s,o.onerror=r,o.src=t,o.id=e,o.async=i,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",tp),o},sp=t=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(t,e[0]?.firstChild);return}let i=document.getElementsByTagName("script");if(i.length>0&&i[0]?.parentNode){i[0]?.parentNode.insertBefore(t,i[0]);return}let s=document.createElement("head");s.appendChild(t);let r=document.getElementsByTagName("html")[0];r?.insertBefore(s,r.firstChild)},rp=(t,e,i,s=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(If(e)));try{let l;sp(ip(t,e,s,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(Vl(e,t,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(Tf(e,t,i)))},i)}catch(l){o(go(l,Vl(e,t,"unknown")))}}),Xs=class{constructor(e,i=ep){this.logger=e,this.timeout=i}loadJSFile(e){let{url:i,id:s,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!N(o);rp(i,s,r||this.timeout,n,a).then(u=>{l||o(u)}).catch(u=>{l||o(s,u)})}},np=Symbol.for("preact-signals");J=void 0;Yi=void 0,bt=0,Js=0,op=0,Ln=0,Qs=void 0,Zs=0;De.prototype.brand=np;De.prototype.h=function(){return!0};De.prototype.S=function(t){var e=this,i=this.t;i!==t&&t.e===void 0&&(t.x=i,this.t=t,i!==void 0?i.e=t:xu(function(){var s;(s=e.W)==null||s.call(e)}))};De.prototype.U=function(t){var e=this;if(this.t!==void 0){var i=t.e,s=t.x;i!==void 0&&(i.x=s,t.e=void 0),s!==void 0&&(s.e=i,t.x=void 0),t===this.t&&(this.t=s,s===void 0&&xu(function(){var r;(r=e.Z)==null||r.call(e)}))}};De.prototype.subscribe=function(t){var e=this;return ut(function(){var i=e.value,s=J;J=void 0;try{t(i)}finally{J=s}},{name:"sub"})};De.prototype.valueOf=function(){return this.value};De.prototype.toString=function(){return this.value+""};De.prototype.toJSON=function(){return this.value};De.prototype.peek=function(){var t=J;J=void 0;try{return this.value}finally{J=t}};Object.defineProperty(De.prototype,"value",{get:function(){var t=Du(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Js>100)throw new Error("Cycle detected");(function(i){bt!==0&&Js===0&&i.l!==Ln&&(i.l=Ln,Qs={S:i,v:i.v,i:i.i,o:Qs})})(this),this.v=t,this.i++,Zs++,bt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{rr()}}}});vi.prototype=new De;vi.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Zs))return!0;if(this.g=Zs,this.f|=1,this.i>0&&!Nu(this))return this.f&=-2,!0;var t=J;try{Lu(this),J=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(i){this.v=i,this.f|=16,this.i++}return J=t,$u(this),this.f&=-2,!0};vi.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}De.prototype.S.call(this,t)};vi.prototype.U=function(t){if(this.t!==void 0&&(De.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};vi.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(vi.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Du(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});_i.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};_i.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Fu(this),Lu(this),bt++;var t=J;return J=this,ap.bind(this,t)};_i.prototype.N=function(){2&this.f||(this.f|=2,this.u=Yi,Yi=this)};_i.prototype.d=function(){this.f|=8,1&this.f||fo(this)};_i.prototype.dispose=function(){this.d()};$n=class{constructor(){this.items=[]}enqueue(e){this.items.push(e)}dequeue(){return this.items.length===0?null:this.items.shift()}isEmpty(){return this.items.length===0}size(){return this.items.length}clear(){this.items=[]}},Bs={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Yl="LOG",Mu="ERROR",lp="RS SDK",up="font-weight: bold; background: black; color: white;",cp="font-weight: normal;",Fn=class{constructor(e=Yl,i="",s=console){this.minLogLevel=Bs[e],this.scope=i,this.logProvider=s}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,i){this.minLogLevel<=Bs[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(i))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=Bs[e],Te(this.minLogLevel)&&(this.minLogLevel=Bs[Yl])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let i=`%c ${lp}`;this.scope&&(i=`${i} - ${this.scope}`);let s=re(e[0])?e[0].trim():"";i=`${i} %c ${s}`;let r=[i,up,cp];return re(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},St=new Fn,_t=(function(t){return t.HANDLEDEXCEPTION="handledException",t.UNHANDLEDEXCEPTION="unhandledException",t.UNHANDLEDREJECTION="unhandledPromiseRejection",t})({}),Uu=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Mn="cookieStorage",Xl="Unable to process/parse source configuration response",dp="The source is disabled. Please enable the source in the dashboard to send events.",hp="Failed to prepare data for the request.",gp="Failed to invoke plugin because the extension point name is missing.",fp="Failed to invoke plugin because the extension point name is invalid.",pp=t=>`${t}${V}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,vp=(t,e,i)=>`${t}${V}The base URL "${i}" for ${e} is not valid.`,_p=(t,e,i)=>`${t}${V}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(i)}".`,mp=(t,e)=>`${t}${V}Ignoring a non-error: ${e}.`,Jl="Failed to log breadcrumb",yp=t=>`${t}${V}Failed to handle the error.`,bp=t=>`${t}${V}Plugin name is missing.`,Ep=(t,e)=>`${t}${V}Plugin "${e}" already exists.`,Sp=(t,e)=>`${t}${V}Plugin "${e}" not found.`,kp=(t,e)=>`${t}${V}Plugin "${e}" not found in plugins but found in byName. This indicates a bug in the plugin engine. Please report this issue to the development team.`,wp=(t,e,i)=>`${t}${V}Plugin "${e}" could not be loaded because some of its dependencies "${i}" do not exist.`,Ap=(t,e,i)=>`${t}${V}Failed to invoke the "${e}" extension point of plugin "${i}".`,Ql="Failed to fetch the source config",Ip=(t,e)=>`${t}${V}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,Tp=(t,e)=>`${t}${V}The data plane URL "${e}" is invalid. It must be a valid URL string. Please check that the data plane URL is correct and try again.`,Bu=t=>`${t}${V}The provided callback parameter is not a function.`,Rp=(t,e,i,s,r)=>`${t} with status ${e} (${i}) for URL: ${s}. Response: ${r.trim()}`,Pp=(t,e,i)=>`${t} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${i}`,Op=(t,e)=>`${t} for URL: ${e}`,Cp=t=>`Failed to save the value for "${t}" to storage`,xp=t=>`Failed to retrieve or parse data for "${t}" from storage`,Dp=t=>`The server responded with status ${t} while setting the cookies. As a fallback, the cookies will be set client side.`,Np=t=>`The server failed to set the ${t} cookie. As a fallback, the cookies will be set client side.`,Zl="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",Lp=(t,e,i)=>`${t}${V}The storage type "${e}" is not supported. Please choose one of the following supported types: "${Uu}". The default type "${i}" will be used instead.`,$p=(t,e,i,s)=>`${t}${V}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(i)}". The default version "${s}" will be used instead.`,Fp=(t,e,i)=>`${t}${V}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${i}). To enable storage data migration, please update the storage encryption version to the latest version.`,Mp=(t,e,i)=>`${t}${V}The provided cookie domain (${e}) does not match the current webpage's domain (${i}). Hence, the cookies will be set client-side.`,Up=(t,e,i,s)=>`${t}${V}The "${e}" property defined under "${i}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${s}).`,Bp=t=>`${t}${V}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,Vp=t=>`${t}${V}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,Gp=(t,e,i)=>`${t}${V}The session timeout value "${e}" is not a number. The default timeout of ${i} ms will be used instead.`,qp=(t,e,i)=>`${t}${V}The session cut off duration value "${e}" is not a number. The default cut off duration of ${i} ms will be used instead.`,jp=(t,e,i)=>`${t}${V}The session cut off duration value "${e}" ms is less than the session timeout value "${i}" ms. The cut off functionality will be disabled.`,Hp=t=>`${t}${V}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.`,zp=(t,e,i)=>`${t}${V}The session timeout value ${e} ms is less than the recommended minimum of ${i} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,Kp=(t,e,i)=>`${t}${V}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${i}" digits long. A new session ID will be auto-generated instead.`,Wp=t=>`${t}${V}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,Yp=(t,e,i,s)=>`${t}${V}The storage type "${i}" is not available for entry "${e}". The SDK will initialize the entry with "${s}" storage type instead.`,Xp=t=>`${t}${V}The callback threw an exception`,Jp=(t,e)=>`${t}${V}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,Qp=(t,e)=>`Failed to load the polyfill script with ID "${t}" from URL ${e}.`,Zp=(t,e,i)=>`${t}${V}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${i}" will be used instead.`,ev=(t,e,i)=>`${t}${V}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${i}" will be used instead.`,tv=(t,e)=>`${t}${V}${e} plugin is deprecated. Please exclude it from the load API options.`,iv=(t,e,i,s)=>{let r=i.length===1,n=r?` '${i[0]}' plugin was`:` ['${i.join("', '")}'] plugins were`,o=`${t}${V}${e}, but${n} not configured to load.`;return s?`${o} So, ${r?"the plugin":"those plugins"} will be loaded automatically.`:`${o} Ignore if this was intentional. Otherwise, consider adding ${r?"it":"them"} to the 'plugins' load API option.`},sv=(t,e)=>`${t}${V}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,rv=t=>`${t}${V}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,nv=(t,e)=>`${t}${V}Ignoring unknown plugins: ${e.join(", ")}.`,ov=(t,e)=>`${t}${V}Failed to load the following unavailable local plugins: ${e.join(", ")}. Some features of the SDK may not work as expected. Make sure you are using the correct SDK bundle variant.`,av=(t,e)=>`${t}${V}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,Vu={All:!0},nr="js-integrations",Gu="plugins",lv=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_]*)?$"),Qi="modern",or="https://cdn.rudderlabs.com",po="v3",qu=`${or}/${po}/${Qi}/${nr}`,ju=`${or}/${po}/${Qi}/${Gu}`,Hu="https://api.rudderstack.com",jt="v3",uv="xhr",Un={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},qs={[jt]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},cv={[uv]:"XhrQueue",beacon:"BeaconQueue"},dv="rsaRequest",hv="rsaMetrics",gv="Custom Device Mode",fv={configUrl:Hu,loadIntegration:!0,sessions:{autoTrack:!0,timeout:Nn,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:Vu,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:zf,storage:{encryption:{version:jt},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},pv=E(W(fv)),Q=uo({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),In=uo({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),vv=10,_v={userId:E(Q.userId),userTraits:E(Q.userTraits),anonymousId:E(Q.anonymousId),groupId:E(Q.groupId),groupTraits:E(Q.groupTraits),initialReferrer:E(Q.initialReferrer),initialReferringDomain:E(Q.initialReferringDomain),sessionInfo:E(Q.sessionInfo),authToken:E(Q.authToken)},mv={isOnline:E(!0),storage:{isLocalStorageAvailable:E(!1),isCookieStorageAvailable:E(!1),isSessionStorageAvailable:E(!1)},isBeaconAvailable:E(!1),isLegacyDOM:E(!1),isUaCHAvailable:E(!1),isCryptoAvailable:E(!1),isAdBlockerDetectionInProgress:E(!1),isAdBlocked:E(void 0),cspBlockedURLs:E([])},yv={isErrorReportingEnabled:E(!1),isMetricsReportingEnabled:E(!1),breadcrumbs:E([])},bv=E(void 0),Ev={activeDataplaneUrl:E(void 0),integrationsCDNPath:E(qu),pluginsCDNPath:E(ju),sourceConfigUrl:E(void 0),status:E(void 0),initialized:E(!1),logLevel:E(Mu),loaded:E(!1),readyCallbacks:E([]),writeKey:E(void 0),dataPlaneUrl:E(void 0),safeAnalyticsInstance:E(void 0)},Sv={enabled:E(!1),initialized:E(!1),data:E({}),activeConsentManagerPluginName:E(void 0),preConsent:E({enabled:!1}),postConsent:E({}),resolutionStrategy:E("and"),provider:E(void 0),metadata:E(void 0)},kv={retries:E(0),dropped:E(0),sent:E(0),queued:E(0),triggered:E(0),metricsServiceUrl:E(void 0)},wv=()=>Ff,Av={app:E({name:Gl,namespace:$f,version:Xi,installType:Pu}),traits:E(null),library:E({name:Gl,version:Xi,snippetVersion:globalThis.RudderSnippetVersion,variant:wv()}),userAgent:E(null),device:E(null),network:E(null),os:E({name:"",version:""}),locale:E(null),screen:E({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":E(void 0),timezone:E(void 0)},Iv={configuredDestinations:E([]),activeDestinations:E([]),loadOnlyIntegrations:E({}),failedDestinations:E([]),loadIntegration:E(!0),initializedDestinations:E([]),clientDestinationsReady:E(!1),integrationsConfig:E({})},Tv={toBeProcessedArray:E([]),readyCallbacksArray:E([])},Rv={ready:E(!1),loadedPlugins:E([]),failedPlugins:E([]),pluginsToLoadFromConfig:E([]),activePlugins:E([]),totalPluginsToLoad:E(0)},Pv={encryptionPluginName:E(void 0),migrate:E(!1),type:E(void 0),cookie:E(void 0),entries:E({}),trulyAnonymousTracking:E(!1)},Ov={isEnabledServerSideCookies:E(!1),dataServiceUrl:E(void 0)},Cv={eventsQueuePluginName:E(void 0),deliveryEnabled:E(!0)},xv={enabled:E(!1),pageLifecycle:{enabled:E(!1),pageViewId:E(void 0),pageLoadedTimestamp:E(void 0)}},Dv={capabilities:mv,consents:Sv,context:Av,eventBuffer:Tv,lifecycle:Ev,loadOptions:pv,metrics:kv,nativeDestinations:Iv,plugins:Rv,reporting:yv,session:_v,source:bv,storage:Pv,serverCookies:Ov,dataPlaneEvents:Cv,autoTrack:xv},d={...W(Dv)},zu=/^\s*at /,Nv=/^(eval@)?(\[native code])?$/,Lv=/(.+?)(?::(\d+))?(?::(\d+))?$/;Wu="global code",Uv=t=>te(t)&&/^global code$/i.test(t)?Wu:t,Bv=t=>{let e={file:t.fileName,method:Uv(t.functionName),lineNumber:t.lineNumber,columnNumber:t.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Wu),e},eu=t=>re(t)?t:"";Yu=(t,e)=>{let i;return lo(t)&&re(sr(t))?i=t:(e.warn(mp(zi,st(t))),i=void 0),i},Vv=(t,e)=>{try{let i=Mv(t);return tu(t.name,t.message,e,i)}catch{return tu(t.name,t.message,e,[])}},iu=(t,e)=>{try{return JSON.parse(t||"")}catch(i){let s=go(i,"Failed to parse response data");e(s)}},js="The request failed",Gv=[/Failed to fetch dynamically imported module: .*/],qv=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],jv=[new RegExp(`${js}.*`),/A script with the id .* is already loaded\./],Hv=[...Gv,...qv],zv="integrations",Kv="sdk",Wv=Kv,Yv={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},su=(t,e,i)=>{let s=Ae(Yv,e||{});return i&&(s.headers=Ae(s.headers,{Authorization:i})),s.url=t,s},ru=(t,e=jf,i)=>new Promise((s,r)=>{let n;if(t.sendRawData===!0)n=t.data;else if(n=st(t.data,!1,[],i),qe(n)){r({error:new Error(hp),undefined:void 0,options:t});return}let o=new XMLHttpRequest,a=u=>{r({error:new Error(Rp(js,o.status,o.statusText,t.url,o.responseText)),xhr:o,options:t})},l=u=>{r({error:new Error(Pp(js,u,t.url)),xhr:o,options:t,...u?.type==="timeout"?{timedOut:!0}:{}})};o.ontimeout=l,o.onerror=l,o.onload=()=>{o.status>=200&&o.status<400?s({response:o.responseText,xhr:o,options:t}):a()},o.open(t.method,t.url,!0),t.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(t.headers).forEach(u=>{t.headers[u]&&o.setRequestHeader(u,t.headers[u])});try{o.send(n)}catch(u){r({error:go(u,Op(js,t.url)),xhr:o,options:t})}}),Bn=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:i,options:s,timeout:r,isRawResponse:n}=e;try{let o=await ru(su(i,s,this.basicAuthHeader),r,this.logger);return{data:n?o.response:iu(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:i,url:s,options:r,timeout:n,isRawResponse:o}=e,a=!N(i);ru(su(s,r,this.basicAuthHeader),n,this.logger).then(l=>{a||i(o?l.response:iu(l.response,this.onError),l)}).catch(l=>{a||i(void 0,l)})}onError(e,i){this.errorHandler?.onError({error:e,context:vf,groupingHash:i})}setAuthHeader(e,i=!1){let s=i?e:gf(`${e}:`);this.basicAuthHeader=`Basic ${s}`}resetAuthHeader(){this.basicAuthHeader=void 0}},Xu=new Bn(St),Xv="1",Jv=()=>["rsa"],Qv=["www.test-host.com","localhost","127.0.0.1","[::1]"],Zv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],e_="RudderStack JavaScript SDK",t_="git+https://github.com/rudderlabs/rudder-sdk-js.git",i_="js",Ju=t=>{d.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(d.lifecycle.sourceConfigUrl.value),i=`${e.origin}${e.pathname}?view=ad`;t.getAsyncData({url:i,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(s,r)=>{d.capabilities.isAdBlockerDetectionInProgress.value=!1,d.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==i}})}catch(e){throw d.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},s_=(t,e)=>{switch(e){case _t.UNHANDLEDEXCEPTION:{let{error:i}=t;return i||t}case _t.UNHANDLEDREJECTION:return t.reason;case _t.HANDLEDEXCEPTION:default:return t}},r_=t=>({type:"manual",name:t,timestamp:new Date,metaData:{}}),n_=(t=()=>window.location.hostname)=>{let e=t();return!e||e&&Qv.includes(e)?"development":"production"},o_=t=>{let e=st(t,!1,Zv);return e!==null?JSON.parse(e):{}},a_=()=>globalThis.location.href.split("?")[0],l_=(t,e,i,s)=>({id:`${t.value?.id??i.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${s.pageLifecycle.pageViewId.value??"NA"}`,name:t.value?.name??"NA"}),u_=(t,e)=>({locale:t.value??"NA",userAgent:e.value??"NA",time:new Date}),c_=(t,e,i,s)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:u}=i,{app:c,locale:h,userAgent:f,timezone:g,screen:p,library:v}=r;return{payloadVersion:"5",notifier:{name:e_,version:c.value.version,url:t_},events:[{exceptions:[W(t)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:c.value.version,releaseStage:n_(),type:c.value.installType},device:u_(h,f),request:{url:a_(),clientIp:"[NOT COLLECTED]"},breadcrumbs:W(l.breadcrumbs.value),context:t.message,groupingHash:s,metaData:{app:{snippetVersion:v.value.snippetVersion},device:{...p.value,timezone:g.value},...o_(i)},user:l_(a,o,n,u)}]}},d_=(t,e,i)=>{if(Te(t.capabilities.isAdBlocked.value)){t.capabilities.isAdBlockerDetectionInProgress.value===!1&&Ju(e);let s=ut(()=>{te(t.capabilities.isAdBlocked.value)&&(i(t.capabilities.isAdBlocked.value===!1),s())})}else i(t.capabilities.isAdBlocked.value===!1)},h_=(t,e,i)=>{let s=t.message;return new Promise(r=>{if(Hv.some(n=>n.test(s))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(s)?.[0];re(n)?n.startsWith(or)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):d_(e,i,r):r(!1):r(!0)}else r(!jv.some(n=>n.test(s)))})},Qu=t=>t?t.split("/").at(-2):void 0,Zu=t=>{let e=t.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},g_=t=>{let e=Zu(t);if(!e)return!1;let i=e.substring(e.lastIndexOf("/")+1);return Qu(e)===nr||Jv().some(r=>i.startsWith(r)&&i.endsWith(".js"))},f_=(t,e)=>{if(e)return e;let i=Zu(t);return Qu(i)===nr?zv:Wv},p_=(t,e,i)=>{let s={version:Xv,message_id:ir(),source:{name:i_,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:i},errors:t};return st(s)},v_=(t,e,i)=>{let s;if(!te(t))s=e;else if(re(t))s=t;else{let r=Yu(t,i);te(r)?s=r.message:s=e}return s},Vn=class{constructor(e,i){ae(this,"initialized",!1);this.httpClient=e,this.logger=i}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:zi,errorType:_t.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:zi,errorType:_t.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let i=re(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&i.startsWith(or)&&!d.capabilities.cspBlockedURLs.value.includes(i)&&(d.capabilities.cspBlockedURLs.value=[...d.capabilities.cspBlockedURLs.value,i])})}async onError(e){try{let{error:i,context:s,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??_t.HANDLEDEXCEPTION,l=s_(i,a),u=Yu(l,this.logger);if(Te(u))return;let c=r?`${r} - `:"",h=`${s}${V}${c}`,f=Vv(u,h),p=sr(u).includes(Ru);if(!p&&!g_(f)&&a!==_t.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await h_(f,d,this.httpClient)){let m={severity:"error",unhandled:a!==_t.HANDLEDEXCEPTION,severityReason:{type:a}},y=v_(n,f.message,this.logger),w=c_(f,m,d,y),R=f_(f,o);this.httpClient.getAsyncData({url:d.metrics.metricsServiceUrl.value,options:{method:"POST",data:p_(w,d,R),sendRawData:!0},isRawResponse:!0})}(a===_t.HANDLEDEXCEPTION||p)&&this.logger.error(f.message)}catch(i){this.logger.error(yp(zi),i)}}leaveBreadcrumb(e){try{d.reporting.breadcrumbs.value=[...d.reporting.breadcrumbs.value,r_(e)]}catch(i){this.onError({error:i,context:zi,customMessage:Jl,groupingHash:Jl})}}},ec=new Vn(Xu,St),Gn=class{constructor(e,i={}){ae(this,"plugins",[]);ae(this,"byName",{});ae(this,"cache",{});ae(this,"config",{throws:!0});this.config={throws:!0,...i},this.logger=e}register(e,i){if(!e.name){let r=bp(li);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=Ep(li,e.name);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},this.plugins=this.plugins.slice();let s=this.plugins.length;this.plugins.forEach((r,n)=>{r.deps?.includes(e.name)&&(s=Math.min(s,n))}),this.plugins.splice(s,0,e),this.byName[e.name]=e,N(e.initialize)&&e.initialize(i)}unregister(e){let i=this.byName[e];if(!i){let r=Sp(li,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let s=this.plugins.indexOf(i);if(s===-1){let r=kp(li,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},delete this.byName[e],this.plugins=this.plugins.slice(),this.plugins.splice(s,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let i=e??".";return this.cache[i]||(this.cache[i]=this.plugins.filter(s=>{if(s.deps?.some(r=>!this.byName[r])){let r=s.deps.filter(n=>!this.byName[n]);return this.logger.error(wp(li,s.name,r)),!1}return i==="."?!0:af(s,i)})),this.cache[i]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,i=!0,...s){let r=e;if(!r)throw new Error(gp);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(fp);let a=r.split(".");a.pop();let l=a.join(".");return(i?this.getPlugins(r):[this.getPlugins(r)[0]]).map(c=>{let h=xn(c,r);if(!N(h)||n)return h;try{return h.apply(xn(c,l),s)}catch(f){if(o)throw f;this.logger.error(Ap(li,r,c.name),f)}return null})}invokeSingle(e,...i){return this.invoke(e,!1,...i)[0]}invokeMultiple(e,...i){return this.invoke(e,!0,...i)}},__=new Gn(St,{throws:!0}),m_=t=>t.config.connectionMode!=="cloud"||t.config.useNativeSDKToSend===!0||t.config.useNativeSDK===!0,y_=t=>t.config.connectionMode==="hybrid"||t.config.useNativeSDKToSend===!0,nu=t=>t.filter(m_),b_=(t,e)=>`${t.replaceAll(" ","-")}___${e}`,tc=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],E_=["Bugsnag","ErrorReporting"],S_={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"}};k_=t=>ic({},(globalThis.__federation_shared__||{}).default||{});A_=t=>{switch(t){case"BeaconQueue":return()=>Ve("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>Be(e,!0));case"CustomConsentManager":return()=>Ve("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>Be(e,!0));case"DeviceModeDestinations":return()=>Ve("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>Be(e,!0));case"DeviceModeTransformation":return()=>Ve("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>Be(e,!0));case"ExternalAnonymousId":return()=>Ve("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>Be(e,!0));case"GoogleLinker":return()=>Ve("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>Be(e,!0));case"KetchConsentManager":return()=>Ve("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>Be(e,!0));case"IubendaConsentManager":return()=>Ve("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>Be(e,!0));case"NativeDestinationQueue":return()=>Ve("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>Be(e,!0));case"OneTrustConsentManager":return()=>Ve("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>Be(e,!0));case"StorageEncryption":return()=>Ve("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>Be(e,!0));case"StorageEncryptionLegacy":return()=>Ve("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>Be(e,!0));case"StorageMigrator":return()=>Ve("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>Be(e,!0));case"XhrQueue":return()=>Ve("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>Be(e,!0));default:return}},I_=t=>{let e={};return t.forEach(i=>{if(tc.includes(i)){let s=A_(i);s&&(e[i]=s)}}),e},sc=()=>({}),T_=()=>({}),R_=t=>I_?.(t)||{},Tn={...sc(),...T_()},P_=t=>({...R_(t)}),qn=class{constructor(e,i,s){this.engine=e,this.errorHandler=i,this.logger=s,this.onError=this.onError.bind(this)}init(){d.lifecycle.status.value="pluginsLoading",Ji("pluginsCDNPath",d.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){ut(()=>{(d.plugins.activePlugins.value.length===0||d.plugins.loadedPlugins.value.length+d.plugins.failedPlugins.value.length===d.plugins.totalPluginsToLoad.value)&&Ie(()=>{d.plugins.ready.value=!0,d.lifecycle.status.value="pluginsReady"})})}getPlugins