@deriv-com/analytics 1.40.0 → 1.40.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 Ni=Object.defineProperty;var Sg=Object.getOwnPropertyDescriptor;var kg=Object.getOwnPropertyNames;var wg=Object.prototype.hasOwnProperty;var Ag=(s,e,t)=>e in s?Ni(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Pe=(s,e)=>()=>(s&&(e=s(s=0)),e);var pn=(s,e)=>{for(var t in e)Ni(s,t,{get:e[t],enumerable:!0})},Tg=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of kg(e))!wg.call(s,r)&&r!==t&&Ni(s,r,{get:()=>e[r],enumerable:!(i=Sg(e,r))||i.enumerable});return s};var Ig=s=>Tg(Ni({},"__esModule",{value:!0}),s);var le=(s,e,t)=>Ag(s,typeof e!="symbol"?e+"":e,t);function ue(s){return s!=null&&typeof s=="object"&&s["@@functional/placeholder"]===!0}function ht(s){return function e(t){return arguments.length===0||ue(t)?e:s.apply(this,arguments)}}function Tt(s){return function e(t,i){switch(arguments.length){case 0:return e;case 1:return ue(t)?e:ht(function(r){return s(t,r)});default:return ue(t)&&ue(i)?e:ue(t)?ht(function(r){return s(r,i)}):ue(i)?ht(function(r){return s(t,r)}):s(t,i)}}}function eo(s){return function e(t,i,r){switch(arguments.length){case 0:return e;case 1:return ue(t)?e:Tt(function(n,o){return s(t,n,o)});case 2:return ue(t)&&ue(i)?e:ue(t)?Tt(function(n,o){return s(n,i,o)}):ue(i)?Tt(function(n,o){return s(t,n,o)}):ht(function(n){return s(t,i,n)});default:return ue(t)&&ue(i)&&ue(r)?e:ue(t)&&ue(i)?Tt(function(n,o){return s(n,o,r)}):ue(t)&&ue(r)?Tt(function(n,o){return s(n,i,o)}):ue(i)&&ue(r)?Tt(function(n,o){return s(t,n,o)}):ue(t)?ht(function(n){return s(n,i,r)}):ue(i)?ht(function(n){return s(t,n,r)}):ue(r)?ht(function(n){return s(t,i,n)}):s(t,i,r)}}}function Di(s,e){return Object.prototype.hasOwnProperty.call(e,s)}function ml(s){return Object.prototype.toString.call(s)==="[object Object]"}function Cg(s,e){var t=s<0?e.length+s:s;return e[t]}function Pg(s){return new RegExp(s.source,s.flags?s.flags:(s.global?"g":"")+(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.sticky?"y":"")+(s.unicode?"u":"")+(s.dotAll?"s":""))}function Zl(s,e,t){if(t||(t=new Dg),Ng(s))return s;var i=function(n){var o=t.get(s);if(o)return o;t.set(s,n);for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(n[a]=Zl(s[a],!0,t));return n};switch(Rg(s)){case"Object":return i(Object.create(Object.getPrototypeOf(s)));case"Array":return i(Array(s.length));case"Date":return new Date(s.valueOf());case"RegExp":return Pg(s);case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return s.slice();default:return s}}function Ng(s){var e=typeof s;return s==null||e!="object"&&e!="function"}function xg(s,e){for(var t=e,i=0;i<s.length;i+=1){if(t==null)return;var r=s[i];Og(r)?t=Cg(r,t):t=t[r]}return t}function Zg(s){return crypto.getRandomValues(new Uint8Array(s))}function ef(){(!mn||It+16>bl)&&(mn=Zg(bl),It=0);for(var s=0,e,t="";s<16;s++)e=mn[It+s],s==6?t+=Fi[e&15|64]:s==8?t+=Fi[e&63|128]:t+=Fi[e],s&1&&s>1&&s<11&&(t+="-");return It+=16,t}function tf(){var s=0,e,t="";if(!Li||Gt+16>256){for(Li=Array(s=256);s--;)Li[s]=256*Math.random()|0;s=Gt=0}for(;s<16;s++)e=Li[Gt+s],s==6?t+=Mi[e&15|64]:s==8?t+=Mi[e&63|128]:t+=Mi[e],s&1&&s>1&&s<11&&(t+="-");return Gt++,t}function Cf(s,e,t=Of){let i;return(...r)=>{globalThis.clearTimeout(i),i=globalThis.setTimeout(()=>{s.apply(e,r)},t)}}function er(){if(gt>1)gt--;else{var s,e=!1;for((function(){var r=Ki;for(Ki=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o})();Hs!==void 0;){var t=Hs;for(Hs=void 0,qi++;t!==void 0;){var i=t.u;if(t.u=void 0,t.f&=-3,!(8&t.f)&&fc(t))try{t.c()}catch(r){e||(s=r,e=!0)}t=i}}if(qi=0,gt--,e)throw s}}function Ee(s){if(gt>0)return s();Rn=++Gf,gt++;try{return s()}finally{er()}}function hc(s){var e=J;J=void 0;try{return s()}finally{J=e}}function gc(s){if(J!==void 0){var e=s.n;if(e===void 0||e.t!==J)return e={i:0,S:s,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,s.n=e,32&J.f&&s.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 Ie(s,e){this.v=s,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 y(s,e){return new Ie(s,e)}function fc(s){for(var e=s.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 pc(s){for(var e=s.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){s.s=e;break}}}function vc(s){for(var e=s.s,t=void 0;e!==void 0;){var i=e.p;e.i===-1?(e.S.U(e),i!==void 0&&(i.n=e.n),e.n!==void 0&&(e.n.p=i)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=i}s.s=t}function ds(s,e){Ie.call(this,void 0),this.x=s,this.s=void 0,this.g=Yi-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function _c(s){var e=s.m;if(s.m=void 0,typeof e=="function"){gt++;var t=J;J=void 0;try{e()}catch(i){throw s.f&=-2,s.f|=8,oo(s),i}finally{J=t,er()}}}function oo(s){for(var e=s.s;e!==void 0;e=e.n)e.S.U(e);s.x=void 0,s.s=void 0,_c(s)}function Hf(s){if(J!==this)throw new Error("Out-of-order effect");vc(this),J=s,this.f&=-2,8&this.f&&oo(this),er()}function hs(s,e){this.x=s,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name}function it(s,e){var t=new hs(s,e);try{t.c()}catch(r){throw t.d(),r}var i=t.d.bind(t);return i[Symbol.dispose]=i,i}function Ic(s){if(!s?.includes(":"))return[s||void 0,void 0,void 0];let e=s.startsWith("(")&&s.endsWith(")")?s.slice(1,-1):s,t=_v.exec(e);return t?[t[1]||void 0,t[2]===void 0?void 0:Number(t[2]),t[3]===void 0?void 0:Number(t[3])]:[void 0,void 0,void 0]}function mv(s){if(!Tc.test(s))return null;s.includes("(eval ")&&(s=s.replaceAll("eval code","eval").replaceAll(/(\(eval at [^()]*)|(,.*$)/g,""));let e=s.replace(/^\s+/,"").replaceAll("(eval code","(").replace(/^.*?\s+/,""),t=/ (\(.+\)$)/.exec(e),i=t?e.replace(t[0],""):e,[r,n,o]=Ic(t?t[1]:e);return{functionName:t&&i||void 0,fileName:r==="eval"||r==="<anonymous>"?void 0:r,lineNumber:n,columnNumber:o}}function yv(s){if(vv.test(s))return null;if(s.includes(" > eval")&&(s=s.replaceAll(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),!s.includes("@")&&!s.includes(":"))return{functionName:s,fileName:void 0,lineNumber:void 0,columnNumber:void 0};let e=s.lastIndexOf("@"),t=e>0?s.slice(0,e):void 0,[i,r,n]=Ic(s.slice(e+1));return{functionName:t,fileName:i,lineNumber:r,columnNumber:n}}function bv(s){if(!s.stack)throw new Error("Cannot parse given Error object");let e=s.stack.split(`
3
- `);return e.some(t=>Tc.test(t))?e.map(mv).filter(t=>t!==null):e.map(yv).filter(t=>t!==null)}function Ll(s,e,t,i){return{errorClass:xl(s),message:`${t}${xl(e)}`,type:"browserjs",stacktrace:i.reduce((r,n)=>{let o=Sv(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function $c(s,e){let t=Object.assign(s,e);for(let i of Object.keys(t))typeof t[i]=="object"&&typeof e[i]=="object"&&(t[i]=$c(t[i],e[i]));return t}async function o_(s){let e=r_[s];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((t,i)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=n_();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}t(e.lib)}).catch(i)})})}function Ne(s,e){if(!s?.default&&e){let t=Object.create(null);return t.default=s,t.__esModule=!0,t}return s}function De(s,e){return o_(s).then(t=>t.get(e).then(i=>i()))}function $_(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function M_(){return Gl||(Gl=1,(function(s,e){(function(t,i){s.exports=i()})(F_,function(){function t(g){return g=JSON.stringify(g),!!/^\{[\s\S]*\}$/.test(g)}function i(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 v="_Is_Incognit",p="yes";try{g||(g=window.localStorage),g.setItem(v,p),g.removeItem(v)}catch{var m={};m._data={},m.setItem=function(E,N){return m._data[E]=String(N)},m.getItem=function(E){return m._data.hasOwnProperty(E)?m._data[E]:void 0},m.removeItem=function(E){return delete m._data[E]},m.clear=function(){return m._data={}},g=m}finally{g.getItem(v)===p&&g.removeItem(v)}return g}var l=a();function c(){if(!(this instanceof c))return new c}c.prototype={set:function(v,p){if(v&&!t(v))l.setItem(v,i(p));else if(t(v))for(var m in v)this.set(m,v[m]);return this},get:function(v){if(v===void 0){var p={};return this.forEach(function(R,C){return p[R]=C}),p}if(v.charAt(0)==="?")return this.has(v.substr(1));var m=arguments;if(m.length>1){for(var b={},E=0,N=m.length;E<N;E++){var I=r(l.getItem(m[E]));this.has(m[E])&&(b[m[E]]=I)}return b}return r(l.getItem(v))},clear:function(){return l.clear(),this},remove:function(v){var p=this.get(v);return l.removeItem(v),p},has:function(v){return{}.hasOwnProperty.call(this.get(),v)},keys:function(){var v=[];return this.forEach(function(p){v.push(p)}),v},forEach:function(v){for(var p=0,m=l.length;p<m;p++){var b=l.key(p);v(b,this.get(b))}return this},search:function(v){for(var p=this.keys(),m={},b=0,E=p.length;b<E;b++)p[b].indexOf(v)>-1&&(m[p[b]]=this.get(p[b]));return m},len:function(){return l.length}};var d=null;function h(g,v){var p=arguments,m=null;if(d||(d=c()),p.length===0)return d.get();if(p.length===1){if(typeof g=="string")return d.get(g);if(t(g))return d.set(g)}if(p.length===2&&typeof g=="string"){if(!v)return d.remove(g);if(v&&typeof v=="string")return d.set(g,v);v&&n(v)&&(m=null,m=v(g,d.get(g)),h.set(g,m))}if(p.length===2&&o(g)&&n(v))for(var b=0,E=g.length;b<E;b++)m=v(g[b],d.get(g[b])),h.set(g[b],m);return h}for(var f in c.prototype)h[f]=c.prototype[f];return h})})(Vi)),Vi.exports}var Rg,Og,Dg,q,Lg,$g,Fg,Mg,ec,x,ne,Le,Se,Qe,Ug,se,as,Bg,to,Vg,An,Gg,Hg,jg,oe,zg,be,ft,Us,Hi,ct,tt,so,Wg,yl,ji,qg,Kg,zi,io,tc,sc,ic,vn,ro,Tn,He,rc,Fs,Ut,Bs,is,Yg,_n,Jg,Qg,Xg,xi,bl,Fi,It,mn,Gt,Mi,Li,sf,Xi,rf,nf,of,nc,af,B,lf,El,cf,uf,df,hf,gf,ff,pf,oc,vf,Je,_f,ac,K,lc,Zi,no,ge,Sl,js,mf,cc,yf,kl,bf,Ef,Gs,Sf,kf,wf,wl,Af,Al,Tf,If,Tl,In,Il,Rf,Of,uc,zs,dc,Rl,Pf,Nf,Df,xf,Lf,$f,Ff,Mf,Uf,Bf,Wi,Vf,J,Hs,gt,qi,Gf,Rn,Ki,Yi,On,$i,Ol,mc,jf,zf,Wf,Cn,pt,ut,yc,Pn,Cl,qf,Kf,Yf,Jf,Qf,Xf,Zf,ep,Pl,tp,sp,ip,rp,np,op,ap,Nl,lp,cp,bc,up,dp,hp,gp,fp,pp,vp,Dl,_p,mp,yp,bp,Ep,Sp,kp,wp,Ap,Tp,Ip,Rp,Op,Cp,Pp,Np,Dp,xp,Lp,$p,Fp,Mp,Up,Bp,Vp,Gp,Hp,Ec,tr,Sc,jp,Ws,sr,ao,kc,wc,Ac,Bt,zp,Nn,Ui,Wp,qp,Kp,Yp,Jp,Qp,Z,yn,Xp,Zp,ev,tv,sv,iv,rv,nv,ov,av,lv,cv,uv,dv,hv,gv,fv,pv,u,Tc,vv,_v,Rc,Ev,Sv,xl,Oc,kv,$l,Bi,wv,Av,Tv,Iv,Rv,Ov,Cv,Pv,Fl,Ml,Dn,Cc,Nv,Dv,xv,Lv,$v,Fv,Mv,Pc,Uv,Bv,Vv,Gv,Hv,jv,zv,Wv,qv,Kv,Nc,Dc,Yv,Jv,Qv,Xv,xn,xc,Ln,Zv,e_,t_,Ul,s_,Lc,i_,r_,n_,a_,l_,Fc,c_,u_,bn,d_,$n,xe,Fe,Ge,st,Ht,h_,g_,f_,p_,v_,__,m_,y_,b_,E_,S_,k_,rs,w_,Mc,Uc,A_,Bc,Vc,ns,Bl,Vl,T_,I_,Fn,R_,dt,O_,C_,P_,N_,D_,x_,L_,Mn,Ji,Vi,F_,Gl,U_,Mt,Gc,os,Un,lo,Bn,co,Vn,uo,Ye,B_,V_,G_,H_,j_,Gn,z_,Hn,W_,q_,Hc,K_,Y_,J_,ls,jn,jc,Q_,X_,Z_,cs,En,Sn,em,tm,sm,Hl,im,zc,rm,nm,om,am,lm,cm,um,dm,hm,Wc,gm,fm,zn,pm,qc,vm,_m,mm,Kc,ym,bm,Wn,Em,Sm,km,wm,jl,Am,zl,Tm,Wl,qn,Im,Rm,ql,kn,Yc,Om,Qi,Kl,Jc,Yl,Cm,Pm,Nm,Dm,xm,Vs,Kn,Lm,$m,Fm,wn,Mm,Um,Bm,Vm,Gm,Ms,Yn,Jn,Qn,Hm,jm,zm,Jl,Ql,Wm,qm,Km,Ym,Gi,Xn,Xl,Jm,Qm,Zn,Vt,us,ho=Pe(()=>{"use strict";Rg=ht(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Og=Number.isInteger||function(e){return e<<0===e};Dg=(function(){function s(){this.map={},this.length=0}return s.prototype.set=function(e,t){var i=this.hash(e),r=this.map[i];r||(this.map[i]=r=[]),r.push([e,t]),this.length+=1},s.prototype.hash=function(e){var t=[];for(var i in e)t.push(Object.prototype.toString.call(e[i]));return t.join()},s.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var o=this.map[t],i=0;i<o.length;i+=1){var r=o[i];if(r[0]===e)return r[1]}return}var n=this.hash(e),o=this.map[n];if(o)for(var i=0;i<o.length;i+=1){var r=o[i];if(r[0]===e)return r[1]}},s})(),q=ht(function(e){return e!=null&&typeof e.clone=="function"?e.clone():Zl(e)});Lg=eo(function(e,t,i){var r={},n;t=t||{},i=i||{};for(n in t)Di(n,t)&&(r[n]=Di(n,i)?e(n,t[n],i[n]):t[n]);for(n in i)Di(n,i)&&!Di(n,r)&&(r[n]=i[n]);return r}),$g=eo(function s(e,t,i){return Lg(function(r,n,o){return ml(n)&&ml(o)?s(e,n,o):e(r,n,o)},t,i)}),Fg=eo(function(e,t,i){return $g(function(r,n,o){return e(n,o)},t,i)}),Mg=Tt(xg),ec=Tt(function(e,t){var i={};for(var r in t)e(t[r],r,t)&&(i[r]=t[r]);return i}),x=s=>typeof s=="function"&&!!(s.constructor&&s.call&&s.apply),ne=s=>typeof s=="string",Le=s=>s===null,Se=s=>typeof s>"u",Qe=s=>Le(s)||Se(s),Ug=s=>typeof s=="bigint",se=s=>!Se(s),as=s=>!Qe(s),Bg=s=>as(s)&&s!=="",to=s=>{switch(Object.prototype.toString.call(s)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return s instanceof Error}},Vg=s=>typeof s=="boolean",An=(s,e)=>{let t=e.split(".");return Mg(t,s)},Gg=(s,e)=>!!An(s,e),Hg=s=>typeof s=="object",jg=s=>!Le(s)&&Hg(s)&&!Array.isArray(s),oe=s=>!Le(s)&&Object.prototype.toString.call(s)==="[object Object]",zg=(s,e)=>{if(!Array.isArray(s)||!Array.isArray(e))return q(e);let t=q(s);return e.forEach((i,r)=>{t[r]=Array.isArray(i)||jg(i)?be(t[r],i):i}),t},be=(s,e)=>Fg(zg,s,e),ft=s=>oe(s)&&Object.keys(s).length>0,Us=s=>{let e=ec(se,s);return Object.keys(e).forEach(t=>{let i=e[t];oe(i)&&(e[t]=Us(i))}),e},Hi=s=>{let e=ec(as,s);return Object.keys(e).forEach(t=>{let i=e[t];oe(i)&&(e[t]=Hi(i))}),e},ct=s=>{if(ft(s))return Hi(s)},tt=(s,e)=>typeof s=="boolean"?s:e,so=s=>(Object.getOwnPropertyNames(s).forEach(function(e){s[e]&&typeof s[e]=="object"&&so(s[e])}),Object.freeze(s)),Wg=s=>s.replace(/^\s+|\s+$/gm,""),yl=s=>s.replace(/^\.+/,""),ji=s=>{let e=s;if(!ne(s)&&!Qe(s))try{e=JSON.stringify(s)}catch{e=null}return e},qg=s=>{let e=Array.from(s,t=>String.fromCodePoint(t)).join("");return globalThis.btoa(e)},Kg=s=>qg(new TextEncoder().encode(s)),zi=(s,e,t,i,r)=>{let n={category:s,name:e,properties:t,options:i,callback:void 0};x(r)&&(n.callback=r),x(i)&&(n.category=s,n.name=e,n.properties=t,n.options=void 0,n.callback=i),x(t)&&(n.category=s,n.name=e,n.properties=void 0,n.options=void 0,n.callback=t),x(e)&&(n.category=s,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),x(s)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=s),oe(s)?(n.name=void 0,n.category=void 0,n.properties=s,x(e)?n.options=void 0:n.options=e):oe(e)&&(n.name=void 0,n.properties=e,x(t)?n.options=void 0:n.options=t),ne(s)&&!ne(e)&&(n.category=void 0,n.name=s),se(n.category)||(n.category=void 0),se(n.name)||(n.name=void 0),n.properties=n.properties?q(n.properties):{},se(n.options)?n.options=q(n.options):n.options=void 0;let o=ne(n.name)?n.name:n.properties.name,a=ne(n.category)?n.category:n.properties.category;return n.properties=be(oe(n.properties)?n.properties:{},{...o&&{name:o},...a&&{category:a}}),n},io=(s,e,t,i)=>{let r={name:s,properties:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.properties=e,r.options=void 0,r.callback=t),x(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=as(r.properties)?q(r.properties):{},se(r.options)?r.options=q(r.options):r.options=void 0,r},tc=(s,e,t,i)=>{let r={userId:s,traits:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.userId=s,r.traits=e,r.options=void 0,r.callback=t),x(e)&&(r.userId=s,r.traits=void 0,r.options=void 0,r.callback=e),(oe(s)||Le(s))&&(r.userId=null,r.traits=s,x(e)?r.options=void 0:r.options=e),r.userId=ji(r.userId),oe(r.traits)?r.traits=q(r.traits):r.traits=void 0,se(r.options)?r.options=q(r.options):r.options=void 0,r},sc=(s,e,t,i)=>{let r={to:s,from:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.to=s,r.from=e,r.options=void 0,r.callback=t),x(e)?(r.to=s,r.from=void 0,r.options=void 0,r.callback=e):(oe(e)||Le(e))&&(r.to=s,r.from=void 0,r.options=e),se(r.to)&&(r.to=ji(r.to)),se(r.from)?r.from=ji(r.from):r.from=void 0,se(r.options)?r.options=q(r.options):r.options=void 0,r},ic=(s,e,t,i)=>{let r={groupId:s,traits:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.groupId=s,r.traits=e,r.options=void 0,r.callback=t),x(e)&&(r.groupId=s,r.traits=void 0,r.options=void 0,r.callback=e),(oe(s)||Le(s))&&(r.groupId=null,r.traits=s,x(e)?r.options=void 0:r.options=e),r.groupId=ji(r.groupId),oe(r.traits)?r.traits=q(r.traits):r.traits=void 0,se(r.options)?r.options=q(r.options):r.options=void 0,r},vn=(function(s){return s.UNLOADED="Page Unloaded",s})({}),ro="API",Tn="CapabilitiesManager",He="ConfigManager",rc="EventManager",Fs="PluginsManager",Ut="UserSessionManager",Bs="ErrorHandler",is="PluginEngine",Yg="StoreManager",_n=`Ready${ro}`,Jg=`Load${ro}`,Qg="HttpClient",Xg="RudderStackAnalytics",xi="AnalyticsCore";bl=4096,Fi=[],It=0;for(;It<256;It++)Fi[It]=(It+256).toString(16).substring(1);Gt=256,Mi=[];for(;Gt--;)Mi[Gt]=(Gt+256).toString(16).substring(1);sf=()=>!Qe(globalThis.crypto)&&x(globalThis.crypto.getRandomValues),Xi=()=>sf()?ef():tf(),rf=()=>!!window.chrome?.runtime?.id,nf=()=>ne(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),of=(s,e=!1)=>{let t=!1,i=!1;function r(){t||(t=!0,s(i),setTimeout(()=>{t=!1},0))}(e||nf())&&globalThis.addEventListener("beforeunload",()=>{i=!1,r()}),globalThis.addEventListener("blur",()=>{i=!0,r()}),globalThis.addEventListener("focus",()=>{t=!1}),document.addEventListener("pagehide",()=>{i=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{i=!0,document.visibilityState==="hidden"?r():t=!1})},nc=s=>s.toISOString(),af=()=>nc(new Date),B=":: ",lf=s=>`A script with the id "${s}" is already loaded. Skipping the loading of this script to prevent conflicts`,El=(s,e,t)=>`Unable to load (${ne(t)?t:t.type}) the script with the id "${s}" from URL "${e}"`,cf=(s,e,t)=>`A timeout of ${t} ms occurred while trying to load the script with id "${s}" from URL "${e}"`,uf=(s,e)=>`${s}${B}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,df="Failed to convert the value to a JSON string.",hf="Failed to encode the cookie data.",gf=(s,e)=>`${s}${B}The "${e}" storage type is `,ff="JSONStringify",pf="[BigInt]",oc="[Circular Reference]",vf=(s,e,t)=>{let i=[];return function(r,n){if(!e?.includes(r)&&!(s&&Qe(n))){if(typeof n!="object"||Le(n))return n;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(n)?(t?.warn(uf(ff,r)),oc):(i.push(n),n)}}},Je=(s,e,t,i)=>{try{return JSON.stringify(s,vf(e,t,i))}catch(r){return i?.warn(df,r),null}},_f=s=>{let e=[];return function(i,r){if(Ug(r))return pf;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?oc:(e.push(r),r)}},ac=(s,e)=>{let t=Array.isArray(s)?[]:{};for(let i in s)if(Object.hasOwnProperty.call(s,i)){let r=s[i],n=e.call(s,i,r);oe(n)||Array.isArray(n)?t[i]=ac(n,e):t[i]=n}return t},K=(s,e)=>{let t=_f(),i=t.call(s,"",s);return oe(s)||Array.isArray(s)?ac(s,t):i},lc="[SDK DISPATCHED ERROR]",Zi=s=>{let{stack:e}=s;if(typeof e=="string"&&e)return e},no=(s,e)=>{if(!to(s))return new Error(`${e}: ${Je(s)}`);try{let t=s.constructor,i=new t(`${e}: ${s.message}`),r=Zi(s);return r&&(i.stack=r),Object.getOwnPropertyNames(s).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{i[n]=s[n]}catch{}}),i}catch{return new Error(`${e}: ${Je(s)}`)}},ge=s=>{if(to(s)){let e=Zi(s);e&&(s.stack=`${e}
4
- ${lc}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:s,bubbles:!0,cancelable:!0,composed:!0}))},Sl="RudderLabs JavaScript SDK",js="3.31.0",mf="com.rudderlabs.javascript",cc="npm",yf="modern",kl="RudderJS-Initiated",bf="ad-block page request",Ef="/ad-blocked",Gs="preloadedEventsBuffer",Sf="Consent Management Interaction",kf="ajs_trait_",wf="ajs_prop_",wl="ajs_aid",Af="ajs_uid",Al="ajs_event",Tf=10*1e3,If=31536e3*1e3,Tl=720*60*1e3,In=1800*1e3,Il=10*1e3,Rf=10*1e3,Of=250,uc=(s="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[s]||(globalThis.RudderStackGlobals[s]={})},zs=(s,e,t="app")=>{uc(t),globalThis.RudderStackGlobals[t][s]=e},dc=(s,e="app")=>(uc(e),globalThis.RudderStackGlobals[e][s]);Rl=(s,e)=>{let t={};return s.forEach((i,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);t[n]=s.get(r)}}),t},Pf=(s=[])=>{let e={trait:kf,properties:wf},t=new URLSearchParams(globalThis.location.search);t.get(Al)&&s.unshift(["track",t.get(Al),Rl(t,e.properties)]);let i=t.get(Af),r=Rl(t,e.trait);if(i||ft(r)){let n=[...i?[i]:[],r];s.unshift(["identify",...n])}t.get(wl)&&s.unshift(["setAnonymousId",t.get(wl)])},Nf=s=>{let e="load",t=[],i=0;for(;i<s.length;){if(s[i]&&s[i][0]===e){t=q(s[i]),s.splice(i,1);break}i+=1}return t},Df=s=>{let e="consent",t=s.filter(r=>r[0]===e),i=s.filter(r=>r[0]!==e);s.splice(0,s.length,...t,...i)},xf=s=>{let e=dc(Gs)||[];Pf(e),e.length>0&&(s.enqueuePreloadBufferEvents(e),zs(Gs,[]))},Lf=(s,e)=>{let t=s.shift(),i;if(x(e[t])){switch(t){case"page":i=zi(...s);break;case"track":i=io(...s);break;case"identify":i=tc(...s);break;case"alias":i=sc(...s);break;case"group":i=ic(...s);break;default:e[t](...s);break}i&&e[t](i)}},$f=10*1e3,Ff="RS_JS_SDK",Mf=(s,e,t=!0,i=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=i,o.onerror=r,o.src=s,o.id=e,o.async=t,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",Ff),o},Uf=s=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(s,e[0]?.firstChild);return}let t=document.getElementsByTagName("script");if(t.length>0&&t[0]?.parentNode){t[0]?.parentNode.insertBefore(s,t[0]);return}let i=document.createElement("head");i.appendChild(s);let r=document.getElementsByTagName("html")[0];r?.insertBefore(i,r.firstChild)},Bf=(s,e,t,i=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(lf(e)));try{let l;Uf(Mf(s,e,i,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(El(e,s,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(cf(e,s,t)))},t)}catch(l){o(no(l,El(e,s,"unknown")))}}),Wi=class{constructor(e,t=$f){this.logger=e,this.timeout=t}loadJSFile(e){let{url:t,id:i,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!x(o);Bf(t,i,r||this.timeout,n,a).then(c=>{l||o(c)}).catch(c=>{l||o(i,c)})}},Vf=Symbol.for("preact-signals");J=void 0;Hs=void 0,gt=0,qi=0,Gf=0,Rn=0,Ki=void 0,Yi=0;Ie.prototype.brand=Vf;Ie.prototype.h=function(){return!0};Ie.prototype.S=function(s){var e=this,t=this.t;t!==s&&s.e===void 0&&(s.x=t,this.t=s,t!==void 0?t.e=s:hc(function(){var i;(i=e.W)==null||i.call(e)}))};Ie.prototype.U=function(s){var e=this;if(this.t!==void 0){var t=s.e,i=s.x;t!==void 0&&(t.x=i,s.e=void 0),i!==void 0&&(i.e=t,s.x=void 0),s===this.t&&(this.t=i,i===void 0&&hc(function(){var r;(r=e.Z)==null||r.call(e)}))}};Ie.prototype.subscribe=function(s){var e=this;return it(function(){var t=e.value,i=J;J=void 0;try{s(t)}finally{J=i}},{name:"sub"})};Ie.prototype.valueOf=function(){return this.value};Ie.prototype.toString=function(){return this.value+""};Ie.prototype.toJSON=function(){return this.value};Ie.prototype.peek=function(){var s=J;J=void 0;try{return this.value}finally{J=s}};Object.defineProperty(Ie.prototype,"value",{get:function(){var s=gc(this);return s!==void 0&&(s.i=this.i),this.v},set:function(s){if(s!==this.v){if(qi>100)throw new Error("Cycle detected");(function(t){gt!==0&&qi===0&&t.l!==Rn&&(t.l=Rn,Ki={S:t,v:t.v,i:t.i,o:Ki})})(this),this.v=s,this.i++,Yi++,gt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{er()}}}});ds.prototype=new Ie;ds.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Yi))return!0;if(this.g=Yi,this.f|=1,this.i>0&&!fc(this))return this.f&=-2,!0;var s=J;try{pc(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(t){this.v=t,this.f|=16,this.i++}return J=s,vc(this),this.f&=-2,!0};ds.prototype.S=function(s){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}Ie.prototype.S.call(this,s)};ds.prototype.U=function(s){if(this.t!==void 0&&(Ie.prototype.U.call(this,s),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};ds.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var s=this.t;s!==void 0;s=s.x)s.t.N()}};Object.defineProperty(ds.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var s=gc(this);if(this.h(),s!==void 0&&(s.i=this.i),16&this.f)throw this.v;return this.v}});hs.prototype.c=function(){var s=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{s()}};hs.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,_c(this),pc(this),gt++;var s=J;return J=this,Hf.bind(this,s)};hs.prototype.N=function(){2&this.f||(this.f|=2,this.u=Hs,Hs=this)};hs.prototype.d=function(){this.f|=8,1&this.f||oo(this)};hs.prototype.dispose=function(){this.d()};On=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=[]}},$i={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Ol="LOG",mc="ERROR",jf="RS SDK",zf="font-weight: bold; background: black; color: white;",Wf="font-weight: normal;",Cn=class{constructor(e=Ol,t="",i=console){this.minLogLevel=$i[e],this.scope=t,this.logProvider=i}log(...e){this.outputLog("LOG",e)}info(...e){this.outputLog("INFO",e)}debug(...e){this.outputLog("DEBUG",e)}warn(...e){this.outputLog("WARN",e)}error(...e){this.outputLog("ERROR",e)}outputLog(e,t){this.minLogLevel<=$i[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=$i[e],Se(this.minLogLevel)&&(this.minLogLevel=$i[Ol])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t=`%c ${jf}`;this.scope&&(t=`${t} - ${this.scope}`);let i=ne(e[0])?e[0].trim():"";t=`${t} %c ${i}`;let r=[t,zf,Wf];return ne(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},pt=new Cn,ut=(function(s){return s.HANDLEDEXCEPTION="handledException",s.UNHANDLEDEXCEPTION="unhandledException",s.UNHANDLEDREJECTION="unhandledPromiseRejection",s})({}),yc=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Pn="cookieStorage",Cl="Unable to process/parse source configuration response",qf="The source is disabled. Please enable the source in the dashboard to send events.",Kf="Failed to prepare data for the request.",Yf="Failed to invoke plugin because the extension point name is missing.",Jf="Failed to invoke plugin because the extension point name is invalid.",Qf=s=>`${s}${B}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,Xf=(s,e,t)=>`${s}${B}The base URL "${t}" for ${e} is not valid.`,Zf=(s,e,t)=>`${s}${B}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(t)}".`,ep=(s,e)=>`${s}${B}Ignoring a non-error: ${e}.`,Pl="Failed to log breadcrumb",tp=s=>`${s}${B}Failed to handle the error.`,sp=s=>`${s}${B}Plugin name is missing.`,ip=(s,e)=>`${s}${B}Plugin "${e}" already exists.`,rp=(s,e)=>`${s}${B}Plugin "${e}" not found.`,np=(s,e)=>`${s}${B}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.`,op=(s,e,t)=>`${s}${B}Plugin "${e}" could not be loaded because some of its dependencies "${t}" do not exist.`,ap=(s,e,t)=>`${s}${B}Failed to invoke the "${e}" extension point of plugin "${t}".`,Nl="Failed to fetch the source config",lp=(s,e)=>`${s}${B}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,cp=(s,e)=>`${s}${B}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.`,bc=s=>`${s}${B}The provided callback parameter is not a function.`,up=(s,e,t,i,r)=>`${s} with status ${e} (${t}) for URL: ${i}. Response: ${r.trim()}`,dp=(s,e,t)=>`${s} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${t}`,hp=(s,e)=>`${s} for URL: ${e}`,gp=s=>`Failed to save the value for "${s}" to storage`,fp=s=>`Failed to retrieve or parse data for "${s}" from storage`,pp=s=>`The server responded with status ${s} while setting the cookies. As a fallback, the cookies will be set client side.`,vp=s=>`The server failed to set the ${s} cookie. As a fallback, the cookies will be set client side.`,Dl="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",_p=(s,e,t)=>`${s}${B}The storage type "${e}" is not supported. Please choose one of the following supported types: "${yc}". The default type "${t}" will be used instead.`,mp=(s,e,t,i)=>`${s}${B}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(t)}". The default version "${i}" will be used instead.`,yp=(s,e,t)=>`${s}${B}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${t}). To enable storage data migration, please update the storage encryption version to the latest version.`,bp=(s,e,t)=>`${s}${B}The provided cookie domain (${e}) does not match the current webpage's domain (${t}). Hence, the cookies will be set client-side.`,Ep=(s,e,t,i)=>`${s}${B}The "${e}" property defined under "${t}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i}).`,Sp=s=>`${s}${B}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,kp=s=>`${s}${B}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,wp=(s,e,t)=>`${s}${B}The session timeout value "${e}" is not a number. The default timeout of ${t} ms will be used instead.`,Ap=(s,e,t)=>`${s}${B}The session cut off duration value "${e}" is not a number. The default cut off duration of ${t} ms will be used instead.`,Tp=(s,e,t)=>`${s}${B}The session cut off duration value "${e}" ms is less than the session timeout value "${t}" ms. The cut off functionality will be disabled.`,Ip=s=>`${s}${B}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.`,Rp=(s,e,t)=>`${s}${B}The session timeout value ${e} ms is less than the recommended minimum of ${t} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,Op=(s,e,t)=>`${s}${B}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${t}" digits long. A new session ID will be auto-generated instead.`,Cp=s=>`${s}${B}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,Pp=(s,e,t,i)=>`${s}${B}The storage type "${t}" is not available for entry "${e}". The SDK will initialize the entry with "${i}" storage type instead.`,Np=s=>`${s}${B}The callback threw an exception`,Dp=(s,e)=>`${s}${B}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,xp=(s,e)=>`Failed to load the polyfill script with ID "${s}" from URL ${e}.`,Lp=(s,e,t)=>`${s}${B}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${t}" will be used instead.`,$p=(s,e,t)=>`${s}${B}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${t}" will be used instead.`,Fp=(s,e)=>`${s}${B}${e} plugin is deprecated. Please exclude it from the load API options.`,Mp=(s,e,t,i)=>{let r=t.length===1,n=r?` '${t[0]}' plugin was`:` ['${t.join("', '")}'] plugins were`,o=`${s}${B}${e}, but${n} not configured to load.`;return i?`${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.`},Up=(s,e)=>`${s}${B}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,Bp=s=>`${s}${B}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,Vp=(s,e)=>`${s}${B}Ignoring unknown plugins: ${e.join(", ")}.`,Gp=(s,e)=>`${s}${B}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.`,Hp=(s,e)=>`${s}${B}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,Ec={All:!0},tr="js-integrations",Sc="plugins",jp=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_]*)?$"),Ws="modern",sr="https://cdn.rudderlabs.com",ao="v3",kc=`${sr}/${ao}/${Ws}/${tr}`,wc=`${sr}/${ao}/${Ws}/${Sc}`,Ac="https://api.rudderstack.com",Bt="v3",zp="xhr",Nn={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Ui={[Bt]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},Wp={[zp]:"XhrQueue",beacon:"BeaconQueue"},qp="rsaRequest",Kp="rsaMetrics",Yp="Custom Device Mode",Jp={configUrl:Ac,loadIntegration:!0,sessions:{autoTrack:!0,timeout:In,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:Ec,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:Rf,storage:{encryption:{version:Bt},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},Qp=y(q(Jp)),Z=so({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),yn=so({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Xp=10,Zp={userId:y(Z.userId),userTraits:y(Z.userTraits),anonymousId:y(Z.anonymousId),groupId:y(Z.groupId),groupTraits:y(Z.groupTraits),initialReferrer:y(Z.initialReferrer),initialReferringDomain:y(Z.initialReferringDomain),sessionInfo:y(Z.sessionInfo),authToken:y(Z.authToken)},ev={isOnline:y(!0),storage:{isLocalStorageAvailable:y(!1),isCookieStorageAvailable:y(!1),isSessionStorageAvailable:y(!1)},isBeaconAvailable:y(!1),isLegacyDOM:y(!1),isUaCHAvailable:y(!1),isCryptoAvailable:y(!1),isAdBlockerDetectionInProgress:y(!1),isAdBlocked:y(void 0),cspBlockedURLs:y([])},tv={isErrorReportingEnabled:y(!1),isMetricsReportingEnabled:y(!1),breadcrumbs:y([])},sv=y(void 0),iv={activeDataplaneUrl:y(void 0),integrationsCDNPath:y(kc),pluginsCDNPath:y(wc),sourceConfigUrl:y(void 0),status:y(void 0),initialized:y(!1),logLevel:y(mc),loaded:y(!1),readyCallbacks:y([]),writeKey:y(void 0),dataPlaneUrl:y(void 0),safeAnalyticsInstance:y(void 0)},rv={enabled:y(!1),initialized:y(!1),data:y({}),activeConsentManagerPluginName:y(void 0),preConsent:y({enabled:!1}),postConsent:y({}),resolutionStrategy:y("and"),provider:y(void 0),metadata:y(void 0)},nv={retries:y(0),dropped:y(0),sent:y(0),queued:y(0),triggered:y(0),metricsServiceUrl:y(void 0)},ov=()=>yf,av={app:y({name:Sl,namespace:mf,version:js,installType:cc}),traits:y(null),library:y({name:Sl,version:js,snippetVersion:globalThis.RudderSnippetVersion,variant:ov()}),userAgent:y(null),device:y(null),network:y(null),os:y({name:"",version:""}),locale:y(null),screen:y({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":y(void 0),timezone:y(void 0)},lv={configuredDestinations:y([]),activeDestinations:y([]),loadOnlyIntegrations:y({}),failedDestinations:y([]),loadIntegration:y(!0),initializedDestinations:y([]),clientDestinationsReady:y(!1),integrationsConfig:y({})},cv={toBeProcessedArray:y([]),readyCallbacksArray:y([])},uv={ready:y(!1),loadedPlugins:y([]),failedPlugins:y([]),pluginsToLoadFromConfig:y([]),activePlugins:y([]),totalPluginsToLoad:y(0)},dv={encryptionPluginName:y(void 0),migrate:y(!1),type:y(void 0),cookie:y(void 0),entries:y({}),trulyAnonymousTracking:y(!1)},hv={isEnabledServerSideCookies:y(!1),dataServiceUrl:y(void 0)},gv={eventsQueuePluginName:y(void 0),deliveryEnabled:y(!0)},fv={enabled:y(!1),pageLifecycle:{enabled:y(!1),pageViewId:y(void 0),pageLoadedTimestamp:y(void 0)}},pv={capabilities:ev,consents:rv,context:av,eventBuffer:cv,lifecycle:iv,loadOptions:Qp,metrics:nv,nativeDestinations:lv,plugins:uv,reporting:tv,session:Zp,source:sv,storage:dv,serverCookies:hv,dataPlaneEvents:gv,autoTrack:fv},u={...q(pv)},Tc=/^\s*at /,vv=/^(eval@)?(\[native code])?$/,_v=/(.+?)(?::(\d+))?(?::(\d+))?$/;Rc="global code",Ev=s=>se(s)&&/^global code$/i.test(s)?Rc:s,Sv=s=>{let e={file:s.fileName,method:Ev(s.functionName),lineNumber:s.lineNumber,columnNumber:s.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Rc),e},xl=s=>ne(s)?s:"";Oc=(s,e)=>{let t;return to(s)&&ne(Zi(s))?t=s:(e.warn(ep(Bs,Je(s))),t=void 0),t},kv=(s,e)=>{try{let t=bv(s);return Ll(s.name,s.message,e,t)}catch{return Ll(s.name,s.message,e,[])}},$l=(s,e)=>{try{return JSON.parse(s||"")}catch(t){let i=no(t,"Failed to parse response data");e(i)}},Bi="The request failed",wv=[/Failed to fetch dynamically imported module: .*/],Av=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],Tv=[new RegExp(`${Bi}.*`),/A script with the id .* is already loaded\./],Iv=[...wv,...Av],Rv="integrations",Ov="sdk",Cv=Ov,Pv={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Fl=(s,e,t)=>{let i=be(Pv,e||{});return t&&(i.headers=be(i.headers,{Authorization:t})),i.url=s,i},Ml=(s,e=Tf,t)=>new Promise((i,r)=>{let n;if(s.sendRawData===!0)n=s.data;else if(n=Je(s.data,!1,[],t),Le(n)){r({error:new Error(Kf),undefined:void 0,options:s});return}let o=new XMLHttpRequest,a=c=>{r({error:new Error(up(Bi,o.status,o.statusText,s.url,o.responseText)),xhr:o,options:s})},l=c=>{r({error:new Error(dp(Bi,c,s.url)),xhr:o,options:s,...c?.type==="timeout"?{timedOut:!0}:{}})};o.ontimeout=l,o.onerror=l,o.onload=()=>{o.status>=200&&o.status<400?i({response:o.responseText,xhr:o,options:s}):a()},o.open(s.method,s.url,!0),s.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(s.headers).forEach(c=>{s.headers[c]&&o.setRequestHeader(c,s.headers[c])});try{o.send(n)}catch(c){r({error:no(c,hp(Bi,s.url)),xhr:o,options:s})}}),Dn=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:t,options:i,timeout:r,isRawResponse:n}=e;try{let o=await Ml(Fl(t,i,this.basicAuthHeader),r,this.logger);return{data:n?o.response:$l(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:t,url:i,options:r,timeout:n,isRawResponse:o}=e,a=!x(t);Ml(Fl(i,r,this.basicAuthHeader),n,this.logger).then(l=>{a||t(o?l.response:$l(l.response,this.onError),l)}).catch(l=>{a||t(void 0,l)})}onError(e,t){this.errorHandler?.onError({error:e,context:Qg,groupingHash:t})}setAuthHeader(e,t=!1){let i=t?e:Kg(`${e}:`);this.basicAuthHeader=`Basic ${i}`}resetAuthHeader(){this.basicAuthHeader=void 0}},Cc=new Dn(pt),Nv="1",Dv=()=>["rsa"],xv=["www.test-host.com","localhost","127.0.0.1","[::1]"],Lv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],$v="RudderStack JavaScript SDK",Fv="git+https://github.com/rudderlabs/rudder-sdk-js.git",Mv="js",Pc=s=>{u.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(u.lifecycle.sourceConfigUrl.value),t=`${e.origin}${e.pathname}?view=ad`;s.getAsyncData({url:t,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(i,r)=>{u.capabilities.isAdBlockerDetectionInProgress.value=!1,u.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==t}})}catch(e){throw u.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},Uv=(s,e)=>{switch(e){case ut.UNHANDLEDEXCEPTION:{let{error:t}=s;return t||s}case ut.UNHANDLEDREJECTION:return s.reason;case ut.HANDLEDEXCEPTION:default:return s}},Bv=s=>({type:"manual",name:s,timestamp:new Date,metaData:{}}),Vv=(s=()=>window.location.hostname)=>{let e=s();return!e||e&&xv.includes(e)?"development":"production"},Gv=s=>{let e=Je(s,!1,Lv);return e!==null?JSON.parse(e):{}},Hv=()=>globalThis.location.href.split("?")[0],jv=(s,e,t,i)=>({id:`${s.value?.id??t.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${i.pageLifecycle.pageViewId.value??"NA"}`,name:s.value?.name??"NA"}),zv=(s,e)=>({locale:s.value??"NA",userAgent:e.value??"NA",time:new Date}),Wv=(s,e,t,i)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:c}=t,{app:d,locale:h,userAgent:f,timezone:g,screen:v,library:p}=r;return{payloadVersion:"5",notifier:{name:$v,version:d.value.version,url:Fv},events:[{exceptions:[q(s)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:d.value.version,releaseStage:Vv(),type:d.value.installType},device:zv(h,f),request:{url:Hv(),clientIp:"[NOT COLLECTED]"},breadcrumbs:q(l.breadcrumbs.value),context:s.message,groupingHash:i,metaData:{app:{snippetVersion:p.value.snippetVersion},device:{...v.value,timezone:g.value},...Gv(t)},user:jv(a,o,n,c)}]}},qv=(s,e,t)=>{if(Se(s.capabilities.isAdBlocked.value)){s.capabilities.isAdBlockerDetectionInProgress.value===!1&&Pc(e);let i=it(()=>{se(s.capabilities.isAdBlocked.value)&&(t(s.capabilities.isAdBlocked.value===!1),i())})}else t(s.capabilities.isAdBlocked.value===!1)},Kv=(s,e,t)=>{let i=s.message;return new Promise(r=>{if(Iv.some(n=>n.test(i))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(i)?.[0];ne(n)?n.startsWith(sr)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):qv(e,t,r):r(!1):r(!0)}else r(!Tv.some(n=>n.test(i)))})},Nc=s=>s?s.split("/").at(-2):void 0,Dc=s=>{let e=s.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},Yv=s=>{let e=Dc(s);if(!e)return!1;let t=e.substring(e.lastIndexOf("/")+1);return Nc(e)===tr||Dv().some(r=>t.startsWith(r)&&t.endsWith(".js"))},Jv=(s,e)=>{if(e)return e;let t=Dc(s);return Nc(t)===tr?Rv:Cv},Qv=(s,e,t)=>{let i={version:Nv,message_id:Xi(),source:{name:Mv,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:t},errors:s};return Je(i)},Xv=(s,e,t)=>{let i;if(!se(s))i=e;else if(ne(s))i=s;else{let r=Oc(s,t);se(r)?i=r.message:i=e}return i},xn=class{constructor(e,t){le(this,"initialized",!1);this.httpClient=e,this.logger=t}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Bs,errorType:ut.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Bs,errorType:ut.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let t=ne(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&t.startsWith(sr)&&!u.capabilities.cspBlockedURLs.value.includes(t)&&(u.capabilities.cspBlockedURLs.value=[...u.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{let{error:t,context:i,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??ut.HANDLEDEXCEPTION,l=Uv(t,a),c=Oc(l,this.logger);if(Se(c))return;let d=r?`${r} - `:"",h=`${i}${B}${d}`,f=kv(c,h),v=Zi(c).includes(lc);if(!v&&!Yv(f)&&a!==ut.HANDLEDEXCEPTION)return;if(u.reporting.isErrorReportingEnabled.value&&await Kv(f,u,this.httpClient)){let m={severity:"error",unhandled:a!==ut.HANDLEDEXCEPTION,severityReason:{type:a}},b=Xv(n,f.message,this.logger),E=Wv(f,m,u,b),N=Jv(f,o);this.httpClient.getAsyncData({url:u.metrics.metricsServiceUrl.value,options:{method:"POST",data:Qv(E,u,N),sendRawData:!0},isRawResponse:!0})}(a===ut.HANDLEDEXCEPTION||v)&&this.logger.error(f.message)}catch(t){this.logger.error(tp(Bs),t)}}leaveBreadcrumb(e){try{u.reporting.breadcrumbs.value=[...u.reporting.breadcrumbs.value,Bv(e)]}catch(t){this.onError({error:t,context:Bs,customMessage:Pl,groupingHash:Pl})}}},xc=new xn(Cc,pt),Ln=class{constructor(e,t={}){le(this,"plugins",[]);le(this,"byName",{});le(this,"cache",{});le(this,"config",{throws:!0});this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){let r=sp(is);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=ip(is,e.name);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},this.plugins=this.plugins.slice();let i=this.plugins.length;this.plugins.forEach((r,n)=>{r.deps?.includes(e.name)&&(i=Math.min(i,n))}),this.plugins.splice(i,0,e),this.byName[e.name]=e,x(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let r=rp(is,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let i=this.plugins.indexOf(t);if(i===-1){let r=np(is,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(i,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(i=>{if(i.deps?.some(r=>!this.byName[r])){let r=i.deps.filter(n=>!this.byName[n]);return this.logger.error(op(is,i.name,r)),!1}return t==="."?!0:Gg(i,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...i){let r=e;if(!r)throw new Error(Yf);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(Jf);let a=r.split(".");a.pop();let l=a.join(".");return(t?this.getPlugins(r):[this.getPlugins(r)[0]]).map(d=>{let h=An(d,r);if(!x(h)||n)return h;try{return h.apply(An(d,l),i)}catch(f){if(o)throw f;this.logger.error(ap(is,r,d.name),f)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}},Zv=new Ln(pt,{throws:!0}),e_=s=>s.config.connectionMode!=="cloud"||s.config.useNativeSDKToSend===!0||s.config.useNativeSDK===!0,t_=s=>s.config.connectionMode==="hybrid"||s.config.useNativeSDKToSend===!0,Ul=s=>s.filter(e_),s_=(s,e)=>`${s.replaceAll(" ","-")}___${e}`,Lc=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],i_=["Bugsnag","ErrorReporting"],r_={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"}};n_=s=>$c({},(globalThis.__federation_shared__||{}).default||{});a_=s=>{switch(s){case"BeaconQueue":return()=>De("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>Ne(e,!0));case"CustomConsentManager":return()=>De("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>Ne(e,!0));case"DeviceModeDestinations":return()=>De("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>Ne(e,!0));case"DeviceModeTransformation":return()=>De("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>Ne(e,!0));case"ExternalAnonymousId":return()=>De("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>Ne(e,!0));case"GoogleLinker":return()=>De("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>Ne(e,!0));case"KetchConsentManager":return()=>De("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>Ne(e,!0));case"IubendaConsentManager":return()=>De("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>Ne(e,!0));case"NativeDestinationQueue":return()=>De("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>Ne(e,!0));case"OneTrustConsentManager":return()=>De("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>Ne(e,!0));case"StorageEncryption":return()=>De("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>Ne(e,!0));case"StorageEncryptionLegacy":return()=>De("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>Ne(e,!0));case"StorageMigrator":return()=>De("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>Ne(e,!0));case"XhrQueue":return()=>De("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>Ne(e,!0));default:return}},l_=s=>{let e={};return s.forEach(t=>{if(Lc.includes(t)){let i=a_(t);i&&(e[t]=i)}}),e},Fc=()=>({}),c_=()=>({}),u_=s=>l_?.(s)||{},bn={...Fc(),...c_()},d_=s=>({...u_(s)}),$n=class{constructor(e,t,i){this.engine=e,this.errorHandler=t,this.logger=i,this.onError=this.onError.bind(this)}init(){u.lifecycle.status.value="pluginsLoading",zs("pluginsCDNPath",u.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){it(()=>{(u.plugins.activePlugins.value.length===0||u.plugins.loadedPlugins.value.length+u.plugins.failedPlugins.value.length===u.plugins.totalPluginsToLoad.value)&&Ee(()=>{u.plugins.ready.value=!0,u.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=u.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>i_.includes(r)?(this.logger.warn(Fp(Fs,r)),!1):!0);let t=[{configurationStatus:()=>se(u.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:u.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(Wp),shouldAddMissingPlugins:!0},{configurationStatus:()=>Ul(u.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Ul(u.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>se(u.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:u.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Nn)},{configurationStatus:()=>se(u.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:u.storage.encryptionPluginName.value,supportedPlugins:Object.values(Ui)},{configurationStatus:()=>u.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],i=!1;return t.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>se(n)),this.addMissingPlugins(r,i,e)):e=e.filter(r.basePlugins!==void 0?n=>!(r.basePlugins.includes(n)||r.supportedPlugins.includes(n)):n=>!r.supportedPlugins.includes(n))}),[...Object.keys(Fc()),...e]}addMissingPlugins(e,t,i){let r=e.shouldAddMissingPlugins||t,n;e.activePluginName?n=[...e.basePlugins||[],e.activePluginName]:n=[...e.supportedPlugins];let o=n.filter(a=>!i.includes(a));o.length>0&&(r&&i.push(...o),this.logger.warn(Mp(Fs,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(bn),...Lc],i=[],r=[];e.forEach(n=>{t.includes(n)?i.push(n):r.push(n)}),r.length>0&&this.logger.warn(Vp(Fs,r)),Ee(()=>{u.plugins.totalPluginsToLoad.value=e.length,u.plugins.activePlugins.value=i,u.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(bn).forEach(([t,i])=>{u.plugins.activePlugins.value.includes(t)&&(x(i)?this.register([i()]):e.push(t))}),e.length>0&&(u.plugins.failedPlugins.value=[...u.plugins.failedPlugins.value,...e],this.logger.error(Gp(Fs,e)))}registerRemotePlugins(){let e=d_(u.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async t=>{await e[t]().then(i=>this.register([i.default()])).catch(i=>{u.plugins.failedPlugins.value=[...u.plugins.failedPlugins.value,t],this.onError(i,`Failed to load plugin "${t}"`,i)})})).catch(t=>{this.onError(t)})}invokeMultiple(e,...t){try{return this.engine.invokeMultiple(e,...t)}catch(i){return this.onError(i,e),[]}}invokeSingle(e,...t){try{return this.engine.invokeSingle(e,...t)}catch(i){return this.onError(i,e),null}}register(e){e.forEach(t=>{try{this.engine.register(t,u)}catch(i){u.plugins.failedPlugins.value=[...u.plugins.failedPlugins.value,t.name],this.onError(i,`Failed to register plugin "${t.name}"`)}})}unregisterLocalPlugins(){Object.keys(bn).forEach(e=>{try{this.engine.unregister(e)}catch(t){this.onError(t,`Failed to unregister plugin "${e}"`)}})}onError(e,t,i){this.errorHandler.onError({error:e,context:Fs,customMessage:t,groupingHash:i})}},xe="cookieStorage",Fe="localStorage",Ge="sessionStorage",st="memoryStorage",Ht="none",h_="test_rudder_cookie",g_="test_rudder_ls",f_="test_rudder_ss",p_="rl_user_id",v_="rl_trait",__="rl_anonymous_id",m_="rl_group_id",y_="rl_group_trait",b_="rl_page_init_referrer",E_="rl_page_init_referring_domain",S_="rl_session",k_="rl_auth_token",rs={userId:p_,userTraits:v_,anonymousId:__,groupId:m_,groupTraits:y_,initialReferrer:b_,initialReferringDomain:E_,sessionInfo:S_,authToken:k_},w_="__tld__",Mc="clientDataInCookie",Uc="clientDataInLocalStorage",A_="clientDataInMemory",Bc="clientDataInSessionStorage",Vc=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ns={[xe]:Mc,[Fe]:Uc,[st]:A_,[Ge]:Bc},Bl=(s,e)=>{try{return encodeURIComponent(s)}catch(t){e?.error(hf,t);return}},Vl=s=>{try{return decodeURIComponent(s)}catch{return}},T_=s=>{let e={},t=s.split(/\s*;\s*/),i;return t[0]&&t.forEach(r=>{i=r.split("=");let n=i[0]?Vl(i[0]):void 0;n&&(e[n]=i[1]?Vl(i[1]):void 0)}),e},I_=(s,e,t,i)=>{let r={...t||{}},n=`${Bl(s,i)}=${Bl(e,i)}`;Le(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},Fn=()=>{let s=globalThis.document.cookie;return T_(s)},R_=s=>Fn()[s],dt=function(s,e,t,i){switch(arguments.length){case 4:case 3:case 2:return I_(s,e,t,i);case 1:return s?R_(s):Fn();default:return Fn()}},O_=s=>{let e=document.createElement("a");return e.href=s,e.hostname},C_=s=>{let t=(typeof globalThis.URL!="function"?O_(s):new URL(s).hostname)?.split(".")??[],i=t[t.length-1],r=[];if(t.length===4&&i&&i===parseInt(i,10).toString())return r;if(t.length<=1)return t[0]&&t[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=t.length-2;n>=0;n-=1)r.push(t.slice(n).join("."));return r},P_=s=>{let e=C_(s);for(let t=0;t<e.length;t+=1){let i=e[t],r=w_,n={domain:`${i.indexOf("localhost")!==-1?"":"."}${i}`};try{if(dt(r,1,n),dt(r))return dt(r,null,n),i}catch{try{dt(r,null,n)}catch{}}}return""},N_=()=>{let s=`.${P_(globalThis.location.href)}`;return{maxage:If,path:"/",domain:!s||s==="."?void 0:s,samesite:"Lax",enabled:!0}},D_=()=>({enabled:!0}),x_=()=>({enabled:!0}),L_=()=>({enabled:!0}),Mn=class{constructor(e){le(this,"isEnabled",!0);le(this,"length",0);le(this,"data",{});this.options=L_(),this.logger=e}configure(e){return this.options=be(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,t){return this.data[e]=t,this.length=Object.keys(this.data).length,t}getItem(e){return e in this.data?this.data[e]:null}removeItem(e){return e in this.data&&delete this.data[e],this.length=Object.keys(this.data).length,null}clear(){this.data={},this.length=0}key(e){return this.keys()[e]??null}keys(){return Object.keys(this.data)}},Ji=new Mn(pt);Vi={exports:{}},F_=Vi.exports;U_=M_(),Mt=$_(U_),Gc=s=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],t=[22,1014];return s instanceof DOMException?e.includes(s.name)||t.includes(s.code):!1},os=(s=Fe,e,t)=>{let i,r,n=gf(Tn,s),o="unavailable",a=!0,l;try{switch(s){case st:return!0;case xe:i=e,r=h_;break;case Fe:i=e??globalThis.localStorage,r=g_;break;case Ge:i=e??globalThis.sessionStorage,r=f_;break;default:return!1}if(i&&(i.setItem(r,"true"),i.getItem(r)))return i.removeItem(r),!0;a=!1}catch(c){a=!1,l=c,Gc(c)&&(o="full")}return a||t?.warn(`${n}${o}.`,l),!1},Un=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.options=D_(),this.logger=e}configure(e){return this.options=be(this.options,e??{}),this.isSupportAvailable=os(Fe),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){Mt.set(e,t),this.length=Mt.len()}getItem(e){let t=Mt.get(e);return Se(t)?null:t}removeItem(e){Mt.remove(e),this.length=Mt.len()}clear(){Mt.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Mt.keys()}},lo=new Un(pt),Bn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.options=x_(),this.logger=e}configure(e){return this.options=be(this.options,e??{}),this.isSupportAvailable=os(Ge),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){this.store&&(this.store.setItem(e,t),this.length=this.store.length)}getItem(e){if(!this.store)return null;let t=this.store.getItem(e);return Se(t)?null:t}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){this.store?.clear(),this.length=0}key(e){return this.store?.key(e)??null}keys(){let e=[];if(!this.store)return e;for(let t=0;t<this.store.length;t+=1){let i=this.store.key(t);i!==null&&e.push(i)}return e}},co=new Bn(pt),Vn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=N_()),this.options=be(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=os(xe,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){return dt(e,t,this.options,this.logger),this.length=Object.keys(dt()).length,!0}getItem(e){let t=dt(e);return Se(t)?null:t}removeItem(e){let t=this.setItem(e,null);return this.length=Object.keys(dt()).length,t}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(dt())}},uo=new Vn(pt),Ye=s=>{switch(s){case Fe:return lo;case Ge:return co;case st:return Ji;case xe:return uo;default:return Ji}},B_=s=>{let e=uo.configure(s);u.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},V_=s=>{lo.configure(s)},G_=s=>{Ji.configure(s)},H_=s=>{co.configure(s)},j_=(s={},e={},t={},i={})=>{B_(s),V_(e),G_(t),H_(i)},Gn=class{constructor(e,t,i){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=t,this.noKeyValidation=Object.keys(this.validKeys).length===0,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=i}createValidKey(e){let{name:t,id:i,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[t,i,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[t,i,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:i,noCompoundKey:r}=this,n=Ye(st);Object.keys(i).forEach(o=>{let a=this.get(i[o]),l=r?o:[e,t,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,t){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(Je(t,!1,[],this.logger)))}catch(r){if(Gc(r))this.logger.warn(Cp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,t);else{let n=gp(e);this.onError(r,n,n)}}}get(e){let t=this.createValidKey(e),i;try{return!t||(i=this.decrypt(this.engine.getItem(t)),Qe(i)||i==="")?null:JSON.parse(i)}catch(r){let n=u.storage.encryptionPluginName.value;if(!n||!u.plugins.failedPlugins.value.includes(n)){let a=fp(e);this.onError(r,a,a)}return null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return Qe(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||typeof e!="string"||Wg(e)==="")return e;let r=`storage.${t}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,t,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:i})}},z_=(s,e)=>{let t;if(s.consents.preConsent.value.enabled)switch(s.consents.preConsent.value.storage?.strategy){case"none":t=Ht;break;case"session":e!=="sessionInfo"&&(t=Ht);break;case"anonymousId":e!=="anonymousId"&&(t=Ht);break}return t},Hn=class{constructor(e,t,i){le(this,"stores",{});le(this,"isInitialized",!1);this.errorHandler=t,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=u.loadOptions.value,t={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};j_(Us(be(t.cookieStorageOptions??{},u.storage.cookie?.value??{})),Us(t.localStorageOptions),Us(t.inMemoryStorageOptions),Us(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[st,Fe,xe,Ge].forEach(t=>{Ye(t)?.isEnabled&&this.setStore({id:ns[t],name:ns[t],isEncrypted:!0,noCompoundKey:!0,type:t,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=u.storage.type.value,t=u.loadOptions.value.storage?.entries,i=u.consents.postConsent.value.storage;(se(i?.type)||se(i?.entries))&&(e=i?.type,t=i?.entries);let r=!0,n={};Vc.forEach(o=>{let a=o,l=o,c=t?.[a]?.type,h=z_(u,o)??c??e??Pn,f=this.getResolvedStorageTypeForEntry(h,o);f!==Ht&&(r=!1),n={...n,[o]:{type:f,key:rs[l]}}}),Ee(()=>{u.storage.type.value=e,u.storage.entries.value=n,u.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,t){let i=e;switch(e){case Fe:Ye(Fe)?.isEnabled||(i=st);break;case Ge:Ye(Ge)?.isEnabled||(i=st);break;case st:case Ht:break;case xe:default:Ye(xe)?.isEnabled?i=xe:Ye(Fe)?.isEnabled?i=Fe:Ye(Ge)?.isEnabled?i=Ge:i=st;break}return i!==e&&this.logger.warn(Pp(Yg,t,e,i)),i}setStore(e){let t=Ye(e.type);return this.stores[e.id]=new Gn(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},W_=s=>oe(s)&&oe(s.source)&&!Qe(s.source.id)&&oe(s.source.config)&&Array.isArray(s.source.destinations),q_=s=>typeof s=="string"&&yc.includes(s),Hc=s=>{let e=new URL(s),{host:t,protocol:i}=e,r=t.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=t,{topDomain:n,protocol:i}},K_=s=>{let{topDomain:e,protocol:t}=Hc(s);return`${t}//${e}`},Y_=(s,e)=>{let t=e?window.location.origin:K_(window.location.href),i=s.startsWith("/")?s.substring(1):s;return`${t}/${i}`},J_=s=>{let{topDomain:e}=Hc(window.location.href);return e===s},ls=s=>s?.endsWith("/")?ls(s.substring(0,s.length-1)):s,jn=s=>{try{return new URL(s).host}catch{return null}},jc=s=>jn(s)??"",Q_=s=>{let e={};try{let t=new URL(s),i="utm_";t.searchParams.forEach((r,n)=>{if(n.startsWith(i)){let o=n.substring(i.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},X_=s=>{let e=s;try{let t=new URL(s);e=t.origin+t.pathname+t.search}catch{}return e},Z_=s=>s.replace(/\/{2,}/g,"/"),cs=s=>{if(!ne(s))return!1;try{return x(globalThis.URL)&&new URL(s),jp.test(s)}catch{return!1}},En="none",Sn="immediate",em=s=>s?.statsCollection?.errors?.enabled===!0,tm=s=>s?.statsCollection?.metrics?.enabled===!0,sm=s=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(oe(s)){let t=q(s);e.storage=t.storage,ft(t.integrations)&&(e.integrations=t.integrations),e.discardPreConsentEvents=t.discardPreConsentEvents===!0,e.sendPageEvent=t.sendPageEvent===!0,e.trackConsent=t.trackConsent===!0,ft(t.consentManagement)&&(e.consentManagement=be(t.consentManagement,{enabled:u.consents.enabled.value}))}return e},Hl=s=>ft(s)||Array.isArray(s),im=(s,e)=>{let{provider:t}=s,i=t?Nn[t]:void 0;return t&&!i&&(e.error(Zf(He,t,Nn)),t=void 0),{provider:t,consentManagerPluginName:i}},zc=(s,e)=>{let t,i=[],r=[],n=!1,o,a=s?.enabled===!0;ft(s)&&a&&({provider:o,consentManagerPluginName:t}=im(s,e),Hl(s.allowedConsentIds)&&(i=s.allowedConsentIds,n=!0),Hl(s.deniedConsentIds)&&(r=s.deniedConsentIds,n=!0));let l={allowedConsentIds:i,deniedConsentIds:r};return a=a&&!!t,{provider:o,consentManagerPluginName:t,initialized:n,enabled:a,consentsData:l}},rm=()=>{let s=document.querySelector("script[data-rsa-write-key]");if(s&&s.dataset.rsaWriteKey===u.lifecycle.writeKey.value)return s.src;let e=document.getElementsByTagName("script"),t=/(?:^|\/)rsa(\.min)?\.js$/;for(let i of e){let r=i.getAttribute("src");if(r&&t.test(r))return r}},nm=s=>{u.reporting.isErrorReportingEnabled.value=em(s.source.config)&&!rf(),u.reporting.isMetricsReportingEnabled.value=tm(s.source.config)},om=s=>{let{useServerSideCookies:e,dataServiceEndpoint:t,storage:i,setCookieDomain:r,sameDomainCookiesOnly:n}=u.loadOptions.value,o=i?.cookie,a=!1,l;if(e){a=e;let c=o.domain??r,d=se(c)&&!J_(yl(c))||n,h=Y_(t??qp,d);if(cs(h)){l=ls(h);let f=jn(window.location.href),g=jn(h);f!==g&&(o={...o,samesite:"None",secure:!0}),!n&&d&&g!==yl(c)&&(a=!1,s.warn(bp(He,c,g)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},am=s=>{let{storage:e}=u.loadOptions.value,t=e?.type;se(t)&&!q_(t)&&(s.warn(_p(He,t,Pn)),t=Pn);let i=e?.encryption?.version,r=i&&Ui[i];!Se(i)&&Se(r)?(s.warn(mp(He,i,Ui,Bt)),i=Bt):Se(i)&&(i=Bt);let n=e?.migrate,o=n&&i===Bt;n===!0&&o!==n&&s.warn(yp(He,i,Bt));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:c}=om(s);Ee(()=>{u.storage.type.value=t,u.storage.cookie.value=c,u.serverCookies.isEnabledServerSideCookies.value=a,u.serverCookies.dataServiceUrl.value=l,u.storage.encryptionPluginName.value=Ui[i],u.storage.migrate.value=o})},lm=s=>{let{provider:e,consentManagerPluginName:t,initialized:i,enabled:r,consentsData:n}=zc(u.loadOptions.value.consentManagement,s),o=u.loadOptions.value.preConsent,a=o?.storage?.strategy??En,l=["none","session","anonymousId"];se(a)&&!l.includes(a)&&(a=En,s.warn(Lp(He,o?.storage?.strategy,En)));let c=o?.events?.delivery??Sn,d=["immediate","buffer"];se(c)&&!d.includes(c)&&(c=Sn,s.warn($p(He,o?.events?.delivery,Sn))),Ee(()=>{u.consents.activeConsentManagerPluginName.value=t,u.consents.initialized.value=i,u.consents.enabled.value=r,u.consents.data.value=n,u.consents.provider.value=e,u.consents.preConsent.value={enabled:u.loadOptions.value.preConsent?.enabled===!0&&i===!1&&r===!0,storage:{strategy:a},events:{delivery:c}}})},cm=s=>{let e=u.consents.resolutionStrategy.value,t;oe(s.consentManagementMetadata)&&(u.consents.provider.value&&(e=s.consentManagementMetadata.providers.find(i=>i.provider===u.consents.provider.value)?.resolutionStrategy??u.consents.resolutionStrategy.value),t=s.consentManagementMetadata),u.consents.provider.value==="custom"&&(e=void 0),Ee(()=>{u.consents.metadata.value=q(t),u.consents.resolutionStrategy.value=e})},um=s=>{if(u.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",t=e;u.loadOptions.value.useBeacon&&(u.capabilities.isBeaconAvailable.value?t="BeaconQueue":(t=e,s.warn(kp(He)))),Ee(()=>{u.dataPlaneEvents.eventsQueuePluginName.value=t})}},dm=(s,e,t,i,r)=>{let n=new URLSearchParams({p:cc,v:js,build:Ws,writeKey:e,lockIntegrationsVersion:t.toString(),lockPluginsVersion:i.toString()}),o=Ac,a=n,l="/sourceConfig/",c="";if(cs(s)){let d=new URL(s);ls(d.pathname).endsWith("/sourceConfig")||(d.pathname=`${ls(d.pathname)}/sourceConfig/`),d.pathname=Z_(d.pathname),n.forEach((h,f)=>{d.searchParams.get(f)===null&&d.searchParams.set(f,h)}),o=d.origin,l=d.pathname,a=d.searchParams,c=d.hash}else r.warn(Dp(He,s));return`${o}${l}?${a}${c}`},hm=s=>s.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:s_(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===Yp})),Wc=(s,e,t,i,r,n,o)=>{let a;if(n){if(!cs(n))return o.error(Xf(He,s,n)),null;a=ls(n)}else if(a=t,u.context.app.value.installType==="cdn"){let l=rm();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${ao}/${Ws}/${e}$`),`/${i}/${Ws}/${e}`)),a},gm=(s,e,t,i)=>Wc("integrations",tr,kc,s,e,t,i),fm=(s,e,t,i)=>Wc("plugins",Sc,wc,s,e,t,i),zn=class{constructor(e,t,i){this.errorHandler=t,this.logger=i,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){it(()=>{this.logger.setMinLogLevel(u.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:t,lockIntegrationsVersion:i,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=u.loadOptions.value,l=gm(js,i,n,this.logger);if(Le(l))return;let c;c=fm(js,r,o,this.logger),c!==null&&(this.attachEffects(),u.lifecycle.activeDataplaneUrl.value=ls(u.lifecycle.dataPlaneUrl.value),am(this.logger),lm(this.logger),um(this.logger),Ee(()=>{u.lifecycle.integrationsCDNPath.value=l,u.lifecycle.pluginsCDNPath.value=c,e&&(u.lifecycle.logLevel.value=e),u.lifecycle.sourceConfigUrl.value=dm(t,u.lifecycle.writeKey.value,i,r,this.logger),u.metrics.metricsServiceUrl.value=`${u.lifecycle.activeDataplaneUrl.value}/${Kp}`,u.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,t,i){this.errorHandler.onError({error:e,context:He,customMessage:t,groupingHash:i})}processConfig(e,t){if(!se(e)){se(t)?this.onError(t.error,Nl):this.onError(new Error(Nl));return}let i;try{ne(e)?i=JSON.parse(e):i=e}catch(n){this.onError(n,Cl);return}if(!W_(i)){this.onError(new Error(Cl));return}if(i.source.enabled===!1){this.logger.error(qf);return}nm(i);let r=i.source.destinations.length>0?hm(i.source.destinations):[];Ee(()=>{u.source.value={config:i.source.config,name:i.source.name,id:i.source.id,workspaceId:i.source.workspaceId},u.nativeDestinations.configuredDestinations.value=r,u.plugins.pluginsToLoadFromConfig.value=u.loadOptions.value.plugins??[],cm(i),u.lifecycle.status.value="configured"})}getConfig(){let e=u.loadOptions.value.getSourceConfig;if(e){if(!x(e)){this.logger.error(Qf(He));return}let t=e();t instanceof Promise?t.then(i=>this.processConfig(i)).catch(i=>{this.onError(i,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:u.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},pm=()=>{let s=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return s?.[1]?s[1]:"NA"},qc=(s=()=>document)=>s()?.referrer||"$direct",vm=(s=()=>document)=>{let t=s().getElementsByTagName("link"),i="";for(let r=0;t[r];r+=1){let n=t[r];if(n.getAttribute("rel")==="canonical"&&!i){i=n.getAttribute("href")??"";break}}return i},_m=(s=()=>globalThis.navigator)=>{let e=s();if(Se(e))return null;let{userAgent:t}=e,{brave:i}=e;if(i&&Object.getPrototypeOf(i).isBrave){let r=t.match(/(chrome)\/([\w.]+)/i);r&&(t=`${t} Brave/${r[2]}`)}return t},mm=(s=()=>globalThis.navigator)=>{let e=s();return Se(e)?null:e.language??e.browserLanguage},Kc=(s=()=>globalThis.location,e=()=>document)=>{let t=s(),i=vm(e),r=t.pathname,{href:n}=t,o=n,{search:a}=t;if(i)try{let h=new URL(i);h.search===""?o=i+a:o=i,r=h.pathname}catch{}let l=X_(o),{title:c}=e(),d=qc(e);return{path:r,referrer:d,referring_domain:jc(d),search:a,title:c,url:l,tab_url:n}},ym=(s,e="none")=>{e==="none"&&s(void 0),e==="default"&&s(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(t=>{s(t)}).catch(()=>{s()})},bm=()=>{let s=globalThis.document.createElement("div");return s.setAttribute("data-a-b","c"),s.dataset?s.dataset.aB==="c":!1},Wn={URL:()=>!x(globalThis.URL)||!x(globalThis.URLSearchParams),Promise:()=>!x(globalThis.Promise),"Number.isNaN":()=>!x(globalThis.Number.isNaN),"Number.isInteger":()=>!x(globalThis.Number.isInteger),"Array.from":()=>!x(globalThis.Array.from),"Array.prototype.find":()=>!x(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!x(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!x(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!x(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!x(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!x(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!x(globalThis.String.fromCodePoint),"Object.entries":()=>!x(globalThis.Object.entries),"Object.values":()=>!x(globalThis.Object.values),"Object.assign":()=>!x(globalThis.Object.assign),"Object.fromEntries":()=>!x(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!bm(),TextEncoder:()=>!x(globalThis.TextEncoder)||!x(globalThis.TextDecoder),requestAnimationFrame:()=>!x(globalThis.requestAnimationFrame)||!x(globalThis.cancelAnimationFrame),CustomEvent:()=>!x(globalThis.CustomEvent),"navigator.sendBeacon":()=>!x(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!x(globalThis.Uint8Array),Set:()=>!x(globalThis.Set),atob:()=>!x(globalThis.atob)},Em=()=>{let s=Object.keys(Wn),e=!1;for(let t=0;t<s.length;t++){let i=Wn[s[t]];if(x(i)&&i()){e=!0;break}}return e},Sm="https://polyfill-fastly.io/v3/polyfill.min.js",km=`${Sm}?version=3.111.0&features=${Object.keys(Wn).join("%2C")}`,wm=10*1e3,jl="rudderstackPolyfill",Am=()=>!Qe(globalThis.crypto)&&x(globalThis.crypto.getRandomValues),zl=()=>!Qe(globalThis.navigator.userAgentData),Tm=()=>!Qe(globalThis.navigator.sendBeacon)&&x(globalThis.navigator.sendBeacon),Wl=()=>{let s={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return s={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},s},qn=class{constructor(e,t,i){this.httpClient=e,this.errorHandler=t,this.logger=i,this.externalSrcLoader=new Wi(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Ee(()=>{u.capabilities.storage.isCookieStorageAvailable.value=os(xe,Ye(xe),this.logger),u.capabilities.storage.isLocalStorageAvailable.value=os(Fe,void 0,this.logger),u.capabilities.storage.isSessionStorageAvailable.value=os(Ge,void 0,this.logger),u.capabilities.isBeaconAvailable.value=Tm(),u.capabilities.isUaCHAvailable.value=zl(),u.capabilities.isCryptoAvailable.value=Am(),u.capabilities.isOnline.value=globalThis.navigator.onLine,u.context.userAgent.value=_m(),u.context.locale.value=mm(),u.context.screen.value=Wl(),u.context.timezone.value=pm(),zl()&&ym(e=>{u.context["ua-ch"].value=e},u.loadOptions.value.uaChTrackLevel)}),it(()=>{u.loadOptions.value.sendAdblockPage===!0&&u.lifecycle.sourceConfigUrl.value!==void 0&&Pc(this.httpClient)})}prepareBrowserCapabilities(){u.capabilities.isLegacyDOM.value=Em();let e=u.loadOptions.value.polyfillURL,t=km;if(as(e)&&(cs(e)?t=e:this.logger.warn(Up(Tn,e))),u.loadOptions.value.polyfillIfRequired&&u.capabilities.isLegacyDOM.value&&cs(t)){let r=t!==u.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${u.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,t=`${t}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:t,id:jl,async:!0,timeout:wm,callback:n=>{n?r||this.onReady():this.onError(new Error(xp(jl,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{u.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{u.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Cf(()=>{u.context.screen.value=Wl()},this))}onReady(){this.detectBrowserCapabilities(),u.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:Tn,groupingHash:t})}},Im="web",Rm=["integrations","anonymousId","originalTimestamp"],ql=["library","consentManagement","userAgent","ua-ch","screen"],kn=["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"],Yc=s=>typeof s=="number"&&!Number.isNaN(s),Om=(s,e)=>e.toString().length>=s,Qi=s=>Yc(s)&&s>=0&&Number.isInteger(s),Kl=10,Jc=s=>{let{cutOff:e}=s,t=Date.now();return!!(e?.enabled&&e.expiresAt&&t>e.expiresAt)},Yl=s=>!s.expiresAt||Date.now()>s.expiresAt||Jc(s),Cm=()=>Date.now(),Pm=(s,e)=>!s||!Qi(s)||!Om(Kl,s)?(e.warn(Op(Ut,s,Kl)),!1):!0,Nm=s=>{if(s?.enabled)return s.expiresAt??(Qi(s.duration)?Date.now()+s.duration:void 0)},Dm=s=>{let{timeout:e,cutOff:t}=s,i=Date.now();return{id:i,expiresAt:i+e,timeout:e,autoTrack:!0,...t&&{cutOff:t}}},xm=(s,e)=>({id:Pm(s,e)?s:Cm(),sessionStart:void 0,manualTrack:!0}),Vs=s=>s===xe||s===Fe||s===Ge||s===st,Kn=()=>Xi(),Lm=s=>{if(Vg(s)){let{entries:e,...t}=yn;return{...t,entries:{...e,anonymousId:s}}}return oe(s)&&oe(s.entries)?be(yn,s):{...yn}},$m=s=>{let e=Kc(),t={};return Object.keys(e).forEach(i=>{t[i]=s?.[i]||e[i]}),t.initial_referrer=s?.initial_referrer||u.session.initialReferrer.value,t.initial_referring_domain=s?.initial_referring_domain||u.session.initialReferringDomain.value,t},Fm=(s,e)=>{let t=e?.page||{},i=s,r=Kc();return Object.keys(r).forEach(n=>{Se(i[n])&&(i[n]=t[n]||r[n])}),Se(i.initial_referrer)&&(i.initial_referrer=t.initial_referrer||u.session.initialReferrer.value),Se(i.initial_referring_domain)&&(i.initial_referring_domain=t.initial_referring_domain||u.session.initialReferringDomain.value),i},wn=(s,e,t)=>{oe(s)&&Object.keys(s).forEach(i=>{(kn.includes(i)||kn.includes(i.toLowerCase()))&&t.warn(Ep(rc,i,e,kn))})},Mm=(s,e)=>{let{properties:t,traits:i,context:r}=s,{traits:n}=r;wn(t,"properties",e),wn(i,"traits",e),wn(n,"context.traits",e)},Um=(s,e)=>{e.anonymousId&&ne(e.anonymousId)&&(s.anonymousId=e.anonymousId),ft(e.integrations)&&(s.integrations=e.integrations),e.originalTimestamp&&ne(e.originalTimestamp)&&(s.originalTimestamp=e.originalTimestamp)},Bm=(s,e,t)=>{let i=s;return Object.keys(e).forEach(r=>{if(!Rm.includes(r)&&!ql.includes(r))if(r!=="context")i=be(i,{[r]:e[r]});else if(!Se(e[r])&&oe(e[r])){let n={};Object.keys(e[r]).forEach(o=>{ql.includes(o)||(n[o]=e[r][o])}),i=be(i,{...n})}else t.warn(Sp(rc))}),i},Vm=(s,e,t)=>{oe(e)&&(Um(s,e),s.context=Bm(s.context,e,t))},Gm=s=>{let e;return u.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=u.consents.postConsent.value.integrations??u.nativeDestinations.loadOnlyIntegrations.value:s?e=s:e=Ec,q(e)},Ms=(s,e,t,i)=>{let r={channel:Im,context:{traits:q(u.session.userTraits.value),sessionId:u.session.sessionInfo.value.id||void 0,sessionStart:u.session.sessionInfo.value.sessionStart||void 0,...u.consents.enabled.value&&{consentManagement:{deniedConsentIds:q(u.consents.data.value.deniedConsentIds),allowedConsentIds:q(u.consents.data.value.allowedConsentIds),provider:u.consents.provider.value,resolutionStrategy:u.consents.resolutionStrategy.value}},"ua-ch":u.context["ua-ch"].value,app:u.context.app.value,library:u.context.library.value,userAgent:u.context.userAgent.value,os:u.context.os.value,locale:u.context.locale.value,screen:u.context.screen.value,campaign:Q_(globalThis.location.href),page:$m(t),timezone:u.context.timezone.value,...u.autoTrack.enabled.value&&{autoTrack:{...u.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:u.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:af(),messageId:Xi(),userId:s.userId||u.session.userId.value};Vs(u.storage.entries.value.anonymousId?.type)?r.anonymousId=u.session.anonymousId.value:r.anonymousId=Kn(),u.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),s.type==="identify"&&(r.context.traits=u.storage.entries.value.userTraits?.type!==Ht?q(u.session.userTraits.value):s.context.traits),s.type==="group"&&((s.groupId||u.session.groupId.value)&&(r.groupId=s.groupId||u.session.groupId.value),(s.traits||u.session.groupTraits.value)&&(r.traits=u.storage.entries.value.groupTraits?.type!==Ht?q(u.session.groupTraits.value):s.traits));let n=be(s,r);return n.event===void 0&&(n.event=null),n.properties===void 0&&(n.properties=null),Vm(n,e,i),Mm(n,i),n.integrations=Gm(n.integrations),n},Yn=class{constructor(e){this.logger=e}generatePageEvent(e,t,i,r){let n=i??{};return n=Fm(n,r),Ms({properties:n,name:t,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,t,i){return Ms({properties:t,event:e,type:"track"},i,void 0,this.logger)}generateIdentifyEvent(e,t,i){return Ms({userId:e,type:"identify",context:{traits:t}},i,void 0,this.logger)}generateAliasEvent(e,t,i){let n=Ms({previousId:t,type:"alias"},i,void 0,this.logger);return n.userId=e??n.userId,n}generateGroupEvent(e,t,i){let r={type:"group"};return e&&(r.groupId=e),t&&(r.traits=t),Ms(r,i,void 0,this.logger)}create(e){let t;switch(e.type){case"page":t=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":t=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":t=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":t=this.generateAliasEvent(e.to,e.from,e.options);break;default:t=this.generateGroupEvent(e.groupId,e.traits,e.options);break}return t}},Jn=class{constructor(e,t,i,r){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=i,this.logger=r,this.eventFactory=new Yn(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let t=this.eventFactory.create(e);this.eventRepository.enqueue(t,e.callback)}},Qn=class{constructor(e,t,i,r,n){this.storeManager=t,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=i,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:e,anonymousIdOptions:t}=u.loadOptions.value,i;as(e)&&typeof e=="string"&&(i=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(i??this.getAnonymousId(t)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),i=this.getSessionInfo()??Z.sessionInfo;e={autoTrack:t.autoTrack&&i.manualTrack!==!0,timeout:t.timeout,manualTrack:i.manualTrack,expiresAt:i.expiresAt,id:i.id,sessionStart:i.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=Z.sessionInfo:t.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:i.cutOff?.expiresAt})}else e=Z.sessionInfo;u.session.sessionInfo.value=e,u.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(u.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),t=this.getInitialReferringDomain();if(e&&t)this.setInitialReferrer(e),this.setInitialReferringDomain(t);else{let i=e||qc();this.setInitialReferrer(i),this.setInitialReferringDomain(jc(i))}}isPersistenceEnabledForStorageEntry(e){return Vs(u.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=u.storage.entries.value,t=[xe,Fe,Ge];Object.keys(e).forEach(i=>{let r=i,n=e[r]?.type,o=this.storeManager?.getStore(ns[n]);o&&t.forEach(a=>{let l=this.storeManager?.getStore(ns[a]);if(l&&a!==n){let c=l.get(rs[r]);Bg(c)&&o.set(rs[r],c),l.remove(rs[r])}})})}migrateStorageIfNeeded(e,t){if(!u.storage.migrate.value)return;let i=e??[];i.length===0&&[Mc,Uc,Bc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&i.push(a)}),(t??Object.keys(rs)).forEach(n=>{let o=rs[n];i.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);Qe(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=u.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let t,i=u.loadOptions.value.sessions?.timeout;Qi(i)?t=i:(this.logger.warn(wp(Ut,i,In)),t=In),t===0&&(this.logger.warn(Ip(Ut)),e=!1),t>0&&t<Il&&this.logger.warn(Rp(Ut,t,Il));let r=this.getCutOffInfo(t);return{timeout:t,autoTrack:e,cutOff:r}}getCutOffInfo(e){let t=u.loadOptions.value.sessions.cutOff,i,r=!1;return t.enabled===!0&&(i=t.duration,r=!0,Qi(i)?i<e&&(this.logger.warn(Tp(Ut,i,e)),r=!1):(this.logger.warn(Ap(Ut,i,Tl)),i=Tl)),{enabled:r,duration:i}}onError(e,t,i){this.errorHandler.onError({error:e,context:Ut,customMessage:t,groupingHash:i})}getEncryptedCookieData(e,t){let i=[];return e.forEach(r=>{let n=t?.encrypt(Je(r.value,!1,[],this.logger));as(n)&&i.push({name:r.name,value:n})}),i}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:u.serverCookies.dataServiceUrl.value,options:{method:"POST",data:Je({reqType:"setCookies",workspaceId:u.source.value?.workspaceId,data:{options:{maxAge:u.storage.cookie.value?.maxage,path:u.storage.cookie.value?.path,domain:u.storage.cookie.value?.domain,sameSite:u.storage.cookie.value?.samesite,secure:u.storage.cookie.value?.secure,expires:u.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:t})}setServerSideCookies(e,t,i){let r=Object.keys(e),n=()=>r.map(c=>({name:e[c].name,value:u.session[c].value})),o={};r.forEach(c=>{o[e[c].name]=i?.get(e[c].name)});let a=()=>{r.forEach(c=>{this.serverSideCookiesRequestInProgress[c]=!1})},l=()=>{n().forEach(c=>{t&&t(c.name,c.value)})};try{let c={};r.forEach(h=>{c[e[h].name]=u.session[h].value});let d=this.getEncryptedCookieData(n(),i);d.length>0?this.makeRequestToSetCookie(d,(h,f)=>{a(),f?.xhr?.status===200?n().forEach(g=>{let v=o[g.name],p=i?.get(g.name);Je(c[g.name],!1,[])!==Je(p,!1,[])&&(Le(v)&&Le(p)&&this.logger.error(vp(g.name)),t&&t(g.name,g.value))}):(this.logger.error(pp(f?.xhr?.status)),l())}):(l(),a())}catch(c){this.onError(c,Dl,Dl),l(),a()}}syncValueToStorage(e){let t=u.storage.entries.value,i=t[e]?.type;if(Vs(i)){let r=this.storeManager.getStore(ns[i]),n=t[e]?.key,o=u.session[e].value;o&&(ne(o)||ft(o))?u.serverCookies.isEnabledServerSideCookies.value&&i===xe?(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,c)=>{r?.set(l,c)},r)},Xp)):r?.set(n,o):r?.remove(n)}}registerEffects(){Vc.forEach(e=>{it(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let i=e;(!ne(e)||!i)&&(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&t&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t)),i=i||Kn()):i=Z.anonymousId,u.session.anonymousId.value=i}getAnonymousId(e){let t=u.storage.entries.value.anonymousId?.type;if(Vs(t)){let i=u.session.anonymousId.value;(!i||i===Z.anonymousId)&&(i=this.getEntryValue("anonymousId")),!i&&e&&(i=this.pluginsManager?.invokeSingle("storage.getAnonymousId",Ye,e)),u.session.anonymousId.value=i||Kn()}return u.session.anonymousId.value}getEntryValue(e){let t=u.storage.entries.value,i=t[e]?.type;if(Vs(i)){let r=this.storeManager?.getStore(ns[i]);this.migrateStorageIfNeeded([r],[e]);let n=t[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let t=Ye(xe);return t?.isEnabled?t.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?u.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()??Z.sessionInfo;return e.autoTrack&&!Yl(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??Z.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=u.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),u.session.sessionInfo.value=e,u.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=u.session,{manualTrack:t,autoTrack:i,timeout:r,cutOff:n}=e.sessionInfo.value;if(i){let o={...Z.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){let{session:t}=u,i=Lm(e);Ee(()=>{Object.keys(Z).forEach(r=>{let n=r;if(i.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[n].value=Z[n];break}})})}setUserId(e){u.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:Z.userId}setUserTraits(e){u.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&oe(e)?be(u.session.userTraits.value??Z.userTraits,e):Z.userTraits}setGroupId(e){u.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:Z.groupId}setGroupTraits(e){u.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&oe(e)?be(u.session.groupTraits.value??Z.groupTraits,e):Z.groupTraits}setInitialReferrer(e){u.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:Z.initialReferrer}setInitialReferringDomain(e){u.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:Z.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if(Yl(e))t=Dm(e);else{let i=Date.now(),r=e.timeout;t.expiresAt=i+r}if(Jc(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){let i=Nm(t.cutOff);t.cutOff.expiresAt=i}u.session.sessionInfo.value=t}start(e){u.session.sessionInfo.value=xm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){u.session.sessionInfo.value=Z.sessionInfo}setAuthToken(e){u.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:Z.authToken}},Hm=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],jm=Hm,zm=(s,e)=>{let t=q(e);return ne(t.setCookieDomain)||(t.setCookieDomain=void 0),["Strict","Lax","None"].includes(t.sameSiteCookie)||(t.sameSiteCookie=void 0),t.secureCookie=tt(t.secureCookie,s.secureCookie),t.sameDomainCookiesOnly=tt(t.sameDomainCookiesOnly,s.sameDomainCookiesOnly),["none","default","full"].includes(t.uaChTrackLevel)||(t.uaChTrackLevel=void 0),t.integrations=ct(t.integrations),Array.isArray(t.plugins)||(t.plugins=jm),t.useGlobalIntegrationsConfigInEvents=tt(t.useGlobalIntegrationsConfigInEvents,s.useGlobalIntegrationsConfigInEvents),t.bufferDataPlaneEventsUntilReady=tt(t.bufferDataPlaneEventsUntilReady,s.bufferDataPlaneEventsUntilReady),t.sendAdblockPage=tt(t.sendAdblockPage,s.sendAdblockPage),t.useServerSideCookies=tt(t.useServerSideCookies,s.useServerSideCookies),ne(t.dataServiceEndpoint)||(t.dataServiceEndpoint=void 0),t.sendAdblockPageOptions=ct(t.sendAdblockPageOptions),t.loadIntegration=tt(t.loadIntegration,s.loadIntegration),ft(t.storage)?(t.storage.migrate=tt(t.storage.migrate,s.storage?.migrate),t.storage.cookie=ct(t.storage.cookie),t.storage.encryption=ct(t.storage.encryption),t.storage=Hi(t.storage)):t.storage=void 0,t.destinationsQueueOptions=ct(t.destinationsQueueOptions),t.queueOptions=ct(t.queueOptions),t.lockIntegrationsVersion=tt(t.lockIntegrationsVersion,s.lockIntegrationsVersion),t.lockPluginsVersion=tt(t.lockPluginsVersion,s.lockPluginsVersion),Yc(t.dataPlaneEventsBufferTimeout)||(t.dataPlaneEventsBufferTimeout=void 0),t.beaconQueueOptions=ct(t.beaconQueueOptions),t.preConsent=ct(t.preConsent),t.sourceConfigurationOverride=ct(t.sourceConfigurationOverride),be(s,Hi(t))},Jl="dataplaneEventsQueue",Ql="destinationsEventsQueue",Wm="transformEvent",qm=(s,e)=>Object.keys(s).filter(t=>s[t]!==!0||!e[t]).reduce((t,i)=>{let r=q(t);return r[i]=s[i],r},{}),Km=(s,e)=>{let t=q(s),i=e.nativeDestinations.integrationsConfig.value,r=qm(s.integrations,i);return t.integrations=be(i,r),t},Ym=s=>s.consents.preConsent.value.enabled&&s.consents.preConsent.value.events?.delivery==="buffer",Gi=(s,e,t,i)=>{if(se(s))if(x(s))try{s(...e)}catch(r){i.error(Np(t),r)}else i.error(bc(t))},Xn=class{constructor(e,t,i,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=i,this.logger=n,this.storeManager=t}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${Jl}.init`,u,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${Wm}.init`,u,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${Ql}.init`,u,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),it(()=>{u.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=Ym(u),t;it(()=>{let i=u.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&u.nativeDestinations.clientDestinationsReady.value===!1;(u.nativeDestinations.activeDestinations.value.some(n=>t_(n))===!1||i===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(t),this.dataplaneEventsQueue?.start())}),u.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(t=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},u.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(u.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,t){let i=Km(e,u);this.pluginsManager.invokeSingle(`${Jl}.enqueue`,u,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let r=q(e);this.pluginsManager.invokeSingle(`${Ql}.enqueue`,u,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${ro}`;Gi(t,[i],n,this.logger)}},Xl=s=>{let e=new CustomEvent(s,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},Jm=s=>ne(s)&&s.trim().length>0,Qm=s=>cs(s),Zn=class{constructor(){this.preloadBuffer=new On,this.initialized=!1,this.errorHandler=xc,this.logger=pt,this.externalSrcLoader=new Wi(this.logger),this.httpClient=Cc,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new qn(this.httpClient,this.errorHandler,this.logger)}load(e,t,i={}){if(!u.lifecycle.status.value){if(!Jm(e)){this.logger.error(lp(xi,e));return}if(!Qm(t)){this.logger.error(cp(xi,t));return}Ee(()=>{u.lifecycle.writeKey.value=q(e),u.lifecycle.dataPlaneUrl.value=q(t),u.loadOptions.value=zm(u.loadOptions.value,i),u.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(u.loadOptions.value.logLevel??mc),zs("state",u,e),this.startLifecycle()}}startLifecycle(){it(()=>{try{switch(u.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 t="Failed to load the SDK";this.errorHandler.onError({error:e,context:xi,customMessage:t,groupingHash:t})}})}onBrowserCapabilitiesReady(){xf(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),u.consents.preConsent.value.enabled===!0?u.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(t=>this.preloadBuffer.enqueue(q(t)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&Lf([...e],this)}}prepareInternalServices(){this.pluginsManager=new $n(Zv,this.errorHandler,this.logger),this.storeManager=new Hn(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new zn(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Qn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Xn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Jn(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){u.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(u.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),u.consents.enabled.value&&!u.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",u,this.logger),u.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",u,this.storeManager,this.logger)),this.eventManager?.init(),u.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Ee(()=>{u.lifecycle.loaded.value=!0,u.lifecycle.status.value="loaded"}),this.initialized=!0;let e=u.loadOptions.value.onLoaded;Gi(e,[globalThis.rudderanalytics],Jg,this.logger),Xl("RSA_Initialised")}onReady(){u.lifecycle.status.value="readyExecuted",u.eventBuffer.readyCallbacksArray.value.forEach(e=>{Gi(e,[],_n,this.logger)}),Xl("RSA_Ready")}processBufferedEvents(){let e=u.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let t=e.shift();if(u.eventBuffer.toBeProcessedArray.value=e,t){let i=t[0];x(this[i])&&this[i](...t.slice(1),!0)}e=u.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if(u.lifecycle.status.value==="destinationsLoading"||u.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",u,this.pluginsManager,this.errorHandler,this.logger);let e=u.nativeDestinations.activeDestinations.value.length;if(e===0){Ee(()=>{u.nativeDestinations.clientDestinationsReady.value=!0,u.lifecycle.status.value="destinationsReady"});return}u.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",u,this.externalSrcLoader,this.errorHandler,this.logger),it(()=>{u.nativeDestinations.initializedDestinations.value.length+u.nativeDestinations.failedDestinations.value.length===e&&Ee(()=>{u.lifecycle.status.value="destinationsReady",u.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){u.lifecycle.status.value!=="ready"&&Ee(()=>{u.lifecycle.status.value="ready"})}ready(e,t=!1){let i="ready";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),!x(e)){this.logger.error(bc(_n));return}u.lifecycle.status.value==="readyExecuted"?Gi(e,[],_n,this.logger):u.eventBuffer.readyCallbacksArray.value=[...u.eventBuffer.readyCallbacksArray.value,e]}page(e,t=!1){let i="page";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),u.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),u.capabilities.isAdBlocked.value===!0&&e.category!==kl&&this.page(zi(kl,bf,{path:Ef},u.loadOptions.value.sendAdblockPageOptions))}track(e,t=!1){let i="track";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event - ${e.name}`),u.metrics.triggered.value+=1,this.eventManager?.addEvent({type:i,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,t=!1){let i="identify";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),u.metrics.triggered.value+=1,e.userId&&u.session.userId.value&&e.userId!==u.session.userId.value&&this.reset(),Le(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:i,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,t=!1){let i="alias";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),u.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:i,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,t=!1){let i="group";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),u.metrics.triggered.value+=1,Le(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:i,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,t=!1){let i="reset";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,t,i=!1){let r="setAnonymousId";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[r,e,t]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,t)}getUserId(){return u.session.userId.value}getUserTraits(){return u.session.userTraits.value}getGroupId(){return u.session.groupId.value}getGroupTraits(){return u.session.groupTraits.value}startSession(e,t=!1){let i="startSession";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let t="endSession";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[t]];return}this.errorHandler.leaveBreadcrumb(`New ${t} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,t=!1){let i="consent";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Ee(()=>{u.consents.preConsent.value={...u.consents.preConsent.value,enabled:!1},u.consents.postConsent.value=sm(e);let{initialized:r,consentsData:n}=zc(u.consents.postConsent.value.consentManagement,this.logger);u.consents.initialized.value=r,u.consents.data.value=n}),u.consents.enabled.value&&!u.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",u,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(t)}sendTrackingEvents(e){if(u.consents.postConsent.value.trackConsent){let t=io(Sf);e?u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(u.consents.postConsent.value.sendPageEvent){let t=zi();e?u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,i=!1){let r="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,u,this.logger);else{if(u.lifecycle.loaded.value){this.logger.error(Hp(xi,e));return}u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[r,e,t]]}}},Vt=class Vt{constructor(){le(this,"analyticsInstances",{});le(this,"defaultAnalyticsKey","");le(this,"logger",pt);try{if(Vt.globalSingleton)return Vt.globalSingleton;Vt.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(),Vt.globalSingleton=this,u.autoTrack.pageLifecycle.pageViewId.value=Xi(),u.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){ge(e)}}createSafeAnalyticsInstance(){u.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(){xc.init(),uo.configure(),lo.configure(),co.configure(),Ji.configure()}setDefaultInstanceKey(e){ne(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;return(!ne(t)||!t)&&(t=this.defaultAnalyticsKey),this.analyticsInstances[t]||(this.analyticsInstances[t]=new Zn),this.analyticsInstances[t]}catch(t){ge(t);return}}load(e,t,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let r=dc(Gs);Df(r),zs(Gs,q(r)),this.getAnalyticsInstance(e)?.load(e,t,K(i))}catch(r){ge(r)}}trackPageLifecycleEvents(e){let{autoTrack:t,useBeacon:i}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=t??{},{events:a=[vn.UNLOADED],enabled:l=r,options:c=n}=o??{};u.autoTrack.pageLifecycle.enabled.value=l,u.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,i,c)}setupPageUnloadTracking(e,t,i){(e.length===0||e.includes(vn.UNLOADED))&&(t===!0?of(r=>{if(r===!1&&u.lifecycle.loaded.value){let n=Date.now(),o=n-u.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(vn.UNLOADED,{timeOnPage:o},{...i,originalTimestamp:nc(new Date(n))})}},!0):this.logger.warn(Bp(Xg)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=Nf(e);zs(Gs,q([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(K(e))}catch(t){ge(t)}}page(e,t,i,r,n){try{this.getAnalyticsInstance()?.page(zi(K(e),K(t),K(i),K(r),K(n)))}catch(o){ge(o)}}track(e,t,i,r){try{this.getAnalyticsInstance()?.track(io(K(e),K(t),K(i),K(r)))}catch(n){ge(n)}}identify(e,t,i,r){try{this.getAnalyticsInstance()?.identify(tc(K(e),K(t),K(i),K(r)))}catch(n){ge(n)}}alias(e,t,i,r){try{this.getAnalyticsInstance()?.alias(sc(K(e),K(t),K(i),K(r)))}catch(n){ge(n)}}group(e,t,i,r){try{this.getAnalyticsInstance()?.group(ic(K(e),K(t),K(i),K(r)))}catch(n){ge(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(K(e))}catch(t){ge(t)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(K(e))}catch(t){ge(t);return}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(K(e),K(t))}catch(i){ge(i)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){ge(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){ge(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){ge(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){ge(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(K(e))}catch(t){ge(t)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){ge(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){ge(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(K(e))}catch(t){ge(t)}}consent(e){try{this.getAnalyticsInstance()?.consent(K(e))}catch(t){ge(t)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(K(e),K(t))}catch(i){ge(i)}}};le(Vt,"globalSingleton",null);us=Vt});var Xc,Zc,go,Qc,eu,tu,su,iu,qs=Pe(()=>{"use strict";Xc="https://deriv.com/cdn-cgi/trace",Zc="https://cdn.growthbook.io",go="https://deriv-dataplane.rudderstack.com",Qc="https://ph.deriv.com",eu="https://us.posthog.com",tu=()=>{if(typeof window>"u")return Qc;let s=window.location.hostname;return s.includes(".deriv.me")?"https://ph.deriv.me":s.includes(".deriv.be")?"https://ph.deriv.be":s.includes(".deriv.ae")?"https://ph.deriv.ae":Qc},su=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],iu=["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 ir(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)s[i]=t[i]}return s}function fo(s,e){function t(r,n,o){if(!(typeof document>"u")){o=ir({},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+"="+s.write(n,r)+a}}function i(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("="),c=l.slice(1).join("=");try{var d=decodeURIComponent(l[0]);if(o[d]=s.read(c,d),r===d)break}catch{}}return r?o[r]:o}}return Object.create({set:t,get:i,remove:function(r,n){t(r,"",ir({},n,{expires:-1}))},withAttributes:function(r){return fo(this.converter,ir({},this.attributes,r))},withConverter:function(r){return fo(ir({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(s)}})}var Xm,ru,nu=Pe(()=>{"use strict";Xm={read:function(s){return s[0]==='"'&&(s=s.slice(1,-1)),s.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(s){return encodeURIComponent(s).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};ru=fo(Xm,{path:"/"})});var Rt,nr,Ks,rr,ou,jt,au,lu,Ys=Pe(()=>{"use strict";nu();qs();Rt=(s,e)=>(...t)=>{e()&&console.log(`[ANALYTIC]${s}`,...t)},nr=s=>{let e=s.split("@")[1]?.toLowerCase();return e?iu.includes(e):!1},Ks=s=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s),rr=null,ou=async()=>{if(rr)return rr;let s=JSON.parse(ru.get("website_status")||"{}")?.clients_country;return rr=(async()=>{try{let e=await fetch(Xc).catch(()=>null);if(!e)return s||"";let t=await e.text().catch(()=>"");return t?Object.fromEntries(t.split(`
5
- `).map(r=>r.split("=",2))).loc?.toLowerCase()||s||"":s||""}catch{return s||""}})(),rr},jt=s=>{if(s==null||typeof s!="object")return s;if(Array.isArray(s)){let i=[];for(let r=0;r<s.length;r++){let n=jt(s[r]);n!=null&&i.push(n)}return i.length?i:void 0}let e={},t=!1;for(let i in s){if(!Object.prototype.hasOwnProperty.call(s,i))continue;let r=jt(s[i]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[i]=r,t=!0)}return t?e:void 0},au=(s,e)=>{for(let t in s){if(!Object.prototype.hasOwnProperty.call(s,t))continue;let i=s[t];i&&typeof i=="object"&&!Array.isArray(i)?au(i,e):e[t]=i}},lu=s=>{if(s==null||typeof s!="object"||Array.isArray(s))return s;let e={};return au(s,e),e}});function _u(){return vu}function po(s){let e=2166136261,t=s.length;for(let i=0;i<t;i++)e^=s.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Js(s,e,t){return t===2?po(po(s+e)+"")%1e4/1e4:t===1?po(e+s)%1e3/1e3:null}function ey(s){return s<=0?[]:new Array(s).fill(1/s)}function cr(s,e){return s>=e[0]&&s<e[1]}function mu(s,e){let t=Js("__"+e[0],s,1);return t===null?!1:t>=e[1]&&t<e[2]}function yu(s,e){for(let t=0;t<e.length;t++)if(cr(s,e[t]))return t;return-1}function _o(s){try{let e=s.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function ur(s,e){if(!e.length)return!1;let t=!1,i=!1;for(let r=0;r<e.length;r++){let n=iy(s,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else t=!0,n&&(i=!0)}return i||!t}function ty(s,e,t){try{let i=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(i="\\/?"+i.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+i+"$","i").test(s)}catch{return!1}}function sy(s,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),i=[[s.host,t.host,!1],[s.pathname,t.pathname,!0]];return t.hash&&i.push([s.hash,t.hash,!1]),t.searchParams.forEach((r,n)=>{i.push([s.searchParams.get(n)||"",r,!1])}),!i.some(r=>!ty(r[0],r[1],r[2]))}catch{return!1}}function iy(s,e,t){try{let i=new URL(s,"https://_");if(e==="regex"){let r=_o(t);return r?r.test(i.href)||r.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return sy(i,t);return!1}catch{return!1}}function bu(s,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=ey(s);t=t||i,t.length!==s&&(t=i);let r=t.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(t=i);let n=0;return t.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function Eu(s,e,t){if(!e)return null;let i=e.split("?")[1];if(!i)return null;let r=i.replace(/#.*/,"").split("&").map(n=>n.split("=",2)).filter(([n])=>n===s).map(([,n])=>parseInt(n));return r.length>0&&r[0]>=0&&r[0]<t?r[0]:null}function Su(s){try{return s()}catch(e){return console.error(e),!1}}async function Wt(s,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||vu.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let i=await t.importKey("raw",vo(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=s.split("."),o=await t.decrypt({name:"AES-CBC",iv:vo(r)},i,vo(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Qs(s){return typeof s=="string"?s:JSON.stringify(s)}function Me(s){typeof s=="number"&&(s=s+""),(!s||typeof s!="string")&&(s="0");let e=s.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}function ku(){let s;try{s="1.6.5"}catch{s=""}return s}function wu(s,e){let t,i;try{t=new URL(s),i=new URL(e)}catch(r){return console.error(`Unable to merge query strings: ${r}`),e}return t.searchParams.forEach((r,n)=>{i.searchParams.has(n)||i.searchParams.set(n,r)}),i.toString()}function pu(s){return typeof s=="object"&&s!==null}function dr(s){return s.urlPatterns&&s.variations.some(e=>pu(e)&&"urlRedirect"in e)?"redirect":s.variations.some(e=>pu(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function hr(s,e){return new Promise(t=>{let i=!1,r,n=o=>{i||(i=!0,r&&clearTimeout(r),t(o||null))};e&&(r=setTimeout(()=>n(),e)),s.then(o=>n(o)).catch(()=>n())})}var vu,vo,Xs=Pe(()=>{"use strict";vu={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};vo=s=>Uint8Array.from(atob(s),e=>e.charCodeAt(0))});function Iu(s){Object.assign(Te,s),Te.backgroundSync||ko()}async function Ru({instance:s,timeout:e,skipCache:t,allowStale:i,backgroundSync:r}){return r||(Te.backgroundSync=!1),ay({instance:s,allowStale:i,timeout:e,skipCache:t})}function ry(s){let e=Zs(s),t=fs.get(e)||new Set;t.add(s),fs.set(e,t)}function Ou(s){fs.forEach(e=>e.delete(s))}function ny(){ps.forEach(s=>{s&&(s.state="idle",Eo(s))})}function oy(){ps.forEach(s=>{s&&s.state==="idle"&&So(s)})}async function Tu(){try{if(!rt.localStorage)return;await rt.localStorage.setItem(Te.cacheKey,JSON.stringify(Array.from(vt.entries())))}catch{}}async function ay({instance:s,allowStale:e,timeout:t,skipCache:i}){let r=Zs(s),n=yo(s),o=new Date,a=new Date(o.getTime()-Te.maxAge+Te.staleTTL);await ly();let l=!Te.disableCache&&!i?vt.get(n):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&vs.add(r),l.staleAt<o?mo(s):bo(s),{data:l.data,success:!0,source:"cache"}):await hr(mo(s),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function Zs(s){let[e,t]=s.getApiInfo();return`${e}||${t}`}function yo(s){let e=Zs(s);if(!("isRemoteEval"in s)||!s.isRemoteEval())return e;let t=s.getAttributes(),i=s.getCacheKeyAttributes()||Object.keys(s.getAttributes()),r={};i.forEach(a=>{r[a]=t[a]});let n=s.getForcedVariations(),o=s.getUrl();return`${e}||${JSON.stringify({ca:r,fv:n,url:o})}`}async function ly(){if(!Au){Au=!0;try{if(rt.localStorage){let s=await rt.localStorage.getItem(Te.cacheKey);if(!Te.disableCache&&s){let e=JSON.parse(s);e&&Array.isArray(e)&&e.forEach(([t,i])=>{vt.set(t,{...i,staleAt:new Date(i.staleAt)})}),Cu()}}}catch{}if(!Te.disableIdleStreams){let s=gs.startIdleListener();s&&(gs.stopIdleListener=s)}}}function Cu(){let s=Array.from(vt.entries()).map(([t,i])=>({key:t,staleAt:i.staleAt.getTime()})).sort((t,i)=>t.staleAt-i.staleAt),e=Math.min(Math.max(0,vt.size-Te.maxEntries),vt.size);for(let t=0;t<e;t++)vt.delete(s[t].key)}function Pu(s,e,t){let i=t.dateUpdated||"",r=new Date(Date.now()+Te.staleTTL),n=Te.disableCache?void 0:vt.get(e);if(n&&i&&n.version===i){n.staleAt=r,Tu();return}Te.disableCache||(vt.set(e,{data:t,version:i,staleAt:r,sse:vs.has(s)}),Cu()),Tu();let o=fs.get(s);o&&o.forEach(a=>cy(a,t))}async function cy(s,e){await s.setPayload(e||s.getPayload())}async function mo(s){let{apiHost:e,apiRequestHeaders:t}=s.getApiHosts(),i=s.getClientKey(),r="isRemoteEval"in s&&s.isRemoteEval(),n=Zs(s),o=yo(s),a=gr.get(o);return a||(a=(r?gs.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:s.getAttributes(),forcedVariations:s.getForcedVariations(),forcedFeatures:Array.from(s.getForcedFeatures().entries()),url:s.getUrl()},headers:t}):gs.fetchFeaturesCall({host:e,clientKey:i,headers:t})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&vs.add(n),c.json()}).then(c=>(Pu(n,o,c),bo(s),gr.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(gr.delete(o),{data:null,source:"error",success:!1,error:c})),gr.set(o,a)),a}function bo(s,e=!1){let t=Zs(s),i=yo(s),{streamingHost:r,streamingHostRequestHeaders:n}=s.getApiHosts(),o=s.getClientKey();if(e&&vs.add(t),Te.backgroundSync&&vs.has(t)&&rt.EventSource){if(ps.has(t))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let c=fs.get(t);c&&c.forEach(d=>{mo(d)})}else if(l.type==="features"){let c=JSON.parse(l.data);Pu(t,i,c)}a.errors=0}catch{Nu(a)}},errors:0,state:"active"};ps.set(t,a),So(a)}}function Nu(s){if(s.state!=="idle"&&(s.errors++,s.errors>3||s.src&&s.src.readyState===2)){let e=Math.pow(3,s.errors-3)*(1e3+Math.random()*1e3);Eo(s),setTimeout(()=>{["idle","active"].includes(s.state)||So(s)},Math.min(e,3e5))}}function Eo(s){s.src&&(s.src.onopen=null,s.src.onerror=null,s.src.close(),s.src=null,s.state==="active"&&(s.state="disabled"))}function So(s){s.src=gs.eventSourceCall({host:s.host,clientKey:s.clientKey,headers:s.headers}),s.state="active",s.src.addEventListener("features",s.cb),s.src.addEventListener("features-updated",s.cb),s.src.onerror=()=>Nu(s),s.src.onopen=()=>{s.errors=0}}function uy(s,e){Eo(s),ps.delete(e)}function ko(){vs.clear(),ps.forEach(uy),fs.clear(),gs.stopIdleListener()}function fr(s,e){if(e.streaming){if(!s.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&bo(s,!0),ry(s)}}var Te,rt,gs,fs,Au,vt,gr,ps,vs,Du=Pe(()=>{"use strict";Xs();Te={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},rt=_u(),gs={fetchFeaturesCall:({host:s,clientKey:e,headers:t})=>rt.fetch(`${s}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:s,clientKey:e,payload:t,headers:i})=>{let r={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(t)};return rt.fetch(`${s}/api/eval/${e}`,r)},eventSourceCall:({host:s,clientKey:e,headers:t})=>t?new rt.EventSource(`${s}/sub/${e}`,{headers:t}):new rt.EventSource(`${s}/sub/${e}`),startIdleListener:()=>{let s;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(s),oy()):document.visibilityState==="hidden"&&(s=window.setTimeout(ny,Te.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(rt.localStorage=globalThis.localStorage)}catch{}fs=new Map,Au=!1,vt=new Map,gr=new Map,ps=new Map,vs=new Set});function hy(s){return s==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[s]}}function yr(s){var e=mr.get(s);return e||(e={element:s,attributes:{}},mr.set(s,e)),e}function br(s,e,t,i,r){var n=t(s),o={isDirty:!1,originalValue:n,virtualValue:n,mutations:[],el:s,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=t(s);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,r(o))}}),mutationRunner:r,setValue:i,getCurrentValue:t};return e==="position"&&s.parentNode?o.observer.observe(s.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(s,hy(e)),o}function Er(s,e){var t=e.getCurrentValue(e.el);e.virtualValue=s,s&&typeof s!="string"?(!t||s.parentNode!==t.parentNode||s.insertBeforeNode!==t.insertBeforeNode)&&(e.isDirty=!0,xu()):s!==t&&(e.isDirty=!0,xu())}function gy(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),Er(Iy(e),s)}function fy(s){var e=new Set(s.originalValue.split(/\s+/).filter(Boolean));s.mutations.forEach(function(t){return t.mutate(e)}),Er(Array.from(e).filter(Boolean).join(" "),s)}function py(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),Er(e,s)}function vy(s){var e=s.parentSelector,t=s.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var r=t?document.querySelector(t):null;return t&&!r?null:{parentNode:i,insertBeforeNode:r}}function _y(s){var e=s.originalValue;s.mutations.forEach(function(t){var i=t.mutate(),r=vy(i);e=r||e}),Er(e,s)}function $u(s){var e=yr(s);return e.html||(e.html=br(s,"html",my,yy,gy)),e.html}function Fu(s){var e=yr(s);return e.position||(e.position=br(s,"position",by,Ey,_y)),e.position}function Mu(s){var e=yr(s);return e.classes||(e.classes=br(s,"class",ky,Sy,fy)),e.classes}function Uu(s,e){var t=yr(s);return t.attributes[e]||(t.attributes[e]=br(s,e,wy(e),Ay(e),py)),t.attributes[e]}function Ty(s,e){var t=mr.get(s);if(t)if(e==="html"){var i,r;(i=t.html)==null||(r=i.observer)==null||r.disconnect(),delete t.html}else if(e==="class"){var n,o;(n=t.classes)==null||(o=n.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var c,d,h;(c=t.attributes)==null||(d=c[e])==null||(h=d.observer)==null||h.disconnect(),delete t.attributes[e]}}function Iy(s){return pr||(pr=document.createElement("div")),pr.innerHTML=s,pr.innerHTML}function vr(s,e,t){if(t.isDirty){t.isDirty=!1;var i=t.virtualValue;t.mutations.length||Ty(s,e),t.setValue(s,i)}}function Ry(s,e){s.html&&vr(e,"html",s.html),s.classes&&vr(e,"class",s.classes),s.position&&vr(e,"position",s.position),Object.keys(s.attributes).forEach(function(t){vr(e,t,s.attributes[t])})}function xu(){mr.forEach(Ry)}function Oy(s,e){var t=null;s.kind==="html"?t=$u(e):s.kind==="class"?t=Mu(e):s.kind==="attribute"?t=Uu(e,s.attribute):s.kind==="position"&&(t=Fu(e)),t&&(t.mutations.push(s),t.mutationRunner(t))}function Cy(s,e){var t=null;if(s.kind==="html"?t=$u(e):s.kind==="class"?t=Mu(e):s.kind==="attribute"?t=Uu(e,s.attribute):s.kind==="position"&&(t=Fu(e)),!!t){var i=t.mutations.indexOf(s);i!==-1&&t.mutations.splice(i,1),t.mutationRunner(t)}}function Bu(s){if(!(s.kind==="position"&&s.elements.size===1)){var e=new Set(s.elements),t=document.querySelectorAll(s.selector);t.forEach(function(i){e.has(i)||(s.elements.add(i),Oy(s,i))})}}function Py(s){s.elements.forEach(function(e){return Cy(s,e)}),s.elements.clear(),Io.delete(s)}function Lu(){Io.forEach(Bu)}function Ny(){typeof document>"u"||(wo||(wo=new MutationObserver(function(){Lu()})),Lu(),wo.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Sr(s){return typeof document>"u"?To:(Io.add(s),Bu(s),{revert:function(){Py(s)}})}function Ao(s,e){return Sr({kind:"html",elements:new Set,mutate:e,selector:s})}function Vu(s,e){return Sr({kind:"position",elements:new Set,mutate:e,selector:s})}function ei(s,e){return Sr({kind:"class",elements:new Set,mutate:e,selector:s})}function _r(s,e,t){return dy.test(e)?e==="class"||e==="className"?ei(s,function(i){var r=t(Array.from(i).join(" "));i.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return i.add(n)})}):Sr({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:s}):To}function Dy(s){var e=s.selector,t=s.action,i=s.value,r=s.attribute,n=s.parentSelector,o=s.insertBeforeSelector;if(r==="html"){if(t==="append")return Ao(e,function(a){return a+(i??"")});if(t==="set")return Ao(e,function(){return i??""})}else if(r==="class"){if(t==="append")return ei(e,function(a){i&&a.add(i)});if(t==="remove")return ei(e,function(a){i&&a.delete(i)});if(t==="set")return ei(e,function(a){a.clear(),i&&a.add(i)})}else if(r==="position"){if(t==="set"&&n)return Vu(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(t==="append")return _r(e,r,function(a){return a!==null?a+(i??""):i??""});if(t==="set")return _r(e,r,function(){return i??""});if(t==="remove")return _r(e,r,function(){return null})}return To}var dy,To,mr,Io,my,yy,by,Ey,Sy,ky,wy,Ay,pr,wo,xy,Gu,Hu=Pe(()=>{"use strict";dy=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,To={revert:function(){}},mr=new Map,Io=new Set;my=function(e){return e.innerHTML},yy=function(e,t){return e.innerHTML=t};by=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Ey=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};Sy=function(e,t){return t?e.className=t:e.removeAttribute("class")},ky=function(e){return e.className};wy=function(e){return function(t){var i;return(i=t.getAttribute(e))!=null?i:null}},Ay=function(e){return function(t,i){return i!==null?t.setAttribute(e,i):t.removeAttribute(e)}};Ny();xy={html:Ao,classes:ei,attribute:_r,position:Vu,declarative:Dy},Gu=xy});function Ot(s,e,t){t=t||{};for(let[i,r]of Object.entries(e))switch(i){case"$or":if(!Wu(s,r,t))return!1;break;case"$nor":if(Wu(s,r,t))return!1;break;case"$and":if(!Uy(s,r,t))return!1;break;case"$not":if(Ot(s,r,t))return!1;break;default:if(!ti(r,Ly(s,i),t))return!1}return!0}function Ly(s,e){let t=e.split("."),i=s;for(let r=0;r<t.length;r++)if(i&&typeof i=="object"&&t[r]in i)i=i[t[r]];else return null;return i}function ju(s,e=!1){let t=`${s}${e?"/i":""}`;return Ro[t]||(Ro[t]=new RegExp(s.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Ro[t]}function ti(s,e,t,i=!1){if(typeof s=="string")return i?String(e).toLowerCase()===s.toLowerCase():e+""===s;if(typeof s=="number")return e*1===s;if(typeof s=="boolean")return e!==null&&!!e===s;if(s===null)return e===null;if(Array.isArray(s)||!qu(s))return JSON.stringify(e)===JSON.stringify(s);for(let r in s)if(!My(r,e,s[r],t))return!1;return!0}function qu(s){let e=Object.keys(s);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function $y(s){if(s===null)return"null";if(Array.isArray(s))return"array";let e=typeof s;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function Fy(s,e,t){if(!Array.isArray(s))return!1;let i=qu(e)?r=>ti(e,r,t):r=>Ot(r,e,t);for(let r=0;r<s.length;r++)if(s[r]&&i(s[r]))return!0;return!1}function _s(s,e,t=!1){if(t){let i=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(s)?s.some(r=>e.some(n=>i(r)===i(n))):e.some(r=>i(s)===i(r))}return Array.isArray(s)?s.some(i=>e.includes(i)):e.includes(s)}function zu(s,e,t,i=!1){if(!Array.isArray(s))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<s.length;o++)if(ti(e[r],s[o],t,i)){n=!0;break}if(!n)return!1}return!0}function My(s,e,t,i){switch(s){case"$veq":return Me(e)===Me(t);case"$vne":return Me(e)!==Me(t);case"$vgt":return Me(e)>Me(t);case"$vgte":return Me(e)>=Me(t);case"$vlt":return Me(e)<Me(t);case"$vlte":return Me(e)<=Me(t);case"$eq":return e===t;case"$ne":return e!==t;case"$lt":return e<t;case"$lte":return e<=t;case"$gt":return e>t;case"$gte":return e>=t;case"$exists":return t?e!=null:e==null;case"$in":return Array.isArray(t)?_s(e,t):!1;case"$ini":return Array.isArray(t)?_s(e,t,!0):!1;case"$inGroup":return _s(e,i[t]||[]);case"$notInGroup":return!_s(e,i[t]||[]);case"$nin":return Array.isArray(t)?!_s(e,t):!1;case"$nini":return Array.isArray(t)?!_s(e,t,!0):!1;case"$not":return!ti(t,e,i);case"$size":return Array.isArray(e)?ti(t,e.length,i):!1;case"$elemMatch":return Fy(e,t,i);case"$all":return Array.isArray(t)?zu(e,t,i):!1;case"$alli":return Array.isArray(t)?zu(e,t,i,!0):!1;case"$regex":try{return ju(t).test(e)}catch{return!1}case"$regexi":try{return ju(t,!0).test(e)}catch{return!1}case"$type":return $y(e)===t;default:return console.error("Unknown operator: "+s),!1}}function Wu(s,e,t){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(Ot(s,e[i],t))return!0;return!1}function Uy(s,e,t){for(let i=0;i<e.length;i++)if(!Ot(s,e[i],t))return!1;return!0}var Ro,Ku=Pe(()=>{"use strict";Xs();Ro={}});function Gy(s){let e=new Map;return s.global.forcedFeatureValues&&s.global.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),s.user.forcedFeatureValues&&s.user.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),e}function Hy(s){return s.global.forcedVariations&&s.user.forcedVariations?{...s.global.forcedVariations,...s.user.forcedVariations}:s.global.forcedVariations?s.global.forcedVariations:s.user.forcedVariations?s.user.forcedVariations:{}}async function ms(s){try{await s()}catch{}}function Yu(s,e,t){if(s.user.trackedExperiments){let r=Ar(e,t);if(s.user.trackedExperiments.has(r))return[];s.user.trackedExperiments.add(r)}s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let i=[];if(s.global.trackingCallback){let r=s.global.trackingCallback;i.push(ms(()=>r(e,t,s.user)))}if(s.user.trackingCallback){let r=s.user.trackingCallback;i.push(ms(()=>r(e,t)))}if(s.global.eventLogger){let r=s.global.eventLogger;i.push(ms(()=>r(Vy,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},s.user)))}return i}function jy(s,e,t){if(s.user.trackedFeatureUsage){let i=JSON.stringify(t.value);if(s.user.trackedFeatureUsage[e]===i)return;s.user.trackedFeatureUsage[e]=i,s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({featureKey:e,result:t,timestamp:Date.now().toString(),logType:"feature"})}if(s.global.onFeatureUsage){let i=s.global.onFeatureUsage;ms(()=>i(e,t,s.user))}if(s.user.onFeatureUsage){let i=s.user.onFeatureUsage;ms(()=>i(e,t))}if(s.global.eventLogger){let i=s.global.eventLogger;ms(()=>i(By,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},s.user))}}function kr(s,e){if(e.stack.evaluatedFeatures.has(s))return Ct(e,s,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(s),e.stack.id=s;let t=Gy(e);if(t.has(s))return Ct(e,s,t.get(s),"override");if(!e.global.features||!e.global.features[s])return Ct(e,s,null,"unknownFeature");let i=e.global.features[s];if(i.rules){let r=new Set(e.stack.evaluatedFeatures);e:for(let n of i.rules){if(n.parentConditions)for(let l of n.parentConditions){e.stack.evaluatedFeatures=new Set(r);let c=kr(l.id,e);if(c.source==="cyclicPrerequisite")return Ct(e,s,null,"cyclicPrerequisite");let d={value:c.value};if(!Ot(d,l.condition||{})){if(l.gate)return Ct(e,s,null,"prerequisite");continue e}}if(n.filters&&Xu(n.filters,e))continue;if("force"in n){if(n.condition&&!Qu(n.condition,e)||!zy(e,n.seed||s,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=>{!Yu(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),Ct(e,s,n.force,"force",n.id)}if(!n.variations)continue;let o={variations:n.variations,key:n.key||s};"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}=wr(o,s,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return Ct(e,s,a.value,"experiment",n.id,o,a)}}return Ct(e,s,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function wr(s,e,t){let i=s.key,r=s.variations.length;if(r<2)return{result:ce(t,s,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:ce(t,s,-1,!1,e)};if(s=Wy(s,t),s.urlPatterns&&!ur(t.user.url||"",s.urlPatterns))return{result:ce(t,s,-1,!1,e)};let n=Eu(i,t.user.url||"",r);if(n!==null)return{result:ce(t,s,n,!1,e)};let o=Hy(t);if(i in o){let m=o[i];return{result:ce(t,s,m,!1,e)}}if(s.status==="draft"||s.active===!1)return{result:ce(t,s,-1,!1,e)};let{hashAttribute:a,hashValue:l}=qt(t,s.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing?s.fallbackAttribute:void 0);if(!l)return{result:ce(t,s,-1,!1,e)};let c=-1,d=!1,h=!1;if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{variation:m,versionIsBlocked:b}=Yy({ctx:t,expKey:s.key,expBucketVersion:s.bucketVersion,expHashAttribute:s.hashAttribute,expFallbackAttribute:s.fallbackAttribute,expMinBucketVersion:s.minBucketVersion,expMeta:s.meta});d=m>=0,c=m,h=!!b}if(!d){if(s.filters){if(Xu(s.filters,t))return{result:ce(t,s,-1,!1,e)}}else if(s.namespace&&!mu(l,s.namespace))return{result:ce(t,s,-1,!1,e)};if(s.include&&!Su(s.include))return{result:ce(t,s,-1,!1,e)};if(s.condition&&!Qu(s.condition,t))return{result:ce(t,s,-1,!1,e)};if(s.parentConditions){let m=new Set(t.stack.evaluatedFeatures);for(let b of s.parentConditions){t.stack.evaluatedFeatures=new Set(m);let E=kr(b.id,t);if(E.source==="cyclicPrerequisite")return{result:ce(t,s,-1,!1,e)};let N={value:E.value};if(!Ot(N,b.condition||{}))return{result:ce(t,s,-1,!1,e)}}}if(s.groups&&!Ky(s.groups,t))return{result:ce(t,s,-1,!1,e)}}if(s.url&&!qy(s.url,t))return{result:ce(t,s,-1,!1,e)};let f=Js(s.seed||i,l,s.hashVersion||1);if(f===null)return{result:ce(t,s,-1,!1,e)};if(!d){let m=s.ranges||bu(r,s.coverage===void 0?1:s.coverage,s.weights);c=yu(f,m)}if(h)return{result:ce(t,s,-1,!1,e,void 0,!0)};if(c<0)return{result:ce(t,s,-1,!1,e)};if("force"in s)return{result:ce(t,s,s.force===void 0?-1:s.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:ce(t,s,-1,!1,e)};if(s.status==="stopped")return{result:ce(t,s,-1,!1,e)};let g=ce(t,s,c,!0,e,f,d);if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{changed:m,key:b,doc:E}=Qy(t,a,Qs(l),{[Oo(s.key,s.bucketVersion)]:g.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[b]=E,t.user.saveStickyBucketAssignmentDoc(E))}let v=Yu(t,s,g);v.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:s,result:g});let p=v.length?v.length===1?v[0]:Promise.all(v).then(()=>{}):void 0;return"changeId"in s&&s.changeId&&t.global.recordChangeId&&t.global.recordChangeId(s.changeId),{result:g,trackingCall:p}}function Ct(s,e,t,i,r,n,o){let a={value:t,on:!!t,off:!t,source:i,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),i!=="override"&&jy(s,e,a),a}function Ju(s){return{...s.user.attributes,...s.user.attributeOverrides}}function Qu(s,e){return Ot(Ju(e),s,e.global.savedGroups||{})}function Xu(s,e){return s.some(t=>{let{hashValue:i}=qt(e,t.attribute);if(!i)return!0;let r=Js(t.seed,i,t.hashVersion||2);return r===null?!0:!t.ranges.some(n=>cr(r,n))})}function zy(s,e,t,i,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=qt(s,t,i);if(!a)return!1;let l=Js(e,a,o||1);return l===null?!1:r?cr(l,r):n!==void 0?l<=n:!0}function ce(s,e,t,i,r,n,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:c}=qt(s,e.hashAttribute,s.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),d=e.meta?e.meta[t]:{},h={key:d.key||""+t,featureId:r,inExperiment:a,hashUsed:i,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};return d.name&&(h.name=d.name),n!==void 0&&(h.bucket=n),d.passthrough&&(h.passthrough=d.passthrough),h}function Wy(s,e){let t=s.key,i=e.global.overrides;return i&&i[t]&&(s=Object.assign({},s,i[t]),typeof s.url=="string"&&(s.url=_o(s.url))),s}function qt(s,e,t){let i=e||"id",r="",n=Ju(s);return n[i]&&(r=n[i]),!r&&t&&(n[t]&&(r=n[t]),r&&(i=t)),{hashAttribute:i,hashValue:r}}function qy(s,e){let t=e.user.url;if(!t)return!1;let i=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(s.test(t)||s.test(i))}function Ky(s,e){let t=e.global.groups||{};for(let i=0;i<s.length;i++)if(t[s[i]])return!0;return!1}function Yy({ctx:s,expKey:e,expBucketVersion:t,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:n,expMeta:o}){t=t||0,n=n||0,i=i||"id",o=o||[];let a=Oo(e,t),l=Jy(s,i,r);if(n>0)for(let h=0;h<n;h++){let f=Oo(e,h);if(l[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=l[a];if(c===void 0)return{variation:-1};let d=o.findIndex(h=>h.key===c);return d<0?{variation:-1}:{variation:d}}function Oo(s,e){return e=e||0,`${s}__${e}`}function Co(s,e){return`${s}||${e}`}function Jy(s,e,t){if(!s.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:r}=qt(s,e),n=Co(i,Qs(r)),{hashAttribute:o,hashValue:a}=qt(s,t),l=a?Co(o,Qs(a)):null,c={};return l&&s.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,s.user.stickyBucketAssignmentDocs[l].assignments||{}),s.user.stickyBucketAssignmentDocs[n]&&Object.assign(c,s.user.stickyBucketAssignmentDocs[n].assignments||{}),c}function Qy(s,e,t,i){let r=Co(e,t),n=s.user.stickyBucketAssignmentDocs&&s.user.stickyBucketAssignmentDocs[r]?s.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o={...n,...i},a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function Xy(s,e){let t=new Set,i=e&&e.features?e.features:s.global.features||{},r=e&&e.experiments?e.experiments:s.global.experiments||[];return Object.keys(i).forEach(n=>{let o=i[n];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),r.map(n=>{t.add(n.hashAttribute||"id"),n.fallbackAttribute&&t.add(n.fallbackAttribute)}),Array.from(t)}async function Zu(s,e,t){let i=Po(s,t);return e.getAllAssignments(i)}function Po(s,e){let t={};return Xy(s,e).forEach(r=>{let{hashValue:n}=qt(s,r);t[r]=Qs(n)}),t}async function ed(s,e,t){if(s={...s},s.encryptedFeatures){try{s.features=JSON.parse(await Wt(s.encryptedFeatures,e,t))}catch(i){console.error(i)}delete s.encryptedFeatures}if(s.encryptedExperiments){try{s.experiments=JSON.parse(await Wt(s.encryptedExperiments,e,t))}catch(i){console.error(i)}delete s.encryptedExperiments}if(s.encryptedSavedGroups){try{s.savedGroups=JSON.parse(await Wt(s.encryptedSavedGroups,e,t))}catch(i){console.error(i)}delete s.encryptedSavedGroups}return s}function td(s){let e=s.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(s.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:s.apiHostRequestHeaders,streamingHostRequestHeaders:s.streamingHostRequestHeaders}}function Ar(s,e){return e.hashAttribute+e.hashValue+s.key+e.variationId}var By,Vy,sd=Pe(()=>{"use strict";Ku();Xs();By="Feature Evaluated",Vy="Experiment Viewed"});var ys,Zy,si,id=Pe(()=>{"use strict";Hu();Xs();Du();sd();ys=typeof window<"u"&&typeof document<"u",Zy=ku(),si=class{constructor(e){if(e=e||{},this.version=Zy,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 t=!1;try{t=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(t)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 t=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=i=>t.saveAssignments(i)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),ys&&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 t in this._options.stickyBucketAssignmentDocs){let i=this._options.stickyBucketAssignmentDocs[t];i&&this._options.stickyBucketService.saveAssignments(i).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await ed(e,this._options.decryptionKey);this._decryptedPayload=t,await this.refreshStickyBuckets(t),t.features&&(this._options.features=t.features),t.savedGroups&&(this._options.savedGroups=t.savedGroups),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let t=e.payload;if(t.encryptedExperiments||t.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,t)),this._payload=t,this._decryptedPayload=t,t.features&&(this._options.features=t.features),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,fr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Iu(e.cacheSettings),e.payload)return await this.setPayload(e.payload),fr(this,e),{success:!0,source:"init"};{let{data:t,...i}=await this._refresh({...e,allowStale:!0});return fr(this,e),await this.setPayload(t||{}),i}}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 t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return td(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:t,allowStale:i,streaming:r}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Ru({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:i,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,t,i){let r=await Wt(e,t||this._options.decryptionKey,i);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,i){let r=await Wt(e,t||this._options.decryptionKey,i);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(t=>{try{t()}catch(i){console.error(i)}}),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,Ou(this),e.destroyAllStreams&&ko(),this.logs=[],ys&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(t=>{t.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,t){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=t,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:t}=wr(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(i=>i.key===e).map(i=>this._runAutoExperiment(i)).filter(i=>i!==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,t){let i=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!i)return null;let r=this._isAutoExperimentBlockedByContext(e),n,o;r?n=ce(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=wr(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!t&&n.inExperiment&&i&&i.valueHash===a)return n;if(i&&this._undoActiveAutoExperiment(e),n.inExperiment){let l=dr(e);if(l==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?wu(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(ur(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=c;let{navigate:d,delay:h}=this._getNavigateFunction();if(d)if(ys)Promise.all([...o?[hr(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??h))]).then(()=>{try{d(c)}catch(f){console.error(f)}});else try{d(c)}catch(f){console.error(f)}}else if(l==="visual"){let c=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(n.value):this._applyDOMChanges(n.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return n}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],i=new Set(t);this._activeAutoExperiments.forEach((r,n)=>{i.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of t){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&dr(r)==="redirect")break}}_onExperimentEval(e,t){let i=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,i)}_fireSubscriptions(e,t,i){(!i||i.result.inExperiment!==t.inExperiment||i.result.variationId!==t.variationId)&&this._subscriptions.forEach(r=>{try{r(e,t)}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,t){let i=this.evalFeature(e).value;return i===null?t:i}feature(e){return this.evalFeature(e)}evalFeature(e){return kr(e,this._getEvalContext())}log(e,t){this.debug&&(this._options.log?this._options.log(e,t):console.log(e,t))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(t=>t&&t.experiment&&t.result).map(t=>[Ar(t.experiment,t.result),t]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(t=>{!t||!t.experiment||!t.result?console.error("Invalid deferred tracking call",{call:t}):e.push(this._options.trackingCallback(t.experiment,t.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,t){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:t,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,t||{},this._getUserContext())}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Ar(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(ys?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=dr(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(i=>i.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let i=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!==i.protocol||n.host!==i.host))return!0}}catch(i){return this.log("Error parsing current or redirect URL",{id:e.key,error:i}),!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}:ys?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!ys)return;let t=[];if(e.css){let i=document.createElement("style");i.innerHTML=e.css,document.head.appendChild(i),t.push(()=>i.remove())}if(e.js){let i=document.createElement("script");i.innerHTML=e.js,this._options.jsInjectionNonce&&(i.nonce=this._options.jsInjectionNonce),document.head.appendChild(i),t.push(()=>i.remove())}return e.domMutations&&e.domMutations.forEach(i=>{t.push(Gu.declarative(i).revert)}),()=>{t.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),i=await Zu(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=i}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let i=this._getEvalContext(),r=Po(i,t);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var rd=Pe(()=>{"use strict";id()});var nd={};pn(nd,{Growthbook:()=>No});var je,No,od=Pe(()=>{"use strict";rd();ho();qs();Ys();je=class je{constructor(e,t,i={},r=!1){this.analytics=new us;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Rt("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:t,user_language:i,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:c,url:d,domain:h,utm_content:f,residence_country:g,loggedIn:v,network_type:p,network_downlink:m,user_id:b,anonymous_id:E,account_mode:N})=>{let R={...this.GrowthBook.getAttributes(),id:e,...b!==void 0&&{user_id:b},...E!==void 0&&{anonymous_id:E},...t!==void 0&&{country:t},...g!==void 0&&{residence_country:g},...i!==void 0&&{user_language:i},...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},...c!==void 0&&{is_authorised:c},...d!==void 0&&{url:d},...h!==void 0&&{domain:h},...f!==void 0&&{utm_content:f},...v!==void 0&&{loggedIn:v},...p!==void 0&&{network_type:p},...m!==void 0&&{network_downlink:m},...N!==void 0&&{account_mode:N}};this.log("setAttributes | updating GrowthBook attributes",R),this.GrowthBook.setAttributes(R)};this.getFeatureValue=(e,t)=>{let i=this.GrowthBook.getFeatureValue(e,t);return this.log("getFeatureValue",{key:e,value:i,defaultValue:t}),i};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let t=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:t}),t};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let t=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:t}),t};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 si({apiHost:Zc,clientKey:e,decryptionKey:t,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})},...i}),this.init()}reapplyExperiment(e){let t=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(t)}waitForIsLoaded(e=1e4){return new Promise((t,i)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),t()):Date.now()-r>=e&&(clearInterval(n),i(new Error("GrowthBook initialization timeout")))},100)})}};je.getGrowthBookInstance=(e,t,i,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,t??"",i,r),je._instance),je.resetInstance=()=>{je._instance&&(je._instance.destroy(),je._instance=void 0)};No=je});function cd(s,e,t,i,r,n,o){try{var a=s[n](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(i,r)}function Ze(s){return function(){var e=this,t=arguments;return new Promise((function(i,r){var n=s.apply(e,t);function o(l){cd(n,i,r,o,a,"next",l)}function a(l){cd(n,i,r,o,a,"throw",l)}o(void 0)}))}}function w(){return w=Object.assign?Object.assign.bind():function(s){for(var e=1;arguments.length>e;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},w.apply(null,arguments)}function uh(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}function dh(){return(dh=Ze((function*(s,e){e===void 0&&(e=!0);try{var t=new Blob([s],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return yield new Response(t).blob()}catch(i){return e&&console.error("Failed to gzip compress data",i),null}}))).apply(this,arguments)}function G(s,e){return s.indexOf(e)!==-1}function fh(s){return s===null||typeof s!="object"}function Mr(s,e){return{}.toString.call(s)==="[object "+e+"]"}function sl(s){return!P(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(s,Event)}function at(s,e,t,i,r){return e>t&&(i.warn("min cannot be greater than max."),e=t),lt(s)?s>t?(i.warn(" cannot be greater than max: "+t+". Using max value instead."),t):e>s?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):s:(i.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+r),at(r||t,e,t,i))}function _b(s){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return xo&&t.length===dd||(dd=t.length,xo=t.reduce(((i,r)=>{Tr||(Tr={});var n=Tr[r];if(n)i[n[0]]=n[1];else for(var o=s(r),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,d=e[r];if(c&&d){i[c]=d,Tr[r]=[c,d];break}}return i}),{})),xo}}function la(s,e,t,i,r){var n={platform:s,filename:e,function:t==="<anonymous>"?Ds:t,in_app:!0};return P(i)||(n.lineno=i),P(r)||(n.colno=r),n}function Nh(s,e){e===void 0&&(e=40);var t=Object.keys(s);if(t.sort(),!t.length)return"[object has no keys]";for(var i=t.length;i>0;i--){var r=t.slice(0,i).join(", ");if(e>=r.length)return i===t.length?r:r.length>e?r.slice(0,e)+"...":r}return""}function Or(s,e){Y(s)&&s.forEach(e)}function ae(s,e){if(!H(s))if(Y(s))s.forEach(e);else if(ib(s))s.forEach(((i,r)=>e(i,r)));else for(var t in s)gh.call(s,t)&&e(s[t],t)}function $r(s){for(var e=Object.keys(s),t=e.length,i=new Array(t);t--;)i[t]=[e[t],s[e[t]]];return i}function Pb(s){var e=s?.hostname;if(!ve(e))return!1;var t=e.split(".").slice(-2).join(".");for(var i of Cb)if(t===i)return!1;return!0}function pe(s,e,t,i){var{capture:r=!1,passive:n=!0}=i??{};s?.addEventListener(e,t,{capture:r,passive:n})}function Mh(s){return s.name==="ph_toolbar_internal"}function Vh(s,e){var{organization:t,projectId:i,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,d,h,f;if(n!=="*"&&!n.includes(a.level)||!s.__loaded)return a;a.tags||(a.tags={});var g=s.requestRouter.endpointFor("ui","/project/"+s.config.token+"/person/"+s.get_distinct_id());a.tags["PostHog Person URL"]=g,s.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=s.get_session_replay_url({withTimestamp:!0}));var v,p=((l=a.exception)==null?void 0:l.values)||[],m=p.map((E=>w({},E,{stacktrace:E.stacktrace?w({},E.stacktrace,{type:"raw",frames:(E.stacktrace.frames||[]).map((N=>w({},N,{platform:"web:javascript"})))}):void 0}))),b={$exception_message:((c=p[0])==null?void 0:c.value)||a.message,$exception_type:(d=p[0])==null?void 0:d.type,$exception_level:a.level,$exception_list:m,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=p[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(f=p[0])==null?void 0:f.type,$sentry_tags:a.tags};return t&&i&&(b.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+a.event_id),o&&((v=s.exceptions)==null||v.sendExceptionEvent(b)),a}}function Gh(s,e,t){if(!T)return{};var i,r=e?[...xs,...t||[]]:[],n=Hh(Ti(T.URL,r,Ii),s),o=(i={},ae(Ub,(function(a){var l=ot.M(a);i[a]=l||null})),i);return fe(o,n)}function Hh(s,e){var t=Mb.concat(e||[]),i={};return ae(t,(function(r){var n=Jr(s,r);i[r]=n||null})),i}function jh(s){var e=(function(n){return n?n.search(Nr+"google.([^/?]*)")===0?"google":n.search(Nr+"bing.com")===0?"bing":n.search(Nr+"yahoo.com")===0?"yahoo":n.search(Nr+"duckduckgo.com")===0?"duckduckgo":null:null})(s),t=e!="yahoo"?"q":"p",i={};if(!St(e)){i.$search_engine=e;var r=T?Jr(T.referrer,t):"";r.length&&(i.ph_keyword=r)}return i}function Td(){return navigator.language||navigator.userLanguage}function zh(){return T?.referrer||Xr}function Wh(s,e){var t=s?[...xs,...e||[]]:[],i=ke?.href.substring(0,1e3);return{r:zh().substring(0,1e3),u:i?Ti(i,t,Ii):void 0}}function qh(s){var e,{r:t,u:i}=s,r={$referrer:t,$referring_domain:t==null?void 0:t==Xr?Xr:(e=Yr(t))==null?void 0:e.host};if(i){r.$current_url=i;var n=Yr(i);r.$host=n?.host,r.$pathname=n?.pathname;var o=Hh(i);fe(r,o)}if(t){var a=jh(t);fe(r,a)}return r}function Kh(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Bb(){try{return new Date().getTimezoneOffset()}catch{return}}function qb(s,e){e===void 0&&(e={});var t=(function(){var h=4294967295;return{p(f){for(var g=h,v=0;f.length>v;++v)g=Wb[255&g^f[v]]^g>>>8;h=g},d(){return 4294967295^h}}})(),i=s.length;t.p(s);var r,n,o,a,l,c=(a=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(h,f,g,v,p,m){var b=h.length,E=new We(v+b+5*(1+Math.floor(b/7e3))+p),N=E.subarray(v,E.length-p),I=0;if(!f||8>b)for(var R=0;b>=R;R+=65535){var C=R+65535;b>C?I=Ma(N,I,h.subarray(R,C)):(N[R]=!0,I=Ma(N,I,h.subarray(R,b)))}else{for(var A=zb[f-1],k=A>>>13,L=8191&A,z=(1<<g)-1,j=new Ce(32768),V=new Ce(z+1),S=Math.ceil(g/3),D=2*S,F=function(fn){return(h[fn]^h[fn+1]<<S^h[fn+2]<<D)&z},M=new Ls(25e3),Q=new Ce(288),W=new Ce(32),X=0,ee=0,te=(R=0,0),ye=0,U=0;b>R;++R){var Ae=F(R),qe=32767&R,ss=V[Ae];if(j[qe]=ss,V[Ae]=qe,R>=ye){var Ci=b-R;if((X>7e3||te>24576)&&Ci>423){I=Pd(h,N,0,M,Q,W,ee,te,U,R-U,I),te=X=ee=0,U=R;for(var Ke=0;286>Ke;++Ke)Q[Ke]=0;for(Ke=0;30>Ke;++Ke)W[Ke]=0}var Ft=2,Pi=0,_g=L,wt=qe-ss&32767;if(Ci>2&&Ae==F(R-wt))for(var mg=Math.min(k,Ci)-1,yg=Math.min(32767,R),bg=Math.min(258,Ci);yg>=wt&&--_g&&qe!=ss;){if(h[R+Ft]==h[R+Ft-wt]){for(var At=0;bg>At&&h[R+At]==h[R+At-wt];++At);if(At>Ft){if(Ft=At,Pi=wt,At>mg)break;var Eg=Math.min(wt,At-2),fl=0;for(Ke=0;Eg>Ke;++Ke){var gn=R-wt+Ke+32768&32767,pl=gn-j[gn]+32768&32767;pl>fl&&(fl=pl,ss=gn)}}}wt+=(qe=ss)-(ss=j[qe])+32768&32767}if(Pi){M[te++]=268435456|La[Ft]<<18|$a[Pi];var vl=31&La[Ft],_l=31&$a[Pi];ee+=cl[vl]+ul[_l],++Q[257+vl],++W[_l],ye=R+Ft,++X}else M[te++]=h[R],++Q[h[R]]}}I=Pd(h,N,!0,M,Q,W,ee,te,U,R-U,I)}return Xh(E,0,v+Qh(I)+p)})(n=s,(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)),d=c.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&&Ho(h,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),g){h[3]=8;for(var v=0;g.length>=v;++v)h[v+10]=g.charCodeAt(v)}})(c,e),Ho(c,d-8,t.d()),Ho(c,d-4,i),c}function Nd(s,e,t){return Rs({distinct_id:s,userPropertiesToSet:e,userPropertiesToSetOnce:t})}function sg(s,e){return!s||Object.entries(s).every((t=>{var[i,r]=t,n=e?.[i];if(P(n)||St(n))return!1;var o=[String(n)],a=tg[r.operator];return!!a&&a(r.values,o)}))}function Ud(s){return s instanceof Element&&(s.id===Fh||!(s.closest==null||!s.closest(".toolbar-global-fade-container")))}function dn(s){return!!s&&s.nodeType===1}function $t(s,e){return!!s&&!!s.tagName&&s.tagName.toLowerCase()===e.toLowerCase()}function ng(s){return!!s&&s.nodeType===3}function og(s){return!!s&&s.nodeType===11}function dl(s){return s?cn(s).split(/\s+/):[]}function Bd(s){var e=_?.location.href;return!!(e&&s&&s.some((t=>e.match(t))))}function an(s){var e="";switch(typeof s.className){case"string":e=s.className;break;case"object":e=(s.className&&"baseVal"in s.className?s.className.baseVal:null)||s.getAttribute("class")||"";break;default:e=""}return dl(e)}function ag(s){return H(s)?null:cn(s).split(/(\s+)/).filter((e=>ki(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Oi(s){var e="";return Ja(s)&&!cg(s)&&s.childNodes&&s.childNodes.length&&ae(s.childNodes,(function(t){var i;ng(t)&&t.textContent&&(e+=(i=ag(t.textContent))!==null&&i!==void 0?i:"")})),cn(e)}function Vd(s){return P(s.target)?s.srcElement||null:(e=s.target)!=null&&e.shadowRoot?s.composedPath()[0]||null:s.target||null;var e}function Gd(s,e){if(P(e))return!0;var t,i=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of s)if(t=i(r))return t.v;return!1}function lg(s){var e=s.parentNode;return!(!e||!dn(e))&&e}function Ja(s){for(var e=s;e.parentNode&&!$t(e,"body");e=e.parentNode){var t=an(e);if(G(t,"ph-sensitive")||G(t,"ph-no-capture"))return!1}if(G(an(s),"ph-include"))return!0;var i=s.type||"";if(ve(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var r=s.name||s.id||"";return!ve(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 cg(s){return!!($t(s,"input")&&!["button","checkbox","submit","reset"].includes(s.type)||$t(s,"select")||$t(s,"textarea")||s.getAttribute("contenteditable")==="true")}function ki(s,e){return e===void 0&&(e=!0),!(H(s)||ve(s)&&(s=cn(s),(e?nE:oE).test((s||"").replace(/[- ]/g,""))||(e?aE:lE).test(s)))}function zd(s){var e=Oi(s);return ki(e=(e+" "+hg(s)).trim())?e:""}function hg(s){var e="";return s&&s.childNodes&&s.childNodes.length&&ae(s.childNodes,(function(t){var i;if(t&&((i=t.tagName)==null?void 0:i.toLowerCase())==="span")try{var r=Oi(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+hg(t)).trim())}catch(n){O.error("[AutoCapture]",n)}})),e}function Wd(s){return s.replace(/"|\\"/g,'\\"')}function cE(s){var e=s.attr__class;return e?Y(e)?e:dl(e):void 0}function Ko(s,e){return e.length>s?e.slice(0,s)+"...":e}function uE(s){if(s.previousElementSibling)return s.previousElementSibling;var e=s;do e=e.previousSibling;while(e&&!dn(e));return e}function dE(s,e){for(var t,i,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[s],d=s;d.parentNode&&!$t(d,"body");)og(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var h,f,g=[],v={},p=!1,m=!1;if(ae(c,(R=>{var C=Ja(R);R.tagName.toLowerCase()==="a"&&(p=R.getAttribute("href"),p=C&&p&&ki(p)&&p),G(an(R),"ph-no-capture")&&(m=!0),g.push((function(k,L,z,j){var V=k.tagName.toLowerCase(),S={tag_name:V};hl.indexOf(V)>-1&&!z&&(S.$el_text=V.toLowerCase()==="a"||V.toLowerCase()==="button"?Ko(1024,zd(k)):Ko(1024,Oi(k)));var D=an(k);D.length>0&&(S.classes=D.filter((function(W){return W!==""}))),ae(k.attributes,(function(W){var X;if((!cg(k)||["name","id","class","aria-label"].indexOf(W.name)!==-1)&&(j==null||!j.includes(W.name))&&!L&&ki(W.value)&&(!ve(X=W.name)||X.substring(0,10)!=="_ngcontent"&&X.substring(0,7)!=="_nghost")){var ee=W.value;W.name==="class"&&(ee=dl(ee).join(" ")),S["attr__"+W.name]=Ko(1024,ee)}}));for(var F=1,M=1,Q=k;Q=uE(Q);)F++,Q.tagName===k.tagName&&M++;return S.nth_child=F,S.nth_of_type=M,S})(R,n,o,a));var A=(function(k){if(!Ja(k))return{};var L={};return ae(k.attributes,(function(z){if(z.name&&z.name.indexOf("data-ph-capture-attribute")===0){var j=z.name.replace("data-ph-capture-attribute-",""),V=z.value;j&&V&&ki(V)&&(L[j]=V)}})),L})(R);fe(v,A)})),m)return{props:{},explicitNoCapture:m};if(o||(g[0].$el_text=s.tagName.toLowerCase()==="a"||s.tagName.toLowerCase()==="button"?zd(s):Oi(s)),p){var b,E;g[0].attr__href=p;var N=(b=Yr(p))==null?void 0:b.host,I=_==null||(E=_.location)==null?void 0:E.host;N&&I&&N!==I&&(h=p)}return{props:fe({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:(f=g,(function(R){return R.map((C=>{var A,k,L="";if(C.tag_name&&(L+=C.tag_name),C.attr_class)for(var z of(C.attr_class.sort(),C.attr_class))L+="."+z.replace(/"/g,"");var j=w({},C.text?{text:C.text}:{},{"nth-child":(A=C.nth_child)!==null&&A!==void 0?A:0,"nth-of-type":(k=C.nth_of_type)!==null&&k!==void 0?k:0},C.href?{href:C.href}:{},C.attr_id?{attr_id:C.attr_id}:{},C.attributes),V={};return $r(j).sort(((S,D)=>{var[F]=S,[M]=D;return F.localeCompare(M)})).forEach((S=>{var[D,F]=S;return V[Wd(D.toString())]=Wd(F.toString())})),(L+=":")+$r(V).map((S=>{var[D,F]=S;return D+'="'+F+'"'})).join("")})).join(";")})((function(R){return R.map((C=>{var A,k,L={text:(A=C.$el_text)==null?void 0:A.slice(0,400),tag_name:C.tag_name,href:(k=C.attr__href)==null?void 0:k.slice(0,2048),attr_class:cE(C),attr_id:C.attr__id,nth_child:C.nth_child,nth_of_type:C.nth_of_type,attributes:{}};return $r(C).filter((z=>{var[j]=z;return j.indexOf("attr__")===0})).forEach((z=>{var[j,V]=z;return L.attributes[j]=V})),L}))})(f)))},(t=g[0])!=null&&t.$el_text?{$el_text:(i=g[0])==null?void 0:i.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},v)}}function Kd(s,e,t){try{if(!(e in s))return()=>{};var i=s[e],r=t(i);return yt(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),s[e]=r,()=>{s[e]=i}}catch{return()=>{}}}function Xd(s){return _e(s)&&"clientX"in s&&"clientY"in s&&lt(s.clientX)&&lt(s.clientY)}function Ss(s,e,t){if(H(s))return!1;switch(t){case"exact":return s===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(s);case"regex":try{return new RegExp(e).test(s)}catch{return!1}default:return!1}}var _,me,Be,T,ke,ea,ta,ad,eb,$e,$,ld,Ue,tb,sb,ud,cn,sa,hh,gh,un,Y,yt,_e,Ts,P,ve,Lr,St,H,lt,ks,bt,ib,rb,nb,Do,ob,ia,Tr,dd,xo,Ve,Ur,Et,Ps,ph,vh,_h,mh,mi,Ns,yh,bh,Eh,Zt,ab,Sh,il,kh,rl,lb,nl,wh,Os,Ah,wi,Ai,Cs,Th,Ih,hi,ra,hd,na,Rh,cb,Oh,oa,Oe,Lo,ub,db,hb,ol,gb,Ch,fb,pb,gd,fd,vb,aa,Ds,Ph,mb,yb,bb,Eb,Sb,kb,wb,pd,ca,ua,da,Ab,ha,Tb,ga,fa,pa,va,Dh,O,he,Ib,vd,xh,Br,gi,fi,_d,_a,md,ma,yd,bd,Lh,Ed,Sd,Ir,Vr,$h,Is,pi,ya,vi,Xt,ba,yi,Ea,Sa,Gr,Xe,ka,wa,Aa,Ta,Hr,jr,Fh,Rr,Rb,al,mt,et,bs,Es,Ia,zr,Wr,ws,$o,Fo,kd,fe,wd,Ob,ll,Cb,Ra,Oa,Ad,Uh,Ca,Lt,Nb,ii,Db,ot,Mo,de,xb,Cr,Lb,Kt,we,Pa,Pr,$b,Fb,qr,Uo,Bh,Na,Kr,Yr,Jr,Ti,Qr,Nr,xs,Mb,Ii,Ub,Xr,Vb,bi,ri,Bo,_i,Vo,Da,Gb,Id,Rd,xa,ni,Zr,nt,We,Ce,Ls,cl,ul,Od,Yh,Jh,La,Yt,$a,en,re,Ei,es,tn,Hb,jb,Qh,Xh,_t,oi,Go,Fa,Cd,ai,Ma,Pd,zb,Wb,Ho,Kb,Zh,sn,Rs,jo,Yb,Fr,Ua,Ba,Jb,Va,Ga,Qb,rn,Ri,zo,nn,eg,on,tg,Dr,Ha,Dd,ja,ie,za,Xb,xd,Zb,eE,tE,sE,Wa,Si,Wo,qa,Ld,li,$d,ig,As,rg,Fd,iE,Md,Ka,$s,hl,rE,Hd,Ya,jd,ug,nE,oE,dg,aE,lE,ln,qo,qd,ci,hE,Pt,Yd,Jd,Qd,ui,xr,Qa,Nt,gE,Zd,Yo,fE,Dt,eh,Xa,Za,el,Jo,th,pE,sh,ih,Re,Jt,Qo,Xo,xt,rh,di,nh,oh,ah,Zo,lh,vE,tl,ze,Qt,hn,_E,mE,yE,bE,EE,SE,kE,wE,AE,TE,IE,RE,ch,kt,gg=Pe(()=>{"use strict";_=typeof window<"u"?window:void 0,me=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(me.self=me),typeof File>"u"&&(me.File=function(){});Be=me?.navigator,T=me?.document,ke=me?.location,ea=me?.fetch,ta=me!=null&&me.XMLHttpRequest&&"withCredentials"in new me.XMLHttpRequest?me.XMLHttpRequest:void 0,ad=me?.AbortController,eb=me?.CompressionStream,$e=Be?.userAgent,$=_??{},ld="1.364.1",Ue={DEBUG:!1,LIB_VERSION:ld,LIB_NAME:"web",JS_SDK_VERSION:ld};tb=["$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"],sb=["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"],ud=function(s,e){if(e===void 0&&(e=[]),!s)return!1;var t=s.toLowerCase();return sb.concat(e).some((i=>{var r=i.toLowerCase();return t.indexOf(r)!==-1}))};cn=function(s){return s.trim()},sa=function(s){return s.replace(/^\$/,"")},hh=Object.prototype,gh=hh.hasOwnProperty,un=hh.toString,Y=Array.isArray||function(s){return un.call(s)==="[object Array]"},yt=s=>typeof s=="function",_e=s=>s===Object(s)&&!Y(s),Ts=s=>{if(_e(s)){for(var e in s)if(gh.call(s,e))return!1;return!0}return!1},P=s=>s===void 0,ve=s=>un.call(s)=="[object String]",Lr=s=>ve(s)&&s.trim().length===0,St=s=>s===null,H=s=>P(s)||St(s),lt=s=>un.call(s)=="[object Number]"&&s==s,ks=s=>lt(s)&&s>0,bt=s=>un.call(s)==="[object Boolean]",ib=s=>s instanceof FormData,rb=s=>G(tb,s);nb=[!0,"true",1,"1","yes"],Do=s=>G(nb,s),ob=[!1,"false",0,"0","no"];ia=class{constructor(e){this.t={},this.i=e.i,this.o=at(e.bucketSize,0,100,e.h),this.m=at(e.refillRate,0,this.o,e.h),this.S=at(e.refillInterval,0,864e5,e.h)}T(e,t){var i=Math.floor((t-e.lastAccess)/this.S);i>0&&(e.tokens=Math.min(e.tokens+i*this.m,this.o),e.lastAccess=e.lastAccess+i*this.S)}consumeRateLimit(e){var t,i=Date.now(),r=String(e),n=this.t[r];return n?this.T(n,i):this.t[r]=n={tokens:this.o,lastAccess:i},n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.i)==null||t.call(this,e)),n.tokens===0)}stop(){this.t={}}},Ve="Mobile",Ur="iOS",Et="Android",Ps="Tablet",ph=Et+" "+Ps,vh="iPad",_h="Apple",mh=_h+" Watch",mi="Safari",Ns="BlackBerry",yh="Samsung",bh=yh+"Browser",Eh=yh+" Internet",Zt="Chrome",ab=Zt+" OS",Sh=Zt+" "+Ur,il="Internet Explorer",kh=il+" "+Ve,rl="Opera",lb=rl+" Mini",nl="Edge",wh="Microsoft "+nl,Os="Firefox",Ah=Os+" "+Ur,wi="Nintendo",Ai="PlayStation",Cs="Xbox",Th=Et+" "+Ve,Ih=Ve+" "+mi,hi="Windows",ra=hi+" Phone",hd="Nokia",na="Ouya",Rh="Generic",cb=Rh+" "+Ve.toLowerCase(),Oh=Rh+" "+Ps.toLowerCase(),oa="Konqueror",Oe="(\\d+(\\.\\d+)?)",Lo=new RegExp("Version/"+Oe),ub=new RegExp(Cs,"i"),db=new RegExp(Ai+" \\w+","i"),hb=new RegExp(wi+" \\w+","i"),ol=new RegExp(Ns+"|PlayBook|BB10","i"),gb={"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"},Ch=function(s,e){return e=e||"",G(s," OPR/")&&G(s,"Mini")?lb:G(s," OPR/")?rl:ol.test(s)?Ns:G(s,"IE"+Ve)||G(s,"WPDesktop")?kh:G(s,bh)?Eh:G(s,nl)||G(s,"Edg/")?wh:G(s,"FBIOS")?"Facebook "+Ve:G(s,"UCWEB")||G(s,"UCBrowser")?"UC Browser":G(s,"CriOS")?Sh:G(s,"CrMo")||G(s,Zt)?Zt:G(s,Et)&&G(s,mi)?Th:G(s,"FxiOS")?Ah:G(s.toLowerCase(),oa.toLowerCase())?oa:((t,i)=>i&&G(i,_h)||(function(r){return G(r,mi)&&!G(r,Zt)&&!G(r,Et)})(t))(s,e)?G(s,Ve)?Ih:mi:G(s,Os)?Os:G(s,"MSIE")||G(s,"Trident/")?il:G(s,"Gecko")?Os:""},fb={[kh]:[new RegExp("rv:"+Oe)],[wh]:[new RegExp(nl+"?\\/"+Oe)],[Zt]:[new RegExp("("+Zt+"|CrMo)\\/"+Oe)],[Sh]:[new RegExp("CriOS\\/"+Oe)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Oe)],[mi]:[Lo],[Ih]:[Lo],[rl]:[new RegExp("(Opera|OPR)\\/"+Oe)],[Os]:[new RegExp(Os+"\\/"+Oe)],[Ah]:[new RegExp("FxiOS\\/"+Oe)],[oa]:[new RegExp("Konqueror[:/]?"+Oe,"i")],[Ns]:[new RegExp(Ns+" "+Oe),Lo],[Th]:[new RegExp("android\\s"+Oe,"i")],[Eh]:[new RegExp(bh+"\\/"+Oe)],[il]:[new RegExp("(rv:|MSIE )"+Oe)],Mozilla:[new RegExp("rv:"+Oe)]},pb=function(s,e){var t=Ch(s,e),i=fb[t];if(P(i))return null;for(var r=0;i.length>r;r++){var n=s.match(i[r]);if(n)return parseFloat(n[n.length-2])}return null},gd=[[new RegExp(Cs+"; "+Cs+" (.*?)[);]","i"),s=>[Cs,s&&s[1]||""]],[new RegExp(wi,"i"),[wi,""]],[new RegExp(Ai,"i"),[Ai,""]],[ol,[Ns,""]],[new RegExp(hi,"i"),(s,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[ra,""];if(new RegExp(Ve).test(e)&&!/IEMobile\b/.test(e))return[hi+" "+Ve,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var i=gb[t[1]]||"";return/arm/i.test(e)&&(i="RT"),[hi,i]}return[hi,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,s=>s&&s[3]?[Ur,[s[3],s[4],s[5]||"0"].join(".")]:[Ur,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,s=>{var e="";return s&&s.length>=3&&(e=P(s[2])?s[3]:s[2]),["watchOS",e]}],[new RegExp("("+Et+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Et+")","i"),s=>s&&s[2]?[Et,[s[2],s[3],s[4]||"0"].join(".")]:[Et,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,s=>{var e=["Mac OS X",""];return s&&s[1]&&(e[1]=[s[1],s[2],s[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ab,""]],[/Linux|debian/i,["Linux",""]]],fd=function(s){return hb.test(s)?wi:db.test(s)?Ai:ub.test(s)?Cs:new RegExp(na,"i").test(s)?na:new RegExp("("+ra+"|WPDesktop)","i").test(s)?ra:/iPad/.test(s)?vh:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?mh:ol.test(s)?Ns:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(hd,"i").test(s)?hd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":/(Android|ZTE)/i.test(s)?new RegExp(Ve).test(s)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)||/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?Et:ph:new RegExp("(pda|"+Ve+")","i").test(s)?cb:new RegExp(Ps,"i").test(s)&&!new RegExp(Ps+" pc","i").test(s)?Oh:""},vb=s=>s instanceof Error;aa=class{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,i),$exception_level:"error"}}modifyFrames(e){var t=this;return Ze((function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&Y(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),w({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map((i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Ze((function*(){var i=e;for(var r of t.modifiers)i=yield r(i);return i}))()}convertToExceptionList(e,t){var i,r,n,o={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(r=t.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,w({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:_b(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,i){i===void 0&&(i=0);var r=(n,o)=>{if(4>=o){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(n,a)}};return w({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:n=>r(n,i),next:n=>r(n,i+1)})}},Ds="?";Ph=(s,e)=>{var t=s.indexOf("safari-extension")!==-1,i=s.indexOf("safari-web-extension")!==-1;return t||i?[s.indexOf("@")!==-1?s.split("@")[0]:Ds,t?"safari-extension:"+e:"safari-web-extension:"+e]:[s,e]},mb=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,yb=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,bb=/\((\S*)(?::(\d+))(?::(\d+))\)/,Eb=(s,e)=>{var t=mb.exec(s);if(t){var[,i,r,n]=t;return la(e,i,Ds,+r,+n)}var o=yb.exec(s);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=bb.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=Ph(o[1]||Ds,o[2]);return la(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Sb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,kb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,wb=(s,e)=>{var t=Sb.exec(s);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=kb.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var r=t[3],n=t[1]||Ds;return[n,r]=Ph(n,r),la(e,r,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},pd=/\(error: (.*)\)/,ca=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=ve(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Mr(e,"DOMException")}isDOMError(e){return Mr(e,"DOMError")}},ua=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&typeof i.error.message=="string"?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}},da=class{constructor(){}match(e){return Mr(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},Ab=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ha=class{match(e){return typeof e=="string"}coerce(e,t){var i,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(Ab);return r&&(t=r[1],i=r[2]),[t,i]}},Tb=["fatal","error","warning","log","info","debug"];ga=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(i=t.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return sl(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var i=this.getObjectClassName(e);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+Nh(e)}isSeverityLevel(e){return ve(e)&&!Lr(e)&&Tb.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(vb(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},fa=class{match(e){return sl(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Nh(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},pa=class{match(e){return fh(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},va=class{match(e){return Mr(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!sl(e))return!1;try{var t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return fh(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.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}},Dh=function(s,e){var{debugEnabled:t}=e===void 0?{}:e,i={$(r){if(_&&(Ue.DEBUG||$.POSTHOG_DEBUG||t)&&!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(s,...a)}},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.$("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.$("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.$("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(s,...n)},uninitializedWarning(r){i.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Dh(s+" "+r,n)};return i},O=Dh("[PostHog.js]"),he=O.createLogger,Ib=he("[ExternalScriptsLoader]"),vd=(s,e,t)=>{if(s.config.disable_external_dependency_loading)return Ib.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var i=T?.querySelectorAll("script");if(i){for(var r,n=function(){if(i[o].src===e){var l=i[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)})),l.onerror=c=>t(c),{v:void 0})}},o=0;i.length>o;o++)if(r=n())return r.v}var a=()=>{if(!T)return t("document not found");var l=T.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,t(void 0,h)},l.onerror=h=>t(h),s.config.prepare_external_dependency_script&&(l=s.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(s.config.external_scripts_inject_target==="head")T.head.appendChild(l);else{var c,d=T.querySelectorAll("body > script");d.length>0?(c=d[0].parentNode)==null||c.insertBefore(l,d[0]):T.body.appendChild(l)}};T!=null&&T.body?a():T?.addEventListener("DOMContentLoaded",a)};$.__PosthogExtensions__=$.__PosthogExtensions__||{},$.__PosthogExtensions__.loadExternalDependency=(s,e,t)=>{var i="/static/"+e+".js?v="+s.version;if(e==="remote-config"&&(i="/array/"+s.config.token+"/config.js"),e==="toolbar"){var r=3e5;i=i+"&t="+Math.floor(Date.now()/r)*r}var n=s.requestRouter.endpointFor("assets",i);vd(s,n,t)},$.__PosthogExtensions__.loadSiteApp=(s,e,t)=>{var i=s.requestRouter.endpointFor("api",e);vd(s,i,t)};xh="$people_distinct_id",Br="$device_id",gi="__alias",fi="__timers",_d="$autocapture_disabled_server_side",_a="$heatmaps_enabled_server_side",md="$exception_capture_enabled_server_side",ma="$error_tracking_suppression_rules",yd="$error_tracking_capture_extension_exceptions",bd="$web_vitals_enabled_server_side",Lh="$dead_clicks_enabled_server_side",Ed="$product_tours_enabled_server_side",Sd="$web_vitals_allowed_metrics",Ir="$session_recording_remote_config",Vr="$sesid",$h="$session_is_sampled",Is="$enabled_feature_flags",pi="$early_access_features",ya="$feature_flag_details",vi="$stored_person_properties",Xt="$stored_group_properties",ba="$surveys",yi="$flag_call_reported",Ea="$flag_call_reported_session_id",Sa="$feature_flag_errors",Gr="$feature_flag_evaluated_at",Xe="$user_state",ka="$client_session_props",wa="$capture_rate_limit",Aa="$initial_campaign_params",Ta="$initial_referrer_info",Hr="$initial_person_info",jr="$epp",Fh="__POSTHOG_TOOLBAR__",Rr="$posthog_cookieless",Rb=[xh,gi,"__cmpns",fi,"$session_recording_enabled_server_side",_a,Vr,Is,ma,Xe,pi,ya,Xt,vi,ba,yi,Ea,Sa,Gr,ka,wa,Aa,Ta,jr,Hr],al="PostHog loadExternalDependency extension not found.",mt="on_reject",et="always",bs="anonymous",Es="identified",Ia="identified_only",zr="visibilitychange",Wr="beforeunload",ws="$pageview",$o="$pageleave",Fo="$identify",kd="$groupidentify";fe=function(s){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;e>i;i++)t[i-1]=arguments[i];for(var r of t)for(var n in r)r[n]!==void 0&&(s[n]=r[n]);return s};wd=function(s){try{return s()}catch{return}},Ob=function(s){return function(){try{for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return s.apply(this,t)}catch(r){O.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),O.critical(r)}}},ll=function(s){var e={};return ae(s,(function(t,i){(ve(t)&&t.length>0||lt(t))&&(e[i]=t)})),e},Cb=["herokuapp.com","vercel.app","netlify.app"];Math.trunc||(Math.trunc=function(s){return 0>s?Math.ceil(s):Math.floor(s)}),Number.isInteger||(Number.isInteger=function(s){return lt(s)&&isFinite(s)&&Math.floor(s)===s});Ra=class s{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>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|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new s(n)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new s(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(i!==0)return Math.sign(i)}return 0}},Oa=class{constructor(){this.k=0,this.R=0,this.P=new Ca}generate(){var e=this.generateOrAbort();if(P(e)){this.k=0;var t=this.generateOrAbort();if(P(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.k)this.k=e,this.O();else{if(this.k>=e+1e4)return;this.R++,this.R>4398046511103&&(this.k++,this.O())}return Ra.fromFieldsV7(this.k,Math.trunc(this.R/Math.pow(2,30)),this.R&Math.pow(2,30)-1,this.P.nextUint32())}O(){this.R=1024*this.P.nextUint32()+(1023&this.P.nextUint32())}},Uh=s=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;s.length>e;e++)s[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return s};_&&!P(_.crypto)&&crypto.getRandomValues&&(Uh=s=>crypto.getRandomValues(s));Ca=class{constructor(){this.I=new Uint32Array(8),this.C=1/0}nextUint32(){return this.I.length>this.C||(Uh(this.I),this.C=0),this.I[this.C++]}},Lt=()=>Nb().toString(),Nb=()=>(Ad||(Ad=new Oa)).generate(),ii="",Db=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ot={F:()=>!!T,A(s){O.error("cookieStore error: "+s)},M(s){if(T){try{for(var e=s+"=",t=T.cookie.split(";").filter((n=>n.length)),i=0;t.length>i;i++){for(var r=t[i];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}},D(s){var e;try{e=JSON.parse(ot.M(s))||{}}catch{}return e},L(s,e,t,i,r){if(T)try{var n="",o="",a=(function(d,h){if(h){var f=(function(v,p){if(p===void 0&&(p=T),ii)return ii;if(!p||["localhost","127.0.0.1"].includes(v))return"";for(var m=v.split("."),b=Math.min(m.length,8),E="dmn_chk_"+Lt();!ii&&b--;){var N=m.slice(b).join("."),I=E+"=1;domain=."+N+";path=/";p.cookie=I+";max-age=3",p.cookie.includes(E)&&(p.cookie=I+";max-age=0",ii=N)}return ii})(d);if(!f){var g=(v=>{var p=v.match(Db);return p?p[0]:""})(d);g!==f&&O.info("Warning: cookie subdomain discovery mismatch",g,f),f=g}return f?"; domain=."+f:""}return""})(T.location.hostname,i);if(t){var l=new Date;l.setTime(l.getTime()+864e5*t),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=s+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&O.warn("cookieStore warning: large cookie, len="+c.length),T.cookie=c,c}catch{return}},U(s,e){if(T!=null&&T.cookie)try{ot.L(s,"",-1,e)}catch{return}}},Mo=null,de={F(){if(!St(Mo))return Mo;var s=!0;if(P(_))s=!1;else try{var e="__mplssupport__";de.L(e,"xyz"),de.M(e)!=='"xyz"'&&(s=!1),de.U(e)}catch{s=!1}return s||O.error("localStorage unsupported; falling back to cookie store"),Mo=s,s},A(s){O.error("localStorage error: "+s)},M(s){try{return _?.localStorage.getItem(s)}catch(e){de.A(e)}return null},D(s){try{return JSON.parse(de.M(s))||{}}catch{}return null},L(s,e){try{_?.localStorage.setItem(s,JSON.stringify(e))}catch(t){de.A(t)}},U(s){try{_?.localStorage.removeItem(s)}catch(e){de.A(e)}}},xb=[Br,"distinct_id",Vr,$h,jr,Hr,Xe],Cr={},Lb={F:()=>!0,A(s){O.error("memoryStorage error: "+s)},M:s=>Cr[s]||null,D:s=>Cr[s]||null,L(s,e){Cr[s]=e},U(s){delete Cr[s]}},Kt=null,we={F(){if(!St(Kt))return Kt;if(Kt=!0,P(_))Kt=!1;else try{var s="__support__";we.L(s,"xyz"),we.M(s)!=='"xyz"'&&(Kt=!1),we.U(s)}catch{Kt=!1}return Kt},A(s){O.error("sessionStorage error: ",s)},M(s){try{return _?.sessionStorage.getItem(s)}catch(e){we.A(e)}return null},D(s){try{return JSON.parse(we.M(s))||null}catch{}return null},L(s,e){try{_?.sessionStorage.setItem(s,JSON.stringify(e))}catch(t){we.A(t)}},U(s){try{_?.sessionStorage.removeItem(s)}catch(e){we.A(e)}}},Pa=class{constructor(e){this._instance=e}get N(){return this._instance.config}get consent(){return this.j()?0:this.B}isOptedOut(){return this.N.cookieless_mode===et||this.consent===0||this.consent===-1&&(this.N.opt_out_capturing_by_default||this.N.cookieless_mode===mt)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}optInOut(e){this.H.L(this.q,e?1:0,this.N.cookie_expiration,this.N.cross_subdomain_cookie,this.N.secure_cookie)}reset(){this.H.U(this.q,this.N.cross_subdomain_cookie)}get q(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get B(){var e=this.H.M(this.q);return Do(e)?1:G(ob,e)?0:-1}get H(){if(!this.W){var e=this.N.opt_out_capturing_persistence_type;this.W=e==="localStorage"?de:ot;var t=e==="localStorage"?ot:de;t.M(this.q)&&(this.W.M(this.q)||this.optInOut(Do(t.M(this.q))),t.U(this.q,this.N.cross_subdomain_cookie))}return this.W}j(){return!!this.N.respect_dnt&&[Be?.doNotTrack,Be?.msDoNotTrack,$.doNotTrack].some((e=>Do(e)))}},Pr=he("[Dead Clicks]"),$b=()=>!0,Fb=s=>{var e,t=!((e=s.instance.persistence)==null||!e.get_property(Lh)),i=s.instance.config.capture_dead_clicks;return bt(i)?i:!!_e(i)||t},qr=class{get lazyLoadedDeadClicksAutocapture(){return this.V}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Lh]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Y((()=>{this.G()})):this.stop()}Y(e){var t,i;(t=$.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(i=$.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Pr.error("failed to load script",r):e()}))}G(){var e;if(T){if(!this.V&&(e=$.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=_e(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.V=$.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.V.start(T),Pr.info("starting...")}}else Pr.error("`document` not found. Cannot start.")}stop(){this.V&&(this.V.stop(),this.V=void 0,Pr.info("stopping..."))}},Uo=he("[SegmentIntegration]"),Bh="posthog-js";Na=class{constructor(e,t,i,r,n,o){this.name=Bh,this.setupOnce=function(a){a(Vh(e,{organization:t,projectId:i,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},Kr=class{constructor(e){this.J=(t,i,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(O.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.K=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.X()}X(){var e;this.Z=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.J)}destroy(){var e;(e=this.Z)==null||e.call(this),this.Z=void 0}doPageView(e,t){var i,r=this.tt(e,t);return this.K={pathname:(i=_?.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.tt(e,(t=this.K)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.K)==null?void 0:e.pageViewId}}tt(e,t){var i=this.K;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:d,maxContentY:h}=n;if(!(P(o)||P(a)||P(l)||P(c)||P(d)||P(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),d=Math.ceil(d),h=Math.ceil(h);var f=o>1?at(a/o,0,1,O):1,g=o>1?at(l/o,0,1,O):1,v=c>1?at(d/c,0,1,O):1,p=c>1?at(h/c,0,1,O):1;r=fe(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:d,$prev_pageview_last_content_percentage:v,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}},Yr=s=>{var e=T?.createElement("a");return P(e)?null:(e.href=s,e)},Jr=function(s,e){for(var t,i=((s.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;i.length>r;r++){var n=i[r].split("=");if(n[0]===e){t=n;break}}if(!Y(t)||2>t.length)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{O.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ti=function(s,e,t){if(!s||!e||!e.length)return s;for(var i=s.split("#"),r=i[1],n=(i[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),c=[],d=0;l.length>d;d++){var h=l[d].split("=");Y(h)&&(e.includes(h[0])?c.push(h[0]+"="+t):c.push(l[d]))}var f=a;return o!=null&&(f+="?"+c.join("&")),r!=null&&(f+="#"+r),f},Qr=function(s,e){var t=s.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Nr="https?://(.*)",xs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Mb=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...xs],Ii="<masked>",Ub=["li_fat_id"];Xr="$direct";Vb=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],bi=class{constructor(e,t){this.N=e,this.props={},this.it=!1,this.et=(i=>{var r="";return i.token&&(r=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+r+"_posthog"})(e),this.H=this.rt(e),this.load(),e.debug&&O.info("Persistence loaded",e.persistence,w({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.st}rt(e){Vb.indexOf(e.persistence.toLowerCase())===-1&&(O.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(r){r===void 0&&(r=[]);var n=[...xb,...r];return w({},de,{D(o){try{var a={};try{a=ot.D(o)||{}}catch{}var l=fe(a,JSON.parse(de.M(o)||"{}"));return de.L(o,l),l}catch{}return null},L(o,a,l,c,d,h){try{de.L(o,a,void 0,void 0,h);var f={};n.forEach((g=>{a[g]&&(f[g]=a[g])})),Object.keys(f).length&&ot.L(o,f,l,c,d,h)}catch(g){de.A(g)}},U(o,a){try{_?.localStorage.removeItem(o),ot.U(o,a)}catch(l){de.A(l)}}})})(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return i==="localstorage"&&de.F()?de:i==="localstorage+cookie"&&t.F()?t:i==="sessionstorage"&&we.F()?we:i==="memory"?Lb:i==="cookie"?ot:t.F()?t:ot}nt(e){var t=e??this.N.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[Gr];return!i||typeof i!="number"||Date.now()-i>t}properties(){var e={};return ae(this.props,((t,i)=>{if(i===Is&&_e(t)){if(!this.nt())for(var r=Object.keys(t),n=0;r.length>n;n++)e["$feature/"+r[n]]=t[r[n]]}else Rb.indexOf(i)===-1&&(e[i]=t)})),e}load(){if(!this.st){var e=this.H.D(this.et);e&&(this.props=fe({},e))}}save(){this.st||this.H.L(this.et,this.props,this.ot,this.ut,this.ht,this.N.debug)}remove(){this.H.U(this.et,!1),this.H.U(this.et,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(_e(e)){P(t)&&(t="None"),this.ot=P(i)?this.dt:i;var r=!1;if(ae(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=n,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(_e(e)){this.ot=P(t)?this.dt:t;var i=!1;if(ae(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.props[n]=r,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.it){var e=Gh(this.N.custom_campaign_params,this.N.mask_personal_data_properties,this.N.custom_personal_data_properties);Ts(ll(e))||this.register(e),this.it=!0}}update_search_keyword(){var e;this.register((e=T?.referrer)?jh(e):{})}update_referrer_info(){var e;this.register_once({$referrer:zh(),$referring_domain:T!=null&&T.referrer&&((e=Yr(T.referrer))==null?void 0:e.host)||Xr},void 0)}set_initial_person_info(){this.props[Aa]||this.props[Ta]||this.register_once({[Hr]:Wh(this.N.mask_personal_data_properties,this.N.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};ae([Ta,Aa],(o=>{var a=this.props[o];a&&ae(a,(function(l,c){e["$initial_"+sa(c)]=l}))}));var t,i,r=this.props[Hr];if(r){var n=(t=qh(r),i={},ae(t,(function(o,a){i["$initial_"+sa(a)]=o})),i);fe(e,n)}return e}safe_merge(e){return ae(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this.dt=this.ot=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((d,h)=>d===c[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.rt(e),n=this.props;this.clear(),this.H=r,this.props=n,this.save()}}set_disabled(e){this.st=e,this.st?this.remove():this.save()}set_cross_subdomain(e){e!==this.ut&&(this.ut=e,this.remove(),this.save())}set_secure(e){e!==this.ht&&(this.ht=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[fi]||{};i[e]=t,this.props[fi]=i,this.save()}remove_event_timer(e){var t=(this.props[fi]||{})[e];return P(t)||(delete this.props[fi][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},ri={Activation:"events",Cancellation:"cancelEvents"},Bo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},_i={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Vo={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"},Da={Popover:"popover",Inline:"inline"},Gb={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"},Id={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"},Rd=he("[RateLimiter]"),xa=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((r=>{Rd.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void Rd.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:i})}},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 t,i,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(wa))!==null&&t!==void 0?t:{tokens:n,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>n&&(l.tokens=n);var c=1>l.tokens;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||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=c,(r=this.instance.persistence)==null||r.set_property(wa,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ni=he("[RemoteConfig]"),Zr=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=$._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}vt(e){var t,i;(t=$.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=$.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}ct(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return ni.info("Using preloaded remote config",this.remoteConfig),this.ft(this.remoteConfig),void this._t();if(this._instance.bt())return void ni.warn("Remote config is disabled. Falling back to local config.");this.vt((e=>{if(!e)return ni.info("No config found after loading remote JS config. Falling back to JSON."),void this.ct((t=>{this.ft(t),this._t()}));this.ft(e),this._t()}))}catch(e){ni.error("Error loading remote config",e)}}stop(){this.yt&&(clearInterval(this.yt),this.yt=void 0)}refresh(){this._instance.bt()||T?.visibilityState==="hidden"||this._instance.reloadFeatureFlags()}_t(){var e;if(!this.yt){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.yt=setInterval((()=>{this.refresh()}),t))}}ft(e){var t;e||ni.error("Failed to fetch remote config from PostHog."),this._instance.ft(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},nt={GZipJS:"gzip-js",Base64:"base64"},We=Uint8Array,Ce=Uint16Array,Ls=Uint32Array,cl=new We([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]),ul=new We([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]),Od=new We([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yh=function(s,e){for(var t=new Ce(31),i=0;31>i;++i)t[i]=e+=1<<s[i-1];var r=new Ls(t[30]);for(i=1;30>i;++i)for(var n=t[i];t[i+1]>n;++n)r[n]=n-t[i]<<5|i;return[t,r]},Jh=Yh(cl,2),La=Jh[1];Jh[0][28]=258,La[258]=28;for($a=Yh(ul,0)[1],en=new Ce(32768),re=0;32768>re;++re)Yt=(43690&re)>>>1|(21845&re)<<1,en[re]=((65280&(Yt=(61680&(Yt=(52428&Yt)>>>2|(13107&Yt)<<2))>>>4|(3855&Yt)<<4))>>>8|(255&Yt)<<8)>>>1;Ei=function(s,e,t){for(var i=s.length,r=0,n=new Ce(e);i>r;++r)++n[s[r]-1];var o,a=new Ce(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(t){o=new Ce(1<<e);var l=15-e;for(r=0;i>r;++r)if(s[r])for(var c=r<<4|s[r],d=e-s[r],h=a[s[r]-1]++<<d,f=h|(1<<d)-1;f>=h;++h)o[en[h]>>>l]=c}else for(o=new Ce(i),r=0;i>r;++r)o[r]=en[a[s[r]-1]++]>>>15-s[r];return o},es=new We(288);for(re=0;144>re;++re)es[re]=8;for(re=144;256>re;++re)es[re]=9;for(re=256;280>re;++re)es[re]=7;for(re=280;288>re;++re)es[re]=8;tn=new We(32);for(re=0;32>re;++re)tn[re]=5;Hb=Ei(es,9,0),jb=Ei(tn,5,0),Qh=function(s){return(s/8>>0)+(7&s&&1)},Xh=function(s,e,t){(t==null||t>s.length)&&(t=s.length);var i=new(s instanceof Ce?Ce:s instanceof Ls?Ls:We)(t-e);return i.set(s.subarray(e,t)),i},_t=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8},oi=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8,s[i+2]|=t>>>16},Go=function(s,e){for(var t=[],i=0;s.length>i;++i)s[i]&&t.push({s:i,f:s[i]});var r=t.length,n=t.slice();if(!r)return[new We(0),0];if(r==1){var o=new We(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(R,C){return R.f-C.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,d=1,h=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};d!=r-1;)a=t[t[h].f>t[c].f?c++:h++],l=t[c!=d&&t[h].f>t[c].f?c++:h++],t[d++]={s:-1,f:a.f+l.f,l:a,r:l};var f=n[0].s;for(i=1;r>i;++i)n[i].s>f&&(f=n[i].s);var g=new Ce(f+1),v=Fa(t[d-1],g,0);if(v>e){i=0;var p=0,m=v-e,b=1<<m;for(n.sort((function(R,C){return g[C.s]-g[R.s]||R.f-C.f}));r>i;++i){var E=n[i].s;if(e>=g[E])break;p+=b-(1<<v-g[E]),g[E]=e}for(p>>>=m;p>0;){var N=n[i].s;e>g[N]?p-=1<<e-g[N]++-1:++i}for(;i>=0&&p;--i){var I=n[i].s;g[I]==e&&(--g[I],++p)}v=e}return[new We(g),v]},Fa=function(s,e,t){return s.s==-1?Math.max(Fa(s.l,e,t+1),Fa(s.r,e,t+1)):e[s.s]=t},Cd=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new Ce(++e),i=0,r=s[0],n=1,o=function(l){t[i++]=l},a=1;e>=a;++a)if(s[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=s[a]}return[t.subarray(0,i),e]},ai=function(s,e){for(var t=0,i=0;e.length>i;++i)t+=s[i]*e[i];return t},Ma=function(s,e,t){var i=t.length,r=Qh(e+2);s[r]=255&i,s[r+1]=i>>>8,s[r+2]=255^s[r],s[r+3]=255^s[r+1];for(var n=0;i>n;++n)s[r+n+4]=t[n];return 8*(r+4+i)},Pd=function(s,e,t,i,r,n,o,a,l,c,d){_t(e,d++,t),++r[256];for(var h=Go(r,15),f=h[0],g=h[1],v=Go(n,15),p=v[0],m=v[1],b=Cd(f),E=b[0],N=b[1],I=Cd(p),R=I[0],C=I[1],A=new Ce(19),k=0;E.length>k;++k)A[31&E[k]]++;for(k=0;R.length>k;++k)A[31&R[k]]++;for(var L=Go(A,7),z=L[0],j=L[1],V=19;V>4&&!z[Od[V-1]];--V);var S,D,F,M,Q=c+5<<3,W=ai(r,es)+ai(n,tn)+o,X=ai(r,f)+ai(n,p)+o+14+3*V+ai(A,z)+(2*A[16]+3*A[17]+7*A[18]);if(W>=Q&&X>=Q)return Ma(e,d,s.subarray(l,l+c));if(_t(e,d,1+(W>X)),d+=2,W>X){S=Ei(f,g,0),D=f,F=Ei(p,m,0),M=p;var ee=Ei(z,j,0);for(_t(e,d,N-257),_t(e,d+5,C-1),_t(e,d+10,V-4),d+=14,k=0;V>k;++k)_t(e,d+3*k,z[Od[k]]);d+=3*V;for(var te=[E,R],ye=0;2>ye;++ye){var U=te[ye];for(k=0;U.length>k;++k)_t(e,d,ee[Ae=31&U[k]]),d+=z[Ae],Ae>15&&(_t(e,d,U[k]>>>5&127),d+=U[k]>>>12)}}else S=Hb,D=es,F=jb,M=tn;for(k=0;a>k;++k)if(i[k]>255){var Ae;oi(e,d,S[257+(Ae=i[k]>>>18&31)]),d+=D[Ae+257],Ae>7&&(_t(e,d,i[k]>>>23&31),d+=cl[Ae]);var qe=31&i[k];oi(e,d,F[qe]),d+=M[qe],qe>3&&(oi(e,d,i[k]>>>5&8191),d+=ul[qe])}else oi(e,d,S[i[k]]),d+=D[i[k]];return oi(e,d,S[256]),d+D[256]},zb=new Ls([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Wb=(function(){for(var s=new Ls(256),e=0;256>e;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;s[e]=t}return s})(),Ho=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8};Kb=!!ta||!!ea,Zh="text/plain",sn=function(s,e,t){var i;t===void 0&&(t=!0);var[r,n]=s.split("?"),o=w({},e),a=(i=n?.split("&").map((c=>{var d,[h,f]=c.split("="),g=t&&(d=o[h])!==null&&d!==void 0?d:f;return delete o[h],h+"="+g})))!==null&&i!==void 0?i:[],l=(function(c,d){var h,f;d===void 0&&(d="&");var g=[];return ae(c,(function(v,p){P(v)||P(p)||p==="undefined"||(h=encodeURIComponent((m=>m instanceof File)(v)?v.name:v.toString()),f=encodeURIComponent(p),g[g.length]=f+"="+h)})),g.join(d)})(o);return l&&a.push(l),r+"?"+a.join("&")},Rs=(s,e)=>JSON.stringify(s,((t,i)=>typeof i=="bigint"?i.toString():i),e),jo=s=>{if(s.wt)return s.wt;var{data:e,compression:t}=s;if(e){if(t===nt.GZipJS){var i=qb((function(a,l){var c=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var d=new We(a.length+(a.length>>>1)),h=0,f=function(m){d[h++]=m},g=0;c>g;++g){if(h+5>d.length){var v=new We(h+8+(c-g<<1));v.set(d),d=v}var p=a.charCodeAt(g);128>p?f(p):2048>p?(f(192|p>>>6),f(128|63&p)):p>55295&&57344>p?(f(240|(p=65536+(1047552&p)|1023&a.charCodeAt(++g))>>>18),f(128|p>>>12&63),f(128|p>>>6&63),f(128|63&p)):(f(224|p>>>12),f(128|p>>>6&63),f(128|63&p))}return Xh(d,0,h)})(Rs(e)),{mtime:0});return{contentType:Zh,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(t===nt.Base64){var r=(function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,((l,c)=>String.fromCharCode(parseInt(c,16)))))})(Rs(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Rs(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Rs(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Yb=(function(){var s=Ze((function*(e){var t=Rs(e.data),i=yield(function(n,o){return dh.apply(this,arguments)})(t,Ue.DEBUG);if(!i)return e;var r=yield i.arrayBuffer();return w({},e,{wt:{contentType:Zh,body:r,estimatedSize:r.byteLength}})}));return function(e){return s.apply(this,arguments)}})(),Fr=[];ea&&Fr.push({transport:"fetch",method(s){var e,t,{contentType:i,body:r,estimatedSize:n}=(e=jo(s))!==null&&e!==void 0?e:{},o=new Headers;ae(s.headers,(function(d,h){o.append(h,d)})),i&&o.append("Content-Type",i);var a=s.url,l=null;if(ad){var c=new ad;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),s.timeout)}}ea(a,w({method:s?.method||"GET",headers:o,keepalive:s.method==="POST"&&52428.8>(n||0),body:r,signal:(t=l)==null?void 0:t.signal},s.fetchOptions)).then((d=>d.text().then((h=>{var f={statusCode:d.status,text:h};if(d.status===200)try{f.json=JSON.parse(h)}catch(g){O.error(g)}s.callback==null||s.callback(f)})))).catch((d=>{O.error(d),s.callback==null||s.callback({statusCode:0,error:d})})).finally((()=>l?clearTimeout(l.timeout):null))}}),ta&&Fr.push({transport:"XHR",method(s){var e,t=new ta;t.open(s.method||"GET",s.url,!0);var{contentType:i,body:r}=(e=jo(s))!==null&&e!==void 0?e:{};ae(s.headers,(function(n,o){t.setRequestHeader(o,n)})),i&&t.setRequestHeader("Content-Type",i),s.timeout&&(t.timeout=s.timeout),s.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}s.callback==null||s.callback(n)}},t.send(r)}}),Be!=null&&Be.sendBeacon&&Fr.push({transport:"sendBeacon",method(s){var e=sn(s.url,{beacon:"1"});try{var t,{contentType:i,body:r}=(t=jo(s))!==null&&t!==void 0?t:{},n=typeof r=="string"?new Blob([r],{type:i}):r;Be.sendBeacon(e,n)}catch{}}});Ua=3e3,Ba=class{constructor(e,t){this.Et=!0,this.St=[],this.xt=at(t?.flush_interval_ms||Ua,250,5e3,O.createLogger("flush interval"),Ua),this.Tt=e}enqueue(e){this.St.push(e),this.$t||this.kt()}unload(){this.Rt();var e=this.St.length>0?this.Pt():{},t=Object.values(e);[...t.filter((i=>i.url.indexOf("/e")===0)),...t.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.Tt(w({},i,{transport:"sendBeacon"}))}))}enable(){this.Et=!1,this.kt()}kt(){var e=this;this.Et||(this.$t=setTimeout((()=>{if(this.Rt(),this.St.length>0){var t=this.Pt(),i=function(){var n=t[r],o=new Date().getTime();n.data&&Y(n.data)&&ae(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Tt(n)};for(var r in t)i()}}),this.xt))}Rt(){clearTimeout(this.$t),this.$t=void 0}Pt(){var e={};return ae(this.St,(t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;P(e[n])&&(e[n]=w({},r,{data:[]})),(i=e[n].data)==null||i.push(r.data)})),this.St=[],e}},Jb=["retriesPerformedSoFar"],Va=class{constructor(e){this.Ot=!1,this.It=3e3,this.St=[],this._instance=e,this.St=[],this.Ct=!0,!P(_)&&"onLine"in _.navigator&&(this.Ct=_.navigator.onLine,this.Ft=()=>{this.Ct=!0,this.At()},this.Mt=()=>{this.Ct=!1},pe(_,"online",this.Ft),pe(_,"offline",this.Mt))}get length(){return this.St.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=uh(e,Jb);ks(t)&&(i.url=sn(i.url,{retry_count:t})),this._instance._send_request(w({},i,{callback:r=>{r.statusCode===200||r.statusCode>=400&&500>r.statusCode||(t??0)>=10?i.callback==null||i.callback(r):this.Dt(w({retriesPerformedSoFar:t},i))}}))}Dt(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),d=Math.random()-.5;return Math.ceil(c+d*(c-l))})(t),r=Date.now()+i;this.St.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+i;navigator.onLine||(n+=" (Browser is offline)"),O.warn(n),this.Ot||(this.Ot=!0,this.Lt())}Lt(){if(this.Ut&&clearTimeout(this.Ut),this.St.length===0)return this.Ot=!1,void(this.Ut=void 0);this.Ut=setTimeout((()=>{this.Ct&&this.St.length>0&&this.At(),this.Lt()}),this.It)}At(){var e=Date.now(),t=[],i=this.St.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.St=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Ut&&(clearTimeout(this.Ut),this.Ut=void 0),this.Ot=!1,P(_)||(this.Ft&&(_.removeEventListener("online",this.Ft),this.Ft=void 0),this.Mt&&(_.removeEventListener("offline",this.Mt),this.Mt=void 0)),this.St))try{this._instance._send_request(w({},e,{transport:"sendBeacon"}))}catch(t){O.error(t)}this.St=[]}},Ga=class{constructor(e){this.Nt=()=>{var t,i,r,n;this.jt||(this.jt={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),d=o?.scrollHeight||0;this.jt.lastScrollY=Math.ceil(a),this.jt.maxScrollY=Math.max(a,(t=this.jt.maxScrollY)!==null&&t!==void 0?t:0),this.jt.maxScrollHeight=Math.max(l,(i=this.jt.maxScrollHeight)!==null&&i!==void 0?i:0),this.jt.lastContentY=c,this.jt.maxContentY=Math.max(c,(r=this.jt.maxContentY)!==null&&r!==void 0?r:0),this.jt.maxContentHeight=Math.max(d,(n=this.jt.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get zt(){return this._instance.config.scroll_root_selector}getContext(){return this.jt}resetContext(){var e=this.jt;return setTimeout(this.Nt,0),e}startMeasuringScrollPosition(){pe(_,"scroll",this.Nt,{capture:!0}),pe(_,"scrollend",this.Nt,{capture:!0}),pe(_,"resize",this.Nt)}scrollElement(){if(!this.zt)return _?.document.documentElement;var e=Y(this.zt)?this.zt:[this.zt];for(var t of e){var i=_?.document.querySelector(t);if(i)return i}}scrollY(){if(this.zt){var e=this.scrollElement();return e&&e.scrollTop||0}return _&&(_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop)||0}scrollX(){if(this.zt){var e=this.scrollElement();return e&&e.scrollLeft||0}return _&&(_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft)||0}},Qb=s=>Wh(s?.config.mask_personal_data_properties,s?.config.custom_personal_data_properties),rn=class{constructor(e,t,i,r){this.Bt=n=>{var o=this.Ht();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.qt(this._instance)};this.Wt.register({[ka]:a})}},this._instance=e,this.Vt=t,this.Wt=i,this.qt=r||Qb,this.Vt.onSessionId(this.Bt)}Ht(){return this.Wt.props[ka]}getSetOnceProps(){var e,t=(e=this.Ht())==null?void 0:e.props;return t?"r"in t?qh(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return ae(ll(this.getSetOnceProps()),((t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+sa(i)]=t})),e}},Ri=class{constructor(){this.Yt={}}on(e,t){return this.Yt[e]||(this.Yt[e]=[]),this.Yt[e].push(t),()=>{this.Yt[e]=this.Yt[e].filter((i=>i!==t))}}emit(e,t){for(var i of this.Yt[e]||[])i(t);for(var r of this.Yt["*"]||[])r(e,t)}},zo=he("[SessionId]"),nn=class{on(e,t){return this.Gt.on(e,t)}constructor(e,t,i){var r;if(this.Jt=[],this.Kt=void 0,this.Gt=new Ri,this.Xt=(c,d)=>!(!ks(c)||!ks(d))&&Math.abs(c-d)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===et)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.N=e.config,this.Wt=e.persistence,this.Qt=void 0,this.Zt=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ti=t||Lt,this.ii=i||Lt;var n=this.N.persistence_name||this.N.token;if(this._sessionTimeoutMs=1e3*at(this.N.session_idle_timeout_seconds||1800,60,36e3,zo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ei(),this.ri="ph_"+n+"_window_id",this.si="ph_"+n+"_primary_window_exists",this.ni()){var o=we.D(this.ri),a=we.D(this.si);o&&!a?this.Qt=o:we.U(this.ri),we.L(this.si,!0)}if((r=this.N.bootstrap)!=null&&r.sessionID)try{var l=(c=>{var d=this.N.bootstrap.sessionID.replace(/-/g,"");if(d.length!==32)throw new Error("Not a valid UUID");if(d[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(d.substring(0,12),16)})();this.oi(this.N.bootstrap.sessionID,new Date().getTime(),l)}catch(c){zo.error("Invalid sessionID in bootstrap",c)}this.ai()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return P(this.Jt)&&(this.Jt=[]),this.Jt.push(e),this.Zt&&e(this.Zt,this.Qt),()=>{this.Jt=this.Jt.filter((t=>t!==e))}}ni(){return this.N.persistence!=="memory"&&!this.Wt.st&&we.F()}li(e){e!==this.Qt&&(this.Qt=e,this.ni()&&we.L(this.ri,e))}ui(){return this.Qt?this.Qt:this.ni()?we.D(this.ri):null}oi(e,t,i){e===this.Zt&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.Zt=e,this.Wt.register({[Vr]:[t,e,i]}))}hi(){var e=this.Wt.props[Vr];return Y(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.oi(null,null,null)}destroy(){clearTimeout(this.di),this.di=void 0,this.Kt&&_&&(_.removeEventListener(Wr,this.Kt,{capture:!1}),this.Kt=void 0),this.Jt=[]}ai(){this.Kt=()=>{this.ni()&&we.U(this.si)},pe(_,Wr,this.Kt,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.N.cookieless_mode===et)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||new Date().getTime(),[r,n,o]=this.hi(),a=this.ui(),l=ks(o)&&Math.abs(i-o)>864e5,c=!1,d=!n,h=!d&&!e&&this.Xt(i,r);d||h||l?(n=this.ti(),a=this.ii(),zo.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}}),o=i,c=!0):a||(a=this.ii(),c=!0);var f=ks(r)&&e&&!l?r:i,g=ks(o)?o:new Date().getTime();return this.li(a),this.oi(n,f,g),e||this.ei(),c&&this.Jt.forEach((v=>v(n,a,c?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:g,changeReason:c?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}ei(){clearTimeout(this.di),this.di=setTimeout((()=>{var[e]=this.hi();if(this.Xt(new Date().getTime(),e)){var t=this.Zt;this.resetSessionId(),this.Gt.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},eg=function(s,e){if(!s)return!1;var t=s.userAgent;if(t&&ud(t,e))return!0;try{var i=s?.userAgentData;if(i!=null&&i.brands&&i.brands.some((r=>ud(r?.brand,e))))return!0}catch{}return!!s.webdriver},on=function(s,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(s)}catch{return!1}};tg={exact:(s,e)=>e.some((t=>s.some((i=>t===i)))),is_not:(s,e)=>e.every((t=>s.every((i=>t!==i)))),regex:(s,e)=>e.some((t=>s.some((i=>on(t,i))))),not_regex:(s,e)=>e.every((t=>s.every((i=>!on(t,i))))),icontains:(s,e)=>e.map(Dr).some((t=>s.map(Dr).some((i=>t.includes(i))))),not_icontains:(s,e)=>e.map(Dr).every((t=>s.map(Dr).every((i=>!t.includes(i))))),gt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((r=>i>parseFloat(r)))})),lt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((r=>i<parseFloat(r)))}))},Dr=s=>s.toLowerCase();Ha="custom",Dd="i.posthog.com",ja=class{constructor(e){this.vi={},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,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+Dd,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.vi[this.apiHost]||(this.vi[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":Ha),this.vi[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===Ha)return this.apiHost+t;var i=Dd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}},ie=he("[Surveys]"),za="seenSurvey_",Xb=(s,e)=>{var t="$survey_"+e+"/"+s.id;return s.current_iteration&&s.current_iteration>0&&(t="$survey_"+e+"/"+s.id+"/"+s.current_iteration),t},xd=s=>((e,t)=>{var i=""+za+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+za+t.id+"_"+t.current_iteration),i})(0,s),Zb=[Bo.Popover,Bo.Widget,Bo.API],eE={ignoreConditions:!1,ignoreDelay:!1,displayType:Da.Popover},tE=he("[PostHog ExternalIntegrations]"),sE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Wa=class{constructor(e){this._instance=e}Y(e,t){var i;(i=$.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,(r=>{if(r)return tE.error("failed to load script",r);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!r||(a=$.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.Y(sE[o],(()=>{var d;(d=$.__PosthogExtensions__)==null||(d=d.integrations)==null||(d=d[o])==null||d.start(e._instance)})),!r&&(l=$.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=$.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[i,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;t(i)}}},Si={},Wo=0,qa=()=>{},Ld='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',li="Surveys module not available",$d="sanitize_properties is deprecated. Use before_send instead",ig="Invalid value for property_denylist config: ",As="posthog",rg=!Kb&&$e?.indexOf("MSIE")===-1&&$e?.indexOf("Mozilla")===-1,Fd=s=>{var e;return w({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Pb(T?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:qa,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:s??"unset",__preview_deferred_init_extensions:!1,debug:ke&&ve(ke?.search)&&ke.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(t){O.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ia,before_send:void 0,request_queue_config:{flush_interval_ms:Ua},error_tracking:{},_onCapture:qa,__preview_eager_load_replay:!1},(t=>({rageclick:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(s))},iE=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Md=s=>{var e={};for(var[t,i]of iE)P(s[t])||(e[i]=s[t]);var r=fe({},e,s);return Y(s.property_blacklist)&&(P(s.property_denylist)?r.property_denylist=s.property_blacklist:Y(s.property_denylist)?r.property_denylist=[...s.property_blacklist,...s.property_denylist]:O.error(ig+s.property_denylist)),r},Ka=class{constructor(){this.__forceAllowLocalhost=!1}get ci(){return this.__forceAllowLocalhost}set ci(e){O.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},$s=class s{fi(e,t){if(e){var i=this.pi.indexOf(e);i!==-1&&this.pi.splice(i,1)}return this.pi.push(t),t.initialize==null||t.initialize(),t}get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new Ka,this.gi=!1,this.version=Ue.LIB_VERSION,this.mi=new Ri,this.pi=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Fd(),this.SentryIntegration=Na,this.sentryIntegration=i=>(function(r,n){var o=Vh(r,n);return{name:Bh,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.bi=!1,this.yi=null,this.wi=null,this.Ei=null,this.scrollManager=new Ga(this),this.pageViewManager=new Kr(this),this.rateLimiter=new xa(this),this.requestRouter=new ja(this),this.consent=new Pa(this),this.externalIntegrations=new Wa(this);var t=(e=s.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(i,r,n)=>{var o=ve(i)?{[i]:r}:i;this.setPersonProperties(o),n?.({})},set_once:(i,r,n)=>{var o=ve(i)?{[i]:r}:i;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(i=>O.info('send "'+i?.event+'"',i)))}init(e,t,i){if(i&&i!==As){var r,n=(r=Si[i])!==null&&r!==void 0?r:new s;return n._init(e,t,i),Si[i]=n,Si[As][i]=n,n}return this._init(e,t,i)}_init(e,t,i){var r;if(t===void 0&&(t={}),P(e)||Lr(e))return O.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={},t.debug=this.Si(t.debug),this.xi=t,this.Ti=[],t.person_profiles?this.wi=t.person_profiles:t.process_person&&(this.wi=t.process_person),this.set_config(fe({},Fd(t.defaults),Md(t),{name:i,token:e})),this.config.on_xhr_error&&O.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:nt.GZipJS;var n=this.$i();this.persistence=new bi(this.config,n),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new bi(w({},this.config,{persistence:"sessionStorage"}),n);var o=w({},this.persistence.props),a=w({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.ki=new Ba((p=>this.Ri(p)),this.config.request_queue_config),this.Pi=new Va(this),this.__request_queue=[];var l=this.config.cookieless_mode===et||this.config.cookieless_mode===mt&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new nn(this),this.sessionPropsManager=new rn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(O.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Oi(l)}),0)):(O.info("Initializing extensions synchronously"),this.Oi(l)),Ue.DEBUG=Ue.DEBUG||this.config.debug,Ue.DEBUG&&O.info("Starting in debug mode",{this:this,config:t,thisC:w({},this.config),p:o,s:a}),((r=t.bootstrap)==null?void 0:r.distinctID)!==void 0){var c=t.bootstrap.distinctID,d=this.get_distinct_id(),h=this.persistence.get_property(Xe);if(t.bootstrap.isIdentifiedID&&d!=null&&d!==c&&h===bs)this.identify(c);else if(t.bootstrap.isIdentifiedID&&d!=null&&d!==c&&h===Es)O.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 f=this.config.get_device_id(Lt()),g=t.bootstrap.isIdentifiedID?f:c;this.persistence.set_property(Xe,t.bootstrap.isIdentifiedID?Es:bs),this.register({distinct_id:c,$device_id:g})}}if(l)this.register_once({distinct_id:Rr,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(Lt());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(Xe,bs)}return pe(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?(function(p,m){var b=p.config.segment;if(!b)return m();(function(E,N){var I=E.config.segment;if(!I)return N();var R=A=>{var k=()=>A.anonymousId()||Lt();E.config.get_device_id=k,A.id()&&(E.register({distinct_id:A.id(),$device_id:k()}),E.persistence.set_property(Xe,Es)),N()},C=I.user();"then"in C&&yt(C.then)?C.then(R):R(C)})(p,(()=>{b.register((E=>{Promise&&Promise.resolve||Uo.warn("This browser does not have Promise support, and can not use the segment integration");var N=(I,R)=>{if(!R)return I;I.event.userId||I.event.anonymousId===E.get_distinct_id()||(Uo.info("No userId set, resetting PostHog"),E.reset()),I.event.userId&&I.event.userId!==E.get_distinct_id()&&(Uo.info("UserId set, identifying with PostHog"),E.identify(I.event.userId));var C=E.calculateEventProperties(R,I.event.properties);return I.event.properties=Object.assign({},C,I.event.properties),I};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:I=>N(I,I.event.event),page:I=>N(I,ws),identify:I=>N(I,Fo),screen:I=>N(I,"$screen")}})(p)).then((()=>{m()}))}))})(this,(()=>this.Ii())):this.Ii(),yt(this.config._onCapture)&&this.config._onCapture!==qa&&(O.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(p=>this.config._onCapture(p.event,p)))),this.config.ip&&O.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}Oi(e){var t,i,r,n,o,a,l,c=performance.now(),d=w({},s.__defaultExtensionClasses,this.config.__extensionClasses),h=[];d.featureFlags&&this.pi.push(this.featureFlags=(t=this.featureFlags)!==null&&t!==void 0?t:new d.featureFlags(this)),d.exceptions&&this.pi.push(this.exceptions=(i=this.exceptions)!==null&&i!==void 0?i:new d.exceptions(this)),d.historyAutocapture&&this.pi.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this.pi.push(new d.tracingHeaders(this)),d.siteApps&&this.pi.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!e&&this.pi.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),d.autocapture&&this.pi.push(this.autocapture=new d.autocapture(this)),d.surveys&&this.pi.push(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new d.surveys(this)),d.logs&&this.pi.push(this.logs=(n=this.logs)!==null&&n!==void 0?n:new d.logs(this)),d.conversations&&this.pi.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new d.conversations(this)),d.productTours&&this.pi.push(this.productTours=new d.productTours(this)),d.heatmaps&&this.pi.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this.pi.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this.pi.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this.pi.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,Fb)),d.toolbar&&this.pi.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new d.toolbar(this)),d.experiments&&this.pi.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new d.experiments(this)),this.pi.forEach((f=>{f.initialize&&h.push((()=>{f.initialize==null||f.initialize()}))})),h.push((()=>{if(this.Ci){var f=this.Ci;this.Ci=void 0,this.ft(f)}})),this.Fi(h,c)}Fi(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.Fi(e,t)}),0);var i=e.shift();if(i)try{i()}catch(n){O.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&O.info("PostHog extensions initialized ("+r+"ms)")}ft(e){var t;if(!T||!T.body)return O.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.ft(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Ci=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=G(e.supportedCompression,nt.GZipJS)?nt.GZipJS:G(e.supportedCompression,nt.Base64)?nt.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.wi?this.wi:Ia}),this.pi.forEach((i=>i.onRemoteConfig==null?void 0:i.onRemoteConfig(e)))}Ii(){try{this.config.loaded(this)}catch(i){O.critical("`loaded` function failed",i)}if(this.Ai(),this.config.internal_or_test_user_hostname&&ke!=null&&ke.hostname){var e=ke.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode===et)&&this.Mi()}),1),this.Di=new Zr(this),this.Di.load()}Ai(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.ki)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Or(this.__request_queue,(e=>this.Ri(e))),this.__request_queue=[],this.Ai()}_handle_unload(){var e,t,i;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Li()&&this.capture($o),(t=this.ki)==null||t.unload(),(i=this.Pi)==null||i.unload()):this.Li()&&this.capture($o,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(rg?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=sn(e.url,{ip:this.config.ip?1:0}),e.headers=w({},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,(t=>{var i,r,n,o=w({},t);o.timeout=o.timeout||6e4,o.url=sn(o.url,{_:new Date().getTime().toString(),ver:Ue.JS_SDK_VERSION,compression:o.compression});var a=(i=o.transport)!==null&&i!==void 0?i:"fetch",l=Fr.filter((d=>!o.disableTransport||!d.transport||!o.disableTransport.includes(d.transport))),c=(r=(n=(function(d,h){for(var f=0;d.length>f;f++)if(d[f].transport===a)return d[f]})(l))==null?void 0:n.method)!==null&&r!==void 0?r:l[0].method;if(!c)throw new Error("No available transport method");a!=="sendBeacon"&&o.data&&o.compression===nt.GZipJS&&eb?Yb(o).then((d=>{c(d)})).catch((()=>{c(o)})):c(o)})(w({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(i=(r=this.config).on_request_error)==null||i.call(r,t),e.callback==null||e.callback(t)}}))))}Ri(e){this.Pi?this.Pi.retriableRequest(e):this._send_request(e)}_execute_array(e){Wo++;try{var t,i=[],r=[],n=[];Or(e,(a=>{a&&(Y(t=a[0])?n.push(a):yt(a)?a.call(this):Y(a)&&t==="alias"?i.push(a):Y(a)&&t.indexOf("capture")!==-1&&yt(this[t])?n.push(a):r.push(a))}));var o=function(a,l){Or(a,(function(c){if(Y(c[0])){var d=l;ae(c,(function(h){d=d[h[0]].apply(d,h.slice(1))}))}else l[c[0]].apply(l,c.slice(1))}))};o(i,this),o(r,this),o(n,this)}finally{Wo--}}push(e){if(Wo>0&&Y(e)&&ve(e[0])){var t=s.prototype[e[0]];yt(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,i){var r,n,o,a,l,c;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.ki){if(this.is_capturing())if(!P(e)&&ve(e)){var d=!this.config.opt_out_useragent_filter&&this._is_bot();if(!d||this.config.__preview_capture_bot_pageviews){var h=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(h==null||!h.isRateLimited){t!=null&&t.$current_url&&!ve(t?.$current_url)&&(O.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!=="$exception"||i!=null&&i.Ui||O.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 f=new Date,g=i?.timestamp||f,v=Lt(),p={uuid:v,event:e,properties:this.calculateEventProperties(e,t||{},g,v)};e===ws&&this.config.__preview_capture_bot_pageviews&&d&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),h&&(p.properties.$lib_rate_limit_remaining_tokens=h.remainingTokens),i?.$set&&(p.$set=i?.$set);var m,b=this.Ni(i?.$set_once,e!==kd,e===Fo);if(b&&(p.$set_once=b),(n=p,o=i!=null&&i._noTruncate?null:this.config.properties_string_max_length,a=n,l=k=>ve(k)&&!St(o)?k.slice(0,o):k,c=new Set,p=(function k(L,z){return L!==Object(L)?l?l(L):L:c.has(L)?void 0:(c.add(L),Y(L)?(j=[],Or(L,(V=>{j.push(k(V))}))):(j={},ae(L,((V,S)=>{c.has(V)||(j[S]=k(V,S))}))),j);var j})(a)).timestamp=g,P(i?.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=f),e===_i.DISMISSED||e===_i.SENT){var E=t?.[Vo.SURVEY_ID],N=t?.[Vo.SURVEY_ITERATION];m={id:E,current_iteration:N},localStorage.getItem(xd(m))||localStorage.setItem(xd(m),"true"),p.$set=w({},p.$set,{[Xb({id:E,current_iteration:N},e===_i.SENT?"responded":"dismissed")]:!0})}else e===_i.SHOWN&&(p.$set=w({},p.$set,{[Vo.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Gb.SHOWN){var I=t?.[Id.TOUR_TYPE];I&&(p.$set=w({},p.$set,{[Id.TOUR_LAST_SEEN_DATE+"/"+I]:new Date().toISOString()}))}var R=w({},p.properties.$set,p.$set);if(Ts(R)||this.setPersonPropertiesForFlags(R),!H(this.config.before_send)){var C=this.ji(p);if(!C)return;p=C}this.mi.emit("eventCaptured",p);var A={method:"POST",url:(r=i?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:i?._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.Ri(A):this.ki.enqueue(A),p}O.critical("This capture call is ignored due to client rate limiting.")}}else O.error("No event name provided to posthog.capture")}else O.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=w({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode==et||this.config.cookieless_mode==mt&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=w({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ve(a.distinct_id)&&!lt(a.distinct_id)||Lr(a.distinct_id))&&O.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,d=(function(b,E){var N,I,R,C;if(!$e)return{};var A,k,L,z,j,V,S,D,F=b?[...xs,...E||[]]:[],[M,Q]=(function(W){for(var X=0;gd.length>X;X++){var[ee,te]=gd[X],ye=ee.exec(W),U=ye&&(yt(te)?te(ye,W):te);if(U)return U}return["",""]})($e);return fe(ll({$os:M,$os_version:Q,$browser:Ch($e,navigator.vendor),$device:fd($e),$device_type:(k=$e,L={userAgentDataPlatform:(N=navigator)==null||(N=N.userAgentData)==null?void 0:N.platform,maxTouchPoints:(I=navigator)==null?void 0:I.maxTouchPoints,screenWidth:_==null||(R=_.screen)==null?void 0:R.width,screenHeight:_==null||(C=_.screen)==null?void 0:C.height,devicePixelRatio:_?.devicePixelRatio},D=fd(k),D===vh||D===ph||D==="Kobo"||D==="Kindle Fire"||D===Oh?Ps:D===wi||D===Cs||D===Ai||D===na?"Console":D===mh?"Wearable":D?Ve:L?.userAgentDataPlatform==="Android"&&((z=L?.maxTouchPoints)!==null&&z!==void 0?z:0)>0?600>Math.min((j=L?.screenWidth)!==null&&j!==void 0?j:0,(V=L?.screenHeight)!==null&&V!==void 0?V:0)/((S=L?.devicePixelRatio)!==null&&S!==void 0?S:1)?Ve:Ps:"Desktop"),$timezone:Kh(),$timezone_offset:Bb()}),{$current_url:Ti(ke?.href,F,Ii),$host:ke?.host,$pathname:ke?.pathname,$raw_user_agent:$e.length>1e3?$e.substring(0,997)+"...":$e,$browser_version:pb($e,navigator.vendor),$browser_language:Td(),$browser_language_prefix:(A=Td(),typeof A=="string"?A.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.innerWidth,$lib:Ue.LIB_NAME,$lib_version:Ue.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,i.getTime());a.$session_id=h,a.$window_id=f}this.sessionPropsManager&&fe(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&fe(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.Pi)==null?void 0:g.length}catch(b){a.$sdk_debug_error_capturing_properties=String(b)}if(this.requestRouter.region===Ha&&(a.$lib_custom_api_host=this.config.api_host),c=e!==ws||n?e!==$o||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=fe(a,c),e===ws&&T&&(a.title=T.title),!P(o)){var v=i.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}$e&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=fe({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),Y(this.config.property_denylist)?ae(this.config.property_denylist,(function(b){delete a[b]})):O.error(ig+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(O.error($d),a=p(a,e));var m=this.zi();return a.$process_person_profile=m,m&&!n&&this.Bi("_calculate_event_properties"),a}Ni(e,t,i){var r;if(t===void 0&&(t=!0),i===void 0&&(i=!1),!this.persistence||!this.zi()||this.gi&&!i)return e;var n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),a=fe({},n,o||{},e||{}),l=this.config.sanitize_properties;return l&&(O.error($d),a=l(a,"$set_once")),t&&(this.gi=!0),Ts(a)?void 0:a}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var r;(r=this.persistence)==null||r.register_once(e,t,i)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}Hi(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return(t=this.featureFlags)==null?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var i;return(i=this.featureFlags)==null?void 0:i.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,i){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return t===void 0&&(t=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.mi.on(e,t)}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:li}),()=>{})}onSessionId(e){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:li})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:li})}renderSurvey(e,t){var i;(i=this.surveys)==null||i.renderSurvey(e,t)}displaySurvey(e,t){var i;t===void 0&&(t=eE),(i=this.surveys)==null||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return(t=(i=this.surveys)==null?void 0:i.canRenderSurvey(e))!==null&&t!==void 0?t:{visible:!1,disabledReason:li}}canRenderSurveyAsync(e,t){var i,r;return t===void 0&&(t=!1),(i=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,t))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:li})}qi(e){return!e||Lr(e)?(O.critical("Unique user id has not been set in posthog.identify"),!1):e===Rr?(O.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())||(O.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,t,i){if(!this.__loaded||!this.persistence)return O.uninitializedWarning("posthog.identify");if(lt(e)&&(e=e.toString(),O.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.qi(e)&&this.Bi("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Br)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(gi)&&(this.unregister(gi),this.register({distinct_id:e}));var n,o=(this.persistence.get_property(Xe)||bs)===bs;e!==r&&o?(this.persistence.set_property(Xe,Es),this.setPersonPropertiesForFlags(w({},i||{},t||{}),!1),this.capture(Fo,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this.Ei=Nd(e,t,i),(n=this.featureFlags)==null||n.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(yi))}}setPersonProperties(e,t){if((e||t)&&this.Bi("posthog.setPersonProperties")){var i=Nd(this.get_distinct_id(),e,t);this.Ei!==i?(this.setPersonPropertiesForFlags(w({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Ei=i):O.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:w({},r,{[e]:t})}),i&&(this.capture(kd,{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),r[e]===t||i||this.reloadFeatureFlags()}else O.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),(i=this.featureFlags)==null||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),this.Bi("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)==null||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,n,o,a,l;if(O.info("reset"),!this.__loaded)return O.uninitializedWarning("posthog.reset");var c=this.get_property(Br);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(i=this.sessionPersistence)==null||i.clear(),(r=this.surveys)==null||r.reset(),(n=this.Di)==null||n.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.persistence)==null||a.set_property(Xe,bs),(l=this.sessionManager)==null||l.resetSessionId(),this.Ei=null,this.config.cookieless_mode===et)this.register_once({distinct_id:Rr,$device_id:null},"");else{var d=this.config.get_device_id(Lt());this.register_once({distinct_id:d,$device_id:e?d:c},"")}this.register({$last_posthog_reset:new Date().toISOString()},1),this.reloadFeatureFlags()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&i){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!i)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}return r}alias(e,t){return e===this.get_property(xh)?(O.critical("Attempting to create alias for existing People user - aborting."),-2):this.Bi("posthog.alias")?(P(t)&&(t=this.get_distinct_id()),e!==t?(this.Hi(gi,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(O.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=w({},this.config);if(_e(e)){var i,r,n,o,a,l,c,d,h;fe(this.config,Md(e));var f=this.$i();(i=this.persistence)==null||i.update_config(this.config,t,f),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new bi(w({},this.config,{persistence:"sessionStorage"}),f);var g=this.Si(this.config.debug);bt(g)&&(this.config.debug=g),bt(this.config.debug)&&(this.config.debug?(Ue.DEBUG=!0,de.F()&&de.L("ph_debug",!0),O.info("set_config",{config:e,oldConfig:t,newConfig:w({},this.config)})):(Ue.DEBUG=!1,de.F()&&de.U("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(d=this.surveys)==null||d.loadIfEnabled(),this.Wi(),(h=this.externalIntegrations)==null||h.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){Ue.LIB_NAME=e,Ue.LIB_VERSION=t}startSessionRecording(e){var t,i,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)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),l.sampling&&((i=this.sessionRecording)==null||i.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,t){if(this.exceptions){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(w({},r,t))}}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return(t=(i=this.toolbar)==null?void 0:i.loadToolbar(e))!==null&&t!==void 0&&t}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:As;return t!==As&&(t=As+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(Xe))===Es||((t=this.sessionPersistence)==null?void 0:t.get_property(Xe))===Es}zi(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles===Ia&&!this._isIdentified()&&Ts(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[gi])&&((t=this.persistence)==null||(t=t.props)==null||!t[jr]))}Li(){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.zi()||this.Bi("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Bi("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Bi(e){return this.config.person_profiles==="never"?(O.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Hi(jr,!0),!0)}$i(){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!==mt)}Wi(){var e,t,i,r,n=this.$i();return((e=this.persistence)==null?void 0:e.st)!==n&&((i=this.persistence)==null||i.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.st)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==et){if(this.config.cookieless_mode===mt&&this.consent.isExplicitlyOptedOut()){var i,r,n,o,a;this.reset(!0),(i=this.sessionManager)==null||i.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new nn(this),this.pageViewManager=new Kr(this),this.persistence&&(this.sessionPropsManager=new rn(this,this.sessionManager,this.persistence));var l=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=s.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=this.fi(this.sessionRecording,new l(this)))}var c,d;this.consent.optInOut(!0),this.Wi(),this.Ai(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode==mt&&((c=this.surveys)==null||c.loadIfEnabled()),(P(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((d=e?.captureEventName)!==null&&d!==void 0?d:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Mi()}else O.warn(Ld)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==et?(this.config.cookieless_mode===mt&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Wi(),this.config.cookieless_mode===mt&&(this.register({distinct_id:Rr,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(i=this.sessionRecording)==null||i.stopRecording(),this.sessionRecording=void 0,this.Mi())):O.warn(Ld)}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===et||(this.config.cookieless_mode===mt?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Wi()}_is_bot(){return Be?eg(Be,this.config.custom_blocked_useragents):void 0}Mi(){T&&(T.visibilityState==="visible"?this.bi||(this.bi=!0,this.capture(ws,{title:T.title},{send_instantly:!0}),this.yi&&(T.removeEventListener(zr,this.yi),this.yi=null)):this.yi||(this.yi=this.Mi.bind(this),pe(T,zr,this.yi)))}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}))}bt(){var e,t,i,r,n,o,a=this.xi||{};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?(O.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):(i="advanced_disable_decide",r=O,n=(t="advanced_disable_flags")in(e=a)&&!H(e[t]),o=i in e&&!H(e[i]),n?e[t]:!!o&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}ji(e){if(H(this.config.before_send))return e;var t=Y(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),H(i)){var n="Event '"+e.event+"' was rejected in beforeSend function";return rb(e.event)?O.warn(n+". This can cause unexpected behavior."):O.info(n),null}i.properties&&!Ts(i.properties)||O.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return(e=this.pageViewManager.K)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Si(e){var t=bt(e)&&!e,i=de.F()&&de.M("ph_debug")==="true";return!t&&(!!i||e)}};$s.__defaultExtensionClasses={},(function(s,e){for(var t=0;e.length>t;t++)s.prototype[e[t]]=Ob(s.prototype[e[t]])})($s,["identify"]);hl=["a","button","form","input","select","textarea","label"];rE=["next","previous","prev",">","<"],Hd=[".ph-no-rageclick",".ph-no-capture"],Ya=s=>!s||$t(s,"html")||!dn(s),jd=(s,e)=>{if(!_||Ya(s))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[s],r=s;r.parentNode&&!$t(r,"body");)if(og(r.parentNode))i.push(r.parentNode.host),r=r.parentNode.host;else{var n=lg(r);if(!n)break;if(e||hl.indexOf(n.tagName.toLowerCase())>-1)t=!0;else{var o=_.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}i.push(n),r=n}return{parentIsUsefulElement:t,targetElementList:i}};ug="(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})",nE=new RegExp("^(?:"+ug+")$"),oE=new RegExp(ug),dg="\\d{3}-?\\d{2}-?\\d{4}",aE=new RegExp("^("+dg+")$"),lE=new RegExp("("+dg+")");ln=class{constructor(e){this.disabled=e===!1;var t=_e(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},qo="$copy_autocapture",qd=he("[AutoCapture]");ci=he("[ExceptionAutocapture]");hE=he("[TracingHeaders]"),Pt=he("[Web Vitals]"),Yd=9e5,Jd="disabled",Qd="lazy_loading",ui="awaiting_config",xr="missing_config";he("[SessionRecording]");Qa="[SessionRecording]",Nt=he(Qa),gE=he("[Heatmaps]");Zd=he("[Product Tours]"),Yo="ph_product_tours",fE=["$set_once","$set"],Dt=he("[SiteApps]"),eh="Error while initializing PostHog app with config id ";Xa=class{constructor(e){this.Vi=new Ri,this.Yi=(t,i)=>this.Gi(t,i)&&this.Ji(t,i)&&this.Ki(t,i)&&this.Xi(t,i),this.Gi=(t,i)=>i==null||!i.event||t?.event===i?.event,this._instance=e,this.Qi=new Set,this.Zi=new Set}init(){var e,t;P((e=this._instance)==null?void 0:e._addCaptureHook)||(t=this._instance)==null||t._addCaptureHook(((i,r)=>{this.on(i,r)}))}register(e){var t,i;if(!P((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.Zi)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var d;(d=this.Qi)==null||d.add(c?.event||"")}))})),(i=this._instance)!=null&&i.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,t){var i;t!=null&&e.length!=0&&(this.Qi.has(e)||this.Qi.has(t?.event))&&this.Zi&&((i=this.Zi)==null?void 0:i.size)>0&&this.Zi.forEach((r=>{this.te(t,r)&&this.Vi.emit("actionCaptured",r.name)}))}ie(e){this.onAction("actionCaptured",(t=>e(t)))}te(e,t){if(t?.steps==null)return!1;for(var i of t.steps)if(this.Yi(e,i))return!0;return!1}onAction(e,t){return this.Vi.on(e,t)}Ji(e,t){if(t!=null&&t.url){var i,r=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!r||typeof r!="string"||!Ss(r,t.url,t.url_matching||"contains"))return!1}return!0}Ki(e,t){return!!this.ee(e,t)&&!!this.re(e,t)&&!!this.se(e,t)}ee(e,t){var i;if(t==null||!t.href)return!0;var r=this.ne(e);if(r.length>0)return r.some((a=>Ss(a.href,t.href,t.href_matching||"exact")));var n,o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!o&&Ss((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}re(e,t){var i;if(t==null||!t.text)return!0;var r=this.ne(e);if(r.length>0)return r.some((c=>Ss(c.text,t.text,t.text_matching||"exact")||Ss(c.$el_text,t.text,t.text_matching||"exact")));var n,o,a,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(n=(function(c){for(var d,h=[],f=/(?::|")text="(.*?)"/g;!H(d=f.exec(c));)h.includes(d[1])||h.push(d[1]);return h})(l),o=t.text,a=t.text_matching||"exact",n.some((c=>Ss(c,o,a))))}se(e,t){var i,r;if(t==null||!t.selector)return!0;var n=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}ne(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Xi(e,t){return t==null||!t.properties||t.properties.length===0||sg(t.properties.reduce(((i,r)=>{var n=Y(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return i[r.key]={values:n,operator:r.operator||"exact"},i}),{}),e?.properties)}},Za=class{constructor(e){this._instance=e,this.oe=new Map,this.ae=new Map,this.le=new Map}ue(e,t){return!!e&&sg(e.propertyFilters,t?.properties)}he(e,t){var i=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=i.get(o.name)||[];a.push(r.id),i.set(o.name,a)}}))})),i}de(e,t,i){var r=(i===ri.Activation?this.oe:this.ae).get(e),n=[];return this.ve((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[i])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.ue(l,t)}))}register(e){var t;P((t=this._instance)==null?void 0:t._addCaptureHook)||(this.ce(e),this.fe(e))}fe(e){var t=e.filter((i=>{var r,n;return((r=i.conditions)==null?void 0:r.actions)&&((n=i.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.pe==null&&(this.pe=new Xa(this._instance),this.pe.init(),this.pe.ie((i=>{this.onAction(i)}))),t.forEach((i=>{var r,n,o,a,l;i.conditions&&(r=i.conditions)!=null&&r.actions&&(n=i.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=i.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.pe)==null||a.register(i.conditions.actions.values),(l=i.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var d=this.le.get(c.name);d&&d.push(i.id),this.le.set(c.name,d||[i.id])}})))})))}ce(e){var t,i=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}));i.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.oe=this.he(e,ri.Activation),this.ae=this.he(e,ri.Cancellation))}onEvent(e,t){var i,r=this._e(),n=this.ge(),o=this.me(),a=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[n])||[];if(o===e&&t&&a.length>0){var l,c;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var d=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(d){var h=a.indexOf(d);0>h||(a.splice(h,1),this.be(a))}}else{if(this.ae.has(e)){var f=this.de(e,t,ri.Cancellation);f.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:f.map((v=>v.id))}),f.forEach((v=>{var p=a.indexOf(v.id);0>p||a.splice(p,1),this.ye(v.id)})),this.be(a))}if(this.oe.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.oe.get(e)});var g=this.de(e,t,ri.Activation);this.be(a.concat(g.map((v=>v.id))||[]))}}}onAction(e){var t,i=this.ge(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[i])||[];this.le.has(e)&&this.be(r.concat(this.le.get(e)||[]))}be(e){var t,i=this._e(),r=this.ge(),n=[...new Set(e)].filter((o=>!this.we(o)));i.info("updating activated items",{activatedItems:n}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:n})}getActivatedIds(){var e,t=this.ge();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.oe}Ee(){return this.pe}},el=class extends Za{constructor(e){super(e)}ge(){return"$surveys_activated"}me(){return _i.SHOWN}ve(e){var t;(t=this._instance)==null||t.getSurveys(e)}ye(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}_e(){return ie}we(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Jo="SDK is not enabled or survey functionality is not yet loaded",th="Disabled. Not loading surveys.",pE=_!=null&&_.location?Qr(_.location.hash,"__posthog")||Qr(location.hash,"state"):null,sh="_postHogToolbarParams",ih=he("[Toolbar]"),Re=he("[FeatureFlags]"),Jt=he("[FeatureFlags]",{debugEnabled:!0}),Qo=`" failed. Feature flags didn't load in time.`,Xo="$active_feature_flags",xt="$override_feature_flags",rh="$feature_flag_payloads",di="$override_feature_flag_payloads",nh="$feature_flag_request_id",oh=s=>{for(var e={},t=0;s.length>t;t++)e[s[t]]=!0;return e},ah=s=>{var e={};for(var[t,i]of $r(s||{}))i&&(e[t]=i);return e},Zo=he("[Error tracking]"),lh="Refusing to render web experiment since the viewer is a likely bot",vE={icontains:(s,e)=>!!_&&e.href.toLowerCase().indexOf(s.toLowerCase())>-1,not_icontains:(s,e)=>!!_&&e.href.toLowerCase().indexOf(s.toLowerCase())===-1,regex:(s,e)=>!!_&&on(e.href,s),not_regex:(s,e)=>!!_&&!on(e.href,s),exact:(s,e)=>e.href===s,is_not:(s,e)=>e.href!==s},tl=class s{get N(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments((r=>{s.Se("retrieved web experiments from the server"),t.xe=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;t.xe&&(s.Se("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=t.xe)==null||o.set(n.feature_flag_key,n));var a=t._instance.getFeatureFlag(n.feature_flag_key);ve(a)&&n.variants[a]&&t.Te(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var c=n.variants[l];s.$e(c)&&t.Te(n.name,l,c.transforms)}}))}),i)},this._instance=e,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())s.Se(lh);else if(!this.N.disable_web_experiments){if(H(this.xe))return this.xe=new Map,this.loadIfEnabled(),void this.previewWebExperiment();s.Se("applying feature flags",e),e.forEach((t=>{var i;if(this.xe&&(i=this.xe)!=null&&i.has(t)){var r,n=this._instance.getFeatureFlag(t),o=(r=this.xe)==null?void 0:r.get(t);n&&o!=null&&o.variants[n]&&this.Te(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=s.getWindowLocation();if(e!=null&&e.search){var t=Jr(e?.search,"__experiment_id"),i=Jr(e?.search,"__experiment_variant");t&&i&&(s.Se("previewing web experiments "+t+" && "+i),this.getWebExperiments((r=>{this.ke(parseInt(t),i,r)}),!1,!0))}}loadIfEnabled(){this.N.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.N.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.N.token),method:"GET",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}ke(e,t,i){var r=i.filter((n=>n.id===e));r&&r.length>0&&(s.Se("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Te(r[0].name,t,r[0].variants[t].transforms))}static $e(e){return!H(e.conditions)&&s.Re(e)&&s.Pe(e)}static Re(e){var t;if(H(e.conditions)||H((t=e.conditions)==null?void 0:t.url))return!0;var i,r,n,o=s.getWindowLocation();return!!o&&((i=e.conditions)==null||!i.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 Pe(e){var t;if(H(e.conditions)||H((t=e.conditions)==null?void 0:t.utm))return!0;var i=Gh();if(i.utm_source){var r,n,o,a,l,c,d,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)==i.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)==i.utm_source,v=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==i.utm_medium,p=(d=e.conditions)==null||(d=d.utm)==null||!d.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return f&&v&&p&&g}return!1}static Se(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];O.info("[WebExperiments] "+e,i)}Te(e,t,i){this._is_bot()?s.Se(lh):t!=="control"?i.forEach((r=>{if(r.selector){var n;s.Se("applying transform of variant "+t+" 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)}))}})):s.Se("Control variants leave the page unmodified.")}_is_bot(){return Be&&this._instance?eg(Be,this.N.custom_blocked_useragents):void 0}},ze=he("[Conversations]"),Qt="Conversations not available yet.",hn={featureFlags:class{constructor(s){this.Oe=!1,this.Ie=!1,this.Ce=!1,this.Fe=!1,this.Ae=!1,this.Me=!1,this.De=!1,this.Le=!1,this._instance=s,this.featureFlagEventHandlers=[]}get N(){return this._instance.config}get Wt(){return this._instance.persistence}Ue(s){return this._instance.get_property(s)}Ne(){var s,e;return(s=(e=this.Wt)==null?void 0:e.nt(this.N.feature_flag_cache_ttl_ms))!==null&&s!==void 0&&s}je(){return!!this.Ne()&&(this.Le||this.Ce||(this.Le=!0,Re.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}ze(){var s,e=(s=this.N.evaluation_contexts)!==null&&s!==void 0?s:this.N.evaluation_environments;return!this.N.evaluation_environments||this.N.evaluation_contexts||this.De||(Re.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.De=!0),e!=null&&e.length?e.filter((t=>{var i=t&&typeof t=="string"&&t.trim().length>0;return i||Re.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}Be(){return this.ze().length>0}initialize(){var s,e,{config:t}=this._instance,i=(s=(e=t.bootstrap)==null?void 0:e.featureFlags)!==null&&s!==void 0?s:{};if(Object.keys(i).length){var r,n,o=(r=(n=t.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(i).filter((c=>!!i[c])).reduce(((c,d)=>(c[d]=i[d]||!1,c)),{}),l=Object.keys(o).filter((c=>a[c])).reduce(((c,d)=>(o[d]&&(c[d]=o[d]),c)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(s,e,t){var i=t!=null&&t.merge?this.getFlagVariants():{},r=t!=null&&t.merge?this.getFlagPayloads():{},n=w({},i,s),o=w({},r,e),a={};for(var[l,c]of Object.entries(n)){var d=typeof c=="string";a[l]={key:l,enabled:!!d||!!c,variant:d?c: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.Ie}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var s=this.Ue(ya),e=this.Ue(xt),t=this.Ue(di);if(!t&&!e)return s||{};var i=fe({},s||{}),r=[...new Set([...Object.keys(t||{}),...Object.keys(e||{})])];for(var n of r){var o,a,l=i[n],c=e?.[n],d=P(c)?(o=l?.enabled)!==null&&o!==void 0&&o:!!c,h=P(c)?l.variant:typeof c=="string"?c:void 0,f=t?.[n],g=w({},l,{enabled:d,variant:d?h??l?.variant:void 0});d!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),f&&(g.metadata=w({},l?.metadata,{payload:f,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),i[n]=g}return this.Oe||(Re.warn(" Overriding feature flag details!",{flagDetails:s,overriddenPayloads:t,finalDetails:i}),this.Oe=!0),i}getFlagVariants(){var s=this.Ue(Is),e=this.Ue(xt);if(!e)return s||{};for(var t=fe({},s),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.Oe||(Re.warn(" Overriding feature flags!",{enabledFlags:s,overriddenFlags:e,finalFlags:t}),this.Oe=!0),t}getFlagPayloads(){var s=this.Ue(rh),e=this.Ue(di);if(!e)return s||{};for(var t=fe({},s||{}),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.Oe||(Re.warn(" Overriding feature flag payloads!",{flagPayloads:s,overriddenPayloads:e,finalPayloads:t}),this.Oe=!0),t}reloadFeatureFlags(){this.Fe||this.N.advanced_disable_feature_flags||this.He||(this._instance.mi.emit("featureFlagsReloading",!0),this.He=setTimeout((()=>{this.qe()}),5))}We(){clearTimeout(this.He),this.He=void 0}ensureFlagsLoaded(){this.Ie||this.Ce||this.He||this.reloadFeatureFlags()}setAnonymousDistinctId(s){this.$anon_distinct_id=s}setReloadingPaused(s){this.Fe=s}qe(s){var e;if(this.We(),!this._instance.bt())if(this.Ce)this.Ae=!0;else{var t=this.N.token,i=this.Ue(Br),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:w({},((e=this.Wt)==null?void 0:e.get_initial_props())||{},this.Ue(vi)||{}),group_properties:this.Ue(Xt),timezone:Kh()};St(i)||P(i)||(r.$device_id=i),(s!=null&&s.disableFlags||this.N.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Be()&&(r.evaluation_contexts=this.ze());var n=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.N.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Ce=!0,this._instance._send_request({method:"POST",url:n,data:r,compression:this.N.disable_compression?void 0:nt.Base64,timeout:this.N.feature_flag_request_timeout_ms,callback:o=>{var a,l,c,d=!0;if(o.statusCode===200&&(this.Ae||(this.$anon_distinct_id=void 0),d=!1),this.Ce=!1,!r.disable_flags||this.Ae){this.Me=!d;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"),(c=this.Wt)==null||c.register({[Sa]:h}),g?Re.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:{},d),this.Ae&&(this.Ae=!1,this.qe()))}}})}}getFeatureFlag(s,e){var t;if(e===void 0&&(e={}),!e.fresh||this.Me)if(this.Ie||this.getFlags()&&this.getFlags().length>0){if(!this.je()){var i=this.getFeatureFlagResult(s,e);return(t=i?.variant)!==null&&t!==void 0?t:i?.enabled}}else Re.warn('getFeatureFlag for key "'+s+Qo)}getFeatureFlagDetails(s){return this.getFlagsWithDetails()[s]}getFeatureFlagPayload(s){var e=this.getFeatureFlagResult(s,{send_event:!1});return e?.payload}getFeatureFlagResult(s,e){if(e===void 0&&(e={}),!e.fresh||this.Me)if(this.Ie||this.getFlags()&&this.getFlags().length>0){if(!this.je()){var t=this.getFlagVariants(),i=s in t,r=t[s],n=this.getFlagPayloads()[s],o=String(r),a=this.Ue(nh)||void 0,l=this.Ue(Gr)||void 0,c=this.Ue(yi)||{};if(this.N.advanced_feature_flags_dedup_per_session){var d,h=this._instance.get_session_id(),f=this.Ue(Ea);h&&h!==f&&(c={},(d=this.Wt)==null||d.register({[yi]:c,[Ea]:h}))}if((e.send_event||!("send_event"in e))&&(!(s in c)||!c[s].includes(o))){var g,v,p,m,b,E,N,I,R,C;Y(c[s])?c[s].push(o):c[s]=[o],(g=this.Wt)==null||g.register({[yi]:c});var A=this.getFeatureFlagDetails(s),k=[...(v=this.Ue(Sa))!==null&&v!==void 0?v:[]];P(r)&&k.push("flag_missing");var L={$feature_flag:s,$feature_flag_response:r,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:((p=this.N.bootstrap)==null||(p=p.featureFlags)==null?void 0:p[s])||null,$feature_flag_bootstrapped_payload:((m=this.N.bootstrap)==null||(m=m.featureFlagPayloads)==null?void 0:m[s])||null,$used_bootstrap_value:!this.Me};P(A==null||(b=A.metadata)==null?void 0:b.version)||(L.$feature_flag_version=A.metadata.version);var z,j=(E=A==null||(N=A.reason)==null?void 0:N.description)!==null&&E!==void 0?E:A==null||(I=A.reason)==null?void 0:I.code;j&&(L.$feature_flag_reason=j),A!=null&&(R=A.metadata)!=null&&R.id&&(L.$feature_flag_id=A.metadata.id),P(A?.original_variant)&&P(A?.original_enabled)||(L.$feature_flag_original_response=P(A.original_variant)?A.original_enabled:A.original_variant),A!=null&&(C=A.metadata)!=null&&C.original_payload&&(L.$feature_flag_original_payload=A==null||(z=A.metadata)==null?void 0:z.original_payload),k.length&&(L.$feature_flag_error=k.join(",")),this._instance.capture("$feature_flag_called",L)}if(i){var V=n;if(!P(n))try{V=JSON.parse(n)}catch{}return{key:s,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:V}}}}else Re.warn('getFeatureFlagResult for key "'+s+Qo)}getRemoteConfigPayload(s,e){var t=this.N.token,i={distinct_id:this._instance.get_distinct_id(),token:t};this.Be()&&(i.evaluation_contexts=this.ze()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:i,compression:this.N.disable_compression?void 0:nt.Base64,timeout:this.N.feature_flag_request_timeout_ms,callback(r){var n,o=(n=r.json)==null?void 0:n.featureFlagPayloads;e(o?.[s]||void 0)}})}isFeatureEnabled(s,e){if(e===void 0&&(e={}),!e.fresh||this.Me){if(this.Ie||this.getFlags()&&this.getFlags().length>0){var t=this.getFeatureFlag(s,e);return P(t)?void 0:!!t}Re.warn('isFeatureEnabled for key "'+s+Qo)}}addFeatureFlagsHandler(s){this.featureFlagEventHandlers.push(s)}removeFeatureFlagsHandler(s){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==s))}receivedFeatureFlags(s,e){if(this.Wt){this.Ie=!0;var t=this.getFlagVariants(),i=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(n,o,a,l,c){a===void 0&&(a={}),l===void 0&&(l={}),c===void 0&&(c={});var d=(C=>{var A=C.flags;return A?(C.featureFlags=Object.fromEntries(Object.keys(A).map((k=>{var L;return[k,(L=A[k].variant)!==null&&L!==void 0?L:A[k].enabled]}))),C.featureFlagPayloads=Object.fromEntries(Object.keys(A).filter((k=>A[k].enabled)).filter((k=>{var L;return(L=A[k].metadata)==null?void 0:L.payload})).map((k=>{var L;return[k,(L=A[k].metadata)==null?void 0:L.payload]})))):Re.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),C})(n),h=d.flags,f=d.featureFlags,g=d.featureFlagPayloads;if(f){var v=n.requestId,p=n.evaluatedAt;if(Y(f)){Re.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(f)for(var b=0;f.length>b;b++)m[f[b]]=!0;o&&o.register({[Xo]:f,[Is]:m})}else{var E=f,N=g,I=h;if(n.errorsWhileComputingFlags)if(h){var R=new Set(Object.keys(h).filter((C=>{var A;return!((A=h[C])!=null&&A.failed)})));E=w({},a,Object.fromEntries(Object.entries(E).filter((C=>{var[A]=C;return R.has(A)})))),N=w({},l,Object.fromEntries(Object.entries(N||{}).filter((C=>{var[A]=C;return R.has(A)})))),I=w({},c,Object.fromEntries(Object.entries(I||{}).filter((C=>{var[A]=C;return R.has(A)}))))}else E=w({},a,E),N=w({},l,N),I=w({},c,I);o&&o.register(w({[Xo]:Object.keys(ah(E)),[Is]:E||{},[rh]:N||{},[ya]:I||{}},v?{[nh]:v}:{},p?{[Gr]:p}:{}))}}})(s,this.Wt,t,i,r),e||(this.Le=!1),this.Ve(e)}}override(s,e){e===void 0&&(e=!1),Re.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:s,suppressWarning:e})}overrideFeatureFlags(s){if(!this._instance.__loaded||!this.Wt)return Re.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(s===!1)return this.Wt.unregister(xt),this.Wt.unregister(di),this.Ve(),Jt.info("All overrides cleared");if(Y(s)){var e=oh(s);return this.Wt.register({[xt]:e}),this.Ve(),Jt.info("Flag overrides set",{flags:s})}if(s&&typeof s=="object"&&("flags"in s||"payloads"in s)){var t,i=s;if(this.Oe=!!((t=i.suppressWarning)!==null&&t!==void 0&&t),"flags"in i){if(i.flags===!1)this.Wt.unregister(xt),Jt.info("Flag overrides cleared");else if(i.flags){if(Y(i.flags)){var r=oh(i.flags);this.Wt.register({[xt]:r})}else this.Wt.register({[xt]:i.flags});Jt.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this.Wt.unregister(di),Jt.info("Payload overrides cleared")):i.payloads&&(this.Wt.register({[di]:i.payloads}),Jt.info("Payload overrides set",{payloads:i.payloads}))),void this.Ve()}if(s&&typeof s=="object")return this.Wt.register({[xt]:s}),this.Ve(),Jt.info("Flag overrides set",{flags:s});Re.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:s})}onFeatureFlags(s){if(this.addFeatureFlagsHandler(s),this.Ie){var{flags:e,flagVariants:t}=this.Ye();s(e,t)}return()=>this.removeFeatureFlagsHandler(s)}updateEarlyAccessFeatureEnrollment(s,e,t){var i,r=(this.Ue(pi)||[]).find((l=>l.flagKey===s)),n={["$feature_enrollment/"+s]:e},o={$feature_flag:s,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),t&&(o.$feature_enrollment_stage=t),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=w({},this.getFlagVariants(),{[s]:e});(i=this.Wt)==null||i.register({[Xo]:Object.keys(ah(a)),[Is]:a}),this.Ve()}getEarlyAccessFeatures(s,e,t){e===void 0&&(e=!1);var i=this.Ue(pi),r=t?"&"+t.map((n=>"stage="+n)).join("&"):"";if(i&&!e)return s(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.N.token+r),method:"GET",callback:n=>{var o,a;if(n.json){var l=n.json.earlyAccessFeatures;return(o=this.Wt)==null||o.unregister(pi),(a=this.Wt)==null||a.register({[pi]:l}),s(l)}}})}Ye(){var s=this.getFlags(),e=this.getFlagVariants();return{flags:s.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}Ve(s){var{flags:e,flagVariants:t}=this.Ye();this.featureFlagEventHandlers.forEach((i=>i(e,t,{errorsLoading:s})))}setPersonPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=this.Ue(vi)||{};this._instance.register({[vi]:w({},t,s)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(vi)}setGroupPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=this.Ue(Xt)||{};Object.keys(t).length!==0&&Object.keys(t).forEach((i=>{t[i]=w({},t[i],s[i]),delete s[i]})),this._instance.register({[Xt]:w({},t,s)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(s){if(s){var e=this.Ue(Xt)||{};this._instance.register({[Xt]:w({},e,{[s]:{}})})}else this._instance.unregister(Xt)}reset(){this.Ie=!1,this.Ce=!1,this.Fe=!1,this.Ae=!1,this.Me=!1,this.$anon_distinct_id=void 0,this.We(),this.Oe=!1}}},_E={sessionRecording:class{get N(){return this._instance.config}get Wt(){return this._instance.persistence}get started(){var s;return!((s=this.Ge)==null||!s.isStarted)}get status(){var s,e;return this.Je===ui||this.Je===xr?this.Je:(s=(e=this.Ge)==null?void 0:e.status)!==null&&s!==void 0?s:this.Je}constructor(s){if(this._forceAllowLocalhostNetworkCapture=!1,this.Je=Jd,this.Ke=void 0,this._instance=s,!this._instance.sessionManager)throw Nt.error("started without valid sessionManager"),new Error(Qa+" started without valid sessionManager. This is a bug.");if(this.N.cookieless_mode===et)throw new Error(Qa+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Xe(){var s,e=!((s=this._instance.get_property(Ir))==null||!s.enabled),t=!this.N.disable_session_recording,i=this.N.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&t&&!i}startIfEnabledOrStop(s){var e;if(!this.Xe||(e=this.Ge)==null||!e.isStarted){var t=!P(Object.assign)&&!P(Array.from);this.Xe&&t?(this.Qe(s),Nt.info("starting")):(this.Je=Jd,this.stopRecording())}}Qe(s){var e,t,i;this.Xe&&(this.Je!==ui&&this.Je!==xr&&(this.Je=Qd),$!=null&&(e=$.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=$.__PosthogExtensions__)!=null&&t.initSessionRecording?this.Ze(s):(i=$.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.tr,(r=>{if(r)return Nt.error("could not load recorder",r);this.Ze(s)})))}stopRecording(){var s,e;(s=this.Ke)==null||s.call(this),this.Ke=void 0,(e=this.Ge)==null||e.stop()}ir(){var s,e;(s=this.Ke)==null||s.call(this),this.Ke=void 0,(e=this.Ge)==null||e.discard()}er(){var s;(s=this.Wt)==null||s.unregister($h)}rr(s,e){if(H(s))return null;var t,i=lt(s)?s:parseFloat(s);return typeof(t=i)!="number"||!Number.isFinite(t)||0>t||t>1?(Nt.warn(e+" must be between 0 and 1. Ignoring invalid value:",s),null):i}sr(s){if(this.Wt){var e,t,i=this.Wt,r=()=>{var n,o=s.sessionRecording===!1?void 0:s.sessionRecording,a=this.rr((n=this.N.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.rr(o?.sampleRate,"remote config sampleRate"),c=a??l;H(c)&&this.er();var d=o?.minimumDurationMilliseconds;i.register({[Ir]:w({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:w({capturePerformance:s.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:P(d)?null:d,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};r(),(e=this.Ke)==null||e.call(this),this.Ke=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(r)}}onRemoteConfig(s){return"sessionRecording"in s?s.sessionRecording===!1?(this.sr(s),void this.ir()):(this.sr(s),void this.startIfEnabledOrStop()):(this.Je===ui&&(this.Je=xr,Nt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(s,e){var t;e===void 0&&(e="log"),(t=this.Ge)!=null&&t.log?this.Ge.log(s,e):Nt.warn("log called before recorder was ready")}get tr(){var s,e,t=(s=this._instance)==null||(s=s.persistence)==null?void 0:s.get_property(Ir);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}nr(){var s,e=this._instance.get_property(Ir);if(!e)return!1;var t=(s=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&s!==void 0?s:Date.now();return 36e5>=Date.now()-t}Ze(s){var e,t;if((e=$.__PosthogExtensions__)==null||!e.initSessionRecording)return Nt.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.Ge||(this.Ge=(t=$.__PosthogExtensions__)==null?void 0:t.initSessionRecording(this._instance),this.Ge._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.nr())return this.Je===xr||this.Je===ui?void 0:(this.Je=ui,Nt.info("persisted remote config is stale, requesting fresh config before starting"),void new Zr(this._instance).load());this.Je=Qd,this.Ge.start(s)}onRRwebEmit(s){var e;(e=this.Ge)==null||e.onRRwebEmit==null||e.onRRwebEmit(s)}overrideLinkedFlag(){var s,e;this.Ge||(e=this.Wt)==null||e.register({$replay_override_linked_flag:!0}),(s=this.Ge)==null||s.overrideLinkedFlag()}overrideSampling(){var s,e;this.Ge||(e=this.Wt)==null||e.register({$replay_override_sampling:!0}),(s=this.Ge)==null||s.overrideSampling()}overrideTrigger(s){var e,t;this.Ge||(t=this.Wt)==null||t.register({[s==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.Ge)==null||e.overrideTrigger(s)}get sdkDebugProperties(){var s;return((s=this.Ge)==null?void 0:s.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(s,e){var t;return!((t=this.Ge)==null||!t.tryAddCustomEvent(s,e))}}},mE={autocapture:class{constructor(s){this.ar=!1,this.lr=null,this.ur=!1,this.instance=s,this.rageclicks=new ln(s.config.rageclick),this.hr=null}initialize(){this.startIfEnabled()}get N(){var s,e,t=_e(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(s=t.url_allowlist)==null?void 0:s.map((i=>new RegExp(i))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((i=>new RegExp(i))),t}dr(){if(this.isBrowserSupported()){if(_&&T){var s=t=>{t=t||_?.event;try{this.vr(t)}catch(i){qd.error("Failed to capture event",i)}};if(pe(T,"submit",s,{capture:!0}),pe(T,"change",s,{capture:!0}),pe(T,"click",s,{capture:!0}),this.N.capture_copied_text){var e=t=>{this.vr(t=t||_?.event,qo)};pe(T,"copy",e,{capture:!0}),pe(T,"cut",e,{capture:!0})}}}else qd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.ar&&(this.dr(),this.ar=!0)}onRemoteConfig(s){s.elementsChainAsString&&(this.ur=s.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[_d]:!!s.autocapture_opt_out}),this.lr=!!s.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(s){this.hr=s}getElementSelectors(s){var e,t=[];return(e=this.hr)==null||e.forEach((i=>{var r=T?.querySelectorAll(i);r?.forEach((n=>{s===n&&t.push(i)}))})),t}get isEnabled(){var s,e,t=(s=this.instance.persistence)==null?void 0:s.props[_d];if(St(this.lr)&&!bt(t)&&!this.instance.bt())return!1;var i=(e=this.lr)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!i}vr(s,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,i=Vd(s);ng(i)&&(i=i.parentNode||null),e==="$autocapture"&&s.type==="click"&&s instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,s.timeStamp||new Date().getTime())&&(function(h,f){if(!_||Ya(h))return!1;var g,v,p;if(bt(f)?(g=!!f&&Hd,v=void 0):(g=(p=f?.css_selector_ignorelist)!==null&&p!==void 0?p:Hd,v=f?.content_ignorelist),g===!1)return!1;var{targetElementList:m}=jd(h,!1);return!(function(b,E){if(b===!1||P(b))return!1;var N;if(b===!0)N=rE;else{if(!Y(b))return!1;if(b.length>10)return O.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;N=b.map((I=>I.toLowerCase()))}return E.some((I=>{var{safeText:R,ariaLabel:C}=I;return N.some((A=>R.includes(A)||C.includes(A)))}))})(v,m.map((b=>{var E;return{safeText:Oi(b).toLowerCase(),ariaLabel:((E=b.getAttribute("aria-label"))==null?void 0:E.toLowerCase().trim())||""}})))&&!Gd(m,g)})(i,this.instance.config.rageclick)&&this.vr(s,"$rageclick");var r=e===qo;if(i&&(function(h,f,g,v,p){var m,b,E,N;if(g===void 0&&(g=void 0),!_||Ya(h)||(m=g)!=null&&m.url_allowlist&&!Bd(g.url_allowlist)||(b=g)!=null&&b.url_ignorelist&&Bd(g.url_ignorelist))return!1;if((E=g)!=null&&E.dom_event_allowlist){var I=g.dom_event_allowlist;if(I&&!I.some((L=>f.type===L)))return!1}var{parentIsUsefulElement:R,targetElementList:C}=jd(h,v);if(!(function(L,z){var j=z?.element_allowlist;if(P(j))return!0;var V,S=function(F){if(j.some((M=>F.tagName.toLowerCase()===M)))return{v:!0}};for(var D of L)if(V=S(D))return V.v;return!1})(C,g)||!Gd(C,(N=g)==null?void 0:N.css_selector_allowlist))return!1;var A=_.getComputedStyle(h);if(A&&A.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0;var k=h.tagName.toLowerCase();switch(k){case"html":return!1;case"form":return(p||["submit"]).indexOf(f.type)>=0;case"input":case"select":case"textarea":return(p||["change","click"]).indexOf(f.type)>=0;default:return R?(p||["click"]).indexOf(f.type)>=0:(p||["click"]).indexOf(f.type)>=0&&(hl.indexOf(k)>-1||h.getAttribute("contenteditable")==="true")}})(i,s,this.N,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=dE(i,{e:s,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.N.element_attribute_ignorelist,elementsChainAsString:this.ur});if(o)return!1;var a=this.getElementSelectors(i);if(a&&a.length>0&&(n.$element_selectors=a),e===qo){var l,c=ag(_==null||(l=_.getSelection())==null?void 0:l.toString()),d=s.type||"clipboard";if(!c)return!1;n.$selected_content=c,n.$copy_type=d}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return yt(T?.querySelectorAll)}},historyAutocapture:class{constructor(s){var e;this._instance=s,this.cr=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(O.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.pr&&this.pr(),this.pr=void 0,O.info("History API monitoring stopped")}monitorHistoryChanges(){var s,e;if(_&&_.history){var t=this;(s=_.history.pushState)!=null&&s.__posthog_wrapped__||Kd(_.history,"pushState",(i=>function(r,n,o){i.call(this,r,n,o),t._r("pushState")})),(e=_.history.replaceState)!=null&&e.__posthog_wrapped__||Kd(_.history,"replaceState",(i=>function(r,n,o){i.call(this,r,n,o),t._r("replaceState")})),this.gr()}}_r(s){try{var e,t=_==null||(e=_.location)==null?void 0:e.pathname;if(!t)return;t!==this.cr&&this.isEnabled&&this._instance.capture(ws,{navigation_type:s}),this.cr=t}catch(i){O.error("Error capturing "+s+" pageview",i)}}gr(){if(!this.pr){var s=()=>{this._r("popstate")};pe(_,"popstate",s),this.pr=()=>{_&&_.removeEventListener("popstate",s)}}}},heatmaps:class{get N(){return this.instance.config}constructor(s){var e;this.mr=!1,this.ar=!1,this.br=null,this.instance=s,this.mr=!((e=this.instance.persistence)==null||!e.props[_a]),this.rageclicks=new ln(s.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var s=5e3;return _e(this.N.capture_heatmaps)&&this.N.capture_heatmaps.flush_interval_milliseconds&&(s=this.N.capture_heatmaps.flush_interval_milliseconds),s}get isEnabled(){return H(this.N.capture_heatmaps)?H(this.N.enable_heatmaps)?this.mr:this.N.enable_heatmaps:this.N.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ar)return;gE.info("starting..."),this.yr(),this.wr()}else{var s;clearInterval((s=this.br)!==null&&s!==void 0?s:void 0),this.Er(),this.getAndClearBuffer()}}onRemoteConfig(s){if("heatmaps"in s){var e=!!s.heatmaps;this.instance.persistence&&this.instance.persistence.register({[_a]:e}),this.mr=e,this.startIfEnabled()}}getAndClearBuffer(){var s=this.I;return this.I=void 0,s}Sr(s){this.Tr(s.originalEvent,"deadclick")}wr(){this.br&&clearInterval(this.br),this.br=T?.visibilityState==="visible"?setInterval(this.At.bind(this),this.flushIntervalMilliseconds):null}yr(){_&&T&&(this.$r=this.At.bind(this),pe(_,Wr,this.$r),this.kr=s=>this.Tr(s||_?.event),pe(T,"click",this.kr,{capture:!0}),this.Rr=s=>this.Pr(s||_?.event),pe(T,"mousemove",this.Rr,{capture:!0}),this.Or=new qr(this.instance,$b,this.Sr.bind(this)),this.Or.startIfEnabledOrStop(),this.Ir=this.wr.bind(this),pe(T,zr,this.Ir),this.ar=!0)}Er(){var s;_&&T&&(this.$r&&_.removeEventListener(Wr,this.$r),this.kr&&T.removeEventListener("click",this.kr,{capture:!0}),this.Rr&&T.removeEventListener("mousemove",this.Rr,{capture:!0}),this.Ir&&T.removeEventListener(zr,this.Ir),clearTimeout(this.Cr),(s=this.Or)==null||s.stop(),this.ar=!1)}Fr(s,e){var t=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var c=o;c&&dn(c)&&!$t(c,"body");){if(c===l)return!1;if(G(a,_?.getComputedStyle(c).position))return!0;c=lg(c)}return!1})(Vd(s),["fixed","sticky"],r);return{x:s.clientX+(n?0:i),y:s.clientY+(n?0:t),target_fixed:n,type:e}}Tr(s,e){var t;if(e===void 0&&(e="click"),!Ud(s.target)&&Xd(s)){var i=this.Fr(s,e);(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,new Date().getTime())&&this.Ar(w({},i,{type:"rageclick"})),this.Ar(i)}}Pr(s){!Ud(s.target)&&Xd(s)&&(clearTimeout(this.Cr),this.Cr=setTimeout((()=>{this.Ar(this.Fr(s,"mousemove"))}),500))}Ar(s){if(_){var e=_.location.href,t=this.N.custom_personal_data_properties,i=this.N.mask_personal_data_properties?[...xs,...t||[]]:[],r=Ti(e,i,Ii);this.I=this.I||{},this.I[r]||(this.I[r]=[]),this.I[r].push(s)}}At(){this.I&&!Ts(this.I)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:qr,webVitalsAutocapture:class{constructor(s){var e;this.mr=!1,this.ar=!1,this.I={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Mr=()=>{clearTimeout(this.Dr),this.I.metrics.length!==0&&(this._instance.capture("$web_vitals",this.I.metrics.reduce(((t,i)=>w({},t,{["$web_vitals_"+i.name+"_event"]:w({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.I={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Lr=t=>{var i,r=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(P(r))Pt.error("Could not read session ID. Dropping metrics!");else{this.I=this.I||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Ur();P(n)||(H(t?.name)||H(t?.value)?Pt.error("Invalid metric received",t):!this.Nr||this.Nr>t.value?(this.I.url!==n&&(this.Mr(),this.Dr=setTimeout(this.Mr,this.flushToCaptureTimeoutMs)),P(this.I.url)&&(this.I.url=n),this.I.firstMetricTimestamp=P(this.I.firstMetricTimestamp)?Date.now():this.I.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0),this.I.metrics.push(w({},t,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.I.metrics.length===this.allowedMetrics.length&&this.Mr()):Pt.error("Ignoring metric with value >= "+this.Nr,t))}},this.jr=()=>{if(!this.ar){var t,i,r,n,o=$.__PosthogExtensions__;P(o)||P(o.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:i,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),t&&i&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.Lr.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Lr.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Lr.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.Lr.bind(this)),this.ar=!0):Pt.error("web vitals callbacks not loaded - not starting")}},this._instance=s,this.mr=!((e=this._instance.persistence)==null||!e.props[bd]),this.startIfEnabled()}get zr(){return this._instance.config.capture_performance}get allowedMetrics(){var s,e,t=_e(this.zr)?(s=this.zr)==null?void 0:s.web_vitals_allowed_metrics:void 0;return H(t)?((e=this._instance.persistence)==null?void 0:e.props[Sd])||["CLS","FCP","INP","LCP"]:t}get flushToCaptureTimeoutMs(){return(_e(this.zr)?this.zr.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var s=_e(this.zr)?this.zr.web_vitals_attribution:void 0;return s!=null&&s}get Nr(){var s=_e(this.zr)&&lt(this.zr.__web_vitals_max_value)?this.zr.__web_vitals_max_value:Yd;return s>0&&6e4>=s?Yd:s}get isEnabled(){var s=ke?.protocol;if(s!=="http:"&&s!=="https:")return Pt.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=_e(this.zr)?this.zr.web_vitals:bt(this.zr)?this.zr:void 0;return bt(e)?e:this.mr}startIfEnabled(){this.isEnabled&&!this.ar&&(Pt.info("enabled, starting..."),this.Y(this.jr))}onRemoteConfig(s){if("capturePerformance"in s){var e=_e(s.capturePerformance)&&!!s.capturePerformance.web_vitals,t=_e(s.capturePerformance)?s.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[bd]:e}),this._instance.persistence.register({[Sd]:t})),this.mr=e,this.startIfEnabled()}}Y(s){var e,t;(e=$.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?s():(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(i=>{i?Pt.error("failed to load script",i):s()}))}Ur(){var s=_?_.location.href:void 0;if(s){var e=this._instance.config.custom_personal_data_properties,t=this._instance.config.mask_personal_data_properties?[...xs,...e||[]]:[];return Ti(s,t,Ii)}Pt.error("Could not determine current URL")}}},yE={exceptionObserver:class{constructor(s){var e,t,i;this.jr=()=>{var r;if(_&&this.isEnabled&&(r=$.__PosthogExtensions__)!=null&&r.errorWrappingFunctions){var n=$.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=$.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=$.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Br&&this.N.capture_unhandled_errors&&(this.Br=n(this.captureException.bind(this))),!this.Hr&&this.N.capture_unhandled_rejections&&(this.Hr=o(this.captureException.bind(this))),!this.qr&&this.N.capture_console_errors&&(this.qr=a(this.captureException.bind(this)))}catch(l){ci.error("failed to start",l),this.Wr()}}},this._instance=s,this.Vr=!((e=this._instance.persistence)==null||!e.props[md]),this.Yr=new ia({refillRate:(t=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&t!==void 0?t:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,h:ci}),this.N=this.Gr(),this.startIfEnabledOrStop()}Gr(){var s=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return _e(s)?e=w({},e,s):(P(s)?this.Vr:s)&&(e=w({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.N.capture_console_errors||this.N.capture_unhandled_errors||this.N.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ci.info("enabled"),this.Wr(),this.Y(this.jr)):this.Wr()}Y(s){var e,t;(e=$.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&s(),(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return ci.error("failed to load script",i);s()}))}Wr(){var s,e,t;(s=this.Br)==null||s.call(this),this.Br=void 0,(e=this.Hr)==null||e.call(this),this.Hr=void 0,(t=this.qr)==null||t.call(this),this.qr=void 0}onRemoteConfig(s){"autocaptureExceptions"in s&&(this.Vr=!!s.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[md]:this.Vr}),this.N=this.Gr(),this.startIfEnabledOrStop())}onConfigChange(){this.N=this.Gr()}captureException(s){var e,t,i,r=(e=s==null||(t=s.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.Yr.consumeRateLimit(r)?ci.info("Skipping exception capture because of client rate limiting.",{exception:r}):(i=this._instance.exceptions)==null||i.sendExceptionEvent(s)}},exceptions:class{constructor(s){var e,t;this.Jr=[],this.Kr=new aa([new ca,new va,new da,new ua,new fa,new ga,new ha,new pa],(function(i){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 c=[],d=a.split(`
6
- `),h=l;d.length>h;h++){var f=d[h];if(1024>=f.length){var g=pd.test(f)?f.replace(pd,"$1"):f;if(!g.match(/\S*Error: /)){for(var v of n){var p=v(g,i);if(p){c.push(p);break}}if(c.length>=50)break}}}return(function(m){if(!m.length)return[];var b=Array.from(m);return b.reverse(),b.slice(0,50).map((E=>{return w({},E,{filename:E.filename||(N=b,N[N.length-1]||{}).filename,function:E.function||Ds});var N}))})(c)}})("web:javascript",Eb,wb)),this._instance=s,this.Jr=(e=(t=this._instance.persistence)==null?void 0:t.get_property(ma))!==null&&e!==void 0?e:[]}onRemoteConfig(s){var e,t,i;if("errorTracking"in s){var r=(e=(t=s.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],n=(i=s.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Jr=r,this._instance.persistence&&this._instance.persistence.register({[ma]:this.Jr,[yd]:n})}}get Xr(){var s,e=!!this._instance.get_property(yd),t=this._instance.config.error_tracking.captureExtensionExceptions;return(s=t??e)!==null&&s!==void 0&&s}buildProperties(s,e){return this.Kr.buildFromUnknown(s,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}sendExceptionEvent(s){var e=s.$exception_list;if(this.Qr(e)){if(this.Zr(e))return void Zo.info("Skipping exception capture because a suppression rule matched");if(!this.Xr&&this.ts(e))return void Zo.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.es(e))return void Zo.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",Ui:!0})}Zr(s){if(s.length===0)return!1;var e=s.reduce(((t,i)=>{var{type:r,value:n}=i;return ve(r)&&r.length>0&&t.$exception_types.push(r),ve(n)&&n.length>0&&t.$exception_values.push(n),t}),{$exception_types:[],$exception_values:[]});return this.Jr.some((t=>{var i=t.values.map((r=>{var n,o=tg[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 t.type==="OR"?i.some(Boolean):i.every(Boolean)}))}ts(s){return s.flatMap((e=>{var t,i;return(t=(i=e.stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}es(s){if(s.length>0){var e,t,i,r,n=(e=(t=s[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(i=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}Qr(s){return!H(s)&&Y(s)}}},bE=w({productTours:class{get Wt(){return this._instance.persistence}constructor(s){this.rs=null,this.ss=null,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){"productTours"in s&&(this.Wt&&this.Wt.register({[Ed]:!!s.productTours}),this.loadIfEnabled())}loadIfEnabled(){var s,e;this.rs||(s=this._instance).config.disable_product_tours||(e=s.persistence)==null||!e.get_property(Ed)||this.Y((()=>this.ns()))}Y(s){var e,t;(e=$.__PosthogExtensions__)!=null&&e.generateProductTours?s():(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(i=>{i?Zd.error("Could not load product tours script",i):s()}))}ns(){var s;!this.rs&&(s=$.__PosthogExtensions__)!=null&&s.generateProductTours&&(this.rs=$.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(s,e){if(e===void 0&&(e=!1),!Y(this.ss)||e){var t=this.Wt;if(t){var i=t.props[Yo];if(Y(i)&&!e)return this.ss=i,void s(i,{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 Zd.error(o),void s([],{isLoaded:!1,error:o})}var a=Y(r.json.product_tours)?r.json.product_tours:[];this.ss=a,t&&t.register({[Yo]:a}),s(a,{isLoaded:!0})}})}else s(this.ss,{isLoaded:!0})}getActiveProductTours(s){H(this.rs)?s([],{isLoaded:!1,error:"Product tours not loaded"}):this.rs.getActiveProductTours(s)}showProductTour(s){var e;(e=this.rs)==null||e.showTourById(s)}previewTour(s){this.rs?this.rs.previewTour(s):this.Y((()=>{var e;this.ns(),(e=this.rs)==null||e.previewTour(s)}))}dismissProductTour(){var s;(s=this.rs)==null||s.dismissTour("user_clicked_skip")}nextStep(){var s;(s=this.rs)==null||s.nextStep()}previousStep(){var s;(s=this.rs)==null||s.previousStep()}clearCache(){var s;this.ss=null,(s=this.Wt)==null||s.unregister(Yo)}resetTour(s){var e;(e=this.rs)==null||e.resetTour(s)}resetAllTours(){var s;(s=this.rs)==null||s.resetAllTours()}cancelPendingTour(s){var e;(e=this.rs)==null||e.cancelPendingTour(s)}}},hn),EE={siteApps:class{constructor(s){this._instance=s,this.os=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ls(s,e){if(e){var t=this.globalsForEvent(e);this.os.push(t),this.os.length>1e3&&(this.os=this.os.slice(10))}}get siteAppLoaders(){var s;return(s=$._POSTHOG_REMOTE_CONFIG)==null||(s=s[this._instance.config.token])==null?void 0:s.siteApps}initialize(){if(this.isEnabled){var s=this._instance._addCaptureHook(this.ls.bind(this));this.us=()=>{s(),this.os=[],this.us=void 0}}}globalsForEvent(s){var e,t,i,r,n,o,a;if(!s)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var[h,f]of Object.entries(d))l[h]={id:c[h],type:h,properties:f};var{$set_once:g,$set:v}=s;return{event:w({},uh(s,fE),{properties:w({},s.properties,v?{$set:w({},(e=(t=s.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},v)}:{},g?{$set_once:w({},(i=(r=s.properties)==null?void 0:r.$set_once)!==null&&i!==void 0?i:{},g)}:{}),elements_chain:(n=(o=s.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=s.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(s){var e=this.apps[s.id],t=()=>{var o;!e.errored&&this.os.length&&(Dt.info("Processing "+this.os.length+" events for site app with id "+s.id),this.os.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.us)==null||o.call(this))},i=!1,r=o=>{e.errored=!o,e.loaded=!0,Dt.info("Site app with id "+s.id+" "+(o?"loaded":"errored")),i&&t()};try{var{processEvent:n}=s.init({posthog:this._instance,callback(o){r(o)}});n&&(e.processEvent=n),i=!0}catch(o){Dt.error(eh+s.id,o),r(!1)}if(i&&e.loaded)try{t()}catch(o){Dt.error("Error while processing buffered events PostHog app with config id "+s.id,o),e.errored=!0}}hs(){var s=this.siteAppLoaders||[];for(var e of s)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of s)this.setupSiteApp(t)}ds(s){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(s);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(i){Dt.error("Error while processing event "+s.event+" for site app "+t.id,i)}}}onRemoteConfig(s){var e,t,i,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.hs(),void this._instance.on("eventCaptured",(l=>this.ds(l)))):void Dt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.us)==null||t.call(this),(i=s.siteApps)!=null&&i.length)if(this.isEnabled){var n=function(l){var c;$["__$$ph_site_app_"+l]=r._instance,(c=$.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(r._instance,a,(d=>{if(d)return Dt.error(eh+l,d)}))};for(var{id:o,url:a}of s.siteApps)n(o)}else Dt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},SE={tracingHeaders:class{constructor(s){this.vs=void 0,this.cs=void 0,this.jr=()=>{var e,t;P(this.vs)&&((e=$.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),P(this.cs)&&((t=$.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=s}initialize(){this.startIfEnabledOrStop()}Y(s){var e,t;(e=$.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&s(),(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return hE.error("failed to load script",i);s()}))}startIfEnabledOrStop(){var s,e;this._instance.config.__add_tracing_headers?this.Y(this.jr):((s=this.vs)==null||s.call(this),(e=this.cs)==null||e.call(this),this.vs=void 0,this.cs=void 0)}}},kE=w({surveys:class{get N(){return this._instance.config}constructor(s){this.fs=void 0,this._surveyManager=null,this.ps=!1,this._s=[],this.gs=null,this._instance=s,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(!this.N.disable_surveys){var e=s.surveys;if(H(e))return ie.warn("Flags not loaded yet. Not loading surveys.");var t=Y(e);this.fs=t?e.length>0:e,ie.info("flags response received, isSurveysEnabled: "+this.fs),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var s=[],e=0;e<localStorage.length;e++){var t=localStorage.key(e);(t!=null&&t.startsWith(za)||t!=null&&t.startsWith("inProgressSurvey_"))&&s.push(t)}s.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.ps)ie.info("Already initializing surveys, skipping...");else if(this.N.disable_surveys)ie.info(th);else if(this.N.cookieless_mode&&this._instance.consent.isOptedOut())ie.info("Not loading surveys in cookieless mode without consent.");else{var s=$?.__PosthogExtensions__;if(s){if(!P(this.fs)||this.N.advanced_enable_surveys){var e=this.fs||this.N.advanced_enable_surveys;this.ps=!0;try{var t=s.generateSurveys;if(t)return void this.bs(t,e);var i=s.loadExternalDependency;if(!i)return void this.ys(al);i(this._instance,"surveys",(r=>{r||!s.generateSurveys?this.ys("Could not load surveys script",r):this.bs(s.generateSurveys,e)}))}catch(r){throw this.ys("Error initializing surveys",r),r}finally{this.ps=!1}}}else ie.error("PostHog Extensions not found.")}}bs(s,e){this._surveyManager=s(this._instance,e),this._surveyEventReceiver=new el(this._instance),ie.info("Surveys loaded successfully"),this.ws({isLoaded:!0})}ys(s,e){ie.error(s,e),this.ws({isLoaded:!1,error:s})}onSurveysLoaded(s){return this._s.push(s),this._surveyManager&&this.ws({isLoaded:!0}),()=>{this._s=this._s.filter((e=>e!==s))}}getSurveys(s,e){if(e===void 0&&(e=!1),this.N.disable_surveys)return ie.info(th),s([]);var t,i=this._instance.get_property(ba);if(i&&!e)return s(i,{isLoaded:!0});typeof Promise<"u"&&this.gs?this.gs.then((r=>{var{surveys:n,context:o}=r;return s(n,o)})):(typeof Promise<"u"&&(this.gs=new Promise((r=>{t=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.N.token),method:"GET",timeout:this.N.surveys_request_timeout_ms,callback:r=>{var n;this.gs=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;ie.error(a);var l={isLoaded:!1,error:a};return s([],l),void(t==null||t({surveys:[],context:l}))}var c,d=r.json.surveys||[],h=d.filter((g=>(function(v){return!(!v.start_date||v.end_date)})(g)&&((function(v){var p;return!((p=v.conditions)==null||(p=p.events)==null||(p=p.values)==null||!p.length)})(g)||(function(v){var p;return!((p=v.conditions)==null||(p=p.actions)==null||(p=p.values)==null||!p.length)})(g))));h.length>0&&((c=this._surveyEventReceiver)==null||c.register(h)),(n=this._instance.persistence)==null||n.register({[ba]:d});var f={isLoaded:!0};s(d,f),t?.({surveys:d,context:f})}}))}ws(s){for(var e of this._s)try{if(!s.isLoaded)return e([],s);this.getSurveys(e)}catch(t){ie.error("Error in survey callback",t)}}getActiveMatchingSurveys(s,e){if(e===void 0&&(e=!1),!H(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(s,e);ie.warn("init was not called")}Es(s){var e=null;return this.getSurveys((t=>{var i;e=(i=t.find((r=>r.id===s)))!==null&&i!==void 0?i:null})),e}Ss(s){if(H(this._surveyManager))return{eligible:!1,reason:Jo};var e=typeof s=="string"?this.Es(s):s;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(s){if(H(this._surveyManager))return ie.warn("init was not called"),{visible:!1,disabledReason:Jo};var e=this.Ss(s);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(s,e){return H(this._surveyManager)?(ie.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Jo})):new Promise((t=>{this.getSurveys((i=>{var r,n=(r=i.find((a=>a.id===s)))!==null&&r!==void 0?r:null;if(n){var o=this.Ss(n);t({visible:o.eligible,disabledReason:o.reason})}else t({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(s,e,t){var i;if(H(this._surveyManager))ie.warn("init was not called");else{var r=typeof s=="string"?this.Es(s):s;if(r!=null&&r.id)if(Zb.includes(r.type)){var n=T?.querySelector(e);if(n)return(i=r.appearance)!=null&&i.surveyPopupDelaySeconds?(ie.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;ie.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,t),ie.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,t);ie.warn("Survey element not found")}else ie.warn("Surveys of type "+r.type+" cannot be rendered in the app");else ie.warn("Survey not found")}}displaySurvey(s,e){var t;if(H(this._surveyManager))ie.warn("init was not called");else{var i=this.Es(s);if(i){var r=i;if((t=i.appearance)!=null&&t.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=w({},i,{appearance:w({},i.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Da.Popover&&e.initialResponses&&ie.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(i);if(!n.visible)return void ie.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==Da.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else ie.warn("Survey not found")}}cancelPendingSurvey(s){H(this._surveyManager)?ie.warn("init was not called"):this._surveyManager.cancelSurvey(s)}handlePageUnload(){var s;(s=this._surveyManager)==null||s.handlePageUnload()}}},hn),wE={toolbar:class{constructor(s){this.instance=s}xs(s){$.ph_toolbar_state=s}Ts(){var s;return(s=$.ph_toolbar_state)!==null&&s!==void 0?s:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(s,e,t){if(s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),Mh(this.instance.config)||!_||!T)return!1;s=s??_.location,t=t??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var i,r=pE||Qr(s.hash,"__posthog")||Qr(s.hash,"state"),n=r?wd((()=>JSON.parse(atob(decodeURIComponent(r)))))||wd((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((i=n).source="url",i&&Object.keys(i).length>0&&(n.desiredHash?s.hash=n.desiredHash:t?t.replaceState(t.state,"",s.pathname+s.search):s.hash="")):((i=JSON.parse(e.getItem(sh)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}$s(s){var e=$.ph_load_toolbar||$.ph_load_editor;!H(e)&&yt(e)?e(s,this.instance):ih.warn("No toolbar load function found")}loadToolbar(s){var e=!(T==null||!T.getElementById(Fh));if(!_||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=w({token:this.instance.config.token},s,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(_.localStorage.setItem(sh,JSON.stringify(w({},i,{source:void 0}))),this.Ts()===2)this.$s(i);else if(this.Ts()===0){var r;this.xs(1),(r=$.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return ih.error("[Toolbar] Failed to load",n),void this.xs(0);this.xs(2),this.$s(i)})),pe(_,"turbolinks:load",(()=>{this.xs(0),this.loadToolbar(i)}))}return!0}ks(s){return this.loadToolbar(s)}maybeLoadEditor(s,e,t){return s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(s,e,t)}}},AE=w({experiments:tl},hn),TE={conversations:class{constructor(s){this.Rs=void 0,this._conversationsManager=null,this.Ps=!1,this.Os=null,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(!this._instance.config.disable_conversations){var e=s.conversations;H(e)||(bt(e)?this.Rs=e:(this.Rs=e.enabled,this.Os=e),this.loadIfEnabled())}}reset(){var s;(s=this._conversationsManager)==null||s.reset(),this._conversationsManager=null,this.Rs=void 0,this.Os=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ps||this._instance.config.disable_conversations||Mh(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var s=$?.__PosthogExtensions__;if(s&&!P(this.Rs)&&this.Rs)if(this.Os&&this.Os.token){this.Ps=!0;try{var e=s.initConversations;if(e)return this.Is(e),void(this.Ps=!1);var t=s.loadExternalDependency;if(!t)return void this.Cs(al);t(this._instance,"conversations",(i=>{i||!s.initConversations?this.Cs("Could not load conversations script",i):this.Is(s.initConversations),this.Ps=!1}))}catch(i){this.Cs("Error initializing conversations",i),this.Ps=!1}}else ze.error("Conversations enabled but missing token in remote config.")}}Is(s){if(this.Os)try{this._conversationsManager=s(this.Os,this._instance),ze.info("Conversations loaded successfully")}catch(e){this.Cs("Error completing conversations initialization",e)}else ze.error("Cannot complete initialization: remote config is null")}Cs(s,e){ze.error(s,e),this._conversationsManager=null,this.Ps=!1}show(){this._conversationsManager?this._conversationsManager.show():ze.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Rs===!0&&!St(this._conversationsManager)}isVisible(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&s!==void 0&&s}sendMessage(s,e,t){var i=this;return Ze((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(s,e,t):(ze.warn(Qt),null)}))()}getMessages(s,e){var t=this;return Ze((function*(){return t._conversationsManager?t._conversationsManager.getMessages(s,e):(ze.warn(Qt),null)}))()}markAsRead(s){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(s):(ze.warn(Qt),null)}))()}getTickets(s){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.getTickets(s):(ze.warn(Qt),null)}))()}requestRestoreLink(s){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(s):(ze.warn(Qt),null)}))()}restoreFromToken(s){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(s):(ze.warn(Qt),null)}))()}restoreFromUrlToken(){var s=this;return Ze((function*(){return s._conversationsManager?s._conversationsManager.restoreFromUrlToken():(ze.warn(Qt),null)}))()}getCurrentTicketId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&s!==void 0?s:null}getWidgetSessionId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&s!==void 0?s:null}}},IE={logs:class{constructor(s){var e;this.Fs=!1,this.As=!1,this._instance=s,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Fs=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(s){var e,t=(e=s.logs)==null?void 0:e.captureConsoleLogs;!H(t)&&t&&(this.Fs=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Fs&&!this.As){var s=he("[logs]"),e=$?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(i=>{var r;i||(r=e.logs)==null||!r.initializeLogs?s.error("Could not load logs script",i):(e.logs.initializeLogs(this._instance),this.As=!0)})):s.error(al)}else s.error("PostHog Extensions not found.")}}}},RE=w({},hn,_E,mE,yE,bE,EE,kE,SE,wE,AE,TE,IE);$s.__defaultExtensionClasses=w({},RE);kt=(ch=Si[As]=new $s,(function(){function s(){s.done||(s.done=!0,rg=!1,ae(Si,(function(e){e._dom_loaded()})))}T!=null&&T.addEventListener?T.readyState==="complete"?s():pe(T,"DOMContentLoaded",s,{capture:!1}):_&&O.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),ch)});var fg={};pn(fg,{Posthog:()=>gl});var ts,gl,pg=Pe(()=>{"use strict";gg();qs();Ys();ts=class ts{constructor(e,t=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=Rt("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let t=`ph_${e}_posthog`,i=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==t);if(i.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;i.forEach(a=>{[o,r,""].forEach(c=>{let d=c?`; Domain=${c}`:"";document.cookie=`${a}=; path=/${d}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(c=>c.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:t,config:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.cleanupStalePosthogCookies(e);let r=t||tu();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:eu,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...i.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=su.some(c=>a.endsWith(`.${c}`)||a===c);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...i};kt.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,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let i=typeof kt._isIdentified=="function"?kt._isIdentified():this.has_identified;e&&!i?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),kt.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),kt.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,language:i,country_of_residence:r})=>{if(!(!this.has_initialized||!e))try{let n=kt.get_property("$stored_person_properties")??{},o={};n.client_id||(o.client_id=e),t&&n.is_internal===void 0&&(o.is_internal=nr(t)),i&&!n.language&&(o.language=i),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}),kt.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,t)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:t}),kt.capture(e,t)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.options=e,this.debug=t,this.init()}};ts.getPosthogInstance=(e,t=!1)=>(ts._instance||(ts._instance=new ts(e,t)),ts._instance);gl=ts});var CE={};pn(CE,{Analytics:()=>vg});ho();qs();Ys();var Zm=4320*60*60,zt=class zt{constructor(e,t,i=!1){this.analytics=new us;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=Rt("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let t=window.location.hostname,n=["webflow.io"].some(c=>t.endsWith(c))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let c=new Uint8Array(16);crypto.getRandomValues(c),c[6]=c[6]&15|64,c[8]=c[8]&63|128;let d=Array.from(c,h=>h.toString(16).padStart(2,"0")).join("");o=`${d.slice(0,8)}-${d.slice(8,12)}-${d.slice(12,16)}-${d.slice(16,20)}-${d.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=${Zm}; SameSite=Lax${l}`}catch(t){console.warn("RudderStack: Failed to set anonymous ID cookie",t)}};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:go});try{this.setCookieIfNotExists(),this.analytics.load(e,go,{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(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let i=this.getUserId();if(!i||i!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:t}),this.analytics.identify(e,t||{}),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,t="Deriv App",i,r)=>{if(!(!this.has_initialized||e===this.current_page))try{let n={...i&&{user_id:i},...r};this.log("pageView | tracking page view",{platform:t,current_page:e,properties:n}),this.analytics.page(t,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,t)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:t}),this.analytics.track(e,t)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=t,this.debug=i,this.init(e)}};zt.getRudderStackInstance=(e,t,i=!1)=>(zt._instance||(zt._instance=new zt(e,t,i)),zt._instance);var or=zt;var ar="cached_analytics_events",lr="cached_analytics_page_views",cu=(s,e)=>{try{let t=localStorage.getItem(ar),i=t?JSON.parse(t):[];i.push({name:s,properties:e,timestamp:Date.now()}),localStorage.setItem(ar,JSON.stringify(i))}catch(t){console.warn("Analytics: Failed to cache event",t)}},uu=(s,e)=>{try{let t=localStorage.getItem(lr),i=t?JSON.parse(t):[];i.push({name:s,properties:e,timestamp:Date.now()}),localStorage.setItem(lr,JSON.stringify(i))}catch(t){console.warn("Analytics: Failed to cache page view",t)}},du=()=>{try{let s=localStorage.getItem(ar);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached events",s)}return[]},hu=()=>{try{let s=localStorage.getItem(lr);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached pages",s)}return[]},gu=()=>{try{localStorage.removeItem(ar)}catch(s){console.warn("Analytics: Failed to clear cached events",s)}},fu=()=>{try{localStorage.removeItem(lr)}catch(s){console.warn("Analytics: Failed to clear cached page views",s)}};Ys();function OE(s){let e=s?.debug??!1,t=Rt("",()=>e),i,r,n,o={},a={},l=[],c=[],d=!1,h=()=>{if(!d&&r?.has_initialized){d=!0;try{let S=du();S.length>0&&(t(`processStorageCache | replaying ${S.length} cached event(s)`,S),S.forEach(F=>{let M=jt(F.properties);r?.track(F.name,M)}),gu());let D=hu();D.length>0&&(t(`processStorageCache | replaying ${D.length} cached page view(s)`,D),D.forEach(F=>{r?.pageView(F.name,"Deriv App",I(),F.properties)}),fu())}catch(S){console.warn("Analytics: Failed to process storage cache",S)}}},f=()=>{t("onSdkLoaded | RudderStack SDK loaded"),h(),c.length>0&&t(`onSdkLoaded | flushing ${c.length} pending identify call(s)`),c.forEach(({userId:S,traits:D})=>{S&&r?.identifyEvent(S,D)}),c=[]},g=async({growthbookKey:S,growthbookDecryptionKey:D,rudderstackKey:F,growthbookOptions:M,posthogOptions:Q,debug:W})=>{var X,ee;W!==void 0&&(e=W),t("initialise | starting analytics initialization",{rudderstack:!!F,growthbook:!!S,posthog:!!Q});try{let te=M?.attributes?.country||(S?await ou():void 0);if(F&&(t("initialise | initializing RudderStack"),r=or.getRudderStackInstance(F,f,e)),M?.attributes&&Object.keys(M.attributes).length>0){let U=M.attributes,Ae=r?.getAnonymousId();o={...o,country:te,...U.user_language&&{user_language:U.user_language},...U.account_type&&{account_type:U.account_type},...U.app_id&&{app_id:U.app_id},...U.residence_country&&{residence_country:U.residence_country},...U.device_type&&{device_type:U.device_type},...U.url&&{url:U.url},...U.email_hash&&{email_hash:U.email_hash},...U.network_type&&{network_type:U.network_type},...U.network_rtt&&{network_rtt:U.network_rtt},...U.network_downlink&&{network_downlink:U.network_downlink},...U.account_currency&&{account_currency:U.account_currency},...U.account_mode&&{account_mode:U.account_mode},loggedIn:!!U.loggedIn,...U.user_id&&!Ks(U.user_id)&&{user_id:U.user_id},...Ae&&{anonymous_id:Ae}}}M??(M={}),M.attributes??(M.attributes={});let ye=r?.getAnonymousId();if((X=M.attributes).id??(X.id=ye),(ee=M.attributes).country??(ee.country=te),S){t("initialise | initializing GrowthBook");let{Growthbook:U}=await Promise.resolve().then(()=>(od(),nd));i=U.getGrowthBookInstance(S,D,M,e),t("initialise | GrowthBook initialized");let Ae=setInterval(()=>{Object.keys(a).length>0?clearInterval(Ae):a=m("tracking-buttons-config",{})},1e3)}if(Q){t("initialise | initializing PostHog");let{Posthog:U}=await Promise.resolve().then(()=>(pg(),fg));n=U.getPosthogInstance(Q,e),t("initialise | PostHog initialized")}t("initialise | analytics initialization complete")}catch(te){console.warn("Analytics: Failed to initialize",te)}},v=S=>{t("setAttributes | received attributes",S);let{user_id:D,...F}=S,M=D??I();if(i){let Q={...F};D&&!Ks(D)&&(Q.user_id=D),M&&(Q.id=M,Q.user_id=M),t("setAttributes | called GrowthBook setAttributes",Q),i.setAttributes(Q)}o={...o,...Object.fromEntries(Object.entries(F).filter(([,Q])=>Q!==void 0)),...D!==void 0&&!Ks(D)&&{user_id:D}},t("setAttributes | updated core_data",o)},p=S=>i?.getFeatureState(S)?.experimentResult?.name,m=(S,D)=>i?.getFeatureValue(S,D),b=async()=>await i?.getStatus(),E=S=>i?.isOn(S),N=S=>i?.setUrl(S),I=()=>{let S=r?.getUserId()||"";return S&&!Ks(S)?S:""},V={initialise:g,setAttributes:v,identifyEvent:(S,D)=>{let F=S||I();if(!F){t("identifyEvent | skipped \u2014 no user_id available");return}t("identifyEvent | called",{user_id:F,traits:D});let M=ee=>{if(!ee)return ee;let{email:te,...ye}=ee;return{...ye,...te&&{is_internal:nr(te)}}},Q=D?.rudderstack!==void 0||D?.posthog!==void 0,W,X;if(Q){let{rudderstack:ee,posthog:te,...ye}=D;W=M({...ye,...ee}),X=M({...ye,...te})}else W=M(D),X=M(D);r&&(r.has_initialized?(t("identifyEvent | calling RudderStack identify",{user_id:F,traits:W}),r.identifyEvent(F,W)):c.some(ee=>ee.userId===F)||(t("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:F}),c.push({userId:F,traits:W}))),n?.has_initialized&&X&&(t("identifyEvent | calling PostHog identify",{user_id:F,traits:X}),n.identifyEvent(F,X))},backfillPersonProperties:({user_id:S,email:D,language:F,country_of_residence:M})=>{t("backfillPersonProperties | called",{user_id:S}),n?.has_initialized?(t("backfillPersonProperties | backfilling person properties in PostHog",{user_id:S}),n.backfillPersonProperties({user_id:S,email:D,language:F,country_of_residence:M})):t("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:p,getFeatureValue:m,getGrowthbookStatus:b,isFeatureOn:E,setUrl:N,getId:I,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(S,D)=>{let F=I();t("trackEvent | called",{event:S,analytics_data:D,userId:F,core_data:o});let M={...o,...D,...F&&!o.user_id&&{user_id:F}};if(t("trackEvent | built payload",{event:S,final_payload:M}),!(!(S in a)||a[S])){t("trackEvent | skipped \u2014 event disabled by tracking_config",{event:S});return}let W=r?.has_initialized;if(!navigator.onLine||!W)W?(t("trackEvent | offline \u2014 caching event to memory",{event:S}),l.push({event:S,payload:M})):(t("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:S}),cu(S,M));else{l.length>0&&(t(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(ee=>{let te=jt(ee.payload);r?.track(ee.event,te)}),l=[]);let X=jt(M);t("trackEvent | sending event to RudderStack",{event:S,payload:X}),r?.track(S,X)}if(n?.has_initialized){let X=["page_name","user_language","form_name","version","email_hash"],ee=lu(M),te=jt(Object.fromEntries(Object.entries(ee).filter(([ye])=>!X.includes(ye))));t("trackEvent | sending event to PostHog",{event:S,payload:te}),n.capture(S,te)}},getInstances:()=>({ab:i,tracking:r,posthog:n}),pageView:(S,D="Deriv App",F)=>{let M=I();t("pageView | called",{current_page:S,platform:D,properties:F,userId:M}),r?.has_initialized?(t("pageView | sending page view to RudderStack",{current_page:S,platform:D}),r.pageView(S,D,M,F)):(t("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:S}),uu(S,{platform:D,...F}))},reset:()=>{t("reset | resetting all providers"),r?.has_initialized&&(t("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(t("reset | resetting PostHog"),n.reset())}};return typeof window<"u"&&(window.AnalyticsInstance=V),V}var vg=OE();return Ig(CE);})();
2
+ "use strict";var DerivAnalytics=(()=>{var Di=Object.defineProperty;var Sg=Object.getOwnPropertyDescriptor;var kg=Object.getOwnPropertyNames;var wg=Object.prototype.hasOwnProperty;var Tg=(s,e,t)=>e in s?Di(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Pe=(s,e)=>()=>(s&&(e=s(s=0)),e);var pn=(s,e)=>{for(var t in e)Di(s,t,{get:e[t],enumerable:!0})},Ag=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of kg(e))!wg.call(s,r)&&r!==t&&Di(s,r,{get:()=>e[r],enumerable:!(i=Sg(e,r))||i.enumerable});return s};var Rg=s=>Ag(Di({},"__esModule",{value:!0}),s);var le=(s,e,t)=>Tg(s,typeof e!="symbol"?e+"":e,t);function ue(s){return s!=null&&typeof s=="object"&&s["@@functional/placeholder"]===!0}function ht(s){return function e(t){return arguments.length===0||ue(t)?e:s.apply(this,arguments)}}function Tt(s){return function e(t,i){switch(arguments.length){case 0:return e;case 1:return ue(t)?e:ht(function(r){return s(t,r)});default:return ue(t)&&ue(i)?e:ue(t)?ht(function(r){return s(r,i)}):ue(i)?ht(function(r){return s(t,r)}):s(t,i)}}}function eo(s){return function e(t,i,r){switch(arguments.length){case 0:return e;case 1:return ue(t)?e:Tt(function(n,o){return s(t,n,o)});case 2:return ue(t)&&ue(i)?e:ue(t)?Tt(function(n,o){return s(n,i,o)}):ue(i)?Tt(function(n,o){return s(t,n,o)}):ht(function(n){return s(t,i,n)});default:return ue(t)&&ue(i)&&ue(r)?e:ue(t)&&ue(i)?Tt(function(n,o){return s(n,o,r)}):ue(t)&&ue(r)?Tt(function(n,o){return s(n,i,o)}):ue(i)&&ue(r)?Tt(function(n,o){return s(t,n,o)}):ue(t)?ht(function(n){return s(n,i,r)}):ue(i)?ht(function(n){return s(t,n,r)}):ue(r)?ht(function(n){return s(t,i,n)}):s(t,i,r)}}}function Ni(s,e){return Object.prototype.hasOwnProperty.call(e,s)}function ml(s){return Object.prototype.toString.call(s)==="[object Object]"}function Cg(s,e){var t=s<0?e.length+s:s;return e[t]}function Pg(s){return new RegExp(s.source,s.flags?s.flags:(s.global?"g":"")+(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.sticky?"y":"")+(s.unicode?"u":"")+(s.dotAll?"s":""))}function Zl(s,e,t){if(t||(t=new Ng),Dg(s))return s;var i=function(n){var o=t.get(s);if(o)return o;t.set(s,n);for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(n[a]=Zl(s[a],!0,t));return n};switch(Ig(s)){case"Object":return i(Object.create(Object.getPrototypeOf(s)));case"Array":return i(Array(s.length));case"Date":return new Date(s.valueOf());case"RegExp":return Pg(s);case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return s.slice();default:return s}}function Dg(s){var e=typeof s;return s==null||e!="object"&&e!="function"}function xg(s,e){for(var t=e,i=0;i<s.length;i+=1){if(t==null)return;var r=s[i];Og(r)?t=Cg(r,t):t=t[r]}return t}function Zg(s){return crypto.getRandomValues(new Uint8Array(s))}function ef(){(!mn||At+16>bl)&&(mn=Zg(bl),At=0);for(var s=0,e,t="";s<16;s++)e=mn[At+s],s==6?t+=Fi[e&15|64]:s==8?t+=Fi[e&63|128]:t+=Fi[e],s&1&&s>1&&s<11&&(t+="-");return At+=16,t}function tf(){var s=0,e,t="";if(!Li||Gt+16>256){for(Li=Array(s=256);s--;)Li[s]=256*Math.random()|0;s=Gt=0}for(;s<16;s++)e=Li[Gt+s],s==6?t+=Mi[e&15|64]:s==8?t+=Mi[e&63|128]:t+=Mi[e],s&1&&s>1&&s<11&&(t+="-");return Gt++,t}function Cf(s,e,t=Of){let i;return(...r)=>{globalThis.clearTimeout(i),i=globalThis.setTimeout(()=>{s.apply(e,r)},t)}}function er(){if(gt>1)gt--;else{var s,e=!1;for((function(){var r=Wi;for(Wi=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o})();js!==void 0;){var t=js;for(js=void 0,qi++;t!==void 0;){var i=t.u;if(t.u=void 0,t.f&=-3,!(8&t.f)&&fc(t))try{t.c()}catch(r){e||(s=r,e=!0)}t=i}}if(qi=0,gt--,e)throw s}}function Ee(s){if(gt>0)return s();In=++Gf,gt++;try{return s()}finally{er()}}function hc(s){var e=X;X=void 0;try{return s()}finally{X=e}}function gc(s){if(X!==void 0){var e=s.n;if(e===void 0||e.t!==X)return e={i:0,S:s,p:X.s,n:void 0,t:X,e:void 0,x:void 0,r:e},X.s!==void 0&&(X.s.n=e),X.s=e,s.n=e,32&X.f&&s.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=X.s,e.n=void 0,X.s.n=e,X.s=e),e}}function Re(s,e){this.v=s,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 y(s,e){return new Re(s,e)}function fc(s){for(var e=s.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 pc(s){for(var e=s.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){s.s=e;break}}}function vc(s){for(var e=s.s,t=void 0;e!==void 0;){var i=e.p;e.i===-1?(e.S.U(e),i!==void 0&&(i.n=e.n),e.n!==void 0&&(e.n.p=i)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=i}s.s=t}function ds(s,e){Re.call(this,void 0),this.x=s,this.s=void 0,this.g=Yi-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function _c(s){var e=s.m;if(s.m=void 0,typeof e=="function"){gt++;var t=X;X=void 0;try{e()}catch(i){throw s.f&=-2,s.f|=8,oo(s),i}finally{X=t,er()}}}function oo(s){for(var e=s.s;e!==void 0;e=e.n)e.S.U(e);s.x=void 0,s.s=void 0,_c(s)}function jf(s){if(X!==this)throw new Error("Out-of-order effect");vc(this),X=s,this.f&=-2,8&this.f&&oo(this),er()}function hs(s,e){this.x=s,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name}function it(s,e){var t=new hs(s,e);try{t.c()}catch(r){throw t.d(),r}var i=t.d.bind(t);return i[Symbol.dispose]=i,i}function Rc(s){if(!s?.includes(":"))return[s||void 0,void 0,void 0];let e=s.startsWith("(")&&s.endsWith(")")?s.slice(1,-1):s,t=_v.exec(e);return t?[t[1]||void 0,t[2]===void 0?void 0:Number(t[2]),t[3]===void 0?void 0:Number(t[3])]:[void 0,void 0,void 0]}function mv(s){if(!Ac.test(s))return null;s.includes("(eval ")&&(s=s.replaceAll("eval code","eval").replaceAll(/(\(eval at [^()]*)|(,.*$)/g,""));let e=s.replace(/^\s+/,"").replaceAll("(eval code","(").replace(/^.*?\s+/,""),t=/ (\(.+\)$)/.exec(e),i=t?e.replace(t[0],""):e,[r,n,o]=Rc(t?t[1]:e);return{functionName:t&&i||void 0,fileName:r==="eval"||r==="<anonymous>"?void 0:r,lineNumber:n,columnNumber:o}}function yv(s){if(vv.test(s))return null;if(s.includes(" > eval")&&(s=s.replaceAll(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),!s.includes("@")&&!s.includes(":"))return{functionName:s,fileName:void 0,lineNumber:void 0,columnNumber:void 0};let e=s.lastIndexOf("@"),t=e>0?s.slice(0,e):void 0,[i,r,n]=Rc(s.slice(e+1));return{functionName:t,fileName:i,lineNumber:r,columnNumber:n}}function bv(s){if(!s.stack)throw new Error("Cannot parse given Error object");let e=s.stack.split(`
3
+ `);return e.some(t=>Ac.test(t))?e.map(mv).filter(t=>t!==null):e.map(yv).filter(t=>t!==null)}function Ll(s,e,t,i){return{errorClass:xl(s),message:`${t}${xl(e)}`,type:"browserjs",stacktrace:i.reduce((r,n)=>{let o=Sv(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function $c(s,e){let t=Object.assign(s,e);for(let i of Object.keys(t))typeof t[i]=="object"&&typeof e[i]=="object"&&(t[i]=$c(t[i],e[i]));return t}async function o_(s){let e=r_[s];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((t,i)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=n_();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}t(e.lib)}).catch(i)})})}function De(s,e){if(!s?.default&&e){let t=Object.create(null);return t.default=s,t.__esModule=!0,t}return s}function Ne(s,e){return o_(s).then(t=>t.get(e).then(i=>i()))}function $_(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function M_(){return Gl||(Gl=1,(function(s,e){(function(t,i){s.exports=i()})(F_,function(){function t(g){return g=JSON.stringify(g),!!/^\{[\s\S]*\}$/.test(g)}function i(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(E,D){return m._data[E]=String(D)},m.getItem=function(E){return m._data.hasOwnProperty(E)?m._data[E]:void 0},m.removeItem=function(E){return delete m._data[E]},m.clear=function(){return m._data={}},g=m}finally{g.getItem(p)===v&&g.removeItem(p)}return g}var l=a();function c(){if(!(this instanceof c))return new c}c.prototype={set:function(p,v){if(p&&!t(p))l.setItem(p,i(v));else if(t(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(I,C){return v[I]=C}),v}if(p.charAt(0)==="?")return this.has(p.substr(1));var m=arguments;if(m.length>1){for(var b={},E=0,D=m.length;E<D;E++){var R=r(l.getItem(m[E]));this.has(m[E])&&(b[m[E]]=R)}return b}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 b=l.key(v);p(b,this.get(b))}return this},search:function(p){for(var v=this.keys(),m={},b=0,E=v.length;b<E;b++)v[b].indexOf(p)>-1&&(m[v[b]]=this.get(v[b]));return m},len:function(){return l.length}};var d=null;function h(g,p){var v=arguments,m=null;if(d||(d=c()),v.length===0)return d.get();if(v.length===1){if(typeof g=="string")return d.get(g);if(t(g))return d.set(g)}if(v.length===2&&typeof g=="string"){if(!p)return d.remove(g);if(p&&typeof p=="string")return d.set(g,p);p&&n(p)&&(m=null,m=p(g,d.get(g)),h.set(g,m))}if(v.length===2&&o(g)&&n(p))for(var b=0,E=g.length;b<E;b++)m=p(g[b],d.get(g[b])),h.set(g[b],m);return h}for(var f in c.prototype)h[f]=c.prototype[f];return h})})(Vi)),Vi.exports}var Ig,Og,Ng,q,Lg,$g,Fg,Mg,ec,x,ne,Le,Se,Je,Ug,se,as,Bg,to,Vg,Tn,Gg,jg,Hg,oe,zg,be,ft,Us,ji,ct,tt,so,Kg,yl,Hi,qg,Wg,zi,io,tc,sc,ic,vn,ro,An,je,rc,Fs,Ut,Bs,is,Yg,_n,Xg,Jg,Qg,xi,bl,Fi,At,mn,Gt,Mi,Li,sf,Qi,rf,nf,of,nc,af,B,lf,El,cf,uf,df,hf,gf,ff,pf,oc,vf,Xe,_f,ac,W,lc,Zi,no,ge,Sl,Hs,mf,cc,yf,kl,bf,Ef,Gs,Sf,kf,wf,wl,Tf,Tl,Af,Rf,Al,Rn,Rl,If,Of,uc,zs,dc,Il,Pf,Df,Nf,xf,Lf,$f,Ff,Mf,Uf,Bf,Ki,Vf,X,js,gt,qi,Gf,In,Wi,Yi,On,$i,Ol,mc,Hf,zf,Kf,Cn,pt,ut,yc,Pn,Cl,qf,Wf,Yf,Xf,Jf,Qf,Zf,ep,Pl,tp,sp,ip,rp,np,op,ap,Dl,lp,cp,bc,up,dp,hp,gp,fp,pp,vp,Nl,_p,mp,yp,bp,Ep,Sp,kp,wp,Tp,Ap,Rp,Ip,Op,Cp,Pp,Dp,Np,xp,Lp,$p,Fp,Mp,Up,Bp,Vp,Gp,jp,Ec,tr,Sc,Hp,Ks,sr,ao,kc,wc,Tc,Bt,zp,Dn,Ui,Kp,qp,Wp,Yp,Xp,Jp,Z,yn,Qp,Zp,ev,tv,sv,iv,rv,nv,ov,av,lv,cv,uv,dv,hv,gv,fv,pv,u,Ac,vv,_v,Ic,Ev,Sv,xl,Oc,kv,$l,Bi,wv,Tv,Av,Rv,Iv,Ov,Cv,Pv,Fl,Ml,Nn,Cc,Dv,Nv,xv,Lv,$v,Fv,Mv,Pc,Uv,Bv,Vv,Gv,jv,Hv,zv,Kv,qv,Wv,Dc,Nc,Yv,Xv,Jv,Qv,xn,xc,Ln,Zv,e_,t_,Ul,s_,Lc,i_,r_,n_,a_,l_,Fc,c_,u_,bn,d_,$n,xe,Fe,Ge,st,jt,h_,g_,f_,p_,v_,__,m_,y_,b_,E_,S_,k_,rs,w_,Mc,Uc,T_,Bc,Vc,ns,Bl,Vl,A_,R_,Fn,I_,dt,O_,C_,P_,D_,N_,x_,L_,Mn,Xi,Vi,F_,Gl,U_,Mt,Gc,os,Un,lo,Bn,co,Vn,uo,Ye,B_,V_,G_,j_,H_,Gn,z_,jn,K_,q_,jc,W_,Y_,X_,ls,Hn,Hc,J_,Q_,Z_,cs,En,Sn,em,tm,sm,jl,im,zc,rm,nm,om,am,lm,cm,um,dm,hm,Kc,gm,fm,zn,pm,qc,vm,_m,mm,Wc,ym,bm,Kn,Em,Sm,km,wm,Hl,Tm,zl,Am,Kl,qn,Rm,Im,ql,kn,Yc,Om,Ji,Wl,Xc,Yl,Cm,Pm,Dm,Nm,xm,Vs,Wn,Lm,$m,Fm,wn,Mm,Um,Bm,Vm,Gm,Ms,Yn,Xn,Jn,jm,Hm,zm,Xl,Jl,Km,qm,Wm,Ym,Gi,Qn,Ql,Xm,Jm,Zn,Vt,us,ho=Pe(()=>{"use strict";Ig=ht(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Og=Number.isInteger||function(e){return e<<0===e};Ng=(function(){function s(){this.map={},this.length=0}return s.prototype.set=function(e,t){var i=this.hash(e),r=this.map[i];r||(this.map[i]=r=[]),r.push([e,t]),this.length+=1},s.prototype.hash=function(e){var t=[];for(var i in e)t.push(Object.prototype.toString.call(e[i]));return t.join()},s.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var o=this.map[t],i=0;i<o.length;i+=1){var r=o[i];if(r[0]===e)return r[1]}return}var n=this.hash(e),o=this.map[n];if(o)for(var i=0;i<o.length;i+=1){var r=o[i];if(r[0]===e)return r[1]}},s})(),q=ht(function(e){return e!=null&&typeof e.clone=="function"?e.clone():Zl(e)});Lg=eo(function(e,t,i){var r={},n;t=t||{},i=i||{};for(n in t)Ni(n,t)&&(r[n]=Ni(n,i)?e(n,t[n],i[n]):t[n]);for(n in i)Ni(n,i)&&!Ni(n,r)&&(r[n]=i[n]);return r}),$g=eo(function s(e,t,i){return Lg(function(r,n,o){return ml(n)&&ml(o)?s(e,n,o):e(r,n,o)},t,i)}),Fg=eo(function(e,t,i){return $g(function(r,n,o){return e(n,o)},t,i)}),Mg=Tt(xg),ec=Tt(function(e,t){var i={};for(var r in t)e(t[r],r,t)&&(i[r]=t[r]);return i}),x=s=>typeof s=="function"&&!!(s.constructor&&s.call&&s.apply),ne=s=>typeof s=="string",Le=s=>s===null,Se=s=>typeof s>"u",Je=s=>Le(s)||Se(s),Ug=s=>typeof s=="bigint",se=s=>!Se(s),as=s=>!Je(s),Bg=s=>as(s)&&s!=="",to=s=>{switch(Object.prototype.toString.call(s)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return s instanceof Error}},Vg=s=>typeof s=="boolean",Tn=(s,e)=>{let t=e.split(".");return Mg(t,s)},Gg=(s,e)=>!!Tn(s,e),jg=s=>typeof s=="object",Hg=s=>!Le(s)&&jg(s)&&!Array.isArray(s),oe=s=>!Le(s)&&Object.prototype.toString.call(s)==="[object Object]",zg=(s,e)=>{if(!Array.isArray(s)||!Array.isArray(e))return q(e);let t=q(s);return e.forEach((i,r)=>{t[r]=Array.isArray(i)||Hg(i)?be(t[r],i):i}),t},be=(s,e)=>Fg(zg,s,e),ft=s=>oe(s)&&Object.keys(s).length>0,Us=s=>{let e=ec(se,s);return Object.keys(e).forEach(t=>{let i=e[t];oe(i)&&(e[t]=Us(i))}),e},ji=s=>{let e=ec(as,s);return Object.keys(e).forEach(t=>{let i=e[t];oe(i)&&(e[t]=ji(i))}),e},ct=s=>{if(ft(s))return ji(s)},tt=(s,e)=>typeof s=="boolean"?s:e,so=s=>(Object.getOwnPropertyNames(s).forEach(function(e){s[e]&&typeof s[e]=="object"&&so(s[e])}),Object.freeze(s)),Kg=s=>s.replace(/^\s+|\s+$/gm,""),yl=s=>s.replace(/^\.+/,""),Hi=s=>{let e=s;if(!ne(s)&&!Je(s))try{e=JSON.stringify(s)}catch{e=null}return e},qg=s=>{let e=Array.from(s,t=>String.fromCodePoint(t)).join("");return globalThis.btoa(e)},Wg=s=>qg(new TextEncoder().encode(s)),zi=(s,e,t,i,r)=>{let n={category:s,name:e,properties:t,options:i,callback:void 0};x(r)&&(n.callback=r),x(i)&&(n.category=s,n.name=e,n.properties=t,n.options=void 0,n.callback=i),x(t)&&(n.category=s,n.name=e,n.properties=void 0,n.options=void 0,n.callback=t),x(e)&&(n.category=s,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),x(s)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=s),oe(s)?(n.name=void 0,n.category=void 0,n.properties=s,x(e)?n.options=void 0:n.options=e):oe(e)&&(n.name=void 0,n.properties=e,x(t)?n.options=void 0:n.options=t),ne(s)&&!ne(e)&&(n.category=void 0,n.name=s),se(n.category)||(n.category=void 0),se(n.name)||(n.name=void 0),n.properties=n.properties?q(n.properties):{},se(n.options)?n.options=q(n.options):n.options=void 0;let o=ne(n.name)?n.name:n.properties.name,a=ne(n.category)?n.category:n.properties.category;return n.properties=be(oe(n.properties)?n.properties:{},{...o&&{name:o},...a&&{category:a}}),n},io=(s,e,t,i)=>{let r={name:s,properties:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.properties=e,r.options=void 0,r.callback=t),x(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=as(r.properties)?q(r.properties):{},se(r.options)?r.options=q(r.options):r.options=void 0,r},tc=(s,e,t,i)=>{let r={userId:s,traits:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.userId=s,r.traits=e,r.options=void 0,r.callback=t),x(e)&&(r.userId=s,r.traits=void 0,r.options=void 0,r.callback=e),(oe(s)||Le(s))&&(r.userId=null,r.traits=s,x(e)?r.options=void 0:r.options=e),r.userId=Hi(r.userId),oe(r.traits)?r.traits=q(r.traits):r.traits=void 0,se(r.options)?r.options=q(r.options):r.options=void 0,r},sc=(s,e,t,i)=>{let r={to:s,from:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.to=s,r.from=e,r.options=void 0,r.callback=t),x(e)?(r.to=s,r.from=void 0,r.options=void 0,r.callback=e):(oe(e)||Le(e))&&(r.to=s,r.from=void 0,r.options=e),se(r.to)&&(r.to=Hi(r.to)),se(r.from)?r.from=Hi(r.from):r.from=void 0,se(r.options)?r.options=q(r.options):r.options=void 0,r},ic=(s,e,t,i)=>{let r={groupId:s,traits:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.groupId=s,r.traits=e,r.options=void 0,r.callback=t),x(e)&&(r.groupId=s,r.traits=void 0,r.options=void 0,r.callback=e),(oe(s)||Le(s))&&(r.groupId=null,r.traits=s,x(e)?r.options=void 0:r.options=e),r.groupId=Hi(r.groupId),oe(r.traits)?r.traits=q(r.traits):r.traits=void 0,se(r.options)?r.options=q(r.options):r.options=void 0,r},vn=(function(s){return s.UNLOADED="Page Unloaded",s})({}),ro="API",An="CapabilitiesManager",je="ConfigManager",rc="EventManager",Fs="PluginsManager",Ut="UserSessionManager",Bs="ErrorHandler",is="PluginEngine",Yg="StoreManager",_n=`Ready${ro}`,Xg=`Load${ro}`,Jg="HttpClient",Qg="RudderStackAnalytics",xi="AnalyticsCore";bl=4096,Fi=[],At=0;for(;At<256;At++)Fi[At]=(At+256).toString(16).substring(1);Gt=256,Mi=[];for(;Gt--;)Mi[Gt]=(Gt+256).toString(16).substring(1);sf=()=>!Je(globalThis.crypto)&&x(globalThis.crypto.getRandomValues),Qi=()=>sf()?ef():tf(),rf=()=>!!window.chrome?.runtime?.id,nf=()=>ne(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),of=(s,e=!1)=>{let t=!1,i=!1;function r(){t||(t=!0,s(i),setTimeout(()=>{t=!1},0))}(e||nf())&&globalThis.addEventListener("beforeunload",()=>{i=!1,r()}),globalThis.addEventListener("blur",()=>{i=!0,r()}),globalThis.addEventListener("focus",()=>{t=!1}),document.addEventListener("pagehide",()=>{i=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{i=!0,document.visibilityState==="hidden"?r():t=!1})},nc=s=>s.toISOString(),af=()=>nc(new Date),B=":: ",lf=s=>`A script with the id "${s}" is already loaded. Skipping the loading of this script to prevent conflicts`,El=(s,e,t)=>`Unable to load (${ne(t)?t:t.type}) the script with the id "${s}" from URL "${e}"`,cf=(s,e,t)=>`A timeout of ${t} ms occurred while trying to load the script with id "${s}" from URL "${e}"`,uf=(s,e)=>`${s}${B}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,df="Failed to convert the value to a JSON string.",hf="Failed to encode the cookie data.",gf=(s,e)=>`${s}${B}The "${e}" storage type is `,ff="JSONStringify",pf="[BigInt]",oc="[Circular Reference]",vf=(s,e,t)=>{let i=[];return function(r,n){if(!e?.includes(r)&&!(s&&Je(n))){if(typeof n!="object"||Le(n))return n;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(n)?(t?.warn(uf(ff,r)),oc):(i.push(n),n)}}},Xe=(s,e,t,i)=>{try{return JSON.stringify(s,vf(e,t,i))}catch(r){return i?.warn(df,r),null}},_f=s=>{let e=[];return function(i,r){if(Ug(r))return pf;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?oc:(e.push(r),r)}},ac=(s,e)=>{let t=Array.isArray(s)?[]:{};for(let i in s)if(Object.hasOwnProperty.call(s,i)){let r=s[i],n=e.call(s,i,r);oe(n)||Array.isArray(n)?t[i]=ac(n,e):t[i]=n}return t},W=(s,e)=>{let t=_f(),i=t.call(s,"",s);return oe(s)||Array.isArray(s)?ac(s,t):i},lc="[SDK DISPATCHED ERROR]",Zi=s=>{let{stack:e}=s;if(typeof e=="string"&&e)return e},no=(s,e)=>{if(!to(s))return new Error(`${e}: ${Xe(s)}`);try{let t=s.constructor,i=new t(`${e}: ${s.message}`),r=Zi(s);return r&&(i.stack=r),Object.getOwnPropertyNames(s).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{i[n]=s[n]}catch{}}),i}catch{return new Error(`${e}: ${Xe(s)}`)}},ge=s=>{if(to(s)){let e=Zi(s);e&&(s.stack=`${e}
4
+ ${lc}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:s,bubbles:!0,cancelable:!0,composed:!0}))},Sl="RudderLabs JavaScript SDK",Hs="3.31.0",mf="com.rudderlabs.javascript",cc="npm",yf="modern",kl="RudderJS-Initiated",bf="ad-block page request",Ef="/ad-blocked",Gs="preloadedEventsBuffer",Sf="Consent Management Interaction",kf="ajs_trait_",wf="ajs_prop_",wl="ajs_aid",Tf="ajs_uid",Tl="ajs_event",Af=10*1e3,Rf=31536e3*1e3,Al=720*60*1e3,Rn=1800*1e3,Rl=10*1e3,If=10*1e3,Of=250,uc=(s="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[s]||(globalThis.RudderStackGlobals[s]={})},zs=(s,e,t="app")=>{uc(t),globalThis.RudderStackGlobals[t][s]=e},dc=(s,e="app")=>(uc(e),globalThis.RudderStackGlobals[e][s]);Il=(s,e)=>{let t={};return s.forEach((i,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);t[n]=s.get(r)}}),t},Pf=(s=[])=>{let e={trait:kf,properties:wf},t=new URLSearchParams(globalThis.location.search);t.get(Tl)&&s.unshift(["track",t.get(Tl),Il(t,e.properties)]);let i=t.get(Tf),r=Il(t,e.trait);if(i||ft(r)){let n=[...i?[i]:[],r];s.unshift(["identify",...n])}t.get(wl)&&s.unshift(["setAnonymousId",t.get(wl)])},Df=s=>{let e="load",t=[],i=0;for(;i<s.length;){if(s[i]&&s[i][0]===e){t=q(s[i]),s.splice(i,1);break}i+=1}return t},Nf=s=>{let e="consent",t=s.filter(r=>r[0]===e),i=s.filter(r=>r[0]!==e);s.splice(0,s.length,...t,...i)},xf=s=>{let e=dc(Gs)||[];Pf(e),e.length>0&&(s.enqueuePreloadBufferEvents(e),zs(Gs,[]))},Lf=(s,e)=>{let t=s.shift(),i;if(x(e[t])){switch(t){case"page":i=zi(...s);break;case"track":i=io(...s);break;case"identify":i=tc(...s);break;case"alias":i=sc(...s);break;case"group":i=ic(...s);break;default:e[t](...s);break}i&&e[t](i)}},$f=10*1e3,Ff="RS_JS_SDK",Mf=(s,e,t=!0,i=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=i,o.onerror=r,o.src=s,o.id=e,o.async=t,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",Ff),o},Uf=s=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(s,e[0]?.firstChild);return}let t=document.getElementsByTagName("script");if(t.length>0&&t[0]?.parentNode){t[0]?.parentNode.insertBefore(s,t[0]);return}let i=document.createElement("head");i.appendChild(s);let r=document.getElementsByTagName("html")[0];r?.insertBefore(i,r.firstChild)},Bf=(s,e,t,i=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(lf(e)));try{let l;Uf(Mf(s,e,i,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(El(e,s,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(cf(e,s,t)))},t)}catch(l){o(no(l,El(e,s,"unknown")))}}),Ki=class{constructor(e,t=$f){this.logger=e,this.timeout=t}loadJSFile(e){let{url:t,id:i,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!x(o);Bf(t,i,r||this.timeout,n,a).then(c=>{l||o(c)}).catch(c=>{l||o(i,c)})}},Vf=Symbol.for("preact-signals");X=void 0;js=void 0,gt=0,qi=0,Gf=0,In=0,Wi=void 0,Yi=0;Re.prototype.brand=Vf;Re.prototype.h=function(){return!0};Re.prototype.S=function(s){var e=this,t=this.t;t!==s&&s.e===void 0&&(s.x=t,this.t=s,t!==void 0?t.e=s:hc(function(){var i;(i=e.W)==null||i.call(e)}))};Re.prototype.U=function(s){var e=this;if(this.t!==void 0){var t=s.e,i=s.x;t!==void 0&&(t.x=i,s.e=void 0),i!==void 0&&(i.e=t,s.x=void 0),s===this.t&&(this.t=i,i===void 0&&hc(function(){var r;(r=e.Z)==null||r.call(e)}))}};Re.prototype.subscribe=function(s){var e=this;return it(function(){var t=e.value,i=X;X=void 0;try{s(t)}finally{X=i}},{name:"sub"})};Re.prototype.valueOf=function(){return this.value};Re.prototype.toString=function(){return this.value+""};Re.prototype.toJSON=function(){return this.value};Re.prototype.peek=function(){var s=X;X=void 0;try{return this.value}finally{X=s}};Object.defineProperty(Re.prototype,"value",{get:function(){var s=gc(this);return s!==void 0&&(s.i=this.i),this.v},set:function(s){if(s!==this.v){if(qi>100)throw new Error("Cycle detected");(function(t){gt!==0&&qi===0&&t.l!==In&&(t.l=In,Wi={S:t,v:t.v,i:t.i,o:Wi})})(this),this.v=s,this.i++,Yi++,gt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{er()}}}});ds.prototype=new Re;ds.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Yi))return!0;if(this.g=Yi,this.f|=1,this.i>0&&!fc(this))return this.f&=-2,!0;var s=X;try{pc(this),X=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return X=s,vc(this),this.f&=-2,!0};ds.prototype.S=function(s){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}Re.prototype.S.call(this,s)};ds.prototype.U=function(s){if(this.t!==void 0&&(Re.prototype.U.call(this,s),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};ds.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var s=this.t;s!==void 0;s=s.x)s.t.N()}};Object.defineProperty(ds.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var s=gc(this);if(this.h(),s!==void 0&&(s.i=this.i),16&this.f)throw this.v;return this.v}});hs.prototype.c=function(){var s=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{s()}};hs.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,_c(this),pc(this),gt++;var s=X;return X=this,jf.bind(this,s)};hs.prototype.N=function(){2&this.f||(this.f|=2,this.u=js,js=this)};hs.prototype.d=function(){this.f|=8,1&this.f||oo(this)};hs.prototype.dispose=function(){this.d()};On=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=[]}},$i={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Ol="LOG",mc="ERROR",Hf="RS SDK",zf="font-weight: bold; background: black; color: white;",Kf="font-weight: normal;",Cn=class{constructor(e=Ol,t="",i=console){this.minLogLevel=$i[e],this.scope=t,this.logProvider=i}log(...e){this.outputLog("LOG",e)}info(...e){this.outputLog("INFO",e)}debug(...e){this.outputLog("DEBUG",e)}warn(...e){this.outputLog("WARN",e)}error(...e){this.outputLog("ERROR",e)}outputLog(e,t){this.minLogLevel<=$i[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=$i[e],Se(this.minLogLevel)&&(this.minLogLevel=$i[Ol])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t=`%c ${Hf}`;this.scope&&(t=`${t} - ${this.scope}`);let i=ne(e[0])?e[0].trim():"";t=`${t} %c ${i}`;let r=[t,zf,Kf];return ne(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},pt=new Cn,ut=(function(s){return s.HANDLEDEXCEPTION="handledException",s.UNHANDLEDEXCEPTION="unhandledException",s.UNHANDLEDREJECTION="unhandledPromiseRejection",s})({}),yc=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Pn="cookieStorage",Cl="Unable to process/parse source configuration response",qf="The source is disabled. Please enable the source in the dashboard to send events.",Wf="Failed to prepare data for the request.",Yf="Failed to invoke plugin because the extension point name is missing.",Xf="Failed to invoke plugin because the extension point name is invalid.",Jf=s=>`${s}${B}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,Qf=(s,e,t)=>`${s}${B}The base URL "${t}" for ${e} is not valid.`,Zf=(s,e,t)=>`${s}${B}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(t)}".`,ep=(s,e)=>`${s}${B}Ignoring a non-error: ${e}.`,Pl="Failed to log breadcrumb",tp=s=>`${s}${B}Failed to handle the error.`,sp=s=>`${s}${B}Plugin name is missing.`,ip=(s,e)=>`${s}${B}Plugin "${e}" already exists.`,rp=(s,e)=>`${s}${B}Plugin "${e}" not found.`,np=(s,e)=>`${s}${B}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.`,op=(s,e,t)=>`${s}${B}Plugin "${e}" could not be loaded because some of its dependencies "${t}" do not exist.`,ap=(s,e,t)=>`${s}${B}Failed to invoke the "${e}" extension point of plugin "${t}".`,Dl="Failed to fetch the source config",lp=(s,e)=>`${s}${B}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,cp=(s,e)=>`${s}${B}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.`,bc=s=>`${s}${B}The provided callback parameter is not a function.`,up=(s,e,t,i,r)=>`${s} with status ${e} (${t}) for URL: ${i}. Response: ${r.trim()}`,dp=(s,e,t)=>`${s} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${t}`,hp=(s,e)=>`${s} for URL: ${e}`,gp=s=>`Failed to save the value for "${s}" to storage`,fp=s=>`Failed to retrieve or parse data for "${s}" from storage`,pp=s=>`The server responded with status ${s} while setting the cookies. As a fallback, the cookies will be set client side.`,vp=s=>`The server failed to set the ${s} cookie. As a fallback, the cookies will be set client side.`,Nl="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",_p=(s,e,t)=>`${s}${B}The storage type "${e}" is not supported. Please choose one of the following supported types: "${yc}". The default type "${t}" will be used instead.`,mp=(s,e,t,i)=>`${s}${B}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(t)}". The default version "${i}" will be used instead.`,yp=(s,e,t)=>`${s}${B}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${t}). To enable storage data migration, please update the storage encryption version to the latest version.`,bp=(s,e,t)=>`${s}${B}The provided cookie domain (${e}) does not match the current webpage's domain (${t}). Hence, the cookies will be set client-side.`,Ep=(s,e,t,i)=>`${s}${B}The "${e}" property defined under "${t}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i}).`,Sp=s=>`${s}${B}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,kp=s=>`${s}${B}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,wp=(s,e,t)=>`${s}${B}The session timeout value "${e}" is not a number. The default timeout of ${t} ms will be used instead.`,Tp=(s,e,t)=>`${s}${B}The session cut off duration value "${e}" is not a number. The default cut off duration of ${t} ms will be used instead.`,Ap=(s,e,t)=>`${s}${B}The session cut off duration value "${e}" ms is less than the session timeout value "${t}" ms. The cut off functionality will be disabled.`,Rp=s=>`${s}${B}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.`,Ip=(s,e,t)=>`${s}${B}The session timeout value ${e} ms is less than the recommended minimum of ${t} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,Op=(s,e,t)=>`${s}${B}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${t}" digits long. A new session ID will be auto-generated instead.`,Cp=s=>`${s}${B}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,Pp=(s,e,t,i)=>`${s}${B}The storage type "${t}" is not available for entry "${e}". The SDK will initialize the entry with "${i}" storage type instead.`,Dp=s=>`${s}${B}The callback threw an exception`,Np=(s,e)=>`${s}${B}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,xp=(s,e)=>`Failed to load the polyfill script with ID "${s}" from URL ${e}.`,Lp=(s,e,t)=>`${s}${B}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${t}" will be used instead.`,$p=(s,e,t)=>`${s}${B}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${t}" will be used instead.`,Fp=(s,e)=>`${s}${B}${e} plugin is deprecated. Please exclude it from the load API options.`,Mp=(s,e,t,i)=>{let r=t.length===1,n=r?` '${t[0]}' plugin was`:` ['${t.join("', '")}'] plugins were`,o=`${s}${B}${e}, but${n} not configured to load.`;return i?`${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.`},Up=(s,e)=>`${s}${B}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,Bp=s=>`${s}${B}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,Vp=(s,e)=>`${s}${B}Ignoring unknown plugins: ${e.join(", ")}.`,Gp=(s,e)=>`${s}${B}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.`,jp=(s,e)=>`${s}${B}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,Ec={All:!0},tr="js-integrations",Sc="plugins",Hp=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_]*)?$"),Ks="modern",sr="https://cdn.rudderlabs.com",ao="v3",kc=`${sr}/${ao}/${Ks}/${tr}`,wc=`${sr}/${ao}/${Ks}/${Sc}`,Tc="https://api.rudderstack.com",Bt="v3",zp="xhr",Dn={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Ui={[Bt]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},Kp={[zp]:"XhrQueue",beacon:"BeaconQueue"},qp="rsaRequest",Wp="rsaMetrics",Yp="Custom Device Mode",Xp={configUrl:Tc,loadIntegration:!0,sessions:{autoTrack:!0,timeout:Rn,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:Ec,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:If,storage:{encryption:{version:Bt},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},Jp=y(q(Xp)),Z=so({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),yn=so({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Qp=10,Zp={userId:y(Z.userId),userTraits:y(Z.userTraits),anonymousId:y(Z.anonymousId),groupId:y(Z.groupId),groupTraits:y(Z.groupTraits),initialReferrer:y(Z.initialReferrer),initialReferringDomain:y(Z.initialReferringDomain),sessionInfo:y(Z.sessionInfo),authToken:y(Z.authToken)},ev={isOnline:y(!0),storage:{isLocalStorageAvailable:y(!1),isCookieStorageAvailable:y(!1),isSessionStorageAvailable:y(!1)},isBeaconAvailable:y(!1),isLegacyDOM:y(!1),isUaCHAvailable:y(!1),isCryptoAvailable:y(!1),isAdBlockerDetectionInProgress:y(!1),isAdBlocked:y(void 0),cspBlockedURLs:y([])},tv={isErrorReportingEnabled:y(!1),isMetricsReportingEnabled:y(!1),breadcrumbs:y([])},sv=y(void 0),iv={activeDataplaneUrl:y(void 0),integrationsCDNPath:y(kc),pluginsCDNPath:y(wc),sourceConfigUrl:y(void 0),status:y(void 0),initialized:y(!1),logLevel:y(mc),loaded:y(!1),readyCallbacks:y([]),writeKey:y(void 0),dataPlaneUrl:y(void 0),safeAnalyticsInstance:y(void 0)},rv={enabled:y(!1),initialized:y(!1),data:y({}),activeConsentManagerPluginName:y(void 0),preConsent:y({enabled:!1}),postConsent:y({}),resolutionStrategy:y("and"),provider:y(void 0),metadata:y(void 0)},nv={retries:y(0),dropped:y(0),sent:y(0),queued:y(0),triggered:y(0),metricsServiceUrl:y(void 0)},ov=()=>yf,av={app:y({name:Sl,namespace:mf,version:Hs,installType:cc}),traits:y(null),library:y({name:Sl,version:Hs,snippetVersion:globalThis.RudderSnippetVersion,variant:ov()}),userAgent:y(null),device:y(null),network:y(null),os:y({name:"",version:""}),locale:y(null),screen:y({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":y(void 0),timezone:y(void 0)},lv={configuredDestinations:y([]),activeDestinations:y([]),loadOnlyIntegrations:y({}),failedDestinations:y([]),loadIntegration:y(!0),initializedDestinations:y([]),clientDestinationsReady:y(!1),integrationsConfig:y({})},cv={toBeProcessedArray:y([]),readyCallbacksArray:y([])},uv={ready:y(!1),loadedPlugins:y([]),failedPlugins:y([]),pluginsToLoadFromConfig:y([]),activePlugins:y([]),totalPluginsToLoad:y(0)},dv={encryptionPluginName:y(void 0),migrate:y(!1),type:y(void 0),cookie:y(void 0),entries:y({}),trulyAnonymousTracking:y(!1)},hv={isEnabledServerSideCookies:y(!1),dataServiceUrl:y(void 0)},gv={eventsQueuePluginName:y(void 0),deliveryEnabled:y(!0)},fv={enabled:y(!1),pageLifecycle:{enabled:y(!1),pageViewId:y(void 0),pageLoadedTimestamp:y(void 0)}},pv={capabilities:ev,consents:rv,context:av,eventBuffer:cv,lifecycle:iv,loadOptions:Jp,metrics:nv,nativeDestinations:lv,plugins:uv,reporting:tv,session:Zp,source:sv,storage:dv,serverCookies:hv,dataPlaneEvents:gv,autoTrack:fv},u={...q(pv)},Ac=/^\s*at /,vv=/^(eval@)?(\[native code])?$/,_v=/(.+?)(?::(\d+))?(?::(\d+))?$/;Ic="global code",Ev=s=>se(s)&&/^global code$/i.test(s)?Ic:s,Sv=s=>{let e={file:s.fileName,method:Ev(s.functionName),lineNumber:s.lineNumber,columnNumber:s.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Ic),e},xl=s=>ne(s)?s:"";Oc=(s,e)=>{let t;return to(s)&&ne(Zi(s))?t=s:(e.warn(ep(Bs,Xe(s))),t=void 0),t},kv=(s,e)=>{try{let t=bv(s);return Ll(s.name,s.message,e,t)}catch{return Ll(s.name,s.message,e,[])}},$l=(s,e)=>{try{return JSON.parse(s||"")}catch(t){let i=no(t,"Failed to parse response data");e(i)}},Bi="The request failed",wv=[/Failed to fetch dynamically imported module: .*/],Tv=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],Av=[new RegExp(`${Bi}.*`),/A script with the id .* is already loaded\./],Rv=[...wv,...Tv],Iv="integrations",Ov="sdk",Cv=Ov,Pv={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Fl=(s,e,t)=>{let i=be(Pv,e||{});return t&&(i.headers=be(i.headers,{Authorization:t})),i.url=s,i},Ml=(s,e=Af,t)=>new Promise((i,r)=>{let n;if(s.sendRawData===!0)n=s.data;else if(n=Xe(s.data,!1,[],t),Le(n)){r({error:new Error(Wf),undefined:void 0,options:s});return}let o=new XMLHttpRequest,a=c=>{r({error:new Error(up(Bi,o.status,o.statusText,s.url,o.responseText)),xhr:o,options:s})},l=c=>{r({error:new Error(dp(Bi,c,s.url)),xhr:o,options:s,...c?.type==="timeout"?{timedOut:!0}:{}})};o.ontimeout=l,o.onerror=l,o.onload=()=>{o.status>=200&&o.status<400?i({response:o.responseText,xhr:o,options:s}):a()},o.open(s.method,s.url,!0),s.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(s.headers).forEach(c=>{s.headers[c]&&o.setRequestHeader(c,s.headers[c])});try{o.send(n)}catch(c){r({error:no(c,hp(Bi,s.url)),xhr:o,options:s})}}),Nn=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:t,options:i,timeout:r,isRawResponse:n}=e;try{let o=await Ml(Fl(t,i,this.basicAuthHeader),r,this.logger);return{data:n?o.response:$l(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:t,url:i,options:r,timeout:n,isRawResponse:o}=e,a=!x(t);Ml(Fl(i,r,this.basicAuthHeader),n,this.logger).then(l=>{a||t(o?l.response:$l(l.response,this.onError),l)}).catch(l=>{a||t(void 0,l)})}onError(e,t){this.errorHandler?.onError({error:e,context:Jg,groupingHash:t})}setAuthHeader(e,t=!1){let i=t?e:Wg(`${e}:`);this.basicAuthHeader=`Basic ${i}`}resetAuthHeader(){this.basicAuthHeader=void 0}},Cc=new Nn(pt),Dv="1",Nv=()=>["rsa"],xv=["www.test-host.com","localhost","127.0.0.1","[::1]"],Lv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],$v="RudderStack JavaScript SDK",Fv="git+https://github.com/rudderlabs/rudder-sdk-js.git",Mv="js",Pc=s=>{u.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(u.lifecycle.sourceConfigUrl.value),t=`${e.origin}${e.pathname}?view=ad`;s.getAsyncData({url:t,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(i,r)=>{u.capabilities.isAdBlockerDetectionInProgress.value=!1,u.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==t}})}catch(e){throw u.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},Uv=(s,e)=>{switch(e){case ut.UNHANDLEDEXCEPTION:{let{error:t}=s;return t||s}case ut.UNHANDLEDREJECTION:return s.reason;case ut.HANDLEDEXCEPTION:default:return s}},Bv=s=>({type:"manual",name:s,timestamp:new Date,metaData:{}}),Vv=(s=()=>window.location.hostname)=>{let e=s();return!e||e&&xv.includes(e)?"development":"production"},Gv=s=>{let e=Xe(s,!1,Lv);return e!==null?JSON.parse(e):{}},jv=()=>globalThis.location.href.split("?")[0],Hv=(s,e,t,i)=>({id:`${s.value?.id??t.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${i.pageLifecycle.pageViewId.value??"NA"}`,name:s.value?.name??"NA"}),zv=(s,e)=>({locale:s.value??"NA",userAgent:e.value??"NA",time:new Date}),Kv=(s,e,t,i)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:c}=t,{app:d,locale:h,userAgent:f,timezone:g,screen:p,library:v}=r;return{payloadVersion:"5",notifier:{name:$v,version:d.value.version,url:Fv},events:[{exceptions:[q(s)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:d.value.version,releaseStage:Vv(),type:d.value.installType},device:zv(h,f),request:{url:jv(),clientIp:"[NOT COLLECTED]"},breadcrumbs:q(l.breadcrumbs.value),context:s.message,groupingHash:i,metaData:{app:{snippetVersion:v.value.snippetVersion},device:{...p.value,timezone:g.value},...Gv(t)},user:Hv(a,o,n,c)}]}},qv=(s,e,t)=>{if(Se(s.capabilities.isAdBlocked.value)){s.capabilities.isAdBlockerDetectionInProgress.value===!1&&Pc(e);let i=it(()=>{se(s.capabilities.isAdBlocked.value)&&(t(s.capabilities.isAdBlocked.value===!1),i())})}else t(s.capabilities.isAdBlocked.value===!1)},Wv=(s,e,t)=>{let i=s.message;return new Promise(r=>{if(Rv.some(n=>n.test(i))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(i)?.[0];ne(n)?n.startsWith(sr)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):qv(e,t,r):r(!1):r(!0)}else r(!Av.some(n=>n.test(i)))})},Dc=s=>s?s.split("/").at(-2):void 0,Nc=s=>{let e=s.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},Yv=s=>{let e=Nc(s);if(!e)return!1;let t=e.substring(e.lastIndexOf("/")+1);return Dc(e)===tr||Nv().some(r=>t.startsWith(r)&&t.endsWith(".js"))},Xv=(s,e)=>{if(e)return e;let t=Nc(s);return Dc(t)===tr?Iv:Cv},Jv=(s,e,t)=>{let i={version:Dv,message_id:Qi(),source:{name:Mv,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:t},errors:s};return Xe(i)},Qv=(s,e,t)=>{let i;if(!se(s))i=e;else if(ne(s))i=s;else{let r=Oc(s,t);se(r)?i=r.message:i=e}return i},xn=class{constructor(e,t){le(this,"initialized",!1);this.httpClient=e,this.logger=t}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Bs,errorType:ut.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Bs,errorType:ut.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let t=ne(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&t.startsWith(sr)&&!u.capabilities.cspBlockedURLs.value.includes(t)&&(u.capabilities.cspBlockedURLs.value=[...u.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{let{error:t,context:i,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??ut.HANDLEDEXCEPTION,l=Uv(t,a),c=Oc(l,this.logger);if(Se(c))return;let d=r?`${r} - `:"",h=`${i}${B}${d}`,f=kv(c,h),p=Zi(c).includes(lc);if(!p&&!Yv(f)&&a!==ut.HANDLEDEXCEPTION)return;if(u.reporting.isErrorReportingEnabled.value&&await Wv(f,u,this.httpClient)){let m={severity:"error",unhandled:a!==ut.HANDLEDEXCEPTION,severityReason:{type:a}},b=Qv(n,f.message,this.logger),E=Kv(f,m,u,b),D=Xv(f,o);this.httpClient.getAsyncData({url:u.metrics.metricsServiceUrl.value,options:{method:"POST",data:Jv(E,u,D),sendRawData:!0},isRawResponse:!0})}(a===ut.HANDLEDEXCEPTION||p)&&this.logger.error(f.message)}catch(t){this.logger.error(tp(Bs),t)}}leaveBreadcrumb(e){try{u.reporting.breadcrumbs.value=[...u.reporting.breadcrumbs.value,Bv(e)]}catch(t){this.onError({error:t,context:Bs,customMessage:Pl,groupingHash:Pl})}}},xc=new xn(Cc,pt),Ln=class{constructor(e,t={}){le(this,"plugins",[]);le(this,"byName",{});le(this,"cache",{});le(this,"config",{throws:!0});this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){let r=sp(is);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=ip(is,e.name);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},this.plugins=this.plugins.slice();let i=this.plugins.length;this.plugins.forEach((r,n)=>{r.deps?.includes(e.name)&&(i=Math.min(i,n))}),this.plugins.splice(i,0,e),this.byName[e.name]=e,x(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let r=rp(is,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let i=this.plugins.indexOf(t);if(i===-1){let r=np(is,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(i,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(i=>{if(i.deps?.some(r=>!this.byName[r])){let r=i.deps.filter(n=>!this.byName[n]);return this.logger.error(op(is,i.name,r)),!1}return t==="."?!0:Gg(i,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...i){let r=e;if(!r)throw new Error(Yf);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(Xf);let a=r.split(".");a.pop();let l=a.join(".");return(t?this.getPlugins(r):[this.getPlugins(r)[0]]).map(d=>{let h=Tn(d,r);if(!x(h)||n)return h;try{return h.apply(Tn(d,l),i)}catch(f){if(o)throw f;this.logger.error(ap(is,r,d.name),f)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}},Zv=new Ln(pt,{throws:!0}),e_=s=>s.config.connectionMode!=="cloud"||s.config.useNativeSDKToSend===!0||s.config.useNativeSDK===!0,t_=s=>s.config.connectionMode==="hybrid"||s.config.useNativeSDKToSend===!0,Ul=s=>s.filter(e_),s_=(s,e)=>`${s.replaceAll(" ","-")}___${e}`,Lc=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],i_=["Bugsnag","ErrorReporting"],r_={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"}};n_=s=>$c({},(globalThis.__federation_shared__||{}).default||{});a_=s=>{switch(s){case"BeaconQueue":return()=>Ne("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>De(e,!0));case"CustomConsentManager":return()=>Ne("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>De(e,!0));case"DeviceModeDestinations":return()=>Ne("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>De(e,!0));case"DeviceModeTransformation":return()=>Ne("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>De(e,!0));case"ExternalAnonymousId":return()=>Ne("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>De(e,!0));case"GoogleLinker":return()=>Ne("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>De(e,!0));case"KetchConsentManager":return()=>Ne("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>De(e,!0));case"IubendaConsentManager":return()=>Ne("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>De(e,!0));case"NativeDestinationQueue":return()=>Ne("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>De(e,!0));case"OneTrustConsentManager":return()=>Ne("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>De(e,!0));case"StorageEncryption":return()=>Ne("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>De(e,!0));case"StorageEncryptionLegacy":return()=>Ne("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>De(e,!0));case"StorageMigrator":return()=>Ne("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>De(e,!0));case"XhrQueue":return()=>Ne("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>De(e,!0));default:return}},l_=s=>{let e={};return s.forEach(t=>{if(Lc.includes(t)){let i=a_(t);i&&(e[t]=i)}}),e},Fc=()=>({}),c_=()=>({}),u_=s=>l_?.(s)||{},bn={...Fc(),...c_()},d_=s=>({...u_(s)}),$n=class{constructor(e,t,i){this.engine=e,this.errorHandler=t,this.logger=i,this.onError=this.onError.bind(this)}init(){u.lifecycle.status.value="pluginsLoading",zs("pluginsCDNPath",u.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){it(()=>{(u.plugins.activePlugins.value.length===0||u.plugins.loadedPlugins.value.length+u.plugins.failedPlugins.value.length===u.plugins.totalPluginsToLoad.value)&&Ee(()=>{u.plugins.ready.value=!0,u.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=u.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>i_.includes(r)?(this.logger.warn(Fp(Fs,r)),!1):!0);let t=[{configurationStatus:()=>se(u.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:u.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(Kp),shouldAddMissingPlugins:!0},{configurationStatus:()=>Ul(u.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Ul(u.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>se(u.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:u.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Dn)},{configurationStatus:()=>se(u.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:u.storage.encryptionPluginName.value,supportedPlugins:Object.values(Ui)},{configurationStatus:()=>u.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],i=!1;return t.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>se(n)),this.addMissingPlugins(r,i,e)):e=e.filter(r.basePlugins!==void 0?n=>!(r.basePlugins.includes(n)||r.supportedPlugins.includes(n)):n=>!r.supportedPlugins.includes(n))}),[...Object.keys(Fc()),...e]}addMissingPlugins(e,t,i){let r=e.shouldAddMissingPlugins||t,n;e.activePluginName?n=[...e.basePlugins||[],e.activePluginName]:n=[...e.supportedPlugins];let o=n.filter(a=>!i.includes(a));o.length>0&&(r&&i.push(...o),this.logger.warn(Mp(Fs,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(bn),...Lc],i=[],r=[];e.forEach(n=>{t.includes(n)?i.push(n):r.push(n)}),r.length>0&&this.logger.warn(Vp(Fs,r)),Ee(()=>{u.plugins.totalPluginsToLoad.value=e.length,u.plugins.activePlugins.value=i,u.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(bn).forEach(([t,i])=>{u.plugins.activePlugins.value.includes(t)&&(x(i)?this.register([i()]):e.push(t))}),e.length>0&&(u.plugins.failedPlugins.value=[...u.plugins.failedPlugins.value,...e],this.logger.error(Gp(Fs,e)))}registerRemotePlugins(){let e=d_(u.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async t=>{await e[t]().then(i=>this.register([i.default()])).catch(i=>{u.plugins.failedPlugins.value=[...u.plugins.failedPlugins.value,t],this.onError(i,`Failed to load plugin "${t}"`,i)})})).catch(t=>{this.onError(t)})}invokeMultiple(e,...t){try{return this.engine.invokeMultiple(e,...t)}catch(i){return this.onError(i,e),[]}}invokeSingle(e,...t){try{return this.engine.invokeSingle(e,...t)}catch(i){return this.onError(i,e),null}}register(e){e.forEach(t=>{try{this.engine.register(t,u)}catch(i){u.plugins.failedPlugins.value=[...u.plugins.failedPlugins.value,t.name],this.onError(i,`Failed to register plugin "${t.name}"`)}})}unregisterLocalPlugins(){Object.keys(bn).forEach(e=>{try{this.engine.unregister(e)}catch(t){this.onError(t,`Failed to unregister plugin "${e}"`)}})}onError(e,t,i){this.errorHandler.onError({error:e,context:Fs,customMessage:t,groupingHash:i})}},xe="cookieStorage",Fe="localStorage",Ge="sessionStorage",st="memoryStorage",jt="none",h_="test_rudder_cookie",g_="test_rudder_ls",f_="test_rudder_ss",p_="rl_user_id",v_="rl_trait",__="rl_anonymous_id",m_="rl_group_id",y_="rl_group_trait",b_="rl_page_init_referrer",E_="rl_page_init_referring_domain",S_="rl_session",k_="rl_auth_token",rs={userId:p_,userTraits:v_,anonymousId:__,groupId:m_,groupTraits:y_,initialReferrer:b_,initialReferringDomain:E_,sessionInfo:S_,authToken:k_},w_="__tld__",Mc="clientDataInCookie",Uc="clientDataInLocalStorage",T_="clientDataInMemory",Bc="clientDataInSessionStorage",Vc=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ns={[xe]:Mc,[Fe]:Uc,[st]:T_,[Ge]:Bc},Bl=(s,e)=>{try{return encodeURIComponent(s)}catch(t){e?.error(hf,t);return}},Vl=s=>{try{return decodeURIComponent(s)}catch{return}},A_=s=>{let e={},t=s.split(/\s*;\s*/),i;return t[0]&&t.forEach(r=>{i=r.split("=");let n=i[0]?Vl(i[0]):void 0;n&&(e[n]=i[1]?Vl(i[1]):void 0)}),e},R_=(s,e,t,i)=>{let r={...t||{}},n=`${Bl(s,i)}=${Bl(e,i)}`;Le(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},Fn=()=>{let s=globalThis.document.cookie;return A_(s)},I_=s=>Fn()[s],dt=function(s,e,t,i){switch(arguments.length){case 4:case 3:case 2:return R_(s,e,t,i);case 1:return s?I_(s):Fn();default:return Fn()}},O_=s=>{let e=document.createElement("a");return e.href=s,e.hostname},C_=s=>{let t=(typeof globalThis.URL!="function"?O_(s):new URL(s).hostname)?.split(".")??[],i=t[t.length-1],r=[];if(t.length===4&&i&&i===parseInt(i,10).toString())return r;if(t.length<=1)return t[0]&&t[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=t.length-2;n>=0;n-=1)r.push(t.slice(n).join("."));return r},P_=s=>{let e=C_(s);for(let t=0;t<e.length;t+=1){let i=e[t],r=w_,n={domain:`${i.indexOf("localhost")!==-1?"":"."}${i}`};try{if(dt(r,1,n),dt(r))return dt(r,null,n),i}catch{try{dt(r,null,n)}catch{}}}return""},D_=()=>{let s=`.${P_(globalThis.location.href)}`;return{maxage:Rf,path:"/",domain:!s||s==="."?void 0:s,samesite:"Lax",enabled:!0}},N_=()=>({enabled:!0}),x_=()=>({enabled:!0}),L_=()=>({enabled:!0}),Mn=class{constructor(e){le(this,"isEnabled",!0);le(this,"length",0);le(this,"data",{});this.options=L_(),this.logger=e}configure(e){return this.options=be(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,t){return this.data[e]=t,this.length=Object.keys(this.data).length,t}getItem(e){return e in this.data?this.data[e]:null}removeItem(e){return e in this.data&&delete this.data[e],this.length=Object.keys(this.data).length,null}clear(){this.data={},this.length=0}key(e){return this.keys()[e]??null}keys(){return Object.keys(this.data)}},Xi=new Mn(pt);Vi={exports:{}},F_=Vi.exports;U_=M_(),Mt=$_(U_),Gc=s=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],t=[22,1014];return s instanceof DOMException?e.includes(s.name)||t.includes(s.code):!1},os=(s=Fe,e,t)=>{let i,r,n=gf(An,s),o="unavailable",a=!0,l;try{switch(s){case st:return!0;case xe:i=e,r=h_;break;case Fe:i=e??globalThis.localStorage,r=g_;break;case Ge:i=e??globalThis.sessionStorage,r=f_;break;default:return!1}if(i&&(i.setItem(r,"true"),i.getItem(r)))return i.removeItem(r),!0;a=!1}catch(c){a=!1,l=c,Gc(c)&&(o="full")}return a||t?.warn(`${n}${o}.`,l),!1},Un=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.options=N_(),this.logger=e}configure(e){return this.options=be(this.options,e??{}),this.isSupportAvailable=os(Fe),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){Mt.set(e,t),this.length=Mt.len()}getItem(e){let t=Mt.get(e);return Se(t)?null:t}removeItem(e){Mt.remove(e),this.length=Mt.len()}clear(){Mt.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Mt.keys()}},lo=new Un(pt),Bn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.options=x_(),this.logger=e}configure(e){return this.options=be(this.options,e??{}),this.isSupportAvailable=os(Ge),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){this.store&&(this.store.setItem(e,t),this.length=this.store.length)}getItem(e){if(!this.store)return null;let t=this.store.getItem(e);return Se(t)?null:t}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){this.store?.clear(),this.length=0}key(e){return this.store?.key(e)??null}keys(){let e=[];if(!this.store)return e;for(let t=0;t<this.store.length;t+=1){let i=this.store.key(t);i!==null&&e.push(i)}return e}},co=new Bn(pt),Vn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=D_()),this.options=be(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=os(xe,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){return dt(e,t,this.options,this.logger),this.length=Object.keys(dt()).length,!0}getItem(e){let t=dt(e);return Se(t)?null:t}removeItem(e){let t=this.setItem(e,null);return this.length=Object.keys(dt()).length,t}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(dt())}},uo=new Vn(pt),Ye=s=>{switch(s){case Fe:return lo;case Ge:return co;case st:return Xi;case xe:return uo;default:return Xi}},B_=s=>{let e=uo.configure(s);u.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},V_=s=>{lo.configure(s)},G_=s=>{Xi.configure(s)},j_=s=>{co.configure(s)},H_=(s={},e={},t={},i={})=>{B_(s),V_(e),G_(t),j_(i)},Gn=class{constructor(e,t,i){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=t,this.noKeyValidation=Object.keys(this.validKeys).length===0,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=i}createValidKey(e){let{name:t,id:i,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[t,i,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[t,i,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:i,noCompoundKey:r}=this,n=Ye(st);Object.keys(i).forEach(o=>{let a=this.get(i[o]),l=r?o:[e,t,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,t){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(Xe(t,!1,[],this.logger)))}catch(r){if(Gc(r))this.logger.warn(Cp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,t);else{let n=gp(e);this.onError(r,n,n)}}}get(e){let t=this.createValidKey(e),i;try{return!t||(i=this.decrypt(this.engine.getItem(t)),Je(i)||i==="")?null:JSON.parse(i)}catch(r){let n=u.storage.encryptionPluginName.value;if(!n||!u.plugins.failedPlugins.value.includes(n)){let a=fp(e);this.onError(r,a,a)}return null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return Je(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||typeof e!="string"||Kg(e)==="")return e;let r=`storage.${t}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,t,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:i})}},z_=(s,e)=>{let t;if(s.consents.preConsent.value.enabled)switch(s.consents.preConsent.value.storage?.strategy){case"none":t=jt;break;case"session":e!=="sessionInfo"&&(t=jt);break;case"anonymousId":e!=="anonymousId"&&(t=jt);break}return t},jn=class{constructor(e,t,i){le(this,"stores",{});le(this,"isInitialized",!1);this.errorHandler=t,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=u.loadOptions.value,t={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};H_(Us(be(t.cookieStorageOptions??{},u.storage.cookie?.value??{})),Us(t.localStorageOptions),Us(t.inMemoryStorageOptions),Us(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[st,Fe,xe,Ge].forEach(t=>{Ye(t)?.isEnabled&&this.setStore({id:ns[t],name:ns[t],isEncrypted:!0,noCompoundKey:!0,type:t,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=u.storage.type.value,t=u.loadOptions.value.storage?.entries,i=u.consents.postConsent.value.storage;(se(i?.type)||se(i?.entries))&&(e=i?.type,t=i?.entries);let r=!0,n={};Vc.forEach(o=>{let a=o,l=o,c=t?.[a]?.type,h=z_(u,o)??c??e??Pn,f=this.getResolvedStorageTypeForEntry(h,o);f!==jt&&(r=!1),n={...n,[o]:{type:f,key:rs[l]}}}),Ee(()=>{u.storage.type.value=e,u.storage.entries.value=n,u.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,t){let i=e;switch(e){case Fe:Ye(Fe)?.isEnabled||(i=st);break;case Ge:Ye(Ge)?.isEnabled||(i=st);break;case st:case jt:break;case xe:default:Ye(xe)?.isEnabled?i=xe:Ye(Fe)?.isEnabled?i=Fe:Ye(Ge)?.isEnabled?i=Ge:i=st;break}return i!==e&&this.logger.warn(Pp(Yg,t,e,i)),i}setStore(e){let t=Ye(e.type);return this.stores[e.id]=new Gn(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},K_=s=>oe(s)&&oe(s.source)&&!Je(s.source.id)&&oe(s.source.config)&&Array.isArray(s.source.destinations),q_=s=>typeof s=="string"&&yc.includes(s),jc=s=>{let e=new URL(s),{host:t,protocol:i}=e,r=t.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=t,{topDomain:n,protocol:i}},W_=s=>{let{topDomain:e,protocol:t}=jc(s);return`${t}//${e}`},Y_=(s,e)=>{let t=e?window.location.origin:W_(window.location.href),i=s.startsWith("/")?s.substring(1):s;return`${t}/${i}`},X_=s=>{let{topDomain:e}=jc(window.location.href);return e===s},ls=s=>s?.endsWith("/")?ls(s.substring(0,s.length-1)):s,Hn=s=>{try{return new URL(s).host}catch{return null}},Hc=s=>Hn(s)??"",J_=s=>{let e={};try{let t=new URL(s),i="utm_";t.searchParams.forEach((r,n)=>{if(n.startsWith(i)){let o=n.substring(i.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},Q_=s=>{let e=s;try{let t=new URL(s);e=t.origin+t.pathname+t.search}catch{}return e},Z_=s=>s.replace(/\/{2,}/g,"/"),cs=s=>{if(!ne(s))return!1;try{return x(globalThis.URL)&&new URL(s),Hp.test(s)}catch{return!1}},En="none",Sn="immediate",em=s=>s?.statsCollection?.errors?.enabled===!0,tm=s=>s?.statsCollection?.metrics?.enabled===!0,sm=s=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(oe(s)){let t=q(s);e.storage=t.storage,ft(t.integrations)&&(e.integrations=t.integrations),e.discardPreConsentEvents=t.discardPreConsentEvents===!0,e.sendPageEvent=t.sendPageEvent===!0,e.trackConsent=t.trackConsent===!0,ft(t.consentManagement)&&(e.consentManagement=be(t.consentManagement,{enabled:u.consents.enabled.value}))}return e},jl=s=>ft(s)||Array.isArray(s),im=(s,e)=>{let{provider:t}=s,i=t?Dn[t]:void 0;return t&&!i&&(e.error(Zf(je,t,Dn)),t=void 0),{provider:t,consentManagerPluginName:i}},zc=(s,e)=>{let t,i=[],r=[],n=!1,o,a=s?.enabled===!0;ft(s)&&a&&({provider:o,consentManagerPluginName:t}=im(s,e),jl(s.allowedConsentIds)&&(i=s.allowedConsentIds,n=!0),jl(s.deniedConsentIds)&&(r=s.deniedConsentIds,n=!0));let l={allowedConsentIds:i,deniedConsentIds:r};return a=a&&!!t,{provider:o,consentManagerPluginName:t,initialized:n,enabled:a,consentsData:l}},rm=()=>{let s=document.querySelector("script[data-rsa-write-key]");if(s&&s.dataset.rsaWriteKey===u.lifecycle.writeKey.value)return s.src;let e=document.getElementsByTagName("script"),t=/(?:^|\/)rsa(\.min)?\.js$/;for(let i of e){let r=i.getAttribute("src");if(r&&t.test(r))return r}},nm=s=>{u.reporting.isErrorReportingEnabled.value=em(s.source.config)&&!rf(),u.reporting.isMetricsReportingEnabled.value=tm(s.source.config)},om=s=>{let{useServerSideCookies:e,dataServiceEndpoint:t,storage:i,setCookieDomain:r,sameDomainCookiesOnly:n}=u.loadOptions.value,o=i?.cookie,a=!1,l;if(e){a=e;let c=o.domain??r,d=se(c)&&!X_(yl(c))||n,h=Y_(t??qp,d);if(cs(h)){l=ls(h);let f=Hn(window.location.href),g=Hn(h);f!==g&&(o={...o,samesite:"None",secure:!0}),!n&&d&&g!==yl(c)&&(a=!1,s.warn(bp(je,c,g)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},am=s=>{let{storage:e}=u.loadOptions.value,t=e?.type;se(t)&&!q_(t)&&(s.warn(_p(je,t,Pn)),t=Pn);let i=e?.encryption?.version,r=i&&Ui[i];!Se(i)&&Se(r)?(s.warn(mp(je,i,Ui,Bt)),i=Bt):Se(i)&&(i=Bt);let n=e?.migrate,o=n&&i===Bt;n===!0&&o!==n&&s.warn(yp(je,i,Bt));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:c}=om(s);Ee(()=>{u.storage.type.value=t,u.storage.cookie.value=c,u.serverCookies.isEnabledServerSideCookies.value=a,u.serverCookies.dataServiceUrl.value=l,u.storage.encryptionPluginName.value=Ui[i],u.storage.migrate.value=o})},lm=s=>{let{provider:e,consentManagerPluginName:t,initialized:i,enabled:r,consentsData:n}=zc(u.loadOptions.value.consentManagement,s),o=u.loadOptions.value.preConsent,a=o?.storage?.strategy??En,l=["none","session","anonymousId"];se(a)&&!l.includes(a)&&(a=En,s.warn(Lp(je,o?.storage?.strategy,En)));let c=o?.events?.delivery??Sn,d=["immediate","buffer"];se(c)&&!d.includes(c)&&(c=Sn,s.warn($p(je,o?.events?.delivery,Sn))),Ee(()=>{u.consents.activeConsentManagerPluginName.value=t,u.consents.initialized.value=i,u.consents.enabled.value=r,u.consents.data.value=n,u.consents.provider.value=e,u.consents.preConsent.value={enabled:u.loadOptions.value.preConsent?.enabled===!0&&i===!1&&r===!0,storage:{strategy:a},events:{delivery:c}}})},cm=s=>{let e=u.consents.resolutionStrategy.value,t;oe(s.consentManagementMetadata)&&(u.consents.provider.value&&(e=s.consentManagementMetadata.providers.find(i=>i.provider===u.consents.provider.value)?.resolutionStrategy??u.consents.resolutionStrategy.value),t=s.consentManagementMetadata),u.consents.provider.value==="custom"&&(e=void 0),Ee(()=>{u.consents.metadata.value=q(t),u.consents.resolutionStrategy.value=e})},um=s=>{if(u.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",t=e;u.loadOptions.value.useBeacon&&(u.capabilities.isBeaconAvailable.value?t="BeaconQueue":(t=e,s.warn(kp(je)))),Ee(()=>{u.dataPlaneEvents.eventsQueuePluginName.value=t})}},dm=(s,e,t,i,r)=>{let n=new URLSearchParams({p:cc,v:Hs,build:Ks,writeKey:e,lockIntegrationsVersion:t.toString(),lockPluginsVersion:i.toString()}),o=Tc,a=n,l="/sourceConfig/",c="";if(cs(s)){let d=new URL(s);ls(d.pathname).endsWith("/sourceConfig")||(d.pathname=`${ls(d.pathname)}/sourceConfig/`),d.pathname=Z_(d.pathname),n.forEach((h,f)=>{d.searchParams.get(f)===null&&d.searchParams.set(f,h)}),o=d.origin,l=d.pathname,a=d.searchParams,c=d.hash}else r.warn(Np(je,s));return`${o}${l}?${a}${c}`},hm=s=>s.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:s_(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===Yp})),Kc=(s,e,t,i,r,n,o)=>{let a;if(n){if(!cs(n))return o.error(Qf(je,s,n)),null;a=ls(n)}else if(a=t,u.context.app.value.installType==="cdn"){let l=rm();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${ao}/${Ks}/${e}$`),`/${i}/${Ks}/${e}`)),a},gm=(s,e,t,i)=>Kc("integrations",tr,kc,s,e,t,i),fm=(s,e,t,i)=>Kc("plugins",Sc,wc,s,e,t,i),zn=class{constructor(e,t,i){this.errorHandler=t,this.logger=i,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){it(()=>{this.logger.setMinLogLevel(u.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:t,lockIntegrationsVersion:i,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=u.loadOptions.value,l=gm(Hs,i,n,this.logger);if(Le(l))return;let c;c=fm(Hs,r,o,this.logger),c!==null&&(this.attachEffects(),u.lifecycle.activeDataplaneUrl.value=ls(u.lifecycle.dataPlaneUrl.value),am(this.logger),lm(this.logger),um(this.logger),Ee(()=>{u.lifecycle.integrationsCDNPath.value=l,u.lifecycle.pluginsCDNPath.value=c,e&&(u.lifecycle.logLevel.value=e),u.lifecycle.sourceConfigUrl.value=dm(t,u.lifecycle.writeKey.value,i,r,this.logger),u.metrics.metricsServiceUrl.value=`${u.lifecycle.activeDataplaneUrl.value}/${Wp}`,u.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,t,i){this.errorHandler.onError({error:e,context:je,customMessage:t,groupingHash:i})}processConfig(e,t){if(!se(e)){se(t)?this.onError(t.error,Dl):this.onError(new Error(Dl));return}let i;try{ne(e)?i=JSON.parse(e):i=e}catch(n){this.onError(n,Cl);return}if(!K_(i)){this.onError(new Error(Cl));return}if(i.source.enabled===!1){this.logger.error(qf);return}nm(i);let r=i.source.destinations.length>0?hm(i.source.destinations):[];Ee(()=>{u.source.value={config:i.source.config,name:i.source.name,id:i.source.id,workspaceId:i.source.workspaceId},u.nativeDestinations.configuredDestinations.value=r,u.plugins.pluginsToLoadFromConfig.value=u.loadOptions.value.plugins??[],cm(i),u.lifecycle.status.value="configured"})}getConfig(){let e=u.loadOptions.value.getSourceConfig;if(e){if(!x(e)){this.logger.error(Jf(je));return}let t=e();t instanceof Promise?t.then(i=>this.processConfig(i)).catch(i=>{this.onError(i,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:u.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},pm=()=>{let s=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return s?.[1]?s[1]:"NA"},qc=(s=()=>document)=>s()?.referrer||"$direct",vm=(s=()=>document)=>{let t=s().getElementsByTagName("link"),i="";for(let r=0;t[r];r+=1){let n=t[r];if(n.getAttribute("rel")==="canonical"&&!i){i=n.getAttribute("href")??"";break}}return i},_m=(s=()=>globalThis.navigator)=>{let e=s();if(Se(e))return null;let{userAgent:t}=e,{brave:i}=e;if(i&&Object.getPrototypeOf(i).isBrave){let r=t.match(/(chrome)\/([\w.]+)/i);r&&(t=`${t} Brave/${r[2]}`)}return t},mm=(s=()=>globalThis.navigator)=>{let e=s();return Se(e)?null:e.language??e.browserLanguage},Wc=(s=()=>globalThis.location,e=()=>document)=>{let t=s(),i=vm(e),r=t.pathname,{href:n}=t,o=n,{search:a}=t;if(i)try{let h=new URL(i);h.search===""?o=i+a:o=i,r=h.pathname}catch{}let l=Q_(o),{title:c}=e(),d=qc(e);return{path:r,referrer:d,referring_domain:Hc(d),search:a,title:c,url:l,tab_url:n}},ym=(s,e="none")=>{e==="none"&&s(void 0),e==="default"&&s(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(t=>{s(t)}).catch(()=>{s()})},bm=()=>{let s=globalThis.document.createElement("div");return s.setAttribute("data-a-b","c"),s.dataset?s.dataset.aB==="c":!1},Kn={URL:()=>!x(globalThis.URL)||!x(globalThis.URLSearchParams),Promise:()=>!x(globalThis.Promise),"Number.isNaN":()=>!x(globalThis.Number.isNaN),"Number.isInteger":()=>!x(globalThis.Number.isInteger),"Array.from":()=>!x(globalThis.Array.from),"Array.prototype.find":()=>!x(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!x(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!x(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!x(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!x(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!x(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!x(globalThis.String.fromCodePoint),"Object.entries":()=>!x(globalThis.Object.entries),"Object.values":()=>!x(globalThis.Object.values),"Object.assign":()=>!x(globalThis.Object.assign),"Object.fromEntries":()=>!x(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!bm(),TextEncoder:()=>!x(globalThis.TextEncoder)||!x(globalThis.TextDecoder),requestAnimationFrame:()=>!x(globalThis.requestAnimationFrame)||!x(globalThis.cancelAnimationFrame),CustomEvent:()=>!x(globalThis.CustomEvent),"navigator.sendBeacon":()=>!x(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!x(globalThis.Uint8Array),Set:()=>!x(globalThis.Set),atob:()=>!x(globalThis.atob)},Em=()=>{let s=Object.keys(Kn),e=!1;for(let t=0;t<s.length;t++){let i=Kn[s[t]];if(x(i)&&i()){e=!0;break}}return e},Sm="https://polyfill-fastly.io/v3/polyfill.min.js",km=`${Sm}?version=3.111.0&features=${Object.keys(Kn).join("%2C")}`,wm=10*1e3,Hl="rudderstackPolyfill",Tm=()=>!Je(globalThis.crypto)&&x(globalThis.crypto.getRandomValues),zl=()=>!Je(globalThis.navigator.userAgentData),Am=()=>!Je(globalThis.navigator.sendBeacon)&&x(globalThis.navigator.sendBeacon),Kl=()=>{let s={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return s={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},s},qn=class{constructor(e,t,i){this.httpClient=e,this.errorHandler=t,this.logger=i,this.externalSrcLoader=new Ki(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Ee(()=>{u.capabilities.storage.isCookieStorageAvailable.value=os(xe,Ye(xe),this.logger),u.capabilities.storage.isLocalStorageAvailable.value=os(Fe,void 0,this.logger),u.capabilities.storage.isSessionStorageAvailable.value=os(Ge,void 0,this.logger),u.capabilities.isBeaconAvailable.value=Am(),u.capabilities.isUaCHAvailable.value=zl(),u.capabilities.isCryptoAvailable.value=Tm(),u.capabilities.isOnline.value=globalThis.navigator.onLine,u.context.userAgent.value=_m(),u.context.locale.value=mm(),u.context.screen.value=Kl(),u.context.timezone.value=pm(),zl()&&ym(e=>{u.context["ua-ch"].value=e},u.loadOptions.value.uaChTrackLevel)}),it(()=>{u.loadOptions.value.sendAdblockPage===!0&&u.lifecycle.sourceConfigUrl.value!==void 0&&Pc(this.httpClient)})}prepareBrowserCapabilities(){u.capabilities.isLegacyDOM.value=Em();let e=u.loadOptions.value.polyfillURL,t=km;if(as(e)&&(cs(e)?t=e:this.logger.warn(Up(An,e))),u.loadOptions.value.polyfillIfRequired&&u.capabilities.isLegacyDOM.value&&cs(t)){let r=t!==u.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${u.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,t=`${t}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:t,id:Hl,async:!0,timeout:wm,callback:n=>{n?r||this.onReady():this.onError(new Error(xp(Hl,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{u.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{u.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Cf(()=>{u.context.screen.value=Kl()},this))}onReady(){this.detectBrowserCapabilities(),u.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:An,groupingHash:t})}},Rm="web",Im=["integrations","anonymousId","originalTimestamp"],ql=["library","consentManagement","userAgent","ua-ch","screen"],kn=["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"],Yc=s=>typeof s=="number"&&!Number.isNaN(s),Om=(s,e)=>e.toString().length>=s,Ji=s=>Yc(s)&&s>=0&&Number.isInteger(s),Wl=10,Xc=s=>{let{cutOff:e}=s,t=Date.now();return!!(e?.enabled&&e.expiresAt&&t>e.expiresAt)},Yl=s=>!s.expiresAt||Date.now()>s.expiresAt||Xc(s),Cm=()=>Date.now(),Pm=(s,e)=>!s||!Ji(s)||!Om(Wl,s)?(e.warn(Op(Ut,s,Wl)),!1):!0,Dm=s=>{if(s?.enabled)return s.expiresAt??(Ji(s.duration)?Date.now()+s.duration:void 0)},Nm=s=>{let{timeout:e,cutOff:t}=s,i=Date.now();return{id:i,expiresAt:i+e,timeout:e,autoTrack:!0,...t&&{cutOff:t}}},xm=(s,e)=>({id:Pm(s,e)?s:Cm(),sessionStart:void 0,manualTrack:!0}),Vs=s=>s===xe||s===Fe||s===Ge||s===st,Wn=()=>Qi(),Lm=s=>{if(Vg(s)){let{entries:e,...t}=yn;return{...t,entries:{...e,anonymousId:s}}}return oe(s)&&oe(s.entries)?be(yn,s):{...yn}},$m=s=>{let e=Wc(),t={};return Object.keys(e).forEach(i=>{t[i]=s?.[i]||e[i]}),t.initial_referrer=s?.initial_referrer||u.session.initialReferrer.value,t.initial_referring_domain=s?.initial_referring_domain||u.session.initialReferringDomain.value,t},Fm=(s,e)=>{let t=e?.page||{},i=s,r=Wc();return Object.keys(r).forEach(n=>{Se(i[n])&&(i[n]=t[n]||r[n])}),Se(i.initial_referrer)&&(i.initial_referrer=t.initial_referrer||u.session.initialReferrer.value),Se(i.initial_referring_domain)&&(i.initial_referring_domain=t.initial_referring_domain||u.session.initialReferringDomain.value),i},wn=(s,e,t)=>{oe(s)&&Object.keys(s).forEach(i=>{(kn.includes(i)||kn.includes(i.toLowerCase()))&&t.warn(Ep(rc,i,e,kn))})},Mm=(s,e)=>{let{properties:t,traits:i,context:r}=s,{traits:n}=r;wn(t,"properties",e),wn(i,"traits",e),wn(n,"context.traits",e)},Um=(s,e)=>{e.anonymousId&&ne(e.anonymousId)&&(s.anonymousId=e.anonymousId),ft(e.integrations)&&(s.integrations=e.integrations),e.originalTimestamp&&ne(e.originalTimestamp)&&(s.originalTimestamp=e.originalTimestamp)},Bm=(s,e,t)=>{let i=s;return Object.keys(e).forEach(r=>{if(!Im.includes(r)&&!ql.includes(r))if(r!=="context")i=be(i,{[r]:e[r]});else if(!Se(e[r])&&oe(e[r])){let n={};Object.keys(e[r]).forEach(o=>{ql.includes(o)||(n[o]=e[r][o])}),i=be(i,{...n})}else t.warn(Sp(rc))}),i},Vm=(s,e,t)=>{oe(e)&&(Um(s,e),s.context=Bm(s.context,e,t))},Gm=s=>{let e;return u.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=u.consents.postConsent.value.integrations??u.nativeDestinations.loadOnlyIntegrations.value:s?e=s:e=Ec,q(e)},Ms=(s,e,t,i)=>{let r={channel:Rm,context:{traits:q(u.session.userTraits.value),sessionId:u.session.sessionInfo.value.id||void 0,sessionStart:u.session.sessionInfo.value.sessionStart||void 0,...u.consents.enabled.value&&{consentManagement:{deniedConsentIds:q(u.consents.data.value.deniedConsentIds),allowedConsentIds:q(u.consents.data.value.allowedConsentIds),provider:u.consents.provider.value,resolutionStrategy:u.consents.resolutionStrategy.value}},"ua-ch":u.context["ua-ch"].value,app:u.context.app.value,library:u.context.library.value,userAgent:u.context.userAgent.value,os:u.context.os.value,locale:u.context.locale.value,screen:u.context.screen.value,campaign:J_(globalThis.location.href),page:$m(t),timezone:u.context.timezone.value,...u.autoTrack.enabled.value&&{autoTrack:{...u.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:u.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:af(),messageId:Qi(),userId:s.userId||u.session.userId.value};Vs(u.storage.entries.value.anonymousId?.type)?r.anonymousId=u.session.anonymousId.value:r.anonymousId=Wn(),u.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),s.type==="identify"&&(r.context.traits=u.storage.entries.value.userTraits?.type!==jt?q(u.session.userTraits.value):s.context.traits),s.type==="group"&&((s.groupId||u.session.groupId.value)&&(r.groupId=s.groupId||u.session.groupId.value),(s.traits||u.session.groupTraits.value)&&(r.traits=u.storage.entries.value.groupTraits?.type!==jt?q(u.session.groupTraits.value):s.traits));let n=be(s,r);return n.event===void 0&&(n.event=null),n.properties===void 0&&(n.properties=null),Vm(n,e,i),Mm(n,i),n.integrations=Gm(n.integrations),n},Yn=class{constructor(e){this.logger=e}generatePageEvent(e,t,i,r){let n=i??{};return n=Fm(n,r),Ms({properties:n,name:t,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,t,i){return Ms({properties:t,event:e,type:"track"},i,void 0,this.logger)}generateIdentifyEvent(e,t,i){return Ms({userId:e,type:"identify",context:{traits:t}},i,void 0,this.logger)}generateAliasEvent(e,t,i){let n=Ms({previousId:t,type:"alias"},i,void 0,this.logger);return n.userId=e??n.userId,n}generateGroupEvent(e,t,i){let r={type:"group"};return e&&(r.groupId=e),t&&(r.traits=t),Ms(r,i,void 0,this.logger)}create(e){let t;switch(e.type){case"page":t=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":t=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":t=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":t=this.generateAliasEvent(e.to,e.from,e.options);break;default:t=this.generateGroupEvent(e.groupId,e.traits,e.options);break}return t}},Xn=class{constructor(e,t,i,r){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=i,this.logger=r,this.eventFactory=new Yn(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let t=this.eventFactory.create(e);this.eventRepository.enqueue(t,e.callback)}},Jn=class{constructor(e,t,i,r,n){this.storeManager=t,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=i,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:e,anonymousIdOptions:t}=u.loadOptions.value,i;as(e)&&typeof e=="string"&&(i=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(i??this.getAnonymousId(t)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),i=this.getSessionInfo()??Z.sessionInfo;e={autoTrack:t.autoTrack&&i.manualTrack!==!0,timeout:t.timeout,manualTrack:i.manualTrack,expiresAt:i.expiresAt,id:i.id,sessionStart:i.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=Z.sessionInfo:t.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:i.cutOff?.expiresAt})}else e=Z.sessionInfo;u.session.sessionInfo.value=e,u.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(u.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),t=this.getInitialReferringDomain();if(e&&t)this.setInitialReferrer(e),this.setInitialReferringDomain(t);else{let i=e||qc();this.setInitialReferrer(i),this.setInitialReferringDomain(Hc(i))}}isPersistenceEnabledForStorageEntry(e){return Vs(u.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=u.storage.entries.value,t=[xe,Fe,Ge];Object.keys(e).forEach(i=>{let r=i,n=e[r]?.type,o=this.storeManager?.getStore(ns[n]);o&&t.forEach(a=>{let l=this.storeManager?.getStore(ns[a]);if(l&&a!==n){let c=l.get(rs[r]);Bg(c)&&o.set(rs[r],c),l.remove(rs[r])}})})}migrateStorageIfNeeded(e,t){if(!u.storage.migrate.value)return;let i=e??[];i.length===0&&[Mc,Uc,Bc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&i.push(a)}),(t??Object.keys(rs)).forEach(n=>{let o=rs[n];i.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);Je(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=u.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let t,i=u.loadOptions.value.sessions?.timeout;Ji(i)?t=i:(this.logger.warn(wp(Ut,i,Rn)),t=Rn),t===0&&(this.logger.warn(Rp(Ut)),e=!1),t>0&&t<Rl&&this.logger.warn(Ip(Ut,t,Rl));let r=this.getCutOffInfo(t);return{timeout:t,autoTrack:e,cutOff:r}}getCutOffInfo(e){let t=u.loadOptions.value.sessions.cutOff,i,r=!1;return t.enabled===!0&&(i=t.duration,r=!0,Ji(i)?i<e&&(this.logger.warn(Ap(Ut,i,e)),r=!1):(this.logger.warn(Tp(Ut,i,Al)),i=Al)),{enabled:r,duration:i}}onError(e,t,i){this.errorHandler.onError({error:e,context:Ut,customMessage:t,groupingHash:i})}getEncryptedCookieData(e,t){let i=[];return e.forEach(r=>{let n=t?.encrypt(Xe(r.value,!1,[],this.logger));as(n)&&i.push({name:r.name,value:n})}),i}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:u.serverCookies.dataServiceUrl.value,options:{method:"POST",data:Xe({reqType:"setCookies",workspaceId:u.source.value?.workspaceId,data:{options:{maxAge:u.storage.cookie.value?.maxage,path:u.storage.cookie.value?.path,domain:u.storage.cookie.value?.domain,sameSite:u.storage.cookie.value?.samesite,secure:u.storage.cookie.value?.secure,expires:u.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:t})}setServerSideCookies(e,t,i){let r=Object.keys(e),n=()=>r.map(c=>({name:e[c].name,value:u.session[c].value})),o={};r.forEach(c=>{o[e[c].name]=i?.get(e[c].name)});let a=()=>{r.forEach(c=>{this.serverSideCookiesRequestInProgress[c]=!1})},l=()=>{n().forEach(c=>{t&&t(c.name,c.value)})};try{let c={};r.forEach(h=>{c[e[h].name]=u.session[h].value});let d=this.getEncryptedCookieData(n(),i);d.length>0?this.makeRequestToSetCookie(d,(h,f)=>{a(),f?.xhr?.status===200?n().forEach(g=>{let p=o[g.name],v=i?.get(g.name);Xe(c[g.name],!1,[])!==Xe(v,!1,[])&&(Le(p)&&Le(v)&&this.logger.error(vp(g.name)),t&&t(g.name,g.value))}):(this.logger.error(pp(f?.xhr?.status)),l())}):(l(),a())}catch(c){this.onError(c,Nl,Nl),l(),a()}}syncValueToStorage(e){let t=u.storage.entries.value,i=t[e]?.type;if(Vs(i)){let r=this.storeManager.getStore(ns[i]),n=t[e]?.key,o=u.session[e].value;o&&(ne(o)||ft(o))?u.serverCookies.isEnabledServerSideCookies.value&&i===xe?(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,c)=>{r?.set(l,c)},r)},Qp)):r?.set(n,o):r?.remove(n)}}registerEffects(){Vc.forEach(e=>{it(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let i=e;(!ne(e)||!i)&&(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&t&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t)),i=i||Wn()):i=Z.anonymousId,u.session.anonymousId.value=i}getAnonymousId(e){let t=u.storage.entries.value.anonymousId?.type;if(Vs(t)){let i=u.session.anonymousId.value;(!i||i===Z.anonymousId)&&(i=this.getEntryValue("anonymousId")),!i&&e&&(i=this.pluginsManager?.invokeSingle("storage.getAnonymousId",Ye,e)),u.session.anonymousId.value=i||Wn()}return u.session.anonymousId.value}getEntryValue(e){let t=u.storage.entries.value,i=t[e]?.type;if(Vs(i)){let r=this.storeManager?.getStore(ns[i]);this.migrateStorageIfNeeded([r],[e]);let n=t[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let t=Ye(xe);return t?.isEnabled?t.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?u.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()??Z.sessionInfo;return e.autoTrack&&!Yl(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??Z.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=u.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),u.session.sessionInfo.value=e,u.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=u.session,{manualTrack:t,autoTrack:i,timeout:r,cutOff:n}=e.sessionInfo.value;if(i){let o={...Z.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){let{session:t}=u,i=Lm(e);Ee(()=>{Object.keys(Z).forEach(r=>{let n=r;if(i.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[n].value=Z[n];break}})})}setUserId(e){u.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:Z.userId}setUserTraits(e){u.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&oe(e)?be(u.session.userTraits.value??Z.userTraits,e):Z.userTraits}setGroupId(e){u.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:Z.groupId}setGroupTraits(e){u.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&oe(e)?be(u.session.groupTraits.value??Z.groupTraits,e):Z.groupTraits}setInitialReferrer(e){u.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:Z.initialReferrer}setInitialReferringDomain(e){u.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:Z.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if(Yl(e))t=Nm(e);else{let i=Date.now(),r=e.timeout;t.expiresAt=i+r}if(Xc(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){let i=Dm(t.cutOff);t.cutOff.expiresAt=i}u.session.sessionInfo.value=t}start(e){u.session.sessionInfo.value=xm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){u.session.sessionInfo.value=Z.sessionInfo}setAuthToken(e){u.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:Z.authToken}},jm=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],Hm=jm,zm=(s,e)=>{let t=q(e);return ne(t.setCookieDomain)||(t.setCookieDomain=void 0),["Strict","Lax","None"].includes(t.sameSiteCookie)||(t.sameSiteCookie=void 0),t.secureCookie=tt(t.secureCookie,s.secureCookie),t.sameDomainCookiesOnly=tt(t.sameDomainCookiesOnly,s.sameDomainCookiesOnly),["none","default","full"].includes(t.uaChTrackLevel)||(t.uaChTrackLevel=void 0),t.integrations=ct(t.integrations),Array.isArray(t.plugins)||(t.plugins=Hm),t.useGlobalIntegrationsConfigInEvents=tt(t.useGlobalIntegrationsConfigInEvents,s.useGlobalIntegrationsConfigInEvents),t.bufferDataPlaneEventsUntilReady=tt(t.bufferDataPlaneEventsUntilReady,s.bufferDataPlaneEventsUntilReady),t.sendAdblockPage=tt(t.sendAdblockPage,s.sendAdblockPage),t.useServerSideCookies=tt(t.useServerSideCookies,s.useServerSideCookies),ne(t.dataServiceEndpoint)||(t.dataServiceEndpoint=void 0),t.sendAdblockPageOptions=ct(t.sendAdblockPageOptions),t.loadIntegration=tt(t.loadIntegration,s.loadIntegration),ft(t.storage)?(t.storage.migrate=tt(t.storage.migrate,s.storage?.migrate),t.storage.cookie=ct(t.storage.cookie),t.storage.encryption=ct(t.storage.encryption),t.storage=ji(t.storage)):t.storage=void 0,t.destinationsQueueOptions=ct(t.destinationsQueueOptions),t.queueOptions=ct(t.queueOptions),t.lockIntegrationsVersion=tt(t.lockIntegrationsVersion,s.lockIntegrationsVersion),t.lockPluginsVersion=tt(t.lockPluginsVersion,s.lockPluginsVersion),Yc(t.dataPlaneEventsBufferTimeout)||(t.dataPlaneEventsBufferTimeout=void 0),t.beaconQueueOptions=ct(t.beaconQueueOptions),t.preConsent=ct(t.preConsent),t.sourceConfigurationOverride=ct(t.sourceConfigurationOverride),be(s,ji(t))},Xl="dataplaneEventsQueue",Jl="destinationsEventsQueue",Km="transformEvent",qm=(s,e)=>Object.keys(s).filter(t=>s[t]!==!0||!e[t]).reduce((t,i)=>{let r=q(t);return r[i]=s[i],r},{}),Wm=(s,e)=>{let t=q(s),i=e.nativeDestinations.integrationsConfig.value,r=qm(s.integrations,i);return t.integrations=be(i,r),t},Ym=s=>s.consents.preConsent.value.enabled&&s.consents.preConsent.value.events?.delivery==="buffer",Gi=(s,e,t,i)=>{if(se(s))if(x(s))try{s(...e)}catch(r){i.error(Dp(t),r)}else i.error(bc(t))},Qn=class{constructor(e,t,i,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=i,this.logger=n,this.storeManager=t}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${Xl}.init`,u,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${Km}.init`,u,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${Jl}.init`,u,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),it(()=>{u.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=Ym(u),t;it(()=>{let i=u.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&u.nativeDestinations.clientDestinationsReady.value===!1;(u.nativeDestinations.activeDestinations.value.some(n=>t_(n))===!1||i===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(t),this.dataplaneEventsQueue?.start())}),u.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(t=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},u.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(u.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,t){let i=Wm(e,u);this.pluginsManager.invokeSingle(`${Xl}.enqueue`,u,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let r=q(e);this.pluginsManager.invokeSingle(`${Jl}.enqueue`,u,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${ro}`;Gi(t,[i],n,this.logger)}},Ql=s=>{let e=new CustomEvent(s,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},Xm=s=>ne(s)&&s.trim().length>0,Jm=s=>cs(s),Zn=class{constructor(){this.preloadBuffer=new On,this.initialized=!1,this.errorHandler=xc,this.logger=pt,this.externalSrcLoader=new Ki(this.logger),this.httpClient=Cc,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new qn(this.httpClient,this.errorHandler,this.logger)}load(e,t,i={}){if(!u.lifecycle.status.value){if(!Xm(e)){this.logger.error(lp(xi,e));return}if(!Jm(t)){this.logger.error(cp(xi,t));return}Ee(()=>{u.lifecycle.writeKey.value=q(e),u.lifecycle.dataPlaneUrl.value=q(t),u.loadOptions.value=zm(u.loadOptions.value,i),u.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(u.loadOptions.value.logLevel??mc),zs("state",u,e),this.startLifecycle()}}startLifecycle(){it(()=>{try{switch(u.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 t="Failed to load the SDK";this.errorHandler.onError({error:e,context:xi,customMessage:t,groupingHash:t})}})}onBrowserCapabilitiesReady(){xf(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),u.consents.preConsent.value.enabled===!0?u.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(t=>this.preloadBuffer.enqueue(q(t)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&Lf([...e],this)}}prepareInternalServices(){this.pluginsManager=new $n(Zv,this.errorHandler,this.logger),this.storeManager=new jn(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new zn(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Jn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Qn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Xn(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){u.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(u.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),u.consents.enabled.value&&!u.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",u,this.logger),u.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",u,this.storeManager,this.logger)),this.eventManager?.init(),u.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Ee(()=>{u.lifecycle.loaded.value=!0,u.lifecycle.status.value="loaded"}),this.initialized=!0;let e=u.loadOptions.value.onLoaded;Gi(e,[globalThis.rudderanalytics],Xg,this.logger),Ql("RSA_Initialised")}onReady(){u.lifecycle.status.value="readyExecuted",u.eventBuffer.readyCallbacksArray.value.forEach(e=>{Gi(e,[],_n,this.logger)}),Ql("RSA_Ready")}processBufferedEvents(){let e=u.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let t=e.shift();if(u.eventBuffer.toBeProcessedArray.value=e,t){let i=t[0];x(this[i])&&this[i](...t.slice(1),!0)}e=u.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if(u.lifecycle.status.value==="destinationsLoading"||u.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",u,this.pluginsManager,this.errorHandler,this.logger);let e=u.nativeDestinations.activeDestinations.value.length;if(e===0){Ee(()=>{u.nativeDestinations.clientDestinationsReady.value=!0,u.lifecycle.status.value="destinationsReady"});return}u.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",u,this.externalSrcLoader,this.errorHandler,this.logger),it(()=>{u.nativeDestinations.initializedDestinations.value.length+u.nativeDestinations.failedDestinations.value.length===e&&Ee(()=>{u.lifecycle.status.value="destinationsReady",u.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){u.lifecycle.status.value!=="ready"&&Ee(()=>{u.lifecycle.status.value="ready"})}ready(e,t=!1){let i="ready";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),!x(e)){this.logger.error(bc(_n));return}u.lifecycle.status.value==="readyExecuted"?Gi(e,[],_n,this.logger):u.eventBuffer.readyCallbacksArray.value=[...u.eventBuffer.readyCallbacksArray.value,e]}page(e,t=!1){let i="page";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),u.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),u.capabilities.isAdBlocked.value===!0&&e.category!==kl&&this.page(zi(kl,bf,{path:Ef},u.loadOptions.value.sendAdblockPageOptions))}track(e,t=!1){let i="track";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event - ${e.name}`),u.metrics.triggered.value+=1,this.eventManager?.addEvent({type:i,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,t=!1){let i="identify";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),u.metrics.triggered.value+=1,e.userId&&u.session.userId.value&&e.userId!==u.session.userId.value&&this.reset(),Le(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:i,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,t=!1){let i="alias";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),u.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:i,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,t=!1){let i="group";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),u.metrics.triggered.value+=1,Le(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:i,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,t=!1){let i="reset";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,t,i=!1){let r="setAnonymousId";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[r,e,t]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,t)}getUserId(){return u.session.userId.value}getUserTraits(){return u.session.userTraits.value}getGroupId(){return u.session.groupId.value}getGroupTraits(){return u.session.groupTraits.value}startSession(e,t=!1){let i="startSession";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let t="endSession";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[t]];return}this.errorHandler.leaveBreadcrumb(`New ${t} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,t=!1){let i="consent";if(!u.lifecycle.loaded.value){u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Ee(()=>{u.consents.preConsent.value={...u.consents.preConsent.value,enabled:!1},u.consents.postConsent.value=sm(e);let{initialized:r,consentsData:n}=zc(u.consents.postConsent.value.consentManagement,this.logger);u.consents.initialized.value=r,u.consents.data.value=n}),u.consents.enabled.value&&!u.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",u,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(t)}sendTrackingEvents(e){if(u.consents.postConsent.value.trackConsent){let t=io(Sf);e?u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(u.consents.postConsent.value.sendPageEvent){let t=zi();e?u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,i=!1){let r="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,u,this.logger);else{if(u.lifecycle.loaded.value){this.logger.error(jp(xi,e));return}u.eventBuffer.toBeProcessedArray.value=[...u.eventBuffer.toBeProcessedArray.value,[r,e,t]]}}},Vt=class Vt{constructor(){le(this,"analyticsInstances",{});le(this,"defaultAnalyticsKey","");le(this,"logger",pt);try{if(Vt.globalSingleton)return Vt.globalSingleton;Vt.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(),Vt.globalSingleton=this,u.autoTrack.pageLifecycle.pageViewId.value=Qi(),u.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){ge(e)}}createSafeAnalyticsInstance(){u.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(){xc.init(),uo.configure(),lo.configure(),co.configure(),Xi.configure()}setDefaultInstanceKey(e){ne(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;return(!ne(t)||!t)&&(t=this.defaultAnalyticsKey),this.analyticsInstances[t]||(this.analyticsInstances[t]=new Zn),this.analyticsInstances[t]}catch(t){ge(t);return}}load(e,t,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let r=dc(Gs);Nf(r),zs(Gs,q(r)),this.getAnalyticsInstance(e)?.load(e,t,W(i))}catch(r){ge(r)}}trackPageLifecycleEvents(e){let{autoTrack:t,useBeacon:i}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=t??{},{events:a=[vn.UNLOADED],enabled:l=r,options:c=n}=o??{};u.autoTrack.pageLifecycle.enabled.value=l,u.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,i,c)}setupPageUnloadTracking(e,t,i){(e.length===0||e.includes(vn.UNLOADED))&&(t===!0?of(r=>{if(r===!1&&u.lifecycle.loaded.value){let n=Date.now(),o=n-u.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(vn.UNLOADED,{timeOnPage:o},{...i,originalTimestamp:nc(new Date(n))})}},!0):this.logger.warn(Bp(Qg)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=Df(e);zs(Gs,q([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(W(e))}catch(t){ge(t)}}page(e,t,i,r,n){try{this.getAnalyticsInstance()?.page(zi(W(e),W(t),W(i),W(r),W(n)))}catch(o){ge(o)}}track(e,t,i,r){try{this.getAnalyticsInstance()?.track(io(W(e),W(t),W(i),W(r)))}catch(n){ge(n)}}identify(e,t,i,r){try{this.getAnalyticsInstance()?.identify(tc(W(e),W(t),W(i),W(r)))}catch(n){ge(n)}}alias(e,t,i,r){try{this.getAnalyticsInstance()?.alias(sc(W(e),W(t),W(i),W(r)))}catch(n){ge(n)}}group(e,t,i,r){try{this.getAnalyticsInstance()?.group(ic(W(e),W(t),W(i),W(r)))}catch(n){ge(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(W(e))}catch(t){ge(t)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(W(e))}catch(t){ge(t);return}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(W(e),W(t))}catch(i){ge(i)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){ge(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){ge(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){ge(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){ge(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(W(e))}catch(t){ge(t)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){ge(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){ge(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(W(e))}catch(t){ge(t)}}consent(e){try{this.getAnalyticsInstance()?.consent(W(e))}catch(t){ge(t)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(W(e),W(t))}catch(i){ge(i)}}};le(Vt,"globalSingleton",null);us=Vt});var Qc,Zc,go,Jc,eu,tu,su,iu,qs=Pe(()=>{"use strict";Qc="https://deriv.com/cdn-cgi/trace",Zc="https://cdn.growthbook.io",go="https://deriv-dataplane.rudderstack.com",Jc="https://ph.deriv.com",eu="https://us.posthog.com",tu=()=>{if(typeof window>"u")return Jc;let s=window.location.hostname;return s.includes(".deriv.me")?"https://ph.deriv.me":s.includes(".deriv.be")?"https://ph.deriv.be":s.includes(".deriv.ae")?"https://ph.deriv.ae":Jc},su=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],iu=["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 ir(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)s[i]=t[i]}return s}function fo(s,e){function t(r,n,o){if(!(typeof document>"u")){o=ir({},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+"="+s.write(n,r)+a}}function i(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("="),c=l.slice(1).join("=");try{var d=decodeURIComponent(l[0]);if(o[d]=s.read(c,d),r===d)break}catch{}}return r?o[r]:o}}return Object.create({set:t,get:i,remove:function(r,n){t(r,"",ir({},n,{expires:-1}))},withAttributes:function(r){return fo(this.converter,ir({},this.attributes,r))},withConverter:function(r){return fo(ir({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(s)}})}var Qm,ru,nu=Pe(()=>{"use strict";Qm={read:function(s){return s[0]==='"'&&(s=s.slice(1,-1)),s.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(s){return encodeURIComponent(s).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};ru=fo(Qm,{path:"/"})});var Rt,nr,Ws,rr,ou,Ht,au,lu,Ys=Pe(()=>{"use strict";nu();qs();Rt=(s,e)=>(...t)=>{e()&&console.log(`[ANALYTIC]${s}`,...t)},nr=s=>{let e=s.split("@")[1]?.toLowerCase();return e?iu.includes(e):!1},Ws=s=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s),rr=null,ou=async()=>{if(rr)return rr;let s=JSON.parse(ru.get("website_status")||"{}")?.clients_country;return rr=(async()=>{try{let e=await fetch(Qc).catch(()=>null);if(!e)return s||"";let t=await e.text().catch(()=>"");return t?Object.fromEntries(t.split(`
5
+ `).map(r=>r.split("=",2))).loc?.toLowerCase()||s||"":s||""}catch{return s||""}})(),rr},Ht=s=>{if(s==null||typeof s!="object")return s;if(Array.isArray(s)){let i=[];for(let r=0;r<s.length;r++){let n=Ht(s[r]);n!=null&&i.push(n)}return i.length?i:void 0}let e={},t=!1;for(let i in s){if(!Object.prototype.hasOwnProperty.call(s,i))continue;let r=Ht(s[i]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[i]=r,t=!0)}return t?e:void 0},au=(s,e)=>{for(let t in s){if(!Object.prototype.hasOwnProperty.call(s,t))continue;let i=s[t];i&&typeof i=="object"&&!Array.isArray(i)?au(i,e):e[t]=i}},lu=s=>{if(s==null||typeof s!="object"||Array.isArray(s))return s;let e={};return au(s,e),e}});function _u(){return vu}function po(s){let e=2166136261,t=s.length;for(let i=0;i<t;i++)e^=s.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Xs(s,e,t){return t===2?po(po(s+e)+"")%1e4/1e4:t===1?po(e+s)%1e3/1e3:null}function ey(s){return s<=0?[]:new Array(s).fill(1/s)}function cr(s,e){return s>=e[0]&&s<e[1]}function mu(s,e){let t=Xs("__"+e[0],s,1);return t===null?!1:t>=e[1]&&t<e[2]}function yu(s,e){for(let t=0;t<e.length;t++)if(cr(s,e[t]))return t;return-1}function _o(s){try{let e=s.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function ur(s,e){if(!e.length)return!1;let t=!1,i=!1;for(let r=0;r<e.length;r++){let n=iy(s,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else t=!0,n&&(i=!0)}return i||!t}function ty(s,e,t){try{let i=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(i="\\/?"+i.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+i+"$","i").test(s)}catch{return!1}}function sy(s,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),i=[[s.host,t.host,!1],[s.pathname,t.pathname,!0]];return t.hash&&i.push([s.hash,t.hash,!1]),t.searchParams.forEach((r,n)=>{i.push([s.searchParams.get(n)||"",r,!1])}),!i.some(r=>!ty(r[0],r[1],r[2]))}catch{return!1}}function iy(s,e,t){try{let i=new URL(s,"https://_");if(e==="regex"){let r=_o(t);return r?r.test(i.href)||r.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return sy(i,t);return!1}catch{return!1}}function bu(s,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=ey(s);t=t||i,t.length!==s&&(t=i);let r=t.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(t=i);let n=0;return t.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function Eu(s,e,t){if(!e)return null;let i=e.split("?")[1];if(!i)return null;let r=i.replace(/#.*/,"").split("&").map(n=>n.split("=",2)).filter(([n])=>n===s).map(([,n])=>parseInt(n));return r.length>0&&r[0]>=0&&r[0]<t?r[0]:null}function Su(s){try{return s()}catch(e){return console.error(e),!1}}async function Kt(s,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||vu.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let i=await t.importKey("raw",vo(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=s.split("."),o=await t.decrypt({name:"AES-CBC",iv:vo(r)},i,vo(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Js(s){return typeof s=="string"?s:JSON.stringify(s)}function Me(s){typeof s=="number"&&(s=s+""),(!s||typeof s!="string")&&(s="0");let e=s.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}function ku(){let s;try{s="1.6.5"}catch{s=""}return s}function wu(s,e){let t,i;try{t=new URL(s),i=new URL(e)}catch(r){return console.error(`Unable to merge query strings: ${r}`),e}return t.searchParams.forEach((r,n)=>{i.searchParams.has(n)||i.searchParams.set(n,r)}),i.toString()}function pu(s){return typeof s=="object"&&s!==null}function dr(s){return s.urlPatterns&&s.variations.some(e=>pu(e)&&"urlRedirect"in e)?"redirect":s.variations.some(e=>pu(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function hr(s,e){return new Promise(t=>{let i=!1,r,n=o=>{i||(i=!0,r&&clearTimeout(r),t(o||null))};e&&(r=setTimeout(()=>n(),e)),s.then(o=>n(o)).catch(()=>n())})}var vu,vo,Qs=Pe(()=>{"use strict";vu={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};vo=s=>Uint8Array.from(atob(s),e=>e.charCodeAt(0))});function Ru(s){Object.assign(Ae,s),Ae.backgroundSync||ko()}async function Iu({instance:s,timeout:e,skipCache:t,allowStale:i,backgroundSync:r}){return r||(Ae.backgroundSync=!1),ay({instance:s,allowStale:i,timeout:e,skipCache:t})}function ry(s){let e=Zs(s),t=fs.get(e)||new Set;t.add(s),fs.set(e,t)}function Ou(s){fs.forEach(e=>e.delete(s))}function ny(){ps.forEach(s=>{s&&(s.state="idle",Eo(s))})}function oy(){ps.forEach(s=>{s&&s.state==="idle"&&So(s)})}async function Au(){try{if(!rt.localStorage)return;await rt.localStorage.setItem(Ae.cacheKey,JSON.stringify(Array.from(vt.entries())))}catch{}}async function ay({instance:s,allowStale:e,timeout:t,skipCache:i}){let r=Zs(s),n=yo(s),o=new Date,a=new Date(o.getTime()-Ae.maxAge+Ae.staleTTL);await ly();let l=!Ae.disableCache&&!i?vt.get(n):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&vs.add(r),l.staleAt<o?mo(s):bo(s),{data:l.data,success:!0,source:"cache"}):await hr(mo(s),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function Zs(s){let[e,t]=s.getApiInfo();return`${e}||${t}`}function yo(s){let e=Zs(s);if(!("isRemoteEval"in s)||!s.isRemoteEval())return e;let t=s.getAttributes(),i=s.getCacheKeyAttributes()||Object.keys(s.getAttributes()),r={};i.forEach(a=>{r[a]=t[a]});let n=s.getForcedVariations(),o=s.getUrl();return`${e}||${JSON.stringify({ca:r,fv:n,url:o})}`}async function ly(){if(!Tu){Tu=!0;try{if(rt.localStorage){let s=await rt.localStorage.getItem(Ae.cacheKey);if(!Ae.disableCache&&s){let e=JSON.parse(s);e&&Array.isArray(e)&&e.forEach(([t,i])=>{vt.set(t,{...i,staleAt:new Date(i.staleAt)})}),Cu()}}}catch{}if(!Ae.disableIdleStreams){let s=gs.startIdleListener();s&&(gs.stopIdleListener=s)}}}function Cu(){let s=Array.from(vt.entries()).map(([t,i])=>({key:t,staleAt:i.staleAt.getTime()})).sort((t,i)=>t.staleAt-i.staleAt),e=Math.min(Math.max(0,vt.size-Ae.maxEntries),vt.size);for(let t=0;t<e;t++)vt.delete(s[t].key)}function Pu(s,e,t){let i=t.dateUpdated||"",r=new Date(Date.now()+Ae.staleTTL),n=Ae.disableCache?void 0:vt.get(e);if(n&&i&&n.version===i){n.staleAt=r,Au();return}Ae.disableCache||(vt.set(e,{data:t,version:i,staleAt:r,sse:vs.has(s)}),Cu()),Au();let o=fs.get(s);o&&o.forEach(a=>cy(a,t))}async function cy(s,e){await s.setPayload(e||s.getPayload())}async function mo(s){let{apiHost:e,apiRequestHeaders:t}=s.getApiHosts(),i=s.getClientKey(),r="isRemoteEval"in s&&s.isRemoteEval(),n=Zs(s),o=yo(s),a=gr.get(o);return a||(a=(r?gs.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:s.getAttributes(),forcedVariations:s.getForcedVariations(),forcedFeatures:Array.from(s.getForcedFeatures().entries()),url:s.getUrl()},headers:t}):gs.fetchFeaturesCall({host:e,clientKey:i,headers:t})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&vs.add(n),c.json()}).then(c=>(Pu(n,o,c),bo(s),gr.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(gr.delete(o),{data:null,source:"error",success:!1,error:c})),gr.set(o,a)),a}function bo(s,e=!1){let t=Zs(s),i=yo(s),{streamingHost:r,streamingHostRequestHeaders:n}=s.getApiHosts(),o=s.getClientKey();if(e&&vs.add(t),Ae.backgroundSync&&vs.has(t)&&rt.EventSource){if(ps.has(t))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let c=fs.get(t);c&&c.forEach(d=>{mo(d)})}else if(l.type==="features"){let c=JSON.parse(l.data);Pu(t,i,c)}a.errors=0}catch{Du(a)}},errors:0,state:"active"};ps.set(t,a),So(a)}}function Du(s){if(s.state!=="idle"&&(s.errors++,s.errors>3||s.src&&s.src.readyState===2)){let e=Math.pow(3,s.errors-3)*(1e3+Math.random()*1e3);Eo(s),setTimeout(()=>{["idle","active"].includes(s.state)||So(s)},Math.min(e,3e5))}}function Eo(s){s.src&&(s.src.onopen=null,s.src.onerror=null,s.src.close(),s.src=null,s.state==="active"&&(s.state="disabled"))}function So(s){s.src=gs.eventSourceCall({host:s.host,clientKey:s.clientKey,headers:s.headers}),s.state="active",s.src.addEventListener("features",s.cb),s.src.addEventListener("features-updated",s.cb),s.src.onerror=()=>Du(s),s.src.onopen=()=>{s.errors=0}}function uy(s,e){Eo(s),ps.delete(e)}function ko(){vs.clear(),ps.forEach(uy),fs.clear(),gs.stopIdleListener()}function fr(s,e){if(e.streaming){if(!s.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&bo(s,!0),ry(s)}}var Ae,rt,gs,fs,Tu,vt,gr,ps,vs,Nu=Pe(()=>{"use strict";Qs();Ae={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},rt=_u(),gs={fetchFeaturesCall:({host:s,clientKey:e,headers:t})=>rt.fetch(`${s}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:s,clientKey:e,payload:t,headers:i})=>{let r={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(t)};return rt.fetch(`${s}/api/eval/${e}`,r)},eventSourceCall:({host:s,clientKey:e,headers:t})=>t?new rt.EventSource(`${s}/sub/${e}`,{headers:t}):new rt.EventSource(`${s}/sub/${e}`),startIdleListener:()=>{let s;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(s),oy()):document.visibilityState==="hidden"&&(s=window.setTimeout(ny,Ae.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(rt.localStorage=globalThis.localStorage)}catch{}fs=new Map,Tu=!1,vt=new Map,gr=new Map,ps=new Map,vs=new Set});function hy(s){return s==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[s]}}function yr(s){var e=mr.get(s);return e||(e={element:s,attributes:{}},mr.set(s,e)),e}function br(s,e,t,i,r){var n=t(s),o={isDirty:!1,originalValue:n,virtualValue:n,mutations:[],el:s,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=t(s);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,r(o))}}),mutationRunner:r,setValue:i,getCurrentValue:t};return e==="position"&&s.parentNode?o.observer.observe(s.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(s,hy(e)),o}function Er(s,e){var t=e.getCurrentValue(e.el);e.virtualValue=s,s&&typeof s!="string"?(!t||s.parentNode!==t.parentNode||s.insertBeforeNode!==t.insertBeforeNode)&&(e.isDirty=!0,xu()):s!==t&&(e.isDirty=!0,xu())}function gy(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),Er(Ry(e),s)}function fy(s){var e=new Set(s.originalValue.split(/\s+/).filter(Boolean));s.mutations.forEach(function(t){return t.mutate(e)}),Er(Array.from(e).filter(Boolean).join(" "),s)}function py(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),Er(e,s)}function vy(s){var e=s.parentSelector,t=s.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var r=t?document.querySelector(t):null;return t&&!r?null:{parentNode:i,insertBeforeNode:r}}function _y(s){var e=s.originalValue;s.mutations.forEach(function(t){var i=t.mutate(),r=vy(i);e=r||e}),Er(e,s)}function $u(s){var e=yr(s);return e.html||(e.html=br(s,"html",my,yy,gy)),e.html}function Fu(s){var e=yr(s);return e.position||(e.position=br(s,"position",by,Ey,_y)),e.position}function Mu(s){var e=yr(s);return e.classes||(e.classes=br(s,"class",ky,Sy,fy)),e.classes}function Uu(s,e){var t=yr(s);return t.attributes[e]||(t.attributes[e]=br(s,e,wy(e),Ty(e),py)),t.attributes[e]}function Ay(s,e){var t=mr.get(s);if(t)if(e==="html"){var i,r;(i=t.html)==null||(r=i.observer)==null||r.disconnect(),delete t.html}else if(e==="class"){var n,o;(n=t.classes)==null||(o=n.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var c,d,h;(c=t.attributes)==null||(d=c[e])==null||(h=d.observer)==null||h.disconnect(),delete t.attributes[e]}}function Ry(s){return pr||(pr=document.createElement("div")),pr.innerHTML=s,pr.innerHTML}function vr(s,e,t){if(t.isDirty){t.isDirty=!1;var i=t.virtualValue;t.mutations.length||Ay(s,e),t.setValue(s,i)}}function Iy(s,e){s.html&&vr(e,"html",s.html),s.classes&&vr(e,"class",s.classes),s.position&&vr(e,"position",s.position),Object.keys(s.attributes).forEach(function(t){vr(e,t,s.attributes[t])})}function xu(){mr.forEach(Iy)}function Oy(s,e){var t=null;s.kind==="html"?t=$u(e):s.kind==="class"?t=Mu(e):s.kind==="attribute"?t=Uu(e,s.attribute):s.kind==="position"&&(t=Fu(e)),t&&(t.mutations.push(s),t.mutationRunner(t))}function Cy(s,e){var t=null;if(s.kind==="html"?t=$u(e):s.kind==="class"?t=Mu(e):s.kind==="attribute"?t=Uu(e,s.attribute):s.kind==="position"&&(t=Fu(e)),!!t){var i=t.mutations.indexOf(s);i!==-1&&t.mutations.splice(i,1),t.mutationRunner(t)}}function Bu(s){if(!(s.kind==="position"&&s.elements.size===1)){var e=new Set(s.elements),t=document.querySelectorAll(s.selector);t.forEach(function(i){e.has(i)||(s.elements.add(i),Oy(s,i))})}}function Py(s){s.elements.forEach(function(e){return Cy(s,e)}),s.elements.clear(),Ro.delete(s)}function Lu(){Ro.forEach(Bu)}function Dy(){typeof document>"u"||(wo||(wo=new MutationObserver(function(){Lu()})),Lu(),wo.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Sr(s){return typeof document>"u"?Ao:(Ro.add(s),Bu(s),{revert:function(){Py(s)}})}function To(s,e){return Sr({kind:"html",elements:new Set,mutate:e,selector:s})}function Vu(s,e){return Sr({kind:"position",elements:new Set,mutate:e,selector:s})}function ei(s,e){return Sr({kind:"class",elements:new Set,mutate:e,selector:s})}function _r(s,e,t){return dy.test(e)?e==="class"||e==="className"?ei(s,function(i){var r=t(Array.from(i).join(" "));i.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return i.add(n)})}):Sr({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:s}):Ao}function Ny(s){var e=s.selector,t=s.action,i=s.value,r=s.attribute,n=s.parentSelector,o=s.insertBeforeSelector;if(r==="html"){if(t==="append")return To(e,function(a){return a+(i??"")});if(t==="set")return To(e,function(){return i??""})}else if(r==="class"){if(t==="append")return ei(e,function(a){i&&a.add(i)});if(t==="remove")return ei(e,function(a){i&&a.delete(i)});if(t==="set")return ei(e,function(a){a.clear(),i&&a.add(i)})}else if(r==="position"){if(t==="set"&&n)return Vu(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(t==="append")return _r(e,r,function(a){return a!==null?a+(i??""):i??""});if(t==="set")return _r(e,r,function(){return i??""});if(t==="remove")return _r(e,r,function(){return null})}return Ao}var dy,Ao,mr,Ro,my,yy,by,Ey,Sy,ky,wy,Ty,pr,wo,xy,Gu,ju=Pe(()=>{"use strict";dy=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Ao={revert:function(){}},mr=new Map,Ro=new Set;my=function(e){return e.innerHTML},yy=function(e,t){return e.innerHTML=t};by=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Ey=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};Sy=function(e,t){return t?e.className=t:e.removeAttribute("class")},ky=function(e){return e.className};wy=function(e){return function(t){var i;return(i=t.getAttribute(e))!=null?i:null}},Ty=function(e){return function(t,i){return i!==null?t.setAttribute(e,i):t.removeAttribute(e)}};Dy();xy={html:To,classes:ei,attribute:_r,position:Vu,declarative:Ny},Gu=xy});function It(s,e,t){t=t||{};for(let[i,r]of Object.entries(e))switch(i){case"$or":if(!Ku(s,r,t))return!1;break;case"$nor":if(Ku(s,r,t))return!1;break;case"$and":if(!Uy(s,r,t))return!1;break;case"$not":if(It(s,r,t))return!1;break;default:if(!ti(r,Ly(s,i),t))return!1}return!0}function Ly(s,e){let t=e.split("."),i=s;for(let r=0;r<t.length;r++)if(i&&typeof i=="object"&&t[r]in i)i=i[t[r]];else return null;return i}function Hu(s,e=!1){let t=`${s}${e?"/i":""}`;return Io[t]||(Io[t]=new RegExp(s.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Io[t]}function ti(s,e,t,i=!1){if(typeof s=="string")return i?String(e).toLowerCase()===s.toLowerCase():e+""===s;if(typeof s=="number")return e*1===s;if(typeof s=="boolean")return e!==null&&!!e===s;if(s===null)return e===null;if(Array.isArray(s)||!qu(s))return JSON.stringify(e)===JSON.stringify(s);for(let r in s)if(!My(r,e,s[r],t))return!1;return!0}function qu(s){let e=Object.keys(s);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function $y(s){if(s===null)return"null";if(Array.isArray(s))return"array";let e=typeof s;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function Fy(s,e,t){if(!Array.isArray(s))return!1;let i=qu(e)?r=>ti(e,r,t):r=>It(r,e,t);for(let r=0;r<s.length;r++)if(s[r]&&i(s[r]))return!0;return!1}function _s(s,e,t=!1){if(t){let i=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(s)?s.some(r=>e.some(n=>i(r)===i(n))):e.some(r=>i(s)===i(r))}return Array.isArray(s)?s.some(i=>e.includes(i)):e.includes(s)}function zu(s,e,t,i=!1){if(!Array.isArray(s))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<s.length;o++)if(ti(e[r],s[o],t,i)){n=!0;break}if(!n)return!1}return!0}function My(s,e,t,i){switch(s){case"$veq":return Me(e)===Me(t);case"$vne":return Me(e)!==Me(t);case"$vgt":return Me(e)>Me(t);case"$vgte":return Me(e)>=Me(t);case"$vlt":return Me(e)<Me(t);case"$vlte":return Me(e)<=Me(t);case"$eq":return e===t;case"$ne":return e!==t;case"$lt":return e<t;case"$lte":return e<=t;case"$gt":return e>t;case"$gte":return e>=t;case"$exists":return t?e!=null:e==null;case"$in":return Array.isArray(t)?_s(e,t):!1;case"$ini":return Array.isArray(t)?_s(e,t,!0):!1;case"$inGroup":return _s(e,i[t]||[]);case"$notInGroup":return!_s(e,i[t]||[]);case"$nin":return Array.isArray(t)?!_s(e,t):!1;case"$nini":return Array.isArray(t)?!_s(e,t,!0):!1;case"$not":return!ti(t,e,i);case"$size":return Array.isArray(e)?ti(t,e.length,i):!1;case"$elemMatch":return Fy(e,t,i);case"$all":return Array.isArray(t)?zu(e,t,i):!1;case"$alli":return Array.isArray(t)?zu(e,t,i,!0):!1;case"$regex":try{return Hu(t).test(e)}catch{return!1}case"$regexi":try{return Hu(t,!0).test(e)}catch{return!1}case"$type":return $y(e)===t;default:return console.error("Unknown operator: "+s),!1}}function Ku(s,e,t){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(It(s,e[i],t))return!0;return!1}function Uy(s,e,t){for(let i=0;i<e.length;i++)if(!It(s,e[i],t))return!1;return!0}var Io,Wu=Pe(()=>{"use strict";Qs();Io={}});function Gy(s){let e=new Map;return s.global.forcedFeatureValues&&s.global.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),s.user.forcedFeatureValues&&s.user.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),e}function jy(s){return s.global.forcedVariations&&s.user.forcedVariations?{...s.global.forcedVariations,...s.user.forcedVariations}:s.global.forcedVariations?s.global.forcedVariations:s.user.forcedVariations?s.user.forcedVariations:{}}async function ms(s){try{await s()}catch{}}function Yu(s,e,t){if(s.user.trackedExperiments){let r=Tr(e,t);if(s.user.trackedExperiments.has(r))return[];s.user.trackedExperiments.add(r)}s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let i=[];if(s.global.trackingCallback){let r=s.global.trackingCallback;i.push(ms(()=>r(e,t,s.user)))}if(s.user.trackingCallback){let r=s.user.trackingCallback;i.push(ms(()=>r(e,t)))}if(s.global.eventLogger){let r=s.global.eventLogger;i.push(ms(()=>r(Vy,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},s.user)))}return i}function Hy(s,e,t){if(s.user.trackedFeatureUsage){let i=JSON.stringify(t.value);if(s.user.trackedFeatureUsage[e]===i)return;s.user.trackedFeatureUsage[e]=i,s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({featureKey:e,result:t,timestamp:Date.now().toString(),logType:"feature"})}if(s.global.onFeatureUsage){let i=s.global.onFeatureUsage;ms(()=>i(e,t,s.user))}if(s.user.onFeatureUsage){let i=s.user.onFeatureUsage;ms(()=>i(e,t))}if(s.global.eventLogger){let i=s.global.eventLogger;ms(()=>i(By,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},s.user))}}function kr(s,e){if(e.stack.evaluatedFeatures.has(s))return Ot(e,s,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(s),e.stack.id=s;let t=Gy(e);if(t.has(s))return Ot(e,s,t.get(s),"override");if(!e.global.features||!e.global.features[s])return Ot(e,s,null,"unknownFeature");let i=e.global.features[s];if(i.rules){let r=new Set(e.stack.evaluatedFeatures);e:for(let n of i.rules){if(n.parentConditions)for(let l of n.parentConditions){e.stack.evaluatedFeatures=new Set(r);let c=kr(l.id,e);if(c.source==="cyclicPrerequisite")return Ot(e,s,null,"cyclicPrerequisite");let d={value:c.value};if(!It(d,l.condition||{})){if(l.gate)return Ot(e,s,null,"prerequisite");continue e}}if(n.filters&&Qu(n.filters,e))continue;if("force"in n){if(n.condition&&!Ju(n.condition,e)||!zy(e,n.seed||s,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=>{!Yu(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),Ot(e,s,n.force,"force",n.id)}if(!n.variations)continue;let o={variations:n.variations,key:n.key||s};"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}=wr(o,s,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return Ot(e,s,a.value,"experiment",n.id,o,a)}}return Ot(e,s,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function wr(s,e,t){let i=s.key,r=s.variations.length;if(r<2)return{result:ce(t,s,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:ce(t,s,-1,!1,e)};if(s=Ky(s,t),s.urlPatterns&&!ur(t.user.url||"",s.urlPatterns))return{result:ce(t,s,-1,!1,e)};let n=Eu(i,t.user.url||"",r);if(n!==null)return{result:ce(t,s,n,!1,e)};let o=jy(t);if(i in o){let m=o[i];return{result:ce(t,s,m,!1,e)}}if(s.status==="draft"||s.active===!1)return{result:ce(t,s,-1,!1,e)};let{hashAttribute:a,hashValue:l}=qt(t,s.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing?s.fallbackAttribute:void 0);if(!l)return{result:ce(t,s,-1,!1,e)};let c=-1,d=!1,h=!1;if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{variation:m,versionIsBlocked:b}=Yy({ctx:t,expKey:s.key,expBucketVersion:s.bucketVersion,expHashAttribute:s.hashAttribute,expFallbackAttribute:s.fallbackAttribute,expMinBucketVersion:s.minBucketVersion,expMeta:s.meta});d=m>=0,c=m,h=!!b}if(!d){if(s.filters){if(Qu(s.filters,t))return{result:ce(t,s,-1,!1,e)}}else if(s.namespace&&!mu(l,s.namespace))return{result:ce(t,s,-1,!1,e)};if(s.include&&!Su(s.include))return{result:ce(t,s,-1,!1,e)};if(s.condition&&!Ju(s.condition,t))return{result:ce(t,s,-1,!1,e)};if(s.parentConditions){let m=new Set(t.stack.evaluatedFeatures);for(let b of s.parentConditions){t.stack.evaluatedFeatures=new Set(m);let E=kr(b.id,t);if(E.source==="cyclicPrerequisite")return{result:ce(t,s,-1,!1,e)};let D={value:E.value};if(!It(D,b.condition||{}))return{result:ce(t,s,-1,!1,e)}}}if(s.groups&&!Wy(s.groups,t))return{result:ce(t,s,-1,!1,e)}}if(s.url&&!qy(s.url,t))return{result:ce(t,s,-1,!1,e)};let f=Xs(s.seed||i,l,s.hashVersion||1);if(f===null)return{result:ce(t,s,-1,!1,e)};if(!d){let m=s.ranges||bu(r,s.coverage===void 0?1:s.coverage,s.weights);c=yu(f,m)}if(h)return{result:ce(t,s,-1,!1,e,void 0,!0)};if(c<0)return{result:ce(t,s,-1,!1,e)};if("force"in s)return{result:ce(t,s,s.force===void 0?-1:s.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:ce(t,s,-1,!1,e)};if(s.status==="stopped")return{result:ce(t,s,-1,!1,e)};let g=ce(t,s,c,!0,e,f,d);if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{changed:m,key:b,doc:E}=Jy(t,a,Js(l),{[Oo(s.key,s.bucketVersion)]:g.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[b]=E,t.user.saveStickyBucketAssignmentDoc(E))}let p=Yu(t,s,g);p.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:s,result:g});let v=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in s&&s.changeId&&t.global.recordChangeId&&t.global.recordChangeId(s.changeId),{result:g,trackingCall:v}}function Ot(s,e,t,i,r,n,o){let a={value:t,on:!!t,off:!t,source:i,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),i!=="override"&&Hy(s,e,a),a}function Xu(s){return{...s.user.attributes,...s.user.attributeOverrides}}function Ju(s,e){return It(Xu(e),s,e.global.savedGroups||{})}function Qu(s,e){return s.some(t=>{let{hashValue:i}=qt(e,t.attribute);if(!i)return!0;let r=Xs(t.seed,i,t.hashVersion||2);return r===null?!0:!t.ranges.some(n=>cr(r,n))})}function zy(s,e,t,i,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=qt(s,t,i);if(!a)return!1;let l=Xs(e,a,o||1);return l===null?!1:r?cr(l,r):n!==void 0?l<=n:!0}function ce(s,e,t,i,r,n,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:c}=qt(s,e.hashAttribute,s.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),d=e.meta?e.meta[t]:{},h={key:d.key||""+t,featureId:r,inExperiment:a,hashUsed:i,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};return d.name&&(h.name=d.name),n!==void 0&&(h.bucket=n),d.passthrough&&(h.passthrough=d.passthrough),h}function Ky(s,e){let t=s.key,i=e.global.overrides;return i&&i[t]&&(s=Object.assign({},s,i[t]),typeof s.url=="string"&&(s.url=_o(s.url))),s}function qt(s,e,t){let i=e||"id",r="",n=Xu(s);return n[i]&&(r=n[i]),!r&&t&&(n[t]&&(r=n[t]),r&&(i=t)),{hashAttribute:i,hashValue:r}}function qy(s,e){let t=e.user.url;if(!t)return!1;let i=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(s.test(t)||s.test(i))}function Wy(s,e){let t=e.global.groups||{};for(let i=0;i<s.length;i++)if(t[s[i]])return!0;return!1}function Yy({ctx:s,expKey:e,expBucketVersion:t,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:n,expMeta:o}){t=t||0,n=n||0,i=i||"id",o=o||[];let a=Oo(e,t),l=Xy(s,i,r);if(n>0)for(let h=0;h<n;h++){let f=Oo(e,h);if(l[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=l[a];if(c===void 0)return{variation:-1};let d=o.findIndex(h=>h.key===c);return d<0?{variation:-1}:{variation:d}}function Oo(s,e){return e=e||0,`${s}__${e}`}function Co(s,e){return`${s}||${e}`}function Xy(s,e,t){if(!s.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:r}=qt(s,e),n=Co(i,Js(r)),{hashAttribute:o,hashValue:a}=qt(s,t),l=a?Co(o,Js(a)):null,c={};return l&&s.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,s.user.stickyBucketAssignmentDocs[l].assignments||{}),s.user.stickyBucketAssignmentDocs[n]&&Object.assign(c,s.user.stickyBucketAssignmentDocs[n].assignments||{}),c}function Jy(s,e,t,i){let r=Co(e,t),n=s.user.stickyBucketAssignmentDocs&&s.user.stickyBucketAssignmentDocs[r]?s.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o={...n,...i},a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function Qy(s,e){let t=new Set,i=e&&e.features?e.features:s.global.features||{},r=e&&e.experiments?e.experiments:s.global.experiments||[];return Object.keys(i).forEach(n=>{let o=i[n];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),r.map(n=>{t.add(n.hashAttribute||"id"),n.fallbackAttribute&&t.add(n.fallbackAttribute)}),Array.from(t)}async function Zu(s,e,t){let i=Po(s,t);return e.getAllAssignments(i)}function Po(s,e){let t={};return Qy(s,e).forEach(r=>{let{hashValue:n}=qt(s,r);t[r]=Js(n)}),t}async function ed(s,e,t){if(s={...s},s.encryptedFeatures){try{s.features=JSON.parse(await Kt(s.encryptedFeatures,e,t))}catch(i){console.error(i)}delete s.encryptedFeatures}if(s.encryptedExperiments){try{s.experiments=JSON.parse(await Kt(s.encryptedExperiments,e,t))}catch(i){console.error(i)}delete s.encryptedExperiments}if(s.encryptedSavedGroups){try{s.savedGroups=JSON.parse(await Kt(s.encryptedSavedGroups,e,t))}catch(i){console.error(i)}delete s.encryptedSavedGroups}return s}function td(s){let e=s.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(s.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:s.apiHostRequestHeaders,streamingHostRequestHeaders:s.streamingHostRequestHeaders}}function Tr(s,e){return e.hashAttribute+e.hashValue+s.key+e.variationId}var By,Vy,sd=Pe(()=>{"use strict";Wu();Qs();By="Feature Evaluated",Vy="Experiment Viewed"});var ys,Zy,si,id=Pe(()=>{"use strict";ju();Qs();Nu();sd();ys=typeof window<"u"&&typeof document<"u",Zy=ku(),si=class{constructor(e){if(e=e||{},this.version=Zy,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 t=!1;try{t=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(t)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 t=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=i=>t.saveAssignments(i)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),ys&&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 t in this._options.stickyBucketAssignmentDocs){let i=this._options.stickyBucketAssignmentDocs[t];i&&this._options.stickyBucketService.saveAssignments(i).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await ed(e,this._options.decryptionKey);this._decryptedPayload=t,await this.refreshStickyBuckets(t),t.features&&(this._options.features=t.features),t.savedGroups&&(this._options.savedGroups=t.savedGroups),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let t=e.payload;if(t.encryptedExperiments||t.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,t)),this._payload=t,this._decryptedPayload=t,t.features&&(this._options.features=t.features),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,fr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Ru(e.cacheSettings),e.payload)return await this.setPayload(e.payload),fr(this,e),{success:!0,source:"init"};{let{data:t,...i}=await this._refresh({...e,allowStale:!0});return fr(this,e),await this.setPayload(t||{}),i}}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 t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return td(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:t,allowStale:i,streaming:r}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Iu({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:i,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,t,i){let r=await Kt(e,t||this._options.decryptionKey,i);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,i){let r=await Kt(e,t||this._options.decryptionKey,i);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(t=>{try{t()}catch(i){console.error(i)}}),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,Ou(this),e.destroyAllStreams&&ko(),this.logs=[],ys&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(t=>{t.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,t){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=t,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:t}=wr(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(i=>i.key===e).map(i=>this._runAutoExperiment(i)).filter(i=>i!==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,t){let i=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!i)return null;let r=this._isAutoExperimentBlockedByContext(e),n,o;r?n=ce(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=wr(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!t&&n.inExperiment&&i&&i.valueHash===a)return n;if(i&&this._undoActiveAutoExperiment(e),n.inExperiment){let l=dr(e);if(l==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?wu(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(ur(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=c;let{navigate:d,delay:h}=this._getNavigateFunction();if(d)if(ys)Promise.all([...o?[hr(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??h))]).then(()=>{try{d(c)}catch(f){console.error(f)}});else try{d(c)}catch(f){console.error(f)}}else if(l==="visual"){let c=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(n.value):this._applyDOMChanges(n.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return n}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],i=new Set(t);this._activeAutoExperiments.forEach((r,n)=>{i.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of t){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&dr(r)==="redirect")break}}_onExperimentEval(e,t){let i=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,i)}_fireSubscriptions(e,t,i){(!i||i.result.inExperiment!==t.inExperiment||i.result.variationId!==t.variationId)&&this._subscriptions.forEach(r=>{try{r(e,t)}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,t){let i=this.evalFeature(e).value;return i===null?t:i}feature(e){return this.evalFeature(e)}evalFeature(e){return kr(e,this._getEvalContext())}log(e,t){this.debug&&(this._options.log?this._options.log(e,t):console.log(e,t))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(t=>t&&t.experiment&&t.result).map(t=>[Tr(t.experiment,t.result),t]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(t=>{!t||!t.experiment||!t.result?console.error("Invalid deferred tracking call",{call:t}):e.push(this._options.trackingCallback(t.experiment,t.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,t){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:t,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,t||{},this._getUserContext())}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Tr(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(ys?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=dr(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(i=>i.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let i=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!==i.protocol||n.host!==i.host))return!0}}catch(i){return this.log("Error parsing current or redirect URL",{id:e.key,error:i}),!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}:ys?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!ys)return;let t=[];if(e.css){let i=document.createElement("style");i.innerHTML=e.css,document.head.appendChild(i),t.push(()=>i.remove())}if(e.js){let i=document.createElement("script");i.innerHTML=e.js,this._options.jsInjectionNonce&&(i.nonce=this._options.jsInjectionNonce),document.head.appendChild(i),t.push(()=>i.remove())}return e.domMutations&&e.domMutations.forEach(i=>{t.push(Gu.declarative(i).revert)}),()=>{t.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),i=await Zu(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=i}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let i=this._getEvalContext(),r=Po(i,t);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var rd=Pe(()=>{"use strict";id()});var nd={};pn(nd,{Growthbook:()=>Do});var He,Do,od=Pe(()=>{"use strict";rd();ho();qs();Ys();He=class He{constructor(e,t,i={},r=!1){this.analytics=new us;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Rt("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:t,user_language:i,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:c,url:d,domain:h,utm_content:f,residence_country:g,loggedIn:p,network_type:v,network_downlink:m,user_id:b,anonymous_id:E,account_mode:D})=>{let I={...this.GrowthBook.getAttributes(),id:e,...b!==void 0&&{user_id:b},...E!==void 0&&{anonymous_id:E},...t!==void 0&&{country:t},...g!==void 0&&{residence_country:g},...i!==void 0&&{user_language:i},...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},...c!==void 0&&{is_authorised:c},...d!==void 0&&{url:d},...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},...D!==void 0&&{account_mode:D}};this.log("setAttributes | updating GrowthBook attributes",I),this.GrowthBook.setAttributes(I)};this.getFeatureValue=(e,t)=>{let i=this.GrowthBook.getFeatureValue(e,t);return this.log("getFeatureValue",{key:e,value:i,defaultValue:t}),i};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let t=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:t}),t};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let t=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:t}),t};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 si({apiHost:Zc,clientKey:e,decryptionKey:t,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})},...i}),this.init()}reapplyExperiment(e){let t=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(t)}waitForIsLoaded(e=1e4){return new Promise((t,i)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),t()):Date.now()-r>=e&&(clearInterval(n),i(new Error("GrowthBook initialization timeout")))},100)})}};He.getGrowthBookInstance=(e,t,i,r=!1)=>He._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),He._instance):(He._instance=new He(e,t??"",i,r),He._instance),He.resetInstance=()=>{He._instance&&(He._instance.destroy(),He._instance=void 0)};Do=He});function cd(s,e,t,i,r,n,o){try{var a=s[n](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(i,r)}function Ze(s){return function(){var e=this,t=arguments;return new Promise((function(i,r){var n=s.apply(e,t);function o(l){cd(n,i,r,o,a,"next",l)}function a(l){cd(n,i,r,o,a,"throw",l)}o(void 0)}))}}function T(){return T=Object.assign?Object.assign.bind():function(s){for(var e=1;arguments.length>e;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},T.apply(null,arguments)}function uh(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}function dh(){return(dh=Ze((function*(s,e){e===void 0&&(e=!0);try{var t=new Blob([s],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return yield new Response(t).blob()}catch(i){return e&&console.error("Failed to gzip compress data",i),null}}))).apply(this,arguments)}function j(s,e){return s.indexOf(e)!==-1}function fh(s){return s===null||typeof s!="object"}function Mr(s,e){return{}.toString.call(s)==="[object "+e+"]"}function sl(s){return typeof Event<"u"&&(function(e,t){try{return e instanceof t}catch{return!1}})(s,Event)}function at(s,e,t,i,r){return e>t&&(i.warn("min cannot be greater than max."),e=t),lt(s)?s>t?(i.warn(" cannot be greater than max: "+t+". Using max value instead."),t):e>s?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):s:(i.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+r),at(r||t,e,t,i))}function _b(s){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return xo&&t.length===dd||(dd=t.length,xo=t.reduce(((i,r)=>{Ar||(Ar={});var n=Ar[r];if(n)i[n[0]]=n[1];else for(var o=s(r),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,d=e[r];if(c&&d){i[c]=d,Ar[r]=[c,d];break}}return i}),{})),xo}}function la(s,e,t,i,r){var n={platform:s,filename:e,function:t==="<anonymous>"?Ns:t,in_app:!0};return P(i)||(n.lineno=i),P(r)||(n.colno=r),n}function Dh(s,e){e===void 0&&(e=40);var t=Object.keys(s);if(t.sort(),!t.length)return"[object has no keys]";for(var i=t.length;i>0;i--){var r=t.slice(0,i).join(", ");if(e>=r.length)return i===t.length?r:r.length>e?r.slice(0,e)+"...":r}return""}function Or(s,e){Y(s)&&s.forEach(e)}function ae(s,e){if(!H(s))if(Y(s))s.forEach(e);else if(ib(s))s.forEach(((i,r)=>e(i,r)));else for(var t in s)gh.call(s,t)&&e(s[t],t)}function $r(s){for(var e=Object.keys(s),t=e.length,i=new Array(t);t--;)i[t]=[e[t],s[e[t]]];return i}function Pb(s){var e=s?.hostname;if(!ve(e))return!1;var t=e.split(".").slice(-2).join(".");for(var i of Cb)if(t===i)return!1;return!0}function pe(s,e,t,i){var{capture:r=!1,passive:n=!0}=i??{};s?.addEventListener(e,t,{capture:r,passive:n})}function Mh(s){return s.name==="ph_toolbar_internal"}function Vh(s,e){var{organization:t,projectId:i,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,d,h,f;if(n!=="*"&&!n.includes(a.level)||!s.__loaded)return a;a.tags||(a.tags={});var g=s.requestRouter.endpointFor("ui","/project/"+s.config.token+"/person/"+s.get_distinct_id());a.tags["PostHog Person URL"]=g,s.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=s.get_session_replay_url({withTimestamp:!0}));var p,v=((l=a.exception)==null?void 0:l.values)||[],m=v.map((E=>T({},E,{stacktrace:E.stacktrace?T({},E.stacktrace,{type:"raw",frames:(E.stacktrace.frames||[]).map((D=>T({},D,{platform:"web:javascript"})))}):void 0}))),b={$exception_message:((c=v[0])==null?void 0:c.value)||a.message,$exception_type:(d=v[0])==null?void 0:d.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 t&&i&&(b.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+a.event_id),o&&((p=s.exceptions)==null||p.sendExceptionEvent(b)),a}}function Gh(s,e,t){if(!A)return{};var i,r=e?[...xs,...t||[]]:[],n=jh(Ai(A.URL,r,Ri),s),o=(i={},ae(Ub,(function(a){var l=ot.Wt(a);i[a]=l||null})),i);return fe(o,n)}function jh(s,e){var t=Mb.concat(e||[]),i={};return ae(t,(function(r){var n=Xr(s,r);i[r]=n||null})),i}function Hh(s){var e=(function(n){return n?n.search(Dr+"google.([^/?]*)")===0?"google":n.search(Dr+"bing.com")===0?"bing":n.search(Dr+"yahoo.com")===0?"yahoo":n.search(Dr+"duckduckgo.com")===0?"duckduckgo":null:null})(s),t=e!="yahoo"?"q":"p",i={};if(!$t(e)){i.$search_engine=e;var r=A?Xr(A.referrer,t):"";r.length&&(i.ph_keyword=r)}return i}function Ad(){return navigator.language||navigator.userLanguage}function zh(){return A?.referrer||Qr}function Kh(s,e){var t=s?[...xs,...e||[]]:[],i=ke?.href.substring(0,1e3);return{r:zh().substring(0,1e3),u:i?Ai(i,t,Ri):void 0}}function qh(s){var e,{r:t,u:i}=s,r={$referrer:t,$referring_domain:t==null?void 0:t==Qr?Qr:(e=Yr(t))==null?void 0:e.host};if(i){r.$current_url=i;var n=Yr(i);r.$host=n?.host,r.$pathname=n?.pathname;var o=jh(i);fe(r,o)}if(t){var a=Hh(t);fe(r,a)}return r}function Wh(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Bb(){try{return new Date().getTimezoneOffset()}catch{return}}function qb(s,e){e===void 0&&(e={});var t=(function(){var h=4294967295;return{p(f){for(var g=h,p=0;f.length>p;++p)g=Kb[255&g^f[p]]^g>>>8;h=g},d(){return 4294967295^h}}})(),i=s.length;t.p(s);var r,n,o,a,l,c=(a=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(h,f,g,p,v,m){var b=h.length,E=new Ke(p+b+5*(1+Math.floor(b/7e3))+v),D=E.subarray(p,E.length-v),R=0;if(!f||8>b)for(var I=0;b>=I;I+=65535){var C=I+65535;b>C?R=Ma(D,R,h.subarray(I,C)):(D[I]=!0,R=Ma(D,R,h.subarray(I,b)))}else{for(var w=zb[f-1],S=w>>>13,$=8191&w,G=(1<<g)-1,z=new Ce(32768),V=new Ce(G+1),k=Math.ceil(g/3),N=2*k,F=function(fn){return(h[fn]^h[fn+1]<<k^h[fn+2]<<N)&G},M=new Ls(25e3),J=new Ce(288),K=new Ce(32),Q=0,ee=0,te=(I=0,0),ye=0,U=0;b>I;++I){var Te=F(I),qe=32767&I,ss=V[Te];if(z[qe]=ss,V[Te]=qe,I>=ye){var Ci=b-I;if((Q>7e3||te>24576)&&Ci>423){R=Pd(h,D,0,M,J,K,ee,te,U,I-U,R),te=Q=ee=0,U=I;for(var We=0;286>We;++We)J[We]=0;for(We=0;30>We;++We)K[We]=0}var Ft=2,Pi=0,_g=$,kt=qe-ss&32767;if(Ci>2&&Te==F(I-kt))for(var mg=Math.min(S,Ci)-1,yg=Math.min(32767,I),bg=Math.min(258,Ci);yg>=kt&&--_g&&qe!=ss;){if(h[I+Ft]==h[I+Ft-kt]){for(var wt=0;bg>wt&&h[I+wt]==h[I+wt-kt];++wt);if(wt>Ft){if(Ft=wt,Pi=kt,wt>mg)break;var Eg=Math.min(kt,wt-2),fl=0;for(We=0;Eg>We;++We){var gn=I-kt+We+32768&32767,pl=gn-z[gn]+32768&32767;pl>fl&&(fl=pl,ss=gn)}}}kt+=(qe=ss)-(ss=z[qe])+32768&32767}if(Pi){M[te++]=268435456|La[Ft]<<18|$a[Pi];var vl=31&La[Ft],_l=31&$a[Pi];ee+=cl[vl]+ul[_l],++J[257+vl],++K[_l],ye=I+Ft,++Q}else M[te++]=h[I],++J[h[I]]}}R=Pd(h,D,!0,M,J,K,ee,te,U,I-U,R)}return Qh(E,0,p+Jh(R)+v)})(n=s,(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)),d=c.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&&jo(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)}})(c,e),jo(c,d-8,t.d()),jo(c,d-4,i),c}function Dd(s,e,t){return Is({distinct_id:s,userPropertiesToSet:e,userPropertiesToSetOnce:t})}function sg(s,e){return!s||Object.entries(s).every((t=>{var[i,r]=t,n=e?.[i];if(P(n)||$t(n))return!1;var o=[String(n)],a=tg[r.operator];return!!a&&a(r.values,o)}))}function Ud(s){return s instanceof Element&&(s.id===Fh||!(s.closest==null||!s.closest(".toolbar-global-fade-container")))}function dn(s){return!!s&&s.nodeType===1}function Lt(s,e){return!!s&&!!s.tagName&&s.tagName.toLowerCase()===e.toLowerCase()}function ng(s){return!!s&&s.nodeType===3}function og(s){return!!s&&s.nodeType===11}function dl(s){return s?cn(s).split(/\s+/):[]}function Bd(s){var e=_?.location.href;return!!(e&&s&&s.some((t=>e.match(t))))}function an(s){var e="";switch(typeof s.className){case"string":e=s.className;break;case"object":e=(s.className&&"baseVal"in s.className?s.className.baseVal:null)||s.getAttribute("class")||"";break;default:e=""}return dl(e)}function ag(s){return H(s)?null:cn(s).split(/(\s+)/).filter((e=>ki(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Oi(s){var e="";return Xa(s)&&!cg(s)&&s.childNodes&&s.childNodes.length&&ae(s.childNodes,(function(t){var i;ng(t)&&t.textContent&&(e+=(i=ag(t.textContent))!==null&&i!==void 0?i:"")})),cn(e)}function Vd(s){return P(s.target)?s.srcElement||null:(e=s.target)!=null&&e.shadowRoot?s.composedPath()[0]||null:s.target||null;var e}function Gd(s,e){if(P(e))return!0;var t,i=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of s)if(t=i(r))return t.v;return!1}function lg(s){var e=s.parentNode;return!(!e||!dn(e))&&e}function Xa(s){for(var e=s;e.parentNode&&!Lt(e,"body");e=e.parentNode){var t=an(e);if(j(t,"ph-sensitive")||j(t,"ph-no-capture"))return!1}if(j(an(s),"ph-include"))return!0;var i=s.type||"";if(ve(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var r=s.name||s.id||"";return!ve(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 cg(s){return!!(Lt(s,"input")&&!["button","checkbox","submit","reset"].includes(s.type)||Lt(s,"select")||Lt(s,"textarea")||s.getAttribute("contenteditable")==="true")}function ki(s,e){return e===void 0&&(e=!0),!(H(s)||ve(s)&&(s=cn(s),(e?nE:oE).test((s||"").replace(/[- ]/g,""))||(e?aE:lE).test(s)))}function zd(s){var e=Oi(s);return ki(e=(e+" "+hg(s)).trim())?e:""}function hg(s){var e="";return s&&s.childNodes&&s.childNodes.length&&ae(s.childNodes,(function(t){var i;if(t&&((i=t.tagName)==null?void 0:i.toLowerCase())==="span")try{var r=Oi(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+hg(t)).trim())}catch(n){O.error("[AutoCapture]",n)}})),e}function Kd(s){return s.replace(/"|\\"/g,'\\"')}function cE(s){var e=s.attr__class;return e?Y(e)?e:dl(e):void 0}function Wo(s,e){return e.length>s?e.slice(0,s)+"...":e}function uE(s){if(s.previousElementSibling)return s.previousElementSibling;var e=s;do e=e.previousSibling;while(e&&!dn(e));return e}function dE(s,e){for(var t,i,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[s],d=s;d.parentNode&&!Lt(d,"body");)og(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var h,f,g=[],p={},v=!1,m=!1;if(ae(c,(I=>{var C=Xa(I);I.tagName.toLowerCase()==="a"&&(v=I.getAttribute("href"),v=C&&v&&ki(v)&&v),j(an(I),"ph-no-capture")&&(m=!0),g.push((function(S,$,G,z){var V=S.tagName.toLowerCase(),k={tag_name:V};hl.indexOf(V)>-1&&!G&&(k.$el_text=V.toLowerCase()==="a"||V.toLowerCase()==="button"?Wo(1024,zd(S)):Wo(1024,Oi(S)));var N=an(S);N.length>0&&(k.classes=N.filter((function(K){return K!==""}))),ae(S.attributes,(function(K){var Q;if((!cg(S)||["name","id","class","aria-label"].indexOf(K.name)!==-1)&&(z==null||!z.includes(K.name))&&!$&&ki(K.value)&&(!ve(Q=K.name)||Q.substring(0,10)!=="_ngcontent"&&Q.substring(0,7)!=="_nghost")){var ee=K.value;K.name==="class"&&(ee=dl(ee).join(" ")),k["attr__"+K.name]=Wo(1024,ee)}}));for(var F=1,M=1,J=S;J=uE(J);)F++,J.tagName===S.tagName&&M++;return k.nth_child=F,k.nth_of_type=M,k})(I,n,o,a));var w=(function(S){if(!Xa(S))return{};var $={};return ae(S.attributes,(function(G){if(G.name&&G.name.indexOf("data-ph-capture-attribute")===0){var z=G.name.replace("data-ph-capture-attribute-",""),V=G.value;z&&V&&ki(V)&&($[z]=V)}})),$})(I);fe(p,w)})),m)return{props:{},explicitNoCapture:m};if(o||(g[0].$el_text=s.tagName.toLowerCase()==="a"||s.tagName.toLowerCase()==="button"?zd(s):Oi(s)),v){var b,E;g[0].attr__href=v;var D=(b=Yr(v))==null?void 0:b.host,R=_==null||(E=_.location)==null?void 0:E.host;D&&R&&D!==R&&(h=v)}return{props:fe({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:(f=g,(function(I){return I.map((C=>{var w,S,$="";if(C.tag_name&&($+=C.tag_name),C.attr_class)for(var G of(C.attr_class.sort(),C.attr_class))$+="."+G.replace(/"/g,"");var z=T({},C.text?{text:C.text}:{},{"nth-child":(w=C.nth_child)!==null&&w!==void 0?w:0,"nth-of-type":(S=C.nth_of_type)!==null&&S!==void 0?S:0},C.href?{href:C.href}:{},C.attr_id?{attr_id:C.attr_id}:{},C.attributes),V={};return $r(z).sort(((k,N)=>{var[F]=k,[M]=N;return F.localeCompare(M)})).forEach((k=>{var[N,F]=k;return V[Kd(N.toString())]=Kd(F.toString())})),($+=":")+$r(V).map((k=>{var[N,F]=k;return N+'="'+F+'"'})).join("")})).join(";")})((function(I){return I.map((C=>{var w,S,$={text:(w=C.$el_text)==null?void 0:w.slice(0,400),tag_name:C.tag_name,href:(S=C.attr__href)==null?void 0:S.slice(0,2048),attr_class:cE(C),attr_id:C.attr__id,nth_child:C.nth_child,nth_of_type:C.nth_of_type,attributes:{}};return $r(C).filter((G=>{var[z]=G;return z.indexOf("attr__")===0})).forEach((G=>{var[z,V]=G;return $.attributes[z]=V})),$}))})(f)))},(t=g[0])!=null&&t.$el_text?{$el_text:(i=g[0])==null?void 0:i.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},p)}}function Wd(s,e,t){try{if(!(e in s))return()=>{};var i=s[e],r=t(i);return yt(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),s[e]=r,()=>{s[e]=i}}catch{return()=>{}}}function Qd(s){return _e(s)&&"clientX"in s&&"clientY"in s&&lt(s.clientX)&&lt(s.clientY)}function Ss(s,e,t){if(H(s))return!1;switch(t){case"exact":return s===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(s);case"regex":try{return new RegExp(e).test(s)}catch{return!1}default:return!1}}var _,me,Be,A,ke,ea,ta,ad,eb,$e,L,ld,Ue,tb,sb,ud,cn,sa,hh,gh,un,Y,yt,_e,As,P,ve,Lr,$t,H,lt,ks,bt,ib,rb,nb,No,ob,ia,Ar,dd,xo,Ve,Ur,Et,Ps,ph,vh,_h,mh,mi,Ds,yh,bh,Eh,Zt,ab,Sh,il,kh,rl,lb,nl,wh,Os,Th,wi,Ti,Cs,Ah,Rh,hi,ra,hd,na,Ih,cb,Oh,oa,Oe,Lo,ub,db,hb,ol,gb,Ch,fb,pb,gd,fd,vb,aa,Ns,Ph,mb,yb,bb,Eb,Sb,kb,wb,pd,ca,ua,da,Tb,ha,Ab,ga,fa,pa,va,Nh,O,he,Rb,vd,xh,Br,gi,fi,_d,_a,md,ma,yd,bd,Lh,Ed,Sd,Rr,Vr,$h,Rs,pi,ya,vi,Qt,ba,yi,Ea,Sa,Gr,Qe,ka,wa,Ta,Aa,jr,Hr,Fh,Ir,Ib,al,mt,et,bs,Es,Ra,zr,Kr,ws,$o,Fo,kd,fe,wd,Ob,ll,Cb,Ia,Oa,Td,Uh,Ca,xt,Db,ii,Nb,ot,Mo,de,xb,Cr,Lb,Wt,we,Pa,Pr,$b,Fb,qr,Uo,Bh,Da,Wr,Yr,Xr,Ai,Jr,Dr,xs,Mb,Ri,Ub,Qr,Vb,bi,ri,Bo,_i,Vo,Na,Gb,Rd,Id,xa,ni,Zr,nt,Ke,Ce,Ls,cl,ul,Od,Yh,Xh,La,Yt,$a,en,re,Ei,es,tn,jb,Hb,Jh,Qh,_t,oi,Go,Fa,Cd,ai,Ma,Pd,zb,Kb,jo,Wb,Zh,sn,Is,Ho,Yb,Fr,Ua,Ba,Xb,Va,Ga,Jb,rn,Ii,zo,nn,eg,on,tg,Nr,ja,Nd,Ha,ie,za,Qb,xd,Zb,eE,tE,sE,Ka,Si,Ko,qa,Ld,li,$d,ig,Ts,rg,Fd,iE,Md,Wa,$s,hl,rE,jd,Ya,Hd,ug,nE,oE,dg,aE,lE,ln,qo,qd,ci,hE,Ct,Yd,Xd,Jd,ui,xr,Ja,Pt,gE,Zd,Yo,fE,Dt,eh,Qa,Za,el,Xo,th,pE,sh,ih,Ie,Xt,Jo,Qo,Nt,rh,di,nh,oh,ah,Zo,lh,vE,tl,ze,Jt,hn,_E,mE,yE,bE,EE,SE,kE,wE,TE,AE,RE,IE,ch,St,gg=Pe(()=>{"use strict";_=typeof window<"u"?window:void 0,me=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(me.self=me),typeof File>"u"&&(me.File=function(){});Be=me?.navigator,A=me?.document,ke=me?.location,ea=me?.fetch,ta=me!=null&&me.XMLHttpRequest&&"withCredentials"in new me.XMLHttpRequest?me.XMLHttpRequest:void 0,ad=me?.AbortController,eb=me?.CompressionStream,$e=Be?.userAgent,L=_??{},ld="1.364.7",Ue={DEBUG:!1,LIB_VERSION:ld,LIB_NAME:"web",JS_SDK_VERSION:ld};tb=["$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"],sb=["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"],ud=function(s,e){if(e===void 0&&(e=[]),!s)return!1;var t=s.toLowerCase();return sb.concat(e).some((i=>{var r=i.toLowerCase();return t.indexOf(r)!==-1}))};cn=function(s){return s.trim()},sa=function(s){return s.replace(/^\$/,"")},hh=Object.prototype,gh=hh.hasOwnProperty,un=hh.toString,Y=Array.isArray||function(s){return un.call(s)==="[object Array]"},yt=s=>typeof s=="function",_e=s=>s===Object(s)&&!Y(s),As=s=>{if(_e(s)){for(var e in s)if(gh.call(s,e))return!1;return!0}return!1},P=s=>s===void 0,ve=s=>un.call(s)=="[object String]",Lr=s=>ve(s)&&s.trim().length===0,$t=s=>s===null,H=s=>P(s)||$t(s),lt=s=>un.call(s)=="[object Number]"&&s==s,ks=s=>lt(s)&&s>0,bt=s=>un.call(s)==="[object Boolean]",ib=s=>s instanceof FormData,rb=s=>j(tb,s);nb=[!0,"true",1,"1","yes"],No=s=>j(nb,s),ob=[!1,"false",0,"0","no"];ia=class{constructor(e){this.Pt={},this.Dt=e.Dt,this.jt=at(e.bucketSize,0,100,e.qt),this.$t=at(e.refillRate,0,this.jt,e.qt),this.Ht=at(e.refillInterval,0,864e5,e.qt)}Vt(e,t){var i=Math.floor((t-e.lastAccess)/this.Ht);i>0&&(e.tokens=Math.min(e.tokens+i*this.$t,this.jt),e.lastAccess=e.lastAccess+i*this.Ht)}consumeRateLimit(e){var t,i=Date.now(),r=String(e),n=this.Pt[r];return n?this.Vt(n,i):this.Pt[r]=n={tokens:this.jt,lastAccess:i},n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.Dt)==null||t.call(this,e)),n.tokens===0)}stop(){this.Pt={}}},Ve="Mobile",Ur="iOS",Et="Android",Ps="Tablet",ph=Et+" "+Ps,vh="iPad",_h="Apple",mh=_h+" Watch",mi="Safari",Ds="BlackBerry",yh="Samsung",bh=yh+"Browser",Eh=yh+" Internet",Zt="Chrome",ab=Zt+" OS",Sh=Zt+" "+Ur,il="Internet Explorer",kh=il+" "+Ve,rl="Opera",lb=rl+" Mini",nl="Edge",wh="Microsoft "+nl,Os="Firefox",Th=Os+" "+Ur,wi="Nintendo",Ti="PlayStation",Cs="Xbox",Ah=Et+" "+Ve,Rh=Ve+" "+mi,hi="Windows",ra=hi+" Phone",hd="Nokia",na="Ouya",Ih="Generic",cb=Ih+" "+Ve.toLowerCase(),Oh=Ih+" "+Ps.toLowerCase(),oa="Konqueror",Oe="(\\d+(\\.\\d+)?)",Lo=new RegExp("Version/"+Oe),ub=new RegExp(Cs,"i"),db=new RegExp(Ti+" \\w+","i"),hb=new RegExp(wi+" \\w+","i"),ol=new RegExp(Ds+"|PlayBook|BB10","i"),gb={"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"},Ch=function(s,e){return e=e||"",j(s," OPR/")&&j(s,"Mini")?lb:j(s," OPR/")?rl:ol.test(s)?Ds:j(s,"IE"+Ve)||j(s,"WPDesktop")?kh:j(s,bh)?Eh:j(s,nl)||j(s,"Edg/")?wh:j(s,"FBIOS")?"Facebook "+Ve:j(s,"UCWEB")||j(s,"UCBrowser")?"UC Browser":j(s,"CriOS")?Sh:j(s,"CrMo")||j(s,Zt)?Zt:j(s,Et)&&j(s,mi)?Ah:j(s,"FxiOS")?Th:j(s.toLowerCase(),oa.toLowerCase())?oa:((t,i)=>i&&j(i,_h)||(function(r){return j(r,mi)&&!j(r,Zt)&&!j(r,Et)})(t))(s,e)?j(s,Ve)?Rh:mi:j(s,Os)?Os:j(s,"MSIE")||j(s,"Trident/")?il:j(s,"Gecko")?Os:""},fb={[kh]:[new RegExp("rv:"+Oe)],[wh]:[new RegExp(nl+"?\\/"+Oe)],[Zt]:[new RegExp("("+Zt+"|CrMo)\\/"+Oe)],[Sh]:[new RegExp("CriOS\\/"+Oe)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Oe)],[mi]:[Lo],[Rh]:[Lo],[rl]:[new RegExp("(Opera|OPR)\\/"+Oe)],[Os]:[new RegExp(Os+"\\/"+Oe)],[Th]:[new RegExp("FxiOS\\/"+Oe)],[oa]:[new RegExp("Konqueror[:/]?"+Oe,"i")],[Ds]:[new RegExp(Ds+" "+Oe),Lo],[Ah]:[new RegExp("android\\s"+Oe,"i")],[Eh]:[new RegExp(bh+"\\/"+Oe)],[il]:[new RegExp("(rv:|MSIE )"+Oe)],Mozilla:[new RegExp("rv:"+Oe)]},pb=function(s,e){var t=Ch(s,e),i=fb[t];if(P(i))return null;for(var r=0;i.length>r;r++){var n=s.match(i[r]);if(n)return parseFloat(n[n.length-2])}return null},gd=[[new RegExp(Cs+"; "+Cs+" (.*?)[);]","i"),s=>[Cs,s&&s[1]||""]],[new RegExp(wi,"i"),[wi,""]],[new RegExp(Ti,"i"),[Ti,""]],[ol,[Ds,""]],[new RegExp(hi,"i"),(s,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[ra,""];if(new RegExp(Ve).test(e)&&!/IEMobile\b/.test(e))return[hi+" "+Ve,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var i=gb[t[1]]||"";return/arm/i.test(e)&&(i="RT"),[hi,i]}return[hi,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,s=>s&&s[3]?[Ur,[s[3],s[4],s[5]||"0"].join(".")]:[Ur,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,s=>{var e="";return s&&s.length>=3&&(e=P(s[2])?s[3]:s[2]),["watchOS",e]}],[new RegExp("("+Et+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Et+")","i"),s=>s&&s[2]?[Et,[s[2],s[3],s[4]||"0"].join(".")]:[Et,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,s=>{var e=["Mac OS X",""];return s&&s[1]&&(e[1]=[s[1],s[2],s[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ab,""]],[/Linux|debian/i,["Linux",""]]],fd=function(s){return hb.test(s)?wi:db.test(s)?Ti:ub.test(s)?Cs:new RegExp(na,"i").test(s)?na:new RegExp("("+ra+"|WPDesktop)","i").test(s)?ra:/iPad/.test(s)?vh:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?mh:ol.test(s)?Ds:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(hd,"i").test(s)?hd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":/(Android|ZTE)/i.test(s)?new RegExp(Ve).test(s)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)||/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?Et:ph:new RegExp("(pda|"+Ve+")","i").test(s)?cb:new RegExp(Ps,"i").test(s)&&!new RegExp(Ps+" pc","i").test(s)?Oh:""},vb=s=>s instanceof Error;aa=class{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,i),$exception_level:"error"}}modifyFrames(e){var t=this;return Ze((function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&Y(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),T({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map((i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Ze((function*(){var i=e;for(var r of t.modifiers)i=yield r(i);return i}))()}convertToExceptionList(e,t){var i,r,n,o={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(r=t.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,T({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:_b(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,i){i===void 0&&(i=0);var r=(n,o)=>{if(4>=o){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(n,a)}};return T({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:n=>r(n,i),next:n=>r(n,i+1)})}},Ns="?";Ph=(s,e)=>{var t=s.indexOf("safari-extension")!==-1,i=s.indexOf("safari-web-extension")!==-1;return t||i?[s.indexOf("@")!==-1?s.split("@")[0]:Ns,t?"safari-extension:"+e:"safari-web-extension:"+e]:[s,e]},mb=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,yb=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,bb=/\((\S*)(?::(\d+))(?::(\d+))\)/,Eb=(s,e)=>{var t=mb.exec(s);if(t){var[,i,r,n]=t;return la(e,i,Ns,+r,+n)}var o=yb.exec(s);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=bb.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=Ph(o[1]||Ns,o[2]);return la(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Sb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,kb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,wb=(s,e)=>{var t=Sb.exec(s);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=kb.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var r=t[3],n=t[1]||Ns;return[n,r]=Ph(n,r),la(e,r,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},pd=/\(error: (.*)\)/,ca=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=ve(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Mr(e,"DOMException")}isDOMError(e){return Mr(e,"DOMError")}},ua=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&typeof i.error.message=="string"?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}},da=class{constructor(){}match(e){return Mr(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},Tb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ha=class{match(e){return typeof e=="string"}coerce(e,t){var i,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(Tb);return r&&(t=r[1],i=r[2]),[t,i]}},Ab=["fatal","error","warning","log","info","debug"];ga=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(i=t.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return sl(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var i=this.getObjectClassName(e);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+Dh(e)}isSeverityLevel(e){return ve(e)&&!Lr(e)&&Ab.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(vb(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},fa=class{match(e){return sl(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Dh(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},pa=class{match(e){return fh(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},va=class{match(e){return Mr(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!sl(e))return!1;try{var t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return fh(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.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}},Nh=function(s,e){var{debugEnabled:t}=e===void 0?{}:e,i={C(r){if(_&&(Ue.DEBUG||L.POSTHOG_DEBUG||t)&&!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(s,...a)}},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.C("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.C("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.C("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(s,...n)},uninitializedWarning(r){i.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Nh(s+" "+r,n)};return i},O=Nh("[PostHog.js]"),he=O.createLogger,Rb=he("[ExternalScriptsLoader]"),vd=(s,e,t)=>{if(s.config.disable_external_dependency_loading)return Rb.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var i=A?.querySelectorAll("script");if(i){for(var r,n=function(){if(i[o].src===e){var l=i[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)})),l.onerror=c=>t(c),{v:void 0})}},o=0;i.length>o;o++)if(r=n())return r.v}var a=()=>{if(!A)return t("document not found");var l=A.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,t(void 0,h)},l.onerror=h=>t(h),s.config.prepare_external_dependency_script&&(l=s.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(s.config.external_scripts_inject_target==="head")A.head.appendChild(l);else{var c,d=A.querySelectorAll("body > script");d.length>0?(c=d[0].parentNode)==null||c.insertBefore(l,d[0]):A.body.appendChild(l)}};A!=null&&A.body?a():A?.addEventListener("DOMContentLoaded",a)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(s,e,t)=>{var i="/static/"+e+".js?v="+s.version;if(e==="remote-config"&&(i="/array/"+s.config.token+"/config.js"),e==="toolbar"){var r=3e5;i=i+"&t="+Math.floor(Date.now()/r)*r}var n=s.requestRouter.endpointFor("assets",i);vd(s,n,t)},L.__PosthogExtensions__.loadSiteApp=(s,e,t)=>{var i=s.requestRouter.endpointFor("api",e);vd(s,i,t)};xh="$people_distinct_id",Br="$device_id",gi="__alias",fi="__timers",_d="$autocapture_disabled_server_side",_a="$heatmaps_enabled_server_side",md="$exception_capture_enabled_server_side",ma="$error_tracking_suppression_rules",yd="$error_tracking_capture_extension_exceptions",bd="$web_vitals_enabled_server_side",Lh="$dead_clicks_enabled_server_side",Ed="$product_tours_enabled_server_side",Sd="$web_vitals_allowed_metrics",Rr="$session_recording_remote_config",Vr="$sesid",$h="$session_is_sampled",Rs="$enabled_feature_flags",pi="$early_access_features",ya="$feature_flag_details",vi="$stored_person_properties",Qt="$stored_group_properties",ba="$surveys",yi="$flag_call_reported",Ea="$flag_call_reported_session_id",Sa="$feature_flag_errors",Gr="$feature_flag_evaluated_at",Qe="$user_state",ka="$client_session_props",wa="$capture_rate_limit",Ta="$initial_campaign_params",Aa="$initial_referrer_info",jr="$initial_person_info",Hr="$epp",Fh="__POSTHOG_TOOLBAR__",Ir="$posthog_cookieless",Ib=[xh,gi,"__cmpns",fi,"$session_recording_enabled_server_side",_a,Vr,Rs,ma,Qe,pi,ya,Qt,vi,ba,yi,Ea,Sa,Gr,ka,wa,Ta,Aa,Hr,jr],al="PostHog loadExternalDependency extension not found.",mt="on_reject",et="always",bs="anonymous",Es="identified",Ra="identified_only",zr="visibilitychange",Kr="beforeunload",ws="$pageview",$o="$pageleave",Fo="$identify",kd="$groupidentify";fe=function(s){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;e>i;i++)t[i-1]=arguments[i];for(var r of t)for(var n in r)r[n]!==void 0&&(s[n]=r[n]);return s};wd=function(s){try{return s()}catch{return}},Ob=function(s){return function(){try{for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return s.apply(this,t)}catch(r){O.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),O.critical(r)}}},ll=function(s){var e={};return ae(s,(function(t,i){(ve(t)&&t.length>0||lt(t))&&(e[i]=t)})),e},Cb=["herokuapp.com","vercel.app","netlify.app"];Math.trunc||(Math.trunc=function(s){return 0>s?Math.ceil(s):Math.floor(s)}),Number.isInteger||(Number.isInteger=function(s){return lt(s)&&isFinite(s)&&Math.floor(s)===s});Ia=class s{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>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|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new s(n)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new s(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(i!==0)return Math.sign(i)}return 0}},Oa=class{constructor(){this.I=0,this.S=0,this.k=new Ca}generate(){var e=this.generateOrAbort();if(P(e)){this.I=0;var t=this.generateOrAbort();if(P(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.I)this.I=e,this.A();else{if(this.I>=e+1e4)return;this.S++,this.S>4398046511103&&(this.I++,this.A())}return Ia.fromFieldsV7(this.I,Math.trunc(this.S/Math.pow(2,30)),this.S&Math.pow(2,30)-1,this.k.nextUint32())}A(){this.S=1024*this.k.nextUint32()+(1023&this.k.nextUint32())}},Uh=s=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;s.length>e;e++)s[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return s};_&&!P(_.crypto)&&crypto.getRandomValues&&(Uh=s=>crypto.getRandomValues(s));Ca=class{constructor(){this.T=new Uint32Array(8),this.N=1/0}nextUint32(){return this.T.length>this.N||(Uh(this.T),this.N=0),this.T[this.N++]}},xt=()=>Db().toString(),Db=()=>(Td||(Td=new Oa)).generate(),ii="",Nb=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ot={Yt:()=>!!A,Ut(s){O.error("cookieStore error: "+s)},Wt(s){if(A){try{for(var e=s+"=",t=A.cookie.split(";").filter((n=>n.length)),i=0;t.length>i;i++){for(var r=t[i];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}},Gt(s){var e;try{e=JSON.parse(ot.Wt(s))||{}}catch{}return e},Xt(s,e,t,i,r){if(A)try{var n="",o="",a=(function(d,h){if(h){var f=(function(p,v){if(v===void 0&&(v=A),ii)return ii;if(!v||["localhost","127.0.0.1"].includes(p))return"";for(var m=p.split("."),b=Math.min(m.length,8),E="dmn_chk_"+xt();!ii&&b--;){var D=m.slice(b).join("."),R=E+"=1;domain=."+D+";path=/";v.cookie=R+";max-age=3",v.cookie.includes(E)&&(v.cookie=R+";max-age=0",ii=D)}return ii})(d);if(!f){var g=(p=>{var v=p.match(Nb);return v?v[0]:""})(d);g!==f&&O.info("Warning: cookie subdomain discovery mismatch",g,f),f=g}return f?"; domain=."+f:""}return""})(A.location.hostname,i);if(t){var l=new Date;l.setTime(l.getTime()+864e5*t),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=s+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&O.warn("cookieStore warning: large cookie, len="+c.length),A.cookie=c,c}catch{return}},Jt(s,e){if(A!=null&&A.cookie)try{ot.Xt(s,"",-1,e)}catch{return}}},Mo=null,de={Yt(){if(!$t(Mo))return Mo;var s=!0;if(P(_))s=!1;else try{var e="__mplssupport__";de.Xt(e,"xyz"),de.Wt(e)!=='"xyz"'&&(s=!1),de.Jt(e)}catch{s=!1}return s||O.error("localStorage unsupported; falling back to cookie store"),Mo=s,s},Ut(s){O.error("localStorage error: "+s)},Wt(s){try{return _?.localStorage.getItem(s)}catch(e){de.Ut(e)}return null},Gt(s){try{return JSON.parse(de.Wt(s))||{}}catch{}return null},Xt(s,e){try{_?.localStorage.setItem(s,JSON.stringify(e))}catch(t){de.Ut(t)}},Jt(s){try{_?.localStorage.removeItem(s)}catch(e){de.Ut(e)}}},xb=[Br,"distinct_id",Vr,$h,Hr,jr,Qe],Cr={},Lb={Yt:()=>!0,Ut(s){O.error("memoryStorage error: "+s)},Wt:s=>Cr[s]||null,Gt:s=>Cr[s]||null,Xt(s,e){Cr[s]=e},Jt(s){delete Cr[s]}},Wt=null,we={Yt(){if(!$t(Wt))return Wt;if(Wt=!0,P(_))Wt=!1;else try{var s="__support__";we.Xt(s,"xyz"),we.Wt(s)!=='"xyz"'&&(Wt=!1),we.Jt(s)}catch{Wt=!1}return Wt},Ut(s){O.error("sessionStorage error: ",s)},Wt(s){try{return _?.sessionStorage.getItem(s)}catch(e){we.Ut(e)}return null},Gt(s){try{return JSON.parse(we.Wt(s))||null}catch{}return null},Xt(s,e){try{_?.sessionStorage.setItem(s,JSON.stringify(e))}catch(t){we.Ut(t)}},Jt(s){try{_?.sessionStorage.removeItem(s)}catch(e){we.Ut(e)}}},Pa=class{constructor(e){this._instance=e}get Rt(){return this._instance.config}get consent(){return this.Kt()?0:this.Qt}isOptedOut(){return this.Rt.cookieless_mode===et||this.consent===0||this.consent===-1&&(this.Rt.opt_out_capturing_by_default||this.Rt.cookieless_mode===mt)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}optInOut(e){this.tr.Xt(this.er,e?1:0,this.Rt.cookie_expiration,this.Rt.cross_subdomain_cookie,this.Rt.secure_cookie)}reset(){this.tr.Jt(this.er,this.Rt.cross_subdomain_cookie)}get er(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get Qt(){var e=this.tr.Wt(this.er);return No(e)?1:j(ob,e)?0:-1}get tr(){if(!this.rr){var e=this.Rt.opt_out_capturing_persistence_type;this.rr=e==="localStorage"?de:ot;var t=e==="localStorage"?ot:de;t.Wt(this.er)&&(this.rr.Wt(this.er)||this.optInOut(No(t.Wt(this.er))),t.Jt(this.er,this.Rt.cross_subdomain_cookie))}return this.rr}Kt(){return!!this.Rt.respect_dnt&&[Be?.doNotTrack,Be?.msDoNotTrack,L.doNotTrack].some((e=>No(e)))}},Pr=he("[Dead Clicks]"),$b=()=>!0,Fb=s=>{var e,t=!((e=s.instance.persistence)==null||!e.get_property(Lh)),i=s.instance.config.capture_dead_clicks;return bt(i)?i:!!_e(i)||t},qr=class{get lazyLoadedDeadClicksAutocapture(){return this.ir}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Lh]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.nr((()=>{this.sr()})):this.stop()}nr(e){var t,i;(t=L.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Pr.error("failed to load script",r):e()}))}sr(){var e;if(A){if(!this.ir&&(e=L.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=_e(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.ir=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.ir.start(A),Pr.info("starting...")}}else Pr.error("`document` not found. Cannot start.")}stop(){this.ir&&(this.ir.stop(),this.ir=void 0,Pr.info("stopping..."))}},Uo=he("[SegmentIntegration]"),Bh="posthog-js";Da=class{constructor(e,t,i,r,n,o){this.name=Bh,this.setupOnce=function(a){a(Vh(e,{organization:t,projectId:i,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},Wr=class{constructor(e){this.ar=(t,i,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(O.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.lr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.ur()}ur(){var e;this.hr=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.ar)}destroy(){var e;(e=this.hr)==null||e.call(this),this.hr=void 0}doPageView(e,t){var i,r=this.cr(e,t);return this.lr={pathname:(i=_?.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.cr(e,(t=this.lr)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.lr)==null?void 0:e.pageViewId}}cr(e,t){var i=this.lr;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:d,maxContentY:h}=n;if(!(P(o)||P(a)||P(l)||P(c)||P(d)||P(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),d=Math.ceil(d),h=Math.ceil(h);var f=o>1?at(a/o,0,1,O):1,g=o>1?at(l/o,0,1,O):1,p=c>1?at(d/c,0,1,O):1,v=c>1?at(h/c,0,1,O):1;r=fe(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:d,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}},Yr=s=>{var e=A?.createElement("a");return P(e)?null:(e.href=s,e)},Xr=function(s,e){for(var t,i=((s.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;i.length>r;r++){var n=i[r].split("=");if(n[0]===e){t=n;break}}if(!Y(t)||2>t.length)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{O.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ai=function(s,e,t){if(!s||!e||!e.length)return s;for(var i=s.split("#"),r=i[1],n=(i[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),c=[],d=0;l.length>d;d++){var h=l[d].split("=");Y(h)&&(e.includes(h[0])?c.push(h[0]+"="+t):c.push(l[d]))}var f=a;return o!=null&&(f+="?"+c.join("&")),r!=null&&(f+="#"+r),f},Jr=function(s,e){var t=s.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Dr="https?://(.*)",xs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Mb=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...xs],Ri="<masked>",Ub=["li_fat_id"];Qr="$direct";Vb=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],bi=class{constructor(e,t){this.Rt=e,this.props={},this.dr=!1,this.vr=(i=>{var r="";return i.token&&(r=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+r+"_posthog"})(e),this.tr=this.pr(e),this.load(),e.debug&&O.info("Persistence loaded",e.persistence,T({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.gr}pr(e){Vb.indexOf(e.persistence.toLowerCase())===-1&&(O.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(r){r===void 0&&(r=[]);var n=[...xb,...r];return T({},de,{Gt(o){try{var a={};try{a=ot.Gt(o)||{}}catch{}var l=fe(a,JSON.parse(de.Wt(o)||"{}"));return de.Xt(o,l),l}catch{}return null},Xt(o,a,l,c,d,h){try{de.Xt(o,a,void 0,void 0,h);var f={};n.forEach((g=>{a[g]&&(f[g]=a[g])})),Object.keys(f).length&&ot.Xt(o,f,l,c,d,h)}catch(g){de.Ut(g)}},Jt(o,a){try{_?.localStorage.removeItem(o),ot.Jt(o,a)}catch(l){de.Ut(l)}}})})(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return i==="localstorage"&&de.Yt()?de:i==="localstorage+cookie"&&t.Yt()?t:i==="sessionstorage"&&we.Yt()?we:i==="memory"?Lb:i==="cookie"?ot:t.Yt()?t:ot}mr(e){var t=e??this.Rt.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[Gr];return!i||typeof i!="number"||Date.now()-i>t}properties(){var e={};return ae(this.props,((t,i)=>{if(i===Rs&&_e(t)){if(!this.mr())for(var r=Object.keys(t),n=0;r.length>n;n++)e["$feature/"+r[n]]=t[r[n]]}else Ib.indexOf(i)===-1&&(e[i]=t)})),e}load(){if(!this.gr){var e=this.tr.Gt(this.vr);e&&(this.props=fe({},e))}}save(){this.gr||this.tr.Xt(this.vr,this.props,this.yr,this.br,this.wr,this.Rt.debug)}remove(){this.tr.Jt(this.vr,!1),this.tr.Jt(this.vr,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(_e(e)){P(t)&&(t="None"),this.yr=P(i)?this._r:i;var r=!1;if(ae(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=n,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(_e(e)){this.yr=P(t)?this._r:t;var i=!1;if(ae(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.props[n]=r,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.dr){var e=Gh(this.Rt.custom_campaign_params,this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties);As(ll(e))||this.register(e),this.dr=!0}}update_search_keyword(){var e;this.register((e=A?.referrer)?Hh(e):{})}update_referrer_info(){var e;this.register_once({$referrer:zh(),$referring_domain:A!=null&&A.referrer&&((e=Yr(A.referrer))==null?void 0:e.host)||Qr},void 0)}set_initial_person_info(){this.props[Ta]||this.props[Aa]||this.register_once({[jr]:Kh(this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};ae([Aa,Ta],(o=>{var a=this.props[o];a&&ae(a,(function(l,c){e["$initial_"+sa(c)]=l}))}));var t,i,r=this.props[jr];if(r){var n=(t=qh(r),i={},ae(t,(function(o,a){i["$initial_"+sa(a)]=o})),i);fe(e,n)}return e}safe_merge(e){return ae(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this._r=this.yr=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((d,h)=>d===c[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.pr(e),n=this.props;this.clear(),this.tr=r,this.props=n,this.save()}}set_disabled(e){this.gr=e,this.gr?this.remove():this.save()}set_cross_subdomain(e){e!==this.br&&(this.br=e,this.remove(),this.save())}set_secure(e){e!==this.wr&&(this.wr=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[fi]||{};i[e]=t,this.props[fi]=i,this.save()}remove_event_timer(e){var t=(this.props[fi]||{})[e];return P(t)||(delete this.props[fi][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},ri={Activation:"events",Cancellation:"cancelEvents"},Bo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},_i={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Vo={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"},Na={Popover:"popover",Inline:"inline"},Gb={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"},Rd={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"},Id=he("[RateLimiter]"),xa=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((r=>{Id.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void Id.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:i})}},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 t,i,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(wa))!==null&&t!==void 0?t:{tokens:n,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>n&&(l.tokens=n);var c=1>l.tokens;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||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=c,(r=this.instance.persistence)==null||r.set_property(wa,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ni=he("[RemoteConfig]"),Zr=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}Ir(e){var t,i;(t=L.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Cr(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return ni.info("Using preloaded remote config",this.remoteConfig),this.Sr(this.remoteConfig),void this.kr();if(this._instance.Tr())return void ni.warn("Remote config is disabled. Falling back to local config.");this.Ir((e=>{if(!e)return ni.info("No config found after loading remote JS config. Falling back to JSON."),void this.Cr((t=>{this.Sr(t),this.kr()}));this.Sr(e),this.kr()}))}catch(e){ni.error("Error loading remote config",e)}}stop(){this.Ar&&(clearInterval(this.Ar),this.Ar=void 0)}refresh(){this._instance.Tr()||A?.visibilityState==="hidden"||this._instance.reloadFeatureFlags()}kr(){var e;if(!this.Ar){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.Ar=setInterval((()=>{this.refresh()}),t))}}Sr(e){var t;e||ni.error("Failed to fetch remote config from PostHog."),this._instance.Sr(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},nt={GZipJS:"gzip-js",Base64:"base64"},Ke=Uint8Array,Ce=Uint16Array,Ls=Uint32Array,cl=new Ke([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]),ul=new Ke([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]),Od=new Ke([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yh=function(s,e){for(var t=new Ce(31),i=0;31>i;++i)t[i]=e+=1<<s[i-1];var r=new Ls(t[30]);for(i=1;30>i;++i)for(var n=t[i];t[i+1]>n;++n)r[n]=n-t[i]<<5|i;return[t,r]},Xh=Yh(cl,2),La=Xh[1];Xh[0][28]=258,La[258]=28;for($a=Yh(ul,0)[1],en=new Ce(32768),re=0;32768>re;++re)Yt=(43690&re)>>>1|(21845&re)<<1,en[re]=((65280&(Yt=(61680&(Yt=(52428&Yt)>>>2|(13107&Yt)<<2))>>>4|(3855&Yt)<<4))>>>8|(255&Yt)<<8)>>>1;Ei=function(s,e,t){for(var i=s.length,r=0,n=new Ce(e);i>r;++r)++n[s[r]-1];var o,a=new Ce(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(t){o=new Ce(1<<e);var l=15-e;for(r=0;i>r;++r)if(s[r])for(var c=r<<4|s[r],d=e-s[r],h=a[s[r]-1]++<<d,f=h|(1<<d)-1;f>=h;++h)o[en[h]>>>l]=c}else for(o=new Ce(i),r=0;i>r;++r)o[r]=en[a[s[r]-1]++]>>>15-s[r];return o},es=new Ke(288);for(re=0;144>re;++re)es[re]=8;for(re=144;256>re;++re)es[re]=9;for(re=256;280>re;++re)es[re]=7;for(re=280;288>re;++re)es[re]=8;tn=new Ke(32);for(re=0;32>re;++re)tn[re]=5;jb=Ei(es,9,0),Hb=Ei(tn,5,0),Jh=function(s){return(s/8>>0)+(7&s&&1)},Qh=function(s,e,t){(t==null||t>s.length)&&(t=s.length);var i=new(s instanceof Ce?Ce:s instanceof Ls?Ls:Ke)(t-e);return i.set(s.subarray(e,t)),i},_t=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8},oi=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8,s[i+2]|=t>>>16},Go=function(s,e){for(var t=[],i=0;s.length>i;++i)s[i]&&t.push({s:i,f:s[i]});var r=t.length,n=t.slice();if(!r)return[new Ke(0),0];if(r==1){var o=new Ke(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(I,C){return I.f-C.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,d=1,h=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};d!=r-1;)a=t[t[h].f>t[c].f?c++:h++],l=t[c!=d&&t[h].f>t[c].f?c++:h++],t[d++]={s:-1,f:a.f+l.f,l:a,r:l};var f=n[0].s;for(i=1;r>i;++i)n[i].s>f&&(f=n[i].s);var g=new Ce(f+1),p=Fa(t[d-1],g,0);if(p>e){i=0;var v=0,m=p-e,b=1<<m;for(n.sort((function(I,C){return g[C.s]-g[I.s]||I.f-C.f}));r>i;++i){var E=n[i].s;if(e>=g[E])break;v+=b-(1<<p-g[E]),g[E]=e}for(v>>>=m;v>0;){var D=n[i].s;e>g[D]?v-=1<<e-g[D]++-1:++i}for(;i>=0&&v;--i){var R=n[i].s;g[R]==e&&(--g[R],++v)}p=e}return[new Ke(g),p]},Fa=function(s,e,t){return s.s==-1?Math.max(Fa(s.l,e,t+1),Fa(s.r,e,t+1)):e[s.s]=t},Cd=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new Ce(++e),i=0,r=s[0],n=1,o=function(l){t[i++]=l},a=1;e>=a;++a)if(s[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=s[a]}return[t.subarray(0,i),e]},ai=function(s,e){for(var t=0,i=0;e.length>i;++i)t+=s[i]*e[i];return t},Ma=function(s,e,t){var i=t.length,r=Jh(e+2);s[r]=255&i,s[r+1]=i>>>8,s[r+2]=255^s[r],s[r+3]=255^s[r+1];for(var n=0;i>n;++n)s[r+n+4]=t[n];return 8*(r+4+i)},Pd=function(s,e,t,i,r,n,o,a,l,c,d){_t(e,d++,t),++r[256];for(var h=Go(r,15),f=h[0],g=h[1],p=Go(n,15),v=p[0],m=p[1],b=Cd(f),E=b[0],D=b[1],R=Cd(v),I=R[0],C=R[1],w=new Ce(19),S=0;E.length>S;++S)w[31&E[S]]++;for(S=0;I.length>S;++S)w[31&I[S]]++;for(var $=Go(w,7),G=$[0],z=$[1],V=19;V>4&&!G[Od[V-1]];--V);var k,N,F,M,J=c+5<<3,K=ai(r,es)+ai(n,tn)+o,Q=ai(r,f)+ai(n,v)+o+14+3*V+ai(w,G)+(2*w[16]+3*w[17]+7*w[18]);if(K>=J&&Q>=J)return Ma(e,d,s.subarray(l,l+c));if(_t(e,d,1+(K>Q)),d+=2,K>Q){k=Ei(f,g,0),N=f,F=Ei(v,m,0),M=v;var ee=Ei(G,z,0);for(_t(e,d,D-257),_t(e,d+5,C-1),_t(e,d+10,V-4),d+=14,S=0;V>S;++S)_t(e,d+3*S,G[Od[S]]);d+=3*V;for(var te=[E,I],ye=0;2>ye;++ye){var U=te[ye];for(S=0;U.length>S;++S)_t(e,d,ee[Te=31&U[S]]),d+=G[Te],Te>15&&(_t(e,d,U[S]>>>5&127),d+=U[S]>>>12)}}else k=jb,N=es,F=Hb,M=tn;for(S=0;a>S;++S)if(i[S]>255){var Te;oi(e,d,k[257+(Te=i[S]>>>18&31)]),d+=N[Te+257],Te>7&&(_t(e,d,i[S]>>>23&31),d+=cl[Te]);var qe=31&i[S];oi(e,d,F[qe]),d+=M[qe],qe>3&&(oi(e,d,i[S]>>>5&8191),d+=ul[qe])}else oi(e,d,k[i[S]]),d+=N[i[S]];return oi(e,d,k[256]),d+N[256]},zb=new Ls([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Kb=(function(){for(var s=new Ls(256),e=0;256>e;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;s[e]=t}return s})(),jo=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8};Wb=!!ta||!!ea,Zh="text/plain",sn=function(s,e,t){var i;t===void 0&&(t=!0);var[r,n]=s.split("?"),o=T({},e),a=(i=n?.split("&").map((c=>{var d,[h,f]=c.split("="),g=t&&(d=o[h])!==null&&d!==void 0?d:f;return delete o[h],h+"="+g})))!==null&&i!==void 0?i:[],l=(function(c,d){var h,f;d===void 0&&(d="&");var g=[];return ae(c,(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(d)})(o);return l&&a.push(l),r+"?"+a.join("&")},Is=(s,e)=>JSON.stringify(s,((t,i)=>typeof i=="bigint"?i.toString():i),e),Ho=s=>{if(s.zt)return s.zt;var{data:e,compression:t}=s;if(e){if(t===nt.GZipJS){var i=qb((function(a,l){var c=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var d=new Ke(a.length+(a.length>>>1)),h=0,f=function(m){d[h++]=m},g=0;c>g;++g){if(h+5>d.length){var p=new Ke(h+8+(c-g<<1));p.set(d),d=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 Qh(d,0,h)})(Is(e)),{mtime:0});return{contentType:Zh,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(t===nt.Base64){var r=(function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,((l,c)=>String.fromCharCode(parseInt(c,16)))))})(Is(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Is(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Is(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Yb=(function(){var s=Ze((function*(e){var t=Is(e.data),i=yield(function(n,o){return dh.apply(this,arguments)})(t,Ue.DEBUG);if(!i)return e;var r=yield i.arrayBuffer();return T({},e,{zt:{contentType:Zh,body:r,estimatedSize:r.byteLength}})}));return function(e){return s.apply(this,arguments)}})(),Fr=[];ea&&Fr.push({transport:"fetch",method(s){var e,t,{contentType:i,body:r,estimatedSize:n}=(e=Ho(s))!==null&&e!==void 0?e:{},o=new Headers;ae(s.headers,(function(d,h){o.append(h,d)})),i&&o.append("Content-Type",i);var a=s.url,l=null;if(ad){var c=new ad;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),s.timeout)}}ea(a,T({method:s?.method||"GET",headers:o,keepalive:s.method==="POST"&&52428.8>(n||0),body:r,signal:(t=l)==null?void 0:t.signal},s.fetchOptions)).then((d=>d.text().then((h=>{var f={statusCode:d.status,text:h};if(d.status===200)try{f.json=JSON.parse(h)}catch(g){O.error(g)}s.callback==null||s.callback(f)})))).catch((d=>{O.error(d),s.callback==null||s.callback({statusCode:0,error:d})})).finally((()=>l?clearTimeout(l.timeout):null))}}),ta&&Fr.push({transport:"XHR",method(s){var e,t=new ta;t.open(s.method||"GET",s.url,!0);var{contentType:i,body:r}=(e=Ho(s))!==null&&e!==void 0?e:{};ae(s.headers,(function(n,o){t.setRequestHeader(o,n)})),i&&t.setRequestHeader("Content-Type",i),s.timeout&&(t.timeout=s.timeout),s.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}s.callback==null||s.callback(n)}},t.send(r)}}),Be!=null&&Be.sendBeacon&&Fr.push({transport:"sendBeacon",method(s){var e=sn(s.url,{beacon:"1"});try{var t,{contentType:i,body:r}=(t=Ho(s))!==null&&t!==void 0?t:{};if(!r)return;var n=r instanceof Blob?r:new Blob([r],{type:i});Be.sendBeacon(e,n)}catch{}}});Ua=3e3,Ba=class{constructor(e,t){this.Er=!0,this.Rr=[],this.Nr=at(t?.flush_interval_ms||Ua,250,5e3,O.createLogger("flush interval"),Ua),this.Mr=e}enqueue(e){this.Rr.push(e),this.Fr||this.Or()}unload(){this.Pr();var e=this.Rr.length>0?this.Lr():{},t=Object.values(e);[...t.filter((i=>i.url.indexOf("/e")===0)),...t.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.Mr(T({},i,{transport:"sendBeacon"}))}))}enable(){this.Er=!1,this.Or()}Or(){var e=this;this.Er||(this.Fr=setTimeout((()=>{if(this.Pr(),this.Rr.length>0){var t=this.Lr(),i=function(){var n=t[r],o=new Date().getTime();n.data&&Y(n.data)&&ae(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Mr(n)};for(var r in t)i()}}),this.Nr))}Pr(){clearTimeout(this.Fr),this.Fr=void 0}Lr(){var e={};return ae(this.Rr,(t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;P(e[n])&&(e[n]=T({},r,{data:[]})),(i=e[n].data)==null||i.push(r.data)})),this.Rr=[],e}},Xb=["retriesPerformedSoFar"],Va=class{constructor(e){this.Dr=!1,this.Br=3e3,this.Rr=[],this._instance=e,this.Rr=[],this.jr=!0,!P(_)&&"onLine"in _.navigator&&(this.jr=_.navigator.onLine,this.qr=()=>{this.jr=!0,this.Zr()},this.$r=()=>{this.jr=!1},pe(_,"online",this.qr),pe(_,"offline",this.$r))}get length(){return this.Rr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=uh(e,Xb);ks(t)&&(i.url=sn(i.url,{retry_count:t})),this._instance._send_request(T({},i,{callback:r=>{r.statusCode===200||r.statusCode>=400&&500>r.statusCode||(t??0)>=10?i.callback==null||i.callback(r):this.Hr(T({retriesPerformedSoFar:t},i))}}))}Hr(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),d=Math.random()-.5;return Math.ceil(c+d*(c-l))})(t),r=Date.now()+i;this.Rr.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+i;navigator.onLine||(n+=" (Browser is offline)"),O.warn(n),this.Dr||(this.Dr=!0,this.Vr())}Vr(){if(this.zr&&clearTimeout(this.zr),this.Rr.length===0)return this.Dr=!1,void(this.zr=void 0);this.zr=setTimeout((()=>{this.jr&&this.Rr.length>0&&this.Zr(),this.Vr()}),this.Br)}Zr(){var e=Date.now(),t=[],i=this.Rr.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Rr=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.zr&&(clearTimeout(this.zr),this.zr=void 0),this.Dr=!1,P(_)||(this.qr&&(_.removeEventListener("online",this.qr),this.qr=void 0),this.$r&&(_.removeEventListener("offline",this.$r),this.$r=void 0)),this.Rr))try{this._instance._send_request(T({},e,{transport:"sendBeacon"}))}catch(t){O.error(t)}this.Rr=[]}},Ga=class{constructor(e){this.Yr=()=>{var t,i,r,n;this.Ur||(this.Ur={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),d=o?.scrollHeight||0;this.Ur.lastScrollY=Math.ceil(a),this.Ur.maxScrollY=Math.max(a,(t=this.Ur.maxScrollY)!==null&&t!==void 0?t:0),this.Ur.maxScrollHeight=Math.max(l,(i=this.Ur.maxScrollHeight)!==null&&i!==void 0?i:0),this.Ur.lastContentY=c,this.Ur.maxContentY=Math.max(c,(r=this.Ur.maxContentY)!==null&&r!==void 0?r:0),this.Ur.maxContentHeight=Math.max(d,(n=this.Ur.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get Wr(){return this._instance.config.scroll_root_selector}getContext(){return this.Ur}resetContext(){var e=this.Ur;return setTimeout(this.Yr,0),e}startMeasuringScrollPosition(){pe(_,"scroll",this.Yr,{capture:!0}),pe(_,"scrollend",this.Yr,{capture:!0}),pe(_,"resize",this.Yr)}scrollElement(){if(!this.Wr)return _?.document.documentElement;var e=Y(this.Wr)?this.Wr:[this.Wr];for(var t of e){var i=_?.document.querySelector(t);if(i)return i}}scrollY(){if(this.Wr){var e=this.scrollElement();return e&&e.scrollTop||0}return _&&(_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop)||0}scrollX(){if(this.Wr){var e=this.scrollElement();return e&&e.scrollLeft||0}return _&&(_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft)||0}},Jb=s=>Kh(s?.config.mask_personal_data_properties,s?.config.custom_personal_data_properties),rn=class{constructor(e,t,i,r){this.Gr=n=>{var o=this.Xr();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.Jr(this._instance)};this.Kr.register({[ka]:a})}},this._instance=e,this.Qr=t,this.Kr=i,this.Jr=r||Jb,this.Qr.onSessionId(this.Gr)}Xr(){return this.Kr.props[ka]}getSetOnceProps(){var e,t=(e=this.Xr())==null?void 0:e.props;return t?"r"in t?qh(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return ae(ll(this.getSetOnceProps()),((t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+sa(i)]=t})),e}},Ii=class{constructor(){this.ti={}}on(e,t){return this.ti[e]||(this.ti[e]=[]),this.ti[e].push(t),()=>{this.ti[e]=this.ti[e].filter((i=>i!==t))}}emit(e,t){for(var i of this.ti[e]||[])i(t);for(var r of this.ti["*"]||[])r(e,t)}},zo=he("[SessionId]"),nn=class{on(e,t){return this.ei.on(e,t)}constructor(e,t,i){var r;if(this.ri=[],this.ii=void 0,this.ei=new Ii,this.ni=(c,d)=>!(!ks(c)||!ks(d))&&Math.abs(c-d)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===et)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Rt=e.config,this.Kr=e.persistence,this.si=void 0,this.oi=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ai=t||xt,this.li=i||xt;var n=this.Rt.persistence_name||this.Rt.token;if(this._sessionTimeoutMs=1e3*at(this.Rt.session_idle_timeout_seconds||1800,60,36e3,zo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ui(),this.hi="ph_"+n+"_window_id",this.ci="ph_"+n+"_primary_window_exists",this.di()){var o=we.Gt(this.hi),a=we.Gt(this.ci);o&&!a?this.si=o:we.Jt(this.hi),we.Xt(this.ci,!0)}if((r=this.Rt.bootstrap)!=null&&r.sessionID)try{var l=(c=>{var d=this.Rt.bootstrap.sessionID.replace(/-/g,"");if(d.length!==32)throw new Error("Not a valid UUID");if(d[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(d.substring(0,12),16)})();this.vi(this.Rt.bootstrap.sessionID,new Date().getTime(),l)}catch(c){zo.error("Invalid sessionID in bootstrap",c)}this.fi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return P(this.ri)&&(this.ri=[]),this.ri.push(e),this.oi&&e(this.oi,this.si),()=>{this.ri=this.ri.filter((t=>t!==e))}}di(){return this.Rt.persistence!=="memory"&&!this.Kr.gr&&we.Yt()}pi(e){e!==this.si&&(this.si=e,this.di()&&we.Xt(this.hi,e))}gi(){return this.si?this.si:this.di()?we.Gt(this.hi):null}vi(e,t,i){e===this.oi&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.oi=e,this.Kr.register({[Vr]:[t,e,i]}))}mi(){var e=this.Kr.props[Vr];return Y(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vi(null,null,null)}destroy(){clearTimeout(this.yi),this.yi=void 0,this.ii&&_&&(_.removeEventListener(Kr,this.ii,{capture:!1}),this.ii=void 0),this.ri=[]}fi(){this.ii=()=>{this.di()&&we.Jt(this.ci)},pe(_,Kr,this.ii,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Rt.cookieless_mode===et)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||new Date().getTime(),[r,n,o]=this.mi(),a=this.gi(),l=ks(o)&&Math.abs(i-o)>864e5,c=!1,d=!n,h=!d&&!e&&this.ni(i,r);d||h||l?(n=this.ai(),a=this.li(),zo.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}}),o=i,c=!0):a||(a=this.li(),c=!0);var f=ks(r)&&e&&!l?r:i,g=ks(o)?o:new Date().getTime();return this.pi(a),this.vi(n,f,g),e||this.ui(),c&&this.ri.forEach((p=>p(n,a,c?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:g,changeReason:c?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}ui(){clearTimeout(this.yi),this.yi=setTimeout((()=>{var[e]=this.mi();if(this.ni(new Date().getTime(),e)){var t=this.oi;this.resetSessionId(),this.ei.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},eg=function(s,e){if(!s)return!1;var t=s.userAgent;if(t&&ud(t,e))return!0;try{var i=s?.userAgentData;if(i!=null&&i.brands&&i.brands.some((r=>ud(r?.brand,e))))return!0}catch{}return!!s.webdriver},on=function(s,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(s)}catch{return!1}};tg={exact:(s,e)=>e.some((t=>s.some((i=>t===i)))),is_not:(s,e)=>e.every((t=>s.every((i=>t!==i)))),regex:(s,e)=>e.some((t=>s.some((i=>on(t,i))))),not_regex:(s,e)=>e.every((t=>s.every((i=>!on(t,i))))),icontains:(s,e)=>e.map(Nr).some((t=>s.map(Nr).some((i=>t.includes(i))))),not_icontains:(s,e)=>e.map(Nr).every((t=>s.map(Nr).every((i=>!t.includes(i))))),gt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((r=>i>parseFloat(r)))})),lt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((r=>i<parseFloat(r)))}))},Nr=s=>s.toLowerCase();ja="custom",Nd="i.posthog.com",Ha=class{constructor(e){this.bi={},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,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+Nd,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.bi[this.apiHost]||(this.bi[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":ja),this.bi[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===ja)return this.apiHost+t;var i=Nd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}},ie=he("[Surveys]"),za="seenSurvey_",Qb=(s,e)=>{var t="$survey_"+e+"/"+s.id;return s.current_iteration&&s.current_iteration>0&&(t="$survey_"+e+"/"+s.id+"/"+s.current_iteration),t},xd=s=>((e,t)=>{var i=""+za+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+za+t.id+"_"+t.current_iteration),i})(0,s),Zb=[Bo.Popover,Bo.Widget,Bo.API],eE={ignoreConditions:!1,ignoreDelay:!1,displayType:Na.Popover},tE=he("[PostHog ExternalIntegrations]"),sE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ka=class{constructor(e){this._instance=e}nr(e,t){var i;(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,(r=>{if(r)return tE.error("failed to load script",r);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!r||(a=L.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.nr(sE[o],(()=>{var d;(d=L.__PosthogExtensions__)==null||(d=d.integrations)==null||(d=d[o])==null||d.start(e._instance)})),!r&&(l=L.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=L.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[i,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;t(i)}}},Si={},Ko=0,qa=()=>{},Ld='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',li="Surveys module not available",$d="sanitize_properties is deprecated. Use before_send instead",ig="Invalid value for property_denylist config: ",Ts="posthog",rg=!Wb&&$e?.indexOf("MSIE")===-1&&$e?.indexOf("Mozilla")===-1,Fd=s=>{var e;return T({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Pb(A?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:qa,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:s??"unset",__preview_deferred_init_extensions:!1,debug:ke&&ve(ke?.search)&&ke.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(t){O.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ra,before_send:void 0,request_queue_config:{flush_interval_ms:Ua},error_tracking:{},_onCapture:qa,__preview_eager_load_replay:!1},(t=>({rageclick:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(s))},iE=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Md=s=>{var e={};for(var[t,i]of iE)P(s[t])||(e[i]=s[t]);var r=fe({},e,s);return Y(s.property_blacklist)&&(P(s.property_denylist)?r.property_denylist=s.property_blacklist:Y(s.property_denylist)?r.property_denylist=[...s.property_blacklist,...s.property_denylist]:O.error(ig+s.property_denylist)),r},Wa=class{constructor(){this.__forceAllowLocalhost=!1}get wi(){return this.__forceAllowLocalhost}set wi(e){O.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},$s=class s{Ii(e,t){if(e){var i=this.Ci.indexOf(e);i!==-1&&this.Ci.splice(i,1)}return this.Ci.push(t),t.initialize==null||t.initialize(),t}get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new Wa,this.Si=!1,this.version=Ue.LIB_VERSION,this.ki=new Ii,this.Ci=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Fd(),this.SentryIntegration=Da,this.sentryIntegration=i=>(function(r,n){var o=Vh(r,n);return{name:Bh,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.xi=!1,this.Ti=null,this.Ai=null,this.Ei=null,this.scrollManager=new Ga(this),this.pageViewManager=new Wr(this),this.rateLimiter=new xa(this),this.requestRouter=new Ha(this),this.consent=new Pa(this),this.externalIntegrations=new Ka(this);var t=(e=s.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(i,r,n)=>{var o=ve(i)?{[i]:r}:i;this.setPersonProperties(o),n?.({})},set_once:(i,r,n)=>{var o=ve(i)?{[i]:r}:i;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(i=>O.info('send "'+i?.event+'"',i)))}init(e,t,i){if(i&&i!==Ts){var r,n=(r=Si[i])!==null&&r!==void 0?r:new s;return n._init(e,t,i),Si[i]=n,Si[Ts][i]=n,n}return this._init(e,t,i)}_init(e,t,i){var r;if(t===void 0&&(t={}),P(e)||Lr(e))return O.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={},t.debug=this.Ri(t.debug),this.Ni=t,this.Mi=[],t.person_profiles?this.Ai=t.person_profiles:t.process_person&&(this.Ai=t.process_person),this.set_config(fe({},Fd(t.defaults),Md(t),{name:i,token:e})),this.config.on_xhr_error&&O.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:nt.GZipJS;var n=this.Fi();this.persistence=new bi(this.config,n),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new bi(T({},this.config,{persistence:"sessionStorage"}),n);var o=T({},this.persistence.props),a=T({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Oi=new Ba((v=>this.Pi(v)),this.config.request_queue_config),this.Li=new Va(this),this.__request_queue=[];var l=this.config.cookieless_mode===et||this.config.cookieless_mode===mt&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new nn(this),this.sessionPropsManager=new rn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(O.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Di(l)}),0)):(O.info("Initializing extensions synchronously"),this.Di(l)),Ue.DEBUG=Ue.DEBUG||this.config.debug,Ue.DEBUG&&O.info("Starting in debug mode",{this:this,config:t,thisC:T({},this.config),p:o,s:a}),((r=t.bootstrap)==null?void 0:r.distinctID)!==void 0){var c=t.bootstrap.distinctID,d=this.get_distinct_id(),h=this.persistence.get_property(Qe);if(t.bootstrap.isIdentifiedID&&d!=null&&d!==c&&h===bs)this.identify(c);else if(t.bootstrap.isIdentifiedID&&d!=null&&d!==c&&h===Es)O.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 f=this.config.get_device_id(xt()),g=t.bootstrap.isIdentifiedID?f:c;this.persistence.set_property(Qe,t.bootstrap.isIdentifiedID?Es:bs),this.register({distinct_id:c,$device_id:g})}}if(l)this.register_once({distinct_id:Ir,$device_id:null},"");else if(!this.get_distinct_id()){var p=this.config.get_device_id(xt());this.register_once({distinct_id:p,$device_id:p},""),this.persistence.set_property(Qe,bs)}return pe(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?(function(v,m){var b=v.config.segment;if(!b)return m();(function(E,D){var R=E.config.segment;if(!R)return D();var I=w=>{var S=()=>w.anonymousId()||xt();E.config.get_device_id=S,w.id()&&(E.register({distinct_id:w.id(),$device_id:S()}),E.persistence.set_property(Qe,Es)),D()},C=R.user();"then"in C&&yt(C.then)?C.then(I):I(C)})(v,(()=>{b.register((E=>{Promise&&Promise.resolve||Uo.warn("This browser does not have Promise support, and can not use the segment integration");var D=(R,I)=>{if(!I)return R;R.event.userId||R.event.anonymousId===E.get_distinct_id()||(Uo.info("No userId set, resetting PostHog"),E.reset()),R.event.userId&&R.event.userId!==E.get_distinct_id()&&(Uo.info("UserId set, identifying with PostHog"),E.identify(R.event.userId));var C=E.calculateEventProperties(I,R.event.properties);return R.event.properties=Object.assign({},C,R.event.properties),R};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:R=>D(R,R.event.event),page:R=>D(R,ws),identify:R=>D(R,Fo),screen:R=>D(R,"$screen")}})(v)).then((()=>{m()}))}))})(this,(()=>this.Bi())):this.Bi(),yt(this.config._onCapture)&&this.config._onCapture!==qa&&(O.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(v=>this.config._onCapture(v.event,v)))),this.config.ip&&O.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}Di(e){var t,i,r,n,o,a,l,c=performance.now(),d=T({},s.__defaultExtensionClasses,this.config.__extensionClasses),h=[];d.featureFlags&&this.Ci.push(this.featureFlags=(t=this.featureFlags)!==null&&t!==void 0?t:new d.featureFlags(this)),d.exceptions&&this.Ci.push(this.exceptions=(i=this.exceptions)!==null&&i!==void 0?i:new d.exceptions(this)),d.historyAutocapture&&this.Ci.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this.Ci.push(new d.tracingHeaders(this)),d.siteApps&&this.Ci.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!e&&this.Ci.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),d.autocapture&&this.Ci.push(this.autocapture=new d.autocapture(this)),d.surveys&&this.Ci.push(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new d.surveys(this)),d.logs&&this.Ci.push(this.logs=(n=this.logs)!==null&&n!==void 0?n:new d.logs(this)),d.conversations&&this.Ci.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new d.conversations(this)),d.productTours&&this.Ci.push(this.productTours=new d.productTours(this)),d.heatmaps&&this.Ci.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this.Ci.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this.Ci.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this.Ci.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,Fb)),d.toolbar&&this.Ci.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new d.toolbar(this)),d.experiments&&this.Ci.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new d.experiments(this)),this.Ci.forEach((f=>{f.initialize&&h.push((()=>{f.initialize==null||f.initialize()}))})),h.push((()=>{if(this.ji){var f=this.ji;this.ji=void 0,this.Sr(f)}})),this.qi(h,c)}qi(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.qi(e,t)}),0);var i=e.shift();if(i)try{i()}catch(n){O.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&O.info("PostHog extensions initialized ("+r+"ms)")}Sr(e){var t;if(!A||!A.body)return O.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Sr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.ji=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=j(e.supportedCompression,nt.GZipJS)?nt.GZipJS:j(e.supportedCompression,nt.Base64)?nt.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ai?this.Ai:Ra}),this.Ci.forEach((i=>i.onRemoteConfig==null?void 0:i.onRemoteConfig(e)))}Bi(){try{this.config.loaded(this)}catch(i){O.critical("`loaded` function failed",i)}if(this.Zi(),this.config.internal_or_test_user_hostname&&ke!=null&&ke.hostname){var e=ke.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode===et)&&this.$i()}),1),this.Hi=new Zr(this),this.Hi.load()}Zi(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Oi)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Or(this.__request_queue,(e=>this.Pi(e))),this.__request_queue=[],this.Zi()}_handle_unload(){var e,t,i;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Vi()&&this.capture($o),(t=this.Oi)==null||t.unload(),(i=this.Li)==null||i.unload()):this.Vi()&&this.capture($o,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(rg?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=sn(e.url,{ip:this.config.ip?1:0}),e.headers=T({},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,(t=>{var i,r,n,o=T({},t);o.timeout=o.timeout||6e4,o.url=sn(o.url,{_:new Date().getTime().toString(),ver:Ue.JS_SDK_VERSION,compression:o.compression});var a=(i=o.transport)!==null&&i!==void 0?i:"fetch",l=Fr.filter((d=>!o.disableTransport||!d.transport||!o.disableTransport.includes(d.transport))),c=(r=(n=(function(d,h){for(var f=0;d.length>f;f++)if(d[f].transport===a)return d[f]})(l))==null?void 0:n.method)!==null&&r!==void 0?r:l[0].method;if(!c)throw new Error("No available transport method");a!=="sendBeacon"&&o.data&&o.compression===nt.GZipJS&&eb?Yb(o).then((d=>{c(d)})).catch((()=>{c(o)})):c(o)})(T({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(i=(r=this.config).on_request_error)==null||i.call(r,t),e.callback==null||e.callback(t)}}))))}Pi(e){this.Li?this.Li.retriableRequest(e):this._send_request(e)}_execute_array(e){Ko++;try{var t,i=[],r=[],n=[];Or(e,(a=>{a&&(Y(t=a[0])?n.push(a):yt(a)?a.call(this):Y(a)&&t==="alias"?i.push(a):Y(a)&&t.indexOf("capture")!==-1&&yt(this[t])?n.push(a):r.push(a))}));var o=function(a,l){Or(a,(function(c){if(Y(c[0])){var d=l;ae(c,(function(h){d=d[h[0]].apply(d,h.slice(1))}))}else l[c[0]].apply(l,c.slice(1))}))};o(i,this),o(r,this),o(n,this)}finally{Ko--}}push(e){if(Ko>0&&Y(e)&&ve(e[0])){var t=s.prototype[e[0]];yt(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,i){var r,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Oi){if(this.is_capturing())if(!P(e)&&ve(e)){var c=!this.config.opt_out_useragent_filter&&this._is_bot();if(!c||this.config.__preview_capture_bot_pageviews){var d=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(d==null||!d.isRateLimited){t!=null&&t.$current_url&&!ve(t?.$current_url)&&(O.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!=="$exception"||i!=null&&i.zi||O.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=i?.timestamp||h,g=xt(),p={uuid:g,event:e,properties:this.calculateEventProperties(e,t||{},f,g)};e===ws&&this.config.__preview_capture_bot_pageviews&&c&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),d&&(p.properties.$lib_rate_limit_remaining_tokens=d.remainingTokens),i?.$set&&(p.$set=i?.$set);var v,m=this.Yi(i?.$set_once,e!==kd,e===Fo);if(m&&(p.$set_once=m),i!=null&&i._noTruncate||(n=this.config.properties_string_max_length,o=p,a=w=>ve(w)?w.slice(0,n):w,l=new Set,p=(function w(S,$){return S!==Object(S)?a?a(S):S:l.has(S)?void 0:(l.add(S),Y(S)?(G=[],Or(S,(z=>{G.push(w(z))}))):(G={},ae(S,((z,V)=>{l.has(z)||(G[V]=w(z,V))}))),G);var G})(o)),p.timestamp=f,P(i?.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=h),e===_i.DISMISSED||e===_i.SENT){var b=t?.[Vo.SURVEY_ID],E=t?.[Vo.SURVEY_ITERATION];v={id:b,current_iteration:E},localStorage.getItem(xd(v))||localStorage.setItem(xd(v),"true"),p.$set=T({},p.$set,{[Qb({id:b,current_iteration:E},e===_i.SENT?"responded":"dismissed")]:!0})}else e===_i.SHOWN&&(p.$set=T({},p.$set,{[Vo.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Gb.SHOWN){var D=t?.[Rd.TOUR_TYPE];D&&(p.$set=T({},p.$set,{[Rd.TOUR_LAST_SEEN_DATE+"/"+D]:new Date().toISOString()}))}var R=T({},p.properties.$set,p.$set);if(As(R)||this.setPersonPropertiesForFlags(R),!H(this.config.before_send)){var I=this.Ui(p);if(!I)return;p=I}this.ki.emit("eventCaptured",p);var C={method:"POST",url:(r=i?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:i?._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.Pi(C):this.Oi.enqueue(C),p}O.critical("This capture call is ignored due to client rate limiting.")}}else O.error("No event name provided to posthog.capture")}else O.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=T({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode==et||this.config.cookieless_mode==mt&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=T({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ve(a.distinct_id)&&!lt(a.distinct_id)||Lr(a.distinct_id))&&O.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,d=(function(b,E){var D,R,I,C;if(!$e)return{};var w,S,$,G,z,V,k,N,F=b?[...xs,...E||[]]:[],[M,J]=(function(K){for(var Q=0;gd.length>Q;Q++){var[ee,te]=gd[Q],ye=ee.exec(K),U=ye&&(yt(te)?te(ye,K):te);if(U)return U}return["",""]})($e);return fe(ll({$os:M,$os_version:J,$browser:Ch($e,navigator.vendor),$device:fd($e),$device_type:(S=$e,$={userAgentDataPlatform:(D=navigator)==null||(D=D.userAgentData)==null?void 0:D.platform,maxTouchPoints:(R=navigator)==null?void 0:R.maxTouchPoints,screenWidth:_==null||(I=_.screen)==null?void 0:I.width,screenHeight:_==null||(C=_.screen)==null?void 0:C.height,devicePixelRatio:_?.devicePixelRatio},N=fd(S),N===vh||N===ph||N==="Kobo"||N==="Kindle Fire"||N===Oh?Ps:N===wi||N===Cs||N===Ti||N===na?"Console":N===mh?"Wearable":N?Ve:$?.userAgentDataPlatform==="Android"&&((G=$?.maxTouchPoints)!==null&&G!==void 0?G:0)>0?600>Math.min((z=$?.screenWidth)!==null&&z!==void 0?z:0,(V=$?.screenHeight)!==null&&V!==void 0?V:0)/((k=$?.devicePixelRatio)!==null&&k!==void 0?k:1)?Ve:Ps:"Desktop"),$timezone:Wh(),$timezone_offset:Bb()}),{$current_url:Ai(ke?.href,F,Ri),$host:ke?.host,$pathname:ke?.pathname,$raw_user_agent:$e.length>1e3?$e.substring(0,997)+"...":$e,$browser_version:pb($e,navigator.vendor),$browser_language:Ad(),$browser_language_prefix:(w=Ad(),typeof w=="string"?w.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.innerWidth,$lib:Ue.LIB_NAME,$lib_version:Ue.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,i.getTime());a.$session_id=h,a.$window_id=f}this.sessionPropsManager&&fe(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&fe(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.Li)==null?void 0:g.length}catch(b){a.$sdk_debug_error_capturing_properties=String(b)}if(this.requestRouter.region===ja&&(a.$lib_custom_api_host=this.config.api_host),c=e!==ws||n?e!==$o||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=fe(a,c),e===ws&&A&&(a.title=A.title),!P(o)){var p=i.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}$e&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=fe({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),Y(this.config.property_denylist)?ae(this.config.property_denylist,(function(b){delete a[b]})):O.error(ig+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(O.error($d),a=v(a,e));var m=this.Wi();return a.$process_person_profile=m,m&&!n&&this.Gi("_calculate_event_properties"),a}Yi(e,t,i){var r;if(t===void 0&&(t=!0),i===void 0&&(i=!1),!this.persistence||!this.Wi()||this.Si&&!i)return e;var n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),a=fe({},n,o||{},e||{}),l=this.config.sanitize_properties;return l&&(O.error($d),a=l(a,"$set_once")),t&&(this.Si=!0),As(a)?void 0:a}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var r;(r=this.persistence)==null||r.register_once(e,t,i)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}Xi(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return(t=this.featureFlags)==null?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var i;return(i=this.featureFlags)==null?void 0:i.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,i){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return t===void 0&&(t=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.ki.on(e,t)}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:li}),()=>{})}onSessionId(e){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:li})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:li})}renderSurvey(e,t){var i;(i=this.surveys)==null||i.renderSurvey(e,t)}displaySurvey(e,t){var i;t===void 0&&(t=eE),(i=this.surveys)==null||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return(t=(i=this.surveys)==null?void 0:i.canRenderSurvey(e))!==null&&t!==void 0?t:{visible:!1,disabledReason:li}}canRenderSurveyAsync(e,t){var i,r;return t===void 0&&(t=!1),(i=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,t))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:li})}Ji(e){return!e||Lr(e)?(O.critical("Unique user id has not been set in posthog.identify"),!1):e===Ir?(O.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())||(O.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,t,i){if(!this.__loaded||!this.persistence)return O.uninitializedWarning("posthog.identify");if(lt(e)&&(e=e.toString(),O.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Ji(e)&&this.Gi("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Br)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(gi)&&(this.unregister(gi),this.register({distinct_id:e}));var n,o=(this.persistence.get_property(Qe)||bs)===bs;e!==r&&o?(this.persistence.set_property(Qe,Es),this.setPersonPropertiesForFlags(T({},i||{},t||{}),!1),this.capture(Fo,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this.Ei=Dd(e,t,i),(n=this.featureFlags)==null||n.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(yi))}}setPersonProperties(e,t){if((e||t)&&this.Gi("posthog.setPersonProperties")){var i=Dd(this.get_distinct_id(),e,t);this.Ei!==i?(this.setPersonPropertiesForFlags(T({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Ei=i):O.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var r=this.getGroups(),n=r[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:T({},r,{[e]:t})}),n||i){var o={$group_type:e,$group_key:t};i&&(o.$group_set=i),this.capture(kd,o)}i&&this.setGroupPropertiesForFlags({[e]:i}),n&&!i&&this.reloadFeatureFlags()}else O.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),(i=this.featureFlags)==null||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),this.Gi("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)==null||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,n,o,a,l;if(O.info("reset"),!this.__loaded)return O.uninitializedWarning("posthog.reset");var c=this.get_property(Br);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(i=this.sessionPersistence)==null||i.clear(),(r=this.surveys)==null||r.reset(),(n=this.Hi)==null||n.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.persistence)==null||a.set_property(Qe,bs),(l=this.sessionManager)==null||l.resetSessionId(),this.Ei=null,this.config.cookieless_mode===et)this.register_once({distinct_id:Ir,$device_id:null},"");else{var d=this.config.get_device_id(xt());this.register_once({distinct_id:d,$device_id:e?d:c},"")}this.register({$last_posthog_reset:new Date().toISOString()},1),this.reloadFeatureFlags()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&i){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!i)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}return r}alias(e,t){return e===this.get_property(xh)?(O.critical("Attempting to create alias for existing People user - aborting."),-2):this.Gi("posthog.alias")?(P(t)&&(t=this.get_distinct_id()),e!==t?(this.Xi(gi,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(O.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=T({},this.config);if(_e(e)){var i,r,n,o,a,l,c,d,h;fe(this.config,Md(e));var f=this.Fi();(i=this.persistence)==null||i.update_config(this.config,t,f),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new bi(T({},this.config,{persistence:"sessionStorage"}),f);var g=this.Ri(this.config.debug);bt(g)&&(this.config.debug=g),bt(this.config.debug)&&(this.config.debug?(Ue.DEBUG=!0,de.Yt()&&de.Xt("ph_debug",!0),O.info("set_config",{config:e,oldConfig:t,newConfig:T({},this.config)})):(Ue.DEBUG=!1,de.Yt()&&de.Jt("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(d=this.surveys)==null||d.loadIfEnabled(),this.Ki(),(h=this.externalIntegrations)==null||h.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){Ue.LIB_NAME=e,Ue.LIB_VERSION=t}startSessionRecording(e){var t,i,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)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),l.sampling&&((i=this.sessionRecording)==null||i.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,t){if(this.exceptions){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(T({},r,t))}}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return(t=(i=this.toolbar)==null?void 0:i.loadToolbar(e))!==null&&t!==void 0&&t}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Ts;return t!==Ts&&(t=Ts+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(Qe))===Es||((t=this.sessionPersistence)==null?void 0:t.get_property(Qe))===Es}Wi(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles===Ra&&!this._isIdentified()&&As(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[gi])&&((t=this.persistence)==null||(t=t.props)==null||!t[Hr]))}Vi(){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.Wi()||this.Gi("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Gi("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Gi(e){return this.config.person_profiles==="never"?(O.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Xi(Hr,!0),!0)}Fi(){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!==mt)}Ki(){var e,t,i,r,n=this.Fi();return((e=this.persistence)==null?void 0:e.gr)!==n&&((i=this.persistence)==null||i.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.gr)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==et){if(this.config.cookieless_mode===mt&&this.consent.isExplicitlyOptedOut()){var i,r,n,o,a;this.reset(!0),(i=this.sessionManager)==null||i.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new nn(this),this.pageViewManager=new Wr(this),this.persistence&&(this.sessionPropsManager=new rn(this,this.sessionManager,this.persistence));var l=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=s.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=this.Ii(this.sessionRecording,new l(this)))}var c,d;this.consent.optInOut(!0),this.Ki(),this.Zi(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode==mt&&((c=this.surveys)==null||c.loadIfEnabled()),(P(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((d=e?.captureEventName)!==null&&d!==void 0?d:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.$i()}else O.warn(Ld)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==et?(this.config.cookieless_mode===mt&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Ki(),this.config.cookieless_mode===mt&&(this.register({distinct_id:Ir,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(i=this.sessionRecording)==null||i.stopRecording(),this.sessionRecording=void 0,this.$i())):O.warn(Ld)}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===et||(this.config.cookieless_mode===mt?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Ki()}_is_bot(){return Be?eg(Be,this.config.custom_blocked_useragents):void 0}$i(){A&&(A.visibilityState==="visible"?this.xi||(this.xi=!0,this.capture(ws,{title:A.title},{send_instantly:!0}),this.Ti&&(A.removeEventListener(zr,this.Ti),this.Ti=null)):this.Ti||(this.Ti=this.$i.bind(this),pe(A,zr,this.Ti)))}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}))}Tr(){var e,t,i,r,n,o,a=this.Ni||{};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?(O.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):(i="advanced_disable_decide",r=O,n=(t="advanced_disable_flags")in(e=a)&&!H(e[t]),o=i in e&&!H(e[i]),n?e[t]:!!o&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}Ui(e){if(H(this.config.before_send))return e;var t=Y(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),H(i)){var n="Event '"+e.event+"' was rejected in beforeSend function";return rb(e.event)?O.warn(n+". This can cause unexpected behavior."):O.info(n),null}i.properties&&!As(i.properties)||O.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return(e=this.pageViewManager.lr)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Ri(e){var t=bt(e)&&!e,i=de.Yt()&&de.Wt("ph_debug")==="true";return!t&&(!!i||e)}};$s.__defaultExtensionClasses={},(function(s,e){for(var t=0;e.length>t;t++)s.prototype[e[t]]=Ob(s.prototype[e[t]])})($s,["identify"]);hl=["a","button","form","input","select","textarea","label"];rE=["next","previous","prev",">","<"],jd=[".ph-no-rageclick",".ph-no-capture"],Ya=s=>!s||Lt(s,"html")||!dn(s),Hd=(s,e)=>{if(!_||Ya(s))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[s],r=s;r.parentNode&&!Lt(r,"body");)if(og(r.parentNode))i.push(r.parentNode.host),r=r.parentNode.host;else{var n=lg(r);if(!n)break;if(e||hl.indexOf(n.tagName.toLowerCase())>-1)t=!0;else{var o=_.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}i.push(n),r=n}return{parentIsUsefulElement:t,targetElementList:i}};ug="(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})",nE=new RegExp("^(?:"+ug+")$"),oE=new RegExp(ug),dg="\\d{3}-?\\d{2}-?\\d{4}",aE=new RegExp("^("+dg+")$"),lE=new RegExp("("+dg+")");ln=class{constructor(e){this.disabled=e===!1;var t=_e(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},qo="$copy_autocapture",qd=he("[AutoCapture]");ci=he("[ExceptionAutocapture]");hE=he("[TracingHeaders]"),Ct=he("[Web Vitals]"),Yd=9e5,Xd="disabled",Jd="lazy_loading",ui="awaiting_config",xr="missing_config";he("[SessionRecording]");Ja="[SessionRecording]",Pt=he(Ja),gE=he("[Heatmaps]");Zd=he("[Product Tours]"),Yo="ph_product_tours",fE=["$set_once","$set"],Dt=he("[SiteApps]"),eh="Error while initializing PostHog app with config id ";Qa=class{constructor(e){this.Qi=new Ii,this.tn=(t,i)=>this.en(t,i)&&this.rn(t,i)&&this.nn(t,i)&&this.sn(t,i),this.en=(t,i)=>i==null||!i.event||t?.event===i?.event,this._instance=e,this.an=new Set,this.ln=new Set}init(){var e,t;P((e=this._instance)==null?void 0:e._addCaptureHook)||(t=this._instance)==null||t._addCaptureHook(((i,r)=>{this.on(i,r)}))}register(e){var t,i;if(!P((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.ln)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var d;(d=this.an)==null||d.add(c?.event||"")}))})),(i=this._instance)!=null&&i.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,t){var i;t!=null&&e.length!=0&&(this.an.has(e)||this.an.has(t?.event))&&this.ln&&((i=this.ln)==null?void 0:i.size)>0&&this.ln.forEach((r=>{this.un(t,r)&&this.Qi.emit("actionCaptured",r.name)}))}hn(e){this.onAction("actionCaptured",(t=>e(t)))}un(e,t){if(t?.steps==null)return!1;for(var i of t.steps)if(this.tn(e,i))return!0;return!1}onAction(e,t){return this.Qi.on(e,t)}rn(e,t){if(t!=null&&t.url){var i,r=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!r||typeof r!="string"||!Ss(r,t.url,t.url_matching||"contains"))return!1}return!0}nn(e,t){return!!this.cn(e,t)&&!!this.dn(e,t)&&!!this.vn(e,t)}cn(e,t){var i;if(t==null||!t.href)return!0;var r=this.fn(e);if(r.length>0)return r.some((a=>Ss(a.href,t.href,t.href_matching||"exact")));var n,o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!o&&Ss((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}dn(e,t){var i;if(t==null||!t.text)return!0;var r=this.fn(e);if(r.length>0)return r.some((c=>Ss(c.text,t.text,t.text_matching||"exact")||Ss(c.$el_text,t.text,t.text_matching||"exact")));var n,o,a,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(n=(function(c){for(var d,h=[],f=/(?::|")text="(.*?)"/g;!H(d=f.exec(c));)h.includes(d[1])||h.push(d[1]);return h})(l),o=t.text,a=t.text_matching||"exact",n.some((c=>Ss(c,o,a))))}vn(e,t){var i,r;if(t==null||!t.selector)return!0;var n=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}fn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}sn(e,t){return t==null||!t.properties||t.properties.length===0||sg(t.properties.reduce(((i,r)=>{var n=Y(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return i[r.key]={values:n,operator:r.operator||"exact"},i}),{}),e?.properties)}},Za=class{constructor(e){this._instance=e,this.pn=new Map,this.gn=new Map,this.mn=new Map}yn(e,t){return!!e&&sg(e.propertyFilters,t?.properties)}bn(e,t){var i=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=i.get(o.name)||[];a.push(r.id),i.set(o.name,a)}}))})),i}wn(e,t,i){var r=(i===ri.Activation?this.pn:this.gn).get(e),n=[];return this._n((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[i])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.yn(l,t)}))}register(e){var t;P((t=this._instance)==null?void 0:t._addCaptureHook)||(this.In(e),this.Cn(e))}Cn(e){var t=e.filter((i=>{var r,n;return((r=i.conditions)==null?void 0:r.actions)&&((n=i.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.Sn==null&&(this.Sn=new Qa(this._instance),this.Sn.init(),this.Sn.hn((i=>{this.onAction(i)}))),t.forEach((i=>{var r,n,o,a,l;i.conditions&&(r=i.conditions)!=null&&r.actions&&(n=i.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=i.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.Sn)==null||a.register(i.conditions.actions.values),(l=i.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var d=this.mn.get(c.name);d&&d.push(i.id),this.mn.set(c.name,d||[i.id])}})))})))}In(e){var t,i=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}));i.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.pn=this.bn(e,ri.Activation),this.gn=this.bn(e,ri.Cancellation))}onEvent(e,t){var i,r=this.re(),n=this.kn(),o=this.xn(),a=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[n])||[];if(o===e&&t&&a.length>0){var l,c;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var d=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(d){var h=a.indexOf(d);0>h||(a.splice(h,1),this.Tn(a))}}else{if(this.gn.has(e)){var f=this.wn(e,t,ri.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.An(p.id)})),this.Tn(a))}if(this.pn.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.pn.get(e)});var g=this.wn(e,t,ri.Activation);this.Tn(a.concat(g.map((p=>p.id))||[]))}}}onAction(e){var t,i=this.kn(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[i])||[];this.mn.has(e)&&this.Tn(r.concat(this.mn.get(e)||[]))}Tn(e){var t,i=this.re(),r=this.kn(),n=[...new Set(e)].filter((o=>!this.En(o)));i.info("updating activated items",{activatedItems:n}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:n})}getActivatedIds(){var e,t=this.kn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.pn}Rn(){return this.Sn}},el=class extends Za{constructor(e){super(e)}kn(){return"$surveys_activated"}xn(){return _i.SHOWN}_n(e){var t;(t=this._instance)==null||t.getSurveys(e)}An(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}re(){return ie}En(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Xo="SDK is not enabled or survey functionality is not yet loaded",th="Disabled. Not loading surveys.",pE=_!=null&&_.location?Jr(_.location.hash,"__posthog")||Jr(location.hash,"state"):null,sh="_postHogToolbarParams",ih=he("[Toolbar]"),Ie=he("[FeatureFlags]"),Xt=he("[FeatureFlags]",{debugEnabled:!0}),Jo=`" failed. Feature flags didn't load in time.`,Qo="$active_feature_flags",Nt="$override_feature_flags",rh="$feature_flag_payloads",di="$override_feature_flag_payloads",nh="$feature_flag_request_id",oh=s=>{for(var e={},t=0;s.length>t;t++)e[s[t]]=!0;return e},ah=s=>{var e={};for(var[t,i]of $r(s||{}))i&&(e[t]=i);return e},Zo=he("[Error tracking]"),lh="Refusing to render web experiment since the viewer is a likely bot",vE={icontains:(s,e)=>!!_&&e.href.toLowerCase().indexOf(s.toLowerCase())>-1,not_icontains:(s,e)=>!!_&&e.href.toLowerCase().indexOf(s.toLowerCase())===-1,regex:(s,e)=>!!_&&on(e.href,s),not_regex:(s,e)=>!!_&&!on(e.href,s),exact:(s,e)=>e.href===s,is_not:(s,e)=>e.href!==s},tl=class s{get Rt(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments((r=>{s.Nn("retrieved web experiments from the server"),t.Mn=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;t.Mn&&(s.Nn("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=t.Mn)==null||o.set(n.feature_flag_key,n));var a=t._instance.getFeatureFlag(n.feature_flag_key);ve(a)&&n.variants[a]&&t.Fn(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var c=n.variants[l];s.On(c)&&t.Fn(n.name,l,c.transforms)}}))}),i)},this._instance=e,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())s.Nn(lh);else if(!this.Rt.disable_web_experiments){if(H(this.Mn))return this.Mn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();s.Nn("applying feature flags",e),e.forEach((t=>{var i;if(this.Mn&&(i=this.Mn)!=null&&i.has(t)){var r,n=this._instance.getFeatureFlag(t),o=(r=this.Mn)==null?void 0:r.get(t);n&&o!=null&&o.variants[n]&&this.Fn(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=s.getWindowLocation();if(e!=null&&e.search){var t=Xr(e?.search,"__experiment_id"),i=Xr(e?.search,"__experiment_variant");t&&i&&(s.Nn("previewing web experiments "+t+" && "+i),this.getWebExperiments((r=>{this.Pn(parseInt(t),i,r)}),!1,!0))}}loadIfEnabled(){this.Rt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.Rt.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Rt.token),method:"GET",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}Pn(e,t,i){var r=i.filter((n=>n.id===e));r&&r.length>0&&(s.Nn("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Fn(r[0].name,t,r[0].variants[t].transforms))}static On(e){return!H(e.conditions)&&s.Ln(e)&&s.Dn(e)}static Ln(e){var t;if(H(e.conditions)||H((t=e.conditions)==null?void 0:t.url))return!0;var i,r,n,o=s.getWindowLocation();return!!o&&((i=e.conditions)==null||!i.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 Dn(e){var t;if(H(e.conditions)||H((t=e.conditions)==null?void 0:t.utm))return!0;var i=Gh();if(i.utm_source){var r,n,o,a,l,c,d,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)==i.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)==i.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==i.utm_medium,v=(d=e.conditions)==null||(d=d.utm)==null||!d.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return f&&p&&v&&g}return!1}static Nn(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];O.info("[WebExperiments] "+e,i)}Fn(e,t,i){this._is_bot()?s.Nn(lh):t!=="control"?i.forEach((r=>{if(r.selector){var n;s.Nn("applying transform of variant "+t+" 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)}))}})):s.Nn("Control variants leave the page unmodified.")}_is_bot(){return Be&&this._instance?eg(Be,this.Rt.custom_blocked_useragents):void 0}},ze=he("[Conversations]"),Jt="Conversations not available yet.",hn={featureFlags:class{constructor(s){this.Bn=!1,this.jn=!1,this.qn=!1,this.Zn=!1,this.$n=!1,this.Hn=!1,this.Vn=!1,this.zn=!1,this._instance=s,this.featureFlagEventHandlers=[]}get Rt(){return this._instance.config}get Kr(){return this._instance.persistence}Yn(s){return this._instance.get_property(s)}Un(){var s,e;return(s=(e=this.Kr)==null?void 0:e.mr(this.Rt.feature_flag_cache_ttl_ms))!==null&&s!==void 0&&s}Wn(){return!!this.Un()&&(this.zn||this.qn||(this.zn=!0,Ie.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Gn(){var s,e=(s=this.Rt.evaluation_contexts)!==null&&s!==void 0?s:this.Rt.evaluation_environments;return!this.Rt.evaluation_environments||this.Rt.evaluation_contexts||this.Vn||(Ie.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Vn=!0),e!=null&&e.length?e.filter((t=>{var i=t&&typeof t=="string"&&t.trim().length>0;return i||Ie.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}Xn(){return this.Gn().length>0}initialize(){var s,e,{config:t}=this._instance,i=(s=(e=t.bootstrap)==null?void 0:e.featureFlags)!==null&&s!==void 0?s:{};if(Object.keys(i).length){var r,n,o=(r=(n=t.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(i).filter((c=>!!i[c])).reduce(((c,d)=>(c[d]=i[d]||!1,c)),{}),l=Object.keys(o).filter((c=>a[c])).reduce(((c,d)=>(o[d]&&(c[d]=o[d]),c)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(s,e,t){var i=t!=null&&t.merge?this.getFlagVariants():{},r=t!=null&&t.merge?this.getFlagPayloads():{},n=T({},i,s),o=T({},r,e),a={};for(var[l,c]of Object.entries(n)){var d=typeof c=="string";a[l]={key:l,enabled:!!d||!!c,variant:d?c: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.jn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var s=this.Yn(ya),e=this.Yn(Nt),t=this.Yn(di);if(!t&&!e)return s||{};var i=fe({},s||{}),r=[...new Set([...Object.keys(t||{}),...Object.keys(e||{})])];for(var n of r){var o,a,l=i[n],c=e?.[n],d=P(c)?(o=l?.enabled)!==null&&o!==void 0&&o:!!c,h=P(c)?l.variant:typeof c=="string"?c:void 0,f=t?.[n],g=T({},l,{enabled:d,variant:d?h??l?.variant:void 0});d!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),f&&(g.metadata=T({},l?.metadata,{payload:f,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),i[n]=g}return this.Bn||(Ie.warn(" Overriding feature flag details!",{flagDetails:s,overriddenPayloads:t,finalDetails:i}),this.Bn=!0),i}getFlagVariants(){var s=this.Yn(Rs),e=this.Yn(Nt);if(!e)return s||{};for(var t=fe({},s),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.Bn||(Ie.warn(" Overriding feature flags!",{enabledFlags:s,overriddenFlags:e,finalFlags:t}),this.Bn=!0),t}getFlagPayloads(){var s=this.Yn(rh),e=this.Yn(di);if(!e)return s||{};for(var t=fe({},s||{}),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.Bn||(Ie.warn(" Overriding feature flag payloads!",{flagPayloads:s,overriddenPayloads:e,finalPayloads:t}),this.Bn=!0),t}reloadFeatureFlags(){this.Zn||this.Rt.advanced_disable_feature_flags||this.Jn||(this._instance.ki.emit("featureFlagsReloading",!0),this.Jn=setTimeout((()=>{this.Kn()}),5))}Qn(){clearTimeout(this.Jn),this.Jn=void 0}ensureFlagsLoaded(){this.jn||this.qn||this.Jn||this.reloadFeatureFlags()}setAnonymousDistinctId(s){this.$anon_distinct_id=s}setReloadingPaused(s){this.Zn=s}Kn(s){var e;if(this.Qn(),!this._instance.Tr())if(this.qn)this.$n=!0;else{var t=this.Rt.token,i=this.Yn(Br),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:T({},((e=this.Kr)==null?void 0:e.get_initial_props())||{},this.Yn(vi)||{}),group_properties:this.Yn(Qt),timezone:Wh()};$t(i)||P(i)||(r.$device_id=i),(s!=null&&s.disableFlags||this.Rt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Xn()&&(r.evaluation_contexts=this.Gn());var n=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Rt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.qn=!0,this._instance._send_request({method:"POST",url:n,data:r,compression:this.Rt.disable_compression?void 0:nt.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback:o=>{var a,l,c,d=!0;if(o.statusCode===200&&(this.$n||(this.$anon_distinct_id=void 0),d=!1),this.qn=!1,!r.disable_flags||this.$n){this.Hn=!d;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"),(c=this.Kr)==null||c.register({[Sa]:h}),g?Ie.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:{},d),this.$n&&(this.$n=!1,this.Kn()))}}})}}getFeatureFlag(s,e){var t;if(e===void 0&&(e={}),!e.fresh||this.Hn)if(this.jn||this.getFlags()&&this.getFlags().length>0){if(!this.Wn()){var i=this.getFeatureFlagResult(s,e);return(t=i?.variant)!==null&&t!==void 0?t:i?.enabled}}else Ie.warn('getFeatureFlag for key "'+s+Jo)}getFeatureFlagDetails(s){return this.getFlagsWithDetails()[s]}getFeatureFlagPayload(s){var e=this.getFeatureFlagResult(s,{send_event:!1});return e?.payload}getFeatureFlagResult(s,e){if(e===void 0&&(e={}),!e.fresh||this.Hn)if(this.jn||this.getFlags()&&this.getFlags().length>0){if(!this.Wn()){var t=this.getFlagVariants(),i=s in t,r=t[s],n=this.getFlagPayloads()[s],o=String(r),a=this.Yn(nh)||void 0,l=this.Yn(Gr)||void 0,c=this.Yn(yi)||{};if(this.Rt.advanced_feature_flags_dedup_per_session){var d,h=this._instance.get_session_id(),f=this.Yn(Ea);h&&h!==f&&(c={},(d=this.Kr)==null||d.register({[yi]:c,[Ea]:h}))}if((e.send_event||!("send_event"in e))&&(!(s in c)||!c[s].includes(o))){var g,p,v,m,b,E,D,R,I,C;Y(c[s])?c[s].push(o):c[s]=[o],(g=this.Kr)==null||g.register({[yi]:c});var w=this.getFeatureFlagDetails(s),S=[...(p=this.Yn(Sa))!==null&&p!==void 0?p:[]];P(r)&&S.push("flag_missing");var $={$feature_flag:s,$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.Rt.bootstrap)==null||(v=v.featureFlags)==null?void 0:v[s])||null,$feature_flag_bootstrapped_payload:((m=this.Rt.bootstrap)==null||(m=m.featureFlagPayloads)==null?void 0:m[s])||null,$used_bootstrap_value:!this.Hn};P(w==null||(b=w.metadata)==null?void 0:b.version)||($.$feature_flag_version=w.metadata.version);var G,z=(E=w==null||(D=w.reason)==null?void 0:D.description)!==null&&E!==void 0?E:w==null||(R=w.reason)==null?void 0:R.code;z&&($.$feature_flag_reason=z),w!=null&&(I=w.metadata)!=null&&I.id&&($.$feature_flag_id=w.metadata.id),P(w?.original_variant)&&P(w?.original_enabled)||($.$feature_flag_original_response=P(w.original_variant)?w.original_enabled:w.original_variant),w!=null&&(C=w.metadata)!=null&&C.original_payload&&($.$feature_flag_original_payload=w==null||(G=w.metadata)==null?void 0:G.original_payload),S.length&&($.$feature_flag_error=S.join(",")),this._instance.capture("$feature_flag_called",$)}if(i){var V=n;if(!P(n))try{V=JSON.parse(n)}catch{}return{key:s,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:V}}}}else Ie.warn('getFeatureFlagResult for key "'+s+Jo)}getRemoteConfigPayload(s,e){var t=this.Rt.token,i={distinct_id:this._instance.get_distinct_id(),token:t};this.Xn()&&(i.evaluation_contexts=this.Gn()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:i,compression:this.Rt.disable_compression?void 0:nt.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback(r){var n,o=(n=r.json)==null?void 0:n.featureFlagPayloads;e(o?.[s]||void 0)}})}isFeatureEnabled(s,e){if(e===void 0&&(e={}),!e.fresh||this.Hn){if(this.jn||this.getFlags()&&this.getFlags().length>0){var t=this.getFeatureFlag(s,e);return P(t)?void 0:!!t}Ie.warn('isFeatureEnabled for key "'+s+Jo)}}addFeatureFlagsHandler(s){this.featureFlagEventHandlers.push(s)}removeFeatureFlagsHandler(s){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==s))}receivedFeatureFlags(s,e){if(this.Kr){this.jn=!0;var t=this.getFlagVariants(),i=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(n,o,a,l,c){a===void 0&&(a={}),l===void 0&&(l={}),c===void 0&&(c={});var d=(C=>{var w=C.flags;return w?(C.featureFlags=Object.fromEntries(Object.keys(w).map((S=>{var $;return[S,($=w[S].variant)!==null&&$!==void 0?$:w[S].enabled]}))),C.featureFlagPayloads=Object.fromEntries(Object.keys(w).filter((S=>w[S].enabled)).filter((S=>{var $;return($=w[S].metadata)==null?void 0:$.payload})).map((S=>{var $;return[S,($=w[S].metadata)==null?void 0:$.payload]})))):Ie.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),C})(n),h=d.flags,f=d.featureFlags,g=d.featureFlagPayloads;if(f){var p=n.requestId,v=n.evaluatedAt;if(Y(f)){Ie.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(f)for(var b=0;f.length>b;b++)m[f[b]]=!0;o&&o.register({[Qo]:f,[Rs]:m})}else{var E=f,D=g,R=h;if(n.errorsWhileComputingFlags)if(h){var I=new Set(Object.keys(h).filter((C=>{var w;return!((w=h[C])!=null&&w.failed)})));E=T({},a,Object.fromEntries(Object.entries(E).filter((C=>{var[w]=C;return I.has(w)})))),D=T({},l,Object.fromEntries(Object.entries(D||{}).filter((C=>{var[w]=C;return I.has(w)})))),R=T({},c,Object.fromEntries(Object.entries(R||{}).filter((C=>{var[w]=C;return I.has(w)}))))}else E=T({},a,E),D=T({},l,D),R=T({},c,R);o&&o.register(T({[Qo]:Object.keys(ah(E)),[Rs]:E||{},[rh]:D||{},[ya]:R||{}},p?{[nh]:p}:{},v?{[Gr]:v}:{}))}}})(s,this.Kr,t,i,r),e||(this.zn=!1),this.ts(e)}}override(s,e){e===void 0&&(e=!1),Ie.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:s,suppressWarning:e})}overrideFeatureFlags(s){if(!this._instance.__loaded||!this.Kr)return Ie.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(s===!1)return this.Kr.unregister(Nt),this.Kr.unregister(di),this.ts(),Xt.info("All overrides cleared");if(Y(s)){var e=oh(s);return this.Kr.register({[Nt]:e}),this.ts(),Xt.info("Flag overrides set",{flags:s})}if(s&&typeof s=="object"&&("flags"in s||"payloads"in s)){var t,i=s;if(this.Bn=!!((t=i.suppressWarning)!==null&&t!==void 0&&t),"flags"in i){if(i.flags===!1)this.Kr.unregister(Nt),Xt.info("Flag overrides cleared");else if(i.flags){if(Y(i.flags)){var r=oh(i.flags);this.Kr.register({[Nt]:r})}else this.Kr.register({[Nt]:i.flags});Xt.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this.Kr.unregister(di),Xt.info("Payload overrides cleared")):i.payloads&&(this.Kr.register({[di]:i.payloads}),Xt.info("Payload overrides set",{payloads:i.payloads}))),void this.ts()}if(s&&typeof s=="object")return this.Kr.register({[Nt]:s}),this.ts(),Xt.info("Flag overrides set",{flags:s});Ie.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:s})}onFeatureFlags(s){if(this.addFeatureFlagsHandler(s),this.jn){var{flags:e,flagVariants:t}=this.es();s(e,t)}return()=>this.removeFeatureFlagsHandler(s)}updateEarlyAccessFeatureEnrollment(s,e,t){var i,r=(this.Yn(pi)||[]).find((l=>l.flagKey===s)),n={["$feature_enrollment/"+s]:e},o={$feature_flag:s,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),t&&(o.$feature_enrollment_stage=t),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=T({},this.getFlagVariants(),{[s]:e});(i=this.Kr)==null||i.register({[Qo]:Object.keys(ah(a)),[Rs]:a}),this.ts()}getEarlyAccessFeatures(s,e,t){e===void 0&&(e=!1);var i=this.Yn(pi),r=t?"&"+t.map((n=>"stage="+n)).join("&"):"";if(i&&!e)return s(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Rt.token+r),method:"GET",callback:n=>{var o,a;if(n.json){var l=n.json.earlyAccessFeatures;return(o=this.Kr)==null||o.unregister(pi),(a=this.Kr)==null||a.register({[pi]:l}),s(l)}}})}es(){var s=this.getFlags(),e=this.getFlagVariants();return{flags:s.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}ts(s){var{flags:e,flagVariants:t}=this.es();this.featureFlagEventHandlers.forEach((i=>i(e,t,{errorsLoading:s})))}setPersonPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=this.Yn(vi)||{};this._instance.register({[vi]:T({},t,s)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(vi)}setGroupPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=this.Yn(Qt)||{};Object.keys(t).length!==0&&Object.keys(t).forEach((i=>{t[i]=T({},t[i],s[i]),delete s[i]})),this._instance.register({[Qt]:T({},t,s)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(s){if(s){var e=this.Yn(Qt)||{};this._instance.register({[Qt]:T({},e,{[s]:{}})})}else this._instance.unregister(Qt)}reset(){this.jn=!1,this.qn=!1,this.Zn=!1,this.$n=!1,this.Hn=!1,this.$anon_distinct_id=void 0,this.Qn(),this.Bn=!1}}},_E={sessionRecording:class{get Rt(){return this._instance.config}get Kr(){return this._instance.persistence}get started(){var s;return!((s=this.rs)==null||!s.isStarted)}get status(){var s,e;return this.ns===ui||this.ns===xr?this.ns:(s=(e=this.rs)==null?void 0:e.status)!==null&&s!==void 0?s:this.ns}constructor(s){if(this._forceAllowLocalhostNetworkCapture=!1,this.ns=Xd,this.ss=void 0,this._instance=s,!this._instance.sessionManager)throw Pt.error("started without valid sessionManager"),new Error(Ja+" started without valid sessionManager. This is a bug.");if(this.Rt.cookieless_mode===et)throw new Error(Ja+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get os(){var s,e=!((s=this._instance.get_property(Rr))==null||!s.enabled),t=!this.Rt.disable_session_recording,i=this.Rt.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&t&&!i}startIfEnabledOrStop(s){var e;if(!this.os||(e=this.rs)==null||!e.isStarted){var t=!P(Object.assign)&&!P(Array.from);this.os&&t?(this.ls(s),Pt.info("starting")):(this.ns=Xd,this.stopRecording())}}ls(s){var e,t,i;this.os&&(this.ns!==ui&&this.ns!==xr&&(this.ns=Jd),L!=null&&(e=L.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=L.__PosthogExtensions__)!=null&&t.initSessionRecording?this.us(s):(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.hs,(r=>{if(r)return Pt.error("could not load recorder",r);this.us(s)})))}stopRecording(){var s,e;(s=this.ss)==null||s.call(this),this.ss=void 0,(e=this.rs)==null||e.stop()}cs(){var s,e;(s=this.ss)==null||s.call(this),this.ss=void 0,(e=this.rs)==null||e.discard()}ds(){var s;(s=this.Kr)==null||s.unregister($h)}vs(s,e){if(H(s))return null;var t,i=lt(s)?s:parseFloat(s);return typeof(t=i)!="number"||!Number.isFinite(t)||0>t||t>1?(Pt.warn(e+" must be between 0 and 1. Ignoring invalid value:",s),null):i}fs(s){if(this.Kr){var e,t,i=this.Kr,r=()=>{var n,o=s.sessionRecording===!1?void 0:s.sessionRecording,a=this.vs((n=this.Rt.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.vs(o?.sampleRate,"remote config sampleRate"),c=a??l;H(c)&&this.ds();var d=o?.minimumDurationMilliseconds;i.register({[Rr]:T({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:T({capturePerformance:s.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:P(d)?null:d,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};r(),(e=this.ss)==null||e.call(this),this.ss=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(r)}}onRemoteConfig(s){return"sessionRecording"in s?s.sessionRecording===!1?(this.fs(s),void this.cs()):(this.fs(s),void this.startIfEnabledOrStop()):(this.ns===ui&&(this.ns=xr,Pt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(s,e){var t;e===void 0&&(e="log"),(t=this.rs)!=null&&t.log?this.rs.log(s,e):Pt.warn("log called before recorder was ready")}get hs(){var s,e,t=(s=this._instance)==null||(s=s.persistence)==null?void 0:s.get_property(Rr);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}ps(){var s,e=this._instance.get_property(Rr);if(!e)return!1;var t=(s=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&s!==void 0?s:Date.now();return 36e5>=Date.now()-t}us(s){var e,t;if((e=L.__PosthogExtensions__)==null||!e.initSessionRecording)return Pt.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.rs||(this.rs=(t=L.__PosthogExtensions__)==null?void 0:t.initSessionRecording(this._instance),this.rs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ps())return this.ns===xr||this.ns===ui?void 0:(this.ns=ui,Pt.info("persisted remote config is stale, requesting fresh config before starting"),void new Zr(this._instance).load());this.ns=Jd,this.rs.start(s)}onRRwebEmit(s){var e;(e=this.rs)==null||e.onRRwebEmit==null||e.onRRwebEmit(s)}overrideLinkedFlag(){var s,e;this.rs||(e=this.Kr)==null||e.register({$replay_override_linked_flag:!0}),(s=this.rs)==null||s.overrideLinkedFlag()}overrideSampling(){var s,e;this.rs||(e=this.Kr)==null||e.register({$replay_override_sampling:!0}),(s=this.rs)==null||s.overrideSampling()}overrideTrigger(s){var e,t;this.rs||(t=this.Kr)==null||t.register({[s==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.rs)==null||e.overrideTrigger(s)}get sdkDebugProperties(){var s;return((s=this.rs)==null?void 0:s.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(s,e){var t;return!((t=this.rs)==null||!t.tryAddCustomEvent(s,e))}}},mE={autocapture:class{constructor(s){this.gs=!1,this.ys=null,this.bs=!1,this.instance=s,this.rageclicks=new ln(s.config.rageclick),this.ws=null}initialize(){this.startIfEnabled()}get Rt(){var s,e,t=_e(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(s=t.url_allowlist)==null?void 0:s.map((i=>new RegExp(i))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((i=>new RegExp(i))),t}_s(){if(this.isBrowserSupported()){if(_&&A){var s=t=>{t=t||_?.event;try{this.Is(t)}catch(i){qd.error("Failed to capture event",i)}};if(pe(A,"submit",s,{capture:!0}),pe(A,"change",s,{capture:!0}),pe(A,"click",s,{capture:!0}),this.Rt.capture_copied_text){var e=t=>{this.Is(t=t||_?.event,qo)};pe(A,"copy",e,{capture:!0}),pe(A,"cut",e,{capture:!0})}}}else qd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.gs&&(this._s(),this.gs=!0)}onRemoteConfig(s){s.elementsChainAsString&&(this.bs=s.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[_d]:!!s.autocapture_opt_out}),this.ys=!!s.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(s){this.ws=s}getElementSelectors(s){var e,t=[];return(e=this.ws)==null||e.forEach((i=>{var r=A?.querySelectorAll(i);r?.forEach((n=>{s===n&&t.push(i)}))})),t}get isEnabled(){var s,e,t=(s=this.instance.persistence)==null?void 0:s.props[_d];if($t(this.ys)&&!bt(t)&&!this.instance.Tr())return!1;var i=(e=this.ys)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!i}Is(s,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,i=Vd(s);ng(i)&&(i=i.parentNode||null),e==="$autocapture"&&s.type==="click"&&s instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,s.timeStamp||new Date().getTime())&&(function(h,f){if(!_||Ya(h))return!1;var g,p,v;if(bt(f)?(g=!!f&&jd,p=void 0):(g=(v=f?.css_selector_ignorelist)!==null&&v!==void 0?v:jd,p=f?.content_ignorelist),g===!1)return!1;var{targetElementList:m}=Hd(h,!1);return!(function(b,E){if(b===!1||P(b))return!1;var D;if(b===!0)D=rE;else{if(!Y(b))return!1;if(b.length>10)return O.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;D=b.map((R=>R.toLowerCase()))}return E.some((R=>{var{safeText:I,ariaLabel:C}=R;return D.some((w=>I.includes(w)||C.includes(w)))}))})(p,m.map((b=>{var E;return{safeText:Oi(b).toLowerCase(),ariaLabel:((E=b.getAttribute("aria-label"))==null?void 0:E.toLowerCase().trim())||""}})))&&!Gd(m,g)})(i,this.instance.config.rageclick)&&this.Is(s,"$rageclick");var r=e===qo;if(i&&(function(h,f,g,p,v){var m,b,E,D;if(g===void 0&&(g=void 0),!_||Ya(h)||(m=g)!=null&&m.url_allowlist&&!Bd(g.url_allowlist)||(b=g)!=null&&b.url_ignorelist&&Bd(g.url_ignorelist))return!1;if((E=g)!=null&&E.dom_event_allowlist){var R=g.dom_event_allowlist;if(R&&!R.some(($=>f.type===$)))return!1}var{parentIsUsefulElement:I,targetElementList:C}=Hd(h,p);if(!(function($,G){var z=G?.element_allowlist;if(P(z))return!0;var V,k=function(F){if(z.some((M=>F.tagName.toLowerCase()===M)))return{v:!0}};for(var N of $)if(V=k(N))return V.v;return!1})(C,g)||!Gd(C,(D=g)==null?void 0:D.css_selector_allowlist))return!1;var w=_.getComputedStyle(h);if(w&&w.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0;var S=h.tagName.toLowerCase();switch(S){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 I?(v||["click"]).indexOf(f.type)>=0:(v||["click"]).indexOf(f.type)>=0&&(hl.indexOf(S)>-1||h.getAttribute("contenteditable")==="true")}})(i,s,this.Rt,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=dE(i,{e:s,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Rt.element_attribute_ignorelist,elementsChainAsString:this.bs});if(o)return!1;var a=this.getElementSelectors(i);if(a&&a.length>0&&(n.$element_selectors=a),e===qo){var l,c=ag(_==null||(l=_.getSelection())==null?void 0:l.toString()),d=s.type||"clipboard";if(!c)return!1;n.$selected_content=c,n.$copy_type=d}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return yt(A?.querySelectorAll)}},historyAutocapture:class{constructor(s){var e;this._instance=s,this.Cs=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(O.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Ss&&this.Ss(),this.Ss=void 0,O.info("History API monitoring stopped")}monitorHistoryChanges(){var s,e;if(_&&_.history){var t=this;(s=_.history.pushState)!=null&&s.__posthog_wrapped__||Wd(_.history,"pushState",(i=>function(r,n,o){i.call(this,r,n,o),t.ks("pushState")})),(e=_.history.replaceState)!=null&&e.__posthog_wrapped__||Wd(_.history,"replaceState",(i=>function(r,n,o){i.call(this,r,n,o),t.ks("replaceState")})),this.xs()}}ks(s){try{var e,t=_==null||(e=_.location)==null?void 0:e.pathname;if(!t)return;t!==this.Cs&&this.isEnabled&&this._instance.capture(ws,{navigation_type:s}),this.Cs=t}catch(i){O.error("Error capturing "+s+" pageview",i)}}xs(){if(!this.Ss){var s=()=>{this.ks("popstate")};pe(_,"popstate",s),this.Ss=()=>{_&&_.removeEventListener("popstate",s)}}}},heatmaps:class{get Rt(){return this.instance.config}constructor(s){var e;this.Ts=!1,this.gs=!1,this.As=null,this.instance=s,this.Ts=!((e=this.instance.persistence)==null||!e.props[_a]),this.rageclicks=new ln(s.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var s=5e3;return _e(this.Rt.capture_heatmaps)&&this.Rt.capture_heatmaps.flush_interval_milliseconds&&(s=this.Rt.capture_heatmaps.flush_interval_milliseconds),s}get isEnabled(){return H(this.Rt.capture_heatmaps)?H(this.Rt.enable_heatmaps)?this.Ts:this.Rt.enable_heatmaps:this.Rt.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.gs)return;gE.info("starting..."),this.Es(),this.Tt()}else{var s;clearInterval((s=this.As)!==null&&s!==void 0?s:void 0),this.Rs(),this.getAndClearBuffer()}}onRemoteConfig(s){if("heatmaps"in s){var e=!!s.heatmaps;this.instance.persistence&&this.instance.persistence.register({[_a]:e}),this.Ts=e,this.startIfEnabled()}}getAndClearBuffer(){var s=this.T;return this.T=void 0,s}Ns(s){this.wt(s.originalEvent,"deadclick")}Tt(){this.As&&clearInterval(this.As),this.As=A?.visibilityState==="visible"?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Es(){_&&A&&(this.Ms=this.Zr.bind(this),pe(_,Kr,this.Ms),this.Fs=s=>this.wt(s||_?.event),pe(A,"click",this.Fs,{capture:!0}),this.Os=s=>this.Ps(s||_?.event),pe(A,"mousemove",this.Os,{capture:!0}),this.Ls=new qr(this.instance,$b,this.Ns.bind(this)),this.Ls.startIfEnabledOrStop(),this.Ds=this.Tt.bind(this),pe(A,zr,this.Ds),this.gs=!0)}Rs(){var s;_&&A&&(this.Ms&&_.removeEventListener(Kr,this.Ms),this.Fs&&A.removeEventListener("click",this.Fs,{capture:!0}),this.Os&&A.removeEventListener("mousemove",this.Os,{capture:!0}),this.Ds&&A.removeEventListener(zr,this.Ds),clearTimeout(this.Bs),(s=this.Ls)==null||s.stop(),this.gs=!1)}js(s,e){var t=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var c=o;c&&dn(c)&&!Lt(c,"body");){if(c===l)return!1;if(j(a,_?.getComputedStyle(c).position))return!0;c=lg(c)}return!1})(Vd(s),["fixed","sticky"],r);return{x:s.clientX+(n?0:i),y:s.clientY+(n?0:t),target_fixed:n,type:e}}wt(s,e){var t;if(e===void 0&&(e="click"),!Ud(s.target)&&Qd(s)){var i=this.js(s,e);(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,new Date().getTime())&&this.qs(T({},i,{type:"rageclick"})),this.qs(i)}}Ps(s){!Ud(s.target)&&Qd(s)&&(clearTimeout(this.Bs),this.Bs=setTimeout((()=>{this.qs(this.js(s,"mousemove"))}),500))}qs(s){if(_){var e=_.location.href,t=this.Rt.custom_personal_data_properties,i=this.Rt.mask_personal_data_properties?[...xs,...t||[]]:[],r=Ai(e,i,Ri);this.T=this.T||{},this.T[r]||(this.T[r]=[]),this.T[r].push(s)}}Zr(){this.T&&!As(this.T)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:qr,webVitalsAutocapture:class{constructor(s){var e;this.Ts=!1,this.gs=!1,this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Zs=()=>{clearTimeout(this.$s),this.T.metrics.length!==0&&(this._instance.capture("$web_vitals",this.T.metrics.reduce(((t,i)=>T({},t,{["$web_vitals_"+i.name+"_event"]:T({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.nt=t=>{var i,r=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(P(r))Ct.error("Could not read session ID. Dropping metrics!");else{this.T=this.T||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Hs();P(n)||(H(t?.name)||H(t?.value)?Ct.error("Invalid metric received",t):!this.Vs||this.Vs>t.value?(this.T.url!==n&&(this.Zs(),this.$s=setTimeout(this.Zs,this.flushToCaptureTimeoutMs)),P(this.T.url)&&(this.T.url=n),this.T.firstMetricTimestamp=P(this.T.firstMetricTimestamp)?Date.now():this.T.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0),this.T.metrics.push(T({},t,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.T.metrics.length===this.allowedMetrics.length&&this.Zs()):Ct.error("Ignoring metric with value >= "+this.Vs,t))}},this.zs=()=>{if(!this.gs){var t,i,r,n,o=L.__PosthogExtensions__;P(o)||P(o.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:i,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),t&&i&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.nt.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.nt.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.nt.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.nt.bind(this)),this.gs=!0):Ct.error("web vitals callbacks not loaded - not starting")}},this._instance=s,this.Ts=!((e=this._instance.persistence)==null||!e.props[bd]),this.startIfEnabled()}get Ys(){return this._instance.config.capture_performance}get allowedMetrics(){var s,e,t=_e(this.Ys)?(s=this.Ys)==null?void 0:s.web_vitals_allowed_metrics:void 0;return H(t)?((e=this._instance.persistence)==null?void 0:e.props[Sd])||["CLS","FCP","INP","LCP"]:t}get flushToCaptureTimeoutMs(){return(_e(this.Ys)?this.Ys.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var s=_e(this.Ys)?this.Ys.web_vitals_attribution:void 0;return s!=null&&s}get Vs(){var s=_e(this.Ys)&&lt(this.Ys.__web_vitals_max_value)?this.Ys.__web_vitals_max_value:Yd;return s>0&&6e4>=s?Yd:s}get isEnabled(){var s=ke?.protocol;if(s!=="http:"&&s!=="https:")return Ct.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=_e(this.Ys)?this.Ys.web_vitals:bt(this.Ys)?this.Ys:void 0;return bt(e)?e:this.Ts}startIfEnabled(){this.isEnabled&&!this.gs&&(Ct.info("enabled, starting..."),this.nr(this.zs))}onRemoteConfig(s){if("capturePerformance"in s){var e=_e(s.capturePerformance)&&!!s.capturePerformance.web_vitals,t=_e(s.capturePerformance)?s.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[bd]:e}),this._instance.persistence.register({[Sd]:t})),this.Ts=e,this.startIfEnabled()}}nr(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?s():(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(i=>{i?Ct.error("failed to load script",i):s()}))}Hs(){var s=_?_.location.href:void 0;if(s){var e=this._instance.config.custom_personal_data_properties,t=this._instance.config.mask_personal_data_properties?[...xs,...e||[]]:[];return Ai(s,t,Ri)}Ct.error("Could not determine current URL")}}},yE={exceptionObserver:class{constructor(s){var e,t,i;this.zs=()=>{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.Us&&this.Rt.capture_unhandled_errors&&(this.Us=n(this.captureException.bind(this))),!this.Ws&&this.Rt.capture_unhandled_rejections&&(this.Ws=o(this.captureException.bind(this))),!this.Gs&&this.Rt.capture_console_errors&&(this.Gs=a(this.captureException.bind(this)))}catch(l){ci.error("failed to start",l),this.Xs()}}},this._instance=s,this.Js=!((e=this._instance.persistence)==null||!e.props[md]),this.Ks=new ia({refillRate:(t=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&t!==void 0?t:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,qt:ci}),this.Rt=this.Qs(),this.startIfEnabledOrStop()}Qs(){var s=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return _e(s)?e=T({},e,s):(P(s)?this.Js:s)&&(e=T({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Rt.capture_console_errors||this.Rt.capture_unhandled_errors||this.Rt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ci.info("enabled"),this.Xs(),this.nr(this.zs)):this.Xs()}nr(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&s(),(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return ci.error("failed to load script",i);s()}))}Xs(){var s,e,t;(s=this.Us)==null||s.call(this),this.Us=void 0,(e=this.Ws)==null||e.call(this),this.Ws=void 0,(t=this.Gs)==null||t.call(this),this.Gs=void 0}onRemoteConfig(s){"autocaptureExceptions"in s&&(this.Js=!!s.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[md]:this.Js}),this.Rt=this.Qs(),this.startIfEnabledOrStop())}onConfigChange(){this.Rt=this.Qs()}captureException(s){var e,t,i,r=(e=s==null||(t=s.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.Ks.consumeRateLimit(r)?ci.info("Skipping exception capture because of client rate limiting.",{exception:r}):(i=this._instance.exceptions)==null||i.sendExceptionEvent(s)}},exceptions:class{constructor(s){var e,t;this.eo=[],this.ro=new aa([new ca,new va,new da,new ua,new fa,new ga,new ha,new pa],(function(i){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 c=[],d=a.split(`
6
+ `),h=l;d.length>h;h++){var f=d[h];if(1024>=f.length){var g=pd.test(f)?f.replace(pd,"$1"):f;if(!g.match(/\S*Error: /)){for(var p of n){var v=p(g,i);if(v){c.push(v);break}}if(c.length>=50)break}}}return(function(m){if(!m.length)return[];var b=Array.from(m);return b.reverse(),b.slice(0,50).map((E=>{return T({},E,{filename:E.filename||(D=b,D[D.length-1]||{}).filename,function:E.function||Ns});var D}))})(c)}})("web:javascript",Eb,wb)),this._instance=s,this.eo=(e=(t=this._instance.persistence)==null?void 0:t.get_property(ma))!==null&&e!==void 0?e:[]}onRemoteConfig(s){var e,t,i;if("errorTracking"in s){var r=(e=(t=s.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],n=(i=s.errorTracking)==null?void 0:i.captureExtensionExceptions;this.eo=r,this._instance.persistence&&this._instance.persistence.register({[ma]:this.eo,[yd]:n})}}get io(){var s,e=!!this._instance.get_property(yd),t=this._instance.config.error_tracking.captureExtensionExceptions;return(s=t??e)!==null&&s!==void 0&&s}buildProperties(s,e){return this.ro.buildFromUnknown(s,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}sendExceptionEvent(s){var e=s.$exception_list;if(this.no(e)){if(this.so(e))return void Zo.info("Skipping exception capture because a suppression rule matched");if(!this.io&&this.oo(e))return void Zo.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ao(e))return void Zo.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",zi:!0})}so(s){if(s.length===0)return!1;var e=s.reduce(((t,i)=>{var{type:r,value:n}=i;return ve(r)&&r.length>0&&t.$exception_types.push(r),ve(n)&&n.length>0&&t.$exception_values.push(n),t}),{$exception_types:[],$exception_values:[]});return this.eo.some((t=>{var i=t.values.map((r=>{var n,o=tg[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 t.type==="OR"?i.some(Boolean):i.every(Boolean)}))}oo(s){return s.flatMap((e=>{var t,i;return(t=(i=e.stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}ao(s){if(s.length>0){var e,t,i,r,n=(e=(t=s[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(i=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}no(s){return!H(s)&&Y(s)}}},bE=T({productTours:class{get Kr(){return this._instance.persistence}constructor(s){this.lo=null,this.uo=null,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){"productTours"in s&&(this.Kr&&this.Kr.register({[Ed]:!!s.productTours}),this.loadIfEnabled())}loadIfEnabled(){var s,e;this.lo||(s=this._instance).config.disable_product_tours||(e=s.persistence)==null||!e.get_property(Ed)||this.nr((()=>this.ho()))}nr(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.generateProductTours?s():(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(i=>{i?Zd.error("Could not load product tours script",i):s()}))}ho(){var s;!this.lo&&(s=L.__PosthogExtensions__)!=null&&s.generateProductTours&&(this.lo=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(s,e){if(e===void 0&&(e=!1),!Y(this.uo)||e){var t=this.Kr;if(t){var i=t.props[Yo];if(Y(i)&&!e)return this.uo=i,void s(i,{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 Zd.error(o),void s([],{isLoaded:!1,error:o})}var a=Y(r.json.product_tours)?r.json.product_tours:[];this.uo=a,t&&t.register({[Yo]:a}),s(a,{isLoaded:!0})}})}else s(this.uo,{isLoaded:!0})}getActiveProductTours(s){H(this.lo)?s([],{isLoaded:!1,error:"Product tours not loaded"}):this.lo.getActiveProductTours(s)}showProductTour(s){var e;(e=this.lo)==null||e.showTourById(s)}previewTour(s){this.lo?this.lo.previewTour(s):this.nr((()=>{var e;this.ho(),(e=this.lo)==null||e.previewTour(s)}))}dismissProductTour(){var s;(s=this.lo)==null||s.dismissTour("user_clicked_skip")}nextStep(){var s;(s=this.lo)==null||s.nextStep()}previousStep(){var s;(s=this.lo)==null||s.previousStep()}clearCache(){var s;this.uo=null,(s=this.Kr)==null||s.unregister(Yo)}resetTour(s){var e;(e=this.lo)==null||e.resetTour(s)}resetAllTours(){var s;(s=this.lo)==null||s.resetAllTours()}cancelPendingTour(s){var e;(e=this.lo)==null||e.cancelPendingTour(s)}}},hn),EE={siteApps:class{constructor(s){this._instance=s,this.co=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}do(s,e){if(e){var t=this.globalsForEvent(e);this.co.push(t),this.co.length>1e3&&(this.co=this.co.slice(10))}}get siteAppLoaders(){var s;return(s=L._POSTHOG_REMOTE_CONFIG)==null||(s=s[this._instance.config.token])==null?void 0:s.siteApps}initialize(){if(this.isEnabled){var s=this._instance._addCaptureHook(this.do.bind(this));this.vo=()=>{s(),this.co=[],this.vo=void 0}}}globalsForEvent(s){var e,t,i,r,n,o,a;if(!s)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var[h,f]of Object.entries(d))l[h]={id:c[h],type:h,properties:f};var{$set_once:g,$set:p}=s;return{event:T({},uh(s,fE),{properties:T({},s.properties,p?{$set:T({},(e=(t=s.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},p)}:{},g?{$set_once:T({},(i=(r=s.properties)==null?void 0:r.$set_once)!==null&&i!==void 0?i:{},g)}:{}),elements_chain:(n=(o=s.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=s.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(s){var e=this.apps[s.id],t=()=>{var o;!e.errored&&this.co.length&&(Dt.info("Processing "+this.co.length+" events for site app with id "+s.id),this.co.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.vo)==null||o.call(this))},i=!1,r=o=>{e.errored=!o,e.loaded=!0,Dt.info("Site app with id "+s.id+" "+(o?"loaded":"errored")),i&&t()};try{var{processEvent:n}=s.init({posthog:this._instance,callback(o){r(o)}});n&&(e.processEvent=n),i=!0}catch(o){Dt.error(eh+s.id,o),r(!1)}if(i&&e.loaded)try{t()}catch(o){Dt.error("Error while processing buffered events PostHog app with config id "+s.id,o),e.errored=!0}}fo(){var s=this.siteAppLoaders||[];for(var e of s)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of s)this.setupSiteApp(t)}po(s){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(s);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(i){Dt.error("Error while processing event "+s.event+" for site app "+t.id,i)}}}onRemoteConfig(s){var e,t,i,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.fo(),void this._instance.on("eventCaptured",(l=>this.po(l)))):void Dt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.vo)==null||t.call(this),(i=s.siteApps)!=null&&i.length)if(this.isEnabled){var n=function(l){var c;L["__$$ph_site_app_"+l]=r._instance,(c=L.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(r._instance,a,(d=>{if(d)return Dt.error(eh+l,d)}))};for(var{id:o,url:a}of s.siteApps)n(o)}else Dt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},SE={tracingHeaders:class{constructor(s){this.mo=void 0,this.yo=void 0,this.zs=()=>{var e,t;P(this.mo)&&((e=L.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),P(this.yo)&&((t=L.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=s}initialize(){this.startIfEnabledOrStop()}nr(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&s(),(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return hE.error("failed to load script",i);s()}))}startIfEnabledOrStop(){var s,e;this._instance.config.__add_tracing_headers?this.nr(this.zs):((s=this.mo)==null||s.call(this),(e=this.yo)==null||e.call(this),this.mo=void 0,this.yo=void 0)}}},kE=T({surveys:class{get Rt(){return this._instance.config}constructor(s){this.bo=void 0,this._surveyManager=null,this.wo=!1,this._o=[],this.Io=null,this._instance=s,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(!this.Rt.disable_surveys){var e=s.surveys;if(H(e))return ie.warn("Flags not loaded yet. Not loading surveys.");var t=Y(e);this.bo=t?e.length>0:e,ie.info("flags response received, isSurveysEnabled: "+this.bo),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var s=[],e=0;e<localStorage.length;e++){var t=localStorage.key(e);(t!=null&&t.startsWith(za)||t!=null&&t.startsWith("inProgressSurvey_"))&&s.push(t)}s.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.wo)ie.info("Already initializing surveys, skipping...");else if(this.Rt.disable_surveys)ie.info(th);else if(this.Rt.cookieless_mode&&this._instance.consent.isOptedOut())ie.info("Not loading surveys in cookieless mode without consent.");else{var s=L?.__PosthogExtensions__;if(s){if(!P(this.bo)||this.Rt.advanced_enable_surveys){var e=this.bo||this.Rt.advanced_enable_surveys;this.wo=!0;try{var t=s.generateSurveys;if(t)return void this.Co(t,e);var i=s.loadExternalDependency;if(!i)return void this.So(al);i(this._instance,"surveys",(r=>{r||!s.generateSurveys?this.So("Could not load surveys script",r):this.Co(s.generateSurveys,e)}))}catch(r){throw this.So("Error initializing surveys",r),r}finally{this.wo=!1}}}else ie.error("PostHog Extensions not found.")}}Co(s,e){this._surveyManager=s(this._instance,e),this._surveyEventReceiver=new el(this._instance),ie.info("Surveys loaded successfully"),this.ko({isLoaded:!0})}So(s,e){ie.error(s,e),this.ko({isLoaded:!1,error:s})}onSurveysLoaded(s){return this._o.push(s),this._surveyManager&&this.ko({isLoaded:!0}),()=>{this._o=this._o.filter((e=>e!==s))}}getSurveys(s,e){if(e===void 0&&(e=!1),this.Rt.disable_surveys)return ie.info(th),s([]);var t,i=this._instance.get_property(ba);if(i&&!e)return s(i,{isLoaded:!0});typeof Promise<"u"&&this.Io?this.Io.then((r=>{var{surveys:n,context:o}=r;return s(n,o)})):(typeof Promise<"u"&&(this.Io=new Promise((r=>{t=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Rt.token),method:"GET",timeout:this.Rt.surveys_request_timeout_ms,callback:r=>{var n;this.Io=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;ie.error(a);var l={isLoaded:!1,error:a};return s([],l),void(t==null||t({surveys:[],context:l}))}var c,d=r.json.surveys||[],h=d.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&&((c=this._surveyEventReceiver)==null||c.register(h)),(n=this._instance.persistence)==null||n.register({[ba]:d});var f={isLoaded:!0};s(d,f),t?.({surveys:d,context:f})}}))}ko(s){for(var e of this._o)try{if(!s.isLoaded)return e([],s);this.getSurveys(e)}catch(t){ie.error("Error in survey callback",t)}}getActiveMatchingSurveys(s,e){if(e===void 0&&(e=!1),!H(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(s,e);ie.warn("init was not called")}xo(s){var e=null;return this.getSurveys((t=>{var i;e=(i=t.find((r=>r.id===s)))!==null&&i!==void 0?i:null})),e}To(s){if(H(this._surveyManager))return{eligible:!1,reason:Xo};var e=typeof s=="string"?this.xo(s):s;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(s){if(H(this._surveyManager))return ie.warn("init was not called"),{visible:!1,disabledReason:Xo};var e=this.To(s);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(s,e){return H(this._surveyManager)?(ie.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Xo})):new Promise((t=>{this.getSurveys((i=>{var r,n=(r=i.find((a=>a.id===s)))!==null&&r!==void 0?r:null;if(n){var o=this.To(n);t({visible:o.eligible,disabledReason:o.reason})}else t({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(s,e,t){var i;if(H(this._surveyManager))ie.warn("init was not called");else{var r=typeof s=="string"?this.xo(s):s;if(r!=null&&r.id)if(Zb.includes(r.type)){var n=A?.querySelector(e);if(n)return(i=r.appearance)!=null&&i.surveyPopupDelaySeconds?(ie.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;ie.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,t),ie.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,t);ie.warn("Survey element not found")}else ie.warn("Surveys of type "+r.type+" cannot be rendered in the app");else ie.warn("Survey not found")}}displaySurvey(s,e){var t;if(H(this._surveyManager))ie.warn("init was not called");else{var i=this.xo(s);if(i){var r=i;if((t=i.appearance)!=null&&t.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=T({},i,{appearance:T({},i.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Na.Popover&&e.initialResponses&&ie.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(i);if(!n.visible)return void ie.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==Na.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else ie.warn("Survey not found")}}cancelPendingSurvey(s){H(this._surveyManager)?ie.warn("init was not called"):this._surveyManager.cancelSurvey(s)}handlePageUnload(){var s;(s=this._surveyManager)==null||s.handlePageUnload()}}},hn),wE={toolbar:class{constructor(s){this.instance=s}Ao(s){L.ph_toolbar_state=s}Eo(){var s;return(s=L.ph_toolbar_state)!==null&&s!==void 0?s:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(s,e,t){if(s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),Mh(this.instance.config)||!_||!A)return!1;s=s??_.location,t=t??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var i,r=pE||Jr(s.hash,"__posthog")||Jr(s.hash,"state"),n=r?wd((()=>JSON.parse(atob(decodeURIComponent(r)))))||wd((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((i=n).source="url",i&&Object.keys(i).length>0&&(n.desiredHash?s.hash=n.desiredHash:t?t.replaceState(t.state,"",s.pathname+s.search):s.hash="")):((i=JSON.parse(e.getItem(sh)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}Ro(s){var e=L.ph_load_toolbar||L.ph_load_editor;!H(e)&&yt(e)?e(s,this.instance):ih.warn("No toolbar load function found")}loadToolbar(s){var e=!(A==null||!A.getElementById(Fh));if(!_||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=T({token:this.instance.config.token},s,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(_.localStorage.setItem(sh,JSON.stringify(T({},i,{source:void 0}))),this.Eo()===2)this.Ro(i);else if(this.Eo()===0){var r;this.Ao(1),(r=L.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return ih.error("[Toolbar] Failed to load",n),void this.Ao(0);this.Ao(2),this.Ro(i)})),pe(_,"turbolinks:load",(()=>{this.Ao(0),this.loadToolbar(i)}))}return!0}No(s){return this.loadToolbar(s)}maybeLoadEditor(s,e,t){return s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(s,e,t)}}},TE=T({experiments:tl},hn),AE={conversations:class{constructor(s){this.Mo=void 0,this._conversationsManager=null,this.Fo=!1,this.Oo=null,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(!this._instance.config.disable_conversations){var e=s.conversations;H(e)||(bt(e)?this.Mo=e:(this.Mo=e.enabled,this.Oo=e),this.loadIfEnabled())}}reset(){var s;(s=this._conversationsManager)==null||s.reset(),this._conversationsManager=null,this.Mo=void 0,this.Oo=null}loadIfEnabled(){if(!(this._conversationsManager||this.Fo||this._instance.config.disable_conversations||Mh(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var s=L?.__PosthogExtensions__;if(s&&!P(this.Mo)&&this.Mo)if(this.Oo&&this.Oo.token){this.Fo=!0;try{var e=s.initConversations;if(e)return this.Po(e),void(this.Fo=!1);var t=s.loadExternalDependency;if(!t)return void this.Lo(al);t(this._instance,"conversations",(i=>{i||!s.initConversations?this.Lo("Could not load conversations script",i):this.Po(s.initConversations),this.Fo=!1}))}catch(i){this.Lo("Error initializing conversations",i),this.Fo=!1}}else ze.error("Conversations enabled but missing token in remote config.")}}Po(s){if(this.Oo)try{this._conversationsManager=s(this.Oo,this._instance),ze.info("Conversations loaded successfully")}catch(e){this.Lo("Error completing conversations initialization",e)}else ze.error("Cannot complete initialization: remote config is null")}Lo(s,e){ze.error(s,e),this._conversationsManager=null,this.Fo=!1}show(){this._conversationsManager?this._conversationsManager.show():ze.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Mo===!0&&!$t(this._conversationsManager)}isVisible(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&s!==void 0&&s}sendMessage(s,e,t){var i=this;return Ze((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(s,e,t):(ze.warn(Jt),null)}))()}getMessages(s,e){var t=this;return Ze((function*(){return t._conversationsManager?t._conversationsManager.getMessages(s,e):(ze.warn(Jt),null)}))()}markAsRead(s){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(s):(ze.warn(Jt),null)}))()}getTickets(s){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.getTickets(s):(ze.warn(Jt),null)}))()}requestRestoreLink(s){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(s):(ze.warn(Jt),null)}))()}restoreFromToken(s){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(s):(ze.warn(Jt),null)}))()}restoreFromUrlToken(){var s=this;return Ze((function*(){return s._conversationsManager?s._conversationsManager.restoreFromUrlToken():(ze.warn(Jt),null)}))()}getCurrentTicketId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&s!==void 0?s:null}getWidgetSessionId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&s!==void 0?s:null}}},RE={logs:class{constructor(s){var e;this.Do=!1,this.Bo=!1,this._instance=s,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Do=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(s){var e,t=(e=s.logs)==null?void 0:e.captureConsoleLogs;!H(t)&&t&&(this.Do=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Do&&!this.Bo){var s=he("[logs]"),e=L?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(i=>{var r;i||(r=e.logs)==null||!r.initializeLogs?s.error("Could not load logs script",i):(e.logs.initializeLogs(this._instance),this.Bo=!0)})):s.error(al)}else s.error("PostHog Extensions not found.")}}}},IE=T({},hn,_E,mE,yE,bE,EE,kE,SE,wE,TE,AE,RE);$s.__defaultExtensionClasses=T({},IE);St=(ch=Si[Ts]=new $s,(function(){function s(){s.done||(s.done=!0,rg=!1,ae(Si,(function(e){e._dom_loaded()})))}A!=null&&A.addEventListener?A.readyState==="complete"?s():pe(A,"DOMContentLoaded",s,{capture:!1}):_&&O.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),ch)});var fg={};pn(fg,{Posthog:()=>gl});var ts,gl,pg=Pe(()=>{"use strict";gg();qs();Ys();ts=class ts{constructor(e,t=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=Rt("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let t=`ph_${e}_posthog`,i=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==t);if(i.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;i.forEach(a=>{[o,r,""].forEach(c=>{let d=c?`; Domain=${c}`:"";document.cookie=`${a}=; path=/${d}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(c=>c.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:t,config:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.cleanupStalePosthogCookies(e);let r=t||tu();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:eu,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...i.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=su.some(c=>a.endsWith(`.${c}`)||a===c);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...i};St.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,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let i=typeof St._isIdentified=="function"?St._isIdentified():this.has_identified;e&&!i?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),St.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),St.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,language:i,country_of_residence:r})=>{if(!(!this.has_initialized||!e))try{let n=St.get_property("$stored_person_properties")??{},o={};n.client_id||(o.client_id=e),t&&n.is_internal===void 0&&(o.is_internal=nr(t)),i&&!n.language&&(o.language=i),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}),St.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,t)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:t}),St.capture(e,t)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.options=e,this.debug=t,this.init()}};ts.getPosthogInstance=(e,t=!1)=>(ts._instance||(ts._instance=new ts(e,t)),ts._instance);gl=ts});var CE={};pn(CE,{Analytics:()=>vg});ho();qs();Ys();var Zm=4320*60*60,zt=class zt{constructor(e,t,i=!1){this.analytics=new us;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=Rt("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let t=window.location.hostname,n=["webflow.io"].some(c=>t.endsWith(c))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let c=new Uint8Array(16);crypto.getRandomValues(c),c[6]=c[6]&15|64,c[8]=c[8]&63|128;let d=Array.from(c,h=>h.toString(16).padStart(2,"0")).join("");o=`${d.slice(0,8)}-${d.slice(8,12)}-${d.slice(12,16)}-${d.slice(16,20)}-${d.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=${Zm}; SameSite=Lax${l}`}catch(t){console.warn("RudderStack: Failed to set anonymous ID cookie",t)}};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:go});try{this.setCookieIfNotExists(),this.analytics.load(e,go,{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(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let i=this.getUserId();if(!i||i!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:t}),this.analytics.identify(e,t||{}),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,t="Deriv App",i,r)=>{if(!(!this.has_initialized||e===this.current_page))try{let n={...i&&{user_id:i},...r};this.log("pageView | tracking page view",{platform:t,current_page:e,properties:n}),this.analytics.page(t,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,t)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:t}),this.analytics.track(e,t)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=t,this.debug=i,this.init(e)}};zt.getRudderStackInstance=(e,t,i=!1)=>(zt._instance||(zt._instance=new zt(e,t,i)),zt._instance);var or=zt;var ar="cached_analytics_events",lr="cached_analytics_page_views",cu=(s,e)=>{try{let t=localStorage.getItem(ar),i=t?JSON.parse(t):[];i.push({name:s,properties:e,timestamp:Date.now()}),localStorage.setItem(ar,JSON.stringify(i))}catch(t){console.warn("Analytics: Failed to cache event",t)}},uu=(s,e)=>{try{let t=localStorage.getItem(lr),i=t?JSON.parse(t):[];i.push({name:s,properties:e,timestamp:Date.now()}),localStorage.setItem(lr,JSON.stringify(i))}catch(t){console.warn("Analytics: Failed to cache page view",t)}},du=()=>{try{let s=localStorage.getItem(ar);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached events",s)}return[]},hu=()=>{try{let s=localStorage.getItem(lr);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached pages",s)}return[]},gu=()=>{try{localStorage.removeItem(ar)}catch(s){console.warn("Analytics: Failed to clear cached events",s)}},fu=()=>{try{localStorage.removeItem(lr)}catch(s){console.warn("Analytics: Failed to clear cached page views",s)}};Ys();function OE(s){let e=s?.debug??!1,t=Rt("",()=>e),i,r,n,o={},a={},l=[],c=[],d=!1,h=()=>{if(!d&&r?.has_initialized){d=!0;try{let k=du();k.length>0&&(t(`processStorageCache | replaying ${k.length} cached event(s)`,k),k.forEach(F=>{let M=Ht(F.properties);r?.track(F.name,M)}),gu());let N=hu();N.length>0&&(t(`processStorageCache | replaying ${N.length} cached page view(s)`,N),N.forEach(F=>{r?.pageView(F.name,"Deriv App",R(),F.properties)}),fu())}catch(k){console.warn("Analytics: Failed to process storage cache",k)}}},f=()=>{t("onSdkLoaded | RudderStack SDK loaded"),h(),c.length>0&&t(`onSdkLoaded | flushing ${c.length} pending identify call(s)`),c.forEach(({userId:k,traits:N})=>{k&&r?.identifyEvent(k,N)}),c=[]},g=async({growthbookKey:k,growthbookDecryptionKey:N,rudderstackKey:F,growthbookOptions:M,posthogOptions:J,debug:K})=>{var Q,ee;K!==void 0&&(e=K),t("initialise | starting analytics initialization",{rudderstack:!!F,growthbook:!!k,posthog:!!J});try{let te=M?.attributes?.country||(k?await ou():void 0);if(F&&(t("initialise | initializing RudderStack"),r=or.getRudderStackInstance(F,f,e)),M?.attributes&&Object.keys(M.attributes).length>0){let U=M.attributes,Te=r?.getAnonymousId();o={...o,country:te,...U.user_language&&{user_language:U.user_language},...U.account_type&&{account_type:U.account_type},...U.app_id&&{app_id:U.app_id},...U.residence_country&&{residence_country:U.residence_country},...U.device_type&&{device_type:U.device_type},...U.url&&{url:U.url},...U.email_hash&&{email_hash:U.email_hash},...U.network_type&&{network_type:U.network_type},...U.network_rtt&&{network_rtt:U.network_rtt},...U.network_downlink&&{network_downlink:U.network_downlink},...U.account_currency&&{account_currency:U.account_currency},...U.account_mode&&{account_mode:U.account_mode},loggedIn:!!U.loggedIn,...U.user_id&&!Ws(U.user_id)&&{user_id:U.user_id},...Te&&{anonymous_id:Te}}}M??(M={}),M.attributes??(M.attributes={});let ye=r?.getAnonymousId();if((Q=M.attributes).id??(Q.id=ye),(ee=M.attributes).country??(ee.country=te),k){t("initialise | initializing GrowthBook");let{Growthbook:U}=await Promise.resolve().then(()=>(od(),nd));i=U.getGrowthBookInstance(k,N,M,e),t("initialise | GrowthBook initialized");let Te=setInterval(()=>{Object.keys(a).length>0?clearInterval(Te):a=m("tracking-buttons-config",{})},1e3)}if(J){t("initialise | initializing PostHog");let{Posthog:U}=await Promise.resolve().then(()=>(pg(),fg));n=U.getPosthogInstance(J,e),t("initialise | PostHog initialized")}t("initialise | analytics initialization complete")}catch(te){console.warn("Analytics: Failed to initialize",te)}},p=k=>{t("setAttributes | received attributes",k);let{user_id:N,...F}=k,M=N??R();if(i){let J={...F};N&&!Ws(N)&&(J.user_id=N),M&&(J.id=M,J.user_id=M),t("setAttributes | called GrowthBook setAttributes",J),i.setAttributes(J)}o={...o,...Object.fromEntries(Object.entries(F).filter(([,J])=>J!==void 0)),...N!==void 0&&!Ws(N)&&{user_id:N}},t("setAttributes | updated core_data",o)},v=k=>i?.getFeatureState(k)?.experimentResult?.name,m=(k,N)=>i?.getFeatureValue(k,N),b=async()=>await i?.getStatus(),E=k=>i?.isOn(k),D=k=>i?.setUrl(k),R=()=>{let k=r?.getUserId()||"";return k&&!Ws(k)?k:""},V={initialise:g,setAttributes:p,identifyEvent:(k,N)=>{let F=k||R();if(!F){t("identifyEvent | skipped \u2014 no user_id available");return}t("identifyEvent | called",{user_id:F,traits:N});let M=ee=>{if(!ee)return ee;let{email:te,...ye}=ee;return{...ye,...te&&{is_internal:nr(te)}}},J=N?.rudderstack!==void 0||N?.posthog!==void 0,K,Q;if(J){let{rudderstack:ee,posthog:te,...ye}=N;K=M({...ye,...ee}),Q=M({...ye,...te})}else K=M(N),Q=M(N);r&&(r.has_initialized?(t("identifyEvent | calling RudderStack identify",{user_id:F,traits:K}),r.identifyEvent(F,K)):c.some(ee=>ee.userId===F)||(t("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:F}),c.push({userId:F,traits:K}))),n?.has_initialized&&Q&&(t("identifyEvent | calling PostHog identify",{user_id:F,traits:Q}),n.identifyEvent(F,Q))},backfillPersonProperties:({user_id:k,email:N,language:F,country_of_residence:M})=>{t("backfillPersonProperties | called",{user_id:k}),n?.has_initialized?(t("backfillPersonProperties | backfilling person properties in PostHog",{user_id:k}),n.backfillPersonProperties({user_id:k,email:N,language:F,country_of_residence:M})):t("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:v,getFeatureValue:m,getGrowthbookStatus:b,isFeatureOn:E,setUrl:D,getId:R,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(k,N)=>{let F=R();t("trackEvent | called",{event:k,analytics_data:N,userId:F,core_data:o});let M={...o,...N,...F&&!o.user_id&&{user_id:F}};if(t("trackEvent | built payload",{event:k,final_payload:M}),!(!(k in a)||a[k])){t("trackEvent | skipped \u2014 event disabled by tracking_config",{event:k});return}let K=r?.has_initialized;if(!navigator.onLine||!K)K?(t("trackEvent | offline \u2014 caching event to memory",{event:k}),l.push({event:k,payload:M})):(t("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:k}),cu(k,M));else{l.length>0&&(t(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(ee=>{let te=Ht(ee.payload);r?.track(ee.event,te)}),l=[]);let Q=Ht(M);t("trackEvent | sending event to RudderStack",{event:k,payload:Q}),r?.track(k,Q)}if(n?.has_initialized){let Q=["page_name","user_language","form_name","version","email_hash"],ee=lu(M),te=Ht(Object.fromEntries(Object.entries(ee).filter(([ye])=>!Q.includes(ye))));t("trackEvent | sending event to PostHog",{event:k,payload:te}),n.capture(k,te)}},getInstances:()=>({ab:i,tracking:r,posthog:n}),pageView:(k,N="Deriv App",F)=>{let M=R();t("pageView | called",{current_page:k,platform:N,properties:F,userId:M}),r?.has_initialized?(t("pageView | sending page view to RudderStack",{current_page:k,platform:N}),r.pageView(k,N,M,F)):(t("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:k}),uu(k,{platform:N,...F}))},reset:()=>{t("reset | resetting all providers"),r?.has_initialized&&(t("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(t("reset | resetting PostHog"),n.reset())}};return typeof window<"u"&&(window.AnalyticsInstance=V),V}var vg=OE();return Rg(CE);})();
7
7
  /*! Bundled license information:
8
8
 
9
9
  js-cookie/dist/js.cookie.mjs: