@deriv-com/analytics 1.42.0 → 1.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  /* @deriv-com/analytics - Browser IIFE Bundle (RudderStack + PostHog) - Built with tsup */
2
- "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 Fe=(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 mt(t){return function e(i){return arguments.length===0||de(i)?e:t.apply(this,arguments)}}function xt(t){return function e(i,s){switch(arguments.length){case 0:return e;case 1:return de(i)?e:mt(function(r){return t(i,r)});default:return de(i)&&de(s)?e:de(i)?mt(function(r){return t(r,s)}):de(s)?mt(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:xt(function(n,o){return t(i,n,o)});case 2:return de(i)&&de(s)?e:de(i)?xt(function(n,o){return t(n,s,o)}):de(s)?xt(function(n,o){return t(i,n,o)}):mt(function(n){return t(i,s,n)});default:return de(i)&&de(s)&&de(r)?e:de(i)&&de(s)?xt(function(n,o){return t(n,o,r)}):de(i)&&de(r)?xt(function(n,o){return t(n,s,o)}):de(s)&&de(r)?xt(function(n,o){return t(i,n,o)}):de(i)?mt(function(n){return t(n,s,r)}):de(s)?mt(function(n){return t(i,n,r)}):de(r)?mt(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||Ht+16>256){for(Us=Array(t=256);t--;)Us[t]=256*Math.random()|0;t=Ht=0}for(;t<16;t++)e=Us[Ht+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 Ht++,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(yt>1)yt--;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)&&Du(i))try{i.c()}catch(r){e||(t=r,e=!0)}i=s}}if(Js=0,yt--,e)throw t}}function Ae(t){if(yt>0)return t();Ln=++op,yt++;try{return t()}finally{rr()}}function xu(t){var e=J;J=void 0;try{return t()}finally{J=e}}function Nu(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 Ce(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 Ce(t,e)}function Du(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){Ce.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"){yt++;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 lt(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(Dv.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(`
3
- `);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 Me(t,e){if(!t?.default&&e){let i=Object.create(null);return i.default=t,i.__esModule=!0,i}return t}function Ue(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 N=r(l.getItem(m[w]));this.has(m[w])&&(y[m[w]]=N)}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,D,re,Ve,Ie,st,rf,te,hi,nf,lo,of,xn,af,lf,uf,ne,cf,we,bt,Hi,Ks,pt,ot,uo,df,Ul,Ws,hf,gf,Ys,co,Eu,Su,ku,kn,ho,Nn,Ye,wu,qi,Gt,zi,li,ff,wn,pf,vf,_f,Ms,Bl,Vs,Nt,An,Ht,Gs,Us,Ef,ir,Sf,kf,wf,Au,Af,V,If,Vl,Tf,Rf,Pf,Of,Cf,xf,Nf,Iu,Df,it,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,Dn,Kl,zf,Kf,Ou,Ji,Cu,Wl,Yf,Xf,Jf,Qf,Zf,ep,tp,ip,sp,rp,Xs,np,J,Yi,yt,Js,op,Ln,Qs,Zs,$n,Bs,Yl,Mu,lp,up,cp,Fn,Et,vt,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,Np,Dp,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,qt,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,Nv,d,zu,Dv,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,Be,je,We,at,zt,O_,C_,x_,N_,D_,L_,$_,F_,M_,U_,B_,V_,ui,G_,rc,nc,q_,oc,ac,ci,ou,au,j_,H_,jn,z_,_t,K_,W_,Y_,X_,J_,Q_,Z_,Hn,er,Hs,tm,lu,sm,Vt,lc,di,zn,vo,Kn,_o,Wn,mo,tt,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,Nm,gc,Dm,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,jt,pi,yo=Fe(()=>{"use strict";zg=mt(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=mt(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=xt(Qg),bu=xt(function(e,i){var s={};for(var r in i)e(i[r],r,i)&&(s[r]=i[r]);return s}),D=t=>typeof t=="function"&&!!(t.constructor&&t.call&&t.apply),re=t=>typeof t=="string",Ve=t=>t===null,Ie=t=>typeof t>"u",st=t=>Ve(t)||Ie(t),rf=t=>typeof t=="bigint",te=t=>!Ie(t),hi=t=>!st(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=>!Ve(t)&&lf(t)&&!Array.isArray(t),ne=t=>!Ve(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)?we(i[r],s):s}),i},we=(t,e)=>tf(cf,t,e),bt=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},pt=t=>{if(bt(t))return Ks(t)},ot=(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)&&!st(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};D(r)&&(n.callback=r),D(s)&&(n.category=t,n.name=e,n.properties=i,n.options=void 0,n.callback=s),D(i)&&(n.category=t,n.name=e,n.properties=void 0,n.options=void 0,n.callback=i),D(e)&&(n.category=t,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),D(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,D(e)?n.options=void 0:n.options=e):ne(e)&&(n.name=void 0,n.properties=e,D(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=we(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 D(s)&&(r.callback=s),D(i)&&(r.properties=e,r.options=void 0,r.callback=i),D(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 D(s)&&(r.callback=s),D(i)&&(r.userId=t,r.traits=e,r.options=void 0,r.callback=i),D(e)&&(r.userId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ne(t)||Ve(t))&&(r.userId=null,r.traits=t,D(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 D(s)&&(r.callback=s),D(i)&&(r.to=t,r.from=e,r.options=void 0,r.callback=i),D(e)?(r.to=t,r.from=void 0,r.options=void 0,r.callback=e):(ne(e)||Ve(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 D(s)&&(r.callback=s),D(i)&&(r.groupId=t,r.traits=e,r.options=void 0,r.callback=i),D(e)&&(r.groupId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ne(t)||Ve(t))&&(r.groupId=null,r.traits=t,D(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",Nn="CapabilitiesManager",Ye="ConfigManager",wu="EventManager",qi="PluginsManager",Gt="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);Ht=256,Gs=[];for(;Ht--;)Gs[Ht]=(Ht+256).toString(16).substring(1);Ef=()=>!st(globalThis.crypto)&&D(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",Nf="[BigInt]",Iu="[Circular Reference]",Df=(t,e,i)=>{let s=[];return function(r,n){if(!e?.includes(r)&&!(t&&st(n))){if(typeof n!="object"||Ve(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)}}},it=(t,e,i,s)=>{try{return JSON.stringify(t,Df(e,i,s))}catch(r){return s?.warn(Pf,r),null}},Lf=t=>{let e=[];return function(s,r){if(rf(r))return Nf;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}: ${it(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}: ${it(t)}`)}},fe=t=>{if(lo(t)){let e=sr(t);e&&(t.stack=`${e}
4
- ${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,Dn=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||bt(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(D(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=!D(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,yt=0,Js=0,op=0,Ln=0,Qs=void 0,Zs=0;Ce.prototype.brand=np;Ce.prototype.h=function(){return!0};Ce.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)}))};Ce.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)}))}};Ce.prototype.subscribe=function(t){var e=this;return lt(function(){var i=e.value,s=J;J=void 0;try{t(i)}finally{J=s}},{name:"sub"})};Ce.prototype.valueOf=function(){return this.value};Ce.prototype.toString=function(){return this.value+""};Ce.prototype.toJSON=function(){return this.value};Ce.prototype.peek=function(){var t=J;J=void 0;try{return this.value}finally{J=t}};Object.defineProperty(Ce.prototype,"value",{get:function(){var t=Nu(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){yt!==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++,yt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{rr()}}}});vi.prototype=new Ce;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&&!Du(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)}Ce.prototype.S.call(this,t)};vi.prototype.U=function(t){if(this.t!==void 0&&(Ce.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=Nu(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),yt++;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],Ie(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}},Et=new Fn,vt=(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`,Np=t=>`The server responded with status ${t} while setting the cookies. As a fallback, the cookies will be set client side.`,Dp=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",qt="v3",uv="xhr",Un={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},qs={[qt]:"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:Dn,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:qt},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)}},Nv={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(Nv)},zu=/^\s*at /,Dv=/^(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,it(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=we(Yv,e||{});return i&&(s.headers=we(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=it(t.data,!1,[],i),Ve(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=!D(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(Et),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 vt.UNHANDLEDEXCEPTION:{let{error:i}=t;return i||t}case vt.UNHANDLEDREJECTION:return t.reason;case vt.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=it(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(Ie(t.capabilities.isAdBlocked.value)){t.capabilities.isAdBlockerDetectionInProgress.value===!1&&Ju(e);let s=lt(()=>{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 it(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:vt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:zi,errorType:vt.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??vt.HANDLEDEXCEPTION,l=s_(i,a),u=Yu(l,this.logger);if(Ie(u))return;let c=r?`${r} - `:"",h=`${s}${V}${c}`,f=Vv(u,h),p=sr(u).includes(Ru);if(!p&&!g_(f)&&a!==vt.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await h_(f,d,this.httpClient)){let m={severity:"error",unhandled:a!==vt.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===vt.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,Et),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,D(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(!D(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(Et,{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()=>Ue("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>Me(e,!0));case"CustomConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>Me(e,!0));case"DeviceModeDestinations":return()=>Ue("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>Me(e,!0));case"DeviceModeTransformation":return()=>Ue("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>Me(e,!0));case"ExternalAnonymousId":return()=>Ue("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>Me(e,!0));case"GoogleLinker":return()=>Ue("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>Me(e,!0));case"KetchConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>Me(e,!0));case"IubendaConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>Me(e,!0));case"NativeDestinationQueue":return()=>Ue("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>Me(e,!0));case"OneTrustConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>Me(e,!0));case"StorageEncryption":return()=>Ue("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>Me(e,!0));case"StorageEncryptionLegacy":return()=>Ue("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>Me(e,!0));case"StorageMigrator":return()=>Ue("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>Me(e,!0));case"XhrQueue":return()=>Ue("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>Me(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(){lt(()=>{(d.plugins.activePlugins.value.length===0||d.plugins.loadedPlugins.value.length+d.plugins.failedPlugins.value.length===d.plugins.totalPluginsToLoad.value)&&Ae(()=>{d.plugins.ready.value=!0,d.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=d.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>E_.includes(r)?(this.logger.warn(tv(qi,r)),!1):!0);let i=[{configurationStatus:()=>te(d.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:d.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(cv),shouldAddMissingPlugins:!0},{configurationStatus:()=>nu(d.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>nu(d.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>te(d.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:d.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Un)},{configurationStatus:()=>te(d.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:d.storage.encryptionPluginName.value,supportedPlugins:Object.values(qs)},{configurationStatus:()=>d.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],s=!1;return i.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>te(n)),this.addMissingPlugins(r,s,e)):e=e.filter(r.basePlugins!==void 0?n=>!(r.basePlugins.includes(n)||r.supportedPlugins.includes(n)):n=>!r.supportedPlugins.includes(n))}),[...Object.keys(sc()),...e]}addMissingPlugins(e,i,s){let r=e.shouldAddMissingPlugins||i,n;e.activePluginName?n=[...e.basePlugins||[],e.activePluginName]:n=[...e.supportedPlugins];let o=n.filter(a=>!s.includes(a));o.length>0&&(r&&s.push(...o),this.logger.warn(iv(qi,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),i=[...Object.keys(Tn),...tc],s=[],r=[];e.forEach(n=>{i.includes(n)?s.push(n):r.push(n)}),r.length>0&&this.logger.warn(nv(qi,r)),Ae(()=>{d.plugins.totalPluginsToLoad.value=e.length,d.plugins.activePlugins.value=s,d.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(Tn).forEach(([i,s])=>{d.plugins.activePlugins.value.includes(i)&&(D(s)?this.register([s()]):e.push(i))}),e.length>0&&(d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,...e],this.logger.error(ov(qi,e)))}registerRemotePlugins(){let e=P_(d.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async i=>{await e[i]().then(s=>this.register([s.default()])).catch(s=>{d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,i],this.onError(s,`Failed to load plugin "${i}"`,s)})})).catch(i=>{this.onError(i)})}invokeMultiple(e,...i){try{return this.engine.invokeMultiple(e,...i)}catch(s){return this.onError(s,e),[]}}invokeSingle(e,...i){try{return this.engine.invokeSingle(e,...i)}catch(s){return this.onError(s,e),null}}register(e){e.forEach(i=>{try{this.engine.register(i,d)}catch(s){d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,i.name],this.onError(s,`Failed to register plugin "${i.name}"`)}})}unregisterLocalPlugins(){Object.keys(Tn).forEach(e=>{try{this.engine.unregister(e)}catch(i){this.onError(i,`Failed to unregister plugin "${e}"`)}})}onError(e,i,s){this.errorHandler.onError({error:e,context:qi,customMessage:i,groupingHash:s})}},Be="cookieStorage",je="localStorage",We="sessionStorage",at="memoryStorage",zt="none",O_="test_rudder_cookie",C_="test_rudder_ls",x_="test_rudder_ss",N_="rl_user_id",D_="rl_trait",L_="rl_anonymous_id",$_="rl_group_id",F_="rl_group_trait",M_="rl_page_init_referrer",U_="rl_page_init_referring_domain",B_="rl_session",V_="rl_auth_token",ui={userId:N_,userTraits:D_,anonymousId:L_,groupId:$_,groupTraits:F_,initialReferrer:M_,initialReferringDomain:U_,sessionInfo:B_,authToken:V_},G_="__tld__",rc="clientDataInCookie",nc="clientDataInLocalStorage",q_="clientDataInMemory",oc="clientDataInSessionStorage",ac=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ci={[Be]:rc,[je]:nc,[at]:q_,[We]:oc},ou=(t,e)=>{try{return encodeURIComponent(t)}catch(i){e?.error(Of,i);return}},au=t=>{try{return decodeURIComponent(t)}catch{return}},j_=t=>{let e={},i=t.split(/\s*;\s*/),s;return i[0]&&i.forEach(r=>{s=r.split("=");let n=s[0]?au(s[0]):void 0;n&&(e[n]=s[1]?au(s[1]):void 0)}),e},H_=(t,e,i,s)=>{let r={...i||{}},n=`${ou(t,s)}=${ou(e,s)}`;Ve(e)&&(r.maxage=-1),r.maxage&&(r.expires=new Date(+new Date+r.maxage)),r.path&&(n+=`; path=${r.path}`),r.domain&&(n+=`; domain=${r.domain}`),r.expires&&(n+=`; expires=${r.expires.toUTCString()}`),r.samesite&&(n+=`; samesite=${r.samesite}`),r.secure&&(n+="; secure"),globalThis.document.cookie=n},jn=()=>{let t=globalThis.document.cookie;return j_(t)},z_=t=>jn()[t],_t=function(t,e,i,s){switch(arguments.length){case 4:case 3:case 2:return H_(t,e,i,s);case 1:return t?z_(t):jn();default:return jn()}},K_=t=>{let e=document.createElement("a");return e.href=t,e.hostname},W_=t=>{let i=(typeof globalThis.URL!="function"?K_(t):new URL(t).hostname)?.split(".")??[],s=i[i.length-1],r=[];if(i.length===4&&s&&s===parseInt(s,10).toString())return r;if(i.length<=1)return i[0]&&i[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=i.length-2;n>=0;n-=1)r.push(i.slice(n).join("."));return r},Y_=t=>{let e=W_(t);for(let i=0;i<e.length;i+=1){let s=e[i],r=G_,n={domain:`${s.indexOf("localhost")!==-1?"":"."}${s}`};try{if(_t(r,1,n),_t(r))return _t(r,null,n),s}catch{try{_t(r,null,n)}catch{}}}return""},X_=()=>{let t=`.${Y_(globalThis.location.href)}`;return{maxage:Hf,path:"/",domain:!t||t==="."?void 0:t,samesite:"Lax",enabled:!0}},J_=()=>({enabled:!0}),Q_=()=>({enabled:!0}),Z_=()=>({enabled:!0}),Hn=class{constructor(e){ae(this,"isEnabled",!0);ae(this,"length",0);ae(this,"data",{});this.options=Z_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,i){return this.data[e]=i,this.length=Object.keys(this.data).length,i}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)}},er=new Hn(Et);Hs={exports:{}},tm=Hs.exports;sm=im(),Vt=em(sm),lc=t=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],i=[22,1014];return t instanceof DOMException?e.includes(t.name)||i.includes(t.code):!1},di=(t=je,e,i)=>{let s,r,n=Cf(Nn,t),o="unavailable",a=!0,l;try{switch(t){case at:return!0;case Be:s=e,r=O_;break;case je:s=e??globalThis.localStorage,r=C_;break;case We:s=e??globalThis.sessionStorage,r=x_;break;default:return!1}if(s&&(s.setItem(r,"true"),s.getItem(r)))return s.removeItem(r),!0;a=!1}catch(u){a=!1,l=u,lc(u)&&(o="full")}return a||i?.warn(`${n}${o}.`,l),!1},zn=class{constructor(e){ae(this,"isSupportAvailable",!0);ae(this,"isEnabled",!0);ae(this,"length",0);this.options=J_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isSupportAvailable=di(je),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){Vt.set(e,i),this.length=Vt.len()}getItem(e){let i=Vt.get(e);return Ie(i)?null:i}removeItem(e){Vt.remove(e),this.length=Vt.len()}clear(){Vt.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Vt.keys()}},vo=new zn(Et),Kn=class{constructor(e){ae(this,"isSupportAvailable",!0);ae(this,"isEnabled",!0);ae(this,"length",0);this.options=Q_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isSupportAvailable=di(We),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){this.store&&(this.store.setItem(e,i),this.length=this.store.length)}getItem(e){if(!this.store)return null;let i=this.store.getItem(e);return Ie(i)?null:i}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){this.store?.clear(),this.length=0}key(e){return this.store?.key(e)??null}keys(){let e=[];if(!this.store)return e;for(let i=0;i<this.store.length;i+=1){let s=this.store.key(i);s!==null&&e.push(s)}return e}},_o=new Kn(Et),Wn=class{constructor(e){ae(this,"isSupportAvailable",!0);ae(this,"isEnabled",!0);ae(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=X_()),this.options=we(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=di(Be,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){return _t(e,i,this.options,this.logger),this.length=Object.keys(_t()).length,!0}getItem(e){let i=_t(e);return Ie(i)?null:i}removeItem(e){let i=this.setItem(e,null);return this.length=Object.keys(_t()).length,i}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(_t())}},mo=new Wn(Et),tt=t=>{switch(t){case je:return vo;case We:return _o;case at:return er;case Be:return mo;default:return er}},rm=t=>{let e=mo.configure(t);d.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},nm=t=>{vo.configure(t)},om=t=>{er.configure(t)},am=t=>{_o.configure(t)},lm=(t={},e={},i={},s={})=>{rm(t),nm(e),om(i),am(s)},Yn=class{constructor(e,i,s){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=i,this.noKeyValidation=Object.keys(this.validKeys).length===0,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=s}createValidKey(e){let{name:i,id:s,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[i,s,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[i,s,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:i,validKeys:s,noCompoundKey:r}=this,n=tt(at);Object.keys(s).forEach(o=>{let a=this.get(s[o]),l=r?o:[e,i,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,i){let s=this.createValidKey(e);if(s)try{this.engine.setItem(s,this.encrypt(it(i,!1,[],this.logger)))}catch(r){if(lc(r))this.logger.warn(Wp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,i);else{let n=Cp(e);this.onError(r,n,n)}}}get(e){let i=this.createValidKey(e),s;try{return!i||(s=this.decrypt(this.engine.getItem(i)),st(s)||s==="")?null:JSON.parse(s)}catch(r){let n=d.storage.encryptionPluginName.value;if(!n||!d.plugins.failedPlugins.value.includes(n)){let a=xp(e);this.onError(r,a,a)}return null}}remove(e){let i=this.createValidKey(e);i&&this.engine.removeItem(i)}getOriginalEngine(){return this.originalEngine}decrypt(e){return st(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,i){if(!this.isEncrypted||!e||typeof e!="string"||df(e)==="")return e;let r=`storage.${i}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,i,s){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:i,groupingHash:s})}},um=(t,e)=>{let i;if(t.consents.preConsent.value.enabled)switch(t.consents.preConsent.value.storage?.strategy){case"none":i=zt;break;case"session":e!=="sessionInfo"&&(i=zt);break;case"anonymousId":e!=="anonymousId"&&(i=zt);break}return i},Xn=class{constructor(e,i,s){ae(this,"stores",{});ae(this,"isInitialized",!1);this.errorHandler=i,this.logger=s,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=d.loadOptions.value,i={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};lm(Hi(we(i.cookieStorageOptions??{},d.storage.cookie?.value??{})),Hi(i.localStorageOptions),Hi(i.inMemoryStorageOptions),Hi(i.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[at,je,Be,We].forEach(i=>{tt(i)?.isEnabled&&this.setStore({id:ci[i],name:ci[i],isEncrypted:!0,noCompoundKey:!0,type:i,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=d.storage.type.value,i=d.loadOptions.value.storage?.entries,s=d.consents.postConsent.value.storage;(te(s?.type)||te(s?.entries))&&(e=s?.type,i=s?.entries);let r=!0,n={};ac.forEach(o=>{let a=o,l=o,u=i?.[a]?.type,h=um(d,o)??u??e??Mn,f=this.getResolvedStorageTypeForEntry(h,o);f!==zt&&(r=!1),n={...n,[o]:{type:f,key:ui[l]}}}),Ae(()=>{d.storage.type.value=e,d.storage.entries.value=n,d.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,i){let s=e;switch(e){case je:tt(je)?.isEnabled||(s=at);break;case We:tt(We)?.isEnabled||(s=at);break;case at:case zt:break;case Be:default:tt(Be)?.isEnabled?s=Be:tt(je)?.isEnabled?s=je:tt(We)?.isEnabled?s=We:s=at;break}return s!==e&&this.logger.warn(Yp(ff,i,e,s)),s}setStore(e){let i=tt(e.type);return this.stores[e.id]=new Yn(e,i,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},cm=t=>ne(t)&&ne(t.source)&&!st(t.source.id)&&ne(t.source.config)&&Array.isArray(t.source.destinations),dm=t=>typeof t=="string"&&Uu.includes(t),uc=t=>{let e=new URL(t),{host:i,protocol:s}=e,r=i.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=i,{topDomain:n,protocol:s}},hm=t=>{let{topDomain:e,protocol:i}=uc(t);return`${i}//${e}`},gm=(t,e)=>{let i=e?window.location.origin:hm(window.location.href),s=t.startsWith("/")?t.substring(1):t;return`${i}/${s}`},fm=t=>{let{topDomain:e}=uc(window.location.href);return e===t},gi=t=>t?.endsWith("/")?gi(t.substring(0,t.length-1)):t,Jn=t=>{try{return new URL(t).host}catch{return null}},cc=t=>Jn(t)??"",pm=t=>{let e={};try{let i=new URL(t),s="utm_";i.searchParams.forEach((r,n)=>{if(n.startsWith(s)){let o=n.substring(s.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},vm=t=>{let e=t;try{let i=new URL(t);e=i.origin+i.pathname+i.search}catch{}return e},_m=t=>t.replace(/\/{2,}/g,"/"),fi=t=>{if(!re(t))return!1;try{return D(globalThis.URL)&&new URL(t),lv.test(t)}catch{return!1}},Rn="none",Pn="immediate",mm=t=>t?.statsCollection?.errors?.enabled===!0,ym=t=>t?.statsCollection?.metrics?.enabled===!0,bm=t=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(ne(t)){let i=W(t);e.storage=i.storage,bt(i.integrations)&&(e.integrations=i.integrations),e.discardPreConsentEvents=i.discardPreConsentEvents===!0,e.sendPageEvent=i.sendPageEvent===!0,e.trackConsent=i.trackConsent===!0,bt(i.consentManagement)&&(e.consentManagement=we(i.consentManagement,{enabled:d.consents.enabled.value}))}return e},uu=t=>bt(t)||Array.isArray(t),Em=(t,e)=>{let{provider:i}=t,s=i?Un[i]:void 0;return i&&!s&&(e.error(_p(Ye,i,Un)),i=void 0),{provider:i,consentManagerPluginName:s}},dc=(t,e)=>{let i,s=[],r=[],n=!1,o,a=t?.enabled===!0;bt(t)&&a&&({provider:o,consentManagerPluginName:i}=Em(t,e),uu(t.allowedConsentIds)&&(s=t.allowedConsentIds,n=!0),uu(t.deniedConsentIds)&&(r=t.deniedConsentIds,n=!0));let l={allowedConsentIds:s,deniedConsentIds:r};return a=a&&!!i,{provider:o,consentManagerPluginName:i,initialized:n,enabled:a,consentsData:l}},Sm=()=>{let t=document.querySelector("script[data-rsa-write-key]");if(t&&t.dataset.rsaWriteKey===d.lifecycle.writeKey.value)return t.src;let e=document.getElementsByTagName("script"),i=/(?:^|\/)rsa(\.min)?\.js$/;for(let s of e){let r=s.getAttribute("src");if(r&&i.test(r))return r}},km=t=>{d.reporting.isErrorReportingEnabled.value=mm(t.source.config)&&!Sf(),d.reporting.isMetricsReportingEnabled.value=ym(t.source.config)},wm=t=>{let{useServerSideCookies:e,dataServiceEndpoint:i,storage:s,setCookieDomain:r,sameDomainCookiesOnly:n}=d.loadOptions.value,o=s?.cookie,a=!1,l;if(e){a=e;let u=o.domain??r,c=te(u)&&!fm(Ul(u))||n,h=gm(i??dv,c);if(fi(h)){l=gi(h);let f=Jn(window.location.href),g=Jn(h);f!==g&&(o={...o,samesite:"None",secure:!0}),!n&&c&&g!==Ul(u)&&(a=!1,t.warn(Mp(Ye,u,g)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},Am=t=>{let{storage:e}=d.loadOptions.value,i=e?.type;te(i)&&!dm(i)&&(t.warn(Lp(Ye,i,Mn)),i=Mn);let s=e?.encryption?.version,r=s&&qs[s];!Ie(s)&&Ie(r)?(t.warn($p(Ye,s,qs,qt)),s=qt):Ie(s)&&(s=qt);let n=e?.migrate,o=n&&s===qt;n===!0&&o!==n&&t.warn(Fp(Ye,s,qt));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:u}=wm(t);Ae(()=>{d.storage.type.value=i,d.storage.cookie.value=u,d.serverCookies.isEnabledServerSideCookies.value=a,d.serverCookies.dataServiceUrl.value=l,d.storage.encryptionPluginName.value=qs[s],d.storage.migrate.value=o})},Im=t=>{let{provider:e,consentManagerPluginName:i,initialized:s,enabled:r,consentsData:n}=dc(d.loadOptions.value.consentManagement,t),o=d.loadOptions.value.preConsent,a=o?.storage?.strategy??Rn,l=["none","session","anonymousId"];te(a)&&!l.includes(a)&&(a=Rn,t.warn(Zp(Ye,o?.storage?.strategy,Rn)));let u=o?.events?.delivery??Pn,c=["immediate","buffer"];te(u)&&!c.includes(u)&&(u=Pn,t.warn(ev(Ye,o?.events?.delivery,Pn))),Ae(()=>{d.consents.activeConsentManagerPluginName.value=i,d.consents.initialized.value=s,d.consents.enabled.value=r,d.consents.data.value=n,d.consents.provider.value=e,d.consents.preConsent.value={enabled:d.loadOptions.value.preConsent?.enabled===!0&&s===!1&&r===!0,storage:{strategy:a},events:{delivery:u}}})},Tm=t=>{let e=d.consents.resolutionStrategy.value,i;ne(t.consentManagementMetadata)&&(d.consents.provider.value&&(e=t.consentManagementMetadata.providers.find(s=>s.provider===d.consents.provider.value)?.resolutionStrategy??d.consents.resolutionStrategy.value),i=t.consentManagementMetadata),d.consents.provider.value==="custom"&&(e=void 0),Ae(()=>{d.consents.metadata.value=W(i),d.consents.resolutionStrategy.value=e})},Rm=t=>{if(d.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",i=e;d.loadOptions.value.useBeacon&&(d.capabilities.isBeaconAvailable.value?i="BeaconQueue":(i=e,t.warn(Vp(Ye)))),Ae(()=>{d.dataPlaneEvents.eventsQueuePluginName.value=i})}},Pm=(t,e,i,s,r)=>{let n=new URLSearchParams({p:Pu,v:Xi,build:Qi,writeKey:e,lockIntegrationsVersion:i.toString(),lockPluginsVersion:s.toString()}),o=Hu,a=n,l="/sourceConfig/",u="";if(fi(t)){let c=new URL(t);gi(c.pathname).endsWith("/sourceConfig")||(c.pathname=`${gi(c.pathname)}/sourceConfig/`),c.pathname=_m(c.pathname),n.forEach((h,f)=>{c.searchParams.get(f)===null&&c.searchParams.set(f,h)}),o=c.origin,l=c.pathname,a=c.searchParams,u=c.hash}else r.warn(Jp(Ye,t));return`${o}${l}?${a}${u}`},Om=t=>t.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:b_(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===gv})),hc=(t,e,i,s,r,n,o)=>{let a;if(n){if(!fi(n))return o.error(vp(Ye,t,n)),null;a=gi(n)}else if(a=i,d.context.app.value.installType==="cdn"){let l=Sm();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${po}/${Qi}/${e}$`),`/${s}/${Qi}/${e}`)),a},Cm=(t,e,i,s)=>hc("integrations",nr,qu,t,e,i,s),xm=(t,e,i,s)=>hc("plugins",Gu,ju,t,e,i,s),Qn=class{constructor(e,i,s){this.errorHandler=i,this.logger=s,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){lt(()=>{this.logger.setMinLogLevel(d.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:i,lockIntegrationsVersion:s,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=d.loadOptions.value,l=Cm(Xi,s,n,this.logger);if(Ve(l))return;let u;u=xm(Xi,r,o,this.logger),u!==null&&(this.attachEffects(),d.lifecycle.activeDataplaneUrl.value=gi(d.lifecycle.dataPlaneUrl.value),Am(this.logger),Im(this.logger),Rm(this.logger),Ae(()=>{d.lifecycle.integrationsCDNPath.value=l,d.lifecycle.pluginsCDNPath.value=u,e&&(d.lifecycle.logLevel.value=e),d.lifecycle.sourceConfigUrl.value=Pm(i,d.lifecycle.writeKey.value,s,r,this.logger),d.metrics.metricsServiceUrl.value=`${d.lifecycle.activeDataplaneUrl.value}/${hv}`,d.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,i,s){this.errorHandler.onError({error:e,context:Ye,customMessage:i,groupingHash:s})}processConfig(e,i){if(!te(e)){te(i)?this.onError(i.error,Ql):this.onError(new Error(Ql));return}let s;try{re(e)?s=JSON.parse(e):s=e}catch(n){this.onError(n,Xl);return}if(!cm(s)){this.onError(new Error(Xl));return}if(s.source.enabled===!1){this.logger.error(dp);return}km(s);let r=s.source.destinations.length>0?Om(s.source.destinations):[];Ae(()=>{d.source.value={config:s.source.config,name:s.source.name,id:s.source.id,workspaceId:s.source.workspaceId},d.nativeDestinations.configuredDestinations.value=r,d.plugins.pluginsToLoadFromConfig.value=d.loadOptions.value.plugins??[],Tm(s),d.lifecycle.status.value="configured"})}getConfig(){let e=d.loadOptions.value.getSourceConfig;if(e){if(!D(e)){this.logger.error(pp(Ye));return}let i=e();i instanceof Promise?i.then(s=>this.processConfig(s)).catch(s=>{this.onError(s,"SourceConfig")}):this.processConfig(i)}else this.httpClient.getAsyncData({url:d.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},Nm=()=>{let t=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return t?.[1]?t[1]:"NA"},gc=(t=()=>document)=>t()?.referrer||"$direct",Dm=(t=()=>document)=>{let i=t().getElementsByTagName("link"),s="";for(let r=0;i[r];r+=1){let n=i[r];if(n.getAttribute("rel")==="canonical"&&!s){s=n.getAttribute("href")??"";break}}return s},Lm=(t=()=>globalThis.navigator)=>{let e=t();if(Ie(e))return null;let{userAgent:i}=e,{brave:s}=e;if(s&&Object.getPrototypeOf(s).isBrave){let r=i.match(/(chrome)\/([\w.]+)/i);r&&(i=`${i} Brave/${r[2]}`)}return i},$m=(t=()=>globalThis.navigator)=>{let e=t();return Ie(e)?null:e.language??e.browserLanguage},fc=(t=()=>globalThis.location,e=()=>document)=>{let i=t(),s=Dm(e),r=i.pathname,{href:n}=i,o=n,{search:a}=i;if(s)try{let h=new URL(s);h.search===""?o=s+a:o=s,r=h.pathname}catch{}let l=vm(o),{title:u}=e(),c=gc(e);return{path:r,referrer:c,referring_domain:cc(c),search:a,title:u,url:l,tab_url:n}},Fm=(t,e="none")=>{e==="none"&&t(void 0),e==="default"&&t(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(i=>{t(i)}).catch(()=>{t()})},Mm=()=>{let t=globalThis.document.createElement("div");return t.setAttribute("data-a-b","c"),t.dataset?t.dataset.aB==="c":!1},Zn={URL:()=>!D(globalThis.URL)||!D(globalThis.URLSearchParams),Promise:()=>!D(globalThis.Promise),"Number.isNaN":()=>!D(globalThis.Number.isNaN),"Number.isInteger":()=>!D(globalThis.Number.isInteger),"Array.from":()=>!D(globalThis.Array.from),"Array.prototype.find":()=>!D(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!D(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!D(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!D(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!D(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!D(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!D(globalThis.String.fromCodePoint),"Object.entries":()=>!D(globalThis.Object.entries),"Object.values":()=>!D(globalThis.Object.values),"Object.assign":()=>!D(globalThis.Object.assign),"Object.fromEntries":()=>!D(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!Mm(),TextEncoder:()=>!D(globalThis.TextEncoder)||!D(globalThis.TextDecoder),requestAnimationFrame:()=>!D(globalThis.requestAnimationFrame)||!D(globalThis.cancelAnimationFrame),CustomEvent:()=>!D(globalThis.CustomEvent),"navigator.sendBeacon":()=>!D(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!D(globalThis.Uint8Array),Set:()=>!D(globalThis.Set),atob:()=>!D(globalThis.atob)},Um=()=>{let t=Object.keys(Zn),e=!1;for(let i=0;i<t.length;i++){let s=Zn[t[i]];if(D(s)&&s()){e=!0;break}}return e},Bm="https://polyfill-fastly.io/v3/polyfill.min.js",Vm=`${Bm}?version=3.111.0&features=${Object.keys(Zn).join("%2C")}`,Gm=10*1e3,cu="rudderstackPolyfill",qm=()=>!st(globalThis.crypto)&&D(globalThis.crypto.getRandomValues),du=()=>!st(globalThis.navigator.userAgentData),jm=()=>!st(globalThis.navigator.sendBeacon)&&D(globalThis.navigator.sendBeacon),hu=()=>{let t={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return t={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},t},eo=class{constructor(e,i,s){this.httpClient=e,this.errorHandler=i,this.logger=s,this.externalSrcLoader=new Xs(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Ae(()=>{d.capabilities.storage.isCookieStorageAvailable.value=di(Be,tt(Be),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=di(je,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=di(We,void 0,this.logger),d.capabilities.isBeaconAvailable.value=jm(),d.capabilities.isUaCHAvailable.value=du(),d.capabilities.isCryptoAvailable.value=qm(),d.capabilities.isOnline.value=globalThis.navigator.onLine,d.context.userAgent.value=Lm(),d.context.locale.value=$m(),d.context.screen.value=hu(),d.context.timezone.value=Nm(),du()&&Fm(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),lt(()=>{d.loadOptions.value.sendAdblockPage===!0&&d.lifecycle.sourceConfigUrl.value!==void 0&&Ju(this.httpClient)})}prepareBrowserCapabilities(){d.capabilities.isLegacyDOM.value=Um();let e=d.loadOptions.value.polyfillURL,i=Vm;if(hi(e)&&(fi(e)?i=e:this.logger.warn(sv(Nn,e))),d.loadOptions.value.polyfillIfRequired&&d.capabilities.isLegacyDOM.value&&fi(i)){let r=i!==d.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${d.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,i=`${i}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:i,id:cu,async:!0,timeout:Gm,callback:n=>{n?r||this.onReady():this.onError(new Error(Qp(cu,i)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{d.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{d.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Wf(()=>{d.context.screen.value=hu()},this))}onReady(){this.detectBrowserCapabilities(),d.lifecycle.status.value="browserCapabilitiesReady"}onError(e,i){this.errorHandler.onError({error:e,context:Nn,groupingHash:i})}},Hm="web",zm=["integrations","anonymousId","originalTimestamp"],gu=["library","consentManagement","userAgent","ua-ch","screen"],On=["id","anonymous_id","user_id","sent_at","timestamp","received_at","original_timestamp","event","event_text","channel","context_ip","context_request_ip","context_passed_ip","group_id","previous_id"],pc=t=>typeof t=="number"&&!Number.isNaN(t),Km=(t,e)=>e.toString().length>=t,tr=t=>pc(t)&&t>=0&&Number.isInteger(t),fu=10,vc=t=>{let{cutOff:e}=t,i=Date.now();return!!(e?.enabled&&e.expiresAt&&i>e.expiresAt)},pu=t=>!t.expiresAt||Date.now()>t.expiresAt||vc(t),Wm=()=>Date.now(),Ym=(t,e)=>!t||!tr(t)||!Km(fu,t)?(e.warn(Kp(Gt,t,fu)),!1):!0,Xm=t=>{if(t?.enabled)return t.expiresAt??(tr(t.duration)?Date.now()+t.duration:void 0)},Jm=t=>{let{timeout:e,cutOff:i}=t,s=Date.now();return{id:s,expiresAt:s+e,timeout:e,autoTrack:!0,...i&&{cutOff:i}}},Qm=(t,e)=>({id:Ym(t,e)?t:Wm(),sessionStart:void 0,manualTrack:!0}),Ki=t=>t===Be||t===je||t===We||t===at,to=()=>ir(),Zm=t=>{if(of(t)){let{entries:e,...i}=In;return{...i,entries:{...e,anonymousId:t}}}return ne(t)&&ne(t.entries)?we(In,t):{...In}},ey=t=>{let e=fc(),i={};return Object.keys(e).forEach(s=>{i[s]=t?.[s]||e[s]}),i.initial_referrer=t?.initial_referrer||d.session.initialReferrer.value,i.initial_referring_domain=t?.initial_referring_domain||d.session.initialReferringDomain.value,i},ty=(t,e)=>{let i=e?.page||{},s=t,r=fc();return Object.keys(r).forEach(n=>{Ie(s[n])&&(s[n]=i[n]||r[n])}),Ie(s.initial_referrer)&&(s.initial_referrer=i.initial_referrer||d.session.initialReferrer.value),Ie(s.initial_referring_domain)&&(s.initial_referring_domain=i.initial_referring_domain||d.session.initialReferringDomain.value),s},Cn=(t,e,i)=>{ne(t)&&Object.keys(t).forEach(s=>{(On.includes(s)||On.includes(s.toLowerCase()))&&i.warn(Up(wu,s,e,On))})},iy=(t,e)=>{let{properties:i,traits:s,context:r}=t,{traits:n}=r;Cn(i,"properties",e),Cn(s,"traits",e),Cn(n,"context.traits",e)},sy=(t,e)=>{e.anonymousId&&re(e.anonymousId)&&(t.anonymousId=e.anonymousId),bt(e.integrations)&&(t.integrations=e.integrations),e.originalTimestamp&&re(e.originalTimestamp)&&(t.originalTimestamp=e.originalTimestamp)},ry=(t,e,i)=>{let s=t;return Object.keys(e).forEach(r=>{if(!zm.includes(r)&&!gu.includes(r))if(r!=="context")s=we(s,{[r]:e[r]});else if(!Ie(e[r])&&ne(e[r])){let n={};Object.keys(e[r]).forEach(o=>{gu.includes(o)||(n[o]=e[r][o])}),s=we(s,{...n})}else i.warn(Bp(wu))}),s},ny=(t,e,i)=>{ne(e)&&(sy(t,e),t.context=ry(t.context,e,i))},oy=t=>{let e;return d.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=d.consents.postConsent.value.integrations??d.nativeDestinations.loadOnlyIntegrations.value:t?e=t:e=Vu,W(e)},ji=(t,e,i,s)=>{let r={channel:Hm,context:{traits:W(d.session.userTraits.value),sessionId:d.session.sessionInfo.value.id||void 0,sessionStart:d.session.sessionInfo.value.sessionStart||void 0,...d.consents.enabled.value&&{consentManagement:{deniedConsentIds:W(d.consents.data.value.deniedConsentIds),allowedConsentIds:W(d.consents.data.value.allowedConsentIds),provider:d.consents.provider.value,resolutionStrategy:d.consents.resolutionStrategy.value}},"ua-ch":d.context["ua-ch"].value,app:d.context.app.value,library:d.context.library.value,userAgent:d.context.userAgent.value,os:d.context.os.value,locale:d.context.locale.value,screen:d.context.screen.value,campaign:pm(globalThis.location.href),page:ey(i),timezone:d.context.timezone.value,...d.autoTrack.enabled.value&&{autoTrack:{...d.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:d.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:Af(),messageId:ir(),userId:t.userId||d.session.userId.value};Ki(d.storage.entries.value.anonymousId?.type)?r.anonymousId=d.session.anonymousId.value:r.anonymousId=to(),d.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),t.type==="identify"&&(r.context.traits=d.storage.entries.value.userTraits?.type!==zt?W(d.session.userTraits.value):t.context.traits),t.type==="group"&&((t.groupId||d.session.groupId.value)&&(r.groupId=t.groupId||d.session.groupId.value),(t.traits||d.session.groupTraits.value)&&(r.traits=d.storage.entries.value.groupTraits?.type!==zt?W(d.session.groupTraits.value):t.traits));let n=we(t,r);return n.event===void 0&&(n.event=null),n.properties===void 0&&(n.properties=null),ny(n,e,s),iy(n,s),n.integrations=oy(n.integrations),n},io=class{constructor(e){this.logger=e}generatePageEvent(e,i,s,r){let n=s??{};return n=ty(n,r),ji({properties:n,name:i,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,i,s){return ji({properties:i,event:e,type:"track"},s,void 0,this.logger)}generateIdentifyEvent(e,i,s){return ji({userId:e,type:"identify",context:{traits:i}},s,void 0,this.logger)}generateAliasEvent(e,i,s){let n=ji({previousId:i,type:"alias"},s,void 0,this.logger);return n.userId=e??n.userId,n}generateGroupEvent(e,i,s){let r={type:"group"};return e&&(r.groupId=e),i&&(r.traits=i),ji(r,s,void 0,this.logger)}create(e){let i;switch(e.type){case"page":i=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":i=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":i=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":i=this.generateAliasEvent(e.to,e.from,e.options);break;default:i=this.generateGroupEvent(e.groupId,e.traits,e.options);break}return i}},so=class{constructor(e,i,s,r){this.eventRepository=e,this.userSessionManager=i,this.errorHandler=s,this.logger=r,this.eventFactory=new io(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let i=this.eventFactory.create(e);this.eventRepository.enqueue(i,e.callback)}},ro=class{constructor(e,i,s,r,n){this.storeManager=i,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=s,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());let{externalAnonymousIdCookieName:e,anonymousIdOptions:i}=d.loadOptions.value,s;hi(e)&&typeof e=="string"&&(s=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(s??this.getAnonymousId(i)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let i=this.getConfiguredSessionTrackingInfo(),s=this.getSessionInfo()??Q.sessionInfo;e={autoTrack:i.autoTrack&&s.manualTrack!==!0,timeout:i.timeout,manualTrack:s.manualTrack,expiresAt:s.expiresAt,id:s.id,sessionStart:s.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=Q.sessionInfo:i.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:i.cutOff.duration,expiresAt:s.cutOff?.expiresAt})}else e=Q.sessionInfo;d.session.sessionInfo.value=e,d.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(d.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),i=this.getInitialReferringDomain();if(e&&i)this.setInitialReferrer(e),this.setInitialReferringDomain(i);else{let s=e||gc();this.setInitialReferrer(s),this.setInitialReferringDomain(cc(s))}}isPersistenceEnabledForStorageEntry(e){return Ki(d.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=d.storage.entries.value,i=[Be,je,We];Object.keys(e).forEach(s=>{let r=s,n=e[r]?.type,o=this.storeManager?.getStore(ci[n]);o&&i.forEach(a=>{let l=this.storeManager?.getStore(ci[a]);if(l&&a!==n){let u=l.get(ui[r]);nf(u)&&o.set(ui[r],u),l.remove(ui[r])}})})}migrateStorageIfNeeded(e,i){if(!d.storage.migrate.value)return;let s=e??[];s.length===0&&[rc,nc,oc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&s.push(a)}),(i??Object.keys(ui)).forEach(n=>{let o=ui[n];s.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);st(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=d.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let i,s=d.loadOptions.value.sessions?.timeout;tr(s)?i=s:(this.logger.warn(Gp(Gt,s,Dn)),i=Dn),i===0&&(this.logger.warn(Hp(Gt)),e=!1),i>0&&i<Kl&&this.logger.warn(zp(Gt,i,Kl));let r=this.getCutOffInfo(i);return{timeout:i,autoTrack:e,cutOff:r}}getCutOffInfo(e){let i=d.loadOptions.value.sessions.cutOff,s,r=!1;return i.enabled===!0&&(s=i.duration,r=!0,tr(s)?s<e&&(this.logger.warn(jp(Gt,s,e)),r=!1):(this.logger.warn(qp(Gt,s,zl)),s=zl)),{enabled:r,duration:s}}onError(e,i,s){this.errorHandler.onError({error:e,context:Gt,customMessage:i,groupingHash:s})}getEncryptedCookieData(e,i){let s=[];return e.forEach(r=>{let n=i?.encrypt(it(r.value,!1,[],this.logger));hi(n)&&s.push({name:r.name,value:n})}),s}makeRequestToSetCookie(e,i){this.httpClient?.getAsyncData({url:d.serverCookies.dataServiceUrl.value,options:{method:"POST",data:it({reqType:"setCookies",workspaceId:d.source.value?.workspaceId,data:{options:{maxAge:d.storage.cookie.value?.maxage,path:d.storage.cookie.value?.path,domain:d.storage.cookie.value?.domain,sameSite:d.storage.cookie.value?.samesite,secure:d.storage.cookie.value?.secure,expires:d.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:i})}setServerSideCookies(e,i,s){let r=Object.keys(e),n=()=>r.map(u=>({name:e[u].name,value:d.session[u].value})),o={};r.forEach(u=>{o[e[u].name]=s?.get(e[u].name)});let a=()=>{r.forEach(u=>{this.serverSideCookiesRequestInProgress[u]=!1})},l=()=>{n().forEach(u=>{i&&i(u.name,u.value)})};try{let u={};r.forEach(h=>{u[e[h].name]=d.session[h].value});let c=this.getEncryptedCookieData(n(),s);c.length>0?this.makeRequestToSetCookie(c,(h,f)=>{a(),f?.xhr?.status===200?n().forEach(g=>{let p=o[g.name],v=s?.get(g.name);it(u[g.name],!1,[])!==it(v,!1,[])&&(Ve(p)&&Ve(v)&&this.logger.error(Dp(g.name)),i&&i(g.name,g.value))}):(this.logger.error(Np(f?.xhr?.status)),l())}):(l(),a())}catch(u){this.onError(u,Zl,Zl),l(),a()}}syncValueToStorage(e){let i=d.storage.entries.value,s=i[e]?.type;if(Ki(s)){let r=this.storeManager.getStore(ci[s]),n=i[e]?.key,o=d.session[e].value;o&&(re(o)||bt(o))?d.serverCookies.isEnabledServerSideCookies.value&&s===Be?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{let a={[e]:{name:n}};this.setServerSideCookies(a,(l,u)=>{r?.set(l,u)},r)},vv)):r?.set(n,o):r?.remove(n)}}registerEffects(){ac.forEach(e=>{lt(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,i){let s=e;(!re(e)||!s)&&(s=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!s&&i&&(s=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",i)),s=s||to()):s=Q.anonymousId,d.session.anonymousId.value=s}getAnonymousId(e){let i=d.storage.entries.value.anonymousId?.type;if(Ki(i)){let s=d.session.anonymousId.value;(!s||s===Q.anonymousId)&&(s=this.getEntryValue("anonymousId")),!s&&e&&(s=this.pluginsManager?.invokeSingle("storage.getAnonymousId",tt,e)),d.session.anonymousId.value=s||to()}return d.session.anonymousId.value}getEntryValue(e){let i=d.storage.entries.value,s=i[e]?.type;if(Ki(s)){let r=this.storeManager?.getStore(ci[s]);this.migrateStorageIfNeeded([r],[e]);let n=i[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let i=tt(Be);return i?.isEnabled?i.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?d.session[e].value:this.getEntryValue(e)}getUserId(){return this.getUserSessionValue("userId")}getUserTraits(){return this.getUserSessionValue("userTraits")}getGroupId(){return this.getUserSessionValue("groupId")}getGroupTraits(){return this.getUserSessionValue("groupTraits")}getInitialReferrer(){return this.getUserSessionValue("initialReferrer")}getInitialReferringDomain(){return this.getUserSessionValue("initialReferringDomain")}getSessionInfo(){return this.getUserSessionValue("sessionInfo")}getAuthToken(){return this.getUserSessionValue("authToken")}getSessionId(){let e=this.getSessionInfo()??Q.sessionInfo;return e.autoTrack&&!pu(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??Q.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=d.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),d.session.sessionInfo.value=e,d.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=d.session,{manualTrack:i,autoTrack:s,timeout:r,cutOff:n}=e.sessionInfo.value;if(s){let o={...Q.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else i&&this.startManualTrackingInternal()}reset(e){let{session:i}=d,s=Zm(e);Ae(()=>{Object.keys(Q).forEach(r=>{let n=r;if(s.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:i[n].value=Q[n];break}})})}setUserId(e){d.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:Q.userId}setUserTraits(e){d.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&ne(e)?we(d.session.userTraits.value??Q.userTraits,e):Q.userTraits}setGroupId(e){d.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:Q.groupId}setGroupTraits(e){d.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&ne(e)?we(d.session.groupTraits.value??Q.groupTraits,e):Q.groupTraits}setInitialReferrer(e){d.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:Q.initialReferrer}setInitialReferringDomain(e){d.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:Q.initialReferringDomain}startOrRenewAutoTracking(e){let i=e;if(pu(e))i=Jm(e);else{let s=Date.now(),r=e.timeout;i.expiresAt=s+r}if(vc(i)&&(i.cutOff.expiresAt=void 0),i.cutOff){let s=Xm(i.cutOff);i.cutOff.expiresAt=s}d.session.sessionInfo.value=i}start(e){d.session.sessionInfo.value=Qm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){d.session.sessionInfo.value=Q.sessionInfo}setAuthToken(e){d.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:Q.authToken}},ay=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],ly=ay,uy=(t,e)=>{let i=W(e);return re(i.setCookieDomain)||(i.setCookieDomain=void 0),["Strict","Lax","None"].includes(i.sameSiteCookie)||(i.sameSiteCookie=void 0),i.secureCookie=ot(i.secureCookie,t.secureCookie),i.sameDomainCookiesOnly=ot(i.sameDomainCookiesOnly,t.sameDomainCookiesOnly),["none","default","full"].includes(i.uaChTrackLevel)||(i.uaChTrackLevel=void 0),i.integrations=pt(i.integrations),Array.isArray(i.plugins)||(i.plugins=ly),i.useGlobalIntegrationsConfigInEvents=ot(i.useGlobalIntegrationsConfigInEvents,t.useGlobalIntegrationsConfigInEvents),i.bufferDataPlaneEventsUntilReady=ot(i.bufferDataPlaneEventsUntilReady,t.bufferDataPlaneEventsUntilReady),i.sendAdblockPage=ot(i.sendAdblockPage,t.sendAdblockPage),i.useServerSideCookies=ot(i.useServerSideCookies,t.useServerSideCookies),re(i.dataServiceEndpoint)||(i.dataServiceEndpoint=void 0),i.sendAdblockPageOptions=pt(i.sendAdblockPageOptions),i.loadIntegration=ot(i.loadIntegration,t.loadIntegration),bt(i.storage)?(i.storage.migrate=ot(i.storage.migrate,t.storage?.migrate),i.storage.cookie=pt(i.storage.cookie),i.storage.encryption=pt(i.storage.encryption),i.storage=Ks(i.storage)):i.storage=void 0,i.destinationsQueueOptions=pt(i.destinationsQueueOptions),i.queueOptions=pt(i.queueOptions),i.lockIntegrationsVersion=ot(i.lockIntegrationsVersion,t.lockIntegrationsVersion),i.lockPluginsVersion=ot(i.lockPluginsVersion,t.lockPluginsVersion),pc(i.dataPlaneEventsBufferTimeout)||(i.dataPlaneEventsBufferTimeout=void 0),i.beaconQueueOptions=pt(i.beaconQueueOptions),i.preConsent=pt(i.preConsent),i.sourceConfigurationOverride=pt(i.sourceConfigurationOverride),we(t,Ks(i))},vu="dataplaneEventsQueue",_u="destinationsEventsQueue",cy="transformEvent",dy=(t,e)=>Object.keys(t).filter(i=>t[i]!==!0||!e[i]).reduce((i,s)=>{let r=W(i);return r[s]=t[s],r},{}),hy=(t,e)=>{let i=W(t),s=e.nativeDestinations.integrationsConfig.value,r=dy(t.integrations,s);return i.integrations=we(s,r),i},gy=t=>t.consents.preConsent.value.enabled&&t.consents.preConsent.value.events?.delivery==="buffer",zs=(t,e,i,s)=>{if(te(t))if(D(t))try{t(...e)}catch(r){s.error(Xp(i),r)}else s.error(Bu(i))},no=class{constructor(e,i,s,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=s,this.logger=n,this.storeManager=i}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${vu}.init`,d,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${cy}.init`,d,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${_u}.init`,d,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),lt(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=gy(d),i;lt(()=>{let s=d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&d.nativeDestinations.clientDestinationsReady.value===!1;(d.nativeDestinations.activeDestinations.value.some(n=>y_(n))===!1||s===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(i),this.dataplaneEventsQueue?.start())}),d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(i=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},d.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(d.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,i){let s=hy(e,d);this.pluginsManager.invokeSingle(`${vu}.enqueue`,d,this.dataplaneEventsQueue,s,this.errorHandler,this.logger);let r=W(e);this.pluginsManager.invokeSingle(`${_u}.enqueue`,d,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${ho}`;zs(i,[s],n,this.logger)}},mu=t=>{let e=new CustomEvent(t,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},fy=t=>re(t)&&t.trim().length>0,py=t=>fi(t),oo=class{constructor(){this.preloadBuffer=new $n,this.initialized=!1,this.errorHandler=ec,this.logger=Et,this.externalSrcLoader=new Xs(this.logger),this.httpClient=Xu,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new eo(this.httpClient,this.errorHandler,this.logger)}load(e,i,s={}){if(!d.lifecycle.status.value){if(!fy(e)){this.logger.error(Ip(Ms,e));return}if(!py(i)){this.logger.error(Tp(Ms,i));return}Ae(()=>{d.lifecycle.writeKey.value=W(e),d.lifecycle.dataPlaneUrl.value=W(i),d.loadOptions.value=uy(d.loadOptions.value,s),d.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(d.loadOptions.value.logLevel??Mu),Ji("state",d,e),this.startLifecycle()}}startLifecycle(){lt(()=>{try{switch(d.lifecycle.status.value){case"mounted":this.onMounted();break;case"browserCapabilitiesReady":this.onBrowserCapabilitiesReady();break;case"configured":this.onConfigured();break;case"pluginsLoading":break;case"pluginsReady":this.onPluginsReady();break;case"initialized":this.onInitialized();break;case"loaded":this.onLoaded();break;case"destinationsLoading":break;case"destinationsReady":this.onDestinationsReady();break;case"ready":this.onReady();break;default:break}}catch(e){let i="Failed to load the SDK";this.errorHandler.onError({error:e,context:Ms,customMessage:i,groupingHash:i})}})}onBrowserCapabilitiesReady(){Qf(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),d.consents.preConsent.value.enabled===!0?d.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(i=>this.preloadBuffer.enqueue(W(i)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&Zf([...e],this)}}prepareInternalServices(){this.pluginsManager=new qn(__,this.errorHandler,this.logger),this.storeManager=new Xn(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Qn(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new ro(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new no(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new so(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){d.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(d.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),d.consents.enabled.value&&!d.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",d,this.logger),d.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger)),this.eventManager?.init(),d.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Ae(()=>{d.lifecycle.loaded.value=!0,d.lifecycle.status.value="loaded"}),this.initialized=!0;let e=d.loadOptions.value.onLoaded;zs(e,[globalThis.rudderanalytics],pf,this.logger),mu("RSA_Initialised")}onReady(){d.lifecycle.status.value="readyExecuted",d.eventBuffer.readyCallbacksArray.value.forEach(e=>{zs(e,[],wn,this.logger)}),mu("RSA_Ready")}processBufferedEvents(){let e=d.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let i=e.shift();if(d.eventBuffer.toBeProcessedArray.value=e,i){let s=i[0];D(this[s])&&this[s](...i.slice(1),!0)}e=d.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if(d.lifecycle.status.value==="destinationsLoading"||d.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",d,this.pluginsManager,this.errorHandler,this.logger);let e=d.nativeDestinations.activeDestinations.value.length;if(e===0){Ae(()=>{d.nativeDestinations.clientDestinationsReady.value=!0,d.lifecycle.status.value="destinationsReady"});return}d.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",d,this.externalSrcLoader,this.errorHandler,this.logger),lt(()=>{d.nativeDestinations.initializedDestinations.value.length+d.nativeDestinations.failedDestinations.value.length===e&&Ae(()=>{d.lifecycle.status.value="destinationsReady",d.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){d.lifecycle.status.value!=="ready"&&Ae(()=>{d.lifecycle.status.value="ready"})}ready(e,i=!1){let s="ready";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),!D(e)){this.logger.error(Bu(wn));return}d.lifecycle.status.value==="readyExecuted"?zs(e,[],wn,this.logger):d.eventBuffer.readyCallbacksArray.value=[...d.eventBuffer.readyCallbacksArray.value,e]}page(e,i=!1){let s="page";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),d.capabilities.isAdBlocked.value===!0&&e.category!==ql&&this.page(Ys(ql,Mf,{path:Uf},d.loadOptions.value.sendAdblockPageOptions))}track(e,i=!1){let s="track";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event - ${e.name}`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:s,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,i=!1){let s="identify";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,e.userId&&d.session.userId.value&&e.userId!==d.session.userId.value&&this.reset(),Ve(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:s,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,i=!1){let s="alias";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:s,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,i=!1){let s="group";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,Ve(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:s,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,i=!1){let s="reset";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,i,s=!1){let r="setAnonymousId";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,i]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,i)}getUserId(){return d.session.userId.value}getUserTraits(){return d.session.userTraits.value}getGroupId(){return d.session.groupId.value}getGroupTraits(){return d.session.groupTraits.value}startSession(e,i=!1){let s="startSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let i="endSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,i=!1){let s="consent";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Ae(()=>{d.consents.preConsent.value={...d.consents.preConsent.value,enabled:!1},d.consents.postConsent.value=bm(e);let{initialized:r,consentsData:n}=dc(d.consents.postConsent.value.consentManagement,this.logger);d.consents.initialized.value=r,d.consents.data.value=n}),d.consents.enabled.value&&!d.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(i)}sendTrackingEvents(e){if(d.consents.postConsent.value.trackConsent){let i=co(Bf);e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["track",i]]:this.track(i)}if(d.consents.postConsent.value.sendPageEvent){let i=Ys();e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["page",i]]:this.page(i)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,i,s=!1){let r="addCustomIntegration";if(s)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,i,d,this.logger);else{if(d.lifecycle.loaded.value){this.logger.error(av(Ms,e));return}d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,i]]}}},jt=class jt{constructor(){ae(this,"analyticsInstances",{});ae(this,"defaultAnalyticsKey","");ae(this,"logger",Et);try{if(jt.globalSingleton)return jt.globalSingleton;jt.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.getSessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),jt.globalSingleton=this,d.autoTrack.pageLifecycle.pageViewId.value=ir(),d.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){fe(e)}}createSafeAnalyticsInstance(){d.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(){ec.init(),mo.configure(),vo.configure(),_o.configure(),er.configure()}setDefaultInstanceKey(e){re(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let i=e;return(!re(i)||!i)&&(i=this.defaultAnalyticsKey),this.analyticsInstances[i]||(this.analyticsInstances[i]=new oo),this.analyticsInstances[i]}catch(i){fe(i);return}}load(e,i,s){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(s);let r=Cu(Wi);Jf(r),Ji(Wi,W(r)),this.getAnalyticsInstance(e)?.load(e,i,X(s))}catch(r){fe(r)}}trackPageLifecycleEvents(e){let{autoTrack:i,useBeacon:s}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=i??{},{events:a=[kn.UNLOADED],enabled:l=r,options:u=n}=o??{};d.autoTrack.pageLifecycle.enabled.value=l,d.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,s,u)}setupPageUnloadTracking(e,i,s){(e.length===0||e.includes(kn.UNLOADED))&&(i===!0?wf(r=>{if(r===!1&&d.lifecycle.loaded.value){let n=Date.now(),o=n-d.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(kn.UNLOADED,{timeOnPage:o},{...s,originalTimestamp:Au(new Date(n))})}},!0):this.logger.warn(rv(_f)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],i=Xf(e);Ji(Wi,W([...e])),i.length>0&&(i.shift(),this.load.apply(null,i))}ready(e){try{this.getAnalyticsInstance()?.ready(X(e))}catch(i){fe(i)}}page(e,i,s,r,n){try{this.getAnalyticsInstance()?.page(Ys(X(e),X(i),X(s),X(r),X(n)))}catch(o){fe(o)}}track(e,i,s,r){try{this.getAnalyticsInstance()?.track(co(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}identify(e,i,s,r){try{this.getAnalyticsInstance()?.identify(Eu(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}alias(e,i,s,r){try{this.getAnalyticsInstance()?.alias(Su(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}group(e,i,s,r){try{this.getAnalyticsInstance()?.group(ku(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(X(e))}catch(i){fe(i)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(X(e))}catch(i){fe(i);return}}setAnonymousId(e,i){try{this.getAnalyticsInstance()?.setAnonymousId(X(e),X(i))}catch(s){fe(s)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){fe(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){fe(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){fe(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){fe(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(X(e))}catch(i){fe(i)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){fe(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){fe(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(X(e))}catch(i){fe(i)}}consent(e){try{this.getAnalyticsInstance()?.consent(X(e))}catch(i){fe(i)}}addCustomIntegration(e,i){try{this.getAnalyticsInstance()?.addCustomIntegration(X(e),X(i))}catch(s){fe(s)}}};ae(jt,"globalSingleton",null);pi=jt});var mc,yc,bo,_c,bc,Ec,Sc,kc,Zi=Fe(()=>{"use strict";mc="https://deriv.com/cdn-cgi/trace",yc="https://cdn.growthbook.io",bo="https://deriv-dataplane.rudderstack.com",_c="https://ph.deriv.com",bc="https://us.posthog.com",Ec=()=>{if(typeof window>"u")return _c;let t=window.location.hostname;return t.includes(".deriv.me")?"https://ph.deriv.me":t.includes(".deriv.be")?"https://ph.deriv.be":t.includes(".deriv.ae")?"https://ph.deriv.ae":_c},Sc=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],kc=["deriv.com","derivcrypto.com","besquare.my","besquare.com.my","ewallet.exchange","champion-fx.com","opalstraits.com","binary.com","binary.marketing","championgbs.com","4x.my","re-work.dev","regentmarkets.com","4x.com","binary.me","deriv.team","firstsource.io","firstsource.tech","deriv.hr","vmgbpo.net","mailisk.net","mailosaur.net","mobileapps.mailisk.net","w3e180zd.mailosaur.net"]});function ar(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)t[s]=i[s]}return t}function Eo(t,e){function i(r,n,o){if(!(typeof document>"u")){o=ar({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)o[l]&&(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=r+"="+t.write(n,r)+a}}function s(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var n=document.cookie?document.cookie.split("; "):[],o={},a=0;a<n.length;a++){var l=n[a].split("="),u=l.slice(1).join("=");try{var c=decodeURIComponent(l[0]);if(o[c]=t.read(u,c),r===c)break}catch{}}return r?o[r]:o}}return Object.create({set:i,get:s,remove:function(r,n){i(r,"",ar({},n,{expires:-1}))},withAttributes:function(r){return Eo(this.converter,ar({},this.attributes,r))},withConverter:function(r){return Eo(ar({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var vy,wc,Ac=Fe(()=>{"use strict";vy={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};wc=Eo(vy,{path:"/"})});var Dt,ur,es,lr,Ic,Kt,Tc,Rc,ts=Fe(()=>{"use strict";Ac();Zi();Dt=(t,e)=>(...i)=>{e()&&console.log(`[ANALYTIC]${t}`,...i)},ur=t=>{let e=t.split("@")[1]?.toLowerCase();return e?kc.includes(e):!1},es=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),lr=null,Ic=async()=>{if(lr)return lr;let t=JSON.parse(wc.get("website_status")||"{}")?.clients_country;return lr=(async()=>{try{let e=await fetch(mc).catch(()=>null);if(!e)return t||"";let i=await e.text().catch(()=>"");return i?Object.fromEntries(i.split(`
5
- `).map(r=>r.split("=",2))).loc?.toLowerCase()||t||"":t||""}catch{return t||""}})(),lr},Kt=t=>{if(t==null||typeof t!="object")return t;if(Array.isArray(t)){let s=[];for(let r=0;r<t.length;r++){let n=Kt(t[r]);n!=null&&s.push(n)}return s.length?s:void 0}let e={},i=!1;for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let r=Kt(t[s]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[s]=r,i=!0)}return i?e:void 0},Tc=(t,e)=>{for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let s=t[i];s&&typeof s=="object"&&!Array.isArray(s)?Tc(s,e):e[i]=s}},Rc=t=>{if(t==null||typeof t!="object"||Array.isArray(t))return t;let e={};return Tc(t,e),e}});function Fc(){return $c}function So(t){let e=2166136261,i=t.length;for(let s=0;s<i;s++)e^=t.charCodeAt(s),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function is(t,e,i){return i===2?So(So(t+e)+"")%1e4/1e4:i===1?So(e+t)%1e3/1e3:null}function my(t){return t<=0?[]:new Array(t).fill(1/t)}function gr(t,e){return t>=e[0]&&t<e[1]}function Mc(t,e){let i=is("__"+e[0],t,1);return i===null?!1:i>=e[1]&&i<e[2]}function Uc(t,e){for(let i=0;i<e.length;i++)if(gr(t,e[i]))return i;return-1}function wo(t){try{let e=t.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function fr(t,e){if(!e.length)return!1;let i=!1,s=!1;for(let r=0;r<e.length;r++){let n=Ey(t,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else i=!0,n&&(s=!0)}return s||!i}function yy(t,e,i){try{let s=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return i&&(s="\\/?"+s.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+s+"$","i").test(t)}catch{return!1}}function by(t,e){try{let i=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),s=[[t.host,i.host,!1],[t.pathname,i.pathname,!0]];return i.hash&&s.push([t.hash,i.hash,!1]),i.searchParams.forEach((r,n)=>{s.push([t.searchParams.get(n)||"",r,!1])}),!s.some(r=>!yy(r[0],r[1],r[2]))}catch{return!1}}function Ey(t,e,i){try{let s=new URL(t,"https://_");if(e==="regex"){let r=wo(i);return r?r.test(s.href)||r.test(s.href.substring(s.origin.length)):!1}else if(e==="simple")return by(s,i);return!1}catch{return!1}}function Bc(t,e,i){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let s=my(t);i=i||s,i.length!==t&&(i=s);let r=i.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(i=s);let n=0;return i.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function Vc(t,e,i){if(!e)return null;let s=e.split("?")[1];if(!s)return null;let r=s.replace(/#.*/,"").split("&").map(n=>n.split("=",2)).filter(([n])=>n===t).map(([,n])=>parseInt(n));return r.length>0&&r[0]>=0&&r[0]<i?r[0]:null}function Gc(t){try{return t()}catch(e){return console.error(e),!1}}async function Yt(t,e,i){if(e=e||"",i=i||globalThis.crypto&&globalThis.crypto.subtle||$c.SubtleCrypto,!i)throw new Error("No SubtleCrypto implementation found");try{let s=await i.importKey("raw",ko(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=t.split("."),o=await i.decrypt({name:"AES-CBC",iv:ko(r)},s,ko(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function ss(t){return typeof t=="string"?t:JSON.stringify(t)}function He(t){typeof t=="number"&&(t=t+""),(!t||typeof t!="string")&&(t="0");let e=t.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(i=>i.match(/^[0-9]+$/)?i.padStart(5," "):i).join("-")}function qc(){let t;try{t="1.6.5"}catch{t=""}return t}function jc(t,e){let i,s;try{i=new URL(t),s=new URL(e)}catch(r){return console.error(`Unable to merge query strings: ${r}`),e}return i.searchParams.forEach((r,n)=>{s.searchParams.has(n)||s.searchParams.set(n,r)}),s.toString()}function Lc(t){return typeof t=="object"&&t!==null}function pr(t){return t.urlPatterns&&t.variations.some(e=>Lc(e)&&"urlRedirect"in e)?"redirect":t.variations.some(e=>Lc(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function vr(t,e){return new Promise(i=>{let s=!1,r,n=o=>{s||(s=!0,r&&clearTimeout(r),i(o||null))};e&&(r=setTimeout(()=>n(),e)),t.then(o=>n(o)).catch(()=>n())})}var $c,ko,rs=Fe(()=>{"use strict";$c={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};ko=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0))});function Kc(t){Object.assign(Oe,t),Oe.backgroundSync||Oo()}async function Wc({instance:t,timeout:e,skipCache:i,allowStale:s,backgroundSync:r}){return r||(Oe.backgroundSync=!1),Ay({instance:t,allowStale:s,timeout:e,skipCache:i})}function Sy(t){let e=ns(t),i=yi.get(e)||new Set;i.add(t),yi.set(e,i)}function Yc(t){yi.forEach(e=>e.delete(t))}function ky(){bi.forEach(t=>{t&&(t.state="idle",Ro(t))})}function wy(){bi.forEach(t=>{t&&t.state==="idle"&&Po(t)})}async function zc(){try{if(!ut.localStorage)return;await ut.localStorage.setItem(Oe.cacheKey,JSON.stringify(Array.from(St.entries())))}catch{}}async function Ay({instance:t,allowStale:e,timeout:i,skipCache:s}){let r=ns(t),n=Io(t),o=new Date,a=new Date(o.getTime()-Oe.maxAge+Oe.staleTTL);await Iy();let l=!Oe.disableCache&&!s?St.get(n):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&Ei.add(r),l.staleAt<o?Ao(t):To(t),{data:l.data,success:!0,source:"cache"}):await vr(Ao(t),i)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function ns(t){let[e,i]=t.getApiInfo();return`${e}||${i}`}function Io(t){let e=ns(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;let i=t.getAttributes(),s=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};s.forEach(a=>{r[a]=i[a]});let n=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:r,fv:n,url:o})}`}async function Iy(){if(!Hc){Hc=!0;try{if(ut.localStorage){let t=await ut.localStorage.getItem(Oe.cacheKey);if(!Oe.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(([i,s])=>{St.set(i,{...s,staleAt:new Date(s.staleAt)})}),Xc()}}}catch{}if(!Oe.disableIdleStreams){let t=mi.startIdleListener();t&&(mi.stopIdleListener=t)}}}function Xc(){let t=Array.from(St.entries()).map(([i,s])=>({key:i,staleAt:s.staleAt.getTime()})).sort((i,s)=>i.staleAt-s.staleAt),e=Math.min(Math.max(0,St.size-Oe.maxEntries),St.size);for(let i=0;i<e;i++)St.delete(t[i].key)}function Jc(t,e,i){let s=i.dateUpdated||"",r=new Date(Date.now()+Oe.staleTTL),n=Oe.disableCache?void 0:St.get(e);if(n&&s&&n.version===s){n.staleAt=r,zc();return}Oe.disableCache||(St.set(e,{data:i,version:s,staleAt:r,sse:Ei.has(t)}),Xc()),zc();let o=yi.get(t);o&&o.forEach(a=>Ty(a,i))}async function Ty(t,e){await t.setPayload(e||t.getPayload())}async function Ao(t){let{apiHost:e,apiRequestHeaders:i}=t.getApiHosts(),s=t.getClientKey(),r="isRemoteEval"in t&&t.isRemoteEval(),n=ns(t),o=Io(t),a=_r.get(o);return a||(a=(r?mi.fetchRemoteEvalCall({host:e,clientKey:s,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:i}):mi.fetchFeaturesCall({host:e,clientKey:s,headers:i})).then(u=>{if(!u.ok)throw new Error(`HTTP error: ${u.status}`);return u.headers.get("x-sse-support")==="enabled"&&Ei.add(n),u.json()}).then(u=>(Jc(n,o,u),To(t),_r.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(_r.delete(o),{data:null,source:"error",success:!1,error:u})),_r.set(o,a)),a}function To(t,e=!1){let i=ns(t),s=Io(t),{streamingHost:r,streamingHostRequestHeaders:n}=t.getApiHosts(),o=t.getClientKey();if(e&&Ei.add(i),Oe.backgroundSync&&Ei.has(i)&&ut.EventSource){if(bi.has(i))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let u=yi.get(i);u&&u.forEach(c=>{Ao(c)})}else if(l.type==="features"){let u=JSON.parse(l.data);Jc(i,s,u)}a.errors=0}catch{Qc(a)}},errors:0,state:"active"};bi.set(i,a),Po(a)}}function Qc(t){if(t.state!=="idle"&&(t.errors++,t.errors>3||t.src&&t.src.readyState===2)){let e=Math.pow(3,t.errors-3)*(1e3+Math.random()*1e3);Ro(t),setTimeout(()=>{["idle","active"].includes(t.state)||Po(t)},Math.min(e,3e5))}}function Ro(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,t.state==="active"&&(t.state="disabled"))}function Po(t){t.src=mi.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state="active",t.src.addEventListener("features",t.cb),t.src.addEventListener("features-updated",t.cb),t.src.onerror=()=>Qc(t),t.src.onopen=()=>{t.errors=0}}function Ry(t,e){Ro(t),bi.delete(e)}function Oo(){Ei.clear(),bi.forEach(Ry),yi.clear(),mi.stopIdleListener()}function mr(t,e){if(e.streaming){if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&To(t,!0),Sy(t)}}var Oe,ut,mi,yi,Hc,St,_r,bi,Ei,Zc=Fe(()=>{"use strict";rs();Oe={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},ut=Fc(),mi={fetchFeaturesCall:({host:t,clientKey:e,headers:i})=>ut.fetch(`${t}/api/features/${e}`,{headers:i}),fetchRemoteEvalCall:({host:t,clientKey:e,payload:i,headers:s})=>{let r={method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(i)};return ut.fetch(`${t}/api/eval/${e}`,r)},eventSourceCall:({host:t,clientKey:e,headers:i})=>i?new ut.EventSource(`${t}/sub/${e}`,{headers:i}):new ut.EventSource(`${t}/sub/${e}`),startIdleListener:()=>{let t;if(!(typeof window<"u"&&typeof document<"u"))return;let i=()=>{document.visibilityState==="visible"?(window.clearTimeout(t),wy()):document.visibilityState==="hidden"&&(t=window.setTimeout(ky,Oe.idleStreamInterval))};return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(ut.localStorage=globalThis.localStorage)}catch{}yi=new Map,Hc=!1,St=new Map,_r=new Map,bi=new Map,Ei=new Set});function Oy(t){return t==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}function kr(t){var e=Sr.get(t);return e||(e={element:t,attributes:{}},Sr.set(t,e)),e}function wr(t,e,i,s,r){var n=i(t),o={isDirty:!1,originalValue:n,virtualValue:n,mutations:[],el:t,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=i(t);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,r(o))}}),mutationRunner:r,setValue:s,getCurrentValue:i};return e==="position"&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,Oy(e)),o}function Ar(t,e){var i=e.getCurrentValue(e.el);e.virtualValue=t,t&&typeof t!="string"?(!i||t.parentNode!==i.parentNode||t.insertBeforeNode!==i.insertBeforeNode)&&(e.isDirty=!0,ed()):t!==i&&(e.isDirty=!0,ed())}function Cy(t){var e=t.originalValue;t.mutations.forEach(function(i){return e=i.mutate(e)}),Ar(Hy(e),t)}function xy(t){var e=new Set(t.originalValue.split(/\s+/).filter(Boolean));t.mutations.forEach(function(i){return i.mutate(e)}),Ar(Array.from(e).filter(Boolean).join(" "),t)}function Ny(t){var e=t.originalValue;t.mutations.forEach(function(i){return e=i.mutate(e)}),Ar(e,t)}function Dy(t){var e=t.parentSelector,i=t.insertBeforeSelector,s=document.querySelector(e);if(!s)return null;var r=i?document.querySelector(i):null;return i&&!r?null:{parentNode:s,insertBeforeNode:r}}function Ly(t){var e=t.originalValue;t.mutations.forEach(function(i){var s=i.mutate(),r=Dy(s);e=r||e}),Ar(e,t)}function id(t){var e=kr(t);return e.html||(e.html=wr(t,"html",$y,Fy,Cy)),e.html}function sd(t){var e=kr(t);return e.position||(e.position=wr(t,"position",My,Uy,Ly)),e.position}function rd(t){var e=kr(t);return e.classes||(e.classes=wr(t,"class",Vy,By,xy)),e.classes}function nd(t,e){var i=kr(t);return i.attributes[e]||(i.attributes[e]=wr(t,e,Gy(e),qy(e),Ny)),i.attributes[e]}function jy(t,e){var i=Sr.get(t);if(i)if(e==="html"){var s,r;(s=i.html)==null||(r=s.observer)==null||r.disconnect(),delete i.html}else if(e==="class"){var n,o;(n=i.classes)==null||(o=n.observer)==null||o.disconnect(),delete i.classes}else if(e==="position"){var a,l;(a=i.position)==null||(l=a.observer)==null||l.disconnect(),delete i.position}else{var u,c,h;(u=i.attributes)==null||(c=u[e])==null||(h=c.observer)==null||h.disconnect(),delete i.attributes[e]}}function Hy(t){return yr||(yr=document.createElement("div")),yr.innerHTML=t,yr.innerHTML}function br(t,e,i){if(i.isDirty){i.isDirty=!1;var s=i.virtualValue;i.mutations.length||jy(t,e),i.setValue(t,s)}}function zy(t,e){t.html&&br(e,"html",t.html),t.classes&&br(e,"class",t.classes),t.position&&br(e,"position",t.position),Object.keys(t.attributes).forEach(function(i){br(e,i,t.attributes[i])})}function ed(){Sr.forEach(zy)}function Ky(t,e){var i=null;t.kind==="html"?i=id(e):t.kind==="class"?i=rd(e):t.kind==="attribute"?i=nd(e,t.attribute):t.kind==="position"&&(i=sd(e)),i&&(i.mutations.push(t),i.mutationRunner(i))}function Wy(t,e){var i=null;if(t.kind==="html"?i=id(e):t.kind==="class"?i=rd(e):t.kind==="attribute"?i=nd(e,t.attribute):t.kind==="position"&&(i=sd(e)),!!i){var s=i.mutations.indexOf(t);s!==-1&&i.mutations.splice(s,1),i.mutationRunner(i)}}function od(t){if(!(t.kind==="position"&&t.elements.size===1)){var e=new Set(t.elements),i=document.querySelectorAll(t.selector);i.forEach(function(s){e.has(s)||(t.elements.add(s),Ky(t,s))})}}function Yy(t){t.elements.forEach(function(e){return Wy(t,e)}),t.elements.clear(),Do.delete(t)}function td(){Do.forEach(od)}function Xy(){typeof document>"u"||(Co||(Co=new MutationObserver(function(){td()})),td(),Co.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Ir(t){return typeof document>"u"?No:(Do.add(t),od(t),{revert:function(){Yy(t)}})}function xo(t,e){return Ir({kind:"html",elements:new Set,mutate:e,selector:t})}function ad(t,e){return Ir({kind:"position",elements:new Set,mutate:e,selector:t})}function os(t,e){return Ir({kind:"class",elements:new Set,mutate:e,selector:t})}function Er(t,e,i){return Py.test(e)?e==="class"||e==="className"?os(t,function(s){var r=i(Array.from(s).join(" "));s.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return s.add(n)})}):Ir({kind:"attribute",attribute:e,elements:new Set,mutate:i,selector:t}):No}function Jy(t){var e=t.selector,i=t.action,s=t.value,r=t.attribute,n=t.parentSelector,o=t.insertBeforeSelector;if(r==="html"){if(i==="append")return xo(e,function(a){return a+(s??"")});if(i==="set")return xo(e,function(){return s??""})}else if(r==="class"){if(i==="append")return os(e,function(a){s&&a.add(s)});if(i==="remove")return os(e,function(a){s&&a.delete(s)});if(i==="set")return os(e,function(a){a.clear(),s&&a.add(s)})}else if(r==="position"){if(i==="set"&&n)return ad(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(i==="append")return Er(e,r,function(a){return a!==null?a+(s??""):s??""});if(i==="set")return Er(e,r,function(){return s??""});if(i==="remove")return Er(e,r,function(){return null})}return No}var Py,No,Sr,Do,$y,Fy,My,Uy,By,Vy,Gy,qy,yr,Co,Qy,ld,ud=Fe(()=>{"use strict";Py=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,No={revert:function(){}},Sr=new Map,Do=new Set;$y=function(e){return e.innerHTML},Fy=function(e,i){return e.innerHTML=i};My=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Uy=function(e,i){i.insertBeforeNode&&!i.parentNode.contains(i.insertBeforeNode)||i.parentNode.insertBefore(e,i.insertBeforeNode)};By=function(e,i){return i?e.className=i:e.removeAttribute("class")},Vy=function(e){return e.className};Gy=function(e){return function(i){var s;return(s=i.getAttribute(e))!=null?s:null}},qy=function(e){return function(i,s){return s!==null?i.setAttribute(e,s):i.removeAttribute(e)}};Xy();Qy={html:xo,classes:os,attribute:Er,position:ad,declarative:Jy},ld=Qy});function Lt(t,e,i){i=i||{};for(let[s,r]of Object.entries(e))switch(s){case"$or":if(!hd(t,r,i))return!1;break;case"$nor":if(hd(t,r,i))return!1;break;case"$and":if(!sb(t,r,i))return!1;break;case"$not":if(Lt(t,r,i))return!1;break;default:if(!as(r,Zy(t,s),i))return!1}return!0}function Zy(t,e){let i=e.split("."),s=t;for(let r=0;r<i.length;r++)if(s&&typeof s=="object"&&i[r]in s)s=s[i[r]];else return null;return s}function cd(t,e=!1){let i=`${t}${e?"/i":""}`;return Lo[i]||(Lo[i]=new RegExp(t.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Lo[i]}function as(t,e,i,s=!1){if(typeof t=="string")return s?String(e).toLowerCase()===t.toLowerCase():e+""===t;if(typeof t=="number")return e*1===t;if(typeof t=="boolean")return e!==null&&!!e===t;if(t===null)return e===null;if(Array.isArray(t)||!gd(t))return JSON.stringify(e)===JSON.stringify(t);for(let r in t)if(!ib(r,e,t[r],i))return!1;return!0}function gd(t){let e=Object.keys(t);return e.length>0&&e.filter(i=>i[0]==="$").length===e.length}function eb(t){if(t===null)return"null";if(Array.isArray(t))return"array";let e=typeof t;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function tb(t,e,i){if(!Array.isArray(t))return!1;let s=gd(e)?r=>as(e,r,i):r=>Lt(r,e,i);for(let r=0;r<t.length;r++)if(t[r]&&s(t[r]))return!0;return!1}function Si(t,e,i=!1){if(i){let s=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(t)?t.some(r=>e.some(n=>s(r)===s(n))):e.some(r=>s(t)===s(r))}return Array.isArray(t)?t.some(s=>e.includes(s)):e.includes(t)}function dd(t,e,i,s=!1){if(!Array.isArray(t))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<t.length;o++)if(as(e[r],t[o],i,s)){n=!0;break}if(!n)return!1}return!0}function ib(t,e,i,s){switch(t){case"$veq":return He(e)===He(i);case"$vne":return He(e)!==He(i);case"$vgt":return He(e)>He(i);case"$vgte":return He(e)>=He(i);case"$vlt":return He(e)<He(i);case"$vlte":return He(e)<=He(i);case"$eq":return e===i;case"$ne":return e!==i;case"$lt":return e<i;case"$lte":return e<=i;case"$gt":return e>i;case"$gte":return e>=i;case"$exists":return i?e!=null:e==null;case"$in":return Array.isArray(i)?Si(e,i):!1;case"$ini":return Array.isArray(i)?Si(e,i,!0):!1;case"$inGroup":return Si(e,s[i]||[]);case"$notInGroup":return!Si(e,s[i]||[]);case"$nin":return Array.isArray(i)?!Si(e,i):!1;case"$nini":return Array.isArray(i)?!Si(e,i,!0):!1;case"$not":return!as(i,e,s);case"$size":return Array.isArray(e)?as(i,e.length,s):!1;case"$elemMatch":return tb(e,i,s);case"$all":return Array.isArray(i)?dd(e,i,s):!1;case"$alli":return Array.isArray(i)?dd(e,i,s,!0):!1;case"$regex":try{return cd(i).test(e)}catch{return!1}case"$regexi":try{return cd(i,!0).test(e)}catch{return!1}case"$type":return eb(e)===i;default:return console.error("Unknown operator: "+t),!1}}function hd(t,e,i){if(!e.length)return!0;for(let s=0;s<e.length;s++)if(Lt(t,e[s],i))return!0;return!1}function sb(t,e,i){for(let s=0;s<e.length;s++)if(!Lt(t,e[s],i))return!1;return!0}var Lo,fd=Fe(()=>{"use strict";rs();Lo={}});function ob(t){let e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach((i,s)=>e.set(s,i)),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach((i,s)=>e.set(s,i)),e}function ab(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}async function ki(t){try{await t()}catch{}}function pd(t,e,i){if(t.user.trackedExperiments){let r=Pr(e,i);if(t.user.trackedExperiments.has(r))return[];t.user.trackedExperiments.add(r)}t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({experiment:e,result:i,timestamp:Date.now().toString(),logType:"experiment"});let s=[];if(t.global.trackingCallback){let r=t.global.trackingCallback;s.push(ki(()=>r(e,i,t.user)))}if(t.user.trackingCallback){let r=t.user.trackingCallback;s.push(ki(()=>r(e,i)))}if(t.global.eventLogger){let r=t.global.eventLogger;s.push(ki(()=>r(nb,{experimentId:e.key,variationId:i.key,hashAttribute:i.hashAttribute,hashValue:i.hashValue},t.user)))}return s}function lb(t,e,i){if(t.user.trackedFeatureUsage){let s=JSON.stringify(i.value);if(t.user.trackedFeatureUsage[e]===s)return;t.user.trackedFeatureUsage[e]=s,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:i,timestamp:Date.now().toString(),logType:"feature"})}if(t.global.onFeatureUsage){let s=t.global.onFeatureUsage;ki(()=>s(e,i,t.user))}if(t.user.onFeatureUsage){let s=t.user.onFeatureUsage;ki(()=>s(e,i))}if(t.global.eventLogger){let s=t.global.eventLogger;ki(()=>s(rb,{feature:e,source:i.source,value:i.value,ruleId:i.source==="defaultValue"?"$default":i.ruleId||"",variationId:i.experimentResult?i.experimentResult.key:""},t.user))}}function Tr(t,e){if(e.stack.evaluatedFeatures.has(t))return $t(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;let i=ob(e);if(i.has(t))return $t(e,t,i.get(t),"override");if(!e.global.features||!e.global.features[t])return $t(e,t,null,"unknownFeature");let s=e.global.features[t];if(s.rules){let r=new Set(e.stack.evaluatedFeatures);e:for(let n of s.rules){if(n.parentConditions)for(let l of n.parentConditions){e.stack.evaluatedFeatures=new Set(r);let u=Tr(l.id,e);if(u.source==="cyclicPrerequisite")return $t(e,t,null,"cyclicPrerequisite");let c={value:u.value};if(!Lt(c,l.condition||{})){if(l.gate)return $t(e,t,null,"prerequisite");continue e}}if(n.filters&&md(n.filters,e))continue;if("force"in n){if(n.condition&&!_d(n.condition,e)||!ub(e,n.seed||t,n.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0,n.range,n.coverage,n.hashVersion))continue;return n.tracks&&n.tracks.forEach(l=>{!pd(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),$t(e,t,n.force,"force",n.id)}if(!n.variations)continue;let o={variations:n.variations,key:n.key||t};"coverage"in n&&(o.coverage=n.coverage),n.weights&&(o.weights=n.weights),n.hashAttribute&&(o.hashAttribute=n.hashAttribute),n.fallbackAttribute&&(o.fallbackAttribute=n.fallbackAttribute),n.disableStickyBucketing&&(o.disableStickyBucketing=n.disableStickyBucketing),n.bucketVersion!==void 0&&(o.bucketVersion=n.bucketVersion),n.minBucketVersion!==void 0&&(o.minBucketVersion=n.minBucketVersion),n.namespace&&(o.namespace=n.namespace),n.meta&&(o.meta=n.meta),n.ranges&&(o.ranges=n.ranges),n.name&&(o.name=n.name),n.phase&&(o.phase=n.phase),n.seed&&(o.seed=n.seed),n.hashVersion&&(o.hashVersion=n.hashVersion),n.filters&&(o.filters=n.filters),n.condition&&(o.condition=n.condition);let{result:a}=Rr(o,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return $t(e,t,a.value,"experiment",n.id,o,a)}}return $t(e,t,s.defaultValue===void 0?null:s.defaultValue,"defaultValue")}function Rr(t,e,i){let s=t.key,r=t.variations.length;if(r<2)return{result:le(i,t,-1,!1,e)};if(i.global.enabled===!1||i.user.enabled===!1)return{result:le(i,t,-1,!1,e)};if(t=cb(t,i),t.urlPatterns&&!fr(i.user.url||"",t.urlPatterns))return{result:le(i,t,-1,!1,e)};let n=Vc(s,i.user.url||"",r);if(n!==null)return{result:le(i,t,n,!1,e)};let o=ab(i);if(s in o){let m=o[s];return{result:le(i,t,m,!1,e)}}if(t.status==="draft"||t.active===!1)return{result:le(i,t,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Xt(i,t.hashAttribute,i.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!l)return{result:le(i,t,-1,!1,e)};let u=-1,c=!1,h=!1;if(i.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{variation:m,versionIsBlocked:y}=gb({ctx:i,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});c=m>=0,u=m,h=!!y}if(!c){if(t.filters){if(md(t.filters,i))return{result:le(i,t,-1,!1,e)}}else if(t.namespace&&!Mc(l,t.namespace))return{result:le(i,t,-1,!1,e)};if(t.include&&!Gc(t.include))return{result:le(i,t,-1,!1,e)};if(t.condition&&!_d(t.condition,i))return{result:le(i,t,-1,!1,e)};if(t.parentConditions){let m=new Set(i.stack.evaluatedFeatures);for(let y of t.parentConditions){i.stack.evaluatedFeatures=new Set(m);let w=Tr(y.id,i);if(w.source==="cyclicPrerequisite")return{result:le(i,t,-1,!1,e)};let R={value:w.value};if(!Lt(R,y.condition||{}))return{result:le(i,t,-1,!1,e)}}}if(t.groups&&!hb(t.groups,i))return{result:le(i,t,-1,!1,e)}}if(t.url&&!db(t.url,i))return{result:le(i,t,-1,!1,e)};let f=is(t.seed||s,l,t.hashVersion||1);if(f===null)return{result:le(i,t,-1,!1,e)};if(!c){let m=t.ranges||Bc(r,t.coverage===void 0?1:t.coverage,t.weights);u=Uc(f,m)}if(h)return{result:le(i,t,-1,!1,e,void 0,!0)};if(u<0)return{result:le(i,t,-1,!1,e)};if("force"in t)return{result:le(i,t,t.force===void 0?-1:t.force,!1,e)};if(i.global.qaMode||i.user.qaMode)return{result:le(i,t,-1,!1,e)};if(t.status==="stopped")return{result:le(i,t,-1,!1,e)};let g=le(i,t,u,!0,e,f,c);if(i.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{changed:m,key:y,doc:w}=pb(i,a,ss(l),{[$o(t.key,t.bucketVersion)]:g.key});m&&(i.user.stickyBucketAssignmentDocs=i.user.stickyBucketAssignmentDocs||{},i.user.stickyBucketAssignmentDocs[y]=w,i.user.saveStickyBucketAssignmentDoc(w))}let p=pd(i,t,g);p.length===0&&i.global.saveDeferredTrack&&i.global.saveDeferredTrack({experiment:t,result:g});let v=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in t&&t.changeId&&i.global.recordChangeId&&i.global.recordChangeId(t.changeId),{result:g,trackingCall:v}}function $t(t,e,i,s,r,n,o){let a={value:i,on:!!i,off:!i,source:s,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),s!=="override"&&lb(t,e,a),a}function vd(t){return{...t.user.attributes,...t.user.attributeOverrides}}function _d(t,e){return Lt(vd(e),t,e.global.savedGroups||{})}function md(t,e){return t.some(i=>{let{hashValue:s}=Xt(e,i.attribute);if(!s)return!0;let r=is(i.seed,s,i.hashVersion||2);return r===null?!0:!i.ranges.some(n=>gr(r,n))})}function ub(t,e,i,s,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=Xt(t,i,s);if(!a)return!1;let l=is(e,a,o||1);return l===null?!1:r?gr(l,r):n!==void 0?l<=n:!0}function le(t,e,i,s,r,n,o){let a=!0;(i<0||i>=e.variations.length)&&(i=0,a=!1);let{hashAttribute:l,hashValue:u}=Xt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),c=e.meta?e.meta[i]:{},h={key:c.key||""+i,featureId:r,inExperiment:a,hashUsed:s,variationId:i,value:e.variations[i],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};return c.name&&(h.name=c.name),n!==void 0&&(h.bucket=n),c.passthrough&&(h.passthrough=c.passthrough),h}function cb(t,e){let i=t.key,s=e.global.overrides;return s&&s[i]&&(t=Object.assign({},t,s[i]),typeof t.url=="string"&&(t.url=wo(t.url))),t}function Xt(t,e,i){let s=e||"id",r="",n=vd(t);return n[s]&&(r=n[s]),!r&&i&&(n[i]&&(r=n[i]),r&&(s=i)),{hashAttribute:s,hashValue:r}}function db(t,e){let i=e.user.url;if(!i)return!1;let s=i.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(t.test(i)||t.test(s))}function hb(t,e){let i=e.global.groups||{};for(let s=0;s<t.length;s++)if(i[t[s]])return!0;return!1}function gb({ctx:t,expKey:e,expBucketVersion:i,expHashAttribute:s,expFallbackAttribute:r,expMinBucketVersion:n,expMeta:o}){i=i||0,n=n||0,s=s||"id",o=o||[];let a=$o(e,i),l=fb(t,s,r);if(n>0)for(let h=0;h<n;h++){let f=$o(e,h);if(l[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let u=l[a];if(u===void 0)return{variation:-1};let c=o.findIndex(h=>h.key===u);return c<0?{variation:-1}:{variation:c}}function $o(t,e){return e=e||0,`${t}__${e}`}function Fo(t,e){return`${t}||${e}`}function fb(t,e,i){if(!t.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:s,hashValue:r}=Xt(t,e),n=Fo(s,ss(r)),{hashAttribute:o,hashValue:a}=Xt(t,i),l=a?Fo(o,ss(a)):null,u={};return l&&t.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[l].assignments||{}),t.user.stickyBucketAssignmentDocs[n]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[n].assignments||{}),u}function pb(t,e,i,s){let r=Fo(e,i),n=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[r]?t.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o={...n,...s},a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:i,assignments:o},changed:a}}function vb(t,e){let i=new Set,s=e&&e.features?e.features:t.global.features||{},r=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(s).forEach(n=>{let o=s[n];if(o.rules)for(let a of o.rules)a.variations&&(i.add(a.hashAttribute||"id"),a.fallbackAttribute&&i.add(a.fallbackAttribute))}),r.map(n=>{i.add(n.hashAttribute||"id"),n.fallbackAttribute&&i.add(n.fallbackAttribute)}),Array.from(i)}async function yd(t,e,i){let s=Mo(t,i);return e.getAllAssignments(s)}function Mo(t,e){let i={};return vb(t,e).forEach(r=>{let{hashValue:n}=Xt(t,r);i[r]=ss(n)}),i}async function bd(t,e,i){if(t={...t},t.encryptedFeatures){try{t.features=JSON.parse(await Yt(t.encryptedFeatures,e,i))}catch(s){console.error(s)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await Yt(t.encryptedExperiments,e,i))}catch(s){console.error(s)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await Yt(t.encryptedSavedGroups,e,i))}catch(s){console.error(s)}delete t.encryptedSavedGroups}return t}function Ed(t){let e=t.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(t.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}function Pr(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}var rb,nb,Sd=Fe(()=>{"use strict";fd();rs();rb="Feature Evaluated",nb="Experiment Viewed"});var wi,_b,ls,kd=Fe(()=>{"use strict";ud();rs();Zc();Sd();wi=typeof window<"u"&&typeof document<"u",_b=qc(),ls=class{constructor(e){if(e=e||{},this.version=_b,this._options=this.context=e,this._renderer=e.renderer||null,this._trackedExperiments=new Set,this._completedChangeIds=new Set,this._trackedFeatures={},this.debug=!!e.debug,this._subscriptions=new Set,this.ready=!1,this._assigned=new Map,this._activeAutoExperiments=new Map,this._triggeredExpKeys=new Set,this._initialized=!1,this._redirectedUrl="",this._deferredTrackingCalls=new Map,this._autoExperimentsAllowed=!e.disableExperimentsOnLoad,this._destroyCallbacks=[],this.logs=[],this.log=this.log.bind(this),this._saveDeferredTrack=this._saveDeferredTrack.bind(this),this._onExperimentEval=this._onExperimentEval.bind(this),this._fireSubscriptions=this._fireSubscriptions.bind(this),this._recordChangedId=this._recordChangedId.bind(this),e.remoteEval){if(e.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!e.clientKey)throw new Error("Missing clientKey");let i=!1;try{i=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(i)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(e.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(e.stickyBucketService){let i=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=s=>i.saveAssignments(s)}if(e.plugins)for(let i of e.plugins)i(this);if(e.features&&(this.ready=!0),wi&&e.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),e.experiments&&(this.ready=!0,this._updateAllAutoExperiments()),this._options.stickyBucketService&&this._options.stickyBucketAssignmentDocs)for(let i in this._options.stickyBucketAssignmentDocs){let s=this._options.stickyBucketAssignmentDocs[i];s&&this._options.stickyBucketService.saveAssignments(s).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let i=await bd(e,this._options.decryptionKey);this._decryptedPayload=i,await this.refreshStickyBuckets(i),i.features&&(this._options.features=i.features),i.savedGroups&&(this._options.savedGroups=i.savedGroups),i.experiments&&(this._options.experiments=i.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let i=e.payload;if(i.encryptedExperiments||i.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this._options.stickyBucketService&&!this._options.stickyBucketAssignmentDocs&&(this._options.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this._options.stickyBucketService,i)),this._payload=i,this._decryptedPayload=i,i.features&&(this._options.features=i.features),i.experiments&&(this._options.experiments=i.experiments,this._updateAllAutoExperiments()),this.ready=!0,mr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Kc(e.cacheSettings),e.payload)return await this.setPayload(e.payload),mr(this,e),{success:!0,source:"init"};{let{data:i,...s}=await this._refresh({...e,allowStale:!0});return mr(this,e),await this.setPayload(i||{}),s}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let i=await this._refresh({...e||{},allowStale:!1});i.data&&await this.setPayload(i.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return Ed(this._options)}getClientKey(){return this._options.clientKey||""}getPayload(){return this._payload||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this._decryptedPayload||this.getPayload()}isRemoteEval(){return this._options.remoteEval||!1}getCacheKeyAttributes(){return this._options.cacheKeyAttributes}async _refresh({timeout:e,skipCache:i,allowStale:s,streaming:r}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Wc({instance:this,timeout:e,skipCache:i||this._options.disableCache,allowStale:s,backgroundSync:r??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,i,s){let r=await Yt(e,i||this._options.decryptionKey,s);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,i,s){let r=await Yt(e,i||this._options.decryptionKey,s);this.setExperiments(JSON.parse(r))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(i=>{try{i()}catch(s){console.error(s)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,Yc(this),e.destroyAllStreams&&Oo(),this.logs=[],wi&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(i=>{i.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,i){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=i,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:i}=Rr(e,null,this._getEvalContext());return this._onExperimentEval(e,i),i}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(s=>s.key===e).map(s=>this._runAutoExperiment(s)).filter(s=>s!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,i){let s=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!s)return null;let r=this._isAutoExperimentBlockedByContext(e),n,o;r?n=le(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=Rr(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!i&&n.inExperiment&&s&&s.valueHash===a)return n;if(s&&this._undoActiveAutoExperiment(e),n.inExperiment){let l=pr(e);if(l==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let u=e.persistQueryString?jc(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(fr(u,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=u;let{navigate:c,delay:h}=this._getNavigateFunction();if(c)if(wi)Promise.all([...o?[vr(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??h))]).then(()=>{try{c(u)}catch(f){console.error(f)}});else try{c(u)}catch(f){console.error(f)}}else if(l==="visual"){let u=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(n.value):this._applyDOMChanges(n.value);u&&this._activeAutoExperiments.set(e,{undo:u,valueHash:a})}}return n}_undoActiveAutoExperiment(e){let i=this._activeAutoExperiments.get(e);i&&(i.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let i=this._options.experiments||[],s=new Set(i);this._activeAutoExperiments.forEach((r,n)=>{s.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of i){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&pr(r)==="redirect")break}}_onExperimentEval(e,i){let s=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:i}),this._subscriptions.size>0&&this._fireSubscriptions(e,i,s)}_fireSubscriptions(e,i,s){(!s||s.result.inExperiment!==i.inExperiment||s.result.variationId!==i.variationId)&&this._subscriptions.forEach(r=>{try{r(e,i)}catch(n){console.error(n)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,i){let s=this.evalFeature(e).value;return s===null?i:s}feature(e){return this.evalFeature(e)}evalFeature(e){return Tr(e,this._getEvalContext())}log(e,i){this.debug&&(this._options.log?this._options.log(e,i):console.log(e,i))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(i=>i&&i.experiment&&i.result).map(i=>[Pr(i.experiment,i.result),i]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(i=>{!i||!i.experiment||!i.result?console.error("Invalid deferred tracking call",{call:i}):e.push(this._options.trackingCallback(i.experiment,i.result))}),this._deferredTrackingCalls.clear(),await Promise.all(e)}setTrackingCallback(e){this._options.trackingCallback=e,this.fireDeferredTrackingCalls()}setFeatureUsageCallback(e){this._options.onFeatureUsage=e}setEventLogger(e){this._options.eventLogger=e}async logEvent(e,i){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:i,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,i||{},this._getUserContext())}catch(s){console.error(s)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Pr(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(wi?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let i=pr(e);if(i==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(s=>s.js))return!0}else if(i==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let s=new URL(this._getContextUrl());for(let r of e.variations){if(!r||!r.urlRedirect)continue;let n=new URL(r.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(n.protocol!==s.protocol||n.host!==s.host))return!0}}catch(s){return this.log("Error parsing current or redirect URL",{id:e.key,error:s}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:wi?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!wi)return;let i=[];if(e.css){let s=document.createElement("style");s.innerHTML=e.css,document.head.appendChild(s),i.push(()=>s.remove())}if(e.js){let s=document.createElement("script");s.innerHTML=e.js,this._options.jsInjectionNonce&&(s.nonce=this._options.jsInjectionNonce),document.head.appendChild(s),i.push(()=>s.remove())}return e.domMutations&&e.domMutations.forEach(s=>{i.push(ld.declarative(s).revert)}),()=>{i.forEach(s=>s())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let i=this._getEvalContext(),s=await yd(i,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=s}}generateStickyBucketAssignmentDocsSync(e,i){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let s=this._getEvalContext(),r=Mo(s,i);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var wd=Fe(()=>{"use strict";kd()});var Ad={};Sn(Ad,{Growthbook:()=>Uo});var Xe,Uo,Id=Fe(()=>{"use strict";wd();yo();Zi();ts();Xe=class Xe{constructor(e,i,s={},r=!1){this.analytics=new pi;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Dt("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:i,user_language:s,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:u,url:c,domain:h,utm_content:f,residence_country:g,loggedIn:p,network_type:v,network_downlink:m,user_id:y,anonymous_id:w,account_mode:R})=>{let b={...this.GrowthBook.getAttributes(),id:e,...y!==void 0&&{user_id:y},...w!==void 0&&{anonymous_id:w},...i!==void 0&&{country:i},...g!==void 0&&{residence_country:g},...s!==void 0&&{user_language:s},...r!==void 0&&{device_language:r},...n!==void 0&&{device_type:n},...o!==void 0&&{utm_source:o},...a!==void 0&&{utm_medium:a},...l!==void 0&&{utm_campaign:l},...u!==void 0&&{is_authorised:u},...c!==void 0&&{url:c},...h!==void 0&&{domain:h},...f!==void 0&&{utm_content:f},...p!==void 0&&{loggedIn:p},...v!==void 0&&{network_type:v},...m!==void 0&&{network_downlink:m},...R!==void 0&&{account_mode:R}};this.log("setAttributes | updating GrowthBook attributes",b),this.GrowthBook.setAttributes(b)};this.getFeatureValue=(e,i)=>{let s=this.GrowthBook.getFeatureValue(e,i);return this.log("getFeatureValue",{key:e,value:s,defaultValue:i}),s};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let i=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:i}),i};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let i=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:i}),i};this.init=async()=>{this.log("init | initializing GrowthBook SDK");let e=await this.GrowthBook.init({timeout:2e3,streaming:!0}).catch(()=>{});this.status=e,this.isLoaded=!0,this.log("init | GrowthBook SDK loaded",{status:e})};this.destroy=()=>{this.GrowthBook.destroy(),this.isLoaded=!1,this.status=void 0};this.debug=r;let n=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new ls({apiHost:yc,clientKey:e,decryptionKey:i,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:n,trackingCallback:(o,a)=>{this.log("trackingCallback | experiment viewed",{experiment_id:o.key,variation_id:a.variationId}),typeof window<"u"&&window.dataLayer&&window.dataLayer.push({event:"experiment_viewed",event_category:"experiment",rudder_anonymous_id:this.analytics.getAnonymousId(),experiment_id:o.key,variation_id:a.variationId}),this.analytics.track("experiment_viewed",{experimentId:o.key,variationId:a.variationId})},...s}),this.init()}reapplyExperiment(e){let i=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(i)}waitForIsLoaded(e=1e4){return new Promise((i,s)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),i()):Date.now()-r>=e&&(clearInterval(n),s(new Error("GrowthBook initialization timeout")))},100)})}};Xe.getGrowthBookInstance=(e,i,s,r=!1)=>Xe._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),Xe._instance):(Xe._instance=new Xe(e,i??"",s,r),Xe._instance),Xe.resetInstance=()=>{Xe._instance&&(Xe._instance.destroy(),Xe._instance=void 0)};Uo=Xe});function Pd(t,e,i,s,r,n,o){try{var a=t[n](o),l=a.value}catch(u){return void i(u)}a.done?e(l):Promise.resolve(l).then(s,r)}function Qe(t){return function(){var e=this,i=arguments;return new Promise((function(s,r){var n=t.apply(e,i);function o(l){Pd(n,s,r,o,a,"next",l)}function a(l){Pd(n,s,r,o,a,"throw",l)}o(void 0)}))}}function S(){return S=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var s in i)({}).hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},S.apply(null,arguments)}function Sh(t,e){if(t==null)return{};var i={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(e.indexOf(s)!==-1)continue;i[s]=t[s]}return i}function ua(){return ua=Qe((function*(t,e,i){e===void 0&&(e=!0);try{var s=new CompressionStream("gzip"),r=s.writable.getWriter(),n=r.write(new TextEncoder().encode(t)).then((()=>r.close())).catch((function(){var l=Qe((function*(u){try{yield r.abort(u)}catch{}throw u}));return function(u){return l.apply(this,arguments)}})()),o=new Response(s.readable).blob(),[a]=yield Promise.all([o,n]);return a}catch(l){if(i!=null&&i.rethrow)throw l;return e&&console.error("Failed to gzip compress data",l),null}})),ua.apply(this,arguments)}function z(t,e){return t.indexOf(e)!==-1}function Ah(t){return t===null||typeof t!="object"}function qr(t,e){return{}.toString.call(t)==="[object "+e+"]"}function bl(t){return typeof Event<"u"&&(function(e,i){try{return e instanceof i}catch{return!1}})(t,Event)}function gt(t,e,i,s,r){return e>i&&(s.warn("min cannot be greater than max."),e=i),et(t)?t>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(s.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),gt(r||i,e,i,s))}function qh(t){if(ht(t))return{boolValue:t};if(typeof t=="number")return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if(typeof t=="string")return{stringValue:t};if(Y(t))return{arrayValue:{values:t.map((e=>qh(e)))}};try{return{stringValue:JSON.stringify(t)}}catch{return{stringValue:String(t)}}}function Ld(t){var e=[];for(var i in t){var s=t[i];Pt(s)||P(s)||e.push({key:i,value:qh(s)})}return e}function $b(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return Vo&&i.length===Cd||(Cd=i.length,Vo=i.reduce(((s,r)=>{Or||(Or={});var n=Or[r];if(n)s[n[0]]=n[1];else for(var o=t(r),a=o.length-1;a>=0;a--){var l=o[a],u=l?.filename,c=e[r];if(u&&c){s[u]=c,Or[r]=[u,c];break}}return s}),{})),Vo}}function va(t,e,i,s,r){var n={platform:t,filename:e,function:i==="<anonymous>"?Bi:i,in_app:!0};return P(s)||(n.lineno=s),P(r)||(n.colno=r),n}function Hh(t,e){e===void 0&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(e>=r.length)return s===i.length?r:r.length>e?r.slice(0,e)+"...":r}return""}function Kr(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:qo.enabled,max_bytes:Kb(t.max_bytes,qo.max_bytes)}:S({},qo)}function Kb(t,e){if(!et(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}function xr(t,e){Y(t)&&t.forEach(e)}function oe(t,e){if(!K(t))if(Y(t))t.forEach(e);else if(Eb(t))t.forEach(((s,r)=>e(s,r)));else for(var i in t)wh.call(t,i)&&e(t[i],i)}function Vr(t){for(var e=Object.keys(t),i=e.length,s=new Array(i);i--;)s[i]=[e[i],t[e[i]]];return s}function Jb(t){var e=t?.hostname;if(!ge(e))return!1;var i=e.split(".").slice(-2).join(".");for(var s of Xb)if(i===s)return!1;return!0}function ye(t,e,i,s){var{capture:r=!1,passive:n=!0}=s??{};t?.addEventListener(e,i,{capture:r,passive:n})}function ig(t){return t.name==="ph_toolbar_internal"}function ng(t,e){var{organization:i,projectId:s,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,u,c,h,f;if(n!=="*"&&!n.includes(a.level)||!t.__loaded)return a;a.tags||(a.tags={});var g=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());a.tags["PostHog Person URL"]=g,t.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var p,v=((l=a.exception)==null?void 0:l.values)||[],m=v.map((w=>S({},w,{stacktrace:w.stacktrace?S({},w.stacktrace,{type:"raw",frames:(w.stacktrace.frames||[]).map((R=>S({},R,{platform:"web:javascript"})))}):void 0}))),y={$exception_message:((u=v[0])==null?void 0:u.value)||a.message,$exception_type:(c=v[0])==null?void 0:c.type,$exception_level:a.level,$exception_list:m,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=v[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(f=v[0])==null?void 0:f.type,$sentry_tags:a.tags};return i&&s&&(y.$sentry_url=(r||"https://sentry.io/organizations/")+i+"/issues/?project="+s+"&query="+a.event_id),o&&((p=t.exceptions)==null||p.sendExceptionEvent(y)),a}}function og(t,e,i){if(!I)return{};var s,r=e?[...Vi,...i||[]]:[],n=ag(xs(I.URL,r,Ns),t),o=(s={},oe(aE,(function(a){var l=dt.A(a);s[a]=l||null})),s);return pe(o,n)}function ag(t,e){var i=oE.concat(e||[]),s={};return oe(i,(function(r){var n=nn(t,r);s[r]=n||null})),s}function lg(t){var e=(function(n){return n?n.search(Lr+"google.([^/?]*)")===0?"google":n.search(Lr+"bing.com")===0?"bing":n.search(Lr+"yahoo.com")===0?"yahoo":n.search(Lr+"duckduckgo.com")===0?"duckduckgo":null:null})(t),i=e!="yahoo"?"q":"p",s={};if(!Pt(e)){s.$search_engine=e;var r=I?nn(I.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function Bd(){return navigator.language||navigator.userLanguage}function ug(){return I?.referrer||an}function cg(t,e){var i=t?[...Vi,...e||[]]:[],s=Te?.href.substring(0,1e3);return{r:ug().substring(0,1e3),u:s?xs(s,i,Ns):void 0}}function dg(t){var e,{r:i,u:s}=t,r={$referrer:i,$referring_domain:i==null?void 0:i==an?an:(e=rn(i))==null?void 0:e.host};if(s){r.$current_url=s;var n=rn(s);r.$host=n?.host,r.$pathname=n?.pathname;var o=ag(s);pe(r,o)}if(i){var a=lg(i);pe(r,a)}return r}function hg(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function lE(){try{return new Date().getTimezoneOffset()}catch{return}}function pE(t,e){e===void 0&&(e={});var i=(function(){var h=4294967295;return{p(f){for(var g=h,p=0;f.length>p;++p)g=fE[255&g^f[p]]^g>>>8;h=g},d(){return 4294967295^h}}})(),s=t.length;i.p(t);var r,n,o,a,l,u=(a=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(h,f,g,p,v,m){var y=h.length,w=new Ze(p+y+5*(1+Math.floor(y/7e3))+v),R=w.subarray(p,w.length-v),N=0;if(!f||8>y)for(var b=0;y>=b;b+=65535){var x=b+65535;y>x?N=il(R,N,h.subarray(b,x)):(R[b]=!0,N=il(R,N,h.subarray(b,y)))}else{for(var C=gE[f-1],O=C>>>13,A=8191&C,$=(1<<g)-1,U=new Le(32768),H=new Le($+1),G=Math.ceil(g/3),q=2*G,_e=function(En){return(h[En]^h[En+1]<<G^h[En+2]<<q)&$},Ee=new Gi(25e3),$e=new Le(288),Se=new Le(32),k=0,M=0,F=(b=0,0),B=0,Z=0;y>b;++b){var ce=_e(b),se=32767&b,me=H[ce];if(U[se]=me,H[ce]=se,b>=B){var Pe=y-b;if((k>7e3||F>24576)&&Pe>423){N=Hd(h,R,0,Ee,$e,Se,M,F,Z,b-Z,N),F=k=M=0,Z=b;for(var ke=0;286>ke;++ke)$e[ke]=0;for(ke=0;30>ke;++ke)Se[ke]=0}var j=2,ft=0,Lg=A,Ot=se-me&32767;if(Pe>2&&ce==_e(b-Ot))for(var $g=Math.min(O,Pe)-1,Fg=Math.min(32767,b),Mg=Math.min(258,Pe);Fg>=Ot&&--Lg&&se!=me;){if(h[b+j]==h[b+j-Ot]){for(var Ct=0;Mg>Ct&&h[b+Ct]==h[b+Ct-Ot];++Ct);if(Ct>j){if(j=Ct,ft=Ot,Ct>$g)break;var Ug=Math.min(Ot,Ct-2),Dl=0;for(ke=0;Ug>ke;++ke){var bn=b-Ot+ke+32768&32767,Ll=bn-U[bn]+32768&32767;Ll>Dl&&(Dl=Ll,me=bn)}}}Ot+=(se=me)-(me=U[se])+32768&32767}if(ft){Ee[F++]=268435456|Za[j]<<18|el[ft];var $l=31&Za[j],Fl=31&el[ft];M+=Pl[$l]+Ol[Fl],++$e[257+$l],++Se[Fl],B=b+j,++k}else Ee[F++]=h[b],++$e[h[b]]}}N=Hd(h,R,!0,Ee,$e,Se,M,F,Z,b-Z,N)}return vg(w,0,p+pg(N)+v)})(n=t,(o=e).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),c=u.length;return(function(h,f){var g=f.filename;if(h[0]=31,h[1]=139,h[2]=8,h[8]=2>f.level?4:f.level==9?2:0,h[9]=3,f.mtime!=0&&Qo(h,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),g){h[3]=8;for(var p=0;g.length>=p;++p)h[p+10]=g.charCodeAt(p)}})(u,e),Qo(u,c-8,i.d()),Qo(u,c-4,s),u}function Wd(t,e,i){return Li({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:i})}function bg(t,e){return!t||Object.entries(t).every((i=>{var[s,r]=i,n=e?.[s];if(P(n)||Pt(n))return!1;var o=[String(n)],a=yg[r.operator];return!!a&&a(r.values,o)}))}function eh(t){return t instanceof Element&&(t.id===Qh||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function oi(t){return!!t&&t.nodeType===IE}function nt(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function kg(t){return!!t&&t.nodeType===TE}function wg(t){return!!t&&t.nodeType===RE&&oi(t.host)}function Cl(t){return t?vn(t).split(/\s+/):[]}function th(t){var e=_?.location.href;return!!(e&&t&&t.some((i=>e.match(i))))}function fn(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Cl(e)}function Ag(t){return K(t)?null:vn(t).split(/(\s+)/).filter((e=>Ps(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ls(t){var e="";return fl(t)&&!Tg(t)&&t.childNodes&&t.childNodes.length&&oe(t.childNodes,(function(i){var s;kg(i)&&i.textContent&&(e+=(s=Ag(i.textContent))!==null&&s!==void 0?s:"")})),vn(e)}function ih(t){return P(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}function sh(t,e){if(P(e))return!0;var i,s=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of t)if(i=s(r))return i.v;return!1}function Ig(t){var e=t.parentNode;return!(!e||!oi(e))&&e}function fl(t){for(var e=t;e.parentNode&&!nt(e,"body");e=e.parentNode){var i=fn(e);if(z(i,"ph-sensitive")||z(i,"ph-no-capture"))return!1}if(z(fn(t),"ph-include"))return!0;var s=t.type||"";if(ge(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=t.name||t.id||"";return!ge(r)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,""))}function Tg(t){return!!(nt(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||nt(t,"select")||nt(t,"textarea")||t.getAttribute("contenteditable")==="true")}function Ps(t,e){return e===void 0&&(e=!0),!(K(t)||ge(t)&&(t=vn(t),(e?OE:CE).test((t||"").replace(/[- ]/g,""))||(e?xE:NE).test(t)))}function oh(t){var e=Ls(t);return Ps(e=(e+" "+Og(t)).trim())?e:""}function Og(t){var e="";return t&&t.childNodes&&t.childNodes.length&&oe(t.childNodes,(function(i){var s;if(i&&((s=i.tagName)==null?void 0:s.toLowerCase())==="span")try{var r=Ls(i);e=(e+" "+r).trim(),i.childNodes&&i.childNodes.length&&(e=(e+" "+Og(i)).trim())}catch(n){T.error("[AutoCapture]",n)}})),e}function ah(t){return t.replace(/"|\\"/g,'\\"')}function DE(t){var e=t.attr__class;return e?Y(e)?e:Cl(e):void 0}function ra(t,e){return e.length>t?e.slice(0,t)+"...":e}function LE(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!oi(e));return e}function $E(t,e){var i,s,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e;if(!oi(t))return{props:{}};for(var u=[t],c=t;c.parentNode&&!nt(c,"body");)if(wg(c.parentNode))u.push(c.parentNode.host),c=c.parentNode.host;else{if(!oi(c.parentNode))break;u.push(c.parentNode),c=c.parentNode}var h,f,g=[],p={},v=!1,m=!1;if(oe(u,(b=>{var x=fl(b);if(nt(b,"a")){var C=b.getAttribute("href");v=x&&!!C&&Ps(C)&&C}z(fn(b),"ph-no-capture")&&(m=!0),g.push((function(A,$,U,H){var G=A.tagName.toLowerCase(),q={tag_name:G};xl.indexOf(G)>-1&&!U&&(q.$el_text=G.toLowerCase()==="a"||G.toLowerCase()==="button"?ra(1024,oh(A)):ra(1024,Ls(A)));var _e=fn(A);_e.length>0&&(q.classes=_e.filter((function(k){return k!==""}))),oe(A.attributes,(function(k){var M;if((!Tg(A)||["name","id","class","aria-label"].indexOf(k.name)!==-1)&&(H==null||!H.includes(k.name))&&!$&&Ps(k.value)&&(!ge(M=k.name)||M.substring(0,10)!=="_ngcontent"&&M.substring(0,7)!=="_nghost")){var F=k.value;k.name==="class"&&(F=Cl(F).join(" ")),q["attr__"+k.name]=ra(1024,F)}}));for(var Ee=1,$e=1,Se=A;Se=LE(Se);)Ee++,Se.tagName===A.tagName&&$e++;return q.nth_child=Ee,q.nth_of_type=$e,q})(b,n,o,a));var O=(function(A){if(!fl(A))return{};var $={};return oe(A.attributes,(function(U){if(U.name&&U.name.indexOf("data-ph-capture-attribute")===0){var H=U.name.replace("data-ph-capture-attribute-",""),G=U.value;H&&G&&Ps(G)&&($[H]=G)}})),$})(b);pe(p,O)})),m)return{props:{},explicitNoCapture:m};if(o||(g[0].$el_text=nt(t,"a")||nt(t,"button")?oh(t):Ls(t)),v){var y,w;g[0].attr__href=v;var R=(y=rn(v))==null?void 0:y.host,N=_==null||(w=_.location)==null?void 0:w.host;R&&N&&R!==N&&(h=v)}return{props:pe({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:(f=g,(function(b){return b.map((x=>{var C,O,A="";if(x.tag_name&&(A+=x.tag_name),x.attr_class)for(var $ of(x.attr_class.sort(),x.attr_class))A+="."+$.replace(/"/g,"");var U=S({},x.text?{text:x.text}:{},{"nth-child":(C=x.nth_child)!==null&&C!==void 0?C:0,"nth-of-type":(O=x.nth_of_type)!==null&&O!==void 0?O:0},x.href?{href:x.href}:{},x.attr_id?{attr_id:x.attr_id}:{},x.attributes),H={};return Vr(U).sort(((G,q)=>{var[_e]=G,[Ee]=q;return _e.localeCompare(Ee)})).forEach((G=>{var[q,_e]=G;return H[ah(q.toString())]=ah(_e.toString())})),(A+=":")+Vr(H).map((G=>{var[q,_e]=G;return q+'="'+_e+'"'})).join("")})).join(";")})((function(b){return b.map((x=>{var C,O,A={text:(C=x.$el_text)==null?void 0:C.slice(0,400),tag_name:x.tag_name,href:(O=x.attr__href)==null?void 0:O.slice(0,2048),attr_class:DE(x),attr_id:x.attr__id,nth_child:x.nth_child,nth_of_type:x.nth_of_type,attributes:{}};return Vr(x).filter(($=>{var[U]=$;return U.indexOf("attr__")===0})).forEach(($=>{var[U,H]=$;return A.attributes[U]=H})),A}))})(f)))},(i=g[0])!=null&&i.$el_text?{$el_text:(s=g[0])==null?void 0:s.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},p)}}function lh(t,e,i){try{if(!(e in t))return()=>{};var s=t[e],r=i(s);return It(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=r,()=>{t[e]=s}}catch{return()=>{}}}function hh(t){return ve(t)&&"clientX"in t&&"clientY"in t&&et(t.clientX)&&et(t.clientY)}function Ri(t,e,i){if(K(t))return!1;switch(i){case"exact":return t===e;case"contains":var s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}var _,be,ze,I,Te,aa,la,Td,mb,Ge,L,Rd,De,yb,Od,bb,vn,ca,kh,wh,_n,Y,It,ve,Ni,P,ge,Mr,Pt,K,et,Pi,ht,Eb,Sb,kb,Bo,wb,da,Or,Cd,Vo,Ke,jr,Rt,Mi,Ih,Th,Rh,Ph,ws,Ui,Oh,Ch,xh,si,Ab,Nh,El,Dh,Sl,Ib,kl,Lh,$i,$h,Os,Cs,Fi,Fh,Mh,_s,ha,xd,ga,Uh,Tb,Bh,fa,Ne,Go,Rb,Pb,Ob,wl,Cb,Vh,xb,Nb,Nd,Dd,Db,Gh,Lb,pa,Bi,jh,Fb,Mb,Ub,Bb,Vb,Gb,qb,$d,_a,ma,ya,jb,ba,Hb,Ea,Sa,ka,wa,Hr,zr,zb,qo,Aa,zh,T,ue,Wb,jo,Kh,Wr,ms,ys,Ia,Ta,Ra,Pa,Oa,Ca,Al,xa,Na,bs,Wh,Yh,Xh,Jh,Yr,Il,Di,Ur,Es,Da,La,$a,At,Oi,Ss,ti,Fa,Ma,Br,As,Ua,Ba,Xr,rt,Va,Ga,qa,ja,Jr,Qr,Qh,Cr,Zh,eg,tg,Tl,ii,Tt,Ai,Ii,Ha,Zr,en,Ci,Ho,zo,Fd,pe,Md,Yb,Rl,Xb,za,Ka,Ud,sg,Wa,Bt,Qb,us,Zb,dt,Ko,he,eE,Nr,tE,Jt,Re,Ya,Dr,iE,sE,tn,Wo,rg,Xa,sn,rE,nE,rn,nn,xs,on,Lr,Vi,oE,Ns,aE,an,uE,Is,cs,Yo,ks,Xo,Ja,cE,Vd,Gd,Qa,ds,ln,ct,Ze,Le,Gi,Pl,Ol,qd,gg,fg,Za,Qt,el,un,ie,Ts,ni,cn,dE,hE,pg,vg,kt,hs,Jo,tl,jd,gs,il,Hd,gE,fE,Qo,vE,_g,zd,mn,Li,Zo,_E,Kd,Gr,sl,rl,mE,nl,ol,yE,dn,Ds,ea,hn,mg,gn,yg,$r,al,Yd,bE,ll,ee,ul,EE,SE,kE,wE,cl,Ti,Rs,ta,dl,Xd,fs,Jd,Eg,xi,Sg,Qd,AE,Zd,hl,ri,IE,TE,RE,xl,PE,rh,gl,nh,Rg,OE,CE,Pg,xE,NE,pn,ia,sa,ps,FE,Ft,uh,ch,dh,vs,Fr,pl,Mt,ME,gh,UE,Ut,fh,vl,_l,ml,na,ph,BE,vh,_h,xe,Zt,oa,mh,yh,wt,bh,VE,yl,Je,ei,yn,GE,qE,jE,HE,zE,KE,WE,YE,XE,JE,QE,ZE,Eh,qe,Cg=Fe(()=>{"use strict";_=typeof window<"u"?window:void 0,be=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(be.self=be),typeof File>"u"&&(be.File=function(){});ze=be?.navigator,I=be?.document,Te=be?.location,aa=be?.fetch,la=be!=null&&be.XMLHttpRequest&&"withCredentials"in new be.XMLHttpRequest?be.XMLHttpRequest:void 0,Td=be?.AbortController,mb=be?.CompressionStream,Ge=ze?.userAgent,L=_??{},Rd="1.372.9",De={DEBUG:!1,LIB_VERSION:Rd,LIB_NAME:"web",JS_SDK_VERSION:Rd};yb=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Od=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var i=t.toLowerCase();return yb.concat(e).some((s=>{var r=s.toLowerCase();return i.indexOf(r)!==-1}))},bb=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];vn=function(t){return t.trim()},ca=function(t){return t.replace(/^\$/,"")},kh=Object.prototype,wh=kh.hasOwnProperty,_n=kh.toString,Y=Array.isArray||function(t){return _n.call(t)==="[object Array]"},It=t=>typeof t=="function",ve=t=>t===Object(t)&&!Y(t),Ni=t=>{if(ve(t)){for(var e in t)if(wh.call(t,e))return!1;return!0}return!1},P=t=>t===void 0,ge=t=>_n.call(t)=="[object String]",Mr=t=>ge(t)&&t.trim().length===0,Pt=t=>t===null,K=t=>P(t)||Pt(t),et=t=>_n.call(t)=="[object Number]"&&t==t,Pi=t=>et(t)&&t>0,ht=t=>_n.call(t)==="[object Boolean]",Eb=t=>t instanceof FormData,Sb=t=>z(bb,t);kb=[!0,"true",1,"1","yes"],Bo=t=>z(kb,t),wb=[!1,"false",0,"0","no"];da=class{constructor(e){this.$t={},this.zt=e.zt,this.Zt=gt(e.bucketSize,0,100,e.Gt),this.Qt=gt(e.refillRate,0,this.Zt,e.Gt),this.Jt=gt(e.refillInterval,0,864e5,e.Gt)}Kt(e,i){var s=Math.floor((i-e.lastAccess)/this.Jt);s>0&&(e.tokens=Math.min(e.tokens+s*this.Qt,this.Zt),e.lastAccess=e.lastAccess+s*this.Jt)}consumeRateLimit(e){var i,s=Date.now(),r=String(e),n=this.$t[r];return n?this.Kt(n,s):this.$t[r]=n={tokens:this.Zt,lastAccess:s},n.tokens===0||(n.tokens--,n.tokens===0&&((i=this.zt)==null||i.call(this,e)),n.tokens===0)}stop(){this.$t={}}},Ke="Mobile",jr="iOS",Rt="Android",Mi="Tablet",Ih=Rt+" "+Mi,Th="iPad",Rh="Apple",Ph=Rh+" Watch",ws="Safari",Ui="BlackBerry",Oh="Samsung",Ch=Oh+"Browser",xh=Oh+" Internet",si="Chrome",Ab=si+" OS",Nh=si+" "+jr,El="Internet Explorer",Dh=El+" "+Ke,Sl="Opera",Ib=Sl+" Mini",kl="Edge",Lh="Microsoft "+kl,$i="Firefox",$h=$i+" "+jr,Os="Nintendo",Cs="PlayStation",Fi="Xbox",Fh=Rt+" "+Ke,Mh=Ke+" "+ws,_s="Windows",ha=_s+" Phone",xd="Nokia",ga="Ouya",Uh="Generic",Tb=Uh+" "+Ke.toLowerCase(),Bh=Uh+" "+Mi.toLowerCase(),fa="Konqueror",Ne="(\\d+(\\.\\d+)?)",Go=new RegExp("Version/"+Ne),Rb=new RegExp(Fi,"i"),Pb=new RegExp(Cs+" \\w+","i"),Ob=new RegExp(Os+" \\w+","i"),wl=new RegExp(Ui+"|PlayBook|BB10","i"),Cb={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Vh=function(t,e){return e=e||"",z(t," OPR/")&&z(t,"Mini")?Ib:z(t," OPR/")?Sl:wl.test(t)?Ui:z(t,"IE"+Ke)||z(t,"WPDesktop")?Dh:z(t,Ch)?xh:z(t,kl)||z(t,"Edg/")?Lh:z(t,"FBIOS")?"Facebook "+Ke:z(t,"UCWEB")||z(t,"UCBrowser")?"UC Browser":z(t,"CriOS")?Nh:z(t,"CrMo")||z(t,si)?si:z(t,Rt)&&z(t,ws)?Fh:z(t,"FxiOS")?$h:z(t.toLowerCase(),fa.toLowerCase())?fa:((i,s)=>s&&z(s,Rh)||(function(r){return z(r,ws)&&!z(r,si)&&!z(r,Rt)})(i))(t,e)?z(t,Ke)?Mh:ws:z(t,$i)?$i:z(t,"MSIE")||z(t,"Trident/")?El:z(t,"Gecko")?$i:""},xb={[Dh]:[new RegExp("rv:"+Ne)],[Lh]:[new RegExp(kl+"?\\/"+Ne)],[si]:[new RegExp("("+si+"|CrMo)\\/"+Ne)],[Nh]:[new RegExp("CriOS\\/"+Ne)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ne)],[ws]:[Go],[Mh]:[Go],[Sl]:[new RegExp("(Opera|OPR)\\/"+Ne)],[$i]:[new RegExp($i+"\\/"+Ne)],[$h]:[new RegExp("FxiOS\\/"+Ne)],[fa]:[new RegExp("Konqueror[:/]?"+Ne,"i")],[Ui]:[new RegExp(Ui+" "+Ne),Go],[Fh]:[new RegExp("android\\s"+Ne,"i")],[xh]:[new RegExp(Ch+"\\/"+Ne)],[El]:[new RegExp("(rv:|MSIE )"+Ne)],Mozilla:[new RegExp("rv:"+Ne)]},Nb=function(t,e){var i=Vh(t,e),s=xb[i];if(P(s))return null;for(var r=0;s.length>r;r++){var n=t.match(s[r]);if(n)return parseFloat(n[n.length-2])}return null},Nd=[[new RegExp(Fi+"; "+Fi+" (.*?)[);]","i"),t=>[Fi,t&&t[1]||""]],[new RegExp(Os,"i"),[Os,""]],[new RegExp(Cs,"i"),[Cs,""]],[wl,[Ui,""]],[new RegExp(_s,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[ha,""];if(new RegExp(Ke).test(e)&&!/IEMobile\b/.test(e))return[_s+" "+Ke,""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var s=Cb[i[1]]||"";return/arm/i.test(e)&&(s="RT"),[_s,s]}return[_s,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[jr,[t[3],t[4],t[5]||"0"].join(".")]:[jr,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=P(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Rt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Rt+")","i"),t=>t&&t[2]?[Rt,[t[2],t[3],t[4]||"0"].join(".")]:[Rt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Ab,""]],[/Linux|debian/i,["Linux",""]]],Dd=function(t){return Ob.test(t)?Os:Pb.test(t)?Cs:Rb.test(t)?Fi:new RegExp(ga,"i").test(t)?ga:new RegExp("("+ha+"|WPDesktop)","i").test(t)?ha:/iPad/.test(t)?Th:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Ph:wl.test(t)?Ui:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(xd,"i").test(t)?xd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Ke).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Rt:Ih:new RegExp("(pda|"+Ke+")","i").test(t)?Tb:new RegExp(Mi,"i").test(t)&&!new RegExp(Mi+" pc","i").test(t)?Bh:""},Db=t=>t instanceof Error,Gh={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},Lb=Gh.info;pa=class{constructor(e,i,s){s===void 0&&(s=[]),this.coercers=e,this.stackParser=i,this.modifiers=s}buildFromUnknown(e,i){i===void 0&&(i={});var s=i&&i.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(s,i,0).apply(e),n=this.buildParsingContext(i),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,s),$exception_level:"error"}}modifyFrames(e){var i=this;return Qe((function*(){for(var s of e)s.stacktrace&&s.stacktrace.frames&&Y(s.stacktrace.frames)&&(s.stacktrace.frames=yield i.applyModifiers(s.stacktrace.frames));return e}))()}coerceFallback(e){var i;return{type:"Error",value:"Unknown error",stack:(i=e.syntheticException)==null?void 0:i.stack,synthetic:!0}}parseStacktrace(e,i){var s,r;return e.cause!=null&&(s=this.parseStacktrace(e.cause,i)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?i.skipFirstLines:0),i.chunkIdMap)),S({},e,{cause:s,stack:r})}applyChunkIds(e,i){return e.map((s=>(s.filename&&i&&(s.chunk_id=i[s.filename]),s)))}applyCoercers(e,i){for(var s of this.coercers)if(s.match(e))return s.coerce(e,i);return this.coerceFallback(i)}applyModifiers(e){var i=this;return Qe((function*(){var s=e;for(var r of i.modifiers)s=yield r(s);return s}))()}convertToExceptionList(e,i){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:(s=i.type)!==null&&s!==void 0?s:"generic",handled:(r=i.handled)===null||r===void 0||r,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,S({},i,{handled:!0}))),a}buildParsingContext(e){var i;return{chunkIdMap:$b(this.stackParser),skipFirstLines:(i=e.skipFirstLines)!==null&&i!==void 0?i:1}}buildCoercingContext(e,i,s){s===void 0&&(s=0);var r=(n,o)=>{if(4>=o){var a=this.buildCoercingContext(e,i,o);return this.applyCoercers(n,a)}};return S({},i,{syntheticException:s==0?i.syntheticException:void 0,mechanism:e,apply:n=>r(n,s),next:n=>r(n,s+1)})}},Bi="?";jh=(t,e)=>{var i=t.indexOf("safari-extension")!==-1,s=t.indexOf("safari-web-extension")!==-1;return i||s?[t.indexOf("@")!==-1?t.split("@")[0]:Bi,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Fb=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Mb=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ub=/\((\S*)(?::(\d+))(?::(\d+))\)/,Bb=(t,e)=>{var i=Fb.exec(t);if(i){var[,s,r,n]=i;return va(e,s,Bi,+r,+n)}var o=Mb.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Ub.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=jh(o[1]||Bi,o[2]);return va(e,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Vb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Gb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,qb=(t,e)=>{var i=Vb.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=Gb.exec(i[3]);s&&(i[1]=i[1]||"eval",i[3]=s[1],i[4]=s[2],i[5]="")}var r=i[3],n=i[1]||Bi;return[n,r]=jh(n,r),va(e,r,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},$d=/\(error: (.*)\)/,_a=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,i){var s=ge(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:s?e.stack:void 0,cause:e.cause?i.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var i=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?i+": "+e.message:i}isDOMException(e){return qr(e,"DOMException")}isDOMError(e){return qr(e,"DOMError")}},ma=class{match(e){return(i=>i instanceof Error)(e)}coerce(e,i){return{type:this.getType(e),value:this.getMessage(e,i),stack:this.getStack(e),cause:e.cause?i.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,i){var s=e.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(e){return e.stacktrace||e.stack||void 0}},ya=class{constructor(){}match(e){return qr(e,"ErrorEvent")&&e.error!=null}coerce(e,i){var s;return i.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}},jb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ba=class{match(e){return typeof e=="string"}coerce(e,i){var s,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}getInfos(e){var i="Error",s=e,r=e.match(jb);return r&&(i=r[1],s=r[2]),[i,s]}},Hb=["fatal","error","warning","log","info","debug"];Ea=class{match(e){return typeof e=="object"&&e!==null}coerce(e,i){var s,r=this.getErrorPropertyFromObject(e);return r?i.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(s=i.syntheticException)==null?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return bl(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var i="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(i+=" with message: '"+e.message+"'"),i}if("message"in e&&typeof e.message=="string")return e.message;var s=this.getObjectClassName(e);return(s&&s!=="Object"?"'"+s+"'":"Object")+" captured as exception with keys: "+Hh(e)}isSeverityLevel(e){return ge(e)&&!Mr(e)&&Hb.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var i in e)if({}.hasOwnProperty.call(e,i)){var s=e[i];if(Db(s))return s}}getObjectClassName(e){try{var i=Object.getPrototypeOf(e);return i?i.constructor.name:void 0}catch{return}}},Sa=class{match(e){return bl(e)}coerce(e,i){var s,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Hh(e),stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}},ka=class{match(e){return Ah(e)}coerce(e,i){var s;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}},wa=class{match(e){return qr(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!bl(e))return!1;try{var i=e.detail;return i!=null&&typeof i=="object"&&"reason"in i}catch{return!1}}coerce(e,i){var s,r=this.getUnhandledRejectionReason(e);return Ah(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}},Hr="$message",zr="$timestamp",zb=new Set([Hr,zr]),qo={enabled:!0,max_bytes:32768};Aa=class{constructor(e){this.Yt=[],this.Xt=0,this.qt=Kr(e)}setConfig(e){this.qt=Kr(e),this.er()}add(e){var i=(function(r){var n=(function(c){var h=new WeakSet;try{return JSON.stringify(c,((f,g)=>{if(typeof g=="bigint")return g.toString();if(typeof g!="function"&&typeof g!="symbol"){if(g instanceof Date)return g.toISOString();if(g instanceof Error)return{name:g.name,message:g.message,stack:g.stack};if(g&&typeof g=="object"){if(h.has(g))return"[Circular]";h.add(g)}return g}}))}catch{return}})(r);if(n)try{var o=JSON.parse(n);if(!ve(o))return;var a=o,l=a[Hr],u=a[zr];return!ge(l)||l.trim().length===0||!ge(u)&&!et(u)?void 0:{step:a,json:n}}catch{return}})(e);if(i){var s=(function(r){if(typeof TextEncoder<"u")return new TextEncoder().encode(r).length;for(var n=encodeURIComponent(r),o=0,a=0;n.length>a;a++)n[a]==="%"?(o+=1,a+=2):o+=1;return o})(i.json);s>this.qt.max_bytes||(this.Yt.push({step:i.step,bytes:s}),this.Xt+=s,this.er())}}getAttachable(){return this.Yt.map((e=>e.step))}clear(){this.Yt=[],this.Xt=0}size(){return this.Yt.length}er(){for(;this.Xt>this.qt.max_bytes&&this.Yt.length>0;){var e=this.Yt.shift();e&&(this.Xt-=e.bytes)}}};zh=function(t,e){var{debugEnabled:i}=e===void 0?{}:e,s={k(r){if(_&&(De.DEBUG||L.POSTHOG_DEBUG||i)&&!P(_.console)&&_.console){for(var n=("__rrweb_original__"in _.console[r])?_.console[r].__rrweb_original__:_.console[r],o=arguments.length,a=new Array(o>1?o-1:0),l=1;o>l;l++)a[l-1]=arguments[l];n(t,...a)}},debug(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("debug",...n)},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(t,...n)},uninitializedWarning(r){s.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>zh(t+" "+r,n)};return s},T=zh("[PostHog.js]"),ue=T.createLogger,Wb=ue("[ExternalScriptsLoader]"),jo=(t,e,i)=>{if(t.config.disable_external_dependency_loading)return Wb.warn(e+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var s=I?.querySelectorAll("script");if(s){for(var r,n=function(){if(s[o].src===e){var l=s[o];return l.__posthog_loading_callback_fired?{v:i()}:(l.addEventListener("load",(u=>{l.__posthog_loading_callback_fired=!0,i(void 0,u)})),l.onerror=u=>i(u),{v:void 0})}},o=0;s.length>o;o++)if(r=n())return r.v}var a=()=>{if(!I)return i("document not found");var l=I.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,i(void 0,h)},l.onerror=h=>i(h),t.config.prepare_external_dependency_script&&(l=t.config.prepare_external_dependency_script(l)),!l)return i("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")I.head.appendChild(l);else{var u,c=I.querySelectorAll("body > script");c.length>0?(u=c[0].parentNode)==null||u.insertBefore(l,c[0]):I.body.appendChild(l)}};I!=null&&I.body?a():I?.addEventListener("DOMContentLoaded",a)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(t,e,i)=>{if(e!=="remote-config"){var s;if(t.config.__preview_external_dependency_versioned_paths)s=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js");else{var r="/static/"+e+".js?v="+t.version;if(e==="toolbar"){var n=3e5;r=r+"&t="+Math.floor(Date.now()/n)*n}s=t.requestRouter.endpointFor("assets",r)}jo(t,s,i)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");jo(t,o,i)}},L.__PosthogExtensions__.loadSiteApp=(t,e,i)=>{var s=t.requestRouter.endpointFor("api",e);jo(t,s,i)};Kh="$people_distinct_id",Wr="$device_id",ms="__alias",ys="__timers",Ia="$autocapture_disabled_server_side",Ta="$heatmaps_enabled_server_side",Ra="$exception_capture_enabled_server_side",Pa="$error_tracking_suppression_rules",Oa="$error_tracking_capture_extension_exceptions",Ca="$web_vitals_enabled_server_side",Al="$dead_clicks_enabled_server_side",xa="$product_tours_enabled_server_side",Na="$web_vitals_allowed_metrics",bs="$session_recording_remote_config",Wh="$replay_override_sampling",Yh="$replay_override_linked_flag",Xh="$replay_override_url_trigger",Jh="$replay_override_event_trigger",Yr="$sesid",Il="$session_is_sampled",Di="$enabled_feature_flags",Ur="$active_feature_flags",Es="$early_access_features",Da="$feature_flag_details",La="$feature_flag_payloads",$a="$feature_flag_request_id",At="$override_feature_flags",Oi="$override_feature_flag_payloads",Ss="$stored_person_properties",ti="$stored_group_properties",Fa="$surveys",Ma="$surveys_activated",Br="ph_product_tours",As="$flag_call_reported",Ua="$flag_call_reported_session_id",Ba="$feature_flag_errors",Xr="$feature_flag_evaluated_at",rt="$user_state",Va="$client_session_props",Ga="$capture_rate_limit",qa="$initial_campaign_params",ja="$initial_referrer_info",Jr="$initial_person_info",Qr="$epp",Qh="__POSTHOG_TOOLBAR__",Cr="$posthog_cookieless",Zh="$sdk_debug_extensions_init_method",eg="$sdk_debug_extensions_init_time_ms",tg="$sdk_debug_recording_script_not_loaded",Tl="PostHog loadExternalDependency extension not found.",ii="on_reject",Tt="always",Ai="anonymous",Ii="identified",Ha="identified_only",Zr="visibilitychange",en="beforeunload",Ci="$pageview",Ho="$pageleave",zo="$identify",Fd="$groupidentify";pe=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;e>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)r[n]!==void 0&&(t[n]=r[n]);return t};Md=function(t){try{return t()}catch{return}},Yb=function(t){return function(){try{for(var e=arguments.length,i=new Array(e),s=0;e>s;s++)i[s]=arguments[s];return t.apply(this,i)}catch(r){T.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),T.critical(r)}}},Rl=function(t){var e={};return oe(t,(function(i,s){(ge(i)&&i.length>0||et(i))&&(e[s]=i)})),e},Xb=["herokuapp.com","vercel.app","netlify.app"];Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return et(t)&&isFinite(t)&&Math.floor(t)===t});za=class t{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,i,s,r){if(!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(r)||0>e||0>i||0>s||0>r||e>0xffffffffffff||i>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|i>>>8,n[7]=i,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new t(n)}toString(){for(var e="",i=0;this.bytes.length>i;i++)e=e+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),i!==3&&i!==5&&i!==7&&i!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new t(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var i=0;16>i;i++){var s=this.bytes[i]-e.bytes[i];if(s!==0)return Math.sign(s)}return 0}},Ka=class{constructor(){this.S=0,this.C=0,this.I=new Wa}generate(){var e=this.generateOrAbort();if(P(e)){this.S=0;var i=this.generateOrAbort();if(P(i))throw new Error("Could not generate UUID after timestamp reset");return i}return e}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.T();else{if(this.S>=e+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.T())}return za.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}T(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}},sg=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};_&&!P(_.crypto)&&crypto.getRandomValues&&(sg=t=>crypto.getRandomValues(t));Wa=class{constructor(){this.M=new Uint32Array(8),this.O=1/0}nextUint32(){return this.M.length>this.O||(sg(this.M),this.O=0),this.M[this.O++]}},Bt=()=>Qb().toString(),Qb=()=>(Ud||(Ud=new Ka)).generate(),us="",Zb=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,dt={R:()=>!!I,D(t){T.error("cookieStore error: "+t)},A(t){if(I){try{for(var e=t+"=",i=I.cookie.split(";").filter((n=>n.length)),s=0;i.length>s;s++){for(var r=i[s];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}}catch{}return null}},F(t){var e;try{e=JSON.parse(dt.A(t))||{}}catch{}return e},N(t,e,i,s,r){if(I)try{var n="",o="",a=(function(c,h){if(h){var f=(function(p,v){if(v===void 0&&(v=I),us)return us;if(!v||["localhost","127.0.0.1"].includes(p))return"";for(var m=p.split("."),y=Math.min(m.length,8),w="dmn_chk_"+Bt();!us&&y--;){var R=m.slice(y).join("."),N=w+"=1;domain=."+R+";path=/";v.cookie=N+";max-age=3",v.cookie.includes(w)&&(v.cookie=N+";max-age=0",us=R)}return us})(c);if(!f){var g=(p=>{var v=p.match(Zb);return v?v[0]:""})(c);g!==f&&T.info("Warning: cookie subdomain discovery mismatch",g,f),f=g}return f?"; domain=."+f:""}return""})(I.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&T.warn("cookieStore warning: large cookie, len="+u.length),I.cookie=u,u}catch{return}},q(t,e){if(I!=null&&I.cookie)try{dt.N(t,"",-1,e)}catch{return}}},Ko=null,he={R(){if(!Pt(Ko))return Ko;var t=!0;if(P(_))t=!1;else try{var e="__mplssupport__";he.N(e,"xyz"),he.A(e)!=='"xyz"'&&(t=!1),he.q(e)}catch{t=!1}return t||T.error("localStorage unsupported; falling back to cookie store"),Ko=t,t},D(t){T.error("localStorage error: "+t)},A(t){try{return _?.localStorage.getItem(t)}catch(e){he.D(e)}return null},F(t){try{return JSON.parse(he.A(t))||{}}catch{}return null},N(t,e){try{_?.localStorage.setItem(t,JSON.stringify(e))}catch(i){he.D(i)}},q(t){try{_?.localStorage.removeItem(t)}catch(e){he.D(e)}}},eE=[Wr,"distinct_id",Yr,Il,Qr,Jr,rt],Nr={},tE={R:()=>!0,D(t){T.error("memoryStorage error: "+t)},A:t=>Nr[t]||null,F:t=>Nr[t]||null,N(t,e){Nr[t]=e},q(t){delete Nr[t]}},Jt=null,Re={R(){if(!Pt(Jt))return Jt;if(Jt=!0,P(_))Jt=!1;else try{var t="__support__";Re.N(t,"xyz"),Re.A(t)!=='"xyz"'&&(Jt=!1),Re.q(t)}catch{Jt=!1}return Jt},D(t){T.error("sessionStorage error: ",t)},A(t){try{return _?.sessionStorage.getItem(t)}catch(e){Re.D(e)}return null},F(t){try{return JSON.parse(Re.A(t))||null}catch{}return null},N(t,e){try{_?.sessionStorage.setItem(t,JSON.stringify(e))}catch(i){Re.D(i)}},q(t){try{_?.sessionStorage.removeItem(t)}catch(e){Re.D(e)}}},Ya=class{constructor(e){this._instance=e}get qt(){return this._instance.config}get consent(){return this.rr()?0:this.ir}isOptedOut(){return this.qt.cookieless_mode===Tt||this.isRejected()||this.consent===-1&&this.qt.cookieless_mode===ii}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.qt.opt_out_capturing_by_default}optInOut(e){this.nr.N(this.sr,e?1:0,this.qt.cookie_expiration,this.qt.cross_subdomain_cookie,this.qt.secure_cookie)}reset(){this.nr.q(this.sr,this.qt.cross_subdomain_cookie)}get sr(){var{token:e,opt_out_capturing_cookie_prefix:i,consent_persistence_name:s}=this._instance.config;return s||(i?i+e:"__ph_opt_in_out_"+e)}get ir(){var e=this.nr.A(this.sr);return Bo(e)?1:z(wb,e)?0:-1}get nr(){var e=this.qt.opt_out_capturing_persistence_type,i=e==="localStorage"?he:dt;if(!this.ar||this.ar!==i){this.ar=i;var s=e==="localStorage"?dt:he;s.A(this.sr)&&(this.ar.A(this.sr)||this.optInOut(Bo(s.A(this.sr))),s.q(this.sr,this.qt.cross_subdomain_cookie))}return this.ar}rr(){return!!this.qt.respect_dnt&&[ze?.doNotTrack,ze?.msDoNotTrack,L.doNotTrack].some((e=>Bo(e)))}},Dr=ue("[Dead Clicks]"),iE=()=>!0,sE=t=>{var e,i=!((e=t.instance.persistence)==null||!e.get_property(Al)),s=t.instance.config.capture_dead_clicks;return ht(s)?s:!!ve(s)||i},tn=class{get lazyLoadedDeadClicksAutocapture(){return this.ur}constructor(e,i,s){this.instance=e,this.isEnabled=i,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Al]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.lr((()=>{this.hr()})):this.stop()}lr(e){var i,s;(i=L.__PosthogExtensions__)!=null&&i.initDeadClicksAutocapture&&e(),(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Dr.error("failed to load script",r):e()}))}hr(){var e;if(I){if(!this.ur&&(e=L.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var i=ve(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};i.__onCapture=this.onCapture,this.ur=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.ur.start(I),Dr.info("starting...")}}else Dr.error("`document` not found. Cannot start.")}stop(){this.ur&&(this.ur.stop(),this.ur=void 0,Dr.info("stopping..."))}},Wo=ue("[SegmentIntegration]"),rg="posthog-js";Xa=class{constructor(e,i,s,r,n,o){this.name=rg,this.setupOnce=function(a){a(ng(e,{organization:i,projectId:s,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},sn=class{constructor(e){this.cr=(i,s,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(T.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:i,changeReason:r}),this.dr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.vr()}vr(){var e;this.pr=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.cr)}destroy(){var e;(e=this.pr)==null||e.call(this),this.pr=void 0}doPageView(e,i){var s,r=this.gr(e,i);return this.dr={pathname:(s=_?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:i,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var i;return this.gr(e,(i=this.dr)==null?void 0:i.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.dr)==null?void 0:e.pageViewId}}gr(e,i){var s=this.dr;if(!s)return{$pageview_id:i};var r={$pageview_id:i,$prev_pageview_id:s.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:u,lastContentY:c,maxContentY:h}=n;if(!(P(o)||P(a)||P(l)||P(u)||P(c)||P(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),h=Math.ceil(h);var f=o>1?gt(a/o,0,1,T):1,g=o>1?gt(l/o,0,1,T):1,p=u>1?gt(c/u,0,1,T):1,v=u>1?gt(h/u,0,1,T):1;r=pe(r,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return s.pathname&&(r.$prev_pageview_pathname=s.pathname),s.timestamp&&(r.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),r}},rE={[Kh]:{exposure:"hidden"},[ms]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[ys]:{exposure:"hidden"},[Ia]:{exposure:"event"},[Ta]:{exposure:"hidden"},[Ra]:{exposure:"event"},[Pa]:{exposure:"hidden"},[Oa]:{exposure:"event"},[Ca]:{exposure:"event"},[Al]:{exposure:"event"},[xa]:{exposure:"hidden"},[Na]:{exposure:"event"},[bs]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[Yr]:{exposure:"hidden"},[Il]:{exposure:"event"},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},[Di]:{exposure:"derived",shouldSkipFromEventProperties:(t,e)=>e(),transformToEventProperties(t){if(!ve(t))return{};for(var e={},i=Object.keys(t),s=0;i.length>s;s++)e["$feature/"+i[s]]=t[i[s]];return e}},[Ur]:{exposure:"event"},[Es]:{exposure:"hidden"},[Da]:{exposure:"hidden"},[La]:{exposure:"event"},[$a]:{exposure:"event"},[At]:{exposure:"event"},[Oi]:{exposure:"hidden"},[Ss]:{exposure:"hidden"},[ti]:{exposure:"hidden"},[Fa]:{exposure:"hidden"},[Ma]:{exposure:"event"},[Br]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[As]:{exposure:"hidden"},[Ua]:{exposure:"hidden"},[Ba]:{exposure:"hidden"},[Xr]:{exposure:"hidden"},[rt]:{exposure:"hidden"},[Va]:{exposure:"hidden"},[Ga]:{exposure:"hidden"},[qa]:{exposure:"hidden"},[ja]:{exposure:"hidden"},[Jr]:{exposure:"hidden"},[Qr]:{exposure:"hidden"},[Wh]:{exposure:"event"},[Yh]:{exposure:"event"},[Xh]:{exposure:"event"},[Jh]:{exposure:"event"},[Zh]:{exposure:"event"},[eg]:{exposure:"event"},[tg]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},nE=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],rn=t=>{var e=I?.createElement("a");return P(e)?null:(e.href=t,e)},nn=function(t,e){for(var i,s=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===e){i=n;break}}if(!Y(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch{T.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},xs=function(t,e,i){if(!t||!e||!e.length)return t;for(var s=t.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var h=l[c].split("=");Y(h)&&(e.includes(h[0])?u.push(h[0]+"="+i):u.push(l[c]))}var f=a;return o!=null&&(f+="?"+u.join("&")),r!=null&&(f+="#"+r),f},on=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Lr="https?://(.*)",Vi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],oE=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Vi],Ns="<masked>",aE=["li_fat_id"];an="$direct";uE=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Is=class{constructor(e,i){this.qt=e,this.props={},this.mr=!1,this.yr=(s=>{var r="";return s.token&&(r=s.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),s.persistence_name?"ph_"+s.persistence_name:"ph_"+r+"_posthog"})(e),this.nr=this.br(e),this.load(),e.debug&&T.info("Persistence loaded",e.persistence,S({},this.props)),this.update_config(e,e,i),this.save()}isDisabled(){return!!this._r}br(e){uE.indexOf(e.persistence.toLowerCase())===-1&&(T.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var i=(function(r){r===void 0&&(r=[]);var n=[...eE,...r];return S({},he,{F(o){try{var a={};try{a=dt.F(o)||{}}catch{}var l=pe(a,JSON.parse(he.A(o)||"{}"));return he.N(o,l),l}catch{}return null},N(o,a,l,u,c,h){try{he.N(o,a,void 0,void 0,h);var f={};n.forEach((g=>{a[g]&&(f[g]=a[g])})),Object.keys(f).length&&dt.N(o,f,l,u,c,h)}catch(g){he.D(g)}},q(o,a){try{_?.localStorage.removeItem(o),dt.q(o,a)}catch(l){he.D(l)}}})})(e.cookie_persisted_properties||[]),s=e.persistence.toLowerCase();return s==="localstorage"&&he.R()?he:s==="localstorage+cookie"&&i.R()?i:s==="sessionstorage"&&Re.R()?Re:s==="memory"?tE:s==="cookie"?dt:i.R()?i:dt}wr(e){var i=e??this.qt.feature_flag_cache_ttl_ms;if(!i||0>=i)return!1;var s=this.props[Xr];return!s||typeof s!="number"||Date.now()-s>i}properties(){var e={};return oe(this.props,((i,s)=>{var r=(n=>{var o=rE[n];if(o)return o;for(var[a,l]of nE)if(n.indexOf(a)===0)return l})(s);if(r?.exposure==="derived"){if(r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(i,s===Di?()=>this.wr():()=>!1))return;r.transformToEventProperties&&pe(e,r.transformToEventProperties(i))}else r&&r.exposure!=="event"||(e[s]=i)})),e}load(){if(!this._r){var e=this.nr.F(this.yr);e&&(this.props=pe({},e))}}save(){this._r||this.nr.N(this.yr,this.props,this.Sr,this.kr,this.Cr,this.qt.debug)}remove(){this.nr.q(this.yr,!1),this.nr.q(this.yr,!0)}clear(){this.remove(),this.props={}}register_once(e,i,s){if(ve(e)){P(i)&&(i="None"),this.Sr=P(s)?this.Ir:s;var r=!1;if(oe(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==i||(this.Tr(o,n),r=!0)})),r)return this.save(),!0}return!1}register(e,i){if(ve(e)){this.Sr=P(i)?this.Ir:i;var s=!1;if(oe(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.Tr(n,r),s=!0)})),s)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.Er(e),this.save())}update_campaign_params(){if(!this.mr){var e=og(this.qt.custom_campaign_params,this.qt.mask_personal_data_properties,this.qt.custom_personal_data_properties);Ni(Rl(e))||this.register(e),this.mr=!0}}update_search_keyword(){var e;this.register((e=I?.referrer)?lg(e):{})}update_referrer_info(){var e;this.register_once({$referrer:ug(),$referring_domain:I!=null&&I.referrer&&((e=rn(I.referrer))==null?void 0:e.host)||an},void 0)}set_initial_person_info(){this.props[qa]||this.props[ja]||this.register_once({[Jr]:cg(this.qt.mask_personal_data_properties,this.qt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};oe([ja,qa],(o=>{var a=this.props[o];a&&oe(a,(function(l,u){e["$initial_"+ca(u)]=l}))}));var i,s,r=this.props[Jr];if(r){var n=(i=dg(r),s={},oe(i,(function(o,a){s["$initial_"+ca(a)]=o})),s);pe(e,n)}return e}safe_merge(e){return oe(this.props,(function(i,s){s in e||(e[s]=i)})),e}update_config(e,i,s){if(this.Ir=this.Sr=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==i.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),u=[...a].sort();return l.every(((c,h)=>c===u[h]))})(e.cookie_persisted_properties||[],i.cookie_persisted_properties||[])){var r=this.br(e),n=this.props;this.clear(),this.nr=r,this.props=n,this.save()}}set_disabled(e){this._r=e,this._r?this.remove():this.save()}set_cross_subdomain(e){e!==this.kr&&(this.kr=e,this.remove(),this.save())}set_secure(e){e!==this.Cr&&(this.Cr=e,this.remove(),this.save())}set_event_timer(e,i){var s=this.props[ys]||{};s[e]=i,this.Tr(ys,s),this.save()}remove_event_timer(e){var i=this.props[ys]||{},s=i[e];return P(s)||(delete i[e],this.Tr(ys,i),this.save()),s}get_property(e){return this.props[e]}set_property(e,i){this.Tr(e,i),this.save()}Tr(e,i){this.props[e]=i}Er(e){delete this.props[e]}},cs={Activation:"events",Cancellation:"cancelEvents"},Yo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},ks={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Xo={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Ja={Popover:"popover",Inline:"inline"},cE={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Vd={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Gd=ue("[RateLimiter]"),Qa=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach((r=>{Gd.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void Gd.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:s})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var i,s,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(i=(s=this.instance.persistence)==null?void 0:s.get_property(Ga))!==null&&i!==void 0?i:{tokens:n,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>n&&(l.tokens=n);var u=1>l.tokens;return u||e||(l.tokens=Math.max(0,l.tokens-1)),!u||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=u,(r=this.instance.persistence)==null||r.set_property(Ga,l),{isRateLimited:u,remainingTokens:l.tokens}}isServerRateLimited(e){var i=this.serverLimits[e||"events"]||!1;return i!==!1&&new Date().getTime()<i}},ds=ue("[RemoteConfig]"),ln=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=L._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Mr(e){var i,s;(i=L.__PosthogExtensions__)!=null&&i.loadExternalDependency?(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Pr(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(i){e(i.json)}})}load(){try{if(this.remoteConfig)return ds.info("Using preloaded remote config",this.remoteConfig),this.Rr(this.remoteConfig),void this.Or();if(this._instance.Lr())return void ds.warn("Remote config is disabled. Falling back to local config.");this.Mr((e=>{if(!e)return ds.info("No config found after loading remote JS config. Falling back to JSON."),void this.Pr((i=>{this.Rr(i),this.Or()}));this.Rr(e),this.Or()}))}catch(e){ds.error("Error loading remote config",e)}}stop(){this.Fr&&(clearInterval(this.Fr),this.Fr=void 0)}refresh(){this._instance.Lr()||I?.visibilityState==="hidden"||this._instance.reloadFeatureFlags()}Or(){var e;if(!this.Fr){var i=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;i!==0&&(this.Fr=setInterval((()=>{this.refresh()}),i))}}Rr(e){var i;e||ds.error("Failed to fetch remote config from PostHog."),this._instance.Rr(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(i=this._instance.featureFlags)==null||i.ensureFlagsLoaded())}},ct={GZipJS:"gzip-js",Base64:"base64"},Ze=Uint8Array,Le=Uint16Array,Gi=Uint32Array,Pl=new Ze([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ol=new Ze([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),qd=new Ze([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gg=function(t,e){for(var i=new Le(31),s=0;31>s;++s)i[s]=e+=1<<t[s-1];var r=new Gi(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},fg=gg(Pl,2),Za=fg[1];fg[0][28]=258,Za[258]=28;for(el=gg(Ol,0)[1],un=new Le(32768),ie=0;32768>ie;++ie)Qt=(43690&ie)>>>1|(21845&ie)<<1,un[ie]=((65280&(Qt=(61680&(Qt=(52428&Qt)>>>2|(13107&Qt)<<2))>>>4|(3855&Qt)<<4))>>>8|(255&Qt)<<8)>>>1;Ts=function(t,e,i){for(var s=t.length,r=0,n=new Le(e);s>r;++r)++n[t[r]-1];var o,a=new Le(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Le(1<<e);var l=15-e;for(r=0;s>r;++r)if(t[r])for(var u=r<<4|t[r],c=e-t[r],h=a[t[r]-1]++<<c,f=h|(1<<c)-1;f>=h;++h)o[un[h]>>>l]=u}else for(o=new Le(s),r=0;s>r;++r)o[r]=un[a[t[r]-1]++]>>>15-t[r];return o},ni=new Ze(288);for(ie=0;144>ie;++ie)ni[ie]=8;for(ie=144;256>ie;++ie)ni[ie]=9;for(ie=256;280>ie;++ie)ni[ie]=7;for(ie=280;288>ie;++ie)ni[ie]=8;cn=new Ze(32);for(ie=0;32>ie;++ie)cn[ie]=5;dE=Ts(ni,9,0),hE=Ts(cn,5,0),pg=function(t){return(t/8>>0)+(7&t&&1)},vg=function(t,e,i){(i==null||i>t.length)&&(i=t.length);var s=new(t instanceof Le?Le:t instanceof Gi?Gi:Ze)(i-e);return s.set(t.subarray(e,i)),s},kt=function(t,e,i){var s=e/8>>0;t[s]|=i<<=7&e,t[s+1]|=i>>>8},hs=function(t,e,i){var s=e/8>>0;t[s]|=i<<=7&e,t[s+1]|=i>>>8,t[s+2]|=i>>>16},Jo=function(t,e){for(var i=[],s=0;t.length>s;++s)t[s]&&i.push({s,f:t[s]});var r=i.length,n=i.slice();if(!r)return[new Ze(0),0];if(r==1){var o=new Ze(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(b,x){return b.f-x.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,c=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[h].f>i[u].f?u++:h++],l=i[u!=c&&i[h].f>i[u].f?u++:h++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var f=n[0].s;for(s=1;r>s;++s)n[s].s>f&&(f=n[s].s);var g=new Le(f+1),p=tl(i[c-1],g,0);if(p>e){s=0;var v=0,m=p-e,y=1<<m;for(n.sort((function(b,x){return g[x.s]-g[b.s]||b.f-x.f}));r>s;++s){var w=n[s].s;if(e>=g[w])break;v+=y-(1<<p-g[w]),g[w]=e}for(v>>>=m;v>0;){var R=n[s].s;e>g[R]?v-=1<<e-g[R]++-1:++s}for(;s>=0&&v;--s){var N=n[s].s;g[N]==e&&(--g[N],++v)}p=e}return[new Ze(g),p]},tl=function(t,e,i){return t.s==-1?Math.max(tl(t.l,e,i+1),tl(t.r,e,i+1)):e[t.s]=i},jd=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new Le(++e),s=0,r=t[0],n=1,o=function(l){i[s++]=l},a=1;e>=a;++a)if(t[a]==r&&a!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=t[a]}return[i.subarray(0,s),e]},gs=function(t,e){for(var i=0,s=0;e.length>s;++s)i+=t[s]*e[s];return i},il=function(t,e,i){var s=i.length,r=pg(e+2);t[r]=255&s,t[r+1]=s>>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var n=0;s>n;++n)t[r+n+4]=i[n];return 8*(r+4+s)},Hd=function(t,e,i,s,r,n,o,a,l,u,c){kt(e,c++,i),++r[256];for(var h=Jo(r,15),f=h[0],g=h[1],p=Jo(n,15),v=p[0],m=p[1],y=jd(f),w=y[0],R=y[1],N=jd(v),b=N[0],x=N[1],C=new Le(19),O=0;w.length>O;++O)C[31&w[O]]++;for(O=0;b.length>O;++O)C[31&b[O]]++;for(var A=Jo(C,7),$=A[0],U=A[1],H=19;H>4&&!$[qd[H-1]];--H);var G,q,_e,Ee,$e=u+5<<3,Se=gs(r,ni)+gs(n,cn)+o,k=gs(r,f)+gs(n,v)+o+14+3*H+gs(C,$)+(2*C[16]+3*C[17]+7*C[18]);if(Se>=$e&&k>=$e)return il(e,c,t.subarray(l,l+u));if(kt(e,c,1+(Se>k)),c+=2,Se>k){G=Ts(f,g,0),q=f,_e=Ts(v,m,0),Ee=v;var M=Ts($,U,0);for(kt(e,c,R-257),kt(e,c+5,x-1),kt(e,c+10,H-4),c+=14,O=0;H>O;++O)kt(e,c+3*O,$[qd[O]]);c+=3*H;for(var F=[w,b],B=0;2>B;++B){var Z=F[B];for(O=0;Z.length>O;++O)kt(e,c,M[ce=31&Z[O]]),c+=$[ce],ce>15&&(kt(e,c,Z[O]>>>5&127),c+=Z[O]>>>12)}}else G=dE,q=ni,_e=hE,Ee=cn;for(O=0;a>O;++O)if(s[O]>255){var ce;hs(e,c,G[257+(ce=s[O]>>>18&31)]),c+=q[ce+257],ce>7&&(kt(e,c,s[O]>>>23&31),c+=Pl[ce]);var se=31&s[O];hs(e,c,_e[se]),c+=Ee[se],se>3&&(hs(e,c,s[O]>>>5&8191),c+=Ol[se])}else hs(e,c,G[s[O]]),c+=q[s[O]];return hs(e,c,G[256]),c+q[256]},gE=new Gi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fE=(function(){for(var t=new Gi(256),e=0;256>e;++e){for(var i=e,s=9;--s;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t})(),Qo=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};vE=!!la||!!aa,_g="text/plain",zd=!1,mn=function(t,e,i){var s;i===void 0&&(i=!0);var[r,n]=t.split("?"),o=S({},e),a=(s=n?.split("&").map((u=>{var c,[h,f]=u.split("="),g=i&&(c=o[h])!==null&&c!==void 0?c:f;return delete o[h],h+"="+g})))!==null&&s!==void 0?s:[],l=(function(u,c){var h,f;c===void 0&&(c="&");var g=[];return oe(u,(function(p,v){P(p)||P(v)||v==="undefined"||(h=encodeURIComponent((m=>m instanceof File)(p)?p.name:p.toString()),f=encodeURIComponent(v),g[g.length]=f+"="+h)})),g.join(c)})(o);return l&&a.push(l),r+"?"+a.join("&")},Li=(t,e)=>JSON.stringify(t,((i,s)=>typeof s=="bigint"?s.toString():s),e),Zo=t=>{if(t.tr)return t.tr;var{data:e,compression:i}=t;if(e){if(i===ct.GZipJS){var s=pE((function(a,l){var u=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var c=new Ze(a.length+(a.length>>>1)),h=0,f=function(m){c[h++]=m},g=0;u>g;++g){if(h+5>c.length){var p=new Ze(h+8+(u-g<<1));p.set(c),c=p}var v=a.charCodeAt(g);128>v?f(v):2048>v?(f(192|v>>>6),f(128|63&v)):v>55295&&57344>v?(f(240|(v=65536+(1047552&v)|1023&a.charCodeAt(++g))>>>18),f(128|v>>>12&63),f(128|v>>>6&63),f(128|63&v)):(f(224|v>>>12),f(128|v>>>6&63),f(128|63&v))}return vg(c,0,h)})(Li(e)),{mtime:0});return{contentType:_g,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===ct.Base64){var r=(function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,((l,u)=>String.fromCharCode(parseInt(u,16)))))})(Li(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Li(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Li(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},_E=(function(){var t=Qe((function*(e){var i=Li(e.data),s=yield(function(n,o,a){return ua.apply(this,arguments)})(i,De.DEBUG,{rethrow:!0});if(!s)return e;var r=yield s.arrayBuffer();return S({},e,{tr:{contentType:_g,body:r,estimatedSize:r.byteLength}})}));return function(e){return t.apply(this,arguments)}})(),Kd=(t,e)=>mn(t,{_:new Date().getTime().toString(),ver:De.JS_SDK_VERSION,compression:e}),Gr=[];aa&&Gr.push({transport:"fetch",method(t){var e,i,{contentType:s,body:r,estimatedSize:n}=(e=Zo(t))!==null&&e!==void 0?e:{},o=new Headers;oe(t.headers,(function(c,h){o.append(h,c)})),s&&o.append("Content-Type",s);var a=t.url,l=null;if(Td){var u=new Td;l={signal:u.signal,timeout:setTimeout((()=>u.abort()),t.timeout)}}aa(a,S({method:t?.method||"GET",headers:o,keepalive:t.method==="POST"&&52428.8>(n||0),body:r,signal:(i=l)==null?void 0:i.signal},t.fetchOptions)).then((c=>c.text().then((h=>{var f={statusCode:c.status,text:h};if(c.status===200)try{f.json=JSON.parse(h)}catch(g){T.error(g)}t.callback==null||t.callback(f)})))).catch((c=>{T.error(c),t.callback==null||t.callback({statusCode:0,error:c})})).finally((()=>l?clearTimeout(l.timeout):null))}}),la&&Gr.push({transport:"XHR",method(t){var e,i=new la;i.open(t.method||"GET",t.url,!0);var{contentType:s,body:r}=(e=Zo(t))!==null&&e!==void 0?e:{};oe(t.headers,(function(n,o){i.setRequestHeader(o,n)})),s&&i.setRequestHeader("Content-Type",s),t.timeout&&(i.timeout=t.timeout),t.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(i.readyState===4){var n={statusCode:i.status,text:i.responseText};if(i.status===200)try{n.json=JSON.parse(i.responseText)}catch{}t.callback==null||t.callback(n)}},i.send(r)}}),ze!=null&&ze.sendBeacon&&Gr.push({transport:"sendBeacon",method(t){var e=mn(t.url,{beacon:"1"});try{var i,{contentType:s,body:r}=(i=Zo(t))!==null&&i!==void 0?i:{};if(!r)return;var n=r instanceof Blob?r:new Blob([r],{type:s});ze.sendBeacon(e,n)}catch{}}});sl=3e3,rl=class{constructor(e,i){this.Ar=!0,this.Nr=[],this.$r=gt(i?.flush_interval_ms||sl,250,5e3,T.createLogger("flush interval"),sl),this.Dr=e}enqueue(e){this.Nr.push(e),this.qr||this.jr()}unload(){this.Hr();var e=this.Nr.length>0?this.Ur():{},i=Object.values(e);[...i.filter((s=>s.url.indexOf("/e")===0)),...i.filter((s=>s.url.indexOf("/e")!==0))].map((s=>{this.Dr(S({},s,{transport:"sendBeacon"}))}))}enable(){this.Ar=!1,this.jr()}jr(){var e=this;this.Ar||(this.qr=setTimeout((()=>{if(this.Hr(),this.Nr.length>0){var i=this.Ur(),s=function(){var n=i[r],o=new Date().getTime();n.data&&Y(n.data)&&oe(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Dr(n)};for(var r in i)s()}}),this.$r))}Hr(){clearTimeout(this.qr),this.qr=void 0}Ur(){var e={};return oe(this.Nr,(i=>{var s,r=i,n=(r?r.batchKey:null)||r.url;P(e[n])&&(e[n]=S({},r,{data:[]})),(s=e[n].data)==null||s.push(r.data)})),this.Nr=[],e}},mE=["retriesPerformedSoFar"],nl=class{constructor(e){this.Br=!1,this.zr=3e3,this.Nr=[],this._instance=e,this.Nr=[],this.Vr=!0,!P(_)&&"onLine"in _.navigator&&(this.Vr=_.navigator.onLine,this.Wr=()=>{this.Vr=!0,this.Zr()},this.Gr=()=>{this.Vr=!1},ye(_,"online",this.Wr),ye(_,"offline",this.Gr))}get length(){return this.Nr.length}retriableRequest(e){var{retriesPerformedSoFar:i}=e,s=Sh(e,mE);Pi(i)&&(s.url=mn(s.url,{retry_count:i})),this._instance._send_request(S({},s,{callback:r=>{r.statusCode===200||r.statusCode>=400&&500>r.statusCode||(i??0)>=10?s.callback==null||s.callback(r):this.Qr(S({retriesPerformedSoFar:i},s))}}))}Qr(e){var i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;var s=(function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=Math.random()-.5;return Math.ceil(u+c*(u-l))})(i),r=Date.now()+s;this.Nr.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+s;navigator.onLine||(n+=" (Browser is offline)"),T.warn(n),this.Br||(this.Br=!0,this.Jr())}Jr(){if(this.Kr&&clearTimeout(this.Kr),this.Nr.length===0)return this.Br=!1,void(this.Kr=void 0);this.Kr=setTimeout((()=>{this.Vr&&this.Nr.length>0&&this.Zr(),this.Jr()}),this.zr)}Zr(){var e=Date.now(),i=[],s=this.Nr.filter((n=>e>n.retryAt||(i.push(n),!1)));if(this.Nr=i,s.length>0)for(var{requestOptions:r}of s)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Kr&&(clearTimeout(this.Kr),this.Kr=void 0),this.Br=!1,P(_)||(this.Wr&&(_.removeEventListener("online",this.Wr),this.Wr=void 0),this.Gr&&(_.removeEventListener("offline",this.Gr),this.Gr=void 0)),this.Nr))try{this._instance._send_request(S({},e,{transport:"sendBeacon"}))}catch(i){T.error(i)}this.Nr=[]}},ol=class{constructor(e){this.Yr=()=>{var i,s,r,n;this.Xr||(this.Xr={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+(o?.clientHeight||0),c=o?.scrollHeight||0;this.Xr.lastScrollY=Math.ceil(a),this.Xr.maxScrollY=Math.max(a,(i=this.Xr.maxScrollY)!==null&&i!==void 0?i:0),this.Xr.maxScrollHeight=Math.max(l,(s=this.Xr.maxScrollHeight)!==null&&s!==void 0?s:0),this.Xr.lastContentY=u,this.Xr.maxContentY=Math.max(u,(r=this.Xr.maxContentY)!==null&&r!==void 0?r:0),this.Xr.maxContentHeight=Math.max(c,(n=this.Xr.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get ei(){return this._instance.config.scroll_root_selector}getContext(){return this.Xr}resetContext(){var e=this.Xr;return setTimeout(this.Yr,0),e}startMeasuringScrollPosition(){ye(_,"scroll",this.Yr,{capture:!0}),ye(_,"scrollend",this.Yr,{capture:!0}),ye(_,"resize",this.Yr)}scrollElement(){if(!this.ei)return _?.document.documentElement;var e=Y(this.ei)?this.ei:[this.ei];for(var i of e){var s=_?.document.querySelector(i);if(s)return s}}scrollY(){if(this.ei){var e=this.scrollElement();return e&&e.scrollTop||0}return _&&(_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop)||0}scrollX(){if(this.ei){var e=this.scrollElement();return e&&e.scrollLeft||0}return _&&(_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft)||0}},yE=t=>cg(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties),dn=class{constructor(e,i,s,r){this.ti=n=>{var o=this.ri();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.ii(this._instance)};this.ni.register({[Va]:a})}},this._instance=e,this.si=i,this.ni=s,this.ii=r||yE,this.si.onSessionId(this.ti)}ri(){return this.ni.props[Va]}getSetOnceProps(){var e,i=(e=this.ri())==null?void 0:e.props;return i?"r"in i?dg(i):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){var e={};return oe(Rl(this.getSetOnceProps()),((i,s)=>{s==="$current_url"&&(s="url"),e["$session_entry_"+ca(s)]=i})),e}},Ds=class{constructor(){this.oi={}}on(e,i){return this.oi[e]||(this.oi[e]=[]),this.oi[e].push(i),()=>{this.oi[e]=this.oi[e].filter((s=>s!==i))}}emit(e,i){for(var s of this.oi[e]||[])s(i);for(var r of this.oi["*"]||[])r(e,i)}},ea=ue("[SessionId]"),hn=class{on(e,i){return this.ai.on(e,i)}constructor(e,i,s){var r;if(this.ui=[],this.li=void 0,this.ai=new Ds,this.hi=(u,c)=>!(!Pi(u)||!Pi(c))&&Math.abs(u-c)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===Tt)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.qt=e.config,this.ni=e.persistence,this.ci=void 0,this.di=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.vi=i||Bt,this.fi=s||Bt;var n=this.qt.persistence_name||this.qt.token;if(this._sessionTimeoutMs=1e3*gt(this.qt.session_idle_timeout_seconds||1800,60,36e3,ea.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.pi(),this.gi="ph_"+n+"_window_id",this.mi="ph_"+n+"_primary_window_exists",this.yi()){var o=Re.F(this.gi),a=Re.F(this.mi);o&&!a?this.ci=o:Re.q(this.gi),Re.N(this.mi,!0)}if((r=this.qt.bootstrap)!=null&&r.sessionID)try{var l=(u=>{var c=this.qt.bootstrap.sessionID.replace(/-/g,"");if(c.length!==32)throw new Error("Not a valid UUID");if(c[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(c.substring(0,12),16)})();this.bi(this.qt.bootstrap.sessionID,new Date().getTime(),l)}catch(u){ea.error("Invalid sessionID in bootstrap",u)}this.wi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return P(this.ui)&&(this.ui=[]),this.ui.push(e),this.di&&e(this.di,this.ci),()=>{this.ui=this.ui.filter((i=>i!==e))}}yi(){return this.qt.persistence!=="memory"&&!this.ni._r&&Re.R()}xi(e){e!==this.ci&&(this.ci=e,this.yi()&&Re.N(this.gi,e))}Si(){return this.ci?this.ci:this.yi()?Re.F(this.gi):null}bi(e,i,s){e===this.di&&i===this._sessionActivityTimestamp&&s===this._sessionStartTimestamp||(this._sessionStartTimestamp=s,this._sessionActivityTimestamp=i,this.di=e,this.ni.register({[Yr]:[i,e,s]}))}ki(){var e=this.ni.props[Yr];return Y(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.bi(null,null,null)}destroy(){clearTimeout(this.Ci),this.Ci=void 0,this.li&&_&&(_.removeEventListener(en,this.li,{capture:!1}),this.li=void 0),this.ui=[]}wi(){this.li=()=>{this.yi()&&Re.q(this.mi)},ye(_,en,this.li,{capture:!1})}checkAndGetSessionAndWindowId(e,i){if(e===void 0&&(e=!1),i===void 0&&(i=null),this.qt.cookieless_mode===Tt)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=i||new Date().getTime(),[r,n,o]=this.ki(),a=this.Si(),l=Pi(o)&&Math.abs(s-o)>864e5,u=!1,c=!n,h=!c&&!e&&this.hi(s,r);c||h||l?(n=this.vi(),a=this.fi(),ea.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}}),o=s,u=!0):a||(a=this.fi(),u=!0);var f=Pi(r)&&e&&!l?r:s,g=Pi(o)?o:new Date().getTime();return this.xi(a),this.bi(n,f,g),e||this.pi(),u&&this.ui.forEach((p=>p(n,a,u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:g,changeReason:u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}pi(){clearTimeout(this.Ci),this.Ci=setTimeout((()=>{var[e]=this.ki();if(this.hi(new Date().getTime(),e)){var i=this.di;this.resetSessionId(),this.ai.emit("forcedIdleReset",{idleSessionId:i})}}),1.1*this.sessionTimeoutMs)}},mg=function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&Od(i,e))return!0;try{var s=t?.userAgentData;if(s!=null&&s.brands&&s.brands.some((r=>Od(r?.brand,e))))return!0}catch{}return!!t.webdriver},gn=function(t,e){if(!(function(i){try{new RegExp(i)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};yg={exact:(t,e)=>e.some((i=>t.some((s=>i===s)))),is_not:(t,e)=>e.every((i=>t.every((s=>i!==s)))),regex:(t,e)=>e.some((i=>t.some((s=>gn(i,s))))),not_regex:(t,e)=>e.every((i=>t.every((s=>!gn(i,s))))),icontains:(t,e)=>e.map($r).some((i=>t.map($r).some((s=>i.includes(s))))),not_icontains:(t,e)=>e.map($r).every((i=>t.map($r).every((s=>!i.includes(s))))),gt:(t,e)=>e.some((i=>{var s=parseFloat(i);return!isNaN(s)&&t.some((r=>s>parseFloat(r)))})),lt:(t,e)=>e.some((i=>{var s=parseFloat(i);return!isNaN(s)&&t.some((r=>s<parseFloat(r)))}))},$r=t=>t.toLowerCase();al="custom",Yd="i.posthog.com",bE=/^\/static\//,ll=class{constructor(e){this.Ii={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,i=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return i||(i=this.apiHost.replace("."+Yd,".posthog.com")),i==="https://app.posthog.com"?"https://us.posthog.com":i}get region(){return this.Ii[this.apiHost]||(this.Ii[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":al),this.Ii[this.apiHost]}Ti(e){var i=this.instance.config.__preview_external_dependency_versioned_paths;if(typeof i=="string"&&bE.test(e))return i.trim().replace(/\/$/,"")||void 0}endpointFor(e,i){if(i===void 0&&(i=""),i&&(i=i[0]==="/"?i:"/"+i),e==="ui")return this.uiHost+i;if(e==="flags")return this.flagsApiHost+i;if(e==="assets"){var s=this.Ti(i);if(s)return""+s+i}if(this.region===al)return this.apiHost+i;var r=Yd+i;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},ee=ue("[Surveys]"),ul="seenSurvey_",EE=[Yo.Popover,Yo.Widget,Yo.API],SE={ignoreConditions:!1,ignoreDelay:!1,displayType:Ja.Popover},kE=ue("[PostHog ExternalIntegrations]"),wE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},cl=class{constructor(e){this._instance=e}lr(e,i){var s;(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,e,(r=>{if(r)return kE.error("failed to load script",r);i()}))}startIfEnabledOrStop(){var e=this,i=function(o){var a,l,u;!r||(a=L.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.lr(wE[o],(()=>{var c;(c=L.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.start(e._instance)})),!r&&(l=L.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((u=L.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.stop())};for(var[s,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;i(s)}}},Rs={},ta=0,dl=()=>{},Xd='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',fs="Surveys module not available",Jd="sanitize_properties is deprecated. Use before_send instead",Eg="Invalid value for property_denylist config: ",xi="posthog",Sg=!vE&&Ge?.indexOf("MSIE")===-1&&Ge?.indexOf("Mozilla")===-1,Qd=t=>{var e;return S({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Jb(I?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:dl,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,debug:Te&&ge(Te?.search)&&Te.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(_==null||(e=_.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(i){T.error("Bad HTTP status: "+i.statusCode+" "+i.text)},get_device_id:i=>i,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ha,before_send:void 0,request_queue_config:{flush_interval_ms:sl},error_tracking:{},_onCapture:dl,__preview_eager_load_replay:!1},(i=>({rageclick:!i||"2025-11-30">i||{content_ignorelist:!0},capture_pageview:!i||"2025-05-24">i||"history_change",session_recording:i&&i>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:i&&i>="2026-01-30"?"head":"body",internal_or_test_user_hostname:i&&i>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(t))},AE=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Zd=t=>{var e={};for(var[i,s]of AE)P(t[i])||(e[s]=t[i]);var r=pe({},e,t);return Y(t.property_blacklist)&&(P(t.property_denylist)?r.property_denylist=t.property_blacklist:Y(t.property_denylist)?r.property_denylist=[...t.property_blacklist,...t.property_denylist]:T.error(Eg+t.property_denylist)),r},hl=class{constructor(){this.__forceAllowLocalhost=!1}get Ei(){return this.__forceAllowLocalhost}set Ei(e){T.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},ri=class t{Mi(e,i){if(e){var s=this.Pi.indexOf(e);s!==-1&&this.Pi.splice(s,1)}return this.Pi.push(i),i.initialize==null||i.initialize(),i}Ri(){return this.config.cookieless_mode===Tt||this.config.cookieless_mode===ii&&this.consent.isRejected()}get decideEndpointWasHit(){var e,i;return(e=(i=this.featureFlags)==null?void 0:i.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,i;return(e=(i=this.featureFlags)==null?void 0:i.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new hl,this.Oi=!1,this.version=De.LIB_VERSION,this.Li=new Ds,this.Pi=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Qd(),this.SentryIntegration=Xa,this.sentryIntegration=s=>(function(r,n){var o=ng(r,n);return{name:rg,processEvent:a=>o(a)}})(this,s),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Fi=!1,this.Ai=null,this.Ni=null,this.$i=null,this.scrollManager=new ol(this),this.pageViewManager=new sn(this),this.rateLimiter=new Qa(this),this.requestRouter=new ll(this),this.consent=new Ya(this),this.externalIntegrations=new cl(this);var i=(e=t.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(s,r,n)=>{var o=ge(s)?{[s]:r}:s;this.setPersonProperties(o),n?.({})},set_once:(s,r,n)=>{var o=ge(s)?{[s]:r}:s;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(s=>T.info('send "'+s?.event+'"',s)))}init(e,i,s){if(s&&s!==xi){var r,n=(r=Rs[s])!==null&&r!==void 0?r:new t;return n._init(e,i,s),Rs[s]=n,Rs[xi][s]=n,n}return this._init(e,i,s)}_init(e,i,s){var r,n;if(i===void 0&&(i={}),P(e)||Mr(e))return T.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},i.debug=this.Di(i.debug),this.qi=i,this.ji=[],i.person_profiles?this.Ni=i.person_profiles:i.process_person&&(this.Ni=i.process_person),this.set_config(pe({},Qd(i.defaults),Zd(i),{name:s,token:e})),this.config.on_xhr_error&&T.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:ct.GZipJS;var o=this.Hi();this.persistence=new Is(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Is(S({},this.config,{persistence:"sessionStorage"}),o);var a=S({},this.persistence.props),l=S({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Ui=new rl((m=>this.Bi(m)),this.config.request_queue_config),this.zi=new nl(this),this.__request_queue=[];var u=this.Ri();if(u||(this.sessionManager=new hn(this),this.sessionPropsManager=new dn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(T.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Vi(u)}),0)):(T.info("Initializing extensions synchronously"),this.Vi(u)),De.DEBUG=De.DEBUG||this.config.debug,De.DEBUG&&T.info("Starting in debug mode",{this:this,config:i,thisC:S({},this.config),p:a,s:l}),!this.config.identity_distinct_id||(r=i.bootstrap)!=null&&r.distinctID||(i.bootstrap=S({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((n=i.bootstrap)==null?void 0:n.distinctID)!==void 0){var c=i.bootstrap.distinctID,h=this.get_distinct_id(),f=this.persistence.get_property(rt);if(i.bootstrap.isIdentifiedID&&h!=null&&h!==c&&f===Ai)this.identify(c);else if(i.bootstrap.isIdentifiedID&&h!=null&&h!==c&&f===Ii)T.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var g=this.config.get_device_id(Bt()),p=i.bootstrap.isIdentifiedID?g:c;this.persistence.set_property(rt,i.bootstrap.isIdentifiedID?Ii:Ai),this.register({distinct_id:c,$device_id:p})}}if(u)this.register_once({distinct_id:Cr,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(Bt());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(rt,Ai)}return ye(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),i.segment?(function(m,y){var w=m.config.segment;if(!w)return y();(function(R,N){var b=R.config.segment;if(!b)return N();var x=O=>{var A=()=>O.anonymousId()||Bt();R.config.get_device_id=A,O.id()&&(R.register({distinct_id:O.id(),$device_id:A()}),R.persistence.set_property(rt,Ii)),N()},C=b.user();"then"in C&&It(C.then)?C.then(x):x(C)})(m,(()=>{w.register((R=>{Promise&&Promise.resolve||Wo.warn("This browser does not have Promise support, and can not use the segment integration");var N=(b,x)=>{if(!x)return b;b.event.userId||b.event.anonymousId===R.get_distinct_id()||(Wo.info("No userId set, resetting PostHog"),R.reset()),b.event.userId&&b.event.userId!==R.get_distinct_id()&&(Wo.info("UserId set, identifying with PostHog"),R.identify(b.event.userId));var C=R.calculateEventProperties(x,b.event.properties);return b.event.properties=Object.assign({},C,b.event.properties),b};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:b=>N(b,b.event.event),page:b=>N(b,Ci),identify:b=>N(b,zo),screen:b=>N(b,"$screen")}})(m)).then((()=>{y()}))}))})(this,(()=>this.Wi())):this.Wi(),It(this.config._onCapture)&&this.config._onCapture!==dl&&(T.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(m=>this.config._onCapture(m.event,m)))),this.config.ip&&T.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Vi(e){var i,s,r,n,o,a,l,u=performance.now(),c=S({},t.__defaultExtensionClasses,this.config.__extensionClasses),h=[];c.featureFlags&&this.Pi.push(this.featureFlags=(i=this.featureFlags)!==null&&i!==void 0?i:new c.featureFlags(this)),c.exceptions&&this.Pi.push(this.exceptions=(s=this.exceptions)!==null&&s!==void 0?s:new c.exceptions(this)),c.historyAutocapture&&this.Pi.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this.Pi.push(new c.tracingHeaders(this)),c.siteApps&&this.Pi.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this.Pi.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this.Pi.push(this.autocapture=new c.autocapture(this)),c.surveys&&this.Pi.push(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new c.surveys(this)),c.logs&&this.Pi.push(this.logs=(n=this.logs)!==null&&n!==void 0?n:new c.logs(this)),c.conversations&&this.Pi.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new c.conversations(this)),c.productTours&&this.Pi.push(this.productTours=new c.productTours(this)),c.heatmaps&&this.Pi.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this.Pi.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this.Pi.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this.Pi.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,sE)),c.toolbar&&this.Pi.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new c.toolbar(this)),c.experiments&&this.Pi.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new c.experiments(this)),this.Pi.forEach((f=>{f.initialize&&h.push((()=>{f.initialize==null||f.initialize()}))})),h.push((()=>{if(this.Zi){var f=this.Zi;this.Zi=void 0,this.Rr(f)}})),this.Gi(h,u)}Gi(e,i){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&e.length>0)return void setTimeout((()=>{this.Gi(e,i)}),0);var s=e.shift();if(s)try{s()}catch(n){T.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-i);this.register_for_session({[Zh]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[eg]:r}),this.config.__preview_deferred_init_extensions&&T.info("PostHog extensions initialized ("+r+"ms)")}Rr(e){var i;if(!I||!I.body)return T.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Rr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Zi=e),this.Qi=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=z(e.supportedCompression,ct.GZipJS)?ct.GZipJS:z(e.supportedCompression,ct.Base64)?ct.Base64:void 0),(i=e.analytics)!=null&&i.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ni?this.Ni:Ha}),this.Pi.forEach((s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(e)))}Wi(){try{this.config.loaded(this)}catch(s){T.critical("`loaded` function failed",s)}if(this.Ji(),this.config.internal_or_test_user_hostname&&Te!=null&&Te.hostname){var e=Te.hostname,i=this.config.internal_or_test_user_hostname;(typeof i=="string"?e===i:i.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Ri())&&this.Ki()}),1),this.Yi=new ln(this),this.Yi.load()}Ji(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Ui)==null||e.enable())}_dom_loaded(){this.is_capturing()&&xr(this.__request_queue,(e=>this.Bi(e))),this.__request_queue=[],this.Ji()}_handle_unload(){var e,i,s,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Xi()&&this.capture(Ho),(i=this.logs)==null||i.flushLogs("sendBeacon"),(s=this.Ui)==null||s.unload(),(r=this.zi)==null||r.unload()):this.Xi()&&this.capture(Ho,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Sg?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=mn(e.url,{ip:this.config.ip?1:0}),e.headers=S({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(i=>{var s,r,n,o=S({},i);o.timeout=o.timeout||6e4,o.url=Kd(o.url,o.compression);var a=(s=o.transport)!==null&&s!==void 0?s:"fetch",l=Gr.filter((c=>!o.disableTransport||!c.transport||!o.disableTransport.includes(c.transport))),u=(r=(n=(function(c,h){for(var f=0;c.length>f;f++)if(c[f].transport===a)return c[f]})(l))==null?void 0:n.method)!==null&&r!==void 0?r:l[0].method;if(!u)throw new Error("No available transport method");a!=="sendBeacon"&&o.data&&o.compression===ct.GZipJS&&mb&&!zd?_E(o).then((c=>{u(c)})).catch((c=>{if((h=>!(!h||typeof h!="object")&&("name"in h?String(h.name):"")==="NotReadableError")(c))return zd=!0,void u(S({},o,{compression:void 0,url:Kd(i.url,void 0)}));u(o)})):u(o)})(S({},e,{callback:i=>{var s,r;this.rateLimiter.checkForLimiting(i),400>i.statusCode||(s=(r=this.config).on_request_error)==null||s.call(r,i),e.callback==null||e.callback(i)}}))))}Bi(e){this.zi?this.zi.retriableRequest(e):this._send_request(e)}_execute_array(e){ta++;try{var i,s=[],r=[],n=[];xr(e,(a=>{a&&(Y(i=a[0])?n.push(a):It(a)?a.call(this):Y(a)&&i==="alias"?s.push(a):Y(a)&&i.indexOf("capture")!==-1&&It(this[i])?n.push(a):r.push(a))}));var o=function(a,l){xr(a,(function(u){if(Y(u[0])){var c=l;oe(u,(function(h){c=c[h[0]].apply(c,h.slice(1))}))}else l[u[0]].apply(l,u.slice(1))}))};o(s,this),o(r,this),o(n,this)}finally{ta--}}push(e){if(ta>0&&Y(e)&&ge(e[0])){var i=t.prototype[e[0]];It(i)&&i.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,i,s){var r,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ui){if(this.is_capturing())if(!P(e)&&ge(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=s!=null&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){i!=null&&i.$current_url&&!ge(i?.$current_url)&&(T.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),i==null||delete i.$current_url),e!=="$exception"||s!=null&&s.en||T.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var h=new Date,f=s?.timestamp||h,g=Bt(),p={uuid:g,event:e,properties:this.calculateEventProperties(e,i||{},f,g)};e===Ci&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),c&&(p.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),s?.$set&&(p.$set=s?.$set);var v,m,y,w=this.tn(s?.$set_once,e!==Fd,e===zo);if(w&&(p.$set_once=w),s!=null&&s._noTruncate||(n=this.config.properties_string_max_length,o=p,a=A=>ge(A)?A.slice(0,n):A,l=new Set,p=(function A($,U){return $!==Object($)?a?a($):$:l.has($)?void 0:(l.add($),Y($)?(H=[],xr($,(G=>{H.push(A(G))}))):(H={},oe($,((G,q)=>{l.has(G)||(H[q]=A(G,q))}))),H);var H})(o)),p.timestamp=f,P(s?.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=h),e===ks.DISMISSED||e===ks.SENT){var R=i?.[Xo.SURVEY_ID],N=i?.[Xo.SURVEY_ITERATION];(A=>{try{var $=(U=>((H,G)=>{var q=""+ul+G.id;return G.current_iteration&&G.current_iteration>0&&(q=""+ul+G.id+"_"+G.current_iteration),q})(0,U))(A);if(localStorage.getItem($))return;localStorage.setItem($,"true")}catch(U){ee.error("Failed to persist survey seen state",U)}})({id:R,current_iteration:N}),p.$set=S({},p.$set,{[(v={id:R,current_iteration:N},m=e===ks.SENT?"responded":"dismissed",y="$survey_"+m+"/"+v.id,v.current_iteration&&v.current_iteration>0&&(y="$survey_"+m+"/"+v.id+"/"+v.current_iteration),y)]:!0})}else e===ks.SHOWN&&(p.$set=S({},p.$set,{[Xo.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===cE.SHOWN){var b=i?.[Vd.TOUR_TYPE];b&&(p.$set=S({},p.$set,{[Vd.TOUR_LAST_SEEN_DATE+"/"+b]:new Date().toISOString()}))}var x=S({},p.properties.$set,p.$set);if(Ni(x)||this.setPersonPropertiesForFlags(x),!K(this.config.before_send)){var C=this.rn(p);if(!C)return;p=C}this.Li.emit("eventCaptured",p);var O={method:"POST",url:(r=s?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:s?._batchKey};return!this.config.request_batching||s&&(s==null||!s._batchKey)||s!=null&&s.send_instantly?this.Bi(O):this.Ui.enqueue(O),p}T.critical("This capture call is ignored due to client rate limiting.")}}else T.error("No event name provided to posthog.capture")}else T.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(i=>e(i.event,i)))}calculateEventProperties(e,i,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return i;var o=n?void 0:this.persistence.remove_event_timer(e),a=S({},i);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.Ri()&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=S({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ge(a.distinct_id)&&!et(a.distinct_id)||Mr(a.distinct_id))&&T.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=(function(y,w){var R,N,b,x;if(!Ge)return{};var C,O,A,$,U,H,G,q,_e=y?[...Vi,...w||[]]:[],[Ee,$e]=(function(Se){for(var k=0;Nd.length>k;k++){var[M,F]=Nd[k],B=M.exec(Se),Z=B&&(It(F)?F(B,Se):F);if(Z)return Z}return["",""]})(Ge);return pe(Rl({$os:Ee,$os_version:$e,$browser:Vh(Ge,navigator.vendor),$device:Dd(Ge),$device_type:(O=Ge,A={userAgentDataPlatform:(R=navigator)==null||(R=R.userAgentData)==null?void 0:R.platform,maxTouchPoints:(N=navigator)==null?void 0:N.maxTouchPoints,screenWidth:_==null||(b=_.screen)==null?void 0:b.width,screenHeight:_==null||(x=_.screen)==null?void 0:x.height,devicePixelRatio:_?.devicePixelRatio},q=Dd(O),q===Th||q===Ih||q==="Kobo"||q==="Kindle Fire"||q===Bh?Mi:q===Os||q===Fi||q===Cs||q===ga?"Console":q===Ph?"Wearable":q?Ke:A?.userAgentDataPlatform==="Android"&&(($=A?.maxTouchPoints)!==null&&$!==void 0?$:0)>0?600>Math.min((U=A?.screenWidth)!==null&&U!==void 0?U:0,(H=A?.screenHeight)!==null&&H!==void 0?H:0)/((G=A?.devicePixelRatio)!==null&&G!==void 0?G:1)?Ke:Mi:"Desktop"),$timezone:hg(),$timezone_offset:lE()}),{$current_url:xs(Te?.href,_e,Ns),$host:Te?.host,$pathname:Te?.pathname,$raw_user_agent:Ge.length>1e3?Ge.substring(0,997)+"...":Ge,$browser_version:Nb(Ge,navigator.vendor),$browser_language:Bd(),$browser_language_prefix:(C=Bd(),typeof C=="string"?C.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.innerWidth,$lib:De.LIB_NAME,$lib_version:De.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime());a.$session_id=h,a.$window_id=f}this.sessionPropsManager&&pe(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&pe(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.zi)==null?void 0:g.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===al&&(a.$lib_custom_api_host=this.config.api_host),u=e!==Ci||n?e!==Ho||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=pe(a,u),e===Ci&&I&&(a.title=I.title),!P(o)){var p=s.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}Ge&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=pe({},c,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),Y(this.config.property_denylist)?oe(this.config.property_denylist,(function(y){delete a[y]})):T.error(Eg+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(T.error(Jd),a=v(a,e));var m=this.nn();return a.$process_person_profile=m,m&&!n&&this.sn("_calculate_event_properties"),a}tn(e,i,s){var r;if(i===void 0&&(i=!0),s===void 0&&(s=!1),!this.persistence||!this.nn()||this.Oi&&!s)return e;var n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),a=pe({},n,o||{},e||{}),l=this.config.sanitize_properties;return l&&(T.error(Jd),a=l(a,"$set_once")),i&&(this.Oi=!0),Ni(a)?void 0:a}register(e,i){var s;(s=this.persistence)==null||s.register(e,i)}register_once(e,i,s){var r;(r=this.persistence)==null||r.register_once(e,i,s)}register_for_session(e){var i;(i=this.sessionPersistence)==null||i.register(e)}unregister(e){var i;(i=this.persistence)==null||i.unregister(e)}unregister_for_session(e){var i;(i=this.sessionPersistence)==null||i.unregister(e)}an(e,i){this.register({[e]:i})}getFeatureFlag(e,i){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlag(e,i)}getFeatureFlagPayload(e){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagPayload(e)}getFeatureFlagResult(e,i){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlagResult(e,i)}isFeatureEnabled(e,i){var s;return(s=this.featureFlags)==null?void 0:s.isFeatureEnabled(e,i)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,i,s){var r;(r=this.featureFlags)==null||r.updateFlags(e,i,s)}updateEarlyAccessFeatureEnrollment(e,i,s){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,i,s)}getEarlyAccessFeatures(e,i,s){var r;return i===void 0&&(i=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,i,s)}on(e,i){return this.Li.on(e,i)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:fs}),()=>{})}onSessionId(e){var i,s;return(i=(s=this.sessionManager)==null?void 0:s.onSessionId(e))!==null&&i!==void 0?i:()=>{}}getSurveys(e,i){i===void 0&&(i=!1),this.surveys?this.surveys.getSurveys(e,i):e([],{isLoaded:!1,error:fs})}getActiveMatchingSurveys(e,i){i===void 0&&(i=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,i):e([],{isLoaded:!1,error:fs})}renderSurvey(e,i){var s;(s=this.surveys)==null||s.renderSurvey(e,i)}displaySurvey(e,i){var s;i===void 0&&(i=SE),(s=this.surveys)==null||s.displaySurvey(e,i)}cancelPendingSurvey(e){var i;(i=this.surveys)==null||i.cancelPendingSurvey(e)}canRenderSurvey(e){var i,s;return(i=(s=this.surveys)==null?void 0:s.canRenderSurvey(e))!==null&&i!==void 0?i:{visible:!1,disabledReason:fs}}canRenderSurveyAsync(e,i){var s,r;return i===void 0&&(i=!1),(s=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,i))!==null&&s!==void 0?s:Promise.resolve({visible:!1,disabledReason:fs})}un(e){return!e||Mr(e)?(T.critical("Unique user id has not been set in posthog.identify"),!1):e===Cr?(T.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(T.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,i,s){if(!this.__loaded||!this.persistence)return T.uninitializedWarning("posthog.identify");if(et(e)&&(e=e.toString(),T.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.un(e)&&this.sn("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Wr)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(ms)&&(this.unregister(ms),this.register({distinct_id:e}));var n,o=(this.persistence.get_property(rt)||Ai)===Ai;e!==r&&o?(this.persistence.set_property(rt,Ii),this.setPersonPropertiesForFlags({$set:i||{},$set_once:s||{}},!1),this.capture(zo,{distinct_id:e,$anon_distinct_id:r},{$set:i||{},$set_once:s||{}}),this.$i=Wd(e,i,s),(n=this.featureFlags)==null||n.setAnonymousDistinctId(r)):(i||s)&&this.setPersonProperties(i,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(As))}}setPersonProperties(e,i){if((e||i)&&this.sn("posthog.setPersonProperties")){var s=Wd(this.get_distinct_id(),e,i);this.$i!==s?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:i||{}},!0),this.capture("$set",{$set:e||{},$set_once:i||{}}),this.$i=s):T.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,i,s){if(e&&i){var r=this.getGroups(),n=r[e]!==i;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:S({},r,{[e]:i})}),n||s){var o={$group_type:e,$group_key:i};s&&(o.$group_set=s),this.capture(Fd,o)}s&&this.setGroupPropertiesForFlags({[e]:s}),n&&!s&&this.reloadFeatureFlags()}else T.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,i){var s;i===void 0&&(i=!0),(s=this.featureFlags)==null||s.setPersonPropertiesForFlags(e,i)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,i){var s;i===void 0&&(i=!0),this.sn("posthog.setGroupPropertiesForFlags")&&((s=this.featureFlags)==null||s.setGroupPropertiesForFlags(e,i))}resetGroupPropertiesForFlags(e){var i;(i=this.featureFlags)==null||i.resetGroupPropertiesForFlags(e)}reset(e){var i,s,r,n,o,a,l,u;if(T.info("reset"),!this.__loaded)return T.uninitializedWarning("posthog.reset");var c=this.get_property(Wr);if(this.consent.reset(),(i=this.persistence)==null||i.clear(),(s=this.sessionPersistence)==null||s.clear(),(r=this.surveys)==null||r.reset(),(n=this.Yi)==null||n.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.conversations)==null||a.reset(),(l=this.persistence)==null||l.set_property(rt,Ai),(u=this.sessionManager)==null||u.resetSessionId(),this.$i=null,this.config.cookieless_mode===Tt)this.register_once({distinct_id:Cr,$device_id:null},"");else{var h=this.config.get_device_id(Bt());this.register_once({distinct_id:h,$device_id:e?h:c},"")}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,i){var s;this.config.identity_distinct_id=e,this.config.identity_hash=i,this.alias(e),(s=this.conversations)==null||s.ln()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.hn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,i;return(e=(i=this.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:i,sessionStartTimestamp:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+i);if(e!=null&&e.withTimestamp&&s){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!s)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-s)/1e3)-o,0)}return r}alias(e,i){return e===this.get_property(Kh)?(T.critical("Attempting to create alias for existing People user - aborting."),-2):this.sn("posthog.alias")?(P(i)&&(i=this.get_distinct_id()),e!==i?(this.an(ms,e),this.capture("$create_alias",{alias:e,distinct_id:i})):(T.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var i=S({},this.config);if(ve(e)){var s,r,n,o,a,l,u,c,h,f;pe(this.config,Zd(e));var g=this.Hi();(s=this.persistence)==null||s.update_config(this.config,i,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Is(S({},this.config,{persistence:"sessionStorage"}),g);var p=this.Di(this.config.debug);ht(p)&&(this.config.debug=p),ht(this.config.debug)&&(this.config.debug?(De.DEBUG=!0,he.R()&&he.N("ph_debug",!0),T.info("set_config",{config:e,oldConfig:i,newConfig:S({},this.config)})):(De.DEBUG=!1,he.R()&&he.q("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.exceptions)==null||n.onConfigChange(),(o=this.sessionRecording)==null||o.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(l=this.heatmaps)==null||l.startIfEnabled(),(u=this.exceptionObserver)==null||u.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(h=this.surveys)==null||h.loadIfEnabled(),this.cn(),(f=this.externalIntegrations)==null||f.startIfEnabledOrStop()}}_overrideSDKInfo(e,i){De.LIB_NAME=e,De.LIB_VERSION=i}startSessionRecording(e){var i,s,r,n,o,a=e===!0,l={sampling:a||!(e==null||!e.sampling),linked_flag:a||!(e==null||!e.linked_flag),url_trigger:a||!(e==null||!e.url_trigger),event_trigger:a||!(e==null||!e.event_trigger)};Object.values(l).some(Boolean)&&((i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),l.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),l.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),l.url_trigger&&((n=this.sessionRecording)==null||n.overrideTrigger("url")),l.event_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,i){if(this.exceptions){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(S({},r,i))}}addExceptionStep(e,i){var s;(s=this.exceptions)==null||s.addExceptionStep(e,i)}captureLog(e){var i;(i=this.logs)==null||i.captureLog(e)}get logger(){var e,i;return(e=(i=this.logs)==null?void 0:i.logger)!==null&&e!==void 0?e:t.dn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var i,s;return(i=(s=this.toolbar)==null?void 0:s.loadToolbar(e))!==null&&i!==void 0&&i}get_property(e){var i;return(i=this.persistence)==null?void 0:i.props[e]}getSessionProperty(e){var i;return(i=this.sessionPersistence)==null?void 0:i.props[e]}toString(){var e,i=(e=this.config.name)!==null&&e!==void 0?e:xi;return i!==xi&&(i=xi+"."+i),i}_isIdentified(){var e,i;return((e=this.persistence)==null?void 0:e.get_property(rt))===Ii||((i=this.sessionPersistence)==null?void 0:i.get_property(rt))===Ii}nn(){var e,i;return!(this.config.person_profiles==="never"||this.config.person_profiles===Ha&&!this._isIdentified()&&Ni(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[ms])&&((i=this.persistence)==null||(i=i.props)==null||!i[Qr]))}Xi(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.nn()||this.sn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.sn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}sn(e){return this.config.person_profiles==="never"?(T.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.an(Qr,!0),!0)}Hi(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==ii)}cn(){var e,i,s,r,n=this.Hi();return((e=this.persistence)==null?void 0:e._r)!==n&&((s=this.persistence)==null||s.set_disabled(n)),((i=this.sessionPersistence)==null?void 0:i._r)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var i;if(this.config.cookieless_mode!==Tt){if(this.Ri()){var s,r,n,o,a;this.reset(!0),(s=this.sessionManager)==null||s.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new hn(this),this.pageViewManager=new sn(this),this.persistence&&(this.sessionPropsManager=new dn(this,this.sessionManager,this.persistence));var l,u=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=t.__defaultExtensionClasses)==null?void 0:a.sessionRecording;u&&(this.sessionRecording=this.Mi(this.sessionRecording,new u(this)),this.Qi&&((l=this.sessionRecording)==null||l.onRemoteConfig==null||l.onRemoteConfig(this.Qi)))}var c,h;this.consent.optInOut(!0),this.cn(),this.Ji(),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),this.config.cookieless_mode==ii&&((c=this.surveys)==null||c.loadIfEnabled()),(P(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((h=e?.captureEventName)!==null&&h!==void 0?h:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ki()}else T.warn(Xd)}opt_out_capturing(){var e,i,s;this.config.cookieless_mode!==Tt?(this.config.cookieless_mode===ii&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.cn(),this.config.cookieless_mode===ii&&(this.register({distinct_id:Cr,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(s=this.sessionRecording)==null||s.stopRecording(),this.sessionRecording=void 0,this.Ki())):T.warn(Xd)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===Tt||(this.config.cookieless_mode===ii?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.cn()}_is_bot(){return ze?mg(ze,this.config.custom_blocked_useragents):void 0}Ki(){I&&(I.visibilityState==="visible"?this.Fi||(this.Fi=!0,this.capture(Ci,{title:I.title},{send_instantly:!0}),this.Ai&&(I.removeEventListener(Zr,this.Ai),this.Ai=null)):this.Ai||(this.Ai=this.Ki.bind(this),ye(I,Zr,this.Ai)))}debug(e){e===!1?(_?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(_?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Lr(){var e,i,s,r,n,o,a=this.qi||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(T.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(s="advanced_disable_decide",r=T,n=(i="advanced_disable_flags")in(e=a)&&!K(e[i]),o=s in e&&!K(e[s]),n?e[i]:!!o&&(r&&r.warn("Config field '"+s+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),e[s]))}rn(e){if(K(this.config.before_send))return e;var i=Y(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var r of i){if(s=r(s),K(s)){var n="Event '"+e.event+"' was rejected in beforeSend function";return Sb(e.event)?T.warn(n+". This can cause unexpected behavior."):T.info(n),null}s.properties&&!Ni(s.properties)||T.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return s}getPageViewId(){var e;return(e=this.pageViewManager.dr)==null?void 0:e.pageViewId}captureTraceFeedback(e,i){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:i})}captureTraceMetric(e,i,s){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:i,$ai_metric_value:String(s)})}Di(e){var i=ht(e)&&!e,s=he.R()&&he.A("ph_debug")==="true";return!i&&(!!s||e)}};ri.__defaultExtensionClasses={},ri.dn={trace:Ti=()=>{},debug:Ti,info:Ti,warn:Ti,error:Ti,fatal:Ti},(function(t,e){for(var i=0;e.length>i;i++)t.prototype[e[i]]=Yb(t.prototype[e[i]])})(ri,["identify"]);IE=1,TE=3,RE=11;xl=["a","button","form","input","select","textarea","label"];PE=["next","previous","prev",">","<"],rh=[".ph-no-rageclick",".ph-no-capture"],gl=t=>!t||nt(t,"html")||!oi(t),nh=(t,e)=>{if(!_||gl(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[t],r=t;r.parentNode&&!nt(r,"body");)if(wg(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=Ig(r);if(!n)break;if(e||xl.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=_.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(i=!0)}s.push(n),r=n}return{parentIsUsefulElement:i,targetElementList:s}};Rg="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",OE=new RegExp("^(?:"+Rg+")$"),CE=new RegExp(Rg),Pg="\\d{3}-?\\d{2}-?\\d{4}",xE=new RegExp("^("+Pg+")$"),NE=new RegExp("("+Pg+")");pn=class{constructor(e){this.disabled=e===!1;var i=ve(e)?e:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(e,i,s){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>s-r.timestamp){if(this.clicks.push({x:e,y:i,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:i,timestamp:s}];return!1}},ia="$copy_autocapture",sa=ue("[AutoCapture]");ps=ue("[ExceptionAutocapture]");FE=ue("[TracingHeaders]"),Ft=ue("[Web Vitals]"),uh=9e5,ch="disabled",dh="lazy_loading",vs="awaiting_config",Fr="missing_config";ue("[SessionRecording]"),ue("[SessionRecording]");pl="[SessionRecording]",Mt=ue(pl),ME=ue("[Heatmaps]");gh=ue("[Product Tours]"),UE=["$set_once","$set"],Ut=ue("[SiteApps]"),fh="Error while initializing PostHog app with config id ";vl=class{constructor(e){this.vn=new Ds,this.fn=(i,s)=>this.pn(i,s)&&this.gn(i,s)&&this.mn(i,s)&&this.yn(i,s),this.pn=(i,s)=>s==null||!s.event||i?.event===s?.event,this._instance=e,this.bn=new Set,this._n=new Set}init(){var e,i;P((e=this._instance)==null?void 0:e._addCaptureHook)||(i=this._instance)==null||i._addCaptureHook(((s,r)=>{this.on(s,r)}))}register(e){var i,s;if(!P((i=this._instance)==null?void 0:i._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this._n)==null||a.add(o),(l=o.steps)==null||l.forEach((u=>{var c;(c=this.bn)==null||c.add(u?.event||"")}))})),(s=this._instance)!=null&&s.autocapture)){var r,n=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&n.add(l?.selector)}))})),(r=this._instance)==null||r.autocapture.setElementSelectors(n)}}on(e,i){var s;i!=null&&e.length!=0&&(this.bn.has(e)||this.bn.has(i?.event))&&this._n&&((s=this._n)==null?void 0:s.size)>0&&this._n.forEach((r=>{this.wn(i,r)&&this.vn.emit("actionCaptured",r.name)}))}xn(e){this.onAction("actionCaptured",(i=>e(i)))}wn(e,i){if(i?.steps==null)return!1;for(var s of i.steps)if(this.fn(e,s))return!0;return!1}onAction(e,i){return this.vn.on(e,i)}gn(e,i){if(i!=null&&i.url){var s,r=e==null||(s=e.properties)==null?void 0:s.$current_url;if(!r||typeof r!="string"||!Ri(r,i.url,i.url_matching||"contains"))return!1}return!0}mn(e,i){return!!this.Sn(e,i)&&!!this.kn(e,i)&&!!this.Cn(e,i)}Sn(e,i){var s;if(i==null||!i.href)return!0;var r=this.In(e);if(r.length>0)return r.some((a=>Ri(a.href,i.href,i.href_matching||"exact")));var n,o=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!o&&Ri((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",i.href,i.href_matching||"exact")}kn(e,i){var s;if(i==null||!i.text)return!0;var r=this.In(e);if(r.length>0)return r.some((u=>Ri(u.text,i.text,i.text_matching||"exact")||Ri(u.$el_text,i.text,i.text_matching||"exact")));var n,o,a,l=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!l&&(n=(function(u){for(var c,h=[],f=/(?::|")text="(.*?)"/g;!K(c=f.exec(u));)h.includes(c[1])||h.push(c[1]);return h})(l),o=i.text,a=i.text_matching||"exact",n.some((u=>Ri(u,o,a))))}Cn(e,i){var s,r;if(i==null||!i.selector)return!0;var n=e==null||(s=e.properties)==null?void 0:s.$element_selectors;if(n!=null&&n.includes(i.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(i.selector_regex&&o)try{return new RegExp(i.selector_regex).test(o)}catch{return!1}return!1}In(e){var i;return(e==null||(i=e.properties)==null?void 0:i.$elements)==null?[]:e?.properties.$elements}yn(e,i){return i==null||!i.properties||i.properties.length===0||bg(i.properties.reduce(((s,r)=>{var n=Y(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return s[r.key]={values:n,operator:r.operator||"exact"},s}),{}),e?.properties)}},_l=class{constructor(e){this._instance=e,this.Tn=new Map,this.En=new Map,this.Mn=new Map}Pn(e,i){return!!e&&bg(e.propertyFilters,i?.properties)}Rn(e,i){var s=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[i])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=s.get(o.name)||[];a.push(r.id),s.set(o.name,a)}}))})),s}On(e,i,s){var r=(s===cs.Activation?this.Tn:this.En).get(e),n=[];return this.Ln((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[s])==null||(a=a.values)==null?void 0:a.find((u=>u.name===e));return this.Pn(l,i)}))}register(e){var i;P((i=this._instance)==null?void 0:i._addCaptureHook)||(this.Fn(e),this.An(e))}An(e){var i=e.filter((s=>{var r,n;return((r=s.conditions)==null?void 0:r.actions)&&((n=s.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));i.length!==0&&(this.Nn==null&&(this.Nn=new vl(this._instance),this.Nn.init(),this.Nn.xn((s=>{this.onAction(s)}))),i.forEach((s=>{var r,n,o,a,l;s.conditions&&(r=s.conditions)!=null&&r.actions&&(n=s.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=s.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.Nn)==null||a.register(s.conditions.actions.values),(l=s.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((u=>{if(u&&u.name){var c=this.Mn.get(u.name);c&&c.push(s.id),this.Mn.set(u.name,c||[s.id])}})))})))}Fn(e){var i,s=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.events)&&((a=n.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),r=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.cancelEvents)&&((a=n.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));s.length===0&&r.length===0||((i=this._instance)==null||i._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.Tn=this.Rn(e,cs.Activation),this.En=this.Rn(e,cs.Cancellation))}onEvent(e,i){var s,r=this.le(),n=this.$n(),o=this.Dn(),a=((s=this._instance)==null||(s=s.persistence)==null?void 0:s.props[n])||[];if(o===e&&i&&a.length>0){var l,u;r.info("event matched, removing item from activated items",{event:e,eventPayload:i,existingActivatedItems:a});var c=(i==null||(l=i.properties)==null?void 0:l.$survey_id)||(i==null||(u=i.properties)==null?void 0:u.$product_tour_id);if(c){var h=a.indexOf(c);0>h||(a.splice(h,1),this.qn(a))}}else{if(this.En.has(e)){var f=this.On(e,i,cs.Cancellation);f.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:f.map((p=>p.id))}),f.forEach((p=>{var v=a.indexOf(p.id);0>v||a.splice(v,1),this.jn(p.id)})),this.qn(a))}if(this.Tn.has(e)){r.info("event name matched",{event:e,eventPayload:i,items:this.Tn.get(e)});var g=this.On(e,i,cs.Activation);this.qn(a.concat(g.map((p=>p.id))||[]))}}}onAction(e){var i,s=this.$n(),r=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[s])||[];this.Mn.has(e)&&this.qn(r.concat(this.Mn.get(e)||[]))}qn(e){var i=this.le(),s=[...new Set(e)].filter((r=>!this.Hn(r)));i.info("updating activated items",{activatedItems:s}),this.Un(s)}getActivatedIds(){var e,i=this.$n();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[i])||[]}getEventToItemsMap(){return this.Tn}Bn(){return this.Nn}},ml=class extends _l{constructor(e){super(e)}$n(){return Ma}Dn(){return ks.SHOWN}Ln(e){var i;(i=this._instance)==null||i.getSurveys(e)}jn(e){var i;(i=this._instance)==null||i.cancelPendingSurvey(e)}le(){return ee}Un(e){var i;(i=this._instance)==null||(i=i.persistence)==null||i.register({[Ma]:e})}Hn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},na="SDK is not enabled or survey functionality is not yet loaded",ph="Disabled. Not loading surveys.",BE=_!=null&&_.location?on(_.location.hash,"__posthog")||on(location.hash,"state"):null,vh="_postHogToolbarParams",_h=ue("[Toolbar]"),xe=ue("[FeatureFlags]"),Zt=ue("[FeatureFlags]",{debugEnabled:!0}),oa=`" failed. Feature flags didn't load in time.`,mh=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},yh=t=>{var e={};for(var[i,s]of Vr(t||{}))s&&(e[i]=s);return e},wt=ue("[Error tracking]"),bh="Refusing to render web experiment since the viewer is a likely bot",VE={icontains:(t,e)=>!!_&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!_&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!_&&gn(e.href,t),not_regex:(t,e)=>!!_&&!gn(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t},yl=class t{get qt(){return this._instance.config}constructor(e){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(s){s===void 0&&(s=!1),i.getWebExperiments((r=>{t.zn("retrieved web experiments from the server"),i.Vn=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;i.Vn&&(t.zn("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=i.Vn)==null||o.set(n.feature_flag_key,n));var a=i._instance.getFeatureFlag(n.feature_flag_key);ge(a)&&n.variants[a]&&i.Wn(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];t.Zn(u)&&i.Wn(n.name,l,u.transforms)}}))}),s)},this._instance=e,this._instance.onFeatureFlags((s=>{this.onFeatureFlags(s)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())t.zn(bh);else if(!this.qt.disable_web_experiments){if(K(this.Vn))return this.Vn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.zn("applying feature flags",e),e.forEach((i=>{var s;if(this.Vn&&(s=this.Vn)!=null&&s.has(i)){var r,n=this._instance.getFeatureFlag(i),o=(r=this.Vn)==null?void 0:r.get(i);n&&o!=null&&o.variants[n]&&this.Wn(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=t.getWindowLocation();if(e!=null&&e.search){var i=nn(e?.search,"__experiment_id"),s=nn(e?.search,"__experiment_variant");i&&s&&(t.zn("previewing web experiments "+i+" && "+s),this.getWebExperiments((r=>{this.Gn(parseInt(i),s,r)}),!1,!0))}}loadIfEnabled(){this.qt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,i,s){if(this.qt.disable_web_experiments&&!s)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.qt.token),method:"GET",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}Gn(e,i,s){var r=s.filter((n=>n.id===e));r&&r.length>0&&(t.zn("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.Wn(r[0].name,i,r[0].variants[i].transforms))}static Zn(e){return!K(e.conditions)&&t.Qn(e)&&t.Jn(e)}static Qn(e){var i;if(K(e.conditions)||K((i=e.conditions)==null?void 0:i.url))return!0;var s,r,n,o=t.getWindowLocation();return!!o&&((s=e.conditions)==null||!s.url||VE[(r=(n=e.conditions)==null?void 0:n.urlMatchType)!==null&&r!==void 0?r:"icontains"](e.conditions.url,o))}static getWindowLocation(){return _?.location}static Jn(e){var i;if(K(e.conditions)||K((i=e.conditions)==null?void 0:i.utm))return!0;var s=og();if(s.utm_source){var r,n,o,a,l,u,c,h,f=(r=e.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==s.utm_campaign,g=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==s.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==s.utm_medium,v=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==s.utm_term;return f&&p&&v&&g}return!1}static zn(e){for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;i>r;r++)s[r-1]=arguments[r];T.info("[WebExperiments] "+e,s)}Wn(e,i,s){this._is_bot()?t.zn(bh):i!=="control"?s.forEach((r=>{if(r.selector){var n;t.zn("applying transform of variant "+i+" for experiment "+e+" ",r);var o=(n=document)==null?void 0:n.querySelectorAll(r.selector);o?.forEach((a=>{var l=a;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)}))}})):t.zn("Control variants leave the page unmodified.")}_is_bot(){return ze&&this._instance?mg(ze,this.qt.custom_blocked_useragents):void 0}},Je=ue("[Conversations]"),ei="Conversations not available yet.",yn={featureFlags:class{constructor(t){this.Kn=!1,this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=!1,this._instance=t,this.featureFlagEventHandlers=[]}get qt(){return this._instance.config}get ni(){return this._instance.persistence}os(t){return this._instance.get_property(t)}us(){var t,e;return(t=(e=this.ni)==null?void 0:e.wr(this.qt.feature_flag_cache_ttl_ms))!==null&&t!==void 0&&t}ls(){return!!this.us()&&(this.ss||this.Xn||(this.ss=!0,xe.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}hs(){var t,e=(t=this.qt.evaluation_contexts)!==null&&t!==void 0?t:this.qt.evaluation_environments;return!this.qt.evaluation_environments||this.qt.evaluation_contexts||this.ns||(xe.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ns=!0),e!=null&&e.length?e.filter((i=>{var s=i&&typeof i=="string"&&i.trim().length>0;return s||xe.error("Invalid evaluation context found:",i,"Expected non-empty string"),s})):[]}cs(){return this.hs().length>0}initialize(){var t,e,{config:i}=this._instance,s=(t=(e=i.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(s).length){var r,n,o=(r=(n=i.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(s).filter((u=>!!s[u])).reduce(((u,c)=>(u[c]=s[c]||!1,u)),{}),l=Object.keys(o).filter((u=>a[u])).reduce(((u,c)=>(o[c]&&(u[c]=o[c]),u)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,e,i){var s=i!=null&&i.merge?this.getFlagVariants():{},r=i!=null&&i.merge?this.getFlagPayloads():{},n=S({},s,t),o=S({},r,e),a={};for(var[l,u]of Object.entries(n)){var c=typeof u=="string";a[l]={key:l,enabled:!!c||!!u,variant:c?u:void 0,reason:void 0,metadata:P(o?.[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.receivedFeatureFlags({flags:a})}get hasLoadedFlags(){return this.Yn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.os(Da),e=this.os(At),i=this.os(Oi);if(!i&&!e)return t||{};var s=pe({},t||{}),r=[...new Set([...Object.keys(i||{}),...Object.keys(e||{})])];for(var n of r){var o,a,l=s[n],u=e?.[n],c=P(u)?(o=l?.enabled)!==null&&o!==void 0&&o:!!u,h=P(u)?l.variant:typeof u=="string"?u:void 0,f=i?.[n],g=S({},l,{enabled:c,variant:c?h??l?.variant:void 0});c!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),f&&(g.metadata=S({},l?.metadata,{payload:f,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),s[n]=g}return this.Kn||(xe.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:i,finalDetails:s}),this.Kn=!0),s}getFlagVariants(){var t=this.os(Di),e=this.os(At);if(!e)return t||{};for(var i=pe({},t),s=Object.keys(e),r=0;s.length>r;r++)i[s[r]]=e[s[r]];return this.Kn||(xe.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Kn=!0),i}getFlagPayloads(){var t=this.os(La),e=this.os(Oi);if(!e)return t||{};for(var i=pe({},t||{}),s=Object.keys(e),r=0;s.length>r;r++)i[s[r]]=e[s[r]];return this.Kn||(xe.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Kn=!0),i}reloadFeatureFlags(){this.es||this.qt.advanced_disable_feature_flags||this.ds||(this._instance.Li.emit("featureFlagsReloading",!0),this.ds=setTimeout((()=>{this.vs()}),5))}fs(){clearTimeout(this.ds),this.ds=void 0}ensureFlagsLoaded(){this.Yn||this.Xn||this.ds||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.es=t}vs(t){var e;if(this.fs(),!this._instance.Lr())if(this.Xn)this.ts=!0;else{var i=this.qt.token,s=this.os(Wr),r={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:S({},((e=this.ni)==null?void 0:e.get_initial_props())||{},this.os(Ss)||{}),group_properties:this.os(ti),timezone:hg()};Pt(s)||P(s)||(r.$device_id=s),(t!=null&&t.disableFlags||this.qt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.cs()&&(r.evaluation_contexts=this.hs());var n=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.qt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Xn=!0,this._instance._send_request({method:"POST",url:n,data:r,compression:this.qt.disable_compression?void 0:ct.Base64,timeout:this.qt.feature_flag_request_timeout_ms,callback:o=>{var a,l,u,c=!0;if(o.statusCode===200&&(this.ts||(this.$anon_distinct_id=void 0),c=!1),this.Xn=!1,!r.disable_flags||this.ts){this.rs=!c;var h=[];o.error?o.error instanceof Error?h.push(o.error.name==="AbortError"?"timeout":"connection_error"):h.push("unknown_error"):o.statusCode!==200&&h.push("api_error_"+o.statusCode),(a=o.json)!=null&&a.errorsWhileComputingFlags&&h.push("errors_while_computing_flags");var f,g=!((l=o.json)==null||(l=l.quotaLimited)==null||!l.includes("feature_flags"));g&&h.push("quota_limited"),(u=this.ni)==null||u.register({[Ba]:h}),g?xe.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(r.disable_flags||this.receivedFeatureFlags((f=o.json)!==null&&f!==void 0?f:{},c,{partialResponse:!!this.qt.advanced_only_evaluate_survey_feature_flags}),this.ts&&(this.ts=!1,this.vs()))}}})}}getFeatureFlag(t,e){var i;if(e===void 0&&(e={}),!e.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var s=this.getFeatureFlagResult(t,e);return(i=s?.variant)!==null&&i!==void 0?i:s?.enabled}}else xe.warn('getFeatureFlag for key "'+t+oa)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return e?.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var i=this.getFlagVariants(),s=t in i,r=i[t],n=this.getFlagPayloads()[t],o=String(r),a=this.os($a)||void 0,l=this.os(Xr)||void 0,u=this.os(As)||{};if(this.qt.advanced_feature_flags_dedup_per_session){var c,h=this._instance.get_session_id(),f=this.os(Ua);h&&h!==f&&(u={},(c=this.ni)==null||c.register({[As]:u,[Ua]:h}))}if((e.send_event||!("send_event"in e))&&(!(t in u)||!u[t].includes(o))){var g,p,v,m,y,w,R,N,b,x;Y(u[t])?u[t].push(o):u[t]=[o],(g=this.ni)==null||g.register({[As]:u});var C=this.getFeatureFlagDetails(t),O=[...(p=this.os(Ba))!==null&&p!==void 0?p:[]];P(r)&&O.push("flag_missing");var A={$feature_flag:t,$feature_flag_response:r,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:((v=this.qt.bootstrap)==null||(v=v.featureFlags)==null?void 0:v[t])||null,$feature_flag_bootstrapped_payload:((m=this.qt.bootstrap)==null||(m=m.featureFlagPayloads)==null?void 0:m[t])||null,$used_bootstrap_value:!this.rs};P(C==null||(y=C.metadata)==null?void 0:y.version)||(A.$feature_flag_version=C.metadata.version);var $,U=(w=C==null||(R=C.reason)==null?void 0:R.description)!==null&&w!==void 0?w:C==null||(N=C.reason)==null?void 0:N.code;U&&(A.$feature_flag_reason=U),C!=null&&(b=C.metadata)!=null&&b.id&&(A.$feature_flag_id=C.metadata.id),P(C?.original_variant)&&P(C?.original_enabled)||(A.$feature_flag_original_response=P(C.original_variant)?C.original_enabled:C.original_variant),C!=null&&(x=C.metadata)!=null&&x.original_payload&&(A.$feature_flag_original_payload=C==null||($=C.metadata)==null?void 0:$.original_payload),O.length&&(A.$feature_flag_error=O.join(",")),this._instance.capture("$feature_flag_called",A)}if(s){var H=n;if(!P(n))try{H=JSON.parse(n)}catch{}return{key:t,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:H}}}}else xe.warn('getFeatureFlagResult for key "'+t+oa)}getRemoteConfigPayload(t,e){var i=this.qt.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this.cs()&&(s.evaluation_contexts=this.hs()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:s,compression:this.qt.disable_compression?void 0:ct.Base64,timeout:this.qt.feature_flag_request_timeout_ms,callback(r){var n,o=(n=r.json)==null?void 0:n.featureFlagPayloads;e(o?.[t]||void 0)}})}isFeatureEnabled(t,e){if(e===void 0&&(e={}),!e.fresh||this.rs){if(this.Yn||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return P(i)?void 0:!!i}xe.warn('isFeatureEnabled for key "'+t+oa)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,i){if(this.ni){this.Yn=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();(function(o,a,l,u,c,h){l===void 0&&(l={}),u===void 0&&(u={}),c===void 0&&(c={});var f=(O=>{var A=O.flags;return A?(O.featureFlags=Object.fromEntries(Object.keys(A).map(($=>{var U;return[$,(U=A[$].variant)!==null&&U!==void 0?U:A[$].enabled]}))),O.featureFlagPayloads=Object.fromEntries(Object.keys(A).filter(($=>A[$].enabled)).filter(($=>{var U;return(U=A[$].metadata)==null?void 0:U.payload})).map(($=>{var U;return[$,(U=A[$].metadata)==null?void 0:U.payload]})))):xe.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),O})(o),g=f.flags,p=f.featureFlags,v=f.featureFlagPayloads;if(p){var m=o.requestId,y=o.evaluatedAt;if(Y(p)){xe.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var w={};if(p)for(var R=0;p.length>R;R++)w[p[R]]=!0;a&&a.register({[Ur]:p,[Di]:w})}else{var N=p,b=v,x=g;if(h!=null&&h.partialResponse)N=S({},l,N),b=S({},u,b),x=S({},c,x);else if(o.errorsWhileComputingFlags)if(g){var C=new Set(Object.keys(g).filter((O=>{var A;return!((A=g[O])!=null&&A.failed)})));N=S({},l,Object.fromEntries(Object.entries(N).filter((O=>{var[A]=O;return C.has(A)})))),b=S({},u,Object.fromEntries(Object.entries(b||{}).filter((O=>{var[A]=O;return C.has(A)})))),x=S({},c,Object.fromEntries(Object.entries(x||{}).filter((O=>{var[A]=O;return C.has(A)}))))}else N=S({},l,N),b=S({},u,b),x=S({},c,x);a&&a.register(S({[Ur]:Object.keys(yh(N)),[Di]:N||{},[La]:b||{},[Da]:x||{}},m?{[$a]:m}:{},y?{[Xr]:y}:{}))}}})(t,this.ni,s,r,n,i),e||(this.ss=!1),this.ps(e)}}override(t,e){e===void 0&&(e=!1),xe.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.ni)return xe.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.ni.unregister(At),this.ni.unregister(Oi),this.ps(),Zt.info("All overrides cleared");if(Y(t)){var e=mh(t);return this.ni.register({[At]:e}),this.ps(),Zt.info("Flag overrides set",{flags:t})}if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var i,s=t;if(this.Kn=!!((i=s.suppressWarning)!==null&&i!==void 0&&i),"flags"in s){if(s.flags===!1)this.ni.unregister(At),Zt.info("Flag overrides cleared");else if(s.flags){if(Y(s.flags)){var r=mh(s.flags);this.ni.register({[At]:r})}else this.ni.register({[At]:s.flags});Zt.info("Flag overrides set",{flags:s.flags})}}return"payloads"in s&&(s.payloads===!1?(this.ni.unregister(Oi),Zt.info("Payload overrides cleared")):s.payloads&&(this.ni.register({[Oi]:s.payloads}),Zt.info("Payload overrides set",{payloads:s.payloads}))),void this.ps()}if(t&&typeof t=="object")return this.ni.register({[At]:t}),this.ps(),Zt.info("Flag overrides set",{flags:t});xe.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Yn){var{flags:e,flagVariants:i}=this.gs();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,i){var s,r=(this.os(Es)||[]).find((l=>l.flagKey===t)),n={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=S({},this.getFlagVariants(),{[t]:e});(s=this.ni)==null||s.register({[Ur]:Object.keys(yh(a)),[Di]:a}),this.ps()}getEarlyAccessFeatures(t,e,i){e===void 0&&(e=!1);var s=this.os(Es),r=i?"&"+i.map((n=>"stage="+n)).join("&"):"";if(s&&!e)return t(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.qt.token+r),method:"GET",callback:n=>{var o,a;if(n.json){var l=n.json.earlyAccessFeatures;return(o=this.ni)==null||o.unregister(Es),(a=this.ni)==null||a.register({[Es]:l}),t(l)}}})}gs(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((i=>e[i])),flagVariants:Object.keys(e).filter((i=>e[i])).reduce(((i,s)=>(i[s]=e[s],i)),{})}}ps(t){var{flags:e,flagVariants:i}=this.gs();this.featureFlagEventHandlers.forEach((s=>s(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var i=this.os(Ss)||{},s=t?.$set||(t!=null&&t.$set_once?{}:t),r=t?.$set_once,n={};if(r)for(var o in r)({}).hasOwnProperty.call(r,o)&&(o in i||(n[o]=r[o]));this._instance.register({[Ss]:S({},i,n,s)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Ss)}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var i=this.os(ti)||{};Object.keys(i).length!==0&&Object.keys(i).forEach((s=>{i[s]=S({},i[s],t[s]),delete t[s]})),this._instance.register({[ti]:S({},i,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.os(ti)||{};this._instance.register({[ti]:S({},e,{[t]:{}})})}else this._instance.unregister(ti)}reset(){this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.$anon_distinct_id=void 0,this.fs(),this.Kn=!1}}},GE={sessionRecording:class{get qt(){return this._instance.config}get ni(){return this._instance.persistence}get started(){var t;return!((t=this.ys)==null||!t.isStarted)}get status(){var t,e;return this.bs===vs||this.bs===Fr?this.bs:(t=(e=this.ys)==null?void 0:e.status)!==null&&t!==void 0?t:this.bs}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.bs=ch,this._s=void 0,this._instance=t,!this._instance.sessionManager)throw Mt.error("started without valid sessionManager"),new Error(pl+" started without valid sessionManager. This is a bug.");if(this.qt.cookieless_mode===Tt)throw new Error(pl+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get ws(){var t,e=!((t=this._instance.get_property(bs))==null||!t.enabled),i=!this.qt.disable_session_recording,s=this.qt.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&i&&!s}startIfEnabledOrStop(t){var e;if(!this.ws||(e=this.ys)==null||!e.isStarted){var i=!P(Object.assign)&&!P(Array.from);this.ws&&i?(this.xs(t),Mt.info("starting")):(this.bs=ch,this.stopRecording())}}xs(t){var e,i,s;this.ws&&(this.bs!==vs&&this.bs!==Fr&&(this.bs=dh),L!=null&&(e=L.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(i=L.__PosthogExtensions__)!=null&&i.initSessionRecording?this.Ss(t):(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.ks,(r=>{if(r)return Mt.error("could not load recorder",r);this.Ss(t)})))}stopRecording(){var t,e;(t=this._s)==null||t.call(this),this._s=void 0,(e=this.ys)==null||e.stop()}Cs(){var t,e;(t=this._s)==null||t.call(this),this._s=void 0,(e=this.ys)==null||e.discard()}Is(){var t;(t=this.ni)==null||t.unregister(Il)}Ts(t,e){if(K(t))return null;var i,s=et(t)?t:parseFloat(t);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(Mt.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):s}Es(t){if(this.ni){var e,i,s=this.ni,r=()=>{var n,o=t.sessionRecording===!1?void 0:t.sessionRecording,a=this.Ts((n=this.qt.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.Ts(o?.sampleRate,"remote config sampleRate"),u=a??l;K(u)&&this.Is();var c=o?.minimumDurationMilliseconds;s.register({[bs]:S({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:S({capturePerformance:t.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:P(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};r(),(e=this._s)==null||e.call(this),this._s=(i=this._instance.sessionManager)==null?void 0:i.onSessionId(r)}}onRemoteConfig(t){return"sessionRecording"in t?t.sessionRecording===!1?(this.Es(t),void this.Cs()):(this.Es(t),void this.startIfEnabledOrStop()):(this.bs===vs&&(this.bs=Fr,Mt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;e===void 0&&(e="log"),(i=this.ys)!=null&&i.log?this.ys.log(t,e):Mt.warn("log called before recorder was ready")}get ks(){var t,e,i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.get_property(bs);return(i==null||(e=i.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}Ms(){var t,e=this._instance.get_property(bs);if(!e)return!1;var i=(t=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&t!==void 0?t:Date.now();return 36e5>=Date.now()-i}Ss(t){var e,i;if((e=L.__PosthogExtensions__)==null||!e.initSessionRecording)return Mt.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[tg]:!0});if(this.ys||(this.ys=(i=L.__PosthogExtensions__)==null?void 0:i.initSessionRecording(this._instance),this.ys._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ms())return this.bs===Fr||this.bs===vs?void 0:(this.bs=vs,Mt.info("persisted remote config is stale, requesting fresh config before starting"),void new ln(this._instance).load());this.bs=dh,this.ys.start(t)}onRRwebEmit(t){var e;(e=this.ys)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.ys||(e=this.ni)==null||e.register({[Yh]:!0}),(t=this.ys)==null||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.ys||(e=this.ni)==null||e.register({[Wh]:!0}),(t=this.ys)==null||t.overrideSampling()}overrideTrigger(t){var e,i;this.ys||(i=this.ni)==null||i.register({[t==="url"?Xh:Jh]:!0}),(e=this.ys)==null||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.ys)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!((i=this.ys)==null||!i.tryAddCustomEvent(t,e))}}},qE={autocapture:class{constructor(t){this.Ps=!1,this.Rs=null,this.Os=!1,this.instance=t,this.rageclicks=new pn(t.config.rageclick),this.Ls=null}initialize(){this.startIfEnabled()}get qt(){var t,e,i=ve(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=(t=i.url_allowlist)==null?void 0:t.map((s=>new RegExp(s))),i.url_ignorelist=(e=i.url_ignorelist)==null?void 0:e.map((s=>new RegExp(s))),i}Fs(){if(this.isBrowserSupported()){if(_&&I){var t=i=>{i=i||_?.event;try{this.As(i)}catch(s){sa.error("Failed to capture event",s)}};if(ye(I,"submit",t,{capture:!0}),ye(I,"change",t,{capture:!0}),ye(I,"click",t,{capture:!0}),this.qt.capture_copied_text){var e=i=>{i=i||_?.event;try{this.As(i,ia)}catch(s){sa.error("Failed to capture copy/cut event",s)}};ye(I,"copy",e,{capture:!0}),ye(I,"cut",e,{capture:!0})}}}else sa.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ps&&(this.Fs(),this.Ps=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.Os=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ia]:!!t.autocapture_opt_out}),this.Rs=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Ls=t}getElementSelectors(t){var e,i=[];return(e=this.Ls)==null||e.forEach((s=>{var r=I?.querySelectorAll(s);r?.forEach((n=>{t===n&&i.push(s)}))})),i}get isEnabled(){var t,e,i=(t=this.instance.persistence)==null?void 0:t.props[Ia];if(Pt(this.Rs)&&!ht(i)&&!this.instance.Lr())return!1;var s=(e=this.Rs)!==null&&e!==void 0?e:!!i;return!!this.instance.config.autocapture&&!s}As(t,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var i,s=ih(t);kg(s)&&(s=s.parentNode||null),e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(i=this.rageclicks)!=null&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&(function(h,f){if(!_||gl(h))return!1;var g,p,v;if(ht(f)?(g=!!f&&rh,p=void 0):(g=(v=f?.css_selector_ignorelist)!==null&&v!==void 0?v:rh,p=f?.content_ignorelist),g===!1)return!1;var{targetElementList:m}=nh(h,!1);return!(function(y,w){if(y===!1||P(y))return!1;var R;if(y===!0)R=PE;else{if(!Y(y))return!1;if(y.length>10)return T.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;R=y.map((N=>N.toLowerCase()))}return w.some((N=>{var{safeText:b,ariaLabel:x}=N;return R.some((C=>b.includes(C)||x.includes(C)))}))})(p,m.map((y=>{var w;return{safeText:Ls(y).toLowerCase(),ariaLabel:((w=y.getAttribute("aria-label"))==null?void 0:w.toLowerCase().trim())||""}})))&&!sh(m,g)})(s,this.instance.config.rageclick)&&this.As(t,"$rageclick");var r=e===ia;if(s&&(function(h,f,g,p,v){var m,y,w,R;if(g===void 0&&(g=void 0),!_||gl(h)||(m=g)!=null&&m.url_allowlist&&!th(g.url_allowlist)||(y=g)!=null&&y.url_ignorelist&&th(g.url_ignorelist))return!1;if((w=g)!=null&&w.dom_event_allowlist){var N=g.dom_event_allowlist;if(N&&!N.some((A=>f.type===A)))return!1}var{parentIsUsefulElement:b,targetElementList:x}=nh(h,p);if(!(function(A,$){var U=$?.element_allowlist;if(P(U))return!0;var H,G=function(_e){if(U.some((Ee=>_e.tagName.toLowerCase()===Ee)))return{v:!0}};for(var q of A)if(H=G(q))return H.v;return!1})(x,g)||!sh(x,(R=g)==null?void 0:R.css_selector_allowlist))return!1;var C=_.getComputedStyle(h);if(C&&C.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0;var O=h.tagName.toLowerCase();switch(O){case"html":return!1;case"form":return(v||["submit"]).indexOf(f.type)>=0;case"input":case"select":case"textarea":return(v||["change","click"]).indexOf(f.type)>=0;default:return b?(v||["click"]).indexOf(f.type)>=0:(v||["click"]).indexOf(f.type)>=0&&(xl.indexOf(O)>-1||h.getAttribute("contenteditable")==="true")}})(s,t,this.qt,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=$E(s,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qt.element_attribute_ignorelist,elementsChainAsString:this.Os});if(o)return!1;var a=this.getElementSelectors(s);if(a&&a.length>0&&(n.$element_selectors=a),e===ia){var l,u=Ag(_==null||(l=_.getSelection())==null?void 0:l.toString()),c=t.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return It(I?.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.Ns=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(T.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.$s&&this.$s(),this.$s=void 0,T.info("History API monitoring stopped")}monitorHistoryChanges(){var t,e;if(_&&_.history){var i=this;(t=_.history.pushState)!=null&&t.__posthog_wrapped__||lh(_.history,"pushState",(s=>function(r,n,o){s.call(this,r,n,o),i.Ds("pushState")})),(e=_.history.replaceState)!=null&&e.__posthog_wrapped__||lh(_.history,"replaceState",(s=>function(r,n,o){s.call(this,r,n,o),i.Ds("replaceState")})),this.qs()}}Ds(t){try{var e,i=_==null||(e=_.location)==null?void 0:e.pathname;if(!i)return;i!==this.Ns&&this.isEnabled&&this._instance.capture(Ci,{navigation_type:t}),this.Ns=i}catch(s){T.error("Error capturing "+t+" pageview",s)}}qs(){if(!this.$s){var t=()=>{this.Ds("popstate")};ye(_,"popstate",t),this.$s=()=>{_&&_.removeEventListener("popstate",t)}}}},heatmaps:class{get qt(){return this.instance.config}constructor(t){var e;this.js=!1,this.Ps=!1,this.Hs=null,this.instance=t,this.js=!((e=this.instance.persistence)==null||!e.props[Ta]),this.rageclicks=new pn(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return ve(this.qt.capture_heatmaps)&&this.qt.capture_heatmaps.flush_interval_milliseconds&&(t=this.qt.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return K(this.qt.capture_heatmaps)?K(this.qt.enable_heatmaps)?this.js:this.qt.enable_heatmaps:this.qt.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Ps)return;ME.info("starting..."),this.Us(),this.At()}else{var t;clearInterval((t=this.Hs)!==null&&t!==void 0?t:void 0),this.Bs(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ta]:e}),this.js=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.M;return this.M=void 0,t}zs(t){this.Mt(t.originalEvent,"deadclick")}At(){this.Hs&&clearInterval(this.Hs),this.Hs=I?.visibilityState==="visible"?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Us(){_&&I&&(this.Vs=this.Zr.bind(this),ye(_,en,this.Vs),this.Ws=t=>this.Mt(t||_?.event),ye(I,"click",this.Ws,{capture:!0}),this.Zs=t=>this.Gs(t||_?.event),ye(I,"mousemove",this.Zs,{capture:!0}),this.Qs=new tn(this.instance,iE,this.zs.bind(this)),this.Qs.startIfEnabledOrStop(),this.Js=this.At.bind(this),ye(I,Zr,this.Js),this.Ps=!0)}Bs(){var t;_&&I&&(this.Vs&&_.removeEventListener(en,this.Vs),this.Ws&&I.removeEventListener("click",this.Ws,{capture:!0}),this.Zs&&I.removeEventListener("mousemove",this.Zs,{capture:!0}),this.Js&&I.removeEventListener(Zr,this.Js),clearTimeout(this.Ks),(t=this.Qs)==null||t.stop(),this.Ps=!1)}Ys(t,e){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var u=o;u&&oi(u)&&!nt(u,"body");){if(u===l)return!1;if(z(a,_?.getComputedStyle(u).position))return!0;u=Ig(u)}return!1})(ih(t),["fixed","sticky"],r);return{x:t.clientX+(n?0:s),y:t.clientY+(n?0:i),target_fixed:n,type:e}}Mt(t,e){var i;if(e===void 0&&(e="click"),!eh(t.target)&&hh(t)){var s=this.Ys(t,e);(i=this.rageclicks)!=null&&i.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this.Xs(S({},s,{type:"rageclick"})),this.Xs(s)}}Gs(t){!eh(t.target)&&hh(t)&&(clearTimeout(this.Ks),this.Ks=setTimeout((()=>{this.Xs(this.Ys(t,"mousemove"))}),500))}Xs(t){if(_){var e=_.location.href,i=this.qt.custom_personal_data_properties,s=this.qt.mask_personal_data_properties?[...Vi,...i||[]]:[],r=xs(e,s,Ns);this.M=this.M||{},this.M[r]||(this.M[r]=[]),this.M[r].push(t)}}Zr(){this.M&&!Ni(this.M)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:tn,webVitalsAutocapture:class{constructor(t){var e;this.js=!1,this.Ps=!1,this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.eo=()=>{clearTimeout(this.ro),this.M.metrics.length!==0&&(this._instance.capture("$web_vitals",this.M.metrics.reduce(((i,s)=>S({},i,{["$web_vitals_"+s.name+"_event"]:S({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{})),this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=i=>{var s,r=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(P(r))Ft.error("Could not read session ID. Dropping metrics!");else{this.M=this.M||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.io();P(n)||(K(i?.name)||K(i?.value)?Ft.error("Invalid metric received",i):!this.no||this.no>i.value?(this.M.url!==n&&(this.eo(),this.ro=setTimeout(this.eo,this.flushToCaptureTimeoutMs)),P(this.M.url)&&(this.M.url=n),this.M.firstMetricTimestamp=P(this.M.firstMetricTimestamp)?Date.now():this.M.firstMetricTimestamp,i.attribution&&i.attribution.interactionTargetElement&&(i.attribution.interactionTargetElement=void 0),this.M.metrics.push(S({},i,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.M.metrics.length===this.allowedMetrics.length&&this.eo()):Ft.error("Ignoring metric with value >= "+this.no,i))}},this.so=()=>{if(!this.Ps){var i,s,r,n,o=L.__PosthogExtensions__;P(o)||P(o.postHogWebVitalsCallbacks)||({onLCP:i,onCLS:s,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),i&&s&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&i(this.ht.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.ht.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.ht.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.ht.bind(this)),this.Ps=!0):Ft.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.js=!((e=this._instance.persistence)==null||!e.props[Ca]),this.startIfEnabled()}get oo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=ve(this.oo)?(t=this.oo)==null?void 0:t.web_vitals_allowed_metrics:void 0;return K(i)?((e=this._instance.persistence)==null?void 0:e.props[Na])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(ve(this.oo)?this.oo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=ve(this.oo)?this.oo.web_vitals_attribution:void 0;return t!=null&&t}get no(){var t=ve(this.oo)&&et(this.oo.__web_vitals_max_value)?this.oo.__web_vitals_max_value:uh;return t>0&&6e4>=t?uh:t}get isEnabled(){var t=Te?.protocol;if(t!=="http:"&&t!=="https:")return Ft.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=ve(this.oo)?this.oo.web_vitals:ht(this.oo)?this.oo:void 0;return ht(e)?e:this.js}startIfEnabled(){this.isEnabled&&!this.Ps&&(Ft.info("enabled, starting..."),this.lr(this.so))}onRemoteConfig(t){if("capturePerformance"in t){var e=ve(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=ve(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ca]:e}),this._instance.persistence.register({[Na]:i})),this.js=e,this.startIfEnabled()}}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?t():(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(s=>{s?Ft.error("failed to load script",s):t()}))}io(){var t=_?_.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Vi,...e||[]]:[];return xs(t,i,Ns)}Ft.error("Could not determine current URL")}}},jE={exceptionObserver:class{constructor(t){var e,i,s;this.so=()=>{var r;if(_&&this.isEnabled&&(r=L.__PosthogExtensions__)!=null&&r.errorWrappingFunctions){var n=L.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=L.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=L.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ao&&this.qt.capture_unhandled_errors&&(this.ao=n(this.captureException.bind(this))),!this.uo&&this.qt.capture_unhandled_rejections&&(this.uo=o(this.captureException.bind(this))),!this.lo&&this.qt.capture_console_errors&&(this.lo=a(this.captureException.bind(this)))}catch(l){ps.error("failed to start",l),this.ho()}}},this._instance=t,this.co=!((e=this._instance.persistence)==null||!e.props[Ra]),this.do=new da({refillRate:(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,Gt:ps}),this.qt=this.vo(),this.startIfEnabledOrStop()}vo(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return ve(t)?e=S({},e,t):(P(t)?this.co:t)&&(e=S({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.qt.capture_console_errors||this.qt.capture_unhandled_errors||this.qt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ps.info("enabled"),this.ho(),this.lr(this.so)):this.ho()}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&t(),(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return ps.error("failed to load script",s);t()}))}ho(){var t,e,i;(t=this.ao)==null||t.call(this),this.ao=void 0,(e=this.uo)==null||e.call(this),this.uo=void 0,(i=this.lo)==null||i.call(this),this.lo=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.co=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ra]:this.co}),this.qt=this.vo(),this.startIfEnabledOrStop())}onConfigChange(){this.qt=this.vo()}captureException(t){var e,i,s,r=(e=t==null||(i=t.$exception_list)==null||(i=i[0])==null?void 0:i.type)!==null&&e!==void 0?e:"Exception";this.do.consumeRateLimit(r)?ps.info("Skipping exception capture because of client rate limiting.",{exception:r}):(s=this._instance.exceptions)==null||s.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,i;this.fo=[],this.po=new pa([new _a,new wa,new ya,new ma,new Sa,new Ea,new ba,new ka],(function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;r>o;o++)n[o-1]=arguments[o];return function(a,l){l===void 0&&(l=0);for(var u=[],c=a.split(`
6
- `),h=l;c.length>h;h++){var f=c[h];if(1024>=f.length){var g=$d.test(f)?f.replace($d,"$1"):f;if(!g.match(/\S*Error: /)){for(var p of n){var v=p(g,s);if(v){u.push(v);break}}if(u.length>=50)break}}}return(function(m){if(!m.length)return[];var y=Array.from(m);return y.reverse(),y.slice(0,50).map((w=>{return S({},w,{filename:w.filename||(R=y,R[R.length-1]||{}).filename,function:w.function||Bi});var R}))})(u)}})("web:javascript",Bb,qb)),this._instance=t,this.fo=(e=(i=this._instance.persistence)==null?void 0:i.get_property(Pa))!==null&&e!==void 0?e:[],this.mo=Kr(this.yo()),this.bo=new Aa(this.mo)}onConfigChange(){this.mo=Kr(this.yo()),this.bo.setConfig(this.mo)}onRemoteConfig(t){var e,i,s;if("errorTracking"in t){var r=(e=(i=t.errorTracking)==null?void 0:i.suppressionRules)!==null&&e!==void 0?e:[],n=(s=t.errorTracking)==null?void 0:s.captureExtensionExceptions;this.fo=r,this._instance.persistence&&this._instance.persistence.register({[Pa]:this.fo,[Oa]:n})}}get _o(){var t,e=!!this._instance.get_property(Oa),i=this._instance.config.error_tracking.captureExtensionExceptions;return(t=i??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.po.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this.mo.enabled)try{if(!ge(t)||t.trim().length===0)return void wt.warn("Ignoring exception step because message must be a non-empty string");var i=this.wo(e),{sanitizedProperties:s,droppedKeys:r}=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};var o=[];return{sanitizedProperties:Object.keys(n).reduce(((a,l)=>zb.has(l)?(o.push(l),a):(a[l]=n[l],a)),{}),droppedKeys:o}})(i);r.length>0&&wt.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.bo.add(S({[Hr]:t,[zr]:new Date().toISOString()},s))}catch(n){wt.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.xo(e)){if(this.So(e))return this.ko("Exception dropped: matched a suppression rule"),void wt.info("Skipping exception capture because a suppression rule matched");if(!this._o&&this.Co(e))return this.ko("Exception dropped: thrown by a browser extension"),void wt.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Io(e))return this.ko("Exception dropped: thrown by the PostHog SDK"),void wt.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.mo.enabled&&K(t.$exception_steps)?this.To(t):t;try{var s=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",en:!0});return s&&this.bo.clear(),s}catch(r){return wt.error("Failed to capture exception event. Dropping this exception.",r),void this.bo.clear()}}catch(r){return void wt.error("Failed to process exception event. Ignoring this exception.",r)}}To(t){try{var e=this.bo.getAttachable();return e.length===0?t:S({},t,{$exception_steps:e})}catch(i){return wt.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}ko(t){this.mo.enabled&&this.bo.add({[Hr]:t,[zr]:new Date().toISOString()})}wo(t){return ve(t)?S({},t):{}}yo(){var t,e;return(t=(e=this._instance.config.error_tracking)==null?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}So(t){if(t.length===0)return!1;var e=t.reduce(((i,s)=>{var{type:r,value:n}=s;return ge(r)&&r.length>0&&i.$exception_types.push(r),ge(n)&&n.length>0&&i.$exception_values.push(n),i}),{$exception_types:[],$exception_values:[]});return this.fo.some((i=>{var s=i.values.map((r=>{var n,o=yg[r.operator],a=Y(r.value)?r.value:[r.value],l=(n=e[r.key])!==null&&n!==void 0?n:[];return a.length>0&&o(a,l)}));return i.type==="OR"?s.some(Boolean):s.every(Boolean)}))}Co(t){return t.flatMap((e=>{var i,s;return(i=(s=e.stacktrace)==null?void 0:s.frames)!==null&&i!==void 0?i:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}Io(t){if(t.length>0){var e,i,s,r,n=(e=(i=t[0].stacktrace)==null?void 0:i.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(s=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}xo(t){return!K(t)&&Y(t)}}},HE=S({productTours:class{get ni(){return this._instance.persistence}constructor(t){this.Eo=null,this.Mo=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){"productTours"in t&&(this.ni&&this.ni.register({[xa]:!!t.productTours}),this.loadIfEnabled())}loadIfEnabled(){var t,e;this.Eo||(t=this._instance).config.disable_product_tours||(e=t.persistence)==null||!e.get_property(xa)||this.lr((()=>this.Po()))}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.generateProductTours?t():(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"product-tours",(s=>{s?gh.error("Could not load product tours script",s):t()}))}Po(){var t;!this.Eo&&(t=L.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.Eo=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(e===void 0&&(e=!1),!Y(this.Mo)||e){var i=this.ni;if(i){var s=i.props[Br];if(Y(s)&&!e)return this.Mo=s,void t(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:r=>{var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return gh.error(o),void t([],{isLoaded:!1,error:o})}var a=Y(r.json.product_tours)?r.json.product_tours:[];this.Mo=a,i&&i.register({[Br]:a}),t(a,{isLoaded:!0})}})}else t(this.Mo,{isLoaded:!0})}getActiveProductTours(t){K(this.Eo)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Eo.getActiveProductTours(t)}showProductTour(t){var e;(e=this.Eo)==null||e.showTourById(t)}previewTour(t){this.Eo?this.Eo.previewTour(t):this.lr((()=>{var e;this.Po(),(e=this.Eo)==null||e.previewTour(t)}))}dismissProductTour(){var t;(t=this.Eo)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.Eo)==null||t.nextStep()}previousStep(){var t;(t=this.Eo)==null||t.previousStep()}clearCache(){var t;this.Mo=null,(t=this.ni)==null||t.unregister(Br)}resetTour(t){var e;(e=this.Eo)==null||e.resetTour(t)}resetAllTours(){var t;(t=this.Eo)==null||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.Eo)==null||e.cancelPendingTour(t)}}},yn),zE={siteApps:class{constructor(t){this._instance=t,this.Ro=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Oo(t,e){if(e){var i=this.globalsForEvent(e);this.Ro.push(i),this.Ro.length>1e3&&(this.Ro=this.Ro.slice(10))}}get siteAppLoaders(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Oo.bind(this));this.Lo=()=>{t(),this.Ro=[],this.Lo=void 0}}}globalsForEvent(t){var e,i,s,r,n,o,a;if(!t)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var[h,f]of Object.entries(c))l[h]={id:u[h],type:h,properties:f};var{$set_once:g,$set:p}=t;return{event:S({},Sh(t,UE),{properties:S({},t.properties,p?{$set:S({},(e=(i=t.properties)==null?void 0:i.$set)!==null&&e!==void 0?e:{},p)}:{},g?{$set_once:S({},(s=(r=t.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},g)}:{}),elements_chain:(n=(o=t.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=t.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var o;!e.errored&&this.Ro.length&&(Ut.info("Processing "+this.Ro.length+" events for site app with id "+t.id),this.Ro.forEach((a=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every((a=>a.processedBuffer||a.errored))&&((o=this.Lo)==null||o.call(this))},s=!1,r=o=>{e.errored=!o,e.loaded=!0,Ut.info("Site app with id "+t.id+" "+(o?"loaded":"errored")),s&&i()};try{var{processEvent:n}=t.init({posthog:this._instance,callback(o){r(o)}});n&&(e.processEvent=n),s=!0}catch(o){Ut.error(fh+t.id,o),r(!1)}if(s&&e.loaded)try{i()}catch(o){Ut.error("Error while processing buffered events PostHog app with config id "+t.id,o),e.errored=!0}}Fo(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Ao(t){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(t);for(var i of Object.values(this.apps))try{i.processEvent==null||i.processEvent(e)}catch(s){Ut.error("Error while processing event "+t.event+" for site app "+i.id,s)}}}onRemoteConfig(t){var e,i,s,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.Fo(),void this._instance.on("eventCaptured",(l=>this.Ao(l)))):void Ut.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((i=this.Lo)==null||i.call(this),(s=t.siteApps)!=null&&s.length)if(this.isEnabled){var n=function(l){var u;L["__$$ph_site_app_"+l]=r._instance,(u=L.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(r._instance,a,(c=>{if(c)return Ut.error(fh+l,c)}))};for(var{id:o,url:a}of t.siteApps)n(o)}else Ut.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},KE={tracingHeaders:class{constructor(t){this.No=void 0,this.$o=void 0,this.so=()=>{var e,i,s=this.Do()||[];P(this.No)&&((e=L.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(s,this._instance.get_distinct_id(),this._instance.sessionManager)),P(this.$o)&&((i=L.__PosthogExtensions__)==null||(i=i.tracingHeadersPatchFns)==null||i._patchFetch(s,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=t}initialize(){this.startIfEnabledOrStop()}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&t(),(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return FE.error("failed to load script",s);t()}))}Do(){var t;return(t=this._instance.config.addTracingHeaders)!==null&&t!==void 0?t:this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var t,e;this.Do()?this.lr(this.so):((t=this.No)==null||t.call(this),(e=this.$o)==null||e.call(this),this.No=void 0,this.$o=void 0)}}},WE=S({surveys:class{get qt(){return this._instance.config}constructor(t){this.qo=void 0,this._surveyManager=null,this.jo=!1,this.Ho=[],this.Uo=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.qt.disable_surveys){var e=t.surveys;if(K(e))return ee.warn("Flags not loaded yet. Not loading surveys.");var i=Y(e);this.qo=i?e.length>0:e,ee.info("flags response received, isSurveysEnabled: "+this.qo),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],e=0;e<localStorage.length;e++){var i=localStorage.key(e);(i!=null&&i.startsWith(ul)||i!=null&&i.startsWith("inProgressSurvey_"))&&t.push(i)}t.forEach((s=>localStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.jo)ee.info("Already initializing surveys, skipping...");else if(this.qt.disable_surveys)ee.info(ph);else if(this.qt.cookieless_mode&&this._instance.consent.isOptedOut())ee.info("Not loading surveys in cookieless mode without consent.");else{var t=L?.__PosthogExtensions__;if(t){if(!P(this.qo)||this.qt.advanced_enable_surveys){var e=this.qo||this.qt.advanced_enable_surveys;this.jo=!0;try{var i=t.generateSurveys;if(i)return void this.Bo(i,e);var s=t.loadExternalDependency;if(!s)return void this.zo(Tl);s(this._instance,"surveys",(r=>{r||!t.generateSurveys?this.zo("Could not load surveys script",r):this.Bo(t.generateSurveys,e)}))}catch(r){throw this.zo("Error initializing surveys",r),r}finally{this.jo=!1}}}else ee.error("PostHog Extensions not found.")}}Bo(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new ml(this._instance),ee.info("Surveys loaded successfully"),this.Vo({isLoaded:!0})}zo(t,e){ee.error(t,e),this.Vo({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ho.push(t),this._surveyManager&&this.Vo({isLoaded:!0}),()=>{this.Ho=this.Ho.filter((e=>e!==t))}}getSurveys(t,e){if(e===void 0&&(e=!1),this.qt.disable_surveys)return ee.info(ph),t([]);var i,s=this._instance.get_property(Fa);if(s&&!e)return t(s,{isLoaded:!0});typeof Promise<"u"&&this.Uo?this.Uo.then((r=>{var{surveys:n,context:o}=r;return t(n,o)})):(typeof Promise<"u"&&(this.Uo=new Promise((r=>{i=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.qt.token),method:"GET",timeout:this.qt.surveys_request_timeout_ms,callback:r=>{var n;this.Uo=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;ee.error(a);var l={isLoaded:!1,error:a};return t([],l),void(i==null||i({surveys:[],context:l}))}var u,c=r.json.surveys||[],h=c.filter((g=>(function(p){return!(!p.start_date||p.end_date)})(g)&&((function(p){var v;return!((v=p.conditions)==null||(v=v.events)==null||(v=v.values)==null||!v.length)})(g)||(function(p){var v;return!((v=p.conditions)==null||(v=v.actions)==null||(v=v.values)==null||!v.length)})(g))));h.length>0&&((u=this._surveyEventReceiver)==null||u.register(h)),(n=this._instance.persistence)==null||n.register({[Fa]:c});var f={isLoaded:!0};t(c,f),i?.({surveys:c,context:f})}}))}Vo(t){for(var e of this.Ho)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(i){ee.error("Error in survey callback",i)}}getActiveMatchingSurveys(t,e){if(e===void 0&&(e=!1),!K(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ee.warn("init was not called")}Wo(t){var e=null;return this.getSurveys((i=>{var s;e=(s=i.find((r=>r.id===t)))!==null&&s!==void 0?s:null})),e}Zo(t){if(K(this._surveyManager))return{eligible:!1,reason:na};var e=typeof t=="string"?this.Wo(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(K(this._surveyManager))return ee.warn("init was not called"),{visible:!1,disabledReason:na};var e=this.Zo(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return K(this._surveyManager)?(ee.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:na})):new Promise((i=>{this.getSurveys((s=>{var r,n=(r=s.find((a=>a.id===t)))!==null&&r!==void 0?r:null;if(n){var o=this.Zo(n);i({visible:o.eligible,disabledReason:o.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var s;if(K(this._surveyManager))ee.warn("init was not called");else{var r=typeof t=="string"?this.Wo(t):t;if(r!=null&&r.id)if(EE.includes(r.type)){var n=I?.querySelector(e);if(n)return(s=r.appearance)!=null&&s.surveyPopupDelaySeconds?(ee.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;ee.info("Rendering survey "+r.id+" with delay of "+((o=r.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(r,n,i),ee.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,i);ee.warn("Survey element not found")}else ee.warn("Surveys of type "+r.type+" cannot be rendered in the app");else ee.warn("Survey not found")}}displaySurvey(t,e){var i;if(K(this._surveyManager))ee.warn("init was not called");else{var s=this.Wo(t);if(s){var r=s;if((i=s.appearance)!=null&&i.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=S({},s,{appearance:S({},s.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Ja.Popover&&e.initialResponses&&ee.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(s);if(!n.visible)return void ee.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==Ja.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else ee.warn("Survey not found")}}cancelPendingSurvey(t){K(this._surveyManager)?ee.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload()}}},yn),YE={toolbar:class{constructor(t){this.instance=t}Go(t){L.ph_toolbar_state=t}Qo(){var t;return(t=L.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(t===void 0&&(t=void 0),e===void 0&&(e=void 0),i===void 0&&(i=void 0),ig(this.instance.config)||!_||!I)return!1;t=t??_.location,i=i??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var s,r=BE||on(t.hash,"__posthog")||on(t.hash,"state"),n=r?Md((()=>JSON.parse(atob(decodeURIComponent(r)))))||Md((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?t.hash=n.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((s=JSON.parse(e.getItem(vh)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch{return!1}}Jo(t){var e=L.ph_load_toolbar||L.ph_load_editor;!K(e)&&It(e)?e(t,this.instance):_h.warn("No toolbar load function found")}loadToolbar(t){var e=!(I==null||!I.getElementById(Qh));if(!_||e)return!1;var i=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=S({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(_.localStorage.setItem(vh,JSON.stringify(S({},s,{source:void 0}))),this.Qo()===2)this.Jo(s);else if(this.Qo()===0){var r;this.Go(1),(r=L.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return _h.error("[Toolbar] Failed to load",n),void this.Go(0);this.Go(2),this.Jo(s)})),ye(_,"turbolinks:load",(()=>{this.Go(0),this.loadToolbar(s)}))}return!0}Ko(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return t===void 0&&(t=void 0),e===void 0&&(e=void 0),i===void 0&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},XE=S({experiments:yl},yn),JE={conversations:class{constructor(t){this.Yo=void 0,this._conversationsManager=null,this.Xo=!1,this.ea=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;K(e)||(ht(e)?this.Yo=e:(this.Yo=e.enabled,this.ea=e),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.Yo=void 0,this.ea=null}loadIfEnabled(){if(!(this._conversationsManager||this.Xo||this._instance.config.disable_conversations||ig(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=L?.__PosthogExtensions__;if(t&&!P(this.Yo)&&this.Yo)if(this.ea&&this.ea.token){this.Xo=!0;try{var e=t.initConversations;if(e)return this.ta(e),void(this.Xo=!1);var i=t.loadExternalDependency;if(!i)return void this.ra(Tl);i(this._instance,"conversations",(s=>{s||!t.initConversations?this.ra("Could not load conversations script",s):this.ta(t.initConversations),this.Xo=!1}))}catch(s){this.ra("Error initializing conversations",s),this.Xo=!1}}else Je.error("Conversations enabled but missing token in remote config.")}}ta(t){if(this.ea)try{this._conversationsManager=t(this.ea,this._instance),Je.info("Conversations loaded successfully")}catch(e){this.ra("Error completing conversations initialization",e)}else Je.error("Cannot complete initialization: remote config is null")}ra(t,e){Je.error(t,e),this._conversationsManager=null,this.Xo=!1}show(){this._conversationsManager?this._conversationsManager.show():Je.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Yo===!0&&!Pt(this._conversationsManager)}isVisible(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,i){var s=this;return Qe((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,e,i):(Je.warn(ei),null)}))()}getMessages(t,e){var i=this;return Qe((function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Je.warn(ei),null)}))()}markAsRead(t){var e=this;return Qe((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Je.warn(ei),null)}))()}getTickets(t){var e=this;return Qe((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Je.warn(ei),null)}))()}requestRestoreLink(t){var e=this;return Qe((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Je.warn(ei),null)}))()}restoreFromToken(t){var e=this;return Qe((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Je.warn(ei),null)}))()}restoreFromUrlToken(){var t=this;return Qe((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Je.warn(ei),null)}))()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}ln(){var t;(t=this._conversationsManager)==null||t.setIdentity()}hn(){var t;(t=this._conversationsManager)==null||t.clearIdentity()}}},QE={logs:class{constructor(t){var e;this.ia=!1,this.na=!1,this.Gt=ue("[logs]"),this.sa=[],this.oa=0,this.aa=0,this.ua=!1,this._instance=t,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.ia=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=(e=t.logs)==null?void 0:e.captureConsoleLogs;!K(i)&&i&&(this.ia=!0,this.loadIfEnabled())}reset(){this.sa=[],this.qr&&(clearTimeout(this.qr),this.qr=void 0),this.oa=0,this.aa=0,this.ua=!1}loadIfEnabled(){if(this.ia&&!this.na){var t=L?.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(i=>{var s;i||(s=t.logs)==null||!s.initializeLogs?this.Gt.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.na=!0)})):this.Gt.error(Tl)}else this.Gt.error("PostHog Extensions not found.")}}captureLog(t){var e,i,s,r,n,o;if(this._instance.is_capturing())if(t&&t.body){var a=(e=(i=this._instance.config.logs)==null?void 0:i.flushIntervalMs)!==null&&e!==void 0?e:3e3,l=(s=(r=this._instance.config.logs)==null?void 0:r.maxLogsPerInterval)!==null&&s!==void 0?s:1e3,u=Date.now();if(a>u-this.aa||(this.aa=u,this.oa=0,this.ua=!1),l>this.oa){this.oa++;var c=(function(h,f){var g=h.level||"info",{text:p,number:v}=Gh[g]||Lb,m=String(Date.now())+"000000",y={};f.distinctId&&(y.posthogDistinctId=f.distinctId),f.sessionId&&(y.sessionId=f.sessionId),f.currentUrl&&(y["url.full"]=f.currentUrl),f.screenName&&(y["screen.name"]=f.screenName),f.appState&&(y["app.state"]=f.appState),f.activeFeatureFlags&&f.activeFeatureFlags.length>0&&(y.feature_flags=f.activeFeatureFlags);var w=S({},y,h.attributes||{}),R={timeUnixNano:m,observedTimeUnixNano:m,severityNumber:v,severityText:p,body:{stringValue:h.body},attributes:Ld(w)};return h.trace_id&&(R.traceId=h.trace_id),h.span_id&&(R.spanId=h.span_id),P(h.trace_flags)||(R.flags=h.trace_flags),R})(t,this.la());this.sa.push({record:c}),((n=(o=this._instance.config.logs)==null?void 0:o.maxBufferSize)!==null&&n!==void 0?n:100)>this.sa.length?this.ha():this.flushLogs()}else this.ua||(this.Gt.warn("captureLog dropping logs: exceeded "+l+" logs per "+a+"ms"),this.ua=!0)}else this.Gt.warn("captureLog requires a body")}get logger(){return this.ca||(this.ca={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.ca}flushLogs(t){if(this.qr&&(clearTimeout(this.qr),this.qr=void 0),this.sa.length!==0){var e=this.sa;this.sa=[];var i=this._instance.config.logs,s=S({"service.name":i?.serviceName||"unknown_service"},i?.environment&&{"deployment.environment":i.environment},i?.serviceVersion&&{"service.version":i.serviceVersion},i?.resourceAttributes),r=(function(o,a,l,u){return{resourceLogs:[{resource:{attributes:Ld(a)},scopeLogs:[{scope:{name:l,version:u},logRecords:o}]}]}})(e.map((o=>o.record)),s,De.LIB_NAME,De.LIB_VERSION),n=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance.Bi({method:"POST",url:n,data:r,compression:"best-available",batchKey:"logs",transport:t})}}ha(){var t,e;this.qr||(this.qr=setTimeout((()=>{this.qr=void 0,this.flushLogs()}),(t=(e=this._instance.config.logs)==null?void 0:e.flushIntervalMs)!==null&&t!==void 0?t:3e3))}la(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i}if(L!=null&&(t=L.location)!=null&&t.href&&(e.currentUrl=L.location.href),this._instance.featureFlags){var s=this._instance.featureFlags.getFlags();s&&s.length>0&&(e.activeFeatureFlags=s)}return e}}},ZE=S({},yn,GE,qE,jE,HE,zE,WE,KE,YE,XE,JE,QE);ri.__defaultExtensionClasses=S({},ZE);qe=(Eh=Rs[xi]=new ri,(function(){function t(){t.done||(t.done=!0,Sg=!1,oe(Rs,(function(e){e._dom_loaded()})))}I!=null&&I.addEventListener?I.readyState==="complete"?t():ye(I,"DOMContentLoaded",t,{capture:!1}):_&&T.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),Eh)});var xg={};Sn(xg,{Posthog:()=>Nl});var ai,Nl,Ng=Fe(()=>{"use strict";Cg();Zi();ts();ai=class ai{constructor(e,i=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=Dt("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let i=`ph_${e}_posthog`,s=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==i);if(s.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;s.forEach(a=>{[o,r,""].forEach(u=>{let c=u?`; Domain=${u}`:"";document.cookie=`${a}=; path=/${c}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(u=>u.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:i,config:s={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.cleanupStalePosthogCookies(e);let r=i||Ec();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:bc,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,maskAllInputs:!0,...s.session_recording},before_send:o=>{if(typeof window>"u")return null;let a=window.location.hostname;if(a==="localhost"||a==="127.0.0.1")return o;let l=Sc.some(u=>a.endsWith(`.${u}`)||a===u);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...s};qe.init(e,n),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,i={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let s=this.has_identified&&qe.get_distinct_id()===e;e&&!s?(this.log("identifyEvent | identifying user",{user_id:e,traits:i}),qe.identify(e,{...i,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),qe.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:i,language:s,country_of_residence:r})=>{if(!(!this.has_initialized||!e))try{let n=qe.get_property("$stored_person_properties")??{},o={};n.client_id||(o.client_id=e),i&&n.is_internal===void 0&&(o.is_internal=ur(i)),s&&!n.language&&(o.language=s),r&&!n.country_of_residence&&(o.country_of_residence=r),Object.keys(o).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:o}),qe.setPersonProperties(o)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e,country_of_residence:r})}catch(n){console.error("Posthog: Failed to backfill person properties",n)}};this.capture=(e,i)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:i}),qe.capture(e,i)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let i=qe.isFeatureEnabled(e);return this.log("isFeatureEnabled",{key:e,result:i}),i}catch(i){console.error("Posthog: Failed to check feature flag",i);return}};this.getFeatureFlag=e=>{if(this.has_initialized)try{let i=qe.getFeatureFlag(e);return this.log("getFeatureFlag",{key:e,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag",i);return}};this.getFeatureFlagPayload=e=>{if(this.has_initialized)try{let i=qe.getFeatureFlagResult(e)?.payload;return this.log("getFeatureFlagPayload",{key:e,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag payload",i);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let e=qe.featureFlags?.getFlagVariants()??{};return this.log("getAllFlags",{result:e}),e}catch(e){return console.error("Posthog: Failed to get all feature flags",e),{}}};this.onFeatureFlags=e=>{if(!this.has_initialized)return()=>{};try{this.log("onFeatureFlags | subscribing to feature flag changes");let i=qe.onFeatureFlags(e);return typeof i=="function"?i:()=>{}}catch(i){return console.error("Posthog: Failed to subscribe to feature flags",i),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),qe.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=i,this.init()}};ai.getPosthogInstance=(e,i=!1)=>(ai._instance||(ai._instance=new ai(e,i)),ai._instance);Nl=ai});var t0={};Sn(t0,{Analytics:()=>Dg});yo();Zi();ts();var _y=4320*60*60,Wt=class Wt{constructor(e,i,s=!1){this.analytics=new pi;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=Dt("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let i=window.location.hostname,n=["webflow.io"].some(u=>i.endsWith(u))?i:i.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let u=new Uint8Array(16);crypto.getRandomValues(u),u[6]=u[6]&15|64,u[8]=u[8]&63|128;let c=Array.from(u,h=>h.toString(16).padStart(2,"0")).join("");o=`${c.slice(0,8)}-${c.slice(8,12)}-${c.slice(12,16)}-${c.slice(16,20)}-${c.slice(20)}`}else throw new Error("Crypto API not available for secure random UUID generation");let l=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${this.rudderstack_anonymous_cookie_key}=${o}; path=/; Domain=${n}; max-age=${_y}; SameSite=Lax${l}`}catch(i){console.warn("RudderStack: Failed to set anonymous ID cookie",i)}};this.getUserId=()=>this.analytics.getUserId();this.init=e=>{if(!e){console.warn("RudderStack: Initialization skipped - no key provided");return}this.log("init | loading SDK",{dataplane:bo});try{this.setCookieIfNotExists(),this.analytics.load(e,bo,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,storage:{type:"localStorage"},lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.log("init | SDK loaded successfully",{userId:this.getUserId(),anonymousId:this.getAnonymousId()}),this.onLoadedCallback?.()}})}catch(i){console.error("RudderStack: Failed to initialize",i)}};this.identifyEvent=(e,i)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let s=this.getUserId();if(!s||s!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:i}),this.analytics.identify(e,i||{}),this.has_identified=!0}catch(r){console.error("RudderStack: Failed to identify user",r)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,i="Deriv App",s,r)=>{if(!(!this.has_initialized||e===this.current_page))try{let n={...s&&{user_id:s},...r};this.log("pageView | tracking page view",{platform:i,current_page:e,properties:n}),this.analytics.page(i,e,n),this.current_page=e}catch(n){console.error("RudderStack: Failed to track page view",n)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting RudderStack session"),this.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,i)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:i}),this.analytics.track(e,i)}catch(s){console.warn("RudderStack: Failed to track event",s)}};this.onLoadedCallback=i,this.debug=s,this.init(e)}};Wt.getRudderStackInstance=(e,i,s=!1)=>(Wt._instance||(Wt._instance=new Wt(e,i,s)),Wt._instance);var cr=Wt;var dr="cached_analytics_events",hr="cached_analytics_page_views",Pc=(t,e)=>{try{let i=localStorage.getItem(dr),s=i?JSON.parse(i):[];s.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(dr,JSON.stringify(s))}catch(i){console.warn("Analytics: Failed to cache event",i)}},Oc=(t,e)=>{try{let i=localStorage.getItem(hr),s=i?JSON.parse(i):[];s.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(hr,JSON.stringify(s))}catch(i){console.warn("Analytics: Failed to cache page view",i)}},Cc=()=>{try{let t=localStorage.getItem(dr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached events",t)}return[]},xc=()=>{try{let t=localStorage.getItem(hr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached pages",t)}return[]},Nc=()=>{try{localStorage.removeItem(dr)}catch(t){console.warn("Analytics: Failed to clear cached events",t)}},Dc=()=>{try{localStorage.removeItem(hr)}catch(t){console.warn("Analytics: Failed to clear cached page views",t)}};ts();function e0(t){let e=t?.debug??!1,i=Dt("",()=>e),s,r,n,o={},a={},l=[],u=[],c=!1,h=()=>{if(!c&&r?.has_initialized){c=!0;try{let k=Cc();k.length>0&&(i(`processStorageCache | replaying ${k.length} cached event(s)`,k),k.forEach(F=>{let B=Kt(F.properties);r?.track(F.name,B)}),Nc());let M=xc();M.length>0&&(i(`processStorageCache | replaying ${M.length} cached page view(s)`,M),M.forEach(F=>{r?.pageView(F.name,"Deriv App",N(),F.properties)}),Dc())}catch(k){console.warn("Analytics: Failed to process storage cache",k)}}},f=()=>{i("onSdkLoaded | RudderStack SDK loaded"),h(),u.length>0&&i(`onSdkLoaded | flushing ${u.length} pending identify call(s)`),u.forEach(({userId:k,traits:M})=>{k&&r?.identifyEvent(k,M)}),u=[]},g=async({growthbookKey:k,growthbookDecryptionKey:M,rudderstackKey:F,growthbookOptions:B,posthogOptions:Z,debug:ce})=>{var se,me;ce!==void 0&&(e=ce),i("initialise | starting analytics initialization",{rudderstack:!!F,growthbook:!!k,posthog:!!Z});try{let Pe=B?.attributes?.country||(k?await Ic():void 0);if(F&&(i("initialise | initializing RudderStack"),r=cr.getRudderStackInstance(F,f,e)),B?.attributes&&Object.keys(B.attributes).length>0){let j=B.attributes,ft=r?.getAnonymousId();o={...o,country:Pe,...j.user_language&&{user_language:j.user_language},...j.account_type&&{account_type:j.account_type},...j.app_id&&{app_id:j.app_id},...j.residence_country&&{residence_country:j.residence_country},...j.device_type&&{device_type:j.device_type},...j.url&&{url:j.url},...j.email_hash&&{email_hash:j.email_hash},...j.network_type&&{network_type:j.network_type},...j.network_rtt&&{network_rtt:j.network_rtt},...j.network_downlink&&{network_downlink:j.network_downlink},...j.account_currency&&{account_currency:j.account_currency},...j.account_mode&&{account_mode:j.account_mode},loggedIn:!!j.loggedIn,...j.user_id&&!es(j.user_id)&&{user_id:j.user_id},...ft&&{anonymous_id:ft}}}B??(B={}),B.attributes??(B.attributes={});let ke=r?.getAnonymousId();if((se=B.attributes).id??(se.id=ke),(me=B.attributes).country??(me.country=Pe),k){i("initialise | initializing GrowthBook");let{Growthbook:j}=await Promise.resolve().then(()=>(Id(),Ad));s=j.getGrowthBookInstance(k,M,B,e),i("initialise | GrowthBook initialized");let ft=setInterval(()=>{Object.keys(a).length>0?clearInterval(ft):a=m("tracking-buttons-config",{})},1e3)}if(Z){i("initialise | initializing PostHog");let{Posthog:j}=await Promise.resolve().then(()=>(Ng(),xg));n=j.getPosthogInstance(Z,e),i("initialise | PostHog initialized")}i("initialise | analytics initialization complete")}catch(Pe){console.warn("Analytics: Failed to initialize",Pe)}},p=k=>{i("setAttributes | received attributes",k);let{user_id:M,...F}=k,B=M??N();if(s){let Z={...F};M&&!es(M)&&(Z.user_id=M),B&&(Z.id=B,Z.user_id=B),i("setAttributes | called GrowthBook setAttributes",Z),s.setAttributes(Z)}o={...o,...Object.fromEntries(Object.entries(F).filter(([,Z])=>Z!==void 0)),...M!==void 0&&!es(M)&&{user_id:M}},i("setAttributes | updated core_data",o)},v=k=>s?.getFeatureState(k)?.experimentResult?.name,m=(k,M)=>s?.getFeatureValue(k,M),y=async()=>await s?.getStatus(),w=k=>s?.isOn(k),R=k=>s?.setUrl(k),N=()=>{let k=r?.getUserId()||"";return k&&!es(k)?k:""},Se={initialise:g,setAttributes:p,identifyEvent:(k,M)=>{let F=k||N();if(!F){i("identifyEvent | skipped \u2014 no user_id available");return}i("identifyEvent | called",{user_id:F,traits:M});let B=me=>{if(!me)return me;let{email:Pe,...ke}=me;return{...ke,...Pe&&{is_internal:ur(Pe)}}},Z=M?.rudderstack!==void 0||M?.posthog!==void 0,ce,se;if(Z){let{rudderstack:me,posthog:Pe,...ke}=M;ce=B({...ke,...me}),se=B({...ke,...Pe})}else ce=B(M),se=B(M);r&&(r.has_initialized?(i("identifyEvent | calling RudderStack identify",{user_id:F,traits:ce}),r.identifyEvent(F,ce)):u.some(me=>me.userId===F)||(i("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:F}),u.push({userId:F,traits:ce}))),n?.has_initialized&&(i("identifyEvent | calling PostHog identify",{user_id:F,traits:se}),n.identifyEvent(F,se))},backfillPersonProperties:({user_id:k,email:M,language:F,country_of_residence:B})=>{i("backfillPersonProperties | called",{user_id:k}),n?.has_initialized?(i("backfillPersonProperties | backfilling person properties in PostHog",{user_id:k}),n.backfillPersonProperties({user_id:k,email:M,language:F,country_of_residence:B})):i("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:v,getFeatureValue:m,getGrowthbookStatus:y,isFeatureOn:w,setUrl:R,getId:N,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(k,M)=>{let F=N();i("trackEvent | called",{event:k,analytics_data:M,userId:F,core_data:o});let B={...o,...M,...F&&!o.user_id&&{user_id:F}};if(i("trackEvent | built payload",{event:k,final_payload:B}),!(!(k in a)||a[k])){i("trackEvent | skipped \u2014 event disabled by tracking_config",{event:k});return}let ce=r?.has_initialized;if(!navigator.onLine||!ce)ce?(i("trackEvent | offline \u2014 caching event to memory",{event:k}),l.push({event:k,payload:B})):(i("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:k}),Pc(k,B));else{l.length>0&&(i(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(me=>{let Pe=Kt(me.payload);r?.track(me.event,Pe)}),l=[]);let se=Kt(B);i("trackEvent | sending event to RudderStack",{event:k,payload:se}),r?.track(k,se)}if(n?.has_initialized){let se=Kt(Rc(B));i("trackEvent | sending event to PostHog",{event:k,payload:se}),n.capture(k,se)}},getInstances:()=>({ab:s,tracking:r,posthog:n}),pageView:(k,M="Deriv App",F)=>{let B=N();i("pageView | called",{current_page:k,platform:M,properties:F,userId:B}),r?.has_initialized?(i("pageView | sending page view to RudderStack",{current_page:k,platform:M}),r.pageView(k,M,B,F)):(i("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:k}),Oc(k,{platform:M,...F}))},reset:()=>{i("reset | resetting all providers"),r?.has_initialized&&(i("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(i("reset | resetting PostHog"),n.reset())},isPosthogFeatureEnabled:k=>n?.isFeatureEnabled(k),getPosthogFeatureFlag:k=>n?.getFeatureFlag(k),getPosthogFeatureFlagPayload:k=>n?.getFeatureFlagPayload(k),getPosthogAllFlags:()=>n?.getAllFlags()??{},onPosthogFeatureFlags:k=>n?.onFeatureFlags(k)??(()=>{}),reloadPosthogFeatureFlags:()=>n?.reloadFeatureFlags()};return typeof window<"u"&&(window.AnalyticsInstance=Se),Se}var Dg=e0();return Hg(t0);})();
2
+ "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(`
3
+ `);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}
4
+ ${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"})})}getPluginsToLoadBasedOnConfig(){let e=d.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>E_.includes(r)?(this.logger.warn(tv(qi,r)),!1):!0);let i=[{configurationStatus:()=>te(d.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:d.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(cv),shouldAddMissingPlugins:!0},{configurationStatus:()=>nu(d.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>nu(d.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>te(d.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:d.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Un)},{configurationStatus:()=>te(d.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:d.storage.encryptionPluginName.value,supportedPlugins:Object.values(qs)},{configurationStatus:()=>d.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],s=!1;return i.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>te(n)),this.addMissingPlugins(r,s,e)):e=e.filter(r.basePlugins!==void 0?n=>!(r.basePlugins.includes(n)||r.supportedPlugins.includes(n)):n=>!r.supportedPlugins.includes(n))}),[...Object.keys(sc()),...e]}addMissingPlugins(e,i,s){let r=e.shouldAddMissingPlugins||i,n;e.activePluginName?n=[...e.basePlugins||[],e.activePluginName]:n=[...e.supportedPlugins];let o=n.filter(a=>!s.includes(a));o.length>0&&(r&&s.push(...o),this.logger.warn(iv(qi,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),i=[...Object.keys(Tn),...tc],s=[],r=[];e.forEach(n=>{i.includes(n)?s.push(n):r.push(n)}),r.length>0&&this.logger.warn(nv(qi,r)),Ie(()=>{d.plugins.totalPluginsToLoad.value=e.length,d.plugins.activePlugins.value=s,d.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(Tn).forEach(([i,s])=>{d.plugins.activePlugins.value.includes(i)&&(N(s)?this.register([s()]):e.push(i))}),e.length>0&&(d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,...e],this.logger.error(ov(qi,e)))}registerRemotePlugins(){let e=P_(d.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async i=>{await e[i]().then(s=>this.register([s.default()])).catch(s=>{d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,i],this.onError(s,`Failed to load plugin "${i}"`,s)})})).catch(i=>{this.onError(i)})}invokeMultiple(e,...i){try{return this.engine.invokeMultiple(e,...i)}catch(s){return this.onError(s,e),[]}}invokeSingle(e,...i){try{return this.engine.invokeSingle(e,...i)}catch(s){return this.onError(s,e),null}}register(e){e.forEach(i=>{try{this.engine.register(i,d)}catch(s){d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,i.name],this.onError(s,`Failed to register plugin "${i.name}"`)}})}unregisterLocalPlugins(){Object.keys(Tn).forEach(e=>{try{this.engine.unregister(e)}catch(i){this.onError(i,`Failed to unregister plugin "${e}"`)}})}onError(e,i,s){this.errorHandler.onError({error:e,context:qi,customMessage:i,groupingHash:s})}},Ge="cookieStorage",He="localStorage",Ye="sessionStorage",lt="memoryStorage",Kt="none",O_="test_rudder_cookie",C_="test_rudder_ls",x_="test_rudder_ss",D_="rl_user_id",N_="rl_trait",L_="rl_anonymous_id",$_="rl_group_id",F_="rl_group_trait",M_="rl_page_init_referrer",U_="rl_page_init_referring_domain",B_="rl_session",V_="rl_auth_token",ui={userId:D_,userTraits:N_,anonymousId:L_,groupId:$_,groupTraits:F_,initialReferrer:M_,initialReferringDomain:U_,sessionInfo:B_,authToken:V_},G_="__tld__",rc="clientDataInCookie",nc="clientDataInLocalStorage",q_="clientDataInMemory",oc="clientDataInSessionStorage",ac=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ci={[Ge]:rc,[He]:nc,[lt]:q_,[Ye]:oc},ou=(t,e)=>{try{return encodeURIComponent(t)}catch(i){e?.error(Of,i);return}},au=t=>{try{return decodeURIComponent(t)}catch{return}},j_=t=>{let e={},i=t.split(/\s*;\s*/),s;return i[0]&&i.forEach(r=>{s=r.split("=");let n=s[0]?au(s[0]):void 0;n&&(e[n]=s[1]?au(s[1]):void 0)}),e},H_=(t,e,i,s)=>{let r={...i||{}},n=`${ou(t,s)}=${ou(e,s)}`;qe(e)&&(r.maxage=-1),r.maxage&&(r.expires=new Date(+new Date+r.maxage)),r.path&&(n+=`; path=${r.path}`),r.domain&&(n+=`; domain=${r.domain}`),r.expires&&(n+=`; expires=${r.expires.toUTCString()}`),r.samesite&&(n+=`; samesite=${r.samesite}`),r.secure&&(n+="; secure"),globalThis.document.cookie=n},jn=()=>{let t=globalThis.document.cookie;return j_(t)},z_=t=>jn()[t],mt=function(t,e,i,s){switch(arguments.length){case 4:case 3:case 2:return H_(t,e,i,s);case 1:return t?z_(t):jn();default:return jn()}},K_=t=>{let e=document.createElement("a");return e.href=t,e.hostname},W_=t=>{let i=(typeof globalThis.URL!="function"?K_(t):new URL(t).hostname)?.split(".")??[],s=i[i.length-1],r=[];if(i.length===4&&s&&s===parseInt(s,10).toString())return r;if(i.length<=1)return i[0]&&i[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=i.length-2;n>=0;n-=1)r.push(i.slice(n).join("."));return r},Y_=t=>{let e=W_(t);for(let i=0;i<e.length;i+=1){let s=e[i],r=G_,n={domain:`${s.indexOf("localhost")!==-1?"":"."}${s}`};try{if(mt(r,1,n),mt(r))return mt(r,null,n),s}catch{try{mt(r,null,n)}catch{}}}return""},X_=()=>{let t=`.${Y_(globalThis.location.href)}`;return{maxage:Hf,path:"/",domain:!t||t==="."?void 0:t,samesite:"Lax",enabled:!0}},J_=()=>({enabled:!0}),Q_=()=>({enabled:!0}),Z_=()=>({enabled:!0}),Hn=class{constructor(e){ae(this,"isEnabled",!0);ae(this,"length",0);ae(this,"data",{});this.options=Z_(),this.logger=e}configure(e){return this.options=Ae(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,i){return this.data[e]=i,this.length=Object.keys(this.data).length,i}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)}},er=new Hn(St);Hs={exports:{}},tm=Hs.exports;sm=im(),Gt=em(sm),lc=t=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],i=[22,1014];return t instanceof DOMException?e.includes(t.name)||i.includes(t.code):!1},di=(t=He,e,i)=>{let s,r,n=Cf(Dn,t),o="unavailable",a=!0,l;try{switch(t){case lt:return!0;case Ge:s=e,r=O_;break;case He:s=e??globalThis.localStorage,r=C_;break;case Ye:s=e??globalThis.sessionStorage,r=x_;break;default:return!1}if(s&&(s.setItem(r,"true"),s.getItem(r)))return s.removeItem(r),!0;a=!1}catch(u){a=!1,l=u,lc(u)&&(o="full")}return a||i?.warn(`${n}${o}.`,l),!1},zn=class{constructor(e){ae(this,"isSupportAvailable",!0);ae(this,"isEnabled",!0);ae(this,"length",0);this.options=J_(),this.logger=e}configure(e){return this.options=Ae(this.options,e??{}),this.isSupportAvailable=di(He),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){Gt.set(e,i),this.length=Gt.len()}getItem(e){let i=Gt.get(e);return Te(i)?null:i}removeItem(e){Gt.remove(e),this.length=Gt.len()}clear(){Gt.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Gt.keys()}},vo=new zn(St),Kn=class{constructor(e){ae(this,"isSupportAvailable",!0);ae(this,"isEnabled",!0);ae(this,"length",0);this.options=Q_(),this.logger=e}configure(e){return this.options=Ae(this.options,e??{}),this.isSupportAvailable=di(Ye),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){this.store&&(this.store.setItem(e,i),this.length=this.store.length)}getItem(e){if(!this.store)return null;let i=this.store.getItem(e);return Te(i)?null:i}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){this.store?.clear(),this.length=0}key(e){return this.store?.key(e)??null}keys(){let e=[];if(!this.store)return e;for(let i=0;i<this.store.length;i+=1){let s=this.store.key(i);s!==null&&e.push(s)}return e}},_o=new Kn(St),Wn=class{constructor(e){ae(this,"isSupportAvailable",!0);ae(this,"isEnabled",!0);ae(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=X_()),this.options=Ae(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=di(Ge,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){return mt(e,i,this.options,this.logger),this.length=Object.keys(mt()).length,!0}getItem(e){let i=mt(e);return Te(i)?null:i}removeItem(e){let i=this.setItem(e,null);return this.length=Object.keys(mt()).length,i}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(mt())}},mo=new Wn(St),it=t=>{switch(t){case He:return vo;case Ye:return _o;case lt:return er;case Ge:return mo;default:return er}},rm=t=>{let e=mo.configure(t);d.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},nm=t=>{vo.configure(t)},om=t=>{er.configure(t)},am=t=>{_o.configure(t)},lm=(t={},e={},i={},s={})=>{rm(t),nm(e),om(i),am(s)},Yn=class{constructor(e,i,s){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=i,this.noKeyValidation=Object.keys(this.validKeys).length===0,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=s}createValidKey(e){let{name:i,id:s,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[i,s,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[i,s,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:i,validKeys:s,noCompoundKey:r}=this,n=it(lt);Object.keys(s).forEach(o=>{let a=this.get(s[o]),l=r?o:[e,i,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,i){let s=this.createValidKey(e);if(s)try{this.engine.setItem(s,this.encrypt(st(i,!1,[],this.logger)))}catch(r){if(lc(r))this.logger.warn(Wp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,i);else{let n=Cp(e);this.onError(r,n,n)}}}get(e){let i=this.createValidKey(e),s;try{return!i||(s=this.decrypt(this.engine.getItem(i)),rt(s)||s==="")?null:JSON.parse(s)}catch(r){let n=d.storage.encryptionPluginName.value;if(!n||!d.plugins.failedPlugins.value.includes(n)){let a=xp(e);this.onError(r,a,a)}return null}}remove(e){let i=this.createValidKey(e);i&&this.engine.removeItem(i)}getOriginalEngine(){return this.originalEngine}decrypt(e){return rt(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,i){if(!this.isEncrypted||!e||typeof e!="string"||df(e)==="")return e;let r=`storage.${i}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,i,s){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:i,groupingHash:s})}},um=(t,e)=>{let i;if(t.consents.preConsent.value.enabled)switch(t.consents.preConsent.value.storage?.strategy){case"none":i=Kt;break;case"session":e!=="sessionInfo"&&(i=Kt);break;case"anonymousId":e!=="anonymousId"&&(i=Kt);break}return i},Xn=class{constructor(e,i,s){ae(this,"stores",{});ae(this,"isInitialized",!1);this.errorHandler=i,this.logger=s,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=d.loadOptions.value,i={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};lm(Hi(Ae(i.cookieStorageOptions??{},d.storage.cookie?.value??{})),Hi(i.localStorageOptions),Hi(i.inMemoryStorageOptions),Hi(i.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[lt,He,Ge,Ye].forEach(i=>{it(i)?.isEnabled&&this.setStore({id:ci[i],name:ci[i],isEncrypted:!0,noCompoundKey:!0,type:i,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=d.storage.type.value,i=d.loadOptions.value.storage?.entries,s=d.consents.postConsent.value.storage;(te(s?.type)||te(s?.entries))&&(e=s?.type,i=s?.entries);let r=!0,n={};ac.forEach(o=>{let a=o,l=o,u=i?.[a]?.type,h=um(d,o)??u??e??Mn,f=this.getResolvedStorageTypeForEntry(h,o);f!==Kt&&(r=!1),n={...n,[o]:{type:f,key:ui[l]}}}),Ie(()=>{d.storage.type.value=e,d.storage.entries.value=n,d.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,i){let s=e;switch(e){case He:it(He)?.isEnabled||(s=lt);break;case Ye:it(Ye)?.isEnabled||(s=lt);break;case lt:case Kt:break;case Ge:default:it(Ge)?.isEnabled?s=Ge:it(He)?.isEnabled?s=He:it(Ye)?.isEnabled?s=Ye:s=lt;break}return s!==e&&this.logger.warn(Yp(ff,i,e,s)),s}setStore(e){let i=it(e.type);return this.stores[e.id]=new Yn(e,i,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},cm=t=>ne(t)&&ne(t.source)&&!rt(t.source.id)&&ne(t.source.config)&&Array.isArray(t.source.destinations),dm=t=>typeof t=="string"&&Uu.includes(t),uc=t=>{let e=new URL(t),{host:i,protocol:s}=e,r=i.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=i,{topDomain:n,protocol:s}},hm=t=>{let{topDomain:e,protocol:i}=uc(t);return`${i}//${e}`},gm=(t,e)=>{let i=e?window.location.origin:hm(window.location.href),s=t.startsWith("/")?t.substring(1):t;return`${i}/${s}`},fm=t=>{let{topDomain:e}=uc(window.location.href);return e===t},gi=t=>t?.endsWith("/")?gi(t.substring(0,t.length-1)):t,Jn=t=>{try{return new URL(t).host}catch{return null}},cc=t=>Jn(t)??"",pm=t=>{let e={};try{let i=new URL(t),s="utm_";i.searchParams.forEach((r,n)=>{if(n.startsWith(s)){let o=n.substring(s.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},vm=t=>{let e=t;try{let i=new URL(t);e=i.origin+i.pathname+i.search}catch{}return e},_m=t=>t.replace(/\/{2,}/g,"/"),fi=t=>{if(!re(t))return!1;try{return N(globalThis.URL)&&new URL(t),lv.test(t)}catch{return!1}},Rn="none",Pn="immediate",mm=t=>t?.statsCollection?.errors?.enabled===!0,ym=t=>t?.statsCollection?.metrics?.enabled===!0,bm=t=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(ne(t)){let i=W(t);e.storage=i.storage,Et(i.integrations)&&(e.integrations=i.integrations),e.discardPreConsentEvents=i.discardPreConsentEvents===!0,e.sendPageEvent=i.sendPageEvent===!0,e.trackConsent=i.trackConsent===!0,Et(i.consentManagement)&&(e.consentManagement=Ae(i.consentManagement,{enabled:d.consents.enabled.value}))}return e},uu=t=>Et(t)||Array.isArray(t),Em=(t,e)=>{let{provider:i}=t,s=i?Un[i]:void 0;return i&&!s&&(e.error(_p(Xe,i,Un)),i=void 0),{provider:i,consentManagerPluginName:s}},dc=(t,e)=>{let i,s=[],r=[],n=!1,o,a=t?.enabled===!0;Et(t)&&a&&({provider:o,consentManagerPluginName:i}=Em(t,e),uu(t.allowedConsentIds)&&(s=t.allowedConsentIds,n=!0),uu(t.deniedConsentIds)&&(r=t.deniedConsentIds,n=!0));let l={allowedConsentIds:s,deniedConsentIds:r};return a=a&&!!i,{provider:o,consentManagerPluginName:i,initialized:n,enabled:a,consentsData:l}},Sm=()=>{let t=document.querySelector("script[data-rsa-write-key]");if(t&&t.dataset.rsaWriteKey===d.lifecycle.writeKey.value)return t.src;let e=document.getElementsByTagName("script"),i=/(?:^|\/)rsa(\.min)?\.js$/;for(let s of e){let r=s.getAttribute("src");if(r&&i.test(r))return r}},km=t=>{d.reporting.isErrorReportingEnabled.value=mm(t.source.config)&&!Sf(),d.reporting.isMetricsReportingEnabled.value=ym(t.source.config)},wm=t=>{let{useServerSideCookies:e,dataServiceEndpoint:i,storage:s,setCookieDomain:r,sameDomainCookiesOnly:n}=d.loadOptions.value,o=s?.cookie,a=!1,l;if(e){a=e;let u=o.domain??r,c=te(u)&&!fm(Ul(u))||n,h=gm(i??dv,c);if(fi(h)){l=gi(h);let f=Jn(window.location.href),g=Jn(h);f!==g&&(o={...o,samesite:"None",secure:!0}),!n&&c&&g!==Ul(u)&&(a=!1,t.warn(Mp(Xe,u,g)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},Am=t=>{let{storage:e}=d.loadOptions.value,i=e?.type;te(i)&&!dm(i)&&(t.warn(Lp(Xe,i,Mn)),i=Mn);let s=e?.encryption?.version,r=s&&qs[s];!Te(s)&&Te(r)?(t.warn($p(Xe,s,qs,jt)),s=jt):Te(s)&&(s=jt);let n=e?.migrate,o=n&&s===jt;n===!0&&o!==n&&t.warn(Fp(Xe,s,jt));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:u}=wm(t);Ie(()=>{d.storage.type.value=i,d.storage.cookie.value=u,d.serverCookies.isEnabledServerSideCookies.value=a,d.serverCookies.dataServiceUrl.value=l,d.storage.encryptionPluginName.value=qs[s],d.storage.migrate.value=o})},Im=t=>{let{provider:e,consentManagerPluginName:i,initialized:s,enabled:r,consentsData:n}=dc(d.loadOptions.value.consentManagement,t),o=d.loadOptions.value.preConsent,a=o?.storage?.strategy??Rn,l=["none","session","anonymousId"];te(a)&&!l.includes(a)&&(a=Rn,t.warn(Zp(Xe,o?.storage?.strategy,Rn)));let u=o?.events?.delivery??Pn,c=["immediate","buffer"];te(u)&&!c.includes(u)&&(u=Pn,t.warn(ev(Xe,o?.events?.delivery,Pn))),Ie(()=>{d.consents.activeConsentManagerPluginName.value=i,d.consents.initialized.value=s,d.consents.enabled.value=r,d.consents.data.value=n,d.consents.provider.value=e,d.consents.preConsent.value={enabled:d.loadOptions.value.preConsent?.enabled===!0&&s===!1&&r===!0,storage:{strategy:a},events:{delivery:u}}})},Tm=t=>{let e=d.consents.resolutionStrategy.value,i;ne(t.consentManagementMetadata)&&(d.consents.provider.value&&(e=t.consentManagementMetadata.providers.find(s=>s.provider===d.consents.provider.value)?.resolutionStrategy??d.consents.resolutionStrategy.value),i=t.consentManagementMetadata),d.consents.provider.value==="custom"&&(e=void 0),Ie(()=>{d.consents.metadata.value=W(i),d.consents.resolutionStrategy.value=e})},Rm=t=>{if(d.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",i=e;d.loadOptions.value.useBeacon&&(d.capabilities.isBeaconAvailable.value?i="BeaconQueue":(i=e,t.warn(Vp(Xe)))),Ie(()=>{d.dataPlaneEvents.eventsQueuePluginName.value=i})}},Pm=(t,e,i,s,r)=>{let n=new URLSearchParams({p:Pu,v:Xi,build:Qi,writeKey:e,lockIntegrationsVersion:i.toString(),lockPluginsVersion:s.toString()}),o=Hu,a=n,l="/sourceConfig/",u="";if(fi(t)){let c=new URL(t);gi(c.pathname).endsWith("/sourceConfig")||(c.pathname=`${gi(c.pathname)}/sourceConfig/`),c.pathname=_m(c.pathname),n.forEach((h,f)=>{c.searchParams.get(f)===null&&c.searchParams.set(f,h)}),o=c.origin,l=c.pathname,a=c.searchParams,u=c.hash}else r.warn(Jp(Xe,t));return`${o}${l}?${a}${u}`},Om=t=>t.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:b_(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===gv})),hc=(t,e,i,s,r,n,o)=>{let a;if(n){if(!fi(n))return o.error(vp(Xe,t,n)),null;a=gi(n)}else if(a=i,d.context.app.value.installType==="cdn"){let l=Sm();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${po}/${Qi}/${e}$`),`/${s}/${Qi}/${e}`)),a},Cm=(t,e,i,s)=>hc("integrations",nr,qu,t,e,i,s),xm=(t,e,i,s)=>hc("plugins",Gu,ju,t,e,i,s),Qn=class{constructor(e,i,s){this.errorHandler=i,this.logger=s,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){ut(()=>{this.logger.setMinLogLevel(d.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:i,lockIntegrationsVersion:s,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=d.loadOptions.value,l=Cm(Xi,s,n,this.logger);if(qe(l))return;let u;u=xm(Xi,r,o,this.logger),u!==null&&(this.attachEffects(),d.lifecycle.activeDataplaneUrl.value=gi(d.lifecycle.dataPlaneUrl.value),Am(this.logger),Im(this.logger),Rm(this.logger),Ie(()=>{d.lifecycle.integrationsCDNPath.value=l,d.lifecycle.pluginsCDNPath.value=u,e&&(d.lifecycle.logLevel.value=e),d.lifecycle.sourceConfigUrl.value=Pm(i,d.lifecycle.writeKey.value,s,r,this.logger),d.metrics.metricsServiceUrl.value=`${d.lifecycle.activeDataplaneUrl.value}/${hv}`,d.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,i,s){this.errorHandler.onError({error:e,context:Xe,customMessage:i,groupingHash:s})}processConfig(e,i){if(!te(e)){te(i)?this.onError(i.error,Ql):this.onError(new Error(Ql));return}let s;try{re(e)?s=JSON.parse(e):s=e}catch(n){this.onError(n,Xl);return}if(!cm(s)){this.onError(new Error(Xl));return}if(s.source.enabled===!1){this.logger.error(dp);return}km(s);let r=s.source.destinations.length>0?Om(s.source.destinations):[];Ie(()=>{d.source.value={config:s.source.config,name:s.source.name,id:s.source.id,workspaceId:s.source.workspaceId},d.nativeDestinations.configuredDestinations.value=r,d.plugins.pluginsToLoadFromConfig.value=d.loadOptions.value.plugins??[],Tm(s),d.lifecycle.status.value="configured"})}getConfig(){let e=d.loadOptions.value.getSourceConfig;if(e){if(!N(e)){this.logger.error(pp(Xe));return}let i=e();i instanceof Promise?i.then(s=>this.processConfig(s)).catch(s=>{this.onError(s,"SourceConfig")}):this.processConfig(i)}else this.httpClient.getAsyncData({url:d.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},Dm=()=>{let t=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return t?.[1]?t[1]:"NA"},gc=(t=()=>document)=>t()?.referrer||"$direct",Nm=(t=()=>document)=>{let i=t().getElementsByTagName("link"),s="";for(let r=0;i[r];r+=1){let n=i[r];if(n.getAttribute("rel")==="canonical"&&!s){s=n.getAttribute("href")??"";break}}return s},Lm=(t=()=>globalThis.navigator)=>{let e=t();if(Te(e))return null;let{userAgent:i}=e,{brave:s}=e;if(s&&Object.getPrototypeOf(s).isBrave){let r=i.match(/(chrome)\/([\w.]+)/i);r&&(i=`${i} Brave/${r[2]}`)}return i},$m=(t=()=>globalThis.navigator)=>{let e=t();return Te(e)?null:e.language??e.browserLanguage},fc=(t=()=>globalThis.location,e=()=>document)=>{let i=t(),s=Nm(e),r=i.pathname,{href:n}=i,o=n,{search:a}=i;if(s)try{let h=new URL(s);h.search===""?o=s+a:o=s,r=h.pathname}catch{}let l=vm(o),{title:u}=e(),c=gc(e);return{path:r,referrer:c,referring_domain:cc(c),search:a,title:u,url:l,tab_url:n}},Fm=(t,e="none")=>{e==="none"&&t(void 0),e==="default"&&t(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(i=>{t(i)}).catch(()=>{t()})},Mm=()=>{let t=globalThis.document.createElement("div");return t.setAttribute("data-a-b","c"),t.dataset?t.dataset.aB==="c":!1},Zn={URL:()=>!N(globalThis.URL)||!N(globalThis.URLSearchParams),Promise:()=>!N(globalThis.Promise),"Number.isNaN":()=>!N(globalThis.Number.isNaN),"Number.isInteger":()=>!N(globalThis.Number.isInteger),"Array.from":()=>!N(globalThis.Array.from),"Array.prototype.find":()=>!N(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!N(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!N(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!N(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!N(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!N(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!N(globalThis.String.fromCodePoint),"Object.entries":()=>!N(globalThis.Object.entries),"Object.values":()=>!N(globalThis.Object.values),"Object.assign":()=>!N(globalThis.Object.assign),"Object.fromEntries":()=>!N(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!Mm(),TextEncoder:()=>!N(globalThis.TextEncoder)||!N(globalThis.TextDecoder),requestAnimationFrame:()=>!N(globalThis.requestAnimationFrame)||!N(globalThis.cancelAnimationFrame),CustomEvent:()=>!N(globalThis.CustomEvent),"navigator.sendBeacon":()=>!N(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!N(globalThis.Uint8Array),Set:()=>!N(globalThis.Set),atob:()=>!N(globalThis.atob)},Um=()=>{let t=Object.keys(Zn),e=!1;for(let i=0;i<t.length;i++){let s=Zn[t[i]];if(N(s)&&s()){e=!0;break}}return e},Bm="https://polyfill-fastly.io/v3/polyfill.min.js",Vm=`${Bm}?version=3.111.0&features=${Object.keys(Zn).join("%2C")}`,Gm=10*1e3,cu="rudderstackPolyfill",qm=()=>!rt(globalThis.crypto)&&N(globalThis.crypto.getRandomValues),du=()=>!rt(globalThis.navigator.userAgentData),jm=()=>!rt(globalThis.navigator.sendBeacon)&&N(globalThis.navigator.sendBeacon),hu=()=>{let t={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return t={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},t},eo=class{constructor(e,i,s){this.httpClient=e,this.errorHandler=i,this.logger=s,this.externalSrcLoader=new Xs(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Ie(()=>{d.capabilities.storage.isCookieStorageAvailable.value=di(Ge,it(Ge),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=di(He,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=di(Ye,void 0,this.logger),d.capabilities.isBeaconAvailable.value=jm(),d.capabilities.isUaCHAvailable.value=du(),d.capabilities.isCryptoAvailable.value=qm(),d.capabilities.isOnline.value=globalThis.navigator.onLine,d.context.userAgent.value=Lm(),d.context.locale.value=$m(),d.context.screen.value=hu(),d.context.timezone.value=Dm(),du()&&Fm(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),ut(()=>{d.loadOptions.value.sendAdblockPage===!0&&d.lifecycle.sourceConfigUrl.value!==void 0&&Ju(this.httpClient)})}prepareBrowserCapabilities(){d.capabilities.isLegacyDOM.value=Um();let e=d.loadOptions.value.polyfillURL,i=Vm;if(hi(e)&&(fi(e)?i=e:this.logger.warn(sv(Dn,e))),d.loadOptions.value.polyfillIfRequired&&d.capabilities.isLegacyDOM.value&&fi(i)){let r=i!==d.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${d.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,i=`${i}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:i,id:cu,async:!0,timeout:Gm,callback:n=>{n?r||this.onReady():this.onError(new Error(Qp(cu,i)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{d.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{d.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Wf(()=>{d.context.screen.value=hu()},this))}onReady(){this.detectBrowserCapabilities(),d.lifecycle.status.value="browserCapabilitiesReady"}onError(e,i){this.errorHandler.onError({error:e,context:Dn,groupingHash:i})}},Hm="web",zm=["integrations","anonymousId","originalTimestamp"],gu=["library","consentManagement","userAgent","ua-ch","screen"],On=["id","anonymous_id","user_id","sent_at","timestamp","received_at","original_timestamp","event","event_text","channel","context_ip","context_request_ip","context_passed_ip","group_id","previous_id"],pc=t=>typeof t=="number"&&!Number.isNaN(t),Km=(t,e)=>e.toString().length>=t,tr=t=>pc(t)&&t>=0&&Number.isInteger(t),fu=10,vc=t=>{let{cutOff:e}=t,i=Date.now();return!!(e?.enabled&&e.expiresAt&&i>e.expiresAt)},pu=t=>!t.expiresAt||Date.now()>t.expiresAt||vc(t),Wm=()=>Date.now(),Ym=(t,e)=>!t||!tr(t)||!Km(fu,t)?(e.warn(Kp(qt,t,fu)),!1):!0,Xm=t=>{if(t?.enabled)return t.expiresAt??(tr(t.duration)?Date.now()+t.duration:void 0)},Jm=t=>{let{timeout:e,cutOff:i}=t,s=Date.now();return{id:s,expiresAt:s+e,timeout:e,autoTrack:!0,...i&&{cutOff:i}}},Qm=(t,e)=>({id:Ym(t,e)?t:Wm(),sessionStart:void 0,manualTrack:!0}),Ki=t=>t===Ge||t===He||t===Ye||t===lt,to=()=>ir(),Zm=t=>{if(of(t)){let{entries:e,...i}=In;return{...i,entries:{...e,anonymousId:t}}}return ne(t)&&ne(t.entries)?Ae(In,t):{...In}},ey=t=>{let e=fc(),i={};return Object.keys(e).forEach(s=>{i[s]=t?.[s]||e[s]}),i.initial_referrer=t?.initial_referrer||d.session.initialReferrer.value,i.initial_referring_domain=t?.initial_referring_domain||d.session.initialReferringDomain.value,i},ty=(t,e)=>{let i=e?.page||{},s=t,r=fc();return Object.keys(r).forEach(n=>{Te(s[n])&&(s[n]=i[n]||r[n])}),Te(s.initial_referrer)&&(s.initial_referrer=i.initial_referrer||d.session.initialReferrer.value),Te(s.initial_referring_domain)&&(s.initial_referring_domain=i.initial_referring_domain||d.session.initialReferringDomain.value),s},Cn=(t,e,i)=>{ne(t)&&Object.keys(t).forEach(s=>{(On.includes(s)||On.includes(s.toLowerCase()))&&i.warn(Up(wu,s,e,On))})},iy=(t,e)=>{let{properties:i,traits:s,context:r}=t,{traits:n}=r;Cn(i,"properties",e),Cn(s,"traits",e),Cn(n,"context.traits",e)},sy=(t,e)=>{e.anonymousId&&re(e.anonymousId)&&(t.anonymousId=e.anonymousId),Et(e.integrations)&&(t.integrations=e.integrations),e.originalTimestamp&&re(e.originalTimestamp)&&(t.originalTimestamp=e.originalTimestamp)},ry=(t,e,i)=>{let s=t;return Object.keys(e).forEach(r=>{if(!zm.includes(r)&&!gu.includes(r))if(r!=="context")s=Ae(s,{[r]:e[r]});else if(!Te(e[r])&&ne(e[r])){let n={};Object.keys(e[r]).forEach(o=>{gu.includes(o)||(n[o]=e[r][o])}),s=Ae(s,{...n})}else i.warn(Bp(wu))}),s},ny=(t,e,i)=>{ne(e)&&(sy(t,e),t.context=ry(t.context,e,i))},oy=t=>{let e;return d.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=d.consents.postConsent.value.integrations??d.nativeDestinations.loadOnlyIntegrations.value:t?e=t:e=Vu,W(e)},ji=(t,e,i,s)=>{let r={channel:Hm,context:{traits:W(d.session.userTraits.value),sessionId:d.session.sessionInfo.value.id||void 0,sessionStart:d.session.sessionInfo.value.sessionStart||void 0,...d.consents.enabled.value&&{consentManagement:{deniedConsentIds:W(d.consents.data.value.deniedConsentIds),allowedConsentIds:W(d.consents.data.value.allowedConsentIds),provider:d.consents.provider.value,resolutionStrategy:d.consents.resolutionStrategy.value}},"ua-ch":d.context["ua-ch"].value,app:d.context.app.value,library:d.context.library.value,userAgent:d.context.userAgent.value,os:d.context.os.value,locale:d.context.locale.value,screen:d.context.screen.value,campaign:pm(globalThis.location.href),page:ey(i),timezone:d.context.timezone.value,...d.autoTrack.enabled.value&&{autoTrack:{...d.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:d.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:Af(),messageId:ir(),userId:t.userId||d.session.userId.value};Ki(d.storage.entries.value.anonymousId?.type)?r.anonymousId=d.session.anonymousId.value:r.anonymousId=to(),d.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),t.type==="identify"&&(r.context.traits=d.storage.entries.value.userTraits?.type!==Kt?W(d.session.userTraits.value):t.context.traits),t.type==="group"&&((t.groupId||d.session.groupId.value)&&(r.groupId=t.groupId||d.session.groupId.value),(t.traits||d.session.groupTraits.value)&&(r.traits=d.storage.entries.value.groupTraits?.type!==Kt?W(d.session.groupTraits.value):t.traits));let n=Ae(t,r);return n.event===void 0&&(n.event=null),n.properties===void 0&&(n.properties=null),ny(n,e,s),iy(n,s),n.integrations=oy(n.integrations),n},io=class{constructor(e){this.logger=e}generatePageEvent(e,i,s,r){let n=s??{};return n=ty(n,r),ji({properties:n,name:i,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,i,s){return ji({properties:i,event:e,type:"track"},s,void 0,this.logger)}generateIdentifyEvent(e,i,s){return ji({userId:e,type:"identify",context:{traits:i}},s,void 0,this.logger)}generateAliasEvent(e,i,s){let n=ji({previousId:i,type:"alias"},s,void 0,this.logger);return n.userId=e??n.userId,n}generateGroupEvent(e,i,s){let r={type:"group"};return e&&(r.groupId=e),i&&(r.traits=i),ji(r,s,void 0,this.logger)}create(e){let i;switch(e.type){case"page":i=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":i=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":i=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":i=this.generateAliasEvent(e.to,e.from,e.options);break;default:i=this.generateGroupEvent(e.groupId,e.traits,e.options);break}return i}},so=class{constructor(e,i,s,r){this.eventRepository=e,this.userSessionManager=i,this.errorHandler=s,this.logger=r,this.eventFactory=new io(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let i=this.eventFactory.create(e);this.eventRepository.enqueue(i,e.callback)}},ro=class{constructor(e,i,s,r,n){this.storeManager=i,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=s,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());let{externalAnonymousIdCookieName:e,anonymousIdOptions:i}=d.loadOptions.value,s;hi(e)&&typeof e=="string"&&(s=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(s??this.getAnonymousId(i)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let i=this.getConfiguredSessionTrackingInfo(),s=this.getSessionInfo()??Q.sessionInfo;e={autoTrack:i.autoTrack&&s.manualTrack!==!0,timeout:i.timeout,manualTrack:s.manualTrack,expiresAt:s.expiresAt,id:s.id,sessionStart:s.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=Q.sessionInfo:i.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:i.cutOff.duration,expiresAt:s.cutOff?.expiresAt})}else e=Q.sessionInfo;d.session.sessionInfo.value=e,d.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(d.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),i=this.getInitialReferringDomain();if(e&&i)this.setInitialReferrer(e),this.setInitialReferringDomain(i);else{let s=e||gc();this.setInitialReferrer(s),this.setInitialReferringDomain(cc(s))}}isPersistenceEnabledForStorageEntry(e){return Ki(d.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=d.storage.entries.value,i=[Ge,He,Ye];Object.keys(e).forEach(s=>{let r=s,n=e[r]?.type,o=this.storeManager?.getStore(ci[n]);o&&i.forEach(a=>{let l=this.storeManager?.getStore(ci[a]);if(l&&a!==n){let u=l.get(ui[r]);nf(u)&&o.set(ui[r],u),l.remove(ui[r])}})})}migrateStorageIfNeeded(e,i){if(!d.storage.migrate.value)return;let s=e??[];s.length===0&&[rc,nc,oc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&s.push(a)}),(i??Object.keys(ui)).forEach(n=>{let o=ui[n];s.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);rt(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=d.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let i,s=d.loadOptions.value.sessions?.timeout;tr(s)?i=s:(this.logger.warn(Gp(qt,s,Nn)),i=Nn),i===0&&(this.logger.warn(Hp(qt)),e=!1),i>0&&i<Kl&&this.logger.warn(zp(qt,i,Kl));let r=this.getCutOffInfo(i);return{timeout:i,autoTrack:e,cutOff:r}}getCutOffInfo(e){let i=d.loadOptions.value.sessions.cutOff,s,r=!1;return i.enabled===!0&&(s=i.duration,r=!0,tr(s)?s<e&&(this.logger.warn(jp(qt,s,e)),r=!1):(this.logger.warn(qp(qt,s,zl)),s=zl)),{enabled:r,duration:s}}onError(e,i,s){this.errorHandler.onError({error:e,context:qt,customMessage:i,groupingHash:s})}getEncryptedCookieData(e,i){let s=[];return e.forEach(r=>{let n=i?.encrypt(st(r.value,!1,[],this.logger));hi(n)&&s.push({name:r.name,value:n})}),s}makeRequestToSetCookie(e,i){this.httpClient?.getAsyncData({url:d.serverCookies.dataServiceUrl.value,options:{method:"POST",data:st({reqType:"setCookies",workspaceId:d.source.value?.workspaceId,data:{options:{maxAge:d.storage.cookie.value?.maxage,path:d.storage.cookie.value?.path,domain:d.storage.cookie.value?.domain,sameSite:d.storage.cookie.value?.samesite,secure:d.storage.cookie.value?.secure,expires:d.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:i})}setServerSideCookies(e,i,s){let r=Object.keys(e),n=()=>r.map(u=>({name:e[u].name,value:d.session[u].value})),o={};r.forEach(u=>{o[e[u].name]=s?.get(e[u].name)});let a=()=>{r.forEach(u=>{this.serverSideCookiesRequestInProgress[u]=!1})},l=()=>{n().forEach(u=>{i&&i(u.name,u.value)})};try{let u={};r.forEach(h=>{u[e[h].name]=d.session[h].value});let c=this.getEncryptedCookieData(n(),s);c.length>0?this.makeRequestToSetCookie(c,(h,f)=>{a(),f?.xhr?.status===200?n().forEach(g=>{let p=o[g.name],v=s?.get(g.name);st(u[g.name],!1,[])!==st(v,!1,[])&&(qe(p)&&qe(v)&&this.logger.error(Np(g.name)),i&&i(g.name,g.value))}):(this.logger.error(Dp(f?.xhr?.status)),l())}):(l(),a())}catch(u){this.onError(u,Zl,Zl),l(),a()}}syncValueToStorage(e){let i=d.storage.entries.value,s=i[e]?.type;if(Ki(s)){let r=this.storeManager.getStore(ci[s]),n=i[e]?.key,o=d.session[e].value;o&&(re(o)||Et(o))?d.serverCookies.isEnabledServerSideCookies.value&&s===Ge?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{let a={[e]:{name:n}};this.setServerSideCookies(a,(l,u)=>{r?.set(l,u)},r)},vv)):r?.set(n,o):r?.remove(n)}}registerEffects(){ac.forEach(e=>{ut(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,i){let s=e;(!re(e)||!s)&&(s=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!s&&i&&(s=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",i)),s=s||to()):s=Q.anonymousId,d.session.anonymousId.value=s}getAnonymousId(e){let i=d.storage.entries.value.anonymousId?.type;if(Ki(i)){let s=d.session.anonymousId.value;(!s||s===Q.anonymousId)&&(s=this.getEntryValue("anonymousId")),!s&&e&&(s=this.pluginsManager?.invokeSingle("storage.getAnonymousId",it,e)),d.session.anonymousId.value=s||to()}return d.session.anonymousId.value}getEntryValue(e){let i=d.storage.entries.value,s=i[e]?.type;if(Ki(s)){let r=this.storeManager?.getStore(ci[s]);this.migrateStorageIfNeeded([r],[e]);let n=i[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let i=it(Ge);return i?.isEnabled?i.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?d.session[e].value:this.getEntryValue(e)}getUserId(){return this.getUserSessionValue("userId")}getUserTraits(){return this.getUserSessionValue("userTraits")}getGroupId(){return this.getUserSessionValue("groupId")}getGroupTraits(){return this.getUserSessionValue("groupTraits")}getInitialReferrer(){return this.getUserSessionValue("initialReferrer")}getInitialReferringDomain(){return this.getUserSessionValue("initialReferringDomain")}getSessionInfo(){return this.getUserSessionValue("sessionInfo")}getAuthToken(){return this.getUserSessionValue("authToken")}getSessionId(){let e=this.getSessionInfo()??Q.sessionInfo;return e.autoTrack&&!pu(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??Q.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=d.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),d.session.sessionInfo.value=e,d.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=d.session,{manualTrack:i,autoTrack:s,timeout:r,cutOff:n}=e.sessionInfo.value;if(s){let o={...Q.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else i&&this.startManualTrackingInternal()}reset(e){let{session:i}=d,s=Zm(e);Ie(()=>{Object.keys(Q).forEach(r=>{let n=r;if(s.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:i[n].value=Q[n];break}})})}setUserId(e){d.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:Q.userId}setUserTraits(e){d.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&ne(e)?Ae(d.session.userTraits.value??Q.userTraits,e):Q.userTraits}setGroupId(e){d.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:Q.groupId}setGroupTraits(e){d.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&ne(e)?Ae(d.session.groupTraits.value??Q.groupTraits,e):Q.groupTraits}setInitialReferrer(e){d.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:Q.initialReferrer}setInitialReferringDomain(e){d.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:Q.initialReferringDomain}startOrRenewAutoTracking(e){let i=e;if(pu(e))i=Jm(e);else{let s=Date.now(),r=e.timeout;i.expiresAt=s+r}if(vc(i)&&(i.cutOff.expiresAt=void 0),i.cutOff){let s=Xm(i.cutOff);i.cutOff.expiresAt=s}d.session.sessionInfo.value=i}start(e){d.session.sessionInfo.value=Qm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){d.session.sessionInfo.value=Q.sessionInfo}setAuthToken(e){d.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:Q.authToken}},ay=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],ly=ay,uy=(t,e)=>{let i=W(e);return re(i.setCookieDomain)||(i.setCookieDomain=void 0),["Strict","Lax","None"].includes(i.sameSiteCookie)||(i.sameSiteCookie=void 0),i.secureCookie=at(i.secureCookie,t.secureCookie),i.sameDomainCookiesOnly=at(i.sameDomainCookiesOnly,t.sameDomainCookiesOnly),["none","default","full"].includes(i.uaChTrackLevel)||(i.uaChTrackLevel=void 0),i.integrations=vt(i.integrations),Array.isArray(i.plugins)||(i.plugins=ly),i.useGlobalIntegrationsConfigInEvents=at(i.useGlobalIntegrationsConfigInEvents,t.useGlobalIntegrationsConfigInEvents),i.bufferDataPlaneEventsUntilReady=at(i.bufferDataPlaneEventsUntilReady,t.bufferDataPlaneEventsUntilReady),i.sendAdblockPage=at(i.sendAdblockPage,t.sendAdblockPage),i.useServerSideCookies=at(i.useServerSideCookies,t.useServerSideCookies),re(i.dataServiceEndpoint)||(i.dataServiceEndpoint=void 0),i.sendAdblockPageOptions=vt(i.sendAdblockPageOptions),i.loadIntegration=at(i.loadIntegration,t.loadIntegration),Et(i.storage)?(i.storage.migrate=at(i.storage.migrate,t.storage?.migrate),i.storage.cookie=vt(i.storage.cookie),i.storage.encryption=vt(i.storage.encryption),i.storage=Ks(i.storage)):i.storage=void 0,i.destinationsQueueOptions=vt(i.destinationsQueueOptions),i.queueOptions=vt(i.queueOptions),i.lockIntegrationsVersion=at(i.lockIntegrationsVersion,t.lockIntegrationsVersion),i.lockPluginsVersion=at(i.lockPluginsVersion,t.lockPluginsVersion),pc(i.dataPlaneEventsBufferTimeout)||(i.dataPlaneEventsBufferTimeout=void 0),i.beaconQueueOptions=vt(i.beaconQueueOptions),i.preConsent=vt(i.preConsent),i.sourceConfigurationOverride=vt(i.sourceConfigurationOverride),Ae(t,Ks(i))},vu="dataplaneEventsQueue",_u="destinationsEventsQueue",cy="transformEvent",dy=(t,e)=>Object.keys(t).filter(i=>t[i]!==!0||!e[i]).reduce((i,s)=>{let r=W(i);return r[s]=t[s],r},{}),hy=(t,e)=>{let i=W(t),s=e.nativeDestinations.integrationsConfig.value,r=dy(t.integrations,s);return i.integrations=Ae(s,r),i},gy=t=>t.consents.preConsent.value.enabled&&t.consents.preConsent.value.events?.delivery==="buffer",zs=(t,e,i,s)=>{if(te(t))if(N(t))try{t(...e)}catch(r){s.error(Xp(i),r)}else s.error(Bu(i))},no=class{constructor(e,i,s,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=s,this.logger=n,this.storeManager=i}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${vu}.init`,d,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${cy}.init`,d,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${_u}.init`,d,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),ut(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=gy(d),i;ut(()=>{let s=d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&d.nativeDestinations.clientDestinationsReady.value===!1;(d.nativeDestinations.activeDestinations.value.some(n=>y_(n))===!1||s===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(i),this.dataplaneEventsQueue?.start())}),d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(i=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},d.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(d.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,i){let s=hy(e,d);this.pluginsManager.invokeSingle(`${vu}.enqueue`,d,this.dataplaneEventsQueue,s,this.errorHandler,this.logger);let r=W(e);this.pluginsManager.invokeSingle(`${_u}.enqueue`,d,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${ho}`;zs(i,[s],n,this.logger)}},mu=t=>{let e=new CustomEvent(t,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},fy=t=>re(t)&&t.trim().length>0,py=t=>fi(t),oo=class{constructor(){this.preloadBuffer=new $n,this.initialized=!1,this.errorHandler=ec,this.logger=St,this.externalSrcLoader=new Xs(this.logger),this.httpClient=Xu,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new eo(this.httpClient,this.errorHandler,this.logger)}load(e,i,s={}){if(!d.lifecycle.status.value){if(!fy(e)){this.logger.error(Ip(Ms,e));return}if(!py(i)){this.logger.error(Tp(Ms,i));return}Ie(()=>{d.lifecycle.writeKey.value=W(e),d.lifecycle.dataPlaneUrl.value=W(i),d.loadOptions.value=uy(d.loadOptions.value,s),d.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(d.loadOptions.value.logLevel??Mu),Ji("state",d,e),this.startLifecycle()}}startLifecycle(){ut(()=>{try{switch(d.lifecycle.status.value){case"mounted":this.onMounted();break;case"browserCapabilitiesReady":this.onBrowserCapabilitiesReady();break;case"configured":this.onConfigured();break;case"pluginsLoading":break;case"pluginsReady":this.onPluginsReady();break;case"initialized":this.onInitialized();break;case"loaded":this.onLoaded();break;case"destinationsLoading":break;case"destinationsReady":this.onDestinationsReady();break;case"ready":this.onReady();break;default:break}}catch(e){let i="Failed to load the SDK";this.errorHandler.onError({error:e,context:Ms,customMessage:i,groupingHash:i})}})}onBrowserCapabilitiesReady(){Qf(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),d.consents.preConsent.value.enabled===!0?d.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(i=>this.preloadBuffer.enqueue(W(i)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&Zf([...e],this)}}prepareInternalServices(){this.pluginsManager=new qn(__,this.errorHandler,this.logger),this.storeManager=new Xn(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Qn(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new ro(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new no(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new so(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){d.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(d.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),d.consents.enabled.value&&!d.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",d,this.logger),d.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger)),this.eventManager?.init(),d.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Ie(()=>{d.lifecycle.loaded.value=!0,d.lifecycle.status.value="loaded"}),this.initialized=!0;let e=d.loadOptions.value.onLoaded;zs(e,[globalThis.rudderanalytics],pf,this.logger),mu("RSA_Initialised")}onReady(){d.lifecycle.status.value="readyExecuted",d.eventBuffer.readyCallbacksArray.value.forEach(e=>{zs(e,[],wn,this.logger)}),mu("RSA_Ready")}processBufferedEvents(){let e=d.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let i=e.shift();if(d.eventBuffer.toBeProcessedArray.value=e,i){let s=i[0];N(this[s])&&this[s](...i.slice(1),!0)}e=d.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if(d.lifecycle.status.value==="destinationsLoading"||d.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",d,this.pluginsManager,this.errorHandler,this.logger);let e=d.nativeDestinations.activeDestinations.value.length;if(e===0){Ie(()=>{d.nativeDestinations.clientDestinationsReady.value=!0,d.lifecycle.status.value="destinationsReady"});return}d.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",d,this.externalSrcLoader,this.errorHandler,this.logger),ut(()=>{d.nativeDestinations.initializedDestinations.value.length+d.nativeDestinations.failedDestinations.value.length===e&&Ie(()=>{d.lifecycle.status.value="destinationsReady",d.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){d.lifecycle.status.value!=="ready"&&Ie(()=>{d.lifecycle.status.value="ready"})}ready(e,i=!1){let s="ready";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),!N(e)){this.logger.error(Bu(wn));return}d.lifecycle.status.value==="readyExecuted"?zs(e,[],wn,this.logger):d.eventBuffer.readyCallbacksArray.value=[...d.eventBuffer.readyCallbacksArray.value,e]}page(e,i=!1){let s="page";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),d.capabilities.isAdBlocked.value===!0&&e.category!==ql&&this.page(Ys(ql,Mf,{path:Uf},d.loadOptions.value.sendAdblockPageOptions))}track(e,i=!1){let s="track";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event - ${e.name}`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:s,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,i=!1){let s="identify";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,e.userId&&d.session.userId.value&&e.userId!==d.session.userId.value&&this.reset(),qe(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:s,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,i=!1){let s="alias";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:s,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,i=!1){let s="group";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,qe(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:s,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,i=!1){let s="reset";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,i,s=!1){let r="setAnonymousId";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,i]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,i)}getUserId(){return d.session.userId.value}getUserTraits(){return d.session.userTraits.value}getGroupId(){return d.session.groupId.value}getGroupTraits(){return d.session.groupTraits.value}startSession(e,i=!1){let s="startSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let i="endSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,i=!1){let s="consent";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Ie(()=>{d.consents.preConsent.value={...d.consents.preConsent.value,enabled:!1},d.consents.postConsent.value=bm(e);let{initialized:r,consentsData:n}=dc(d.consents.postConsent.value.consentManagement,this.logger);d.consents.initialized.value=r,d.consents.data.value=n}),d.consents.enabled.value&&!d.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(i)}sendTrackingEvents(e){if(d.consents.postConsent.value.trackConsent){let i=co(Bf);e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["track",i]]:this.track(i)}if(d.consents.postConsent.value.sendPageEvent){let i=Ys();e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["page",i]]:this.page(i)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,i,s=!1){let r="addCustomIntegration";if(s)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,i,d,this.logger);else{if(d.lifecycle.loaded.value){this.logger.error(av(Ms,e));return}d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,i]]}}},Ht=class Ht{constructor(){ae(this,"analyticsInstances",{});ae(this,"defaultAnalyticsKey","");ae(this,"logger",St);try{if(Ht.globalSingleton)return Ht.globalSingleton;Ht.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.getSessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),Ht.globalSingleton=this,d.autoTrack.pageLifecycle.pageViewId.value=ir(),d.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){fe(e)}}createSafeAnalyticsInstance(){d.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(){ec.init(),mo.configure(),vo.configure(),_o.configure(),er.configure()}setDefaultInstanceKey(e){re(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let i=e;return(!re(i)||!i)&&(i=this.defaultAnalyticsKey),this.analyticsInstances[i]||(this.analyticsInstances[i]=new oo),this.analyticsInstances[i]}catch(i){fe(i);return}}load(e,i,s){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(s);let r=Cu(Wi);Jf(r),Ji(Wi,W(r)),this.getAnalyticsInstance(e)?.load(e,i,X(s))}catch(r){fe(r)}}trackPageLifecycleEvents(e){let{autoTrack:i,useBeacon:s}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=i??{},{events:a=[kn.UNLOADED],enabled:l=r,options:u=n}=o??{};d.autoTrack.pageLifecycle.enabled.value=l,d.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,s,u)}setupPageUnloadTracking(e,i,s){(e.length===0||e.includes(kn.UNLOADED))&&(i===!0?wf(r=>{if(r===!1&&d.lifecycle.loaded.value){let n=Date.now(),o=n-d.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(kn.UNLOADED,{timeOnPage:o},{...s,originalTimestamp:Au(new Date(n))})}},!0):this.logger.warn(rv(_f)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],i=Xf(e);Ji(Wi,W([...e])),i.length>0&&(i.shift(),this.load.apply(null,i))}ready(e){try{this.getAnalyticsInstance()?.ready(X(e))}catch(i){fe(i)}}page(e,i,s,r,n){try{this.getAnalyticsInstance()?.page(Ys(X(e),X(i),X(s),X(r),X(n)))}catch(o){fe(o)}}track(e,i,s,r){try{this.getAnalyticsInstance()?.track(co(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}identify(e,i,s,r){try{this.getAnalyticsInstance()?.identify(Eu(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}alias(e,i,s,r){try{this.getAnalyticsInstance()?.alias(Su(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}group(e,i,s,r){try{this.getAnalyticsInstance()?.group(ku(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(X(e))}catch(i){fe(i)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(X(e))}catch(i){fe(i);return}}setAnonymousId(e,i){try{this.getAnalyticsInstance()?.setAnonymousId(X(e),X(i))}catch(s){fe(s)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){fe(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){fe(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){fe(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){fe(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(X(e))}catch(i){fe(i)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){fe(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){fe(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(X(e))}catch(i){fe(i)}}consent(e){try{this.getAnalyticsInstance()?.consent(X(e))}catch(i){fe(i)}}addCustomIntegration(e,i){try{this.getAnalyticsInstance()?.addCustomIntegration(X(e),X(i))}catch(s){fe(s)}}};ae(Ht,"globalSingleton",null);pi=Ht});var mc,yc,bo,_c,bc,Ec,Sc,kc,Zi=Ue(()=>{"use strict";mc="https://deriv.com/cdn-cgi/trace",yc="https://cdn.growthbook.io",bo="https://deriv-dataplane.rudderstack.com",_c="https://ph.deriv.com",bc="https://us.posthog.com",Ec=()=>{if(typeof window>"u")return _c;let t=window.location.hostname;return t.includes(".deriv.me")?"https://ph.deriv.me":t.includes(".deriv.be")?"https://ph.deriv.be":t.includes(".deriv.ae")?"https://ph.deriv.ae":_c},Sc=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],kc=["deriv.com","derivcrypto.com","besquare.my","besquare.com.my","ewallet.exchange","champion-fx.com","opalstraits.com","binary.com","binary.marketing","championgbs.com","4x.my","re-work.dev","regentmarkets.com","4x.com","binary.me","deriv.team","firstsource.io","firstsource.tech","deriv.hr","vmgbpo.net","mailisk.net","mailosaur.net","mobileapps.mailisk.net","w3e180zd.mailosaur.net"]});function ar(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)t[s]=i[s]}return t}function Eo(t,e){function i(r,n,o){if(!(typeof document>"u")){o=ar({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)o[l]&&(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=r+"="+t.write(n,r)+a}}function s(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var n=document.cookie?document.cookie.split("; "):[],o={},a=0;a<n.length;a++){var l=n[a].split("="),u=l.slice(1).join("=");try{var c=decodeURIComponent(l[0]);if(o[c]=t.read(u,c),r===c)break}catch{}}return r?o[r]:o}}return Object.create({set:i,get:s,remove:function(r,n){i(r,"",ar({},n,{expires:-1}))},withAttributes:function(r){return Eo(this.converter,ar({},this.attributes,r))},withConverter:function(r){return Eo(ar({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var vy,wc,Ac=Ue(()=>{"use strict";vy={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};wc=Eo(vy,{path:"/"})});var Lt,ur,es,lr,Ic,Wt,Tc,Rc,ts=Ue(()=>{"use strict";Ac();Zi();Lt=(t,e)=>(...i)=>{e()&&console.log(`[ANALYTIC]${t}`,...i)},ur=t=>{let e=t.split("@")[1]?.toLowerCase();return e?kc.includes(e):!1},es=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),lr=null,Ic=async()=>{if(lr)return lr;let t=JSON.parse(wc.get("website_status")||"{}")?.clients_country;return lr=(async()=>{try{let e=await fetch(mc).catch(()=>null);if(!e)return t||"";let i=await e.text().catch(()=>"");return i?Object.fromEntries(i.split(`
5
+ `).map(r=>r.split("=",2))).loc?.toLowerCase()||t||"":t||""}catch{return t||""}})(),lr},Wt=t=>{if(t==null||typeof t!="object")return t;if(Array.isArray(t)){let s=[];for(let r=0;r<t.length;r++){let n=Wt(t[r]);n!=null&&s.push(n)}return s.length?s:void 0}let e={},i=!1;for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let r=Wt(t[s]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[s]=r,i=!0)}return i?e:void 0},Tc=(t,e)=>{for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let s=t[i];s&&typeof s=="object"&&!Array.isArray(s)?Tc(s,e):e[i]=s}},Rc=t=>{if(t==null||typeof t!="object"||Array.isArray(t))return t;let e={};return Tc(t,e),e}});function Fc(){return $c}function So(t){let e=2166136261,i=t.length;for(let s=0;s<i;s++)e^=t.charCodeAt(s),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function is(t,e,i){return i===2?So(So(t+e)+"")%1e4/1e4:i===1?So(e+t)%1e3/1e3:null}function my(t){return t<=0?[]:new Array(t).fill(1/t)}function gr(t,e){return t>=e[0]&&t<e[1]}function Mc(t,e){let i=is("__"+e[0],t,1);return i===null?!1:i>=e[1]&&i<e[2]}function Uc(t,e){for(let i=0;i<e.length;i++)if(gr(t,e[i]))return i;return-1}function wo(t){try{let e=t.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function fr(t,e){if(!e.length)return!1;let i=!1,s=!1;for(let r=0;r<e.length;r++){let n=Ey(t,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else i=!0,n&&(s=!0)}return s||!i}function yy(t,e,i){try{let s=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return i&&(s="\\/?"+s.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+s+"$","i").test(t)}catch{return!1}}function by(t,e){try{let i=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),s=[[t.host,i.host,!1],[t.pathname,i.pathname,!0]];return i.hash&&s.push([t.hash,i.hash,!1]),i.searchParams.forEach((r,n)=>{s.push([t.searchParams.get(n)||"",r,!1])}),!s.some(r=>!yy(r[0],r[1],r[2]))}catch{return!1}}function Ey(t,e,i){try{let s=new URL(t,"https://_");if(e==="regex"){let r=wo(i);return r?r.test(s.href)||r.test(s.href.substring(s.origin.length)):!1}else if(e==="simple")return by(s,i);return!1}catch{return!1}}function Bc(t,e,i){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let s=my(t);i=i||s,i.length!==t&&(i=s);let r=i.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(i=s);let n=0;return i.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function Vc(t,e,i){if(!e)return null;let s=e.split("?")[1];if(!s)return null;let r=s.replace(/#.*/,"").split("&").map(n=>n.split("=",2)).filter(([n])=>n===t).map(([,n])=>parseInt(n));return r.length>0&&r[0]>=0&&r[0]<i?r[0]:null}function Gc(t){try{return t()}catch(e){return console.error(e),!1}}async function Xt(t,e,i){if(e=e||"",i=i||globalThis.crypto&&globalThis.crypto.subtle||$c.SubtleCrypto,!i)throw new Error("No SubtleCrypto implementation found");try{let s=await i.importKey("raw",ko(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=t.split("."),o=await i.decrypt({name:"AES-CBC",iv:ko(r)},s,ko(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function ss(t){return typeof t=="string"?t:JSON.stringify(t)}function ze(t){typeof t=="number"&&(t=t+""),(!t||typeof t!="string")&&(t="0");let e=t.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(i=>i.match(/^[0-9]+$/)?i.padStart(5," "):i).join("-")}function qc(){let t;try{t="1.6.5"}catch{t=""}return t}function jc(t,e){let i,s;try{i=new URL(t),s=new URL(e)}catch(r){return console.error(`Unable to merge query strings: ${r}`),e}return i.searchParams.forEach((r,n)=>{s.searchParams.has(n)||s.searchParams.set(n,r)}),s.toString()}function Lc(t){return typeof t=="object"&&t!==null}function pr(t){return t.urlPatterns&&t.variations.some(e=>Lc(e)&&"urlRedirect"in e)?"redirect":t.variations.some(e=>Lc(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function vr(t,e){return new Promise(i=>{let s=!1,r,n=o=>{s||(s=!0,r&&clearTimeout(r),i(o||null))};e&&(r=setTimeout(()=>n(),e)),t.then(o=>n(o)).catch(()=>n())})}var $c,ko,rs=Ue(()=>{"use strict";$c={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};ko=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0))});function Kc(t){Object.assign(Ce,t),Ce.backgroundSync||Oo()}async function Wc({instance:t,timeout:e,skipCache:i,allowStale:s,backgroundSync:r}){return r||(Ce.backgroundSync=!1),Ay({instance:t,allowStale:s,timeout:e,skipCache:i})}function Sy(t){let e=ns(t),i=yi.get(e)||new Set;i.add(t),yi.set(e,i)}function Yc(t){yi.forEach(e=>e.delete(t))}function ky(){bi.forEach(t=>{t&&(t.state="idle",Ro(t))})}function wy(){bi.forEach(t=>{t&&t.state==="idle"&&Po(t)})}async function zc(){try{if(!ct.localStorage)return;await ct.localStorage.setItem(Ce.cacheKey,JSON.stringify(Array.from(kt.entries())))}catch{}}async function Ay({instance:t,allowStale:e,timeout:i,skipCache:s}){let r=ns(t),n=Io(t),o=new Date,a=new Date(o.getTime()-Ce.maxAge+Ce.staleTTL);await Iy();let l=!Ce.disableCache&&!s?kt.get(n):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&Ei.add(r),l.staleAt<o?Ao(t):To(t),{data:l.data,success:!0,source:"cache"}):await vr(Ao(t),i)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function ns(t){let[e,i]=t.getApiInfo();return`${e}||${i}`}function Io(t){let e=ns(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;let i=t.getAttributes(),s=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};s.forEach(a=>{r[a]=i[a]});let n=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:r,fv:n,url:o})}`}async function Iy(){if(!Hc){Hc=!0;try{if(ct.localStorage){let t=await ct.localStorage.getItem(Ce.cacheKey);if(!Ce.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(([i,s])=>{kt.set(i,{...s,staleAt:new Date(s.staleAt)})}),Xc()}}}catch{}if(!Ce.disableIdleStreams){let t=mi.startIdleListener();t&&(mi.stopIdleListener=t)}}}function Xc(){let t=Array.from(kt.entries()).map(([i,s])=>({key:i,staleAt:s.staleAt.getTime()})).sort((i,s)=>i.staleAt-s.staleAt),e=Math.min(Math.max(0,kt.size-Ce.maxEntries),kt.size);for(let i=0;i<e;i++)kt.delete(t[i].key)}function Jc(t,e,i){let s=i.dateUpdated||"",r=new Date(Date.now()+Ce.staleTTL),n=Ce.disableCache?void 0:kt.get(e);if(n&&s&&n.version===s){n.staleAt=r,zc();return}Ce.disableCache||(kt.set(e,{data:i,version:s,staleAt:r,sse:Ei.has(t)}),Xc()),zc();let o=yi.get(t);o&&o.forEach(a=>Ty(a,i))}async function Ty(t,e){await t.setPayload(e||t.getPayload())}async function Ao(t){let{apiHost:e,apiRequestHeaders:i}=t.getApiHosts(),s=t.getClientKey(),r="isRemoteEval"in t&&t.isRemoteEval(),n=ns(t),o=Io(t),a=_r.get(o);return a||(a=(r?mi.fetchRemoteEvalCall({host:e,clientKey:s,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:i}):mi.fetchFeaturesCall({host:e,clientKey:s,headers:i})).then(u=>{if(!u.ok)throw new Error(`HTTP error: ${u.status}`);return u.headers.get("x-sse-support")==="enabled"&&Ei.add(n),u.json()}).then(u=>(Jc(n,o,u),To(t),_r.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(_r.delete(o),{data:null,source:"error",success:!1,error:u})),_r.set(o,a)),a}function To(t,e=!1){let i=ns(t),s=Io(t),{streamingHost:r,streamingHostRequestHeaders:n}=t.getApiHosts(),o=t.getClientKey();if(e&&Ei.add(i),Ce.backgroundSync&&Ei.has(i)&&ct.EventSource){if(bi.has(i))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let u=yi.get(i);u&&u.forEach(c=>{Ao(c)})}else if(l.type==="features"){let u=JSON.parse(l.data);Jc(i,s,u)}a.errors=0}catch{Qc(a)}},errors:0,state:"active"};bi.set(i,a),Po(a)}}function Qc(t){if(t.state!=="idle"&&(t.errors++,t.errors>3||t.src&&t.src.readyState===2)){let e=Math.pow(3,t.errors-3)*(1e3+Math.random()*1e3);Ro(t),setTimeout(()=>{["idle","active"].includes(t.state)||Po(t)},Math.min(e,3e5))}}function Ro(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,t.state==="active"&&(t.state="disabled"))}function Po(t){t.src=mi.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state="active",t.src.addEventListener("features",t.cb),t.src.addEventListener("features-updated",t.cb),t.src.onerror=()=>Qc(t),t.src.onopen=()=>{t.errors=0}}function Ry(t,e){Ro(t),bi.delete(e)}function Oo(){Ei.clear(),bi.forEach(Ry),yi.clear(),mi.stopIdleListener()}function mr(t,e){if(e.streaming){if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&To(t,!0),Sy(t)}}var Ce,ct,mi,yi,Hc,kt,_r,bi,Ei,Zc=Ue(()=>{"use strict";rs();Ce={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},ct=Fc(),mi={fetchFeaturesCall:({host:t,clientKey:e,headers:i})=>ct.fetch(`${t}/api/features/${e}`,{headers:i}),fetchRemoteEvalCall:({host:t,clientKey:e,payload:i,headers:s})=>{let r={method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(i)};return ct.fetch(`${t}/api/eval/${e}`,r)},eventSourceCall:({host:t,clientKey:e,headers:i})=>i?new ct.EventSource(`${t}/sub/${e}`,{headers:i}):new ct.EventSource(`${t}/sub/${e}`),startIdleListener:()=>{let t;if(!(typeof window<"u"&&typeof document<"u"))return;let i=()=>{document.visibilityState==="visible"?(window.clearTimeout(t),wy()):document.visibilityState==="hidden"&&(t=window.setTimeout(ky,Ce.idleStreamInterval))};return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(ct.localStorage=globalThis.localStorage)}catch{}yi=new Map,Hc=!1,kt=new Map,_r=new Map,bi=new Map,Ei=new Set});function Oy(t){return t==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}function kr(t){var e=Sr.get(t);return e||(e={element:t,attributes:{}},Sr.set(t,e)),e}function wr(t,e,i,s,r){var n=i(t),o={isDirty:!1,originalValue:n,virtualValue:n,mutations:[],el:t,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=i(t);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,r(o))}}),mutationRunner:r,setValue:s,getCurrentValue:i};return e==="position"&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,Oy(e)),o}function Ar(t,e){var i=e.getCurrentValue(e.el);e.virtualValue=t,t&&typeof t!="string"?(!i||t.parentNode!==i.parentNode||t.insertBeforeNode!==i.insertBeforeNode)&&(e.isDirty=!0,ed()):t!==i&&(e.isDirty=!0,ed())}function Cy(t){var e=t.originalValue;t.mutations.forEach(function(i){return e=i.mutate(e)}),Ar(Hy(e),t)}function xy(t){var e=new Set(t.originalValue.split(/\s+/).filter(Boolean));t.mutations.forEach(function(i){return i.mutate(e)}),Ar(Array.from(e).filter(Boolean).join(" "),t)}function Dy(t){var e=t.originalValue;t.mutations.forEach(function(i){return e=i.mutate(e)}),Ar(e,t)}function Ny(t){var e=t.parentSelector,i=t.insertBeforeSelector,s=document.querySelector(e);if(!s)return null;var r=i?document.querySelector(i):null;return i&&!r?null:{parentNode:s,insertBeforeNode:r}}function Ly(t){var e=t.originalValue;t.mutations.forEach(function(i){var s=i.mutate(),r=Ny(s);e=r||e}),Ar(e,t)}function id(t){var e=kr(t);return e.html||(e.html=wr(t,"html",$y,Fy,Cy)),e.html}function sd(t){var e=kr(t);return e.position||(e.position=wr(t,"position",My,Uy,Ly)),e.position}function rd(t){var e=kr(t);return e.classes||(e.classes=wr(t,"class",Vy,By,xy)),e.classes}function nd(t,e){var i=kr(t);return i.attributes[e]||(i.attributes[e]=wr(t,e,Gy(e),qy(e),Dy)),i.attributes[e]}function jy(t,e){var i=Sr.get(t);if(i)if(e==="html"){var s,r;(s=i.html)==null||(r=s.observer)==null||r.disconnect(),delete i.html}else if(e==="class"){var n,o;(n=i.classes)==null||(o=n.observer)==null||o.disconnect(),delete i.classes}else if(e==="position"){var a,l;(a=i.position)==null||(l=a.observer)==null||l.disconnect(),delete i.position}else{var u,c,h;(u=i.attributes)==null||(c=u[e])==null||(h=c.observer)==null||h.disconnect(),delete i.attributes[e]}}function Hy(t){return yr||(yr=document.createElement("div")),yr.innerHTML=t,yr.innerHTML}function br(t,e,i){if(i.isDirty){i.isDirty=!1;var s=i.virtualValue;i.mutations.length||jy(t,e),i.setValue(t,s)}}function zy(t,e){t.html&&br(e,"html",t.html),t.classes&&br(e,"class",t.classes),t.position&&br(e,"position",t.position),Object.keys(t.attributes).forEach(function(i){br(e,i,t.attributes[i])})}function ed(){Sr.forEach(zy)}function Ky(t,e){var i=null;t.kind==="html"?i=id(e):t.kind==="class"?i=rd(e):t.kind==="attribute"?i=nd(e,t.attribute):t.kind==="position"&&(i=sd(e)),i&&(i.mutations.push(t),i.mutationRunner(i))}function Wy(t,e){var i=null;if(t.kind==="html"?i=id(e):t.kind==="class"?i=rd(e):t.kind==="attribute"?i=nd(e,t.attribute):t.kind==="position"&&(i=sd(e)),!!i){var s=i.mutations.indexOf(t);s!==-1&&i.mutations.splice(s,1),i.mutationRunner(i)}}function od(t){if(!(t.kind==="position"&&t.elements.size===1)){var e=new Set(t.elements),i=document.querySelectorAll(t.selector);i.forEach(function(s){e.has(s)||(t.elements.add(s),Ky(t,s))})}}function Yy(t){t.elements.forEach(function(e){return Wy(t,e)}),t.elements.clear(),No.delete(t)}function td(){No.forEach(od)}function Xy(){typeof document>"u"||(Co||(Co=new MutationObserver(function(){td()})),td(),Co.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Ir(t){return typeof document>"u"?Do:(No.add(t),od(t),{revert:function(){Yy(t)}})}function xo(t,e){return Ir({kind:"html",elements:new Set,mutate:e,selector:t})}function ad(t,e){return Ir({kind:"position",elements:new Set,mutate:e,selector:t})}function os(t,e){return Ir({kind:"class",elements:new Set,mutate:e,selector:t})}function Er(t,e,i){return Py.test(e)?e==="class"||e==="className"?os(t,function(s){var r=i(Array.from(s).join(" "));s.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return s.add(n)})}):Ir({kind:"attribute",attribute:e,elements:new Set,mutate:i,selector:t}):Do}function Jy(t){var e=t.selector,i=t.action,s=t.value,r=t.attribute,n=t.parentSelector,o=t.insertBeforeSelector;if(r==="html"){if(i==="append")return xo(e,function(a){return a+(s??"")});if(i==="set")return xo(e,function(){return s??""})}else if(r==="class"){if(i==="append")return os(e,function(a){s&&a.add(s)});if(i==="remove")return os(e,function(a){s&&a.delete(s)});if(i==="set")return os(e,function(a){a.clear(),s&&a.add(s)})}else if(r==="position"){if(i==="set"&&n)return ad(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(i==="append")return Er(e,r,function(a){return a!==null?a+(s??""):s??""});if(i==="set")return Er(e,r,function(){return s??""});if(i==="remove")return Er(e,r,function(){return null})}return Do}var Py,Do,Sr,No,$y,Fy,My,Uy,By,Vy,Gy,qy,yr,Co,Qy,ld,ud=Ue(()=>{"use strict";Py=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Do={revert:function(){}},Sr=new Map,No=new Set;$y=function(e){return e.innerHTML},Fy=function(e,i){return e.innerHTML=i};My=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Uy=function(e,i){i.insertBeforeNode&&!i.parentNode.contains(i.insertBeforeNode)||i.parentNode.insertBefore(e,i.insertBeforeNode)};By=function(e,i){return i?e.className=i:e.removeAttribute("class")},Vy=function(e){return e.className};Gy=function(e){return function(i){var s;return(s=i.getAttribute(e))!=null?s:null}},qy=function(e){return function(i,s){return s!==null?i.setAttribute(e,s):i.removeAttribute(e)}};Xy();Qy={html:xo,classes:os,attribute:Er,position:ad,declarative:Jy},ld=Qy});function $t(t,e,i){i=i||{};for(let[s,r]of Object.entries(e))switch(s){case"$or":if(!hd(t,r,i))return!1;break;case"$nor":if(hd(t,r,i))return!1;break;case"$and":if(!sb(t,r,i))return!1;break;case"$not":if($t(t,r,i))return!1;break;default:if(!as(r,Zy(t,s),i))return!1}return!0}function Zy(t,e){let i=e.split("."),s=t;for(let r=0;r<i.length;r++)if(s&&typeof s=="object"&&i[r]in s)s=s[i[r]];else return null;return s}function cd(t,e=!1){let i=`${t}${e?"/i":""}`;return Lo[i]||(Lo[i]=new RegExp(t.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Lo[i]}function as(t,e,i,s=!1){if(typeof t=="string")return s?String(e).toLowerCase()===t.toLowerCase():e+""===t;if(typeof t=="number")return e*1===t;if(typeof t=="boolean")return e!==null&&!!e===t;if(t===null)return e===null;if(Array.isArray(t)||!gd(t))return JSON.stringify(e)===JSON.stringify(t);for(let r in t)if(!ib(r,e,t[r],i))return!1;return!0}function gd(t){let e=Object.keys(t);return e.length>0&&e.filter(i=>i[0]==="$").length===e.length}function eb(t){if(t===null)return"null";if(Array.isArray(t))return"array";let e=typeof t;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function tb(t,e,i){if(!Array.isArray(t))return!1;let s=gd(e)?r=>as(e,r,i):r=>$t(r,e,i);for(let r=0;r<t.length;r++)if(t[r]&&s(t[r]))return!0;return!1}function Si(t,e,i=!1){if(i){let s=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(t)?t.some(r=>e.some(n=>s(r)===s(n))):e.some(r=>s(t)===s(r))}return Array.isArray(t)?t.some(s=>e.includes(s)):e.includes(t)}function dd(t,e,i,s=!1){if(!Array.isArray(t))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<t.length;o++)if(as(e[r],t[o],i,s)){n=!0;break}if(!n)return!1}return!0}function ib(t,e,i,s){switch(t){case"$veq":return ze(e)===ze(i);case"$vne":return ze(e)!==ze(i);case"$vgt":return ze(e)>ze(i);case"$vgte":return ze(e)>=ze(i);case"$vlt":return ze(e)<ze(i);case"$vlte":return ze(e)<=ze(i);case"$eq":return e===i;case"$ne":return e!==i;case"$lt":return e<i;case"$lte":return e<=i;case"$gt":return e>i;case"$gte":return e>=i;case"$exists":return i?e!=null:e==null;case"$in":return Array.isArray(i)?Si(e,i):!1;case"$ini":return Array.isArray(i)?Si(e,i,!0):!1;case"$inGroup":return Si(e,s[i]||[]);case"$notInGroup":return!Si(e,s[i]||[]);case"$nin":return Array.isArray(i)?!Si(e,i):!1;case"$nini":return Array.isArray(i)?!Si(e,i,!0):!1;case"$not":return!as(i,e,s);case"$size":return Array.isArray(e)?as(i,e.length,s):!1;case"$elemMatch":return tb(e,i,s);case"$all":return Array.isArray(i)?dd(e,i,s):!1;case"$alli":return Array.isArray(i)?dd(e,i,s,!0):!1;case"$regex":try{return cd(i).test(e)}catch{return!1}case"$regexi":try{return cd(i,!0).test(e)}catch{return!1}case"$type":return eb(e)===i;default:return console.error("Unknown operator: "+t),!1}}function hd(t,e,i){if(!e.length)return!0;for(let s=0;s<e.length;s++)if($t(t,e[s],i))return!0;return!1}function sb(t,e,i){for(let s=0;s<e.length;s++)if(!$t(t,e[s],i))return!1;return!0}var Lo,fd=Ue(()=>{"use strict";rs();Lo={}});function ob(t){let e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach((i,s)=>e.set(s,i)),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach((i,s)=>e.set(s,i)),e}function ab(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}async function ki(t){try{await t()}catch{}}function pd(t,e,i){if(t.user.trackedExperiments){let r=Pr(e,i);if(t.user.trackedExperiments.has(r))return[];t.user.trackedExperiments.add(r)}t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({experiment:e,result:i,timestamp:Date.now().toString(),logType:"experiment"});let s=[];if(t.global.trackingCallback){let r=t.global.trackingCallback;s.push(ki(()=>r(e,i,t.user)))}if(t.user.trackingCallback){let r=t.user.trackingCallback;s.push(ki(()=>r(e,i)))}if(t.global.eventLogger){let r=t.global.eventLogger;s.push(ki(()=>r(nb,{experimentId:e.key,variationId:i.key,hashAttribute:i.hashAttribute,hashValue:i.hashValue},t.user)))}return s}function lb(t,e,i){if(t.user.trackedFeatureUsage){let s=JSON.stringify(i.value);if(t.user.trackedFeatureUsage[e]===s)return;t.user.trackedFeatureUsage[e]=s,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:i,timestamp:Date.now().toString(),logType:"feature"})}if(t.global.onFeatureUsage){let s=t.global.onFeatureUsage;ki(()=>s(e,i,t.user))}if(t.user.onFeatureUsage){let s=t.user.onFeatureUsage;ki(()=>s(e,i))}if(t.global.eventLogger){let s=t.global.eventLogger;ki(()=>s(rb,{feature:e,source:i.source,value:i.value,ruleId:i.source==="defaultValue"?"$default":i.ruleId||"",variationId:i.experimentResult?i.experimentResult.key:""},t.user))}}function Tr(t,e){if(e.stack.evaluatedFeatures.has(t))return Ft(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;let i=ob(e);if(i.has(t))return Ft(e,t,i.get(t),"override");if(!e.global.features||!e.global.features[t])return Ft(e,t,null,"unknownFeature");let s=e.global.features[t];if(s.rules){let r=new Set(e.stack.evaluatedFeatures);e:for(let n of s.rules){if(n.parentConditions)for(let l of n.parentConditions){e.stack.evaluatedFeatures=new Set(r);let u=Tr(l.id,e);if(u.source==="cyclicPrerequisite")return Ft(e,t,null,"cyclicPrerequisite");let c={value:u.value};if(!$t(c,l.condition||{})){if(l.gate)return Ft(e,t,null,"prerequisite");continue e}}if(n.filters&&md(n.filters,e))continue;if("force"in n){if(n.condition&&!_d(n.condition,e)||!ub(e,n.seed||t,n.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0,n.range,n.coverage,n.hashVersion))continue;return n.tracks&&n.tracks.forEach(l=>{!pd(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),Ft(e,t,n.force,"force",n.id)}if(!n.variations)continue;let o={variations:n.variations,key:n.key||t};"coverage"in n&&(o.coverage=n.coverage),n.weights&&(o.weights=n.weights),n.hashAttribute&&(o.hashAttribute=n.hashAttribute),n.fallbackAttribute&&(o.fallbackAttribute=n.fallbackAttribute),n.disableStickyBucketing&&(o.disableStickyBucketing=n.disableStickyBucketing),n.bucketVersion!==void 0&&(o.bucketVersion=n.bucketVersion),n.minBucketVersion!==void 0&&(o.minBucketVersion=n.minBucketVersion),n.namespace&&(o.namespace=n.namespace),n.meta&&(o.meta=n.meta),n.ranges&&(o.ranges=n.ranges),n.name&&(o.name=n.name),n.phase&&(o.phase=n.phase),n.seed&&(o.seed=n.seed),n.hashVersion&&(o.hashVersion=n.hashVersion),n.filters&&(o.filters=n.filters),n.condition&&(o.condition=n.condition);let{result:a}=Rr(o,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return Ft(e,t,a.value,"experiment",n.id,o,a)}}return Ft(e,t,s.defaultValue===void 0?null:s.defaultValue,"defaultValue")}function Rr(t,e,i){let s=t.key,r=t.variations.length;if(r<2)return{result:le(i,t,-1,!1,e)};if(i.global.enabled===!1||i.user.enabled===!1)return{result:le(i,t,-1,!1,e)};if(t=cb(t,i),t.urlPatterns&&!fr(i.user.url||"",t.urlPatterns))return{result:le(i,t,-1,!1,e)};let n=Vc(s,i.user.url||"",r);if(n!==null)return{result:le(i,t,n,!1,e)};let o=ab(i);if(s in o){let m=o[s];return{result:le(i,t,m,!1,e)}}if(t.status==="draft"||t.active===!1)return{result:le(i,t,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Jt(i,t.hashAttribute,i.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!l)return{result:le(i,t,-1,!1,e)};let u=-1,c=!1,h=!1;if(i.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{variation:m,versionIsBlocked:y}=gb({ctx:i,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});c=m>=0,u=m,h=!!y}if(!c){if(t.filters){if(md(t.filters,i))return{result:le(i,t,-1,!1,e)}}else if(t.namespace&&!Mc(l,t.namespace))return{result:le(i,t,-1,!1,e)};if(t.include&&!Gc(t.include))return{result:le(i,t,-1,!1,e)};if(t.condition&&!_d(t.condition,i))return{result:le(i,t,-1,!1,e)};if(t.parentConditions){let m=new Set(i.stack.evaluatedFeatures);for(let y of t.parentConditions){i.stack.evaluatedFeatures=new Set(m);let w=Tr(y.id,i);if(w.source==="cyclicPrerequisite")return{result:le(i,t,-1,!1,e)};let R={value:w.value};if(!$t(R,y.condition||{}))return{result:le(i,t,-1,!1,e)}}}if(t.groups&&!hb(t.groups,i))return{result:le(i,t,-1,!1,e)}}if(t.url&&!db(t.url,i))return{result:le(i,t,-1,!1,e)};let f=is(t.seed||s,l,t.hashVersion||1);if(f===null)return{result:le(i,t,-1,!1,e)};if(!c){let m=t.ranges||Bc(r,t.coverage===void 0?1:t.coverage,t.weights);u=Uc(f,m)}if(h)return{result:le(i,t,-1,!1,e,void 0,!0)};if(u<0)return{result:le(i,t,-1,!1,e)};if("force"in t)return{result:le(i,t,t.force===void 0?-1:t.force,!1,e)};if(i.global.qaMode||i.user.qaMode)return{result:le(i,t,-1,!1,e)};if(t.status==="stopped")return{result:le(i,t,-1,!1,e)};let g=le(i,t,u,!0,e,f,c);if(i.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{changed:m,key:y,doc:w}=pb(i,a,ss(l),{[$o(t.key,t.bucketVersion)]:g.key});m&&(i.user.stickyBucketAssignmentDocs=i.user.stickyBucketAssignmentDocs||{},i.user.stickyBucketAssignmentDocs[y]=w,i.user.saveStickyBucketAssignmentDoc(w))}let p=pd(i,t,g);p.length===0&&i.global.saveDeferredTrack&&i.global.saveDeferredTrack({experiment:t,result:g});let v=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in t&&t.changeId&&i.global.recordChangeId&&i.global.recordChangeId(t.changeId),{result:g,trackingCall:v}}function Ft(t,e,i,s,r,n,o){let a={value:i,on:!!i,off:!i,source:s,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),s!=="override"&&lb(t,e,a),a}function vd(t){return{...t.user.attributes,...t.user.attributeOverrides}}function _d(t,e){return $t(vd(e),t,e.global.savedGroups||{})}function md(t,e){return t.some(i=>{let{hashValue:s}=Jt(e,i.attribute);if(!s)return!0;let r=is(i.seed,s,i.hashVersion||2);return r===null?!0:!i.ranges.some(n=>gr(r,n))})}function ub(t,e,i,s,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=Jt(t,i,s);if(!a)return!1;let l=is(e,a,o||1);return l===null?!1:r?gr(l,r):n!==void 0?l<=n:!0}function le(t,e,i,s,r,n,o){let a=!0;(i<0||i>=e.variations.length)&&(i=0,a=!1);let{hashAttribute:l,hashValue:u}=Jt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),c=e.meta?e.meta[i]:{},h={key:c.key||""+i,featureId:r,inExperiment:a,hashUsed:s,variationId:i,value:e.variations[i],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};return c.name&&(h.name=c.name),n!==void 0&&(h.bucket=n),c.passthrough&&(h.passthrough=c.passthrough),h}function cb(t,e){let i=t.key,s=e.global.overrides;return s&&s[i]&&(t=Object.assign({},t,s[i]),typeof t.url=="string"&&(t.url=wo(t.url))),t}function Jt(t,e,i){let s=e||"id",r="",n=vd(t);return n[s]&&(r=n[s]),!r&&i&&(n[i]&&(r=n[i]),r&&(s=i)),{hashAttribute:s,hashValue:r}}function db(t,e){let i=e.user.url;if(!i)return!1;let s=i.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(t.test(i)||t.test(s))}function hb(t,e){let i=e.global.groups||{};for(let s=0;s<t.length;s++)if(i[t[s]])return!0;return!1}function gb({ctx:t,expKey:e,expBucketVersion:i,expHashAttribute:s,expFallbackAttribute:r,expMinBucketVersion:n,expMeta:o}){i=i||0,n=n||0,s=s||"id",o=o||[];let a=$o(e,i),l=fb(t,s,r);if(n>0)for(let h=0;h<n;h++){let f=$o(e,h);if(l[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let u=l[a];if(u===void 0)return{variation:-1};let c=o.findIndex(h=>h.key===u);return c<0?{variation:-1}:{variation:c}}function $o(t,e){return e=e||0,`${t}__${e}`}function Fo(t,e){return`${t}||${e}`}function fb(t,e,i){if(!t.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:s,hashValue:r}=Jt(t,e),n=Fo(s,ss(r)),{hashAttribute:o,hashValue:a}=Jt(t,i),l=a?Fo(o,ss(a)):null,u={};return l&&t.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[l].assignments||{}),t.user.stickyBucketAssignmentDocs[n]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[n].assignments||{}),u}function pb(t,e,i,s){let r=Fo(e,i),n=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[r]?t.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o={...n,...s},a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:i,assignments:o},changed:a}}function vb(t,e){let i=new Set,s=e&&e.features?e.features:t.global.features||{},r=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(s).forEach(n=>{let o=s[n];if(o.rules)for(let a of o.rules)a.variations&&(i.add(a.hashAttribute||"id"),a.fallbackAttribute&&i.add(a.fallbackAttribute))}),r.map(n=>{i.add(n.hashAttribute||"id"),n.fallbackAttribute&&i.add(n.fallbackAttribute)}),Array.from(i)}async function yd(t,e,i){let s=Mo(t,i);return e.getAllAssignments(s)}function Mo(t,e){let i={};return vb(t,e).forEach(r=>{let{hashValue:n}=Jt(t,r);i[r]=ss(n)}),i}async function bd(t,e,i){if(t={...t},t.encryptedFeatures){try{t.features=JSON.parse(await Xt(t.encryptedFeatures,e,i))}catch(s){console.error(s)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await Xt(t.encryptedExperiments,e,i))}catch(s){console.error(s)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await Xt(t.encryptedSavedGroups,e,i))}catch(s){console.error(s)}delete t.encryptedSavedGroups}return t}function Ed(t){let e=t.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(t.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}function Pr(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}var rb,nb,Sd=Ue(()=>{"use strict";fd();rs();rb="Feature Evaluated",nb="Experiment Viewed"});var wi,_b,ls,kd=Ue(()=>{"use strict";ud();rs();Zc();Sd();wi=typeof window<"u"&&typeof document<"u",_b=qc(),ls=class{constructor(e){if(e=e||{},this.version=_b,this._options=this.context=e,this._renderer=e.renderer||null,this._trackedExperiments=new Set,this._completedChangeIds=new Set,this._trackedFeatures={},this.debug=!!e.debug,this._subscriptions=new Set,this.ready=!1,this._assigned=new Map,this._activeAutoExperiments=new Map,this._triggeredExpKeys=new Set,this._initialized=!1,this._redirectedUrl="",this._deferredTrackingCalls=new Map,this._autoExperimentsAllowed=!e.disableExperimentsOnLoad,this._destroyCallbacks=[],this.logs=[],this.log=this.log.bind(this),this._saveDeferredTrack=this._saveDeferredTrack.bind(this),this._onExperimentEval=this._onExperimentEval.bind(this),this._fireSubscriptions=this._fireSubscriptions.bind(this),this._recordChangedId=this._recordChangedId.bind(this),e.remoteEval){if(e.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!e.clientKey)throw new Error("Missing clientKey");let i=!1;try{i=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(i)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(e.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(e.stickyBucketService){let i=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=s=>i.saveAssignments(s)}if(e.plugins)for(let i of e.plugins)i(this);if(e.features&&(this.ready=!0),wi&&e.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),e.experiments&&(this.ready=!0,this._updateAllAutoExperiments()),this._options.stickyBucketService&&this._options.stickyBucketAssignmentDocs)for(let i in this._options.stickyBucketAssignmentDocs){let s=this._options.stickyBucketAssignmentDocs[i];s&&this._options.stickyBucketService.saveAssignments(s).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let i=await bd(e,this._options.decryptionKey);this._decryptedPayload=i,await this.refreshStickyBuckets(i),i.features&&(this._options.features=i.features),i.savedGroups&&(this._options.savedGroups=i.savedGroups),i.experiments&&(this._options.experiments=i.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let i=e.payload;if(i.encryptedExperiments||i.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this._options.stickyBucketService&&!this._options.stickyBucketAssignmentDocs&&(this._options.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this._options.stickyBucketService,i)),this._payload=i,this._decryptedPayload=i,i.features&&(this._options.features=i.features),i.experiments&&(this._options.experiments=i.experiments,this._updateAllAutoExperiments()),this.ready=!0,mr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Kc(e.cacheSettings),e.payload)return await this.setPayload(e.payload),mr(this,e),{success:!0,source:"init"};{let{data:i,...s}=await this._refresh({...e,allowStale:!0});return mr(this,e),await this.setPayload(i||{}),s}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let i=await this._refresh({...e||{},allowStale:!1});i.data&&await this.setPayload(i.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return Ed(this._options)}getClientKey(){return this._options.clientKey||""}getPayload(){return this._payload||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this._decryptedPayload||this.getPayload()}isRemoteEval(){return this._options.remoteEval||!1}getCacheKeyAttributes(){return this._options.cacheKeyAttributes}async _refresh({timeout:e,skipCache:i,allowStale:s,streaming:r}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Wc({instance:this,timeout:e,skipCache:i||this._options.disableCache,allowStale:s,backgroundSync:r??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,i,s){let r=await Xt(e,i||this._options.decryptionKey,s);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,i,s){let r=await Xt(e,i||this._options.decryptionKey,s);this.setExperiments(JSON.parse(r))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(i=>{try{i()}catch(s){console.error(s)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,Yc(this),e.destroyAllStreams&&Oo(),this.logs=[],wi&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(i=>{i.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,i){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=i,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:i}=Rr(e,null,this._getEvalContext());return this._onExperimentEval(e,i),i}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(s=>s.key===e).map(s=>this._runAutoExperiment(s)).filter(s=>s!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,i){let s=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!s)return null;let r=this._isAutoExperimentBlockedByContext(e),n,o;r?n=le(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=Rr(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!i&&n.inExperiment&&s&&s.valueHash===a)return n;if(s&&this._undoActiveAutoExperiment(e),n.inExperiment){let l=pr(e);if(l==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let u=e.persistQueryString?jc(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(fr(u,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=u;let{navigate:c,delay:h}=this._getNavigateFunction();if(c)if(wi)Promise.all([...o?[vr(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??h))]).then(()=>{try{c(u)}catch(f){console.error(f)}});else try{c(u)}catch(f){console.error(f)}}else if(l==="visual"){let u=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(n.value):this._applyDOMChanges(n.value);u&&this._activeAutoExperiments.set(e,{undo:u,valueHash:a})}}return n}_undoActiveAutoExperiment(e){let i=this._activeAutoExperiments.get(e);i&&(i.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let i=this._options.experiments||[],s=new Set(i);this._activeAutoExperiments.forEach((r,n)=>{s.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of i){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&pr(r)==="redirect")break}}_onExperimentEval(e,i){let s=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:i}),this._subscriptions.size>0&&this._fireSubscriptions(e,i,s)}_fireSubscriptions(e,i,s){(!s||s.result.inExperiment!==i.inExperiment||s.result.variationId!==i.variationId)&&this._subscriptions.forEach(r=>{try{r(e,i)}catch(n){console.error(n)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,i){let s=this.evalFeature(e).value;return s===null?i:s}feature(e){return this.evalFeature(e)}evalFeature(e){return Tr(e,this._getEvalContext())}log(e,i){this.debug&&(this._options.log?this._options.log(e,i):console.log(e,i))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(i=>i&&i.experiment&&i.result).map(i=>[Pr(i.experiment,i.result),i]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(i=>{!i||!i.experiment||!i.result?console.error("Invalid deferred tracking call",{call:i}):e.push(this._options.trackingCallback(i.experiment,i.result))}),this._deferredTrackingCalls.clear(),await Promise.all(e)}setTrackingCallback(e){this._options.trackingCallback=e,this.fireDeferredTrackingCalls()}setFeatureUsageCallback(e){this._options.onFeatureUsage=e}setEventLogger(e){this._options.eventLogger=e}async logEvent(e,i){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:i,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,i||{},this._getUserContext())}catch(s){console.error(s)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Pr(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(wi?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let i=pr(e);if(i==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(s=>s.js))return!0}else if(i==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let s=new URL(this._getContextUrl());for(let r of e.variations){if(!r||!r.urlRedirect)continue;let n=new URL(r.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(n.protocol!==s.protocol||n.host!==s.host))return!0}}catch(s){return this.log("Error parsing current or redirect URL",{id:e.key,error:s}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:wi?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!wi)return;let i=[];if(e.css){let s=document.createElement("style");s.innerHTML=e.css,document.head.appendChild(s),i.push(()=>s.remove())}if(e.js){let s=document.createElement("script");s.innerHTML=e.js,this._options.jsInjectionNonce&&(s.nonce=this._options.jsInjectionNonce),document.head.appendChild(s),i.push(()=>s.remove())}return e.domMutations&&e.domMutations.forEach(s=>{i.push(ld.declarative(s).revert)}),()=>{i.forEach(s=>s())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let i=this._getEvalContext(),s=await yd(i,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=s}}generateStickyBucketAssignmentDocsSync(e,i){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let s=this._getEvalContext(),r=Mo(s,i);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var wd=Ue(()=>{"use strict";kd()});var Ad={};Sn(Ad,{Growthbook:()=>Uo});var Je,Uo,Id=Ue(()=>{"use strict";wd();yo();Zi();ts();Je=class Je{constructor(e,i,s={},r=!1){this.analytics=new pi;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Lt("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:i,user_language:s,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:u,url:c,domain:h,utm_content:f,residence_country:g,loggedIn:p,network_type:v,network_downlink:m,user_id:y,anonymous_id:w,account_mode:R})=>{let b={...this.GrowthBook.getAttributes(),id:e,...y!==void 0&&{user_id:y},...w!==void 0&&{anonymous_id:w},...i!==void 0&&{country:i},...g!==void 0&&{residence_country:g},...s!==void 0&&{user_language:s},...r!==void 0&&{device_language:r},...n!==void 0&&{device_type:n},...o!==void 0&&{utm_source:o},...a!==void 0&&{utm_medium:a},...l!==void 0&&{utm_campaign:l},...u!==void 0&&{is_authorised:u},...c!==void 0&&{url:c},...h!==void 0&&{domain:h},...f!==void 0&&{utm_content:f},...p!==void 0&&{loggedIn:p},...v!==void 0&&{network_type:v},...m!==void 0&&{network_downlink:m},...R!==void 0&&{account_mode:R}};this.log("setAttributes | updating GrowthBook attributes",b),this.GrowthBook.setAttributes(b)};this.getFeatureValue=(e,i)=>{let s=this.GrowthBook.getFeatureValue(e,i);return this.log("getFeatureValue",{key:e,value:s,defaultValue:i}),s};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let i=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:i}),i};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let i=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:i}),i};this.init=async()=>{this.log("init | initializing GrowthBook SDK");let e=await this.GrowthBook.init({timeout:2e3,streaming:!0}).catch(()=>{});this.status=e,this.isLoaded=!0,this.log("init | GrowthBook SDK loaded",{status:e})};this.destroy=()=>{this.GrowthBook.destroy(),this.isLoaded=!1,this.status=void 0};this.debug=r;let n=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new ls({apiHost:yc,clientKey:e,decryptionKey:i,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:n,trackingCallback:(o,a)=>{this.log("trackingCallback | experiment viewed",{experiment_id:o.key,variation_id:a.variationId}),typeof window<"u"&&window.dataLayer&&window.dataLayer.push({event:"experiment_viewed",event_category:"experiment",rudder_anonymous_id:this.analytics.getAnonymousId(),experiment_id:o.key,variation_id:a.variationId}),this.analytics.track("experiment_viewed",{experimentId:o.key,variationId:a.variationId})},...s}),this.init()}reapplyExperiment(e){let i=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(i)}waitForIsLoaded(e=1e4){return new Promise((i,s)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),i()):Date.now()-r>=e&&(clearInterval(n),s(new Error("GrowthBook initialization timeout")))},100)})}};Je.getGrowthBookInstance=(e,i,s,r=!1)=>Je._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),Je._instance):(Je._instance=new Je(e,i??"",s,r),Je._instance),Je.resetInstance=()=>{Je._instance&&(Je._instance.destroy(),Je._instance=void 0)};Uo=Je});function Pd(t,e,i,s,r,n,o){try{var a=t[n](o),l=a.value}catch(u){return void i(u)}a.done?e(l):Promise.resolve(l).then(s,r)}function Ze(t){return function(){var e=this,i=arguments;return new Promise((function(s,r){var n=t.apply(e,i);function o(l){Pd(n,s,r,o,a,"next",l)}function a(l){Pd(n,s,r,o,a,"throw",l)}o(void 0)}))}}function S(){return S=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var s in i)({}).hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},S.apply(null,arguments)}function Sh(t,e){if(t==null)return{};var i={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(e.indexOf(s)!==-1)continue;i[s]=t[s]}return i}function ua(){return ua=Ze((function*(t,e,i){e===void 0&&(e=!0);try{var s=new CompressionStream("gzip"),r=s.writable.getWriter(),n=r.write(new TextEncoder().encode(t)).then((()=>r.close())).catch((function(){var l=Ze((function*(u){try{yield r.abort(u)}catch{}throw u}));return function(u){return l.apply(this,arguments)}})()),o=new Response(s.readable).blob(),[a]=yield Promise.all([o,n]);return a}catch(l){if(i!=null&&i.rethrow)throw l;return e&&console.error("Failed to gzip compress data",l),null}})),ua.apply(this,arguments)}function z(t,e){return t.indexOf(e)!==-1}function Ah(t){return t===null||typeof t!="object"}function qr(t,e){return{}.toString.call(t)==="[object "+e+"]"}function bl(t){return typeof Event<"u"&&(function(e,i){try{return e instanceof i}catch{return!1}})(t,Event)}function ft(t,e,i,s,r){return e>i&&(s.warn("min cannot be greater than max."),e=i),tt(t)?t>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(s.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),ft(r||i,e,i,s))}function qh(t){if(gt(t))return{boolValue:t};if(typeof t=="number")return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if(typeof t=="string")return{stringValue:t};if(Y(t))return{arrayValue:{values:t.map((e=>qh(e)))}};try{return{stringValue:JSON.stringify(t)}}catch{return{stringValue:String(t)}}}function Ld(t){var e=[];for(var i in t){var s=t[i];Ot(s)||P(s)||e.push({key:i,value:qh(s)})}return e}function $b(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return Vo&&i.length===Cd||(Cd=i.length,Vo=i.reduce(((s,r)=>{Or||(Or={});var n=Or[r];if(n)s[n[0]]=n[1];else for(var o=t(r),a=o.length-1;a>=0;a--){var l=o[a],u=l?.filename,c=e[r];if(u&&c){s[u]=c,Or[r]=[u,c];break}}return s}),{})),Vo}}function va(t,e,i,s,r){var n={platform:t,filename:e,function:i==="<anonymous>"?Bi:i,in_app:!0};return P(s)||(n.lineno=s),P(r)||(n.colno=r),n}function Hh(t,e){e===void 0&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(e>=r.length)return s===i.length?r:r.length>e?r.slice(0,e)+"...":r}return""}function Kr(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:qo.enabled,max_bytes:Kb(t.max_bytes,qo.max_bytes)}:S({},qo)}function Kb(t,e){if(!tt(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}function xr(t,e){Y(t)&&t.forEach(e)}function oe(t,e){if(!K(t))if(Y(t))t.forEach(e);else if(Eb(t))t.forEach(((s,r)=>e(s,r)));else for(var i in t)wh.call(t,i)&&e(t[i],i)}function Vr(t){for(var e=Object.keys(t),i=e.length,s=new Array(i);i--;)s[i]=[e[i],t[e[i]]];return s}function Jb(t){var e=t?.hostname;if(!ge(e))return!1;var i=e.split(".").slice(-2).join(".");for(var s of Xb)if(i===s)return!1;return!0}function be(t,e,i,s){var{capture:r=!1,passive:n=!0}=s??{};t?.addEventListener(e,i,{capture:r,passive:n})}function ig(t){return t.name==="ph_toolbar_internal"}function ng(t,e){var{organization:i,projectId:s,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,u,c,h,f;if(n!=="*"&&!n.includes(a.level)||!t.__loaded)return a;a.tags||(a.tags={});var g=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());a.tags["PostHog Person URL"]=g,t.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var p,v=((l=a.exception)==null?void 0:l.values)||[],m=v.map((w=>S({},w,{stacktrace:w.stacktrace?S({},w.stacktrace,{type:"raw",frames:(w.stacktrace.frames||[]).map((R=>S({},R,{platform:"web:javascript"})))}):void 0}))),y={$exception_message:((u=v[0])==null?void 0:u.value)||a.message,$exception_type:(c=v[0])==null?void 0:c.type,$exception_level:a.level,$exception_list:m,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=v[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(f=v[0])==null?void 0:f.type,$sentry_tags:a.tags};return i&&s&&(y.$sentry_url=(r||"https://sentry.io/organizations/")+i+"/issues/?project="+s+"&query="+a.event_id),o&&((p=t.exceptions)==null||p.sendExceptionEvent(y)),a}}function og(t,e,i){if(!I)return{};var s,r=e?[...Vi,...i||[]]:[],n=ag(xs(I.URL,r,Ds),t),o=(s={},oe(aE,(function(a){var l=ht.A(a);s[a]=l||null})),s);return pe(o,n)}function ag(t,e){var i=oE.concat(e||[]),s={};return oe(i,(function(r){var n=nn(t,r);s[r]=n||null})),s}function lg(t){var e=(function(n){return n?n.search(Lr+"google.([^/?]*)")===0?"google":n.search(Lr+"bing.com")===0?"bing":n.search(Lr+"yahoo.com")===0?"yahoo":n.search(Lr+"duckduckgo.com")===0?"duckduckgo":null:null})(t),i=e!="yahoo"?"q":"p",s={};if(!Ot(e)){s.$search_engine=e;var r=I?nn(I.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function Bd(){return navigator.language||navigator.userLanguage}function ug(){return I?.referrer||an}function cg(t,e){var i=t?[...Vi,...e||[]]:[],s=Re?.href.substring(0,1e3);return{r:ug().substring(0,1e3),u:s?xs(s,i,Ds):void 0}}function dg(t){var e,{r:i,u:s}=t,r={$referrer:i,$referring_domain:i==null?void 0:i==an?an:(e=rn(i))==null?void 0:e.host};if(s){r.$current_url=s;var n=rn(s);r.$host=n?.host,r.$pathname=n?.pathname;var o=ag(s);pe(r,o)}if(i){var a=lg(i);pe(r,a)}return r}function hg(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function lE(){try{return new Date().getTimezoneOffset()}catch{return}}function pE(t,e){e===void 0&&(e={});var i=(function(){var h=4294967295;return{p(f){for(var g=h,p=0;f.length>p;++p)g=fE[255&g^f[p]]^g>>>8;h=g},d(){return 4294967295^h}}})(),s=t.length;i.p(t);var r,n,o,a,l,u=(a=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(h,f,g,p,v,m){var y=h.length,w=new et(p+y+5*(1+Math.floor(y/7e3))+v),R=w.subarray(p,w.length-v),D=0;if(!f||8>y)for(var b=0;y>=b;b+=65535){var x=b+65535;y>x?D=il(R,D,h.subarray(b,x)):(R[b]=!0,D=il(R,D,h.subarray(b,y)))}else{for(var C=gE[f-1],O=C>>>13,A=8191&C,$=(1<<g)-1,U=new Fe(32768),H=new Fe($+1),G=Math.ceil(g/3),q=2*G,me=function(En){return(h[En]^h[En+1]<<G^h[En+2]<<q)&$},Se=new Gi(25e3),Me=new Fe(288),ke=new Fe(32),k=0,M=0,F=(b=0,0),B=0,Z=0;y>b;++b){var ce=me(b),se=32767&b,ye=H[ce];if(U[se]=ye,H[ce]=se,b>=B){var Oe=y-b;if((k>7e3||F>24576)&&Oe>423){D=Hd(h,R,0,Se,Me,ke,M,F,Z,b-Z,D),F=k=M=0,Z=b;for(var we=0;286>we;++we)Me[we]=0;for(we=0;30>we;++we)ke[we]=0}var j=2,pt=0,Lg=A,Ct=se-ye&32767;if(Oe>2&&ce==me(b-Ct))for(var $g=Math.min(O,Oe)-1,Fg=Math.min(32767,b),Mg=Math.min(258,Oe);Fg>=Ct&&--Lg&&se!=ye;){if(h[b+j]==h[b+j-Ct]){for(var xt=0;Mg>xt&&h[b+xt]==h[b+xt-Ct];++xt);if(xt>j){if(j=xt,pt=Ct,xt>$g)break;var Ug=Math.min(Ct,xt-2),Nl=0;for(we=0;Ug>we;++we){var bn=b-Ct+we+32768&32767,Ll=bn-U[bn]+32768&32767;Ll>Nl&&(Nl=Ll,ye=bn)}}}Ct+=(se=ye)-(ye=U[se])+32768&32767}if(pt){Se[F++]=268435456|Za[j]<<18|el[pt];var $l=31&Za[j],Fl=31&el[pt];M+=Pl[$l]+Ol[Fl],++Me[257+$l],++ke[Fl],B=b+j,++k}else Se[F++]=h[b],++Me[h[b]]}}D=Hd(h,R,!0,Se,Me,ke,M,F,Z,b-Z,D)}return vg(w,0,p+pg(D)+v)})(n=t,(o=e).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),c=u.length;return(function(h,f){var g=f.filename;if(h[0]=31,h[1]=139,h[2]=8,h[8]=2>f.level?4:f.level==9?2:0,h[9]=3,f.mtime!=0&&Qo(h,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),g){h[3]=8;for(var p=0;g.length>=p;++p)h[p+10]=g.charCodeAt(p)}})(u,e),Qo(u,c-8,i.d()),Qo(u,c-4,s),u}function Wd(t,e,i){return Li({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:i})}function bg(t,e){return!t||Object.entries(t).every((i=>{var[s,r]=i,n=e?.[s];if(P(n)||Ot(n))return!1;var o=[String(n)],a=yg[r.operator];return!!a&&a(r.values,o)}))}function eh(t){return t instanceof Element&&(t.id===Qh||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function ai(t){return!!t&&t.nodeType===IE}function ot(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function kg(t){return!!t&&t.nodeType===TE}function wg(t){return!!t&&t.nodeType===RE&&ai(t.host)}function Cl(t){return t?vn(t).split(/\s+/):[]}function th(t){var e=_?.location.href;return!!(e&&t&&t.some((i=>e.match(i))))}function fn(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Cl(e)}function Ag(t){return K(t)?null:vn(t).split(/(\s+)/).filter((e=>Ps(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ls(t){var e="";return fl(t)&&!Tg(t)&&t.childNodes&&t.childNodes.length&&oe(t.childNodes,(function(i){var s;kg(i)&&i.textContent&&(e+=(s=Ag(i.textContent))!==null&&s!==void 0?s:"")})),vn(e)}function ih(t){return P(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}function sh(t,e){if(P(e))return!0;var i,s=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of t)if(i=s(r))return i.v;return!1}function Ig(t){var e=t.parentNode;return!(!e||!ai(e))&&e}function fl(t){for(var e=t;e.parentNode&&!ot(e,"body");e=e.parentNode){var i=fn(e);if(z(i,"ph-sensitive")||z(i,"ph-no-capture"))return!1}if(z(fn(t),"ph-include"))return!0;var s=t.type||"";if(ge(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=t.name||t.id||"";return!ge(r)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,""))}function Tg(t){return!!(ot(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ot(t,"select")||ot(t,"textarea")||t.getAttribute("contenteditable")==="true")}function Ps(t,e){return e===void 0&&(e=!0),!(K(t)||ge(t)&&(t=vn(t),(e?OE:CE).test((t||"").replace(/[- ]/g,""))||(e?xE:DE).test(t)))}function oh(t){var e=Ls(t);return Ps(e=(e+" "+Og(t)).trim())?e:""}function Og(t){var e="";return t&&t.childNodes&&t.childNodes.length&&oe(t.childNodes,(function(i){var s;if(i&&((s=i.tagName)==null?void 0:s.toLowerCase())==="span")try{var r=Ls(i);e=(e+" "+r).trim(),i.childNodes&&i.childNodes.length&&(e=(e+" "+Og(i)).trim())}catch(n){T.error("[AutoCapture]",n)}})),e}function ah(t){return t.replace(/"|\\"/g,'\\"')}function NE(t){var e=t.attr__class;return e?Y(e)?e:Cl(e):void 0}function ra(t,e){return e.length>t?e.slice(0,t)+"...":e}function LE(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!ai(e));return e}function $E(t,e){var i,s,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e;if(!ai(t))return{props:{}};for(var u=[t],c=t;c.parentNode&&!ot(c,"body");)if(wg(c.parentNode))u.push(c.parentNode.host),c=c.parentNode.host;else{if(!ai(c.parentNode))break;u.push(c.parentNode),c=c.parentNode}var h,f,g=[],p={},v=!1,m=!1;if(oe(u,(b=>{var x=fl(b);if(ot(b,"a")){var C=b.getAttribute("href");v=x&&!!C&&Ps(C)&&C}z(fn(b),"ph-no-capture")&&(m=!0),g.push((function(A,$,U,H){var G=A.tagName.toLowerCase(),q={tag_name:G};xl.indexOf(G)>-1&&!U&&(q.$el_text=G.toLowerCase()==="a"||G.toLowerCase()==="button"?ra(1024,oh(A)):ra(1024,Ls(A)));var me=fn(A);me.length>0&&(q.classes=me.filter((function(k){return k!==""}))),oe(A.attributes,(function(k){var M;if((!Tg(A)||["name","id","class","aria-label"].indexOf(k.name)!==-1)&&(H==null||!H.includes(k.name))&&!$&&Ps(k.value)&&(!ge(M=k.name)||M.substring(0,10)!=="_ngcontent"&&M.substring(0,7)!=="_nghost")){var F=k.value;k.name==="class"&&(F=Cl(F).join(" ")),q["attr__"+k.name]=ra(1024,F)}}));for(var Se=1,Me=1,ke=A;ke=LE(ke);)Se++,ke.tagName===A.tagName&&Me++;return q.nth_child=Se,q.nth_of_type=Me,q})(b,n,o,a));var O=(function(A){if(!fl(A))return{};var $={};return oe(A.attributes,(function(U){if(U.name&&U.name.indexOf("data-ph-capture-attribute")===0){var H=U.name.replace("data-ph-capture-attribute-",""),G=U.value;H&&G&&Ps(G)&&($[H]=G)}})),$})(b);pe(p,O)})),m)return{props:{},explicitNoCapture:m};if(o||(g[0].$el_text=ot(t,"a")||ot(t,"button")?oh(t):Ls(t)),v){var y,w;g[0].attr__href=v;var R=(y=rn(v))==null?void 0:y.host,D=_==null||(w=_.location)==null?void 0:w.host;R&&D&&R!==D&&(h=v)}return{props:pe({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:(f=g,(function(b){return b.map((x=>{var C,O,A="";if(x.tag_name&&(A+=x.tag_name),x.attr_class)for(var $ of(x.attr_class.sort(),x.attr_class))A+="."+$.replace(/"/g,"");var U=S({},x.text?{text:x.text}:{},{"nth-child":(C=x.nth_child)!==null&&C!==void 0?C:0,"nth-of-type":(O=x.nth_of_type)!==null&&O!==void 0?O:0},x.href?{href:x.href}:{},x.attr_id?{attr_id:x.attr_id}:{},x.attributes),H={};return Vr(U).sort(((G,q)=>{var[me]=G,[Se]=q;return me.localeCompare(Se)})).forEach((G=>{var[q,me]=G;return H[ah(q.toString())]=ah(me.toString())})),(A+=":")+Vr(H).map((G=>{var[q,me]=G;return q+'="'+me+'"'})).join("")})).join(";")})((function(b){return b.map((x=>{var C,O,A={text:(C=x.$el_text)==null?void 0:C.slice(0,400),tag_name:x.tag_name,href:(O=x.attr__href)==null?void 0:O.slice(0,2048),attr_class:NE(x),attr_id:x.attr__id,nth_child:x.nth_child,nth_of_type:x.nth_of_type,attributes:{}};return Vr(x).filter(($=>{var[U]=$;return U.indexOf("attr__")===0})).forEach(($=>{var[U,H]=$;return A.attributes[U]=H})),A}))})(f)))},(i=g[0])!=null&&i.$el_text?{$el_text:(s=g[0])==null?void 0:s.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},p)}}function lh(t,e,i){try{if(!(e in t))return()=>{};var s=t[e],r=i(s);return Tt(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=r,()=>{t[e]=s}}catch{return()=>{}}}function hh(t){return ve(t)&&"clientX"in t&&"clientY"in t&&tt(t.clientX)&&tt(t.clientY)}function Ri(t,e,i){if(K(t))return!1;switch(i){case"exact":return t===e;case"contains":var s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}var _,Ee,Ke,I,Re,aa,la,Td,mb,je,L,Rd,$e,yb,Od,bb,vn,ca,kh,wh,_n,Y,Tt,ve,Di,P,ge,Mr,Ot,K,tt,Pi,gt,Eb,Sb,kb,Bo,wb,da,Or,Cd,Vo,We,jr,Pt,Mi,Ih,Th,Rh,Ph,ws,Ui,Oh,Ch,xh,ri,Ab,Dh,El,Nh,Sl,Ib,kl,Lh,$i,$h,Os,Cs,Fi,Fh,Mh,_s,ha,xd,ga,Uh,Tb,Bh,fa,Le,Go,Rb,Pb,Ob,wl,Cb,Vh,xb,Db,Dd,Nd,Nb,Gh,Lb,pa,Bi,jh,Fb,Mb,Ub,Bb,Vb,Gb,qb,$d,_a,ma,ya,jb,ba,Hb,Ea,Sa,ka,wa,Hr,zr,zb,qo,Aa,zh,T,ue,Wb,jo,Kh,Wr,ms,ys,Ia,Ta,Ra,Pa,Oa,Ca,Al,xa,Da,bs,Wh,Yh,Xh,Jh,Yr,Il,Ni,Ur,Es,Na,La,$a,It,Oi,Ss,ii,Fa,Ma,Br,As,Ua,Ba,Xr,nt,Va,Ga,qa,ja,Jr,Qr,Qh,Cr,Zh,eg,tg,Tl,si,Rt,Ai,Ii,Ha,Zr,en,Ci,Ho,zo,Fd,pe,Md,Yb,Rl,Xb,za,Ka,Ud,sg,Wa,Vt,Qb,us,Zb,ht,Ko,he,eE,Dr,tE,Qt,Pe,Ya,Nr,iE,sE,tn,Wo,rg,Xa,sn,rE,nE,rn,nn,xs,on,Lr,Vi,oE,Ds,aE,an,uE,Is,cs,Yo,ks,Xo,Ja,cE,Vd,Gd,Qa,ds,ln,dt,et,Fe,Gi,Pl,Ol,qd,gg,fg,Za,Zt,el,un,ie,Ts,oi,cn,dE,hE,pg,vg,wt,hs,Jo,tl,jd,gs,il,Hd,gE,fE,Qo,vE,_g,zd,mn,Li,Zo,_E,Kd,Gr,sl,rl,mE,nl,ol,yE,dn,Ns,ea,hn,mg,gn,yg,$r,al,Yd,bE,ll,ee,ul,EE,SE,kE,wE,cl,Ti,Rs,ta,dl,Xd,fs,Jd,Eg,xi,Sg,Qd,AE,Zd,hl,ni,IE,TE,RE,xl,PE,rh,gl,nh,Rg,OE,CE,Pg,xE,DE,pn,ia,sa,ps,FE,Mt,uh,ch,dh,vs,Fr,pl,Ut,ME,gh,UE,Bt,fh,vl,_l,ml,na,ph,BE,vh,_h,Ne,ei,oa,mh,yh,At,bh,VE,yl,Qe,ti,yn,GE,qE,jE,HE,zE,KE,WE,YE,XE,JE,QE,ZE,Eh,_e,Cg=Ue(()=>{"use strict";_=typeof window<"u"?window:void 0,Ee=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(Ee.self=Ee),typeof File>"u"&&(Ee.File=function(){});Ke=Ee?.navigator,I=Ee?.document,Re=Ee?.location,aa=Ee?.fetch,la=Ee!=null&&Ee.XMLHttpRequest&&"withCredentials"in new Ee.XMLHttpRequest?Ee.XMLHttpRequest:void 0,Td=Ee?.AbortController,mb=Ee?.CompressionStream,je=Ke?.userAgent,L=_??{},Rd="1.372.9",$e={DEBUG:!1,LIB_VERSION:Rd,LIB_NAME:"web",JS_SDK_VERSION:Rd};yb=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Od=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var i=t.toLowerCase();return yb.concat(e).some((s=>{var r=s.toLowerCase();return i.indexOf(r)!==-1}))},bb=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];vn=function(t){return t.trim()},ca=function(t){return t.replace(/^\$/,"")},kh=Object.prototype,wh=kh.hasOwnProperty,_n=kh.toString,Y=Array.isArray||function(t){return _n.call(t)==="[object Array]"},Tt=t=>typeof t=="function",ve=t=>t===Object(t)&&!Y(t),Di=t=>{if(ve(t)){for(var e in t)if(wh.call(t,e))return!1;return!0}return!1},P=t=>t===void 0,ge=t=>_n.call(t)=="[object String]",Mr=t=>ge(t)&&t.trim().length===0,Ot=t=>t===null,K=t=>P(t)||Ot(t),tt=t=>_n.call(t)=="[object Number]"&&t==t,Pi=t=>tt(t)&&t>0,gt=t=>_n.call(t)==="[object Boolean]",Eb=t=>t instanceof FormData,Sb=t=>z(bb,t);kb=[!0,"true",1,"1","yes"],Bo=t=>z(kb,t),wb=[!1,"false",0,"0","no"];da=class{constructor(e){this.$t={},this.zt=e.zt,this.Zt=ft(e.bucketSize,0,100,e.Gt),this.Qt=ft(e.refillRate,0,this.Zt,e.Gt),this.Jt=ft(e.refillInterval,0,864e5,e.Gt)}Kt(e,i){var s=Math.floor((i-e.lastAccess)/this.Jt);s>0&&(e.tokens=Math.min(e.tokens+s*this.Qt,this.Zt),e.lastAccess=e.lastAccess+s*this.Jt)}consumeRateLimit(e){var i,s=Date.now(),r=String(e),n=this.$t[r];return n?this.Kt(n,s):this.$t[r]=n={tokens:this.Zt,lastAccess:s},n.tokens===0||(n.tokens--,n.tokens===0&&((i=this.zt)==null||i.call(this,e)),n.tokens===0)}stop(){this.$t={}}},We="Mobile",jr="iOS",Pt="Android",Mi="Tablet",Ih=Pt+" "+Mi,Th="iPad",Rh="Apple",Ph=Rh+" Watch",ws="Safari",Ui="BlackBerry",Oh="Samsung",Ch=Oh+"Browser",xh=Oh+" Internet",ri="Chrome",Ab=ri+" OS",Dh=ri+" "+jr,El="Internet Explorer",Nh=El+" "+We,Sl="Opera",Ib=Sl+" Mini",kl="Edge",Lh="Microsoft "+kl,$i="Firefox",$h=$i+" "+jr,Os="Nintendo",Cs="PlayStation",Fi="Xbox",Fh=Pt+" "+We,Mh=We+" "+ws,_s="Windows",ha=_s+" Phone",xd="Nokia",ga="Ouya",Uh="Generic",Tb=Uh+" "+We.toLowerCase(),Bh=Uh+" "+Mi.toLowerCase(),fa="Konqueror",Le="(\\d+(\\.\\d+)?)",Go=new RegExp("Version/"+Le),Rb=new RegExp(Fi,"i"),Pb=new RegExp(Cs+" \\w+","i"),Ob=new RegExp(Os+" \\w+","i"),wl=new RegExp(Ui+"|PlayBook|BB10","i"),Cb={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Vh=function(t,e){return e=e||"",z(t," OPR/")&&z(t,"Mini")?Ib:z(t," OPR/")?Sl:wl.test(t)?Ui:z(t,"IE"+We)||z(t,"WPDesktop")?Nh:z(t,Ch)?xh:z(t,kl)||z(t,"Edg/")?Lh:z(t,"FBIOS")?"Facebook "+We:z(t,"UCWEB")||z(t,"UCBrowser")?"UC Browser":z(t,"CriOS")?Dh:z(t,"CrMo")||z(t,ri)?ri:z(t,Pt)&&z(t,ws)?Fh:z(t,"FxiOS")?$h:z(t.toLowerCase(),fa.toLowerCase())?fa:((i,s)=>s&&z(s,Rh)||(function(r){return z(r,ws)&&!z(r,ri)&&!z(r,Pt)})(i))(t,e)?z(t,We)?Mh:ws:z(t,$i)?$i:z(t,"MSIE")||z(t,"Trident/")?El:z(t,"Gecko")?$i:""},xb={[Nh]:[new RegExp("rv:"+Le)],[Lh]:[new RegExp(kl+"?\\/"+Le)],[ri]:[new RegExp("("+ri+"|CrMo)\\/"+Le)],[Dh]:[new RegExp("CriOS\\/"+Le)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Le)],[ws]:[Go],[Mh]:[Go],[Sl]:[new RegExp("(Opera|OPR)\\/"+Le)],[$i]:[new RegExp($i+"\\/"+Le)],[$h]:[new RegExp("FxiOS\\/"+Le)],[fa]:[new RegExp("Konqueror[:/]?"+Le,"i")],[Ui]:[new RegExp(Ui+" "+Le),Go],[Fh]:[new RegExp("android\\s"+Le,"i")],[xh]:[new RegExp(Ch+"\\/"+Le)],[El]:[new RegExp("(rv:|MSIE )"+Le)],Mozilla:[new RegExp("rv:"+Le)]},Db=function(t,e){var i=Vh(t,e),s=xb[i];if(P(s))return null;for(var r=0;s.length>r;r++){var n=t.match(s[r]);if(n)return parseFloat(n[n.length-2])}return null},Dd=[[new RegExp(Fi+"; "+Fi+" (.*?)[);]","i"),t=>[Fi,t&&t[1]||""]],[new RegExp(Os,"i"),[Os,""]],[new RegExp(Cs,"i"),[Cs,""]],[wl,[Ui,""]],[new RegExp(_s,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[ha,""];if(new RegExp(We).test(e)&&!/IEMobile\b/.test(e))return[_s+" "+We,""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var s=Cb[i[1]]||"";return/arm/i.test(e)&&(s="RT"),[_s,s]}return[_s,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[jr,[t[3],t[4],t[5]||"0"].join(".")]:[jr,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=P(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Pt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Pt+")","i"),t=>t&&t[2]?[Pt,[t[2],t[3],t[4]||"0"].join(".")]:[Pt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Ab,""]],[/Linux|debian/i,["Linux",""]]],Nd=function(t){return Ob.test(t)?Os:Pb.test(t)?Cs:Rb.test(t)?Fi:new RegExp(ga,"i").test(t)?ga:new RegExp("("+ha+"|WPDesktop)","i").test(t)?ha:/iPad/.test(t)?Th:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Ph:wl.test(t)?Ui:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(xd,"i").test(t)?xd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(We).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Pt:Ih:new RegExp("(pda|"+We+")","i").test(t)?Tb:new RegExp(Mi,"i").test(t)&&!new RegExp(Mi+" pc","i").test(t)?Bh:""},Nb=t=>t instanceof Error,Gh={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},Lb=Gh.info;pa=class{constructor(e,i,s){s===void 0&&(s=[]),this.coercers=e,this.stackParser=i,this.modifiers=s}buildFromUnknown(e,i){i===void 0&&(i={});var s=i&&i.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(s,i,0).apply(e),n=this.buildParsingContext(i),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,s),$exception_level:"error"}}modifyFrames(e){var i=this;return Ze((function*(){for(var s of e)s.stacktrace&&s.stacktrace.frames&&Y(s.stacktrace.frames)&&(s.stacktrace.frames=yield i.applyModifiers(s.stacktrace.frames));return e}))()}coerceFallback(e){var i;return{type:"Error",value:"Unknown error",stack:(i=e.syntheticException)==null?void 0:i.stack,synthetic:!0}}parseStacktrace(e,i){var s,r;return e.cause!=null&&(s=this.parseStacktrace(e.cause,i)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?i.skipFirstLines:0),i.chunkIdMap)),S({},e,{cause:s,stack:r})}applyChunkIds(e,i){return e.map((s=>(s.filename&&i&&(s.chunk_id=i[s.filename]),s)))}applyCoercers(e,i){for(var s of this.coercers)if(s.match(e))return s.coerce(e,i);return this.coerceFallback(i)}applyModifiers(e){var i=this;return Ze((function*(){var s=e;for(var r of i.modifiers)s=yield r(s);return s}))()}convertToExceptionList(e,i){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:(s=i.type)!==null&&s!==void 0?s:"generic",handled:(r=i.handled)===null||r===void 0||r,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,S({},i,{handled:!0}))),a}buildParsingContext(e){var i;return{chunkIdMap:$b(this.stackParser),skipFirstLines:(i=e.skipFirstLines)!==null&&i!==void 0?i:1}}buildCoercingContext(e,i,s){s===void 0&&(s=0);var r=(n,o)=>{if(4>=o){var a=this.buildCoercingContext(e,i,o);return this.applyCoercers(n,a)}};return S({},i,{syntheticException:s==0?i.syntheticException:void 0,mechanism:e,apply:n=>r(n,s),next:n=>r(n,s+1)})}},Bi="?";jh=(t,e)=>{var i=t.indexOf("safari-extension")!==-1,s=t.indexOf("safari-web-extension")!==-1;return i||s?[t.indexOf("@")!==-1?t.split("@")[0]:Bi,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Fb=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Mb=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ub=/\((\S*)(?::(\d+))(?::(\d+))\)/,Bb=(t,e)=>{var i=Fb.exec(t);if(i){var[,s,r,n]=i;return va(e,s,Bi,+r,+n)}var o=Mb.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Ub.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=jh(o[1]||Bi,o[2]);return va(e,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Vb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Gb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,qb=(t,e)=>{var i=Vb.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=Gb.exec(i[3]);s&&(i[1]=i[1]||"eval",i[3]=s[1],i[4]=s[2],i[5]="")}var r=i[3],n=i[1]||Bi;return[n,r]=jh(n,r),va(e,r,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},$d=/\(error: (.*)\)/,_a=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,i){var s=ge(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:s?e.stack:void 0,cause:e.cause?i.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var i=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?i+": "+e.message:i}isDOMException(e){return qr(e,"DOMException")}isDOMError(e){return qr(e,"DOMError")}},ma=class{match(e){return(i=>i instanceof Error)(e)}coerce(e,i){return{type:this.getType(e),value:this.getMessage(e,i),stack:this.getStack(e),cause:e.cause?i.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,i){var s=e.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(e){return e.stacktrace||e.stack||void 0}},ya=class{constructor(){}match(e){return qr(e,"ErrorEvent")&&e.error!=null}coerce(e,i){var s;return i.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}},jb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ba=class{match(e){return typeof e=="string"}coerce(e,i){var s,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}getInfos(e){var i="Error",s=e,r=e.match(jb);return r&&(i=r[1],s=r[2]),[i,s]}},Hb=["fatal","error","warning","log","info","debug"];Ea=class{match(e){return typeof e=="object"&&e!==null}coerce(e,i){var s,r=this.getErrorPropertyFromObject(e);return r?i.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(s=i.syntheticException)==null?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return bl(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var i="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(i+=" with message: '"+e.message+"'"),i}if("message"in e&&typeof e.message=="string")return e.message;var s=this.getObjectClassName(e);return(s&&s!=="Object"?"'"+s+"'":"Object")+" captured as exception with keys: "+Hh(e)}isSeverityLevel(e){return ge(e)&&!Mr(e)&&Hb.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var i in e)if({}.hasOwnProperty.call(e,i)){var s=e[i];if(Nb(s))return s}}getObjectClassName(e){try{var i=Object.getPrototypeOf(e);return i?i.constructor.name:void 0}catch{return}}},Sa=class{match(e){return bl(e)}coerce(e,i){var s,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Hh(e),stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}},ka=class{match(e){return Ah(e)}coerce(e,i){var s;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}},wa=class{match(e){return qr(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!bl(e))return!1;try{var i=e.detail;return i!=null&&typeof i=="object"&&"reason"in i}catch{return!1}}coerce(e,i){var s,r=this.getUnhandledRejectionReason(e);return Ah(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}},Hr="$message",zr="$timestamp",zb=new Set([Hr,zr]),qo={enabled:!0,max_bytes:32768};Aa=class{constructor(e){this.Yt=[],this.Xt=0,this.qt=Kr(e)}setConfig(e){this.qt=Kr(e),this.er()}add(e){var i=(function(r){var n=(function(c){var h=new WeakSet;try{return JSON.stringify(c,((f,g)=>{if(typeof g=="bigint")return g.toString();if(typeof g!="function"&&typeof g!="symbol"){if(g instanceof Date)return g.toISOString();if(g instanceof Error)return{name:g.name,message:g.message,stack:g.stack};if(g&&typeof g=="object"){if(h.has(g))return"[Circular]";h.add(g)}return g}}))}catch{return}})(r);if(n)try{var o=JSON.parse(n);if(!ve(o))return;var a=o,l=a[Hr],u=a[zr];return!ge(l)||l.trim().length===0||!ge(u)&&!tt(u)?void 0:{step:a,json:n}}catch{return}})(e);if(i){var s=(function(r){if(typeof TextEncoder<"u")return new TextEncoder().encode(r).length;for(var n=encodeURIComponent(r),o=0,a=0;n.length>a;a++)n[a]==="%"?(o+=1,a+=2):o+=1;return o})(i.json);s>this.qt.max_bytes||(this.Yt.push({step:i.step,bytes:s}),this.Xt+=s,this.er())}}getAttachable(){return this.Yt.map((e=>e.step))}clear(){this.Yt=[],this.Xt=0}size(){return this.Yt.length}er(){for(;this.Xt>this.qt.max_bytes&&this.Yt.length>0;){var e=this.Yt.shift();e&&(this.Xt-=e.bytes)}}};zh=function(t,e){var{debugEnabled:i}=e===void 0?{}:e,s={k(r){if(_&&($e.DEBUG||L.POSTHOG_DEBUG||i)&&!P(_.console)&&_.console){for(var n=("__rrweb_original__"in _.console[r])?_.console[r].__rrweb_original__:_.console[r],o=arguments.length,a=new Array(o>1?o-1:0),l=1;o>l;l++)a[l-1]=arguments[l];n(t,...a)}},debug(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("debug",...n)},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(t,...n)},uninitializedWarning(r){s.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>zh(t+" "+r,n)};return s},T=zh("[PostHog.js]"),ue=T.createLogger,Wb=ue("[ExternalScriptsLoader]"),jo=(t,e,i)=>{if(t.config.disable_external_dependency_loading)return Wb.warn(e+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var s=I?.querySelectorAll("script");if(s){for(var r,n=function(){if(s[o].src===e){var l=s[o];return l.__posthog_loading_callback_fired?{v:i()}:(l.addEventListener("load",(u=>{l.__posthog_loading_callback_fired=!0,i(void 0,u)})),l.onerror=u=>i(u),{v:void 0})}},o=0;s.length>o;o++)if(r=n())return r.v}var a=()=>{if(!I)return i("document not found");var l=I.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,i(void 0,h)},l.onerror=h=>i(h),t.config.prepare_external_dependency_script&&(l=t.config.prepare_external_dependency_script(l)),!l)return i("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")I.head.appendChild(l);else{var u,c=I.querySelectorAll("body > script");c.length>0?(u=c[0].parentNode)==null||u.insertBefore(l,c[0]):I.body.appendChild(l)}};I!=null&&I.body?a():I?.addEventListener("DOMContentLoaded",a)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(t,e,i)=>{if(e!=="remote-config"){var s;if(t.config.__preview_external_dependency_versioned_paths)s=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js");else{var r="/static/"+e+".js?v="+t.version;if(e==="toolbar"){var n=3e5;r=r+"&t="+Math.floor(Date.now()/n)*n}s=t.requestRouter.endpointFor("assets",r)}jo(t,s,i)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");jo(t,o,i)}},L.__PosthogExtensions__.loadSiteApp=(t,e,i)=>{var s=t.requestRouter.endpointFor("api",e);jo(t,s,i)};Kh="$people_distinct_id",Wr="$device_id",ms="__alias",ys="__timers",Ia="$autocapture_disabled_server_side",Ta="$heatmaps_enabled_server_side",Ra="$exception_capture_enabled_server_side",Pa="$error_tracking_suppression_rules",Oa="$error_tracking_capture_extension_exceptions",Ca="$web_vitals_enabled_server_side",Al="$dead_clicks_enabled_server_side",xa="$product_tours_enabled_server_side",Da="$web_vitals_allowed_metrics",bs="$session_recording_remote_config",Wh="$replay_override_sampling",Yh="$replay_override_linked_flag",Xh="$replay_override_url_trigger",Jh="$replay_override_event_trigger",Yr="$sesid",Il="$session_is_sampled",Ni="$enabled_feature_flags",Ur="$active_feature_flags",Es="$early_access_features",Na="$feature_flag_details",La="$feature_flag_payloads",$a="$feature_flag_request_id",It="$override_feature_flags",Oi="$override_feature_flag_payloads",Ss="$stored_person_properties",ii="$stored_group_properties",Fa="$surveys",Ma="$surveys_activated",Br="ph_product_tours",As="$flag_call_reported",Ua="$flag_call_reported_session_id",Ba="$feature_flag_errors",Xr="$feature_flag_evaluated_at",nt="$user_state",Va="$client_session_props",Ga="$capture_rate_limit",qa="$initial_campaign_params",ja="$initial_referrer_info",Jr="$initial_person_info",Qr="$epp",Qh="__POSTHOG_TOOLBAR__",Cr="$posthog_cookieless",Zh="$sdk_debug_extensions_init_method",eg="$sdk_debug_extensions_init_time_ms",tg="$sdk_debug_recording_script_not_loaded",Tl="PostHog loadExternalDependency extension not found.",si="on_reject",Rt="always",Ai="anonymous",Ii="identified",Ha="identified_only",Zr="visibilitychange",en="beforeunload",Ci="$pageview",Ho="$pageleave",zo="$identify",Fd="$groupidentify";pe=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;e>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)r[n]!==void 0&&(t[n]=r[n]);return t};Md=function(t){try{return t()}catch{return}},Yb=function(t){return function(){try{for(var e=arguments.length,i=new Array(e),s=0;e>s;s++)i[s]=arguments[s];return t.apply(this,i)}catch(r){T.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),T.critical(r)}}},Rl=function(t){var e={};return oe(t,(function(i,s){(ge(i)&&i.length>0||tt(i))&&(e[s]=i)})),e},Xb=["herokuapp.com","vercel.app","netlify.app"];Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return tt(t)&&isFinite(t)&&Math.floor(t)===t});za=class t{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,i,s,r){if(!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(r)||0>e||0>i||0>s||0>r||e>0xffffffffffff||i>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|i>>>8,n[7]=i,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new t(n)}toString(){for(var e="",i=0;this.bytes.length>i;i++)e=e+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),i!==3&&i!==5&&i!==7&&i!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new t(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var i=0;16>i;i++){var s=this.bytes[i]-e.bytes[i];if(s!==0)return Math.sign(s)}return 0}},Ka=class{constructor(){this.S=0,this.C=0,this.I=new Wa}generate(){var e=this.generateOrAbort();if(P(e)){this.S=0;var i=this.generateOrAbort();if(P(i))throw new Error("Could not generate UUID after timestamp reset");return i}return e}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.T();else{if(this.S>=e+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.T())}return za.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}T(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}},sg=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};_&&!P(_.crypto)&&crypto.getRandomValues&&(sg=t=>crypto.getRandomValues(t));Wa=class{constructor(){this.M=new Uint32Array(8),this.O=1/0}nextUint32(){return this.M.length>this.O||(sg(this.M),this.O=0),this.M[this.O++]}},Vt=()=>Qb().toString(),Qb=()=>(Ud||(Ud=new Ka)).generate(),us="",Zb=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ht={R:()=>!!I,D(t){T.error("cookieStore error: "+t)},A(t){if(I){try{for(var e=t+"=",i=I.cookie.split(";").filter((n=>n.length)),s=0;i.length>s;s++){for(var r=i[s];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}}catch{}return null}},F(t){var e;try{e=JSON.parse(ht.A(t))||{}}catch{}return e},N(t,e,i,s,r){if(I)try{var n="",o="",a=(function(c,h){if(h){var f=(function(p,v){if(v===void 0&&(v=I),us)return us;if(!v||["localhost","127.0.0.1"].includes(p))return"";for(var m=p.split("."),y=Math.min(m.length,8),w="dmn_chk_"+Vt();!us&&y--;){var R=m.slice(y).join("."),D=w+"=1;domain=."+R+";path=/";v.cookie=D+";max-age=3",v.cookie.includes(w)&&(v.cookie=D+";max-age=0",us=R)}return us})(c);if(!f){var g=(p=>{var v=p.match(Zb);return v?v[0]:""})(c);g!==f&&T.info("Warning: cookie subdomain discovery mismatch",g,f),f=g}return f?"; domain=."+f:""}return""})(I.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&T.warn("cookieStore warning: large cookie, len="+u.length),I.cookie=u,u}catch{return}},q(t,e){if(I!=null&&I.cookie)try{ht.N(t,"",-1,e)}catch{return}}},Ko=null,he={R(){if(!Ot(Ko))return Ko;var t=!0;if(P(_))t=!1;else try{var e="__mplssupport__";he.N(e,"xyz"),he.A(e)!=='"xyz"'&&(t=!1),he.q(e)}catch{t=!1}return t||T.error("localStorage unsupported; falling back to cookie store"),Ko=t,t},D(t){T.error("localStorage error: "+t)},A(t){try{return _?.localStorage.getItem(t)}catch(e){he.D(e)}return null},F(t){try{return JSON.parse(he.A(t))||{}}catch{}return null},N(t,e){try{_?.localStorage.setItem(t,JSON.stringify(e))}catch(i){he.D(i)}},q(t){try{_?.localStorage.removeItem(t)}catch(e){he.D(e)}}},eE=[Wr,"distinct_id",Yr,Il,Qr,Jr,nt],Dr={},tE={R:()=>!0,D(t){T.error("memoryStorage error: "+t)},A:t=>Dr[t]||null,F:t=>Dr[t]||null,N(t,e){Dr[t]=e},q(t){delete Dr[t]}},Qt=null,Pe={R(){if(!Ot(Qt))return Qt;if(Qt=!0,P(_))Qt=!1;else try{var t="__support__";Pe.N(t,"xyz"),Pe.A(t)!=='"xyz"'&&(Qt=!1),Pe.q(t)}catch{Qt=!1}return Qt},D(t){T.error("sessionStorage error: ",t)},A(t){try{return _?.sessionStorage.getItem(t)}catch(e){Pe.D(e)}return null},F(t){try{return JSON.parse(Pe.A(t))||null}catch{}return null},N(t,e){try{_?.sessionStorage.setItem(t,JSON.stringify(e))}catch(i){Pe.D(i)}},q(t){try{_?.sessionStorage.removeItem(t)}catch(e){Pe.D(e)}}},Ya=class{constructor(e){this._instance=e}get qt(){return this._instance.config}get consent(){return this.rr()?0:this.ir}isOptedOut(){return this.qt.cookieless_mode===Rt||this.isRejected()||this.consent===-1&&this.qt.cookieless_mode===si}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.qt.opt_out_capturing_by_default}optInOut(e){this.nr.N(this.sr,e?1:0,this.qt.cookie_expiration,this.qt.cross_subdomain_cookie,this.qt.secure_cookie)}reset(){this.nr.q(this.sr,this.qt.cross_subdomain_cookie)}get sr(){var{token:e,opt_out_capturing_cookie_prefix:i,consent_persistence_name:s}=this._instance.config;return s||(i?i+e:"__ph_opt_in_out_"+e)}get ir(){var e=this.nr.A(this.sr);return Bo(e)?1:z(wb,e)?0:-1}get nr(){var e=this.qt.opt_out_capturing_persistence_type,i=e==="localStorage"?he:ht;if(!this.ar||this.ar!==i){this.ar=i;var s=e==="localStorage"?ht:he;s.A(this.sr)&&(this.ar.A(this.sr)||this.optInOut(Bo(s.A(this.sr))),s.q(this.sr,this.qt.cross_subdomain_cookie))}return this.ar}rr(){return!!this.qt.respect_dnt&&[Ke?.doNotTrack,Ke?.msDoNotTrack,L.doNotTrack].some((e=>Bo(e)))}},Nr=ue("[Dead Clicks]"),iE=()=>!0,sE=t=>{var e,i=!((e=t.instance.persistence)==null||!e.get_property(Al)),s=t.instance.config.capture_dead_clicks;return gt(s)?s:!!ve(s)||i},tn=class{get lazyLoadedDeadClicksAutocapture(){return this.ur}constructor(e,i,s){this.instance=e,this.isEnabled=i,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Al]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.lr((()=>{this.hr()})):this.stop()}lr(e){var i,s;(i=L.__PosthogExtensions__)!=null&&i.initDeadClicksAutocapture&&e(),(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Nr.error("failed to load script",r):e()}))}hr(){var e;if(I){if(!this.ur&&(e=L.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var i=ve(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};i.__onCapture=this.onCapture,this.ur=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.ur.start(I),Nr.info("starting...")}}else Nr.error("`document` not found. Cannot start.")}stop(){this.ur&&(this.ur.stop(),this.ur=void 0,Nr.info("stopping..."))}},Wo=ue("[SegmentIntegration]"),rg="posthog-js";Xa=class{constructor(e,i,s,r,n,o){this.name=rg,this.setupOnce=function(a){a(ng(e,{organization:i,projectId:s,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},sn=class{constructor(e){this.cr=(i,s,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(T.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:i,changeReason:r}),this.dr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.vr()}vr(){var e;this.pr=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.cr)}destroy(){var e;(e=this.pr)==null||e.call(this),this.pr=void 0}doPageView(e,i){var s,r=this.gr(e,i);return this.dr={pathname:(s=_?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:i,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var i;return this.gr(e,(i=this.dr)==null?void 0:i.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.dr)==null?void 0:e.pageViewId}}gr(e,i){var s=this.dr;if(!s)return{$pageview_id:i};var r={$pageview_id:i,$prev_pageview_id:s.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:u,lastContentY:c,maxContentY:h}=n;if(!(P(o)||P(a)||P(l)||P(u)||P(c)||P(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),h=Math.ceil(h);var f=o>1?ft(a/o,0,1,T):1,g=o>1?ft(l/o,0,1,T):1,p=u>1?ft(c/u,0,1,T):1,v=u>1?ft(h/u,0,1,T):1;r=pe(r,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return s.pathname&&(r.$prev_pageview_pathname=s.pathname),s.timestamp&&(r.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),r}},rE={[Kh]:{exposure:"hidden"},[ms]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[ys]:{exposure:"hidden"},[Ia]:{exposure:"event"},[Ta]:{exposure:"hidden"},[Ra]:{exposure:"event"},[Pa]:{exposure:"hidden"},[Oa]:{exposure:"event"},[Ca]:{exposure:"event"},[Al]:{exposure:"event"},[xa]:{exposure:"hidden"},[Da]:{exposure:"event"},[bs]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[Yr]:{exposure:"hidden"},[Il]:{exposure:"event"},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},[Ni]:{exposure:"derived",shouldSkipFromEventProperties:(t,e)=>e(),transformToEventProperties(t){if(!ve(t))return{};for(var e={},i=Object.keys(t),s=0;i.length>s;s++)e["$feature/"+i[s]]=t[i[s]];return e}},[Ur]:{exposure:"event"},[Es]:{exposure:"hidden"},[Na]:{exposure:"hidden"},[La]:{exposure:"event"},[$a]:{exposure:"event"},[It]:{exposure:"event"},[Oi]:{exposure:"hidden"},[Ss]:{exposure:"hidden"},[ii]:{exposure:"hidden"},[Fa]:{exposure:"hidden"},[Ma]:{exposure:"event"},[Br]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[As]:{exposure:"hidden"},[Ua]:{exposure:"hidden"},[Ba]:{exposure:"hidden"},[Xr]:{exposure:"hidden"},[nt]:{exposure:"hidden"},[Va]:{exposure:"hidden"},[Ga]:{exposure:"hidden"},[qa]:{exposure:"hidden"},[ja]:{exposure:"hidden"},[Jr]:{exposure:"hidden"},[Qr]:{exposure:"hidden"},[Wh]:{exposure:"event"},[Yh]:{exposure:"event"},[Xh]:{exposure:"event"},[Jh]:{exposure:"event"},[Zh]:{exposure:"event"},[eg]:{exposure:"event"},[tg]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},nE=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],rn=t=>{var e=I?.createElement("a");return P(e)?null:(e.href=t,e)},nn=function(t,e){for(var i,s=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===e){i=n;break}}if(!Y(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch{T.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},xs=function(t,e,i){if(!t||!e||!e.length)return t;for(var s=t.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var h=l[c].split("=");Y(h)&&(e.includes(h[0])?u.push(h[0]+"="+i):u.push(l[c]))}var f=a;return o!=null&&(f+="?"+u.join("&")),r!=null&&(f+="#"+r),f},on=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Lr="https?://(.*)",Vi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],oE=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Vi],Ds="<masked>",aE=["li_fat_id"];an="$direct";uE=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Is=class{constructor(e,i){this.qt=e,this.props={},this.mr=!1,this.yr=(s=>{var r="";return s.token&&(r=s.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),s.persistence_name?"ph_"+s.persistence_name:"ph_"+r+"_posthog"})(e),this.nr=this.br(e),this.load(),e.debug&&T.info("Persistence loaded",e.persistence,S({},this.props)),this.update_config(e,e,i),this.save()}isDisabled(){return!!this._r}br(e){uE.indexOf(e.persistence.toLowerCase())===-1&&(T.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var i=(function(r){r===void 0&&(r=[]);var n=[...eE,...r];return S({},he,{F(o){try{var a={};try{a=ht.F(o)||{}}catch{}var l=pe(a,JSON.parse(he.A(o)||"{}"));return he.N(o,l),l}catch{}return null},N(o,a,l,u,c,h){try{he.N(o,a,void 0,void 0,h);var f={};n.forEach((g=>{a[g]&&(f[g]=a[g])})),Object.keys(f).length&&ht.N(o,f,l,u,c,h)}catch(g){he.D(g)}},q(o,a){try{_?.localStorage.removeItem(o),ht.q(o,a)}catch(l){he.D(l)}}})})(e.cookie_persisted_properties||[]),s=e.persistence.toLowerCase();return s==="localstorage"&&he.R()?he:s==="localstorage+cookie"&&i.R()?i:s==="sessionstorage"&&Pe.R()?Pe:s==="memory"?tE:s==="cookie"?ht:i.R()?i:ht}wr(e){var i=e??this.qt.feature_flag_cache_ttl_ms;if(!i||0>=i)return!1;var s=this.props[Xr];return!s||typeof s!="number"||Date.now()-s>i}properties(){var e={};return oe(this.props,((i,s)=>{var r=(n=>{var o=rE[n];if(o)return o;for(var[a,l]of nE)if(n.indexOf(a)===0)return l})(s);if(r?.exposure==="derived"){if(r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(i,s===Ni?()=>this.wr():()=>!1))return;r.transformToEventProperties&&pe(e,r.transformToEventProperties(i))}else r&&r.exposure!=="event"||(e[s]=i)})),e}load(){if(!this._r){var e=this.nr.F(this.yr);e&&(this.props=pe({},e))}}save(){this._r||this.nr.N(this.yr,this.props,this.Sr,this.kr,this.Cr,this.qt.debug)}remove(){this.nr.q(this.yr,!1),this.nr.q(this.yr,!0)}clear(){this.remove(),this.props={}}register_once(e,i,s){if(ve(e)){P(i)&&(i="None"),this.Sr=P(s)?this.Ir:s;var r=!1;if(oe(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==i||(this.Tr(o,n),r=!0)})),r)return this.save(),!0}return!1}register(e,i){if(ve(e)){this.Sr=P(i)?this.Ir:i;var s=!1;if(oe(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.Tr(n,r),s=!0)})),s)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.Er(e),this.save())}update_campaign_params(){if(!this.mr){var e=og(this.qt.custom_campaign_params,this.qt.mask_personal_data_properties,this.qt.custom_personal_data_properties);Di(Rl(e))||this.register(e),this.mr=!0}}update_search_keyword(){var e;this.register((e=I?.referrer)?lg(e):{})}update_referrer_info(){var e;this.register_once({$referrer:ug(),$referring_domain:I!=null&&I.referrer&&((e=rn(I.referrer))==null?void 0:e.host)||an},void 0)}set_initial_person_info(){this.props[qa]||this.props[ja]||this.register_once({[Jr]:cg(this.qt.mask_personal_data_properties,this.qt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};oe([ja,qa],(o=>{var a=this.props[o];a&&oe(a,(function(l,u){e["$initial_"+ca(u)]=l}))}));var i,s,r=this.props[Jr];if(r){var n=(i=dg(r),s={},oe(i,(function(o,a){s["$initial_"+ca(a)]=o})),s);pe(e,n)}return e}safe_merge(e){return oe(this.props,(function(i,s){s in e||(e[s]=i)})),e}update_config(e,i,s){if(this.Ir=this.Sr=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==i.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),u=[...a].sort();return l.every(((c,h)=>c===u[h]))})(e.cookie_persisted_properties||[],i.cookie_persisted_properties||[])){var r=this.br(e),n=this.props;this.clear(),this.nr=r,this.props=n,this.save()}}set_disabled(e){this._r=e,this._r?this.remove():this.save()}set_cross_subdomain(e){e!==this.kr&&(this.kr=e,this.remove(),this.save())}set_secure(e){e!==this.Cr&&(this.Cr=e,this.remove(),this.save())}set_event_timer(e,i){var s=this.props[ys]||{};s[e]=i,this.Tr(ys,s),this.save()}remove_event_timer(e){var i=this.props[ys]||{},s=i[e];return P(s)||(delete i[e],this.Tr(ys,i),this.save()),s}get_property(e){return this.props[e]}set_property(e,i){this.Tr(e,i),this.save()}Tr(e,i){this.props[e]=i}Er(e){delete this.props[e]}},cs={Activation:"events",Cancellation:"cancelEvents"},Yo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},ks={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Xo={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Ja={Popover:"popover",Inline:"inline"},cE={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Vd={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Gd=ue("[RateLimiter]"),Qa=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach((r=>{Gd.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void Gd.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:s})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var i,s,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(i=(s=this.instance.persistence)==null?void 0:s.get_property(Ga))!==null&&i!==void 0?i:{tokens:n,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>n&&(l.tokens=n);var u=1>l.tokens;return u||e||(l.tokens=Math.max(0,l.tokens-1)),!u||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=u,(r=this.instance.persistence)==null||r.set_property(Ga,l),{isRateLimited:u,remainingTokens:l.tokens}}isServerRateLimited(e){var i=this.serverLimits[e||"events"]||!1;return i!==!1&&new Date().getTime()<i}},ds=ue("[RemoteConfig]"),ln=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=L._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Mr(e){var i,s;(i=L.__PosthogExtensions__)!=null&&i.loadExternalDependency?(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Pr(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(i){e(i.json)}})}load(){try{if(this.remoteConfig)return ds.info("Using preloaded remote config",this.remoteConfig),this.Rr(this.remoteConfig),void this.Or();if(this._instance.Lr())return void ds.warn("Remote config is disabled. Falling back to local config.");this.Mr((e=>{if(!e)return ds.info("No config found after loading remote JS config. Falling back to JSON."),void this.Pr((i=>{this.Rr(i),this.Or()}));this.Rr(e),this.Or()}))}catch(e){ds.error("Error loading remote config",e)}}stop(){this.Fr&&(clearInterval(this.Fr),this.Fr=void 0)}refresh(){this._instance.Lr()||I?.visibilityState==="hidden"||this._instance.reloadFeatureFlags()}Or(){var e;if(!this.Fr){var i=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;i!==0&&(this.Fr=setInterval((()=>{this.refresh()}),i))}}Rr(e){var i;e||ds.error("Failed to fetch remote config from PostHog."),this._instance.Rr(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(i=this._instance.featureFlags)==null||i.ensureFlagsLoaded())}},dt={GZipJS:"gzip-js",Base64:"base64"},et=Uint8Array,Fe=Uint16Array,Gi=Uint32Array,Pl=new et([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ol=new et([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),qd=new et([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gg=function(t,e){for(var i=new Fe(31),s=0;31>s;++s)i[s]=e+=1<<t[s-1];var r=new Gi(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},fg=gg(Pl,2),Za=fg[1];fg[0][28]=258,Za[258]=28;for(el=gg(Ol,0)[1],un=new Fe(32768),ie=0;32768>ie;++ie)Zt=(43690&ie)>>>1|(21845&ie)<<1,un[ie]=((65280&(Zt=(61680&(Zt=(52428&Zt)>>>2|(13107&Zt)<<2))>>>4|(3855&Zt)<<4))>>>8|(255&Zt)<<8)>>>1;Ts=function(t,e,i){for(var s=t.length,r=0,n=new Fe(e);s>r;++r)++n[t[r]-1];var o,a=new Fe(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Fe(1<<e);var l=15-e;for(r=0;s>r;++r)if(t[r])for(var u=r<<4|t[r],c=e-t[r],h=a[t[r]-1]++<<c,f=h|(1<<c)-1;f>=h;++h)o[un[h]>>>l]=u}else for(o=new Fe(s),r=0;s>r;++r)o[r]=un[a[t[r]-1]++]>>>15-t[r];return o},oi=new et(288);for(ie=0;144>ie;++ie)oi[ie]=8;for(ie=144;256>ie;++ie)oi[ie]=9;for(ie=256;280>ie;++ie)oi[ie]=7;for(ie=280;288>ie;++ie)oi[ie]=8;cn=new et(32);for(ie=0;32>ie;++ie)cn[ie]=5;dE=Ts(oi,9,0),hE=Ts(cn,5,0),pg=function(t){return(t/8>>0)+(7&t&&1)},vg=function(t,e,i){(i==null||i>t.length)&&(i=t.length);var s=new(t instanceof Fe?Fe:t instanceof Gi?Gi:et)(i-e);return s.set(t.subarray(e,i)),s},wt=function(t,e,i){var s=e/8>>0;t[s]|=i<<=7&e,t[s+1]|=i>>>8},hs=function(t,e,i){var s=e/8>>0;t[s]|=i<<=7&e,t[s+1]|=i>>>8,t[s+2]|=i>>>16},Jo=function(t,e){for(var i=[],s=0;t.length>s;++s)t[s]&&i.push({s,f:t[s]});var r=i.length,n=i.slice();if(!r)return[new et(0),0];if(r==1){var o=new et(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(b,x){return b.f-x.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,c=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[h].f>i[u].f?u++:h++],l=i[u!=c&&i[h].f>i[u].f?u++:h++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var f=n[0].s;for(s=1;r>s;++s)n[s].s>f&&(f=n[s].s);var g=new Fe(f+1),p=tl(i[c-1],g,0);if(p>e){s=0;var v=0,m=p-e,y=1<<m;for(n.sort((function(b,x){return g[x.s]-g[b.s]||b.f-x.f}));r>s;++s){var w=n[s].s;if(e>=g[w])break;v+=y-(1<<p-g[w]),g[w]=e}for(v>>>=m;v>0;){var R=n[s].s;e>g[R]?v-=1<<e-g[R]++-1:++s}for(;s>=0&&v;--s){var D=n[s].s;g[D]==e&&(--g[D],++v)}p=e}return[new et(g),p]},tl=function(t,e,i){return t.s==-1?Math.max(tl(t.l,e,i+1),tl(t.r,e,i+1)):e[t.s]=i},jd=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new Fe(++e),s=0,r=t[0],n=1,o=function(l){i[s++]=l},a=1;e>=a;++a)if(t[a]==r&&a!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=t[a]}return[i.subarray(0,s),e]},gs=function(t,e){for(var i=0,s=0;e.length>s;++s)i+=t[s]*e[s];return i},il=function(t,e,i){var s=i.length,r=pg(e+2);t[r]=255&s,t[r+1]=s>>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var n=0;s>n;++n)t[r+n+4]=i[n];return 8*(r+4+s)},Hd=function(t,e,i,s,r,n,o,a,l,u,c){wt(e,c++,i),++r[256];for(var h=Jo(r,15),f=h[0],g=h[1],p=Jo(n,15),v=p[0],m=p[1],y=jd(f),w=y[0],R=y[1],D=jd(v),b=D[0],x=D[1],C=new Fe(19),O=0;w.length>O;++O)C[31&w[O]]++;for(O=0;b.length>O;++O)C[31&b[O]]++;for(var A=Jo(C,7),$=A[0],U=A[1],H=19;H>4&&!$[qd[H-1]];--H);var G,q,me,Se,Me=u+5<<3,ke=gs(r,oi)+gs(n,cn)+o,k=gs(r,f)+gs(n,v)+o+14+3*H+gs(C,$)+(2*C[16]+3*C[17]+7*C[18]);if(ke>=Me&&k>=Me)return il(e,c,t.subarray(l,l+u));if(wt(e,c,1+(ke>k)),c+=2,ke>k){G=Ts(f,g,0),q=f,me=Ts(v,m,0),Se=v;var M=Ts($,U,0);for(wt(e,c,R-257),wt(e,c+5,x-1),wt(e,c+10,H-4),c+=14,O=0;H>O;++O)wt(e,c+3*O,$[qd[O]]);c+=3*H;for(var F=[w,b],B=0;2>B;++B){var Z=F[B];for(O=0;Z.length>O;++O)wt(e,c,M[ce=31&Z[O]]),c+=$[ce],ce>15&&(wt(e,c,Z[O]>>>5&127),c+=Z[O]>>>12)}}else G=dE,q=oi,me=hE,Se=cn;for(O=0;a>O;++O)if(s[O]>255){var ce;hs(e,c,G[257+(ce=s[O]>>>18&31)]),c+=q[ce+257],ce>7&&(wt(e,c,s[O]>>>23&31),c+=Pl[ce]);var se=31&s[O];hs(e,c,me[se]),c+=Se[se],se>3&&(hs(e,c,s[O]>>>5&8191),c+=Ol[se])}else hs(e,c,G[s[O]]),c+=q[s[O]];return hs(e,c,G[256]),c+q[256]},gE=new Gi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fE=(function(){for(var t=new Gi(256),e=0;256>e;++e){for(var i=e,s=9;--s;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t})(),Qo=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};vE=!!la||!!aa,_g="text/plain",zd=!1,mn=function(t,e,i){var s;i===void 0&&(i=!0);var[r,n]=t.split("?"),o=S({},e),a=(s=n?.split("&").map((u=>{var c,[h,f]=u.split("="),g=i&&(c=o[h])!==null&&c!==void 0?c:f;return delete o[h],h+"="+g})))!==null&&s!==void 0?s:[],l=(function(u,c){var h,f;c===void 0&&(c="&");var g=[];return oe(u,(function(p,v){P(p)||P(v)||v==="undefined"||(h=encodeURIComponent((m=>m instanceof File)(p)?p.name:p.toString()),f=encodeURIComponent(v),g[g.length]=f+"="+h)})),g.join(c)})(o);return l&&a.push(l),r+"?"+a.join("&")},Li=(t,e)=>JSON.stringify(t,((i,s)=>typeof s=="bigint"?s.toString():s),e),Zo=t=>{if(t.tr)return t.tr;var{data:e,compression:i}=t;if(e){if(i===dt.GZipJS){var s=pE((function(a,l){var u=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var c=new et(a.length+(a.length>>>1)),h=0,f=function(m){c[h++]=m},g=0;u>g;++g){if(h+5>c.length){var p=new et(h+8+(u-g<<1));p.set(c),c=p}var v=a.charCodeAt(g);128>v?f(v):2048>v?(f(192|v>>>6),f(128|63&v)):v>55295&&57344>v?(f(240|(v=65536+(1047552&v)|1023&a.charCodeAt(++g))>>>18),f(128|v>>>12&63),f(128|v>>>6&63),f(128|63&v)):(f(224|v>>>12),f(128|v>>>6&63),f(128|63&v))}return vg(c,0,h)})(Li(e)),{mtime:0});return{contentType:_g,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===dt.Base64){var r=(function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,((l,u)=>String.fromCharCode(parseInt(u,16)))))})(Li(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Li(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Li(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},_E=(function(){var t=Ze((function*(e){var i=Li(e.data),s=yield(function(n,o,a){return ua.apply(this,arguments)})(i,$e.DEBUG,{rethrow:!0});if(!s)return e;var r=yield s.arrayBuffer();return S({},e,{tr:{contentType:_g,body:r,estimatedSize:r.byteLength}})}));return function(e){return t.apply(this,arguments)}})(),Kd=(t,e)=>mn(t,{_:new Date().getTime().toString(),ver:$e.JS_SDK_VERSION,compression:e}),Gr=[];aa&&Gr.push({transport:"fetch",method(t){var e,i,{contentType:s,body:r,estimatedSize:n}=(e=Zo(t))!==null&&e!==void 0?e:{},o=new Headers;oe(t.headers,(function(c,h){o.append(h,c)})),s&&o.append("Content-Type",s);var a=t.url,l=null;if(Td){var u=new Td;l={signal:u.signal,timeout:setTimeout((()=>u.abort()),t.timeout)}}aa(a,S({method:t?.method||"GET",headers:o,keepalive:t.method==="POST"&&52428.8>(n||0),body:r,signal:(i=l)==null?void 0:i.signal},t.fetchOptions)).then((c=>c.text().then((h=>{var f={statusCode:c.status,text:h};if(c.status===200)try{f.json=JSON.parse(h)}catch(g){T.error(g)}t.callback==null||t.callback(f)})))).catch((c=>{T.error(c),t.callback==null||t.callback({statusCode:0,error:c})})).finally((()=>l?clearTimeout(l.timeout):null))}}),la&&Gr.push({transport:"XHR",method(t){var e,i=new la;i.open(t.method||"GET",t.url,!0);var{contentType:s,body:r}=(e=Zo(t))!==null&&e!==void 0?e:{};oe(t.headers,(function(n,o){i.setRequestHeader(o,n)})),s&&i.setRequestHeader("Content-Type",s),t.timeout&&(i.timeout=t.timeout),t.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(i.readyState===4){var n={statusCode:i.status,text:i.responseText};if(i.status===200)try{n.json=JSON.parse(i.responseText)}catch{}t.callback==null||t.callback(n)}},i.send(r)}}),Ke!=null&&Ke.sendBeacon&&Gr.push({transport:"sendBeacon",method(t){var e=mn(t.url,{beacon:"1"});try{var i,{contentType:s,body:r}=(i=Zo(t))!==null&&i!==void 0?i:{};if(!r)return;var n=r instanceof Blob?r:new Blob([r],{type:s});Ke.sendBeacon(e,n)}catch{}}});sl=3e3,rl=class{constructor(e,i){this.Ar=!0,this.Nr=[],this.$r=ft(i?.flush_interval_ms||sl,250,5e3,T.createLogger("flush interval"),sl),this.Dr=e}enqueue(e){this.Nr.push(e),this.qr||this.jr()}unload(){this.Hr();var e=this.Nr.length>0?this.Ur():{},i=Object.values(e);[...i.filter((s=>s.url.indexOf("/e")===0)),...i.filter((s=>s.url.indexOf("/e")!==0))].map((s=>{this.Dr(S({},s,{transport:"sendBeacon"}))}))}enable(){this.Ar=!1,this.jr()}jr(){var e=this;this.Ar||(this.qr=setTimeout((()=>{if(this.Hr(),this.Nr.length>0){var i=this.Ur(),s=function(){var n=i[r],o=new Date().getTime();n.data&&Y(n.data)&&oe(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Dr(n)};for(var r in i)s()}}),this.$r))}Hr(){clearTimeout(this.qr),this.qr=void 0}Ur(){var e={};return oe(this.Nr,(i=>{var s,r=i,n=(r?r.batchKey:null)||r.url;P(e[n])&&(e[n]=S({},r,{data:[]})),(s=e[n].data)==null||s.push(r.data)})),this.Nr=[],e}},mE=["retriesPerformedSoFar"],nl=class{constructor(e){this.Br=!1,this.zr=3e3,this.Nr=[],this._instance=e,this.Nr=[],this.Vr=!0,!P(_)&&"onLine"in _.navigator&&(this.Vr=_.navigator.onLine,this.Wr=()=>{this.Vr=!0,this.Zr()},this.Gr=()=>{this.Vr=!1},be(_,"online",this.Wr),be(_,"offline",this.Gr))}get length(){return this.Nr.length}retriableRequest(e){var{retriesPerformedSoFar:i}=e,s=Sh(e,mE);Pi(i)&&(s.url=mn(s.url,{retry_count:i})),this._instance._send_request(S({},s,{callback:r=>{r.statusCode===200||r.statusCode>=400&&500>r.statusCode||(i??0)>=10?s.callback==null||s.callback(r):this.Qr(S({retriesPerformedSoFar:i},s))}}))}Qr(e){var i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;var s=(function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=Math.random()-.5;return Math.ceil(u+c*(u-l))})(i),r=Date.now()+s;this.Nr.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+s;navigator.onLine||(n+=" (Browser is offline)"),T.warn(n),this.Br||(this.Br=!0,this.Jr())}Jr(){if(this.Kr&&clearTimeout(this.Kr),this.Nr.length===0)return this.Br=!1,void(this.Kr=void 0);this.Kr=setTimeout((()=>{this.Vr&&this.Nr.length>0&&this.Zr(),this.Jr()}),this.zr)}Zr(){var e=Date.now(),i=[],s=this.Nr.filter((n=>e>n.retryAt||(i.push(n),!1)));if(this.Nr=i,s.length>0)for(var{requestOptions:r}of s)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Kr&&(clearTimeout(this.Kr),this.Kr=void 0),this.Br=!1,P(_)||(this.Wr&&(_.removeEventListener("online",this.Wr),this.Wr=void 0),this.Gr&&(_.removeEventListener("offline",this.Gr),this.Gr=void 0)),this.Nr))try{this._instance._send_request(S({},e,{transport:"sendBeacon"}))}catch(i){T.error(i)}this.Nr=[]}},ol=class{constructor(e){this.Yr=()=>{var i,s,r,n;this.Xr||(this.Xr={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+(o?.clientHeight||0),c=o?.scrollHeight||0;this.Xr.lastScrollY=Math.ceil(a),this.Xr.maxScrollY=Math.max(a,(i=this.Xr.maxScrollY)!==null&&i!==void 0?i:0),this.Xr.maxScrollHeight=Math.max(l,(s=this.Xr.maxScrollHeight)!==null&&s!==void 0?s:0),this.Xr.lastContentY=u,this.Xr.maxContentY=Math.max(u,(r=this.Xr.maxContentY)!==null&&r!==void 0?r:0),this.Xr.maxContentHeight=Math.max(c,(n=this.Xr.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get ei(){return this._instance.config.scroll_root_selector}getContext(){return this.Xr}resetContext(){var e=this.Xr;return setTimeout(this.Yr,0),e}startMeasuringScrollPosition(){be(_,"scroll",this.Yr,{capture:!0}),be(_,"scrollend",this.Yr,{capture:!0}),be(_,"resize",this.Yr)}scrollElement(){if(!this.ei)return _?.document.documentElement;var e=Y(this.ei)?this.ei:[this.ei];for(var i of e){var s=_?.document.querySelector(i);if(s)return s}}scrollY(){if(this.ei){var e=this.scrollElement();return e&&e.scrollTop||0}return _&&(_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop)||0}scrollX(){if(this.ei){var e=this.scrollElement();return e&&e.scrollLeft||0}return _&&(_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft)||0}},yE=t=>cg(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties),dn=class{constructor(e,i,s,r){this.ti=n=>{var o=this.ri();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.ii(this._instance)};this.ni.register({[Va]:a})}},this._instance=e,this.si=i,this.ni=s,this.ii=r||yE,this.si.onSessionId(this.ti)}ri(){return this.ni.props[Va]}getSetOnceProps(){var e,i=(e=this.ri())==null?void 0:e.props;return i?"r"in i?dg(i):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){var e={};return oe(Rl(this.getSetOnceProps()),((i,s)=>{s==="$current_url"&&(s="url"),e["$session_entry_"+ca(s)]=i})),e}},Ns=class{constructor(){this.oi={}}on(e,i){return this.oi[e]||(this.oi[e]=[]),this.oi[e].push(i),()=>{this.oi[e]=this.oi[e].filter((s=>s!==i))}}emit(e,i){for(var s of this.oi[e]||[])s(i);for(var r of this.oi["*"]||[])r(e,i)}},ea=ue("[SessionId]"),hn=class{on(e,i){return this.ai.on(e,i)}constructor(e,i,s){var r;if(this.ui=[],this.li=void 0,this.ai=new Ns,this.hi=(u,c)=>!(!Pi(u)||!Pi(c))&&Math.abs(u-c)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===Rt)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.qt=e.config,this.ni=e.persistence,this.ci=void 0,this.di=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.vi=i||Vt,this.fi=s||Vt;var n=this.qt.persistence_name||this.qt.token;if(this._sessionTimeoutMs=1e3*ft(this.qt.session_idle_timeout_seconds||1800,60,36e3,ea.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.pi(),this.gi="ph_"+n+"_window_id",this.mi="ph_"+n+"_primary_window_exists",this.yi()){var o=Pe.F(this.gi),a=Pe.F(this.mi);o&&!a?this.ci=o:Pe.q(this.gi),Pe.N(this.mi,!0)}if((r=this.qt.bootstrap)!=null&&r.sessionID)try{var l=(u=>{var c=this.qt.bootstrap.sessionID.replace(/-/g,"");if(c.length!==32)throw new Error("Not a valid UUID");if(c[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(c.substring(0,12),16)})();this.bi(this.qt.bootstrap.sessionID,new Date().getTime(),l)}catch(u){ea.error("Invalid sessionID in bootstrap",u)}this.wi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return P(this.ui)&&(this.ui=[]),this.ui.push(e),this.di&&e(this.di,this.ci),()=>{this.ui=this.ui.filter((i=>i!==e))}}yi(){return this.qt.persistence!=="memory"&&!this.ni._r&&Pe.R()}xi(e){e!==this.ci&&(this.ci=e,this.yi()&&Pe.N(this.gi,e))}Si(){return this.ci?this.ci:this.yi()?Pe.F(this.gi):null}bi(e,i,s){e===this.di&&i===this._sessionActivityTimestamp&&s===this._sessionStartTimestamp||(this._sessionStartTimestamp=s,this._sessionActivityTimestamp=i,this.di=e,this.ni.register({[Yr]:[i,e,s]}))}ki(){var e=this.ni.props[Yr];return Y(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.bi(null,null,null)}destroy(){clearTimeout(this.Ci),this.Ci=void 0,this.li&&_&&(_.removeEventListener(en,this.li,{capture:!1}),this.li=void 0),this.ui=[]}wi(){this.li=()=>{this.yi()&&Pe.q(this.mi)},be(_,en,this.li,{capture:!1})}checkAndGetSessionAndWindowId(e,i){if(e===void 0&&(e=!1),i===void 0&&(i=null),this.qt.cookieless_mode===Rt)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=i||new Date().getTime(),[r,n,o]=this.ki(),a=this.Si(),l=Pi(o)&&Math.abs(s-o)>864e5,u=!1,c=!n,h=!c&&!e&&this.hi(s,r);c||h||l?(n=this.vi(),a=this.fi(),ea.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}}),o=s,u=!0):a||(a=this.fi(),u=!0);var f=Pi(r)&&e&&!l?r:s,g=Pi(o)?o:new Date().getTime();return this.xi(a),this.bi(n,f,g),e||this.pi(),u&&this.ui.forEach((p=>p(n,a,u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:g,changeReason:u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}pi(){clearTimeout(this.Ci),this.Ci=setTimeout((()=>{var[e]=this.ki();if(this.hi(new Date().getTime(),e)){var i=this.di;this.resetSessionId(),this.ai.emit("forcedIdleReset",{idleSessionId:i})}}),1.1*this.sessionTimeoutMs)}},mg=function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&Od(i,e))return!0;try{var s=t?.userAgentData;if(s!=null&&s.brands&&s.brands.some((r=>Od(r?.brand,e))))return!0}catch{}return!!t.webdriver},gn=function(t,e){if(!(function(i){try{new RegExp(i)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};yg={exact:(t,e)=>e.some((i=>t.some((s=>i===s)))),is_not:(t,e)=>e.every((i=>t.every((s=>i!==s)))),regex:(t,e)=>e.some((i=>t.some((s=>gn(i,s))))),not_regex:(t,e)=>e.every((i=>t.every((s=>!gn(i,s))))),icontains:(t,e)=>e.map($r).some((i=>t.map($r).some((s=>i.includes(s))))),not_icontains:(t,e)=>e.map($r).every((i=>t.map($r).every((s=>!i.includes(s))))),gt:(t,e)=>e.some((i=>{var s=parseFloat(i);return!isNaN(s)&&t.some((r=>s>parseFloat(r)))})),lt:(t,e)=>e.some((i=>{var s=parseFloat(i);return!isNaN(s)&&t.some((r=>s<parseFloat(r)))}))},$r=t=>t.toLowerCase();al="custom",Yd="i.posthog.com",bE=/^\/static\//,ll=class{constructor(e){this.Ii={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,i=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return i||(i=this.apiHost.replace("."+Yd,".posthog.com")),i==="https://app.posthog.com"?"https://us.posthog.com":i}get region(){return this.Ii[this.apiHost]||(this.Ii[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":al),this.Ii[this.apiHost]}Ti(e){var i=this.instance.config.__preview_external_dependency_versioned_paths;if(typeof i=="string"&&bE.test(e))return i.trim().replace(/\/$/,"")||void 0}endpointFor(e,i){if(i===void 0&&(i=""),i&&(i=i[0]==="/"?i:"/"+i),e==="ui")return this.uiHost+i;if(e==="flags")return this.flagsApiHost+i;if(e==="assets"){var s=this.Ti(i);if(s)return""+s+i}if(this.region===al)return this.apiHost+i;var r=Yd+i;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},ee=ue("[Surveys]"),ul="seenSurvey_",EE=[Yo.Popover,Yo.Widget,Yo.API],SE={ignoreConditions:!1,ignoreDelay:!1,displayType:Ja.Popover},kE=ue("[PostHog ExternalIntegrations]"),wE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},cl=class{constructor(e){this._instance=e}lr(e,i){var s;(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,e,(r=>{if(r)return kE.error("failed to load script",r);i()}))}startIfEnabledOrStop(){var e=this,i=function(o){var a,l,u;!r||(a=L.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.lr(wE[o],(()=>{var c;(c=L.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.start(e._instance)})),!r&&(l=L.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((u=L.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.stop())};for(var[s,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;i(s)}}},Rs={},ta=0,dl=()=>{},Xd='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',fs="Surveys module not available",Jd="sanitize_properties is deprecated. Use before_send instead",Eg="Invalid value for property_denylist config: ",xi="posthog",Sg=!vE&&je?.indexOf("MSIE")===-1&&je?.indexOf("Mozilla")===-1,Qd=t=>{var e;return S({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Jb(I?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:dl,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,debug:Re&&ge(Re?.search)&&Re.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(_==null||(e=_.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(i){T.error("Bad HTTP status: "+i.statusCode+" "+i.text)},get_device_id:i=>i,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ha,before_send:void 0,request_queue_config:{flush_interval_ms:sl},error_tracking:{},_onCapture:dl,__preview_eager_load_replay:!1},(i=>({rageclick:!i||"2025-11-30">i||{content_ignorelist:!0},capture_pageview:!i||"2025-05-24">i||"history_change",session_recording:i&&i>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:i&&i>="2026-01-30"?"head":"body",internal_or_test_user_hostname:i&&i>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(t))},AE=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Zd=t=>{var e={};for(var[i,s]of AE)P(t[i])||(e[s]=t[i]);var r=pe({},e,t);return Y(t.property_blacklist)&&(P(t.property_denylist)?r.property_denylist=t.property_blacklist:Y(t.property_denylist)?r.property_denylist=[...t.property_blacklist,...t.property_denylist]:T.error(Eg+t.property_denylist)),r},hl=class{constructor(){this.__forceAllowLocalhost=!1}get Ei(){return this.__forceAllowLocalhost}set Ei(e){T.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},ni=class t{Mi(e,i){if(e){var s=this.Pi.indexOf(e);s!==-1&&this.Pi.splice(s,1)}return this.Pi.push(i),i.initialize==null||i.initialize(),i}Ri(){return this.config.cookieless_mode===Rt||this.config.cookieless_mode===si&&this.consent.isRejected()}get decideEndpointWasHit(){var e,i;return(e=(i=this.featureFlags)==null?void 0:i.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,i;return(e=(i=this.featureFlags)==null?void 0:i.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new hl,this.Oi=!1,this.version=$e.LIB_VERSION,this.Li=new Ns,this.Pi=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Qd(),this.SentryIntegration=Xa,this.sentryIntegration=s=>(function(r,n){var o=ng(r,n);return{name:rg,processEvent:a=>o(a)}})(this,s),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Fi=!1,this.Ai=null,this.Ni=null,this.$i=null,this.scrollManager=new ol(this),this.pageViewManager=new sn(this),this.rateLimiter=new Qa(this),this.requestRouter=new ll(this),this.consent=new Ya(this),this.externalIntegrations=new cl(this);var i=(e=t.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(s,r,n)=>{var o=ge(s)?{[s]:r}:s;this.setPersonProperties(o),n?.({})},set_once:(s,r,n)=>{var o=ge(s)?{[s]:r}:s;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(s=>T.info('send "'+s?.event+'"',s)))}init(e,i,s){if(s&&s!==xi){var r,n=(r=Rs[s])!==null&&r!==void 0?r:new t;return n._init(e,i,s),Rs[s]=n,Rs[xi][s]=n,n}return this._init(e,i,s)}_init(e,i,s){var r,n;if(i===void 0&&(i={}),P(e)||Mr(e))return T.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},i.debug=this.Di(i.debug),this.qi=i,this.ji=[],i.person_profiles?this.Ni=i.person_profiles:i.process_person&&(this.Ni=i.process_person),this.set_config(pe({},Qd(i.defaults),Zd(i),{name:s,token:e})),this.config.on_xhr_error&&T.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:dt.GZipJS;var o=this.Hi();this.persistence=new Is(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Is(S({},this.config,{persistence:"sessionStorage"}),o);var a=S({},this.persistence.props),l=S({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Ui=new rl((m=>this.Bi(m)),this.config.request_queue_config),this.zi=new nl(this),this.__request_queue=[];var u=this.Ri();if(u||(this.sessionManager=new hn(this),this.sessionPropsManager=new dn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(T.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Vi(u)}),0)):(T.info("Initializing extensions synchronously"),this.Vi(u)),$e.DEBUG=$e.DEBUG||this.config.debug,$e.DEBUG&&T.info("Starting in debug mode",{this:this,config:i,thisC:S({},this.config),p:a,s:l}),!this.config.identity_distinct_id||(r=i.bootstrap)!=null&&r.distinctID||(i.bootstrap=S({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((n=i.bootstrap)==null?void 0:n.distinctID)!==void 0){var c=i.bootstrap.distinctID,h=this.get_distinct_id(),f=this.persistence.get_property(nt);if(i.bootstrap.isIdentifiedID&&h!=null&&h!==c&&f===Ai)this.identify(c);else if(i.bootstrap.isIdentifiedID&&h!=null&&h!==c&&f===Ii)T.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var g=this.config.get_device_id(Vt()),p=i.bootstrap.isIdentifiedID?g:c;this.persistence.set_property(nt,i.bootstrap.isIdentifiedID?Ii:Ai),this.register({distinct_id:c,$device_id:p})}}if(u)this.register_once({distinct_id:Cr,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(Vt());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(nt,Ai)}return be(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),i.segment?(function(m,y){var w=m.config.segment;if(!w)return y();(function(R,D){var b=R.config.segment;if(!b)return D();var x=O=>{var A=()=>O.anonymousId()||Vt();R.config.get_device_id=A,O.id()&&(R.register({distinct_id:O.id(),$device_id:A()}),R.persistence.set_property(nt,Ii)),D()},C=b.user();"then"in C&&Tt(C.then)?C.then(x):x(C)})(m,(()=>{w.register((R=>{Promise&&Promise.resolve||Wo.warn("This browser does not have Promise support, and can not use the segment integration");var D=(b,x)=>{if(!x)return b;b.event.userId||b.event.anonymousId===R.get_distinct_id()||(Wo.info("No userId set, resetting PostHog"),R.reset()),b.event.userId&&b.event.userId!==R.get_distinct_id()&&(Wo.info("UserId set, identifying with PostHog"),R.identify(b.event.userId));var C=R.calculateEventProperties(x,b.event.properties);return b.event.properties=Object.assign({},C,b.event.properties),b};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:b=>D(b,b.event.event),page:b=>D(b,Ci),identify:b=>D(b,zo),screen:b=>D(b,"$screen")}})(m)).then((()=>{y()}))}))})(this,(()=>this.Wi())):this.Wi(),Tt(this.config._onCapture)&&this.config._onCapture!==dl&&(T.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(m=>this.config._onCapture(m.event,m)))),this.config.ip&&T.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Vi(e){var i,s,r,n,o,a,l,u=performance.now(),c=S({},t.__defaultExtensionClasses,this.config.__extensionClasses),h=[];c.featureFlags&&this.Pi.push(this.featureFlags=(i=this.featureFlags)!==null&&i!==void 0?i:new c.featureFlags(this)),c.exceptions&&this.Pi.push(this.exceptions=(s=this.exceptions)!==null&&s!==void 0?s:new c.exceptions(this)),c.historyAutocapture&&this.Pi.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this.Pi.push(new c.tracingHeaders(this)),c.siteApps&&this.Pi.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this.Pi.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this.Pi.push(this.autocapture=new c.autocapture(this)),c.surveys&&this.Pi.push(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new c.surveys(this)),c.logs&&this.Pi.push(this.logs=(n=this.logs)!==null&&n!==void 0?n:new c.logs(this)),c.conversations&&this.Pi.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new c.conversations(this)),c.productTours&&this.Pi.push(this.productTours=new c.productTours(this)),c.heatmaps&&this.Pi.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this.Pi.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this.Pi.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this.Pi.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,sE)),c.toolbar&&this.Pi.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new c.toolbar(this)),c.experiments&&this.Pi.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new c.experiments(this)),this.Pi.forEach((f=>{f.initialize&&h.push((()=>{f.initialize==null||f.initialize()}))})),h.push((()=>{if(this.Zi){var f=this.Zi;this.Zi=void 0,this.Rr(f)}})),this.Gi(h,u)}Gi(e,i){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&e.length>0)return void setTimeout((()=>{this.Gi(e,i)}),0);var s=e.shift();if(s)try{s()}catch(n){T.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-i);this.register_for_session({[Zh]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[eg]:r}),this.config.__preview_deferred_init_extensions&&T.info("PostHog extensions initialized ("+r+"ms)")}Rr(e){var i;if(!I||!I.body)return T.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Rr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Zi=e),this.Qi=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=z(e.supportedCompression,dt.GZipJS)?dt.GZipJS:z(e.supportedCompression,dt.Base64)?dt.Base64:void 0),(i=e.analytics)!=null&&i.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ni?this.Ni:Ha}),this.Pi.forEach((s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(e)))}Wi(){try{this.config.loaded(this)}catch(s){T.critical("`loaded` function failed",s)}if(this.Ji(),this.config.internal_or_test_user_hostname&&Re!=null&&Re.hostname){var e=Re.hostname,i=this.config.internal_or_test_user_hostname;(typeof i=="string"?e===i:i.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Ri())&&this.Ki()}),1),this.Yi=new ln(this),this.Yi.load()}Ji(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Ui)==null||e.enable())}_dom_loaded(){this.is_capturing()&&xr(this.__request_queue,(e=>this.Bi(e))),this.__request_queue=[],this.Ji()}_handle_unload(){var e,i,s,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Xi()&&this.capture(Ho),(i=this.logs)==null||i.flushLogs("sendBeacon"),(s=this.Ui)==null||s.unload(),(r=this.zi)==null||r.unload()):this.Xi()&&this.capture(Ho,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Sg?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=mn(e.url,{ip:this.config.ip?1:0}),e.headers=S({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(i=>{var s,r,n,o=S({},i);o.timeout=o.timeout||6e4,o.url=Kd(o.url,o.compression);var a=(s=o.transport)!==null&&s!==void 0?s:"fetch",l=Gr.filter((c=>!o.disableTransport||!c.transport||!o.disableTransport.includes(c.transport))),u=(r=(n=(function(c,h){for(var f=0;c.length>f;f++)if(c[f].transport===a)return c[f]})(l))==null?void 0:n.method)!==null&&r!==void 0?r:l[0].method;if(!u)throw new Error("No available transport method");a!=="sendBeacon"&&o.data&&o.compression===dt.GZipJS&&mb&&!zd?_E(o).then((c=>{u(c)})).catch((c=>{if((h=>!(!h||typeof h!="object")&&("name"in h?String(h.name):"")==="NotReadableError")(c))return zd=!0,void u(S({},o,{compression:void 0,url:Kd(i.url,void 0)}));u(o)})):u(o)})(S({},e,{callback:i=>{var s,r;this.rateLimiter.checkForLimiting(i),400>i.statusCode||(s=(r=this.config).on_request_error)==null||s.call(r,i),e.callback==null||e.callback(i)}}))))}Bi(e){this.zi?this.zi.retriableRequest(e):this._send_request(e)}_execute_array(e){ta++;try{var i,s=[],r=[],n=[];xr(e,(a=>{a&&(Y(i=a[0])?n.push(a):Tt(a)?a.call(this):Y(a)&&i==="alias"?s.push(a):Y(a)&&i.indexOf("capture")!==-1&&Tt(this[i])?n.push(a):r.push(a))}));var o=function(a,l){xr(a,(function(u){if(Y(u[0])){var c=l;oe(u,(function(h){c=c[h[0]].apply(c,h.slice(1))}))}else l[u[0]].apply(l,u.slice(1))}))};o(s,this),o(r,this),o(n,this)}finally{ta--}}push(e){if(ta>0&&Y(e)&&ge(e[0])){var i=t.prototype[e[0]];Tt(i)&&i.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,i,s){var r,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ui){if(this.is_capturing())if(!P(e)&&ge(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=s!=null&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){i!=null&&i.$current_url&&!ge(i?.$current_url)&&(T.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),i==null||delete i.$current_url),e!=="$exception"||s!=null&&s.en||T.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var h=new Date,f=s?.timestamp||h,g=Vt(),p={uuid:g,event:e,properties:this.calculateEventProperties(e,i||{},f,g)};e===Ci&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),c&&(p.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),s?.$set&&(p.$set=s?.$set);var v,m,y,w=this.tn(s?.$set_once,e!==Fd,e===zo);if(w&&(p.$set_once=w),s!=null&&s._noTruncate||(n=this.config.properties_string_max_length,o=p,a=A=>ge(A)?A.slice(0,n):A,l=new Set,p=(function A($,U){return $!==Object($)?a?a($):$:l.has($)?void 0:(l.add($),Y($)?(H=[],xr($,(G=>{H.push(A(G))}))):(H={},oe($,((G,q)=>{l.has(G)||(H[q]=A(G,q))}))),H);var H})(o)),p.timestamp=f,P(s?.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=h),e===ks.DISMISSED||e===ks.SENT){var R=i?.[Xo.SURVEY_ID],D=i?.[Xo.SURVEY_ITERATION];(A=>{try{var $=(U=>((H,G)=>{var q=""+ul+G.id;return G.current_iteration&&G.current_iteration>0&&(q=""+ul+G.id+"_"+G.current_iteration),q})(0,U))(A);if(localStorage.getItem($))return;localStorage.setItem($,"true")}catch(U){ee.error("Failed to persist survey seen state",U)}})({id:R,current_iteration:D}),p.$set=S({},p.$set,{[(v={id:R,current_iteration:D},m=e===ks.SENT?"responded":"dismissed",y="$survey_"+m+"/"+v.id,v.current_iteration&&v.current_iteration>0&&(y="$survey_"+m+"/"+v.id+"/"+v.current_iteration),y)]:!0})}else e===ks.SHOWN&&(p.$set=S({},p.$set,{[Xo.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===cE.SHOWN){var b=i?.[Vd.TOUR_TYPE];b&&(p.$set=S({},p.$set,{[Vd.TOUR_LAST_SEEN_DATE+"/"+b]:new Date().toISOString()}))}var x=S({},p.properties.$set,p.$set);if(Di(x)||this.setPersonPropertiesForFlags(x),!K(this.config.before_send)){var C=this.rn(p);if(!C)return;p=C}this.Li.emit("eventCaptured",p);var O={method:"POST",url:(r=s?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:s?._batchKey};return!this.config.request_batching||s&&(s==null||!s._batchKey)||s!=null&&s.send_instantly?this.Bi(O):this.Ui.enqueue(O),p}T.critical("This capture call is ignored due to client rate limiting.")}}else T.error("No event name provided to posthog.capture")}else T.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(i=>e(i.event,i)))}calculateEventProperties(e,i,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return i;var o=n?void 0:this.persistence.remove_event_timer(e),a=S({},i);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.Ri()&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=S({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ge(a.distinct_id)&&!tt(a.distinct_id)||Mr(a.distinct_id))&&T.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=(function(y,w){var R,D,b,x;if(!je)return{};var C,O,A,$,U,H,G,q,me=y?[...Vi,...w||[]]:[],[Se,Me]=(function(ke){for(var k=0;Dd.length>k;k++){var[M,F]=Dd[k],B=M.exec(ke),Z=B&&(Tt(F)?F(B,ke):F);if(Z)return Z}return["",""]})(je);return pe(Rl({$os:Se,$os_version:Me,$browser:Vh(je,navigator.vendor),$device:Nd(je),$device_type:(O=je,A={userAgentDataPlatform:(R=navigator)==null||(R=R.userAgentData)==null?void 0:R.platform,maxTouchPoints:(D=navigator)==null?void 0:D.maxTouchPoints,screenWidth:_==null||(b=_.screen)==null?void 0:b.width,screenHeight:_==null||(x=_.screen)==null?void 0:x.height,devicePixelRatio:_?.devicePixelRatio},q=Nd(O),q===Th||q===Ih||q==="Kobo"||q==="Kindle Fire"||q===Bh?Mi:q===Os||q===Fi||q===Cs||q===ga?"Console":q===Ph?"Wearable":q?We:A?.userAgentDataPlatform==="Android"&&(($=A?.maxTouchPoints)!==null&&$!==void 0?$:0)>0?600>Math.min((U=A?.screenWidth)!==null&&U!==void 0?U:0,(H=A?.screenHeight)!==null&&H!==void 0?H:0)/((G=A?.devicePixelRatio)!==null&&G!==void 0?G:1)?We:Mi:"Desktop"),$timezone:hg(),$timezone_offset:lE()}),{$current_url:xs(Re?.href,me,Ds),$host:Re?.host,$pathname:Re?.pathname,$raw_user_agent:je.length>1e3?je.substring(0,997)+"...":je,$browser_version:Db(je,navigator.vendor),$browser_language:Bd(),$browser_language_prefix:(C=Bd(),typeof C=="string"?C.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.innerWidth,$lib:$e.LIB_NAME,$lib_version:$e.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime());a.$session_id=h,a.$window_id=f}this.sessionPropsManager&&pe(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&pe(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.zi)==null?void 0:g.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===al&&(a.$lib_custom_api_host=this.config.api_host),u=e!==Ci||n?e!==Ho||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=pe(a,u),e===Ci&&I&&(a.title=I.title),!P(o)){var p=s.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}je&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=pe({},c,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),Y(this.config.property_denylist)?oe(this.config.property_denylist,(function(y){delete a[y]})):T.error(Eg+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(T.error(Jd),a=v(a,e));var m=this.nn();return a.$process_person_profile=m,m&&!n&&this.sn("_calculate_event_properties"),a}tn(e,i,s){var r;if(i===void 0&&(i=!0),s===void 0&&(s=!1),!this.persistence||!this.nn()||this.Oi&&!s)return e;var n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),a=pe({},n,o||{},e||{}),l=this.config.sanitize_properties;return l&&(T.error(Jd),a=l(a,"$set_once")),i&&(this.Oi=!0),Di(a)?void 0:a}register(e,i){var s;(s=this.persistence)==null||s.register(e,i)}register_once(e,i,s){var r;(r=this.persistence)==null||r.register_once(e,i,s)}register_for_session(e){var i;(i=this.sessionPersistence)==null||i.register(e)}unregister(e){var i;(i=this.persistence)==null||i.unregister(e)}unregister_for_session(e){var i;(i=this.sessionPersistence)==null||i.unregister(e)}an(e,i){this.register({[e]:i})}getFeatureFlag(e,i){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlag(e,i)}getFeatureFlagPayload(e){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagPayload(e)}getFeatureFlagResult(e,i){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlagResult(e,i)}isFeatureEnabled(e,i){var s;return(s=this.featureFlags)==null?void 0:s.isFeatureEnabled(e,i)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,i,s){var r;(r=this.featureFlags)==null||r.updateFlags(e,i,s)}updateEarlyAccessFeatureEnrollment(e,i,s){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,i,s)}getEarlyAccessFeatures(e,i,s){var r;return i===void 0&&(i=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,i,s)}on(e,i){return this.Li.on(e,i)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:fs}),()=>{})}onSessionId(e){var i,s;return(i=(s=this.sessionManager)==null?void 0:s.onSessionId(e))!==null&&i!==void 0?i:()=>{}}getSurveys(e,i){i===void 0&&(i=!1),this.surveys?this.surveys.getSurveys(e,i):e([],{isLoaded:!1,error:fs})}getActiveMatchingSurveys(e,i){i===void 0&&(i=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,i):e([],{isLoaded:!1,error:fs})}renderSurvey(e,i){var s;(s=this.surveys)==null||s.renderSurvey(e,i)}displaySurvey(e,i){var s;i===void 0&&(i=SE),(s=this.surveys)==null||s.displaySurvey(e,i)}cancelPendingSurvey(e){var i;(i=this.surveys)==null||i.cancelPendingSurvey(e)}canRenderSurvey(e){var i,s;return(i=(s=this.surveys)==null?void 0:s.canRenderSurvey(e))!==null&&i!==void 0?i:{visible:!1,disabledReason:fs}}canRenderSurveyAsync(e,i){var s,r;return i===void 0&&(i=!1),(s=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,i))!==null&&s!==void 0?s:Promise.resolve({visible:!1,disabledReason:fs})}un(e){return!e||Mr(e)?(T.critical("Unique user id has not been set in posthog.identify"),!1):e===Cr?(T.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(T.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,i,s){if(!this.__loaded||!this.persistence)return T.uninitializedWarning("posthog.identify");if(tt(e)&&(e=e.toString(),T.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.un(e)&&this.sn("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Wr)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(ms)&&(this.unregister(ms),this.register({distinct_id:e}));var n,o=(this.persistence.get_property(nt)||Ai)===Ai;e!==r&&o?(this.persistence.set_property(nt,Ii),this.setPersonPropertiesForFlags({$set:i||{},$set_once:s||{}},!1),this.capture(zo,{distinct_id:e,$anon_distinct_id:r},{$set:i||{},$set_once:s||{}}),this.$i=Wd(e,i,s),(n=this.featureFlags)==null||n.setAnonymousDistinctId(r)):(i||s)&&this.setPersonProperties(i,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(As))}}setPersonProperties(e,i){if((e||i)&&this.sn("posthog.setPersonProperties")){var s=Wd(this.get_distinct_id(),e,i);this.$i!==s?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:i||{}},!0),this.capture("$set",{$set:e||{},$set_once:i||{}}),this.$i=s):T.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,i,s){if(e&&i){var r=this.getGroups(),n=r[e]!==i;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:S({},r,{[e]:i})}),n||s){var o={$group_type:e,$group_key:i};s&&(o.$group_set=s),this.capture(Fd,o)}s&&this.setGroupPropertiesForFlags({[e]:s}),n&&!s&&this.reloadFeatureFlags()}else T.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,i){var s;i===void 0&&(i=!0),(s=this.featureFlags)==null||s.setPersonPropertiesForFlags(e,i)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,i){var s;i===void 0&&(i=!0),this.sn("posthog.setGroupPropertiesForFlags")&&((s=this.featureFlags)==null||s.setGroupPropertiesForFlags(e,i))}resetGroupPropertiesForFlags(e){var i;(i=this.featureFlags)==null||i.resetGroupPropertiesForFlags(e)}reset(e){var i,s,r,n,o,a,l,u;if(T.info("reset"),!this.__loaded)return T.uninitializedWarning("posthog.reset");var c=this.get_property(Wr);if(this.consent.reset(),(i=this.persistence)==null||i.clear(),(s=this.sessionPersistence)==null||s.clear(),(r=this.surveys)==null||r.reset(),(n=this.Yi)==null||n.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.conversations)==null||a.reset(),(l=this.persistence)==null||l.set_property(nt,Ai),(u=this.sessionManager)==null||u.resetSessionId(),this.$i=null,this.config.cookieless_mode===Rt)this.register_once({distinct_id:Cr,$device_id:null},"");else{var h=this.config.get_device_id(Vt());this.register_once({distinct_id:h,$device_id:e?h:c},"")}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,i){var s;this.config.identity_distinct_id=e,this.config.identity_hash=i,this.alias(e),(s=this.conversations)==null||s.ln()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.hn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,i;return(e=(i=this.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:i,sessionStartTimestamp:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+i);if(e!=null&&e.withTimestamp&&s){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!s)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-s)/1e3)-o,0)}return r}alias(e,i){return e===this.get_property(Kh)?(T.critical("Attempting to create alias for existing People user - aborting."),-2):this.sn("posthog.alias")?(P(i)&&(i=this.get_distinct_id()),e!==i?(this.an(ms,e),this.capture("$create_alias",{alias:e,distinct_id:i})):(T.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var i=S({},this.config);if(ve(e)){var s,r,n,o,a,l,u,c,h,f;pe(this.config,Zd(e));var g=this.Hi();(s=this.persistence)==null||s.update_config(this.config,i,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Is(S({},this.config,{persistence:"sessionStorage"}),g);var p=this.Di(this.config.debug);gt(p)&&(this.config.debug=p),gt(this.config.debug)&&(this.config.debug?($e.DEBUG=!0,he.R()&&he.N("ph_debug",!0),T.info("set_config",{config:e,oldConfig:i,newConfig:S({},this.config)})):($e.DEBUG=!1,he.R()&&he.q("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.exceptions)==null||n.onConfigChange(),(o=this.sessionRecording)==null||o.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(l=this.heatmaps)==null||l.startIfEnabled(),(u=this.exceptionObserver)==null||u.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(h=this.surveys)==null||h.loadIfEnabled(),this.cn(),(f=this.externalIntegrations)==null||f.startIfEnabledOrStop()}}_overrideSDKInfo(e,i){$e.LIB_NAME=e,$e.LIB_VERSION=i}startSessionRecording(e){var i,s,r,n,o,a=e===!0,l={sampling:a||!(e==null||!e.sampling),linked_flag:a||!(e==null||!e.linked_flag),url_trigger:a||!(e==null||!e.url_trigger),event_trigger:a||!(e==null||!e.event_trigger)};Object.values(l).some(Boolean)&&((i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),l.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),l.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),l.url_trigger&&((n=this.sessionRecording)==null||n.overrideTrigger("url")),l.event_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,i){if(this.exceptions){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(S({},r,i))}}addExceptionStep(e,i){var s;(s=this.exceptions)==null||s.addExceptionStep(e,i)}captureLog(e){var i;(i=this.logs)==null||i.captureLog(e)}get logger(){var e,i;return(e=(i=this.logs)==null?void 0:i.logger)!==null&&e!==void 0?e:t.dn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var i,s;return(i=(s=this.toolbar)==null?void 0:s.loadToolbar(e))!==null&&i!==void 0&&i}get_property(e){var i;return(i=this.persistence)==null?void 0:i.props[e]}getSessionProperty(e){var i;return(i=this.sessionPersistence)==null?void 0:i.props[e]}toString(){var e,i=(e=this.config.name)!==null&&e!==void 0?e:xi;return i!==xi&&(i=xi+"."+i),i}_isIdentified(){var e,i;return((e=this.persistence)==null?void 0:e.get_property(nt))===Ii||((i=this.sessionPersistence)==null?void 0:i.get_property(nt))===Ii}nn(){var e,i;return!(this.config.person_profiles==="never"||this.config.person_profiles===Ha&&!this._isIdentified()&&Di(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[ms])&&((i=this.persistence)==null||(i=i.props)==null||!i[Qr]))}Xi(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.nn()||this.sn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.sn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}sn(e){return this.config.person_profiles==="never"?(T.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.an(Qr,!0),!0)}Hi(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==si)}cn(){var e,i,s,r,n=this.Hi();return((e=this.persistence)==null?void 0:e._r)!==n&&((s=this.persistence)==null||s.set_disabled(n)),((i=this.sessionPersistence)==null?void 0:i._r)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var i;if(this.config.cookieless_mode!==Rt){if(this.Ri()){var s,r,n,o,a;this.reset(!0),(s=this.sessionManager)==null||s.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new hn(this),this.pageViewManager=new sn(this),this.persistence&&(this.sessionPropsManager=new dn(this,this.sessionManager,this.persistence));var l,u=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=t.__defaultExtensionClasses)==null?void 0:a.sessionRecording;u&&(this.sessionRecording=this.Mi(this.sessionRecording,new u(this)),this.Qi&&((l=this.sessionRecording)==null||l.onRemoteConfig==null||l.onRemoteConfig(this.Qi)))}var c,h;this.consent.optInOut(!0),this.cn(),this.Ji(),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),this.config.cookieless_mode==si&&((c=this.surveys)==null||c.loadIfEnabled()),(P(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((h=e?.captureEventName)!==null&&h!==void 0?h:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ki()}else T.warn(Xd)}opt_out_capturing(){var e,i,s;this.config.cookieless_mode!==Rt?(this.config.cookieless_mode===si&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.cn(),this.config.cookieless_mode===si&&(this.register({distinct_id:Cr,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(s=this.sessionRecording)==null||s.stopRecording(),this.sessionRecording=void 0,this.Ki())):T.warn(Xd)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===Rt||(this.config.cookieless_mode===si?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.cn()}_is_bot(){return Ke?mg(Ke,this.config.custom_blocked_useragents):void 0}Ki(){I&&(I.visibilityState==="visible"?this.Fi||(this.Fi=!0,this.capture(Ci,{title:I.title},{send_instantly:!0}),this.Ai&&(I.removeEventListener(Zr,this.Ai),this.Ai=null)):this.Ai||(this.Ai=this.Ki.bind(this),be(I,Zr,this.Ai)))}debug(e){e===!1?(_?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(_?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Lr(){var e,i,s,r,n,o,a=this.qi||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(T.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(s="advanced_disable_decide",r=T,n=(i="advanced_disable_flags")in(e=a)&&!K(e[i]),o=s in e&&!K(e[s]),n?e[i]:!!o&&(r&&r.warn("Config field '"+s+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),e[s]))}rn(e){if(K(this.config.before_send))return e;var i=Y(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var r of i){if(s=r(s),K(s)){var n="Event '"+e.event+"' was rejected in beforeSend function";return Sb(e.event)?T.warn(n+". This can cause unexpected behavior."):T.info(n),null}s.properties&&!Di(s.properties)||T.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return s}getPageViewId(){var e;return(e=this.pageViewManager.dr)==null?void 0:e.pageViewId}captureTraceFeedback(e,i){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:i})}captureTraceMetric(e,i,s){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:i,$ai_metric_value:String(s)})}Di(e){var i=gt(e)&&!e,s=he.R()&&he.A("ph_debug")==="true";return!i&&(!!s||e)}};ni.__defaultExtensionClasses={},ni.dn={trace:Ti=()=>{},debug:Ti,info:Ti,warn:Ti,error:Ti,fatal:Ti},(function(t,e){for(var i=0;e.length>i;i++)t.prototype[e[i]]=Yb(t.prototype[e[i]])})(ni,["identify"]);IE=1,TE=3,RE=11;xl=["a","button","form","input","select","textarea","label"];PE=["next","previous","prev",">","<"],rh=[".ph-no-rageclick",".ph-no-capture"],gl=t=>!t||ot(t,"html")||!ai(t),nh=(t,e)=>{if(!_||gl(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[t],r=t;r.parentNode&&!ot(r,"body");)if(wg(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=Ig(r);if(!n)break;if(e||xl.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=_.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(i=!0)}s.push(n),r=n}return{parentIsUsefulElement:i,targetElementList:s}};Rg="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",OE=new RegExp("^(?:"+Rg+")$"),CE=new RegExp(Rg),Pg="\\d{3}-?\\d{2}-?\\d{4}",xE=new RegExp("^("+Pg+")$"),DE=new RegExp("("+Pg+")");pn=class{constructor(e){this.disabled=e===!1;var i=ve(e)?e:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(e,i,s){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>s-r.timestamp){if(this.clicks.push({x:e,y:i,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:i,timestamp:s}];return!1}},ia="$copy_autocapture",sa=ue("[AutoCapture]");ps=ue("[ExceptionAutocapture]");FE=ue("[TracingHeaders]"),Mt=ue("[Web Vitals]"),uh=9e5,ch="disabled",dh="lazy_loading",vs="awaiting_config",Fr="missing_config";ue("[SessionRecording]"),ue("[SessionRecording]");pl="[SessionRecording]",Ut=ue(pl),ME=ue("[Heatmaps]");gh=ue("[Product Tours]"),UE=["$set_once","$set"],Bt=ue("[SiteApps]"),fh="Error while initializing PostHog app with config id ";vl=class{constructor(e){this.vn=new Ns,this.fn=(i,s)=>this.pn(i,s)&&this.gn(i,s)&&this.mn(i,s)&&this.yn(i,s),this.pn=(i,s)=>s==null||!s.event||i?.event===s?.event,this._instance=e,this.bn=new Set,this._n=new Set}init(){var e,i;P((e=this._instance)==null?void 0:e._addCaptureHook)||(i=this._instance)==null||i._addCaptureHook(((s,r)=>{this.on(s,r)}))}register(e){var i,s;if(!P((i=this._instance)==null?void 0:i._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this._n)==null||a.add(o),(l=o.steps)==null||l.forEach((u=>{var c;(c=this.bn)==null||c.add(u?.event||"")}))})),(s=this._instance)!=null&&s.autocapture)){var r,n=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&n.add(l?.selector)}))})),(r=this._instance)==null||r.autocapture.setElementSelectors(n)}}on(e,i){var s;i!=null&&e.length!=0&&(this.bn.has(e)||this.bn.has(i?.event))&&this._n&&((s=this._n)==null?void 0:s.size)>0&&this._n.forEach((r=>{this.wn(i,r)&&this.vn.emit("actionCaptured",r.name)}))}xn(e){this.onAction("actionCaptured",(i=>e(i)))}wn(e,i){if(i?.steps==null)return!1;for(var s of i.steps)if(this.fn(e,s))return!0;return!1}onAction(e,i){return this.vn.on(e,i)}gn(e,i){if(i!=null&&i.url){var s,r=e==null||(s=e.properties)==null?void 0:s.$current_url;if(!r||typeof r!="string"||!Ri(r,i.url,i.url_matching||"contains"))return!1}return!0}mn(e,i){return!!this.Sn(e,i)&&!!this.kn(e,i)&&!!this.Cn(e,i)}Sn(e,i){var s;if(i==null||!i.href)return!0;var r=this.In(e);if(r.length>0)return r.some((a=>Ri(a.href,i.href,i.href_matching||"exact")));var n,o=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!o&&Ri((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",i.href,i.href_matching||"exact")}kn(e,i){var s;if(i==null||!i.text)return!0;var r=this.In(e);if(r.length>0)return r.some((u=>Ri(u.text,i.text,i.text_matching||"exact")||Ri(u.$el_text,i.text,i.text_matching||"exact")));var n,o,a,l=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!l&&(n=(function(u){for(var c,h=[],f=/(?::|")text="(.*?)"/g;!K(c=f.exec(u));)h.includes(c[1])||h.push(c[1]);return h})(l),o=i.text,a=i.text_matching||"exact",n.some((u=>Ri(u,o,a))))}Cn(e,i){var s,r;if(i==null||!i.selector)return!0;var n=e==null||(s=e.properties)==null?void 0:s.$element_selectors;if(n!=null&&n.includes(i.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(i.selector_regex&&o)try{return new RegExp(i.selector_regex).test(o)}catch{return!1}return!1}In(e){var i;return(e==null||(i=e.properties)==null?void 0:i.$elements)==null?[]:e?.properties.$elements}yn(e,i){return i==null||!i.properties||i.properties.length===0||bg(i.properties.reduce(((s,r)=>{var n=Y(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return s[r.key]={values:n,operator:r.operator||"exact"},s}),{}),e?.properties)}},_l=class{constructor(e){this._instance=e,this.Tn=new Map,this.En=new Map,this.Mn=new Map}Pn(e,i){return!!e&&bg(e.propertyFilters,i?.properties)}Rn(e,i){var s=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[i])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=s.get(o.name)||[];a.push(r.id),s.set(o.name,a)}}))})),s}On(e,i,s){var r=(s===cs.Activation?this.Tn:this.En).get(e),n=[];return this.Ln((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[s])==null||(a=a.values)==null?void 0:a.find((u=>u.name===e));return this.Pn(l,i)}))}register(e){var i;P((i=this._instance)==null?void 0:i._addCaptureHook)||(this.Fn(e),this.An(e))}An(e){var i=e.filter((s=>{var r,n;return((r=s.conditions)==null?void 0:r.actions)&&((n=s.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));i.length!==0&&(this.Nn==null&&(this.Nn=new vl(this._instance),this.Nn.init(),this.Nn.xn((s=>{this.onAction(s)}))),i.forEach((s=>{var r,n,o,a,l;s.conditions&&(r=s.conditions)!=null&&r.actions&&(n=s.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=s.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.Nn)==null||a.register(s.conditions.actions.values),(l=s.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((u=>{if(u&&u.name){var c=this.Mn.get(u.name);c&&c.push(s.id),this.Mn.set(u.name,c||[s.id])}})))})))}Fn(e){var i,s=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.events)&&((a=n.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),r=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.cancelEvents)&&((a=n.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));s.length===0&&r.length===0||((i=this._instance)==null||i._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.Tn=this.Rn(e,cs.Activation),this.En=this.Rn(e,cs.Cancellation))}onEvent(e,i){var s,r=this.le(),n=this.$n(),o=this.Dn(),a=((s=this._instance)==null||(s=s.persistence)==null?void 0:s.props[n])||[];if(o===e&&i&&a.length>0){var l,u;r.info("event matched, removing item from activated items",{event:e,eventPayload:i,existingActivatedItems:a});var c=(i==null||(l=i.properties)==null?void 0:l.$survey_id)||(i==null||(u=i.properties)==null?void 0:u.$product_tour_id);if(c){var h=a.indexOf(c);0>h||(a.splice(h,1),this.qn(a))}}else{if(this.En.has(e)){var f=this.On(e,i,cs.Cancellation);f.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:f.map((p=>p.id))}),f.forEach((p=>{var v=a.indexOf(p.id);0>v||a.splice(v,1),this.jn(p.id)})),this.qn(a))}if(this.Tn.has(e)){r.info("event name matched",{event:e,eventPayload:i,items:this.Tn.get(e)});var g=this.On(e,i,cs.Activation);this.qn(a.concat(g.map((p=>p.id))||[]))}}}onAction(e){var i,s=this.$n(),r=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[s])||[];this.Mn.has(e)&&this.qn(r.concat(this.Mn.get(e)||[]))}qn(e){var i=this.le(),s=[...new Set(e)].filter((r=>!this.Hn(r)));i.info("updating activated items",{activatedItems:s}),this.Un(s)}getActivatedIds(){var e,i=this.$n();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[i])||[]}getEventToItemsMap(){return this.Tn}Bn(){return this.Nn}},ml=class extends _l{constructor(e){super(e)}$n(){return Ma}Dn(){return ks.SHOWN}Ln(e){var i;(i=this._instance)==null||i.getSurveys(e)}jn(e){var i;(i=this._instance)==null||i.cancelPendingSurvey(e)}le(){return ee}Un(e){var i;(i=this._instance)==null||(i=i.persistence)==null||i.register({[Ma]:e})}Hn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},na="SDK is not enabled or survey functionality is not yet loaded",ph="Disabled. Not loading surveys.",BE=_!=null&&_.location?on(_.location.hash,"__posthog")||on(location.hash,"state"):null,vh="_postHogToolbarParams",_h=ue("[Toolbar]"),Ne=ue("[FeatureFlags]"),ei=ue("[FeatureFlags]",{debugEnabled:!0}),oa=`" failed. Feature flags didn't load in time.`,mh=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},yh=t=>{var e={};for(var[i,s]of Vr(t||{}))s&&(e[i]=s);return e},At=ue("[Error tracking]"),bh="Refusing to render web experiment since the viewer is a likely bot",VE={icontains:(t,e)=>!!_&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!_&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!_&&gn(e.href,t),not_regex:(t,e)=>!!_&&!gn(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t},yl=class t{get qt(){return this._instance.config}constructor(e){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(s){s===void 0&&(s=!1),i.getWebExperiments((r=>{t.zn("retrieved web experiments from the server"),i.Vn=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;i.Vn&&(t.zn("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=i.Vn)==null||o.set(n.feature_flag_key,n));var a=i._instance.getFeatureFlag(n.feature_flag_key);ge(a)&&n.variants[a]&&i.Wn(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];t.Zn(u)&&i.Wn(n.name,l,u.transforms)}}))}),s)},this._instance=e,this._instance.onFeatureFlags((s=>{this.onFeatureFlags(s)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())t.zn(bh);else if(!this.qt.disable_web_experiments){if(K(this.Vn))return this.Vn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.zn("applying feature flags",e),e.forEach((i=>{var s;if(this.Vn&&(s=this.Vn)!=null&&s.has(i)){var r,n=this._instance.getFeatureFlag(i),o=(r=this.Vn)==null?void 0:r.get(i);n&&o!=null&&o.variants[n]&&this.Wn(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=t.getWindowLocation();if(e!=null&&e.search){var i=nn(e?.search,"__experiment_id"),s=nn(e?.search,"__experiment_variant");i&&s&&(t.zn("previewing web experiments "+i+" && "+s),this.getWebExperiments((r=>{this.Gn(parseInt(i),s,r)}),!1,!0))}}loadIfEnabled(){this.qt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,i,s){if(this.qt.disable_web_experiments&&!s)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.qt.token),method:"GET",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}Gn(e,i,s){var r=s.filter((n=>n.id===e));r&&r.length>0&&(t.zn("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.Wn(r[0].name,i,r[0].variants[i].transforms))}static Zn(e){return!K(e.conditions)&&t.Qn(e)&&t.Jn(e)}static Qn(e){var i;if(K(e.conditions)||K((i=e.conditions)==null?void 0:i.url))return!0;var s,r,n,o=t.getWindowLocation();return!!o&&((s=e.conditions)==null||!s.url||VE[(r=(n=e.conditions)==null?void 0:n.urlMatchType)!==null&&r!==void 0?r:"icontains"](e.conditions.url,o))}static getWindowLocation(){return _?.location}static Jn(e){var i;if(K(e.conditions)||K((i=e.conditions)==null?void 0:i.utm))return!0;var s=og();if(s.utm_source){var r,n,o,a,l,u,c,h,f=(r=e.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==s.utm_campaign,g=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==s.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==s.utm_medium,v=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==s.utm_term;return f&&p&&v&&g}return!1}static zn(e){for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;i>r;r++)s[r-1]=arguments[r];T.info("[WebExperiments] "+e,s)}Wn(e,i,s){this._is_bot()?t.zn(bh):i!=="control"?s.forEach((r=>{if(r.selector){var n;t.zn("applying transform of variant "+i+" for experiment "+e+" ",r);var o=(n=document)==null?void 0:n.querySelectorAll(r.selector);o?.forEach((a=>{var l=a;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)}))}})):t.zn("Control variants leave the page unmodified.")}_is_bot(){return Ke&&this._instance?mg(Ke,this.qt.custom_blocked_useragents):void 0}},Qe=ue("[Conversations]"),ti="Conversations not available yet.",yn={featureFlags:class{constructor(t){this.Kn=!1,this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=!1,this._instance=t,this.featureFlagEventHandlers=[]}get qt(){return this._instance.config}get ni(){return this._instance.persistence}os(t){return this._instance.get_property(t)}us(){var t,e;return(t=(e=this.ni)==null?void 0:e.wr(this.qt.feature_flag_cache_ttl_ms))!==null&&t!==void 0&&t}ls(){return!!this.us()&&(this.ss||this.Xn||(this.ss=!0,Ne.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}hs(){var t,e=(t=this.qt.evaluation_contexts)!==null&&t!==void 0?t:this.qt.evaluation_environments;return!this.qt.evaluation_environments||this.qt.evaluation_contexts||this.ns||(Ne.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ns=!0),e!=null&&e.length?e.filter((i=>{var s=i&&typeof i=="string"&&i.trim().length>0;return s||Ne.error("Invalid evaluation context found:",i,"Expected non-empty string"),s})):[]}cs(){return this.hs().length>0}initialize(){var t,e,{config:i}=this._instance,s=(t=(e=i.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(s).length){var r,n,o=(r=(n=i.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(s).filter((u=>!!s[u])).reduce(((u,c)=>(u[c]=s[c]||!1,u)),{}),l=Object.keys(o).filter((u=>a[u])).reduce(((u,c)=>(o[c]&&(u[c]=o[c]),u)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,e,i){var s=i!=null&&i.merge?this.getFlagVariants():{},r=i!=null&&i.merge?this.getFlagPayloads():{},n=S({},s,t),o=S({},r,e),a={};for(var[l,u]of Object.entries(n)){var c=typeof u=="string";a[l]={key:l,enabled:!!c||!!u,variant:c?u:void 0,reason:void 0,metadata:P(o?.[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.receivedFeatureFlags({flags:a})}get hasLoadedFlags(){return this.Yn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.os(Na),e=this.os(It),i=this.os(Oi);if(!i&&!e)return t||{};var s=pe({},t||{}),r=[...new Set([...Object.keys(i||{}),...Object.keys(e||{})])];for(var n of r){var o,a,l=s[n],u=e?.[n],c=P(u)?(o=l?.enabled)!==null&&o!==void 0&&o:!!u,h=P(u)?l.variant:typeof u=="string"?u:void 0,f=i?.[n],g=S({},l,{enabled:c,variant:c?h??l?.variant:void 0});c!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),f&&(g.metadata=S({},l?.metadata,{payload:f,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),s[n]=g}return this.Kn||(Ne.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:i,finalDetails:s}),this.Kn=!0),s}getFlagVariants(){var t=this.os(Ni),e=this.os(It);if(!e)return t||{};for(var i=pe({},t),s=Object.keys(e),r=0;s.length>r;r++)i[s[r]]=e[s[r]];return this.Kn||(Ne.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Kn=!0),i}getFlagPayloads(){var t=this.os(La),e=this.os(Oi);if(!e)return t||{};for(var i=pe({},t||{}),s=Object.keys(e),r=0;s.length>r;r++)i[s[r]]=e[s[r]];return this.Kn||(Ne.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Kn=!0),i}reloadFeatureFlags(){this.es||this.qt.advanced_disable_feature_flags||this.ds||(this._instance.Li.emit("featureFlagsReloading",!0),this.ds=setTimeout((()=>{this.vs()}),5))}fs(){clearTimeout(this.ds),this.ds=void 0}ensureFlagsLoaded(){this.Yn||this.Xn||this.ds||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.es=t}vs(t){var e;if(this.fs(),!this._instance.Lr())if(this.Xn)this.ts=!0;else{var i=this.qt.token,s=this.os(Wr),r={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:S({},((e=this.ni)==null?void 0:e.get_initial_props())||{},this.os(Ss)||{}),group_properties:this.os(ii),timezone:hg()};Ot(s)||P(s)||(r.$device_id=s),(t!=null&&t.disableFlags||this.qt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.cs()&&(r.evaluation_contexts=this.hs());var n=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.qt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Xn=!0,this._instance._send_request({method:"POST",url:n,data:r,compression:this.qt.disable_compression?void 0:dt.Base64,timeout:this.qt.feature_flag_request_timeout_ms,callback:o=>{var a,l,u,c=!0;if(o.statusCode===200&&(this.ts||(this.$anon_distinct_id=void 0),c=!1),this.Xn=!1,!r.disable_flags||this.ts){this.rs=!c;var h=[];o.error?o.error instanceof Error?h.push(o.error.name==="AbortError"?"timeout":"connection_error"):h.push("unknown_error"):o.statusCode!==200&&h.push("api_error_"+o.statusCode),(a=o.json)!=null&&a.errorsWhileComputingFlags&&h.push("errors_while_computing_flags");var f,g=!((l=o.json)==null||(l=l.quotaLimited)==null||!l.includes("feature_flags"));g&&h.push("quota_limited"),(u=this.ni)==null||u.register({[Ba]:h}),g?Ne.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(r.disable_flags||this.receivedFeatureFlags((f=o.json)!==null&&f!==void 0?f:{},c,{partialResponse:!!this.qt.advanced_only_evaluate_survey_feature_flags}),this.ts&&(this.ts=!1,this.vs()))}}})}}getFeatureFlag(t,e){var i;if(e===void 0&&(e={}),!e.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var s=this.getFeatureFlagResult(t,e);return(i=s?.variant)!==null&&i!==void 0?i:s?.enabled}}else Ne.warn('getFeatureFlag for key "'+t+oa)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return e?.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var i=this.getFlagVariants(),s=t in i,r=i[t],n=this.getFlagPayloads()[t],o=String(r),a=this.os($a)||void 0,l=this.os(Xr)||void 0,u=this.os(As)||{};if(this.qt.advanced_feature_flags_dedup_per_session){var c,h=this._instance.get_session_id(),f=this.os(Ua);h&&h!==f&&(u={},(c=this.ni)==null||c.register({[As]:u,[Ua]:h}))}if((e.send_event||!("send_event"in e))&&(!(t in u)||!u[t].includes(o))){var g,p,v,m,y,w,R,D,b,x;Y(u[t])?u[t].push(o):u[t]=[o],(g=this.ni)==null||g.register({[As]:u});var C=this.getFeatureFlagDetails(t),O=[...(p=this.os(Ba))!==null&&p!==void 0?p:[]];P(r)&&O.push("flag_missing");var A={$feature_flag:t,$feature_flag_response:r,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:((v=this.qt.bootstrap)==null||(v=v.featureFlags)==null?void 0:v[t])||null,$feature_flag_bootstrapped_payload:((m=this.qt.bootstrap)==null||(m=m.featureFlagPayloads)==null?void 0:m[t])||null,$used_bootstrap_value:!this.rs};P(C==null||(y=C.metadata)==null?void 0:y.version)||(A.$feature_flag_version=C.metadata.version);var $,U=(w=C==null||(R=C.reason)==null?void 0:R.description)!==null&&w!==void 0?w:C==null||(D=C.reason)==null?void 0:D.code;U&&(A.$feature_flag_reason=U),C!=null&&(b=C.metadata)!=null&&b.id&&(A.$feature_flag_id=C.metadata.id),P(C?.original_variant)&&P(C?.original_enabled)||(A.$feature_flag_original_response=P(C.original_variant)?C.original_enabled:C.original_variant),C!=null&&(x=C.metadata)!=null&&x.original_payload&&(A.$feature_flag_original_payload=C==null||($=C.metadata)==null?void 0:$.original_payload),O.length&&(A.$feature_flag_error=O.join(",")),this._instance.capture("$feature_flag_called",A)}if(s){var H=n;if(!P(n))try{H=JSON.parse(n)}catch{}return{key:t,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:H}}}}else Ne.warn('getFeatureFlagResult for key "'+t+oa)}getRemoteConfigPayload(t,e){var i=this.qt.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this.cs()&&(s.evaluation_contexts=this.hs()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:s,compression:this.qt.disable_compression?void 0:dt.Base64,timeout:this.qt.feature_flag_request_timeout_ms,callback(r){var n,o=(n=r.json)==null?void 0:n.featureFlagPayloads;e(o?.[t]||void 0)}})}isFeatureEnabled(t,e){if(e===void 0&&(e={}),!e.fresh||this.rs){if(this.Yn||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return P(i)?void 0:!!i}Ne.warn('isFeatureEnabled for key "'+t+oa)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,i){if(this.ni){this.Yn=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();(function(o,a,l,u,c,h){l===void 0&&(l={}),u===void 0&&(u={}),c===void 0&&(c={});var f=(O=>{var A=O.flags;return A?(O.featureFlags=Object.fromEntries(Object.keys(A).map(($=>{var U;return[$,(U=A[$].variant)!==null&&U!==void 0?U:A[$].enabled]}))),O.featureFlagPayloads=Object.fromEntries(Object.keys(A).filter(($=>A[$].enabled)).filter(($=>{var U;return(U=A[$].metadata)==null?void 0:U.payload})).map(($=>{var U;return[$,(U=A[$].metadata)==null?void 0:U.payload]})))):Ne.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),O})(o),g=f.flags,p=f.featureFlags,v=f.featureFlagPayloads;if(p){var m=o.requestId,y=o.evaluatedAt;if(Y(p)){Ne.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var w={};if(p)for(var R=0;p.length>R;R++)w[p[R]]=!0;a&&a.register({[Ur]:p,[Ni]:w})}else{var D=p,b=v,x=g;if(h!=null&&h.partialResponse)D=S({},l,D),b=S({},u,b),x=S({},c,x);else if(o.errorsWhileComputingFlags)if(g){var C=new Set(Object.keys(g).filter((O=>{var A;return!((A=g[O])!=null&&A.failed)})));D=S({},l,Object.fromEntries(Object.entries(D).filter((O=>{var[A]=O;return C.has(A)})))),b=S({},u,Object.fromEntries(Object.entries(b||{}).filter((O=>{var[A]=O;return C.has(A)})))),x=S({},c,Object.fromEntries(Object.entries(x||{}).filter((O=>{var[A]=O;return C.has(A)}))))}else D=S({},l,D),b=S({},u,b),x=S({},c,x);a&&a.register(S({[Ur]:Object.keys(yh(D)),[Ni]:D||{},[La]:b||{},[Na]:x||{}},m?{[$a]:m}:{},y?{[Xr]:y}:{}))}}})(t,this.ni,s,r,n,i),e||(this.ss=!1),this.ps(e)}}override(t,e){e===void 0&&(e=!1),Ne.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.ni)return Ne.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.ni.unregister(It),this.ni.unregister(Oi),this.ps(),ei.info("All overrides cleared");if(Y(t)){var e=mh(t);return this.ni.register({[It]:e}),this.ps(),ei.info("Flag overrides set",{flags:t})}if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var i,s=t;if(this.Kn=!!((i=s.suppressWarning)!==null&&i!==void 0&&i),"flags"in s){if(s.flags===!1)this.ni.unregister(It),ei.info("Flag overrides cleared");else if(s.flags){if(Y(s.flags)){var r=mh(s.flags);this.ni.register({[It]:r})}else this.ni.register({[It]:s.flags});ei.info("Flag overrides set",{flags:s.flags})}}return"payloads"in s&&(s.payloads===!1?(this.ni.unregister(Oi),ei.info("Payload overrides cleared")):s.payloads&&(this.ni.register({[Oi]:s.payloads}),ei.info("Payload overrides set",{payloads:s.payloads}))),void this.ps()}if(t&&typeof t=="object")return this.ni.register({[It]:t}),this.ps(),ei.info("Flag overrides set",{flags:t});Ne.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Yn){var{flags:e,flagVariants:i}=this.gs();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,i){var s,r=(this.os(Es)||[]).find((l=>l.flagKey===t)),n={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=S({},this.getFlagVariants(),{[t]:e});(s=this.ni)==null||s.register({[Ur]:Object.keys(yh(a)),[Ni]:a}),this.ps()}getEarlyAccessFeatures(t,e,i){e===void 0&&(e=!1);var s=this.os(Es),r=i?"&"+i.map((n=>"stage="+n)).join("&"):"";if(s&&!e)return t(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.qt.token+r),method:"GET",callback:n=>{var o,a;if(n.json){var l=n.json.earlyAccessFeatures;return(o=this.ni)==null||o.unregister(Es),(a=this.ni)==null||a.register({[Es]:l}),t(l)}}})}gs(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((i=>e[i])),flagVariants:Object.keys(e).filter((i=>e[i])).reduce(((i,s)=>(i[s]=e[s],i)),{})}}ps(t){var{flags:e,flagVariants:i}=this.gs();this.featureFlagEventHandlers.forEach((s=>s(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var i=this.os(Ss)||{},s=t?.$set||(t!=null&&t.$set_once?{}:t),r=t?.$set_once,n={};if(r)for(var o in r)({}).hasOwnProperty.call(r,o)&&(o in i||(n[o]=r[o]));this._instance.register({[Ss]:S({},i,n,s)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Ss)}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var i=this.os(ii)||{};Object.keys(i).length!==0&&Object.keys(i).forEach((s=>{i[s]=S({},i[s],t[s]),delete t[s]})),this._instance.register({[ii]:S({},i,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.os(ii)||{};this._instance.register({[ii]:S({},e,{[t]:{}})})}else this._instance.unregister(ii)}reset(){this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.$anon_distinct_id=void 0,this.fs(),this.Kn=!1}}},GE={sessionRecording:class{get qt(){return this._instance.config}get ni(){return this._instance.persistence}get started(){var t;return!((t=this.ys)==null||!t.isStarted)}get status(){var t,e;return this.bs===vs||this.bs===Fr?this.bs:(t=(e=this.ys)==null?void 0:e.status)!==null&&t!==void 0?t:this.bs}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.bs=ch,this._s=void 0,this._instance=t,!this._instance.sessionManager)throw Ut.error("started without valid sessionManager"),new Error(pl+" started without valid sessionManager. This is a bug.");if(this.qt.cookieless_mode===Rt)throw new Error(pl+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get ws(){var t,e=!((t=this._instance.get_property(bs))==null||!t.enabled),i=!this.qt.disable_session_recording,s=this.qt.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&i&&!s}startIfEnabledOrStop(t){var e;if(!this.ws||(e=this.ys)==null||!e.isStarted){var i=!P(Object.assign)&&!P(Array.from);this.ws&&i?(this.xs(t),Ut.info("starting")):(this.bs=ch,this.stopRecording())}}xs(t){var e,i,s;this.ws&&(this.bs!==vs&&this.bs!==Fr&&(this.bs=dh),L!=null&&(e=L.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(i=L.__PosthogExtensions__)!=null&&i.initSessionRecording?this.Ss(t):(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.ks,(r=>{if(r)return Ut.error("could not load recorder",r);this.Ss(t)})))}stopRecording(){var t,e;(t=this._s)==null||t.call(this),this._s=void 0,(e=this.ys)==null||e.stop()}Cs(){var t,e;(t=this._s)==null||t.call(this),this._s=void 0,(e=this.ys)==null||e.discard()}Is(){var t;(t=this.ni)==null||t.unregister(Il)}Ts(t,e){if(K(t))return null;var i,s=tt(t)?t:parseFloat(t);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(Ut.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):s}Es(t){if(this.ni){var e,i,s=this.ni,r=()=>{var n,o=t.sessionRecording===!1?void 0:t.sessionRecording,a=this.Ts((n=this.qt.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.Ts(o?.sampleRate,"remote config sampleRate"),u=a??l;K(u)&&this.Is();var c=o?.minimumDurationMilliseconds;s.register({[bs]:S({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:S({capturePerformance:t.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:P(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};r(),(e=this._s)==null||e.call(this),this._s=(i=this._instance.sessionManager)==null?void 0:i.onSessionId(r)}}onRemoteConfig(t){return"sessionRecording"in t?t.sessionRecording===!1?(this.Es(t),void this.Cs()):(this.Es(t),void this.startIfEnabledOrStop()):(this.bs===vs&&(this.bs=Fr,Ut.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;e===void 0&&(e="log"),(i=this.ys)!=null&&i.log?this.ys.log(t,e):Ut.warn("log called before recorder was ready")}get ks(){var t,e,i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.get_property(bs);return(i==null||(e=i.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}Ms(){var t,e=this._instance.get_property(bs);if(!e)return!1;var i=(t=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&t!==void 0?t:Date.now();return 36e5>=Date.now()-i}Ss(t){var e,i;if((e=L.__PosthogExtensions__)==null||!e.initSessionRecording)return Ut.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[tg]:!0});if(this.ys||(this.ys=(i=L.__PosthogExtensions__)==null?void 0:i.initSessionRecording(this._instance),this.ys._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ms())return this.bs===Fr||this.bs===vs?void 0:(this.bs=vs,Ut.info("persisted remote config is stale, requesting fresh config before starting"),void new ln(this._instance).load());this.bs=dh,this.ys.start(t)}onRRwebEmit(t){var e;(e=this.ys)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.ys||(e=this.ni)==null||e.register({[Yh]:!0}),(t=this.ys)==null||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.ys||(e=this.ni)==null||e.register({[Wh]:!0}),(t=this.ys)==null||t.overrideSampling()}overrideTrigger(t){var e,i;this.ys||(i=this.ni)==null||i.register({[t==="url"?Xh:Jh]:!0}),(e=this.ys)==null||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.ys)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!((i=this.ys)==null||!i.tryAddCustomEvent(t,e))}}},qE={autocapture:class{constructor(t){this.Ps=!1,this.Rs=null,this.Os=!1,this.instance=t,this.rageclicks=new pn(t.config.rageclick),this.Ls=null}initialize(){this.startIfEnabled()}get qt(){var t,e,i=ve(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=(t=i.url_allowlist)==null?void 0:t.map((s=>new RegExp(s))),i.url_ignorelist=(e=i.url_ignorelist)==null?void 0:e.map((s=>new RegExp(s))),i}Fs(){if(this.isBrowserSupported()){if(_&&I){var t=i=>{i=i||_?.event;try{this.As(i)}catch(s){sa.error("Failed to capture event",s)}};if(be(I,"submit",t,{capture:!0}),be(I,"change",t,{capture:!0}),be(I,"click",t,{capture:!0}),this.qt.capture_copied_text){var e=i=>{i=i||_?.event;try{this.As(i,ia)}catch(s){sa.error("Failed to capture copy/cut event",s)}};be(I,"copy",e,{capture:!0}),be(I,"cut",e,{capture:!0})}}}else sa.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ps&&(this.Fs(),this.Ps=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.Os=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ia]:!!t.autocapture_opt_out}),this.Rs=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Ls=t}getElementSelectors(t){var e,i=[];return(e=this.Ls)==null||e.forEach((s=>{var r=I?.querySelectorAll(s);r?.forEach((n=>{t===n&&i.push(s)}))})),i}get isEnabled(){var t,e,i=(t=this.instance.persistence)==null?void 0:t.props[Ia];if(Ot(this.Rs)&&!gt(i)&&!this.instance.Lr())return!1;var s=(e=this.Rs)!==null&&e!==void 0?e:!!i;return!!this.instance.config.autocapture&&!s}As(t,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var i,s=ih(t);kg(s)&&(s=s.parentNode||null),e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(i=this.rageclicks)!=null&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&(function(h,f){if(!_||gl(h))return!1;var g,p,v;if(gt(f)?(g=!!f&&rh,p=void 0):(g=(v=f?.css_selector_ignorelist)!==null&&v!==void 0?v:rh,p=f?.content_ignorelist),g===!1)return!1;var{targetElementList:m}=nh(h,!1);return!(function(y,w){if(y===!1||P(y))return!1;var R;if(y===!0)R=PE;else{if(!Y(y))return!1;if(y.length>10)return T.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;R=y.map((D=>D.toLowerCase()))}return w.some((D=>{var{safeText:b,ariaLabel:x}=D;return R.some((C=>b.includes(C)||x.includes(C)))}))})(p,m.map((y=>{var w;return{safeText:Ls(y).toLowerCase(),ariaLabel:((w=y.getAttribute("aria-label"))==null?void 0:w.toLowerCase().trim())||""}})))&&!sh(m,g)})(s,this.instance.config.rageclick)&&this.As(t,"$rageclick");var r=e===ia;if(s&&(function(h,f,g,p,v){var m,y,w,R;if(g===void 0&&(g=void 0),!_||gl(h)||(m=g)!=null&&m.url_allowlist&&!th(g.url_allowlist)||(y=g)!=null&&y.url_ignorelist&&th(g.url_ignorelist))return!1;if((w=g)!=null&&w.dom_event_allowlist){var D=g.dom_event_allowlist;if(D&&!D.some((A=>f.type===A)))return!1}var{parentIsUsefulElement:b,targetElementList:x}=nh(h,p);if(!(function(A,$){var U=$?.element_allowlist;if(P(U))return!0;var H,G=function(me){if(U.some((Se=>me.tagName.toLowerCase()===Se)))return{v:!0}};for(var q of A)if(H=G(q))return H.v;return!1})(x,g)||!sh(x,(R=g)==null?void 0:R.css_selector_allowlist))return!1;var C=_.getComputedStyle(h);if(C&&C.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0;var O=h.tagName.toLowerCase();switch(O){case"html":return!1;case"form":return(v||["submit"]).indexOf(f.type)>=0;case"input":case"select":case"textarea":return(v||["change","click"]).indexOf(f.type)>=0;default:return b?(v||["click"]).indexOf(f.type)>=0:(v||["click"]).indexOf(f.type)>=0&&(xl.indexOf(O)>-1||h.getAttribute("contenteditable")==="true")}})(s,t,this.qt,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=$E(s,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qt.element_attribute_ignorelist,elementsChainAsString:this.Os});if(o)return!1;var a=this.getElementSelectors(s);if(a&&a.length>0&&(n.$element_selectors=a),e===ia){var l,u=Ag(_==null||(l=_.getSelection())==null?void 0:l.toString()),c=t.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return Tt(I?.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.Ns=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(T.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.$s&&this.$s(),this.$s=void 0,T.info("History API monitoring stopped")}monitorHistoryChanges(){var t,e;if(_&&_.history){var i=this;(t=_.history.pushState)!=null&&t.__posthog_wrapped__||lh(_.history,"pushState",(s=>function(r,n,o){s.call(this,r,n,o),i.Ds("pushState")})),(e=_.history.replaceState)!=null&&e.__posthog_wrapped__||lh(_.history,"replaceState",(s=>function(r,n,o){s.call(this,r,n,o),i.Ds("replaceState")})),this.qs()}}Ds(t){try{var e,i=_==null||(e=_.location)==null?void 0:e.pathname;if(!i)return;i!==this.Ns&&this.isEnabled&&this._instance.capture(Ci,{navigation_type:t}),this.Ns=i}catch(s){T.error("Error capturing "+t+" pageview",s)}}qs(){if(!this.$s){var t=()=>{this.Ds("popstate")};be(_,"popstate",t),this.$s=()=>{_&&_.removeEventListener("popstate",t)}}}},heatmaps:class{get qt(){return this.instance.config}constructor(t){var e;this.js=!1,this.Ps=!1,this.Hs=null,this.instance=t,this.js=!((e=this.instance.persistence)==null||!e.props[Ta]),this.rageclicks=new pn(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return ve(this.qt.capture_heatmaps)&&this.qt.capture_heatmaps.flush_interval_milliseconds&&(t=this.qt.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return K(this.qt.capture_heatmaps)?K(this.qt.enable_heatmaps)?this.js:this.qt.enable_heatmaps:this.qt.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Ps)return;ME.info("starting..."),this.Us(),this.At()}else{var t;clearInterval((t=this.Hs)!==null&&t!==void 0?t:void 0),this.Bs(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ta]:e}),this.js=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.M;return this.M=void 0,t}zs(t){this.Mt(t.originalEvent,"deadclick")}At(){this.Hs&&clearInterval(this.Hs),this.Hs=I?.visibilityState==="visible"?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Us(){_&&I&&(this.Vs=this.Zr.bind(this),be(_,en,this.Vs),this.Ws=t=>this.Mt(t||_?.event),be(I,"click",this.Ws,{capture:!0}),this.Zs=t=>this.Gs(t||_?.event),be(I,"mousemove",this.Zs,{capture:!0}),this.Qs=new tn(this.instance,iE,this.zs.bind(this)),this.Qs.startIfEnabledOrStop(),this.Js=this.At.bind(this),be(I,Zr,this.Js),this.Ps=!0)}Bs(){var t;_&&I&&(this.Vs&&_.removeEventListener(en,this.Vs),this.Ws&&I.removeEventListener("click",this.Ws,{capture:!0}),this.Zs&&I.removeEventListener("mousemove",this.Zs,{capture:!0}),this.Js&&I.removeEventListener(Zr,this.Js),clearTimeout(this.Ks),(t=this.Qs)==null||t.stop(),this.Ps=!1)}Ys(t,e){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var u=o;u&&ai(u)&&!ot(u,"body");){if(u===l)return!1;if(z(a,_?.getComputedStyle(u).position))return!0;u=Ig(u)}return!1})(ih(t),["fixed","sticky"],r);return{x:t.clientX+(n?0:s),y:t.clientY+(n?0:i),target_fixed:n,type:e}}Mt(t,e){var i;if(e===void 0&&(e="click"),!eh(t.target)&&hh(t)){var s=this.Ys(t,e);(i=this.rageclicks)!=null&&i.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this.Xs(S({},s,{type:"rageclick"})),this.Xs(s)}}Gs(t){!eh(t.target)&&hh(t)&&(clearTimeout(this.Ks),this.Ks=setTimeout((()=>{this.Xs(this.Ys(t,"mousemove"))}),500))}Xs(t){if(_){var e=_.location.href,i=this.qt.custom_personal_data_properties,s=this.qt.mask_personal_data_properties?[...Vi,...i||[]]:[],r=xs(e,s,Ds);this.M=this.M||{},this.M[r]||(this.M[r]=[]),this.M[r].push(t)}}Zr(){this.M&&!Di(this.M)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:tn,webVitalsAutocapture:class{constructor(t){var e;this.js=!1,this.Ps=!1,this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.eo=()=>{clearTimeout(this.ro),this.M.metrics.length!==0&&(this._instance.capture("$web_vitals",this.M.metrics.reduce(((i,s)=>S({},i,{["$web_vitals_"+s.name+"_event"]:S({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{})),this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=i=>{var s,r=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(P(r))Mt.error("Could not read session ID. Dropping metrics!");else{this.M=this.M||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.io();P(n)||(K(i?.name)||K(i?.value)?Mt.error("Invalid metric received",i):!this.no||this.no>i.value?(this.M.url!==n&&(this.eo(),this.ro=setTimeout(this.eo,this.flushToCaptureTimeoutMs)),P(this.M.url)&&(this.M.url=n),this.M.firstMetricTimestamp=P(this.M.firstMetricTimestamp)?Date.now():this.M.firstMetricTimestamp,i.attribution&&i.attribution.interactionTargetElement&&(i.attribution.interactionTargetElement=void 0),this.M.metrics.push(S({},i,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.M.metrics.length===this.allowedMetrics.length&&this.eo()):Mt.error("Ignoring metric with value >= "+this.no,i))}},this.so=()=>{if(!this.Ps){var i,s,r,n,o=L.__PosthogExtensions__;P(o)||P(o.postHogWebVitalsCallbacks)||({onLCP:i,onCLS:s,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),i&&s&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&i(this.ht.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.ht.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.ht.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.ht.bind(this)),this.Ps=!0):Mt.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.js=!((e=this._instance.persistence)==null||!e.props[Ca]),this.startIfEnabled()}get oo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=ve(this.oo)?(t=this.oo)==null?void 0:t.web_vitals_allowed_metrics:void 0;return K(i)?((e=this._instance.persistence)==null?void 0:e.props[Da])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(ve(this.oo)?this.oo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=ve(this.oo)?this.oo.web_vitals_attribution:void 0;return t!=null&&t}get no(){var t=ve(this.oo)&&tt(this.oo.__web_vitals_max_value)?this.oo.__web_vitals_max_value:uh;return t>0&&6e4>=t?uh:t}get isEnabled(){var t=Re?.protocol;if(t!=="http:"&&t!=="https:")return Mt.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=ve(this.oo)?this.oo.web_vitals:gt(this.oo)?this.oo:void 0;return gt(e)?e:this.js}startIfEnabled(){this.isEnabled&&!this.Ps&&(Mt.info("enabled, starting..."),this.lr(this.so))}onRemoteConfig(t){if("capturePerformance"in t){var e=ve(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=ve(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ca]:e}),this._instance.persistence.register({[Da]:i})),this.js=e,this.startIfEnabled()}}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?t():(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(s=>{s?Mt.error("failed to load script",s):t()}))}io(){var t=_?_.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Vi,...e||[]]:[];return xs(t,i,Ds)}Mt.error("Could not determine current URL")}}},jE={exceptionObserver:class{constructor(t){var e,i,s;this.so=()=>{var r;if(_&&this.isEnabled&&(r=L.__PosthogExtensions__)!=null&&r.errorWrappingFunctions){var n=L.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=L.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=L.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ao&&this.qt.capture_unhandled_errors&&(this.ao=n(this.captureException.bind(this))),!this.uo&&this.qt.capture_unhandled_rejections&&(this.uo=o(this.captureException.bind(this))),!this.lo&&this.qt.capture_console_errors&&(this.lo=a(this.captureException.bind(this)))}catch(l){ps.error("failed to start",l),this.ho()}}},this._instance=t,this.co=!((e=this._instance.persistence)==null||!e.props[Ra]),this.do=new da({refillRate:(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,Gt:ps}),this.qt=this.vo(),this.startIfEnabledOrStop()}vo(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return ve(t)?e=S({},e,t):(P(t)?this.co:t)&&(e=S({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.qt.capture_console_errors||this.qt.capture_unhandled_errors||this.qt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ps.info("enabled"),this.ho(),this.lr(this.so)):this.ho()}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&t(),(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return ps.error("failed to load script",s);t()}))}ho(){var t,e,i;(t=this.ao)==null||t.call(this),this.ao=void 0,(e=this.uo)==null||e.call(this),this.uo=void 0,(i=this.lo)==null||i.call(this),this.lo=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.co=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ra]:this.co}),this.qt=this.vo(),this.startIfEnabledOrStop())}onConfigChange(){this.qt=this.vo()}captureException(t){var e,i,s,r=(e=t==null||(i=t.$exception_list)==null||(i=i[0])==null?void 0:i.type)!==null&&e!==void 0?e:"Exception";this.do.consumeRateLimit(r)?ps.info("Skipping exception capture because of client rate limiting.",{exception:r}):(s=this._instance.exceptions)==null||s.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,i;this.fo=[],this.po=new pa([new _a,new wa,new ya,new ma,new Sa,new Ea,new ba,new ka],(function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;r>o;o++)n[o-1]=arguments[o];return function(a,l){l===void 0&&(l=0);for(var u=[],c=a.split(`
6
+ `),h=l;c.length>h;h++){var f=c[h];if(1024>=f.length){var g=$d.test(f)?f.replace($d,"$1"):f;if(!g.match(/\S*Error: /)){for(var p of n){var v=p(g,s);if(v){u.push(v);break}}if(u.length>=50)break}}}return(function(m){if(!m.length)return[];var y=Array.from(m);return y.reverse(),y.slice(0,50).map((w=>{return S({},w,{filename:w.filename||(R=y,R[R.length-1]||{}).filename,function:w.function||Bi});var R}))})(u)}})("web:javascript",Bb,qb)),this._instance=t,this.fo=(e=(i=this._instance.persistence)==null?void 0:i.get_property(Pa))!==null&&e!==void 0?e:[],this.mo=Kr(this.yo()),this.bo=new Aa(this.mo)}onConfigChange(){this.mo=Kr(this.yo()),this.bo.setConfig(this.mo)}onRemoteConfig(t){var e,i,s;if("errorTracking"in t){var r=(e=(i=t.errorTracking)==null?void 0:i.suppressionRules)!==null&&e!==void 0?e:[],n=(s=t.errorTracking)==null?void 0:s.captureExtensionExceptions;this.fo=r,this._instance.persistence&&this._instance.persistence.register({[Pa]:this.fo,[Oa]:n})}}get _o(){var t,e=!!this._instance.get_property(Oa),i=this._instance.config.error_tracking.captureExtensionExceptions;return(t=i??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.po.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this.mo.enabled)try{if(!ge(t)||t.trim().length===0)return void At.warn("Ignoring exception step because message must be a non-empty string");var i=this.wo(e),{sanitizedProperties:s,droppedKeys:r}=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};var o=[];return{sanitizedProperties:Object.keys(n).reduce(((a,l)=>zb.has(l)?(o.push(l),a):(a[l]=n[l],a)),{}),droppedKeys:o}})(i);r.length>0&&At.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.bo.add(S({[Hr]:t,[zr]:new Date().toISOString()},s))}catch(n){At.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.xo(e)){if(this.So(e))return this.ko("Exception dropped: matched a suppression rule"),void At.info("Skipping exception capture because a suppression rule matched");if(!this._o&&this.Co(e))return this.ko("Exception dropped: thrown by a browser extension"),void At.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Io(e))return this.ko("Exception dropped: thrown by the PostHog SDK"),void At.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.mo.enabled&&K(t.$exception_steps)?this.To(t):t;try{var s=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",en:!0});return s&&this.bo.clear(),s}catch(r){return At.error("Failed to capture exception event. Dropping this exception.",r),void this.bo.clear()}}catch(r){return void At.error("Failed to process exception event. Ignoring this exception.",r)}}To(t){try{var e=this.bo.getAttachable();return e.length===0?t:S({},t,{$exception_steps:e})}catch(i){return At.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}ko(t){this.mo.enabled&&this.bo.add({[Hr]:t,[zr]:new Date().toISOString()})}wo(t){return ve(t)?S({},t):{}}yo(){var t,e;return(t=(e=this._instance.config.error_tracking)==null?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}So(t){if(t.length===0)return!1;var e=t.reduce(((i,s)=>{var{type:r,value:n}=s;return ge(r)&&r.length>0&&i.$exception_types.push(r),ge(n)&&n.length>0&&i.$exception_values.push(n),i}),{$exception_types:[],$exception_values:[]});return this.fo.some((i=>{var s=i.values.map((r=>{var n,o=yg[r.operator],a=Y(r.value)?r.value:[r.value],l=(n=e[r.key])!==null&&n!==void 0?n:[];return a.length>0&&o(a,l)}));return i.type==="OR"?s.some(Boolean):s.every(Boolean)}))}Co(t){return t.flatMap((e=>{var i,s;return(i=(s=e.stacktrace)==null?void 0:s.frames)!==null&&i!==void 0?i:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}Io(t){if(t.length>0){var e,i,s,r,n=(e=(i=t[0].stacktrace)==null?void 0:i.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(s=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}xo(t){return!K(t)&&Y(t)}}},HE=S({productTours:class{get ni(){return this._instance.persistence}constructor(t){this.Eo=null,this.Mo=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){"productTours"in t&&(this.ni&&this.ni.register({[xa]:!!t.productTours}),this.loadIfEnabled())}loadIfEnabled(){var t,e;this.Eo||(t=this._instance).config.disable_product_tours||(e=t.persistence)==null||!e.get_property(xa)||this.lr((()=>this.Po()))}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.generateProductTours?t():(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"product-tours",(s=>{s?gh.error("Could not load product tours script",s):t()}))}Po(){var t;!this.Eo&&(t=L.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.Eo=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(e===void 0&&(e=!1),!Y(this.Mo)||e){var i=this.ni;if(i){var s=i.props[Br];if(Y(s)&&!e)return this.Mo=s,void t(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:r=>{var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return gh.error(o),void t([],{isLoaded:!1,error:o})}var a=Y(r.json.product_tours)?r.json.product_tours:[];this.Mo=a,i&&i.register({[Br]:a}),t(a,{isLoaded:!0})}})}else t(this.Mo,{isLoaded:!0})}getActiveProductTours(t){K(this.Eo)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Eo.getActiveProductTours(t)}showProductTour(t){var e;(e=this.Eo)==null||e.showTourById(t)}previewTour(t){this.Eo?this.Eo.previewTour(t):this.lr((()=>{var e;this.Po(),(e=this.Eo)==null||e.previewTour(t)}))}dismissProductTour(){var t;(t=this.Eo)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.Eo)==null||t.nextStep()}previousStep(){var t;(t=this.Eo)==null||t.previousStep()}clearCache(){var t;this.Mo=null,(t=this.ni)==null||t.unregister(Br)}resetTour(t){var e;(e=this.Eo)==null||e.resetTour(t)}resetAllTours(){var t;(t=this.Eo)==null||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.Eo)==null||e.cancelPendingTour(t)}}},yn),zE={siteApps:class{constructor(t){this._instance=t,this.Ro=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Oo(t,e){if(e){var i=this.globalsForEvent(e);this.Ro.push(i),this.Ro.length>1e3&&(this.Ro=this.Ro.slice(10))}}get siteAppLoaders(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Oo.bind(this));this.Lo=()=>{t(),this.Ro=[],this.Lo=void 0}}}globalsForEvent(t){var e,i,s,r,n,o,a;if(!t)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var[h,f]of Object.entries(c))l[h]={id:u[h],type:h,properties:f};var{$set_once:g,$set:p}=t;return{event:S({},Sh(t,UE),{properties:S({},t.properties,p?{$set:S({},(e=(i=t.properties)==null?void 0:i.$set)!==null&&e!==void 0?e:{},p)}:{},g?{$set_once:S({},(s=(r=t.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},g)}:{}),elements_chain:(n=(o=t.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=t.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var o;!e.errored&&this.Ro.length&&(Bt.info("Processing "+this.Ro.length+" events for site app with id "+t.id),this.Ro.forEach((a=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every((a=>a.processedBuffer||a.errored))&&((o=this.Lo)==null||o.call(this))},s=!1,r=o=>{e.errored=!o,e.loaded=!0,Bt.info("Site app with id "+t.id+" "+(o?"loaded":"errored")),s&&i()};try{var{processEvent:n}=t.init({posthog:this._instance,callback(o){r(o)}});n&&(e.processEvent=n),s=!0}catch(o){Bt.error(fh+t.id,o),r(!1)}if(s&&e.loaded)try{i()}catch(o){Bt.error("Error while processing buffered events PostHog app with config id "+t.id,o),e.errored=!0}}Fo(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Ao(t){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(t);for(var i of Object.values(this.apps))try{i.processEvent==null||i.processEvent(e)}catch(s){Bt.error("Error while processing event "+t.event+" for site app "+i.id,s)}}}onRemoteConfig(t){var e,i,s,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.Fo(),void this._instance.on("eventCaptured",(l=>this.Ao(l)))):void Bt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((i=this.Lo)==null||i.call(this),(s=t.siteApps)!=null&&s.length)if(this.isEnabled){var n=function(l){var u;L["__$$ph_site_app_"+l]=r._instance,(u=L.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(r._instance,a,(c=>{if(c)return Bt.error(fh+l,c)}))};for(var{id:o,url:a}of t.siteApps)n(o)}else Bt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},KE={tracingHeaders:class{constructor(t){this.No=void 0,this.$o=void 0,this.so=()=>{var e,i,s=this.Do()||[];P(this.No)&&((e=L.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(s,this._instance.get_distinct_id(),this._instance.sessionManager)),P(this.$o)&&((i=L.__PosthogExtensions__)==null||(i=i.tracingHeadersPatchFns)==null||i._patchFetch(s,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=t}initialize(){this.startIfEnabledOrStop()}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&t(),(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return FE.error("failed to load script",s);t()}))}Do(){var t;return(t=this._instance.config.addTracingHeaders)!==null&&t!==void 0?t:this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var t,e;this.Do()?this.lr(this.so):((t=this.No)==null||t.call(this),(e=this.$o)==null||e.call(this),this.No=void 0,this.$o=void 0)}}},WE=S({surveys:class{get qt(){return this._instance.config}constructor(t){this.qo=void 0,this._surveyManager=null,this.jo=!1,this.Ho=[],this.Uo=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.qt.disable_surveys){var e=t.surveys;if(K(e))return ee.warn("Flags not loaded yet. Not loading surveys.");var i=Y(e);this.qo=i?e.length>0:e,ee.info("flags response received, isSurveysEnabled: "+this.qo),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],e=0;e<localStorage.length;e++){var i=localStorage.key(e);(i!=null&&i.startsWith(ul)||i!=null&&i.startsWith("inProgressSurvey_"))&&t.push(i)}t.forEach((s=>localStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.jo)ee.info("Already initializing surveys, skipping...");else if(this.qt.disable_surveys)ee.info(ph);else if(this.qt.cookieless_mode&&this._instance.consent.isOptedOut())ee.info("Not loading surveys in cookieless mode without consent.");else{var t=L?.__PosthogExtensions__;if(t){if(!P(this.qo)||this.qt.advanced_enable_surveys){var e=this.qo||this.qt.advanced_enable_surveys;this.jo=!0;try{var i=t.generateSurveys;if(i)return void this.Bo(i,e);var s=t.loadExternalDependency;if(!s)return void this.zo(Tl);s(this._instance,"surveys",(r=>{r||!t.generateSurveys?this.zo("Could not load surveys script",r):this.Bo(t.generateSurveys,e)}))}catch(r){throw this.zo("Error initializing surveys",r),r}finally{this.jo=!1}}}else ee.error("PostHog Extensions not found.")}}Bo(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new ml(this._instance),ee.info("Surveys loaded successfully"),this.Vo({isLoaded:!0})}zo(t,e){ee.error(t,e),this.Vo({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ho.push(t),this._surveyManager&&this.Vo({isLoaded:!0}),()=>{this.Ho=this.Ho.filter((e=>e!==t))}}getSurveys(t,e){if(e===void 0&&(e=!1),this.qt.disable_surveys)return ee.info(ph),t([]);var i,s=this._instance.get_property(Fa);if(s&&!e)return t(s,{isLoaded:!0});typeof Promise<"u"&&this.Uo?this.Uo.then((r=>{var{surveys:n,context:o}=r;return t(n,o)})):(typeof Promise<"u"&&(this.Uo=new Promise((r=>{i=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.qt.token),method:"GET",timeout:this.qt.surveys_request_timeout_ms,callback:r=>{var n;this.Uo=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;ee.error(a);var l={isLoaded:!1,error:a};return t([],l),void(i==null||i({surveys:[],context:l}))}var u,c=r.json.surveys||[],h=c.filter((g=>(function(p){return!(!p.start_date||p.end_date)})(g)&&((function(p){var v;return!((v=p.conditions)==null||(v=v.events)==null||(v=v.values)==null||!v.length)})(g)||(function(p){var v;return!((v=p.conditions)==null||(v=v.actions)==null||(v=v.values)==null||!v.length)})(g))));h.length>0&&((u=this._surveyEventReceiver)==null||u.register(h)),(n=this._instance.persistence)==null||n.register({[Fa]:c});var f={isLoaded:!0};t(c,f),i?.({surveys:c,context:f})}}))}Vo(t){for(var e of this.Ho)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(i){ee.error("Error in survey callback",i)}}getActiveMatchingSurveys(t,e){if(e===void 0&&(e=!1),!K(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ee.warn("init was not called")}Wo(t){var e=null;return this.getSurveys((i=>{var s;e=(s=i.find((r=>r.id===t)))!==null&&s!==void 0?s:null})),e}Zo(t){if(K(this._surveyManager))return{eligible:!1,reason:na};var e=typeof t=="string"?this.Wo(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(K(this._surveyManager))return ee.warn("init was not called"),{visible:!1,disabledReason:na};var e=this.Zo(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return K(this._surveyManager)?(ee.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:na})):new Promise((i=>{this.getSurveys((s=>{var r,n=(r=s.find((a=>a.id===t)))!==null&&r!==void 0?r:null;if(n){var o=this.Zo(n);i({visible:o.eligible,disabledReason:o.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var s;if(K(this._surveyManager))ee.warn("init was not called");else{var r=typeof t=="string"?this.Wo(t):t;if(r!=null&&r.id)if(EE.includes(r.type)){var n=I?.querySelector(e);if(n)return(s=r.appearance)!=null&&s.surveyPopupDelaySeconds?(ee.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;ee.info("Rendering survey "+r.id+" with delay of "+((o=r.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(r,n,i),ee.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,i);ee.warn("Survey element not found")}else ee.warn("Surveys of type "+r.type+" cannot be rendered in the app");else ee.warn("Survey not found")}}displaySurvey(t,e){var i;if(K(this._surveyManager))ee.warn("init was not called");else{var s=this.Wo(t);if(s){var r=s;if((i=s.appearance)!=null&&i.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=S({},s,{appearance:S({},s.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Ja.Popover&&e.initialResponses&&ee.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(s);if(!n.visible)return void ee.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==Ja.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else ee.warn("Survey not found")}}cancelPendingSurvey(t){K(this._surveyManager)?ee.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload()}}},yn),YE={toolbar:class{constructor(t){this.instance=t}Go(t){L.ph_toolbar_state=t}Qo(){var t;return(t=L.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(t===void 0&&(t=void 0),e===void 0&&(e=void 0),i===void 0&&(i=void 0),ig(this.instance.config)||!_||!I)return!1;t=t??_.location,i=i??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var s,r=BE||on(t.hash,"__posthog")||on(t.hash,"state"),n=r?Md((()=>JSON.parse(atob(decodeURIComponent(r)))))||Md((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?t.hash=n.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((s=JSON.parse(e.getItem(vh)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch{return!1}}Jo(t){var e=L.ph_load_toolbar||L.ph_load_editor;!K(e)&&Tt(e)?e(t,this.instance):_h.warn("No toolbar load function found")}loadToolbar(t){var e=!(I==null||!I.getElementById(Qh));if(!_||e)return!1;var i=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=S({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(_.localStorage.setItem(vh,JSON.stringify(S({},s,{source:void 0}))),this.Qo()===2)this.Jo(s);else if(this.Qo()===0){var r;this.Go(1),(r=L.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return _h.error("[Toolbar] Failed to load",n),void this.Go(0);this.Go(2),this.Jo(s)})),be(_,"turbolinks:load",(()=>{this.Go(0),this.loadToolbar(s)}))}return!0}Ko(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return t===void 0&&(t=void 0),e===void 0&&(e=void 0),i===void 0&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},XE=S({experiments:yl},yn),JE={conversations:class{constructor(t){this.Yo=void 0,this._conversationsManager=null,this.Xo=!1,this.ea=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;K(e)||(gt(e)?this.Yo=e:(this.Yo=e.enabled,this.ea=e),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.Yo=void 0,this.ea=null}loadIfEnabled(){if(!(this._conversationsManager||this.Xo||this._instance.config.disable_conversations||ig(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=L?.__PosthogExtensions__;if(t&&!P(this.Yo)&&this.Yo)if(this.ea&&this.ea.token){this.Xo=!0;try{var e=t.initConversations;if(e)return this.ta(e),void(this.Xo=!1);var i=t.loadExternalDependency;if(!i)return void this.ra(Tl);i(this._instance,"conversations",(s=>{s||!t.initConversations?this.ra("Could not load conversations script",s):this.ta(t.initConversations),this.Xo=!1}))}catch(s){this.ra("Error initializing conversations",s),this.Xo=!1}}else Qe.error("Conversations enabled but missing token in remote config.")}}ta(t){if(this.ea)try{this._conversationsManager=t(this.ea,this._instance),Qe.info("Conversations loaded successfully")}catch(e){this.ra("Error completing conversations initialization",e)}else Qe.error("Cannot complete initialization: remote config is null")}ra(t,e){Qe.error(t,e),this._conversationsManager=null,this.Xo=!1}show(){this._conversationsManager?this._conversationsManager.show():Qe.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Yo===!0&&!Ot(this._conversationsManager)}isVisible(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,i){var s=this;return Ze((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,e,i):(Qe.warn(ti),null)}))()}getMessages(t,e){var i=this;return Ze((function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Qe.warn(ti),null)}))()}markAsRead(t){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Qe.warn(ti),null)}))()}getTickets(t){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Qe.warn(ti),null)}))()}requestRestoreLink(t){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Qe.warn(ti),null)}))()}restoreFromToken(t){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Qe.warn(ti),null)}))()}restoreFromUrlToken(){var t=this;return Ze((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Qe.warn(ti),null)}))()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}ln(){var t;(t=this._conversationsManager)==null||t.setIdentity()}hn(){var t;(t=this._conversationsManager)==null||t.clearIdentity()}}},QE={logs:class{constructor(t){var e;this.ia=!1,this.na=!1,this.Gt=ue("[logs]"),this.sa=[],this.oa=0,this.aa=0,this.ua=!1,this._instance=t,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.ia=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=(e=t.logs)==null?void 0:e.captureConsoleLogs;!K(i)&&i&&(this.ia=!0,this.loadIfEnabled())}reset(){this.sa=[],this.qr&&(clearTimeout(this.qr),this.qr=void 0),this.oa=0,this.aa=0,this.ua=!1}loadIfEnabled(){if(this.ia&&!this.na){var t=L?.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(i=>{var s;i||(s=t.logs)==null||!s.initializeLogs?this.Gt.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.na=!0)})):this.Gt.error(Tl)}else this.Gt.error("PostHog Extensions not found.")}}captureLog(t){var e,i,s,r,n,o;if(this._instance.is_capturing())if(t&&t.body){var a=(e=(i=this._instance.config.logs)==null?void 0:i.flushIntervalMs)!==null&&e!==void 0?e:3e3,l=(s=(r=this._instance.config.logs)==null?void 0:r.maxLogsPerInterval)!==null&&s!==void 0?s:1e3,u=Date.now();if(a>u-this.aa||(this.aa=u,this.oa=0,this.ua=!1),l>this.oa){this.oa++;var c=(function(h,f){var g=h.level||"info",{text:p,number:v}=Gh[g]||Lb,m=String(Date.now())+"000000",y={};f.distinctId&&(y.posthogDistinctId=f.distinctId),f.sessionId&&(y.sessionId=f.sessionId),f.currentUrl&&(y["url.full"]=f.currentUrl),f.screenName&&(y["screen.name"]=f.screenName),f.appState&&(y["app.state"]=f.appState),f.activeFeatureFlags&&f.activeFeatureFlags.length>0&&(y.feature_flags=f.activeFeatureFlags);var w=S({},y,h.attributes||{}),R={timeUnixNano:m,observedTimeUnixNano:m,severityNumber:v,severityText:p,body:{stringValue:h.body},attributes:Ld(w)};return h.trace_id&&(R.traceId=h.trace_id),h.span_id&&(R.spanId=h.span_id),P(h.trace_flags)||(R.flags=h.trace_flags),R})(t,this.la());this.sa.push({record:c}),((n=(o=this._instance.config.logs)==null?void 0:o.maxBufferSize)!==null&&n!==void 0?n:100)>this.sa.length?this.ha():this.flushLogs()}else this.ua||(this.Gt.warn("captureLog dropping logs: exceeded "+l+" logs per "+a+"ms"),this.ua=!0)}else this.Gt.warn("captureLog requires a body")}get logger(){return this.ca||(this.ca={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.ca}flushLogs(t){if(this.qr&&(clearTimeout(this.qr),this.qr=void 0),this.sa.length!==0){var e=this.sa;this.sa=[];var i=this._instance.config.logs,s=S({"service.name":i?.serviceName||"unknown_service"},i?.environment&&{"deployment.environment":i.environment},i?.serviceVersion&&{"service.version":i.serviceVersion},i?.resourceAttributes),r=(function(o,a,l,u){return{resourceLogs:[{resource:{attributes:Ld(a)},scopeLogs:[{scope:{name:l,version:u},logRecords:o}]}]}})(e.map((o=>o.record)),s,$e.LIB_NAME,$e.LIB_VERSION),n=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance.Bi({method:"POST",url:n,data:r,compression:"best-available",batchKey:"logs",transport:t})}}ha(){var t,e;this.qr||(this.qr=setTimeout((()=>{this.qr=void 0,this.flushLogs()}),(t=(e=this._instance.config.logs)==null?void 0:e.flushIntervalMs)!==null&&t!==void 0?t:3e3))}la(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i}if(L!=null&&(t=L.location)!=null&&t.href&&(e.currentUrl=L.location.href),this._instance.featureFlags){var s=this._instance.featureFlags.getFlags();s&&s.length>0&&(e.activeFeatureFlags=s)}return e}}},ZE=S({},yn,GE,qE,jE,HE,zE,WE,KE,YE,XE,JE,QE);ni.__defaultExtensionClasses=S({},ZE);_e=(Eh=Rs[xi]=new ni,(function(){function t(){t.done||(t.done=!0,Sg=!1,oe(Rs,(function(e){e._dom_loaded()})))}I!=null&&I.addEventListener?I.readyState==="complete"?t():be(I,"DOMContentLoaded",t,{capture:!1}):_&&T.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),Eh)});var xg={};Sn(xg,{Posthog:()=>Dl});var xe,Dl,Dg=Ue(()=>{"use strict";Cg();Zi();ts();xe=class xe{constructor(e,i=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=Lt("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let i=`ph_${e}_posthog`,s=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==i);if(s.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;s.forEach(a=>{[o,r,""].forEach(u=>{let c=u?`; Domain=${u}`:"";document.cookie=`${a}=; path=/${c}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(u=>u.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:i,config:s={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}if(xe._hasLoaded||_e.__loaded){this.log("init | PostHog already initialized, skipping re-init"),this.has_initialized=!0;return}this.cleanupStalePosthogCookies(e);let r=i||Ec();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:bc,autocapture:{dom_event_allowlist:["click"]},rate_limiting:{events_per_second:10,events_burst_limit:100},...s,person_profiles:"identified_only",capture_pageview:"history_change",capture_pageleave:!0,session_recording:{...s.session_recording,recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,maskAllInputs:!0},before_send:o=>{if(typeof window>"u"||!o)return null;if(o.timestamp){let u=o.timestamp.getTime(),c=Date.now();if(u<c-6048e5||u>c+6048e5)return this.log("init | before_send dropped event with bad timestamp",{event:o.event,timestamp:o.timestamp.toISOString()}),null}let a=window.location.hostname;if(a!=="localhost"&&a!=="127.0.0.1"&&!Sc.some(u=>a.endsWith(`.${u}`)||a===u))return this.log("init | before_send blocked event from disallowed host",{currentHost:a}),null;if(s.before_send){let l=Array.isArray(s.before_send)?s.before_send:[s.before_send],u=o;for(let c of l)u=u?c(u):null;return u}return o}};_e.init(e,n),xe._hasLoaded=!0,this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.resetIfStaleId=(e,i,s)=>{xe.isAnonymousId(e)||(this.log(`${s} | stale identified user, resetting`,{previous:e,next:i}),_e.reset())};this.identifyEvent=(e,i={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{if(!e||!e.trim()||xe.ILLEGAL_IDS.has(e.toLowerCase())){this.log("identifyEvent | skipped \u2014 invalid user_id",{user_id:e});return}let s=_e.get_distinct_id();if(s===e){this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e});return}this.resetIfStaleId(s,e,"identifyEvent"),this.log("identifyEvent | identifying user",{user_id:e,traits:i}),_e.identify(e,{...i,client_id:e}),this.has_identified=!0}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),_e.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:i,language:s,country_of_residence:r})=>{if(!(!this.has_initialized||!e)){if(!e.trim()||xe.ILLEGAL_IDS.has(e.toLowerCase())){this.log("backfillPersonProperties | skipped \u2014 invalid user_id",{user_id:e});return}try{let n=_e.get_distinct_id(),o=n===e;o||this.resetIfStaleId(n,e,"backfillPersonProperties");let a={};if(_e.get_property("client_id")||(a.client_id=e),i&&_e.get_property("is_internal")==null&&(a.is_internal=ur(i)),s&&!_e.get_property("language")&&(a.language=s),r&&!_e.get_property("country_of_residence")&&(a.country_of_residence=r),o){if(Object.keys(a).length===0){this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e});return}this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:a}),_e.setPersonProperties(a)}else a.client_id||(a.client_id=e),this.log("backfillPersonProperties | user not identified, identifying now",{user_id:e,updates:a}),_e.identify(e,a),this.has_identified=!0}catch(n){console.error("Posthog: Failed to backfill person properties",n)}}};this.capture=(e,i)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:i}),_e.capture(e,i)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let i=_e.isFeatureEnabled(e);return this.log("isFeatureEnabled",{key:e,result:i}),i}catch(i){console.error("Posthog: Failed to check feature flag",i);return}};this.getFeatureFlag=e=>{if(this.has_initialized)try{let i=_e.getFeatureFlag(e);return this.log("getFeatureFlag",{key:e,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag",i);return}};this.getFeatureFlagPayload=e=>{if(this.has_initialized)try{let i=_e.getFeatureFlagResult(e)?.payload;return this.log("getFeatureFlagPayload",{key:e,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag payload",i);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let e=_e.featureFlags?.getFlagVariants()??{},i=Object.fromEntries(Object.entries(e).filter(s=>s[1]!=null));return this.log("getAllFlags",{result:i}),i}catch(e){return console.error("Posthog: Failed to get all feature flags",e),{}}};this.onFeatureFlags=e=>{if(!this.has_initialized)return()=>{};try{this.log("onFeatureFlags | subscribing to feature flag changes");let i=_e.onFeatureFlags(e);return typeof i=="function"?i:()=>{}}catch(i){return console.error("Posthog: Failed to subscribe to feature flags",i),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),_e.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=i,this.init()}};xe._hasLoaded=!1,xe.ILLEGAL_IDS=new Set(["restored","null","undefined","anonymous","guest","distinctid","distinct_id","id","not_authenticated","email","true","false","0","none","nan"]),xe.getPosthogInstance=(e,i=!1)=>(xe._instance?e.apiKey&&e.apiKey!==xe._instance.options.apiKey&&console.warn("Posthog: getPosthogInstance called with a different API key \u2014 returning existing instance"):xe._instance=new xe(e,i),xe._instance),xe.isAnonymousId=e=>e?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!0;Dl=xe});var t0={};Sn(t0,{Analytics:()=>Ng});yo();Zi();ts();var _y=4320*60*60,Yt=class Yt{constructor(e,i,s=!1){this.analytics=new pi;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=Lt("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let i=window.location.hostname,n=["webflow.io"].some(u=>i.endsWith(u))?i:i.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let u=new Uint8Array(16);crypto.getRandomValues(u),u[6]=u[6]&15|64,u[8]=u[8]&63|128;let c=Array.from(u,h=>h.toString(16).padStart(2,"0")).join("");o=`${c.slice(0,8)}-${c.slice(8,12)}-${c.slice(12,16)}-${c.slice(16,20)}-${c.slice(20)}`}else throw new Error("Crypto API not available for secure random UUID generation");let l=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${this.rudderstack_anonymous_cookie_key}=${o}; path=/; Domain=${n}; max-age=${_y}; SameSite=Lax${l}`}catch(i){console.warn("RudderStack: Failed to set anonymous ID cookie",i)}};this.getUserId=()=>this.analytics.getUserId();this.init=e=>{if(!e){console.warn("RudderStack: Initialization skipped - no key provided");return}this.log("init | loading SDK",{dataplane:bo});try{this.setCookieIfNotExists(),this.analytics.load(e,bo,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,storage:{type:"localStorage"},lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.log("init | SDK loaded successfully",{userId:this.getUserId(),anonymousId:this.getAnonymousId()}),this.onLoadedCallback?.()}})}catch(i){console.error("RudderStack: Failed to initialize",i)}};this.identifyEvent=(e,i)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let s=this.getUserId();if(!s||s!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:i}),this.analytics.identify(e,i||{}),this.has_identified=!0}catch(r){console.error("RudderStack: Failed to identify user",r)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,i="Deriv App",s,r)=>{if(!(!this.has_initialized||e===this.current_page))try{let n={...s&&{user_id:s},...r};this.log("pageView | tracking page view",{platform:i,current_page:e,properties:n}),this.analytics.page(i,e,n),this.current_page=e}catch(n){console.error("RudderStack: Failed to track page view",n)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting RudderStack session"),this.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,i)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:i}),this.analytics.track(e,i)}catch(s){console.warn("RudderStack: Failed to track event",s)}};this.onLoadedCallback=i,this.debug=s,this.init(e)}};Yt.getRudderStackInstance=(e,i,s=!1)=>(Yt._instance||(Yt._instance=new Yt(e,i,s)),Yt._instance);var cr=Yt;var dr="cached_analytics_events",hr="cached_analytics_page_views",Pc=(t,e)=>{try{let i=localStorage.getItem(dr),s=i?JSON.parse(i):[];s.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(dr,JSON.stringify(s))}catch(i){console.warn("Analytics: Failed to cache event",i)}},Oc=(t,e)=>{try{let i=localStorage.getItem(hr),s=i?JSON.parse(i):[];s.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(hr,JSON.stringify(s))}catch(i){console.warn("Analytics: Failed to cache page view",i)}},Cc=()=>{try{let t=localStorage.getItem(dr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached events",t)}return[]},xc=()=>{try{let t=localStorage.getItem(hr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached pages",t)}return[]},Dc=()=>{try{localStorage.removeItem(dr)}catch(t){console.warn("Analytics: Failed to clear cached events",t)}},Nc=()=>{try{localStorage.removeItem(hr)}catch(t){console.warn("Analytics: Failed to clear cached page views",t)}};ts();function e0(t){let e=t?.debug??!1,i=Lt("",()=>e),s,r,n,o={},a={},l=[],u=[],c=!1,h=()=>{if(!c&&r?.has_initialized){c=!0;try{let k=Cc();k.length>0&&(i(`processStorageCache | replaying ${k.length} cached event(s)`,k),k.forEach(F=>{let B=Wt(F.properties);r?.track(F.name,B)}),Dc());let M=xc();M.length>0&&(i(`processStorageCache | replaying ${M.length} cached page view(s)`,M),M.forEach(F=>{r?.pageView(F.name,"Deriv App",D(),F.properties)}),Nc())}catch(k){console.warn("Analytics: Failed to process storage cache",k)}}},f=()=>{i("onSdkLoaded | RudderStack SDK loaded"),h(),u.length>0&&i(`onSdkLoaded | flushing ${u.length} pending identify call(s)`),u.forEach(({userId:k,traits:M})=>{k&&r?.identifyEvent(k,M)}),u=[]},g=async({growthbookKey:k,growthbookDecryptionKey:M,rudderstackKey:F,growthbookOptions:B,posthogOptions:Z,debug:ce})=>{var se,ye;ce!==void 0&&(e=ce),i("initialise | starting analytics initialization",{rudderstack:!!F,growthbook:!!k,posthog:!!Z});try{let Oe=B?.attributes?.country||(k?await Ic():void 0);if(F&&(i("initialise | initializing RudderStack"),r=cr.getRudderStackInstance(F,f,e)),B?.attributes&&Object.keys(B.attributes).length>0){let j=B.attributes,pt=r?.getAnonymousId();o={...o,country:Oe,...j.user_language&&{user_language:j.user_language},...j.account_type&&{account_type:j.account_type},...j.app_id&&{app_id:j.app_id},...j.residence_country&&{residence_country:j.residence_country},...j.device_type&&{device_type:j.device_type},...j.url&&{url:j.url},...j.email_hash&&{email_hash:j.email_hash},...j.network_type&&{network_type:j.network_type},...j.network_rtt&&{network_rtt:j.network_rtt},...j.network_downlink&&{network_downlink:j.network_downlink},...j.account_currency&&{account_currency:j.account_currency},...j.account_mode&&{account_mode:j.account_mode},loggedIn:!!j.loggedIn,...j.user_id&&!es(j.user_id)&&{user_id:j.user_id},...pt&&{anonymous_id:pt}}}B??(B={}),B.attributes??(B.attributes={});let we=r?.getAnonymousId();if((se=B.attributes).id??(se.id=we),(ye=B.attributes).country??(ye.country=Oe),k){i("initialise | initializing GrowthBook");let{Growthbook:j}=await Promise.resolve().then(()=>(Id(),Ad));s=j.getGrowthBookInstance(k,M,B,e),i("initialise | GrowthBook initialized");let pt=setInterval(()=>{Object.keys(a).length>0?clearInterval(pt):a=m("tracking-buttons-config",{})},1e3)}if(Z){i("initialise | initializing PostHog");let{Posthog:j}=await Promise.resolve().then(()=>(Dg(),xg));n=j.getPosthogInstance(Z,e),i("initialise | PostHog initialized")}i("initialise | analytics initialization complete")}catch(Oe){console.warn("Analytics: Failed to initialize",Oe)}},p=k=>{i("setAttributes | received attributes",k);let{user_id:M,...F}=k,B=M??D();if(s){let Z={...F};M&&!es(M)&&(Z.user_id=M),B&&(Z.id=B,Z.user_id=B),i("setAttributes | called GrowthBook setAttributes",Z),s.setAttributes(Z)}o={...o,...Object.fromEntries(Object.entries(F).filter(([,Z])=>Z!==void 0)),...M!==void 0&&!es(M)&&{user_id:M}},i("setAttributes | updated core_data",o)},v=k=>s?.getFeatureState(k)?.experimentResult?.name,m=(k,M)=>s?.getFeatureValue(k,M),y=async()=>await s?.getStatus(),w=k=>s?.isOn(k),R=k=>s?.setUrl(k),D=()=>{let k=r?.getUserId()||"";return k&&!es(k)?k:""},ke={initialise:g,setAttributes:p,identifyEvent:(k,M)=>{let F=k||D();if(!F){i("identifyEvent | skipped \u2014 no user_id available");return}i("identifyEvent | called",{user_id:F,traits:M});let B=ye=>{if(!ye)return ye;let{email:Oe,...we}=ye;return{...we,...Oe&&{is_internal:ur(Oe)}}},Z=M?.rudderstack!==void 0||M?.posthog!==void 0,ce,se;if(Z){let{rudderstack:ye,posthog:Oe,...we}=M;ce=B({...we,...ye}),se=B({...we,...Oe})}else ce=B(M),se=B(M);r&&(r.has_initialized?(i("identifyEvent | calling RudderStack identify",{user_id:F,traits:ce}),r.identifyEvent(F,ce)):u.some(ye=>ye.userId===F)||(i("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:F}),u.push({userId:F,traits:ce}))),n?.has_initialized&&(i("identifyEvent | calling PostHog identify",{user_id:F,traits:se}),n.identifyEvent(F,se))},backfillPersonProperties:({user_id:k,email:M,language:F,country_of_residence:B})=>{i("backfillPersonProperties | called",{user_id:k}),n?.has_initialized?(i("backfillPersonProperties | backfilling person properties in PostHog",{user_id:k}),n.backfillPersonProperties({user_id:k,email:M,language:F,country_of_residence:B})):i("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:v,getFeatureValue:m,getGrowthbookStatus:y,isFeatureOn:w,setUrl:R,getId:D,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(k,M)=>{let F=D();i("trackEvent | called",{event:k,analytics_data:M,userId:F,core_data:o});let B={...o,...M,...F&&!o.user_id&&{user_id:F}};if(i("trackEvent | built payload",{event:k,final_payload:B}),!(!(k in a)||a[k])){i("trackEvent | skipped \u2014 event disabled by tracking_config",{event:k});return}let ce=r?.has_initialized;if(!navigator.onLine||!ce)ce?(i("trackEvent | offline \u2014 caching event to memory",{event:k}),l.push({event:k,payload:B})):(i("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:k}),Pc(k,B));else{l.length>0&&(i(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(ye=>{let Oe=Wt(ye.payload);r?.track(ye.event,Oe)}),l=[]);let se=Wt(B);i("trackEvent | sending event to RudderStack",{event:k,payload:se}),r?.track(k,se)}if(n?.has_initialized){let se=Wt(Rc(B));i("trackEvent | sending event to PostHog",{event:k,payload:se}),n.capture(k,se)}},getInstances:()=>({ab:s,tracking:r,posthog:n}),pageView:(k,M="Deriv App",F)=>{let B=D();i("pageView | called",{current_page:k,platform:M,properties:F,userId:B}),r?.has_initialized?(i("pageView | sending page view to RudderStack",{current_page:k,platform:M}),r.pageView(k,M,B,F)):(i("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:k}),Oc(k,{platform:M,...F}))},reset:()=>{i("reset | resetting all providers"),r?.has_initialized&&(i("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(i("reset | resetting PostHog"),n.reset())},isPosthogFeatureEnabled:k=>n?.isFeatureEnabled(k),getPosthogFeatureFlag:k=>n?.getFeatureFlag(k),getPosthogFeatureFlagPayload:k=>n?.getFeatureFlagPayload(k),getPosthogAllFlags:()=>n?.getAllFlags()??{},onPosthogFeatureFlags:k=>n?.onFeatureFlags(k)??(()=>{}),reloadPosthogFeatureFlags:()=>n?.reloadFeatureFlags()};return typeof window<"u"&&(window.AnalyticsInstance=ke),ke}var Ng=e0();return Hg(t0);})();
7
7
  /*! Bundled license information:
8
8
 
9
9
  js-cookie/dist/js.cookie.mjs: