@deriv-com/analytics 1.43.0 → 1.44.0

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,10 +1,10 @@
1
1
  /* @deriv-com/analytics - Browser IIFE Bundle (RudderStack + PostHog) - Built with tsup */
2
- "use strict";var DerivAnalytics=(()=>{var br=Object.defineProperty;var $p=Object.getOwnPropertyDescriptor;var Fp=Object.getOwnPropertyNames;var Mp=Object.prototype.hasOwnProperty;var Bp=(t,e,s)=>e in t?br(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var et=(t,e,s)=>()=>{if(s)throw s[0];try{return t&&(e=t(t=0)),e}catch(i){throw s=[i],i}};var ho=(t,e)=>{for(var s in e)br(t,s,{get:e[s],enumerable:!0})},Up=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Fp(e))!Mp.call(t,r)&&r!==s&&br(t,r,{get:()=>e[r],enumerable:!(i=$p(e,r))||i.enumerable});return t};var Vp=t=>Up(br({},"__esModule",{value:!0}),t);var we=(t,e,s)=>Bp(t,typeof e!="symbol"?e+"":e,s);function Pe(t){return t!=null&&typeof t=="object"&&t["@@functional/placeholder"]===!0}function Ft(t){return function e(s){return arguments.length===0||Pe(s)?e:t.apply(this,arguments)}}function Xt(t){return function e(s,i){switch(arguments.length){case 0:return e;case 1:return Pe(s)?e:Ft(function(r){return t(s,r)});default:return Pe(s)&&Pe(i)?e:Pe(s)?Ft(function(r){return t(r,i)}):Pe(i)?Ft(function(r){return t(s,r)}):t(s,i)}}}function Zo(t){return function e(s,i,r){switch(arguments.length){case 0:return e;case 1:return Pe(s)?e:Xt(function(n,o){return t(s,n,o)});case 2:return Pe(s)&&Pe(i)?e:Pe(s)?Xt(function(n,o){return t(n,i,o)}):Pe(i)?Xt(function(n,o){return t(s,n,o)}):Ft(function(n){return t(s,i,n)});default:return Pe(s)&&Pe(i)&&Pe(r)?e:Pe(s)&&Pe(i)?Xt(function(n,o){return t(n,o,r)}):Pe(s)&&Pe(r)?Xt(function(n,o){return t(n,i,o)}):Pe(i)&&Pe(r)?Xt(function(n,o){return t(s,n,o)}):Pe(s)?Ft(function(n){return t(n,i,r)}):Pe(i)?Ft(function(n){return t(s,n,r)}):Pe(r)?Ft(function(n){return t(s,i,n)}):t(s,i,r)}}}function Er(t,e){return Object.prototype.hasOwnProperty.call(e,t)}function Eu(t){return Object.prototype.toString.call(t)==="[object Object]"}function Hp(t,e){var s=t<0?e.length+t:t;return e[s]}function qp(t){return new RegExp(t.source,t.flags?t.flags:(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":"")+(t.dotAll?"s":""))}function ic(t,e,s){if(s||(s=new Kp),zp(t))return t;var i=function(n){var o=s.get(t);if(o)return o;s.set(t,n);for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(n[a]=ic(t[a],!0,s));return n};switch(jp(t)){case"Object":return i(Object.create(Object.getPrototypeOf(t)));case"Array":return i(Array(t.length));case"Date":return new Date(t.valueOf());case"RegExp":return qp(t);case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return t.slice();default:return t}}function zp(t){var e=typeof t;return t==null||e!="object"&&e!="function"}function Wp(t,e){for(var s=e,i=0;i<t.length;i+=1){if(s==null)return;var r=t[i];Gp(r)?s=Hp(r,s):s=s[r]}return s}function fv(t){return crypto.getRandomValues(new Uint8Array(t))}function gv(){(!po||Qt+16>wu)&&(po=fv(wu),Qt=0);for(var t=0,e,s="";t<16;t++)e=po[Qt+t],t==6?s+=Ar[e&15|64]:t==8?s+=Ar[e&63|128]:s+=Ar[e],t&1&&t>1&&t<11&&(s+="-");return Qt+=16,s}function pv(){var t=0,e,s="";if(!wr||_s+16>256){for(wr=Array(t=256);t--;)wr[t]=256*Math.random()|0;t=_s=0}for(;t<16;t++)e=wr[_s+t],t==6?s+=Ir[e&15|64]:t==8?s+=Ir[e&63|128]:s+=Ir[e],t&1&&t>1&&t<11&&(s+="-");return _s++,s}function Gv(t,e,s=jv){let i;return(...r)=>{globalThis.clearTimeout(i),i=globalThis.setTimeout(()=>{t.apply(e,r)},s)}}function Gr(){if(Mt>1)Mt--;else{var t,e=!1;for((function(){var r=Fr;for(Fr=void 0;r!==void 0;){var n=r.S;if(n.v===r.v)for(var o=n.t;o!==void 0;o=o.x)o.i===r.i&&(o.i=n.i);r=r.o}})();Ci!==void 0;){var s=Ci;for(Ci=void 0,$r++;s!==void 0;){var i=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&vc(s))try{s.c()}catch(r){e||(t=r,e=!0)}s=i}}if($r=0,Mt--,e)throw t}}function Ue(t){if(Mt>0)return t();Io=++t_,Mt++;try{return t()}finally{Gr()}}function Hr(t){var e=ke,s=Pi;ke=void 0,Pi=void 0;try{return t()}finally{ke=e,Pi=s}}function pc(t){if(ke!==void 0){var e=t.n;if(e===void 0||e.t!==ke)return e={i:0,S:t,p:ke.s,n:void 0,t:ke,e:void 0,x:void 0,r:e},ke.s!==void 0&&(ke.s.n=e),ke.s=e,t.n=e,32&ke.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=ke.s,e.n=void 0,ke.s.n=e,ke.s=e),e}}function We(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function R(t,e){return new We(t,e)}function vc(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function _c(t){for(var e=t.s;e!==void 0;e=e.n){var s=e.S.n;if(s!==void 0&&(e.r=s),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function mc(t){for(var e=t.s,s=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)):s=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=i}t.s=s}function Hs(t,e){We.call(this,void 0,e),this.x=t,this.s=void 0,this.g=Mr-1,this.f=4}function yc(t){var e=t.m;if(t.m=void 0,typeof e=="function"){Mt++;var s=ke;ke=void 0;try{e()}catch(i){throw t.f&=-2,t.f|=8,na(t),i}finally{ke=s,Gr()}}}function na(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,yc(t)}function s_(t){if(ke!==this)throw new Error("Out-of-order effect");mc(this),ke=t,this.f&=-2,8&this.f&&na(this),Gr()}function qs(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,Pi&&Pi.push(this)}function At(t,e){var s=new qs(t,e);try{s.c()}catch(r){throw s.d(),r}var i=s.d.bind(s);return i[Symbol.dispose]=i,i}function Oc(t){if(!t?.includes(":"))return[t||void 0,void 0,void 0];let e=t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1):t,s=xm.exec(e);return s?[s[1]||void 0,s[2]===void 0?void 0:Number(s[2]),s[3]===void 0?void 0:Number(s[3])]:[void 0,void 0,void 0]}function Dm(t){if(!Tc.test(t))return null;t.includes("(eval ")&&(t=t.replaceAll("eval code","eval").replaceAll(/(\(eval at [^()]*)|(,.*$)/g,""));let e=t.replace(/^\s+/,"").replaceAll("(eval code","(").replace(/^.*?\s+/,""),s=/ (\(.+\)$)/.exec(e),i=s?e.replace(s[0],""):e,[r,n,o]=Oc(s?s[1]:e);return{functionName:s&&i||void 0,fileName:r==="eval"||r==="<anonymous>"?void 0:r,lineNumber:n,columnNumber:o}}function Nm(t){if(Cm.test(t))return null;if(t.includes(" > eval")&&(t=t.replaceAll(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),!t.includes("@")&&!t.includes(":"))return{functionName:t,fileName:void 0,lineNumber:void 0,columnNumber:void 0};let e=t.lastIndexOf("@"),s=e>0?t.slice(0,e):void 0,[i,r,n]=Oc(t.slice(e+1));return{functionName:s,fileName:i,lineNumber:r,columnNumber:n}}function Lm(t){if(!t.stack)throw new Error("Cannot parse given Error object");let e=t.stack.split(`
3
- `);return e.some(s=>Tc.test(s))?e.map(Dm).filter(s=>s!==null):e.map(Nm).filter(s=>s!==null)}function Uu(t,e,s,i){return{errorClass:Bu(t),message:`${s}${Bu(e)}`,type:"browserjs",stacktrace:i.reduce((r,n)=>{let o=Fm(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function Mc(t,e){let s=Object.assign(t,e);for(let i of Object.keys(s))typeof s[i]=="object"&&typeof e[i]=="object"&&(s[i]=Mc(s[i],e[i]));return s}async function Ey(t){let e=yy[t];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((s,i)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=by();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}s(e.lib)}).catch(i)})})}function tt(t,e){if(!t?.default&&e){let s=Object.create(null);return s.default=t,s.__esModule=!0,s}return t}function st(t,e){return Ey(t).then(s=>s.get(e).then(i=>i()))}function Xy(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Zy(){return Ku||(Ku=1,(function(t,e){(function(s,i){t.exports=i()})(Qy,function(){function s(f){return f=JSON.stringify(f),!!/^\{[\s\S]*\}$/.test(f)}function i(f){return f===void 0||typeof f=="function"?f+"":JSON.stringify(f)}function r(f){if(typeof f=="string")try{return JSON.parse(f)}catch{return f}}function n(f){return{}.toString.call(f)==="[object Function]"}function o(f){return Object.prototype.toString.call(f)==="[object Array]"}function a(f){var p="_Is_Incognit",_="yes";try{f||(f=window.localStorage),f.setItem(p,_),f.removeItem(p)}catch{var v={};v._data={},v.setItem=function(y,w){return v._data[y]=String(w)},v.getItem=function(y){return v._data.hasOwnProperty(y)?v._data[y]:void 0},v.removeItem=function(y){return delete v._data[y]},v.clear=function(){return v._data={}},f=v}finally{f.getItem(p)===_&&f.removeItem(p)}return f}var l=a();function u(){if(!(this instanceof u))return new u}u.prototype={set:function(p,_){if(p&&!s(p))l.setItem(p,i(_));else if(s(p))for(var v in p)this.set(v,p[v]);return this},get:function(p){if(p===void 0){var _={};return this.forEach(function(T,C){return _[T]=C}),_}if(p.charAt(0)==="?")return this.has(p.substr(1));var v=arguments;if(v.length>1){for(var m={},y=0,w=v.length;y<w;y++){var E=r(l.getItem(v[y]));this.has(v[y])&&(m[v[y]]=E)}return m}return r(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var _=this.get(p);return l.removeItem(p),_},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(_){p.push(_)}),p},forEach:function(p){for(var _=0,v=l.length;_<v;_++){var m=l.key(_);p(m,this.get(m))}return this},search:function(p){for(var _=this.keys(),v={},m=0,y=_.length;m<y;m++)_[m].indexOf(p)>-1&&(v[_[m]]=this.get(_[m]));return v},len:function(){return l.length}};var c=null;function h(f,p){var _=arguments,v=null;if(c||(c=u()),_.length===0)return c.get();if(_.length===1){if(typeof f=="string")return c.get(f);if(s(f))return c.set(f)}if(_.length===2&&typeof f=="string"){if(!p)return c.remove(f);if(p&&typeof p=="string")return c.set(f,p);p&&n(p)&&(v=null,v=p(f,c.get(f)),h.set(f,v))}if(_.length===2&&o(f)&&n(p))for(var m=0,y=f.length;m<y;m++)v=p(f[m],c.get(f[m])),h.set(f[m],v);return h}for(var g in u.prototype)h[g]=u.prototype[g];return h})})(Pr)),Pr.exports}var jp,Gp,Kp,te,Jp,Yp,Xp,Qp,rc,$,ye,rt,Ve,mt,Zp,pe,Us,ev,ea,tv,So,sv,iv,rv,ve,nv,$e,Bt,Ii,xi,Nt,wt,ta,ov,Su,Dr,av,lv,Nr,sa,nc,oc,ac,fo,ia,wo,ht,ko,ki,gs,Ri,$s,uv,go,cv,dv,hv,Sr,wu,Ar,Qt,po,_s,Ir,wr,vv,Vr,_v,mv,yv,lc,bv,z,Ev,ku,Sv,wv,kv,Au,Av,Iv,Rv,Iu,Tv,uc,Ov,_t,Pv,cc,re,dc,jr,ra,me,Ru,Di,Cv,hc,xv,Tu,Dv,Nv,Oi,Lv,$v,Fv,Ou,Mv,Pu,Bv,Uv,Cu,Ao,xu,Vv,jv,fc,Ni,gc,Du,Hv,qv,zv,Kv,Wv,Jv,Yv,Xv,Qv,Zv,Lr,e_,Pi,ke,Ci,Mt,$r,t_,Io,Fr,Mr,Ro,kr,Nu,bc,i_,r_,n_,To,Ut,Lt,Ec,Oo,Lu,o_,a_,l_,u_,c_,d_,h_,f_,$u,g_,p_,v_,__,m_,y_,b_,Fu,E_,S_,Sc,w_,k_,A_,I_,R_,T_,O_,Mu,P_,C_,x_,D_,N_,L_,$_,Rr,F_,M_,B_,U_,V_,j_,G_,H_,q_,z_,K_,W_,J_,Y_,X_,Q_,Z_,em,tm,sm,im,wc,qr,kc,rm,Li,zr,oa,Ac,Ic,Rc,ps,nm,Po,Tr,om,am,lm,um,cm,dm,ce,vo,hm,fm,gm,pm,vm,_m,mm,ym,bm,Em,Sm,wm,km,Am,Im,Rm,Tm,Om,Pm,d,Tc,Cm,xm,Pc,$m,Fm,Bu,Cc,Mm,Vu,Or,Bm,Um,Vm,jm,Gm,Hm,qm,zm,ju,Gu,Co,xc,Km,Wm,Jm,Ym,Xm,Qm,Zm,Dc,ey,ty,sy,iy,ry,ny,oy,ay,ly,uy,Nc,Lc,cy,dy,hy,fy,xo,$c,Do,gy,py,vy,Hu,_y,Fc,my,yy,by,Sy,wy,Bc,ky,Ay,_o,Iy,No,it,ot,dt,kt,ms,Ry,Ty,Oy,Py,Cy,xy,Dy,Ny,Ly,$y,Fy,My,Fs,By,Uc,Vc,Uy,jc,Gc,Ms,qu,zu,Vy,jy,Lo,Gy,$t,Hy,qy,zy,Ky,Wy,Jy,Yy,$o,Br,Pr,Qy,Ku,eb,fs,Hc,Bs,Fo,aa,Mo,la,Bo,ua,vt,tb,sb,ib,rb,nb,Uo,ob,Vo,ab,lb,qc,ub,cb,db,Vs,jo,zc,hb,fb,gb,js,mo,yo,pb,vb,_b,Wu,mb,Kc,yb,bb,Eb,Sb,wb,kb,Ab,Ib,Rb,Wc,Tb,Ob,Go,Pb,Jc,Cb,xb,Db,Yc,Nb,Lb,Ho,$b,Fb,Mb,Bb,Ju,Ub,Yu,Vb,Xu,qo,jb,Gb,Hb,bo,Cr,qb,zb,Kb,ca,Xc,Qc,zo,Zc,Wb,Ur,Qu,ed,Zu,Jb,Yb,Xb,Qb,Zb,Ti,Ko,e0,t0,s0,Eo,i0,r0,n0,o0,a0,Ai,Wo,Jo,Yo,l0,u0,c0,ec,tc,d0,h0,f0,g0,xr,Xo,sc,p0,v0,Qo,vs,Gs,da=et(()=>{"use strict";jp=Ft(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Gp=Number.isInteger||function(e){return e<<0===e};Kp=(function(){function t(){this.map={},this.length=0}return t.prototype.set=function(e,s){var i=this.hash(e),r=this.map[i];r||(this.map[i]=r=[]),r.push([e,s]),this.length+=1},t.prototype.hash=function(e){var s=[];for(var i in e)s.push(Object.prototype.toString.call(e[i]));return s.join()},t.prototype.get=function(e){if(this.length<=180){for(var s in this.map)for(var o=this.map[s],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]}},t})(),te=Ft(function(e){return e!=null&&typeof e.clone=="function"?e.clone():ic(e)});Jp=Zo(function(e,s,i){var r={},n;s=s||{},i=i||{};for(n in s)Er(n,s)&&(r[n]=Er(n,i)?e(n,s[n],i[n]):s[n]);for(n in i)Er(n,i)&&!Er(n,r)&&(r[n]=i[n]);return r}),Yp=Zo(function t(e,s,i){return Jp(function(r,n,o){return Eu(n)&&Eu(o)?t(e,n,o):e(r,n,o)},s,i)}),Xp=Zo(function(e,s,i){return Yp(function(r,n,o){return e(n,o)},s,i)}),Qp=Xt(Wp),rc=Xt(function(e,s){var i={};for(var r in s)e(s[r],r,s)&&(i[r]=s[r]);return i}),$=t=>typeof t=="function"&&!!(t.constructor&&t.call&&t.apply),ye=t=>typeof t=="string",rt=t=>t===null,Ve=t=>typeof t>"u",mt=t=>rt(t)||Ve(t),Zp=t=>typeof t=="bigint",pe=t=>!Ve(t),Us=t=>!mt(t),ev=t=>Us(t)&&t!=="",ea=t=>{switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return t instanceof Error}},tv=t=>typeof t=="boolean",So=(t,e)=>{let s=e.split(".");return Qp(s,t)},sv=(t,e)=>!!So(t,e),iv=t=>typeof t=="object",rv=t=>!rt(t)&&iv(t)&&!Array.isArray(t),ve=t=>!rt(t)&&Object.prototype.toString.call(t)==="[object Object]",nv=(t,e)=>{if(!Array.isArray(t)||!Array.isArray(e))return te(e);let s=te(t);return e.forEach((i,r)=>{s[r]=Array.isArray(i)||rv(i)?$e(s[r],i):i}),s},$e=(t,e)=>Xp(nv,t,e),Bt=t=>ve(t)&&Object.keys(t).length>0,Ii=t=>{let e=rc(pe,t);return Object.keys(e).forEach(s=>{let i=e[s];ve(i)&&(e[s]=Ii(i))}),e},xi=t=>{let e=rc(Us,t);return Object.keys(e).forEach(s=>{let i=e[s];ve(i)&&(e[s]=xi(i))}),e},Nt=t=>{if(Bt(t))return xi(t)},wt=(t,e)=>typeof t=="boolean"?t:e,ta=t=>(Object.getOwnPropertyNames(t).forEach(function(e){t[e]&&typeof t[e]=="object"&&ta(t[e])}),Object.freeze(t)),ov=t=>t.replace(/^\s+|\s+$/gm,""),Su=t=>t.replace(/^\.+/,""),Dr=t=>{let e=t;if(!ye(t)&&!mt(t))try{e=JSON.stringify(t)}catch{e=null}return e},av=t=>{let e=Array.from(t,s=>String.fromCodePoint(s)).join("");return globalThis.btoa(e)},lv=t=>av(new TextEncoder().encode(t)),Nr=(t,e,s,i,r)=>{let n={category:t,name:e,properties:s,options:i,callback:void 0};$(r)&&(n.callback=r),$(i)&&(n.category=t,n.name=e,n.properties=s,n.options=void 0,n.callback=i),$(s)&&(n.category=t,n.name=e,n.properties=void 0,n.options=void 0,n.callback=s),$(e)&&(n.category=t,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),$(t)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=t),ve(t)?(n.name=void 0,n.category=void 0,n.properties=t,$(e)?n.options=void 0:n.options=e):ve(e)&&(n.name=void 0,n.properties=e,$(s)?n.options=void 0:n.options=s),ye(t)&&!ye(e)&&(n.category=void 0,n.name=t),pe(n.category)||(n.category=void 0),pe(n.name)||(n.name=void 0),n.properties=n.properties?te(n.properties):{},pe(n.options)?n.options=te(n.options):n.options=void 0;let o=ye(n.name)?n.name:n.properties.name,a=ye(n.category)?n.category:n.properties.category;return n.properties=$e(ve(n.properties)?n.properties:{},{...o&&{name:o},...a&&{category:a}}),n},sa=(t,e,s,i)=>{let r={name:t,properties:e,options:s,callback:void 0};return $(i)&&(r.callback=i),$(s)&&(r.properties=e,r.options=void 0,r.callback=s),$(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=Us(r.properties)?te(r.properties):{},pe(r.options)?r.options=te(r.options):r.options=void 0,r},nc=(t,e,s,i)=>{let r={userId:t,traits:e,options:s,callback:void 0};return $(i)&&(r.callback=i),$(s)&&(r.userId=t,r.traits=e,r.options=void 0,r.callback=s),$(e)&&(r.userId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ve(t)||rt(t))&&(r.userId=null,r.traits=t,$(e)?r.options=void 0:r.options=e),r.userId=Dr(r.userId),ve(r.traits)?r.traits=te(r.traits):r.traits=void 0,pe(r.options)?r.options=te(r.options):r.options=void 0,r},oc=(t,e,s,i)=>{let r={to:t,from:e,options:s,callback:void 0};return $(i)&&(r.callback=i),$(s)&&(r.to=t,r.from=e,r.options=void 0,r.callback=s),$(e)?(r.to=t,r.from=void 0,r.options=void 0,r.callback=e):(ve(e)||rt(e))&&(r.to=t,r.from=void 0,r.options=e),pe(r.to)&&(r.to=Dr(r.to)),pe(r.from)?r.from=Dr(r.from):r.from=void 0,pe(r.options)?r.options=te(r.options):r.options=void 0,r},ac=(t,e,s,i)=>{let r={groupId:t,traits:e,options:s,callback:void 0};return $(i)&&(r.callback=i),$(s)&&(r.groupId=t,r.traits=e,r.options=void 0,r.callback=s),$(e)&&(r.groupId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ve(t)||rt(t))&&(r.groupId=null,r.traits=t,$(e)?r.options=void 0:r.options=e),r.groupId=Dr(r.groupId),ve(r.traits)?r.traits=te(r.traits):r.traits=void 0,pe(r.options)?r.options=te(r.options):r.options=void 0,r},fo=(function(t){return t.UNLOADED="Page Unloaded",t})({}),ia="API",wo="CapabilitiesManager",ht="ConfigManager",ko="EventManager",ki="PluginsManager",gs="UserSessionManager",Ri="ErrorHandler",$s="PluginEngine",uv="StoreManager",go=`Ready${ia}`,cv=`Load${ia}`,dv="HttpClient",hv="RudderStackAnalytics",Sr="AnalyticsCore";wu=4096,Ar=[],Qt=0;for(;Qt<256;Qt++)Ar[Qt]=(Qt+256).toString(16).substring(1);_s=256,Ir=[];for(;_s--;)Ir[_s]=(_s+256).toString(16).substring(1);vv=()=>!mt(globalThis.crypto)&&$(globalThis.crypto.getRandomValues),Vr=()=>vv()?gv():pv(),_v=()=>!!window.chrome?.runtime?.id,mv=()=>ye(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),yv=(t,e=!1)=>{let s=!1,i=!1;function r(){s||(s=!0,t(i),setTimeout(()=>{s=!1},0))}(e||mv())&&globalThis.addEventListener("beforeunload",()=>{i=!1,r()}),globalThis.addEventListener("blur",()=>{i=!0,r()}),globalThis.addEventListener("focus",()=>{s=!1}),document.addEventListener("pagehide",()=>{i=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{i=!0,document.visibilityState==="hidden"?r():s=!1})},lc=t=>t.toISOString(),bv=()=>lc(new Date),z=":: ",Ev=t=>`A script with the id "${t}" is already loaded. Skipping the loading of this script to prevent conflicts`,ku=(t,e,s)=>`Unable to load (${ye(s)?s:s.type}) the script with the id "${t}" from URL "${e}"`,Sv=(t,e,s)=>`A timeout of ${s} ms occurred while trying to load the script with id "${t}" from URL "${e}"`,wv=(t,e)=>`${t}${z}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,kv="Failed to convert the value to a JSON string.",Au=(t,e)=>`${t}${z}A bad data (like circular reference, BigInt) has been detected in the object and the property "${e}" has been dropped from the output.`,Av="Failed to encode the cookie data.",Iv=(t,e)=>`${t}${z}The "${e}" storage type is `,Rv="JSONStringify",Iu="JSON",Tv="[BigInt]",uc="[Circular Reference]",Ov=(t,e,s)=>{let i=[];return function(r,n){if(!e?.includes(r)&&!(t&&mt(n))){if(typeof n!="object"||rt(n))return n;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(n)?(s?.warn(wv(Rv,r)),uc):(i.push(n),n)}}},_t=(t,e,s,i)=>{try{return JSON.stringify(t,Ov(e,s,i))}catch(r){return i?.warn(kv,r),null}},Pv=t=>{let e=[];return function(i,r){if(Zp(r))return t?.warn(Au(Iu,i)),Tv;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?(t?.warn(Au(Iu,i)),uc):(e.push(r),r)}},cc=(t,e)=>{let s=Array.isArray(t)?[]:{};for(let i in t)if(Object.hasOwnProperty.call(t,i)){let r=t[i],n=e.call(t,i,r);ve(n)||Array.isArray(n)?s[i]=cc(n,e):s[i]=n}return s},re=(t,e)=>{let s=Pv(e),i=s.call(t,"",t);return ve(t)||Array.isArray(t)?cc(t,s):i},dc="[SDK DISPATCHED ERROR]",jr=t=>{let{stack:e}=t;if(typeof e=="string"&&e)return e},ra=(t,e)=>{if(!ea(t))return new Error(`${e}: ${_t(t)}`);try{let s=t.constructor,i=new s(`${e}: ${t.message}`),r=jr(t);return r&&(i.stack=r),Object.getOwnPropertyNames(t).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{i[n]=t[n]}catch{}}),i}catch{return new Error(`${e}: ${_t(t)}`)}},me=t=>{if(ea(t)){let e=jr(t);e&&(t.stack=`${e}
4
- ${dc}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:t,bubbles:!0,cancelable:!0,composed:!0}))},Ru="RudderLabs JavaScript SDK",Di="3.32.0",Cv="com.rudderlabs.javascript",hc="npm",xv="modern",Tu="RudderJS-Initiated",Dv="ad-block page request",Nv="/ad-blocked",Oi="preloadedEventsBuffer",Lv="Consent Management Interaction",$v="ajs_trait_",Fv="ajs_prop_",Ou="ajs_aid",Mv="ajs_uid",Pu="ajs_event",Bv=10*1e3,Uv=31536e3*1e3,Cu=720*60*1e3,Ao=1800*1e3,xu=10*1e3,Vv=10*1e3,jv=250,fc=(t="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[t]||(globalThis.RudderStackGlobals[t]={})},Ni=(t,e,s="app")=>{fc(s),globalThis.RudderStackGlobals[s][t]=e},gc=(t,e="app")=>(fc(e),globalThis.RudderStackGlobals[e][t]);Du=(t,e)=>{let s={};return t.forEach((i,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);s[n]=t.get(r)}}),s},Hv=(t=[])=>{let e={trait:$v,properties:Fv},s=new URLSearchParams(globalThis.location.search);s.get(Pu)&&t.unshift(["track",s.get(Pu),Du(s,e.properties)]);let i=s.get(Mv),r=Du(s,e.trait);if(i||Bt(r)){let n=[...i?[i]:[],r];t.unshift(["identify",...n])}s.get(Ou)&&t.unshift(["setAnonymousId",s.get(Ou)])},qv=t=>{let e="load",s=[],i=0;for(;i<t.length;){if(t[i]&&t[i][0]===e){s=te(t[i]),t.splice(i,1);break}i+=1}return s},zv=t=>{let e="consent",s=t.filter(r=>r[0]===e),i=t.filter(r=>r[0]!==e);t.splice(0,t.length,...s,...i)},Kv=t=>{let e=gc(Oi)||[];Hv(e),e.length>0&&(t.enqueuePreloadBufferEvents(e),Ni(Oi,[]))},Wv=(t,e)=>{let s=t.shift(),i;if($(e[s])){switch(s){case"page":i=Nr(...t);break;case"track":i=sa(...t);break;case"identify":i=nc(...t);break;case"alias":i=oc(...t);break;case"group":i=ac(...t);break;default:e[s](...t);break}i&&e[s](i)}},Jv=10*1e3,Yv="RS_JS_SDK",Xv=(t,e,s=!0,i=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=i,o.onerror=r,o.src=t,o.id=e,o.async=s,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",Yv),o},Qv=t=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(t,e[0]?.firstChild);return}let s=document.getElementsByTagName("script");if(s.length>0&&s[0]?.parentNode){s[0]?.parentNode.insertBefore(t,s[0]);return}let i=document.createElement("head");i.appendChild(t);let r=document.getElementsByTagName("html")[0];r?.insertBefore(i,r.firstChild)},Zv=(t,e,s,i=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(Ev(e)));try{let l;Qv(Xv(t,e,i,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(ku(e,t,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(Sv(e,t,s)))},s)}catch(l){o(ra(l,ku(e,t,"unknown")))}}),Lr=class{constructor(e,s=Jv){this.logger=e,this.timeout=s}loadJSFile(e){let{url:s,id:i,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!$(o);Zv(s,i,r||this.timeout,n,a).then(u=>{l||o(u)}).catch(u=>{l||o(i,u)})}},e_=Symbol.for("preact-signals");ke=void 0;Ci=void 0,Mt=0,$r=0,t_=0,Io=0,Fr=void 0,Mr=0;We.prototype.brand=e_;We.prototype.h=function(){return!0};We.prototype.S=function(t){var e=this,s=this.t;s!==t&&t.e===void 0&&(t.x=s,this.t=t,s!==void 0?s.e=t:Hr(function(){var i;(i=e.W)==null||i.call(e)}))};We.prototype.U=function(t){var e=this;if(this.t!==void 0){var s=t.e,i=t.x;s!==void 0&&(s.x=i,t.e=void 0),i!==void 0&&(i.e=s,t.x=void 0),t===this.t&&(this.t=i,i===void 0&&Hr(function(){var r;(r=e.Z)==null||r.call(e)}))}};We.prototype.subscribe=function(t){var e=this;return At(function(){var s=e.value;Hr(function(){return t(s)})},{name:"sub"})};We.prototype.valueOf=function(){return this.value};We.prototype.toString=function(){return this.value+""};We.prototype.toJSON=function(){return this.value};We.prototype.peek=function(){var t=this;return Hr(function(){return t.value})};Object.defineProperty(We.prototype,"value",{get:function(){var t=pc(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if($r>100)throw new Error("Cycle detected");(function(s){Mt!==0&&$r===0&&s.l!==Io&&(s.l=Io,Fr={S:s,v:s.v,i:s.i,o:Fr})})(this),this.v=t,this.i++,Mr++,Mt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Gr()}}}});Hs.prototype=new We;Hs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Mr))return!0;if(this.g=Mr,this.f|=1,this.i>0&&!vc(this))return this.f&=-2,!0;var t=ke;try{_c(this),ke=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return ke=t,mc(this),this.f&=-2,!0};Hs.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}We.prototype.S.call(this,t)};Hs.prototype.U=function(t){if(this.t!==void 0&&(We.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};Hs.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(Hs.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=pc(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});qs.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};qs.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,yc(this),_c(this),Mt++;var t=ke;return ke=this,s_.bind(this,t)};qs.prototype.N=function(){2&this.f||(this.f|=2,this.u=Ci,Ci=this)};qs.prototype.d=function(){this.f|=8,1&this.f||na(this)};qs.prototype.dispose=function(){this.d()};Ro=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=[]}},kr={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Nu="LOG",bc="ERROR",i_="RS SDK",r_="font-weight: bold; background: black; color: white;",n_="font-weight: normal;",To=class{constructor(e=Nu,s="",i=console){this.minLogLevel=kr[e],this.scope=s,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,s){this.minLogLevel<=kr[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(s))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=kr[e],Ve(this.minLogLevel)&&(this.minLogLevel=kr[Nu])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let s=`%c ${i_}`;this.scope&&(s=`${s} - ${this.scope}`);let i=ye(e[0])?e[0].trim():"";s=`${s} %c ${i}`;let r=[s,r_,n_];return ye(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},Ut=new To,Lt=(function(t){return t.HANDLEDEXCEPTION="handledException",t.UNHANDLEDEXCEPTION="unhandledException",t.UNHANDLEDREJECTION="unhandledPromiseRejection",t})({}),Ec=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Oo="cookieStorage",Lu="Unable to process/parse source configuration response",o_="The source is disabled. Please enable the source in the dashboard to send events.",a_="Failed to prepare data for the request.",l_="Failed to invoke plugin because the extension point name is missing.",u_="Failed to invoke plugin because the extension point name is invalid.",c_=t=>`${t}${z}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,d_=(t,e,s)=>`${t}${z}The base URL "${s}" for ${e} is not valid.`,h_=(t,e,s)=>`${t}${z}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(s)}".`,f_=(t,e)=>`${t}${z}Ignoring a non-error: ${e}.`,$u="Failed to log breadcrumb",g_=t=>`${t}${z}Failed to handle the error.`,p_=t=>`${t}${z}Plugin name is missing.`,v_=(t,e)=>`${t}${z}Plugin "${e}" already exists.`,__=(t,e)=>`${t}${z}Plugin "${e}" not found.`,m_=(t,e)=>`${t}${z}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.`,y_=(t,e,s)=>`${t}${z}Plugin "${e}" could not be loaded because some of its dependencies "${s}" do not exist.`,b_=(t,e,s)=>`${t}${z}Failed to invoke the "${e}" extension point of plugin "${s}".`,Fu="Failed to fetch the source config",E_=(t,e)=>`${t}${z}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,S_=(t,e)=>`${t}${z}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.`,Sc=t=>`${t}${z}The provided callback parameter is not a function.`,w_=(t,e,s,i,r)=>`${t} with status ${e} (${s}) for URL: ${i}. Response: ${r.trim()}`,k_=(t,e,s)=>`${t} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${s}`,A_=(t,e)=>`${t} for URL: ${e}`,I_=t=>`Failed to save the value for "${t}" to storage`,R_=t=>`Failed to retrieve or parse data for "${t}" from storage`,T_=t=>`The server responded with status ${t} while setting the cookies. As a fallback, the cookies will be set client side.`,O_=t=>`The server failed to set the ${t} cookie. As a fallback, the cookies will be set client side.`,Mu="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",P_=(t,e,s)=>`${t}${z}The storage type "${e}" is not supported. Please choose one of the following supported types: "${Ec}". The default type "${s}" will be used instead.`,C_=(t,e,s,i)=>`${t}${z}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(s)}". The default version "${i}" will be used instead.`,x_=(t,e,s)=>`${t}${z}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${s}). To enable storage data migration, please update the storage encryption version to the latest version.`,D_=(t,e,s)=>`${t}${z}The provided cookie domain (${e}) does not match the current webpage's domain (${s}). Hence, the cookies will be set client-side.`,N_=(t,e,s,i)=>`${t}${z}The "${e}" property defined under "${s}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i}).`,L_=(t,e)=>`${t}${z}The top-level custom context property "${e}" is reserved and was ignored.`,$_=t=>`${t}${z}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,Rr=t=>`${t}${z}Invalid custom context. Use a plain object without prototype pollution keys.`,F_=t=>`${t}${z}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,M_=(t,e,s)=>`${t}${z}The session timeout value "${e}" is not a number. The default timeout of ${s} ms will be used instead.`,B_=(t,e,s)=>`${t}${z}The session cut off duration value "${e}" is not a number. The default cut off duration of ${s} ms will be used instead.`,U_=(t,e,s)=>`${t}${z}The session cut off duration value "${e}" ms is less than the session timeout value "${s}" ms. The cut off functionality will be disabled.`,V_=t=>`${t}${z}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.`,j_=(t,e,s)=>`${t}${z}The session timeout value ${e} ms is less than the recommended minimum of ${s} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,G_=(t,e,s)=>`${t}${z}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${s}" digits long. A new session ID will be auto-generated instead.`,H_=t=>`${t}${z}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,q_=(t,e,s,i)=>`${t}${z}The storage type "${s}" is not available for entry "${e}". The SDK will initialize the entry with "${i}" storage type instead.`,z_=t=>`${t}${z}The callback threw an exception`,K_=(t,e)=>`${t}${z}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,W_=(t,e)=>`Failed to load the polyfill script with ID "${t}" from URL ${e}.`,J_=(t,e,s)=>`${t}${z}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${s}" will be used instead.`,Y_=(t,e,s)=>`${t}${z}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${s}" will be used instead.`,X_=(t,e)=>`${t}${z}${e} plugin is deprecated. Please exclude it from the load API options.`,Q_=(t,e,s,i)=>{let r=s.length===1,n=r?` '${s[0]}' plugin was`:` ['${s.join("', '")}'] plugins were`,o=`${t}${z}${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.`},Z_=(t,e)=>`${t}${z}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,em=t=>`${t}${z}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,tm=(t,e)=>`${t}${z}Ignoring unknown plugins: ${e.join(", ")}.`,sm=(t,e)=>`${t}${z}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.`,im=(t,e)=>`${t}${z}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,wc={All:!0},qr="js-integrations",kc="plugins",rm=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_]*)?$"),Li="modern",zr="https://cdn.rudderlabs.com",oa="v3",Ac=`${zr}/${oa}/${Li}/${qr}`,Ic=`${zr}/${oa}/${Li}/${kc}`,Rc="https://api.rudderstack.com",ps="v3",nm="xhr",Po={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Tr={[ps]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},om={[nm]:"XhrQueue",beacon:"BeaconQueue"},am="rsaRequest",lm="rsaMetrics",um="Custom Device Mode",cm={configUrl:Rc,loadIntegration:!0,sessions:{autoTrack:!0,timeout:Ao,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:wc,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:Vv,storage:{encryption:{version:ps},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},dm=R(te(cm)),ce=ta({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),vo=ta({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),hm=10,fm={userId:R(ce.userId),userTraits:R(ce.userTraits),anonymousId:R(ce.anonymousId),groupId:R(ce.groupId),groupTraits:R(ce.groupTraits),initialReferrer:R(ce.initialReferrer),initialReferringDomain:R(ce.initialReferringDomain),sessionInfo:R(ce.sessionInfo),authToken:R(ce.authToken)},gm={isOnline:R(!0),storage:{isLocalStorageAvailable:R(!1),isCookieStorageAvailable:R(!1),isSessionStorageAvailable:R(!1)},isBeaconAvailable:R(!1),isLegacyDOM:R(!1),isUaCHAvailable:R(!1),isCryptoAvailable:R(!1),isAdBlockerDetectionInProgress:R(!1),isAdBlocked:R(void 0),cspBlockedURLs:R([])},pm={isErrorReportingEnabled:R(!1),isMetricsReportingEnabled:R(!1),breadcrumbs:R([])},vm=R(void 0),_m={activeDataplaneUrl:R(void 0),integrationsCDNPath:R(Ac),pluginsCDNPath:R(Ic),sourceConfigUrl:R(void 0),status:R(void 0),initialized:R(!1),logLevel:R(bc),loaded:R(!1),readyCallbacks:R([]),writeKey:R(void 0),dataPlaneUrl:R(void 0),safeAnalyticsInstance:R(void 0)},mm={enabled:R(!1),initialized:R(!1),data:R({}),activeConsentManagerPluginName:R(void 0),preConsent:R({enabled:!1}),postConsent:R({}),resolutionStrategy:R("and"),provider:R(void 0),metadata:R(void 0)},ym={retries:R(0),dropped:R(0),sent:R(0),queued:R(0),triggered:R(0),metricsServiceUrl:R(void 0)},bm=()=>xv,Em={app:R({name:Ru,namespace:Cv,version:Di,installType:hc}),traits:R(null),library:R({name:Ru,version:Di,snippetVersion:globalThis.RudderSnippetVersion,variant:bm()}),userAgent:R(null),device:R(null),network:R(null),os:R({name:"",version:""}),locale:R(null),screen:R({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":R(void 0),timezone:R(void 0)},Sm=R({}),wm={configuredDestinations:R([]),activeDestinations:R([]),loadOnlyIntegrations:R({}),failedDestinations:R([]),loadIntegration:R(!0),initializedDestinations:R([]),clientDestinationsReady:R(!1),integrationsConfig:R({})},km={toBeProcessedArray:R([]),readyCallbacksArray:R([])},Am={ready:R(!1),loadedPlugins:R([]),failedPlugins:R([]),pluginsToLoadFromConfig:R([]),activePlugins:R([]),totalPluginsToLoad:R(0)},Im={encryptionPluginName:R(void 0),migrate:R(!1),type:R(void 0),cookie:R(void 0),entries:R({}),trulyAnonymousTracking:R(!1)},Rm={isEnabledServerSideCookies:R(!1),dataServiceUrl:R(void 0)},Tm={eventsQueuePluginName:R(void 0),deliveryEnabled:R(!0)},Om={enabled:R(!1),pageLifecycle:{enabled:R(!1),pageViewId:R(void 0),pageLoadedTimestamp:R(void 0)}},Pm={capabilities:gm,consents:mm,context:Em,customContext:Sm,eventBuffer:km,lifecycle:_m,loadOptions:dm,metrics:ym,nativeDestinations:wm,plugins:Am,reporting:pm,session:fm,source:vm,storage:Im,serverCookies:Rm,dataPlaneEvents:Tm,autoTrack:Om},d={...te(Pm)},Tc=/^\s*at /,Cm=/^(eval@)?(\[native code])?$/,xm=/(.+?)(?::(\d+))?(?::(\d+))?$/;Pc="global code",$m=t=>pe(t)&&/^global code$/i.test(t)?Pc:t,Fm=t=>{let e={file:t.fileName,method:$m(t.functionName),lineNumber:t.lineNumber,columnNumber:t.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Pc),e},Bu=t=>ye(t)?t:"";Cc=(t,e)=>{let s;return ea(t)&&ye(jr(t))?s=t:(e.warn(f_(Ri,_t(t))),s=void 0),s},Mm=(t,e)=>{try{let s=Lm(t);return Uu(t.name,t.message,e,s)}catch{return Uu(t.name,t.message,e,[])}},Vu=(t,e)=>{try{return JSON.parse(t||"")}catch(s){let i=ra(s,"Failed to parse response data");e(i)}},Or="The request failed",Bm=[/Failed to fetch dynamically imported module: .*/],Um=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],Vm=[new RegExp(`${Or}.*`),/A script with the id .* is already loaded\./],jm=[...Bm,...Um],Gm="integrations",Hm="sdk",qm=Hm,zm={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},ju=(t,e,s)=>{let i=$e(zm,e||{});return s&&(i.headers=$e(i.headers,{Authorization:s})),i.url=t,i},Gu=(t,e=Bv,s)=>new Promise((i,r)=>{let n;if(t.sendRawData===!0)n=t.data;else if(n=_t(t.data,!1,[],s),rt(n)){r({error:new Error(a_),undefined:void 0,options:t});return}let o=new XMLHttpRequest,a=u=>{r({error:new Error(w_(Or,o.status,o.statusText,t.url,o.responseText)),xhr:o,options:t})},l=u=>{r({error:new Error(k_(Or,u,t.url)),xhr:o,options:t,...u?.type==="timeout"?{timedOut:!0}:{}})};o.ontimeout=l,o.onerror=l,o.onload=()=>{o.status>=200&&o.status<400?i({response:o.responseText,xhr:o,options:t}):a()},o.open(t.method,t.url,!0),t.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(t.headers).forEach(u=>{t.headers[u]&&o.setRequestHeader(u,t.headers[u])});try{o.send(n)}catch(u){r({error:ra(u,A_(Or,t.url)),xhr:o,options:t})}}),Co=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:s,options:i,timeout:r,isRawResponse:n}=e;try{let o=await Gu(ju(s,i,this.basicAuthHeader),r,this.logger);return{data:n?o.response:Vu(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:s,url:i,options:r,timeout:n,isRawResponse:o}=e,a=!$(s);Gu(ju(i,r,this.basicAuthHeader),n,this.logger).then(l=>{a||s(o?l.response:Vu(l.response,this.onError),l)}).catch(l=>{a||s(void 0,l)})}onError(e,s){this.errorHandler?.onError({error:e,context:dv,groupingHash:s})}setAuthHeader(e,s=!1){let i=s?e:lv(`${e}:`);this.basicAuthHeader=`Basic ${i}`}resetAuthHeader(){this.basicAuthHeader=void 0}},xc=new Co(Ut),Km="1",Wm=()=>["rsa"],Jm=["www.test-host.com","localhost","127.0.0.1","[::1]"],Ym=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","customContext","traits","authToken"],Xm="RudderStack JavaScript SDK",Qm="git+https://github.com/rudderlabs/rudder-sdk-js.git",Zm="js",Dc=t=>{d.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(d.lifecycle.sourceConfigUrl.value),s=`${e.origin}${e.pathname}?view=ad`;t.getAsyncData({url:s,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(i,r)=>{d.capabilities.isAdBlockerDetectionInProgress.value=!1,d.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==s}})}catch(e){throw d.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},ey=(t,e)=>{switch(e){case Lt.UNHANDLEDEXCEPTION:{let{error:s}=t;return s||t}case Lt.UNHANDLEDREJECTION:return t.reason;case Lt.HANDLEDEXCEPTION:default:return t}},ty=t=>({type:"manual",name:t,timestamp:new Date,metaData:{}}),sy=(t=()=>window.location.hostname)=>{let e=t();return!e||e&&Jm.includes(e)?"development":"production"},iy=t=>{let e=_t(t,!1,Ym);return e!==null?JSON.parse(e):{}},ry=()=>globalThis.location.href.split("?")[0],ny=(t,e,s,i)=>({id:`${t.value?.id??s.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${i.pageLifecycle.pageViewId.value??"NA"}`,name:t.value?.name??"NA"}),oy=(t,e)=>({locale:t.value??"NA",userAgent:e.value??"NA",time:new Date}),ay=(t,e,s,i)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:u}=s,{app:c,locale:h,userAgent:g,timezone:f,screen:p,library:_}=r;return{payloadVersion:"5",notifier:{name:Xm,version:c.value.version,url:Qm},events:[{exceptions:[te(t)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:c.value.version,releaseStage:sy(),type:c.value.installType},device:oy(h,g),request:{url:ry(),clientIp:"[NOT COLLECTED]"},breadcrumbs:te(l.breadcrumbs.value),context:t.message,groupingHash:i,metaData:{app:{snippetVersion:_.value.snippetVersion},device:{...p.value,timezone:f.value},...iy(s)},user:ny(a,o,n,u)}]}},ly=(t,e,s)=>{if(Ve(t.capabilities.isAdBlocked.value)){t.capabilities.isAdBlockerDetectionInProgress.value===!1&&Dc(e);let i=At(()=>{pe(t.capabilities.isAdBlocked.value)&&(s(t.capabilities.isAdBlocked.value===!1),i())})}else s(t.capabilities.isAdBlocked.value===!1)},uy=(t,e,s)=>{let i=t.message;return new Promise(r=>{if(jm.some(n=>n.test(i))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(i)?.[0];ye(n)?n.startsWith(zr)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):ly(e,s,r):r(!1):r(!0)}else r(!Vm.some(n=>n.test(i)))})},Nc=t=>t?t.split("/").at(-2):void 0,Lc=t=>{let e=t.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},cy=t=>{let e=Lc(t);if(!e)return!1;let s=e.substring(e.lastIndexOf("/")+1);return Nc(e)===qr||Wm().some(r=>s.startsWith(r)&&s.endsWith(".js"))},dy=(t,e)=>{if(e)return e;let s=Lc(t);return Nc(s)===qr?Gm:qm},hy=(t,e,s)=>{let i={version:Km,message_id:Vr(),source:{name:Zm,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:s},errors:t};return _t(i)},fy=(t,e,s)=>{let i;if(!pe(t))i=e;else if(ye(t))i=t;else{let r=Cc(t,s);pe(r)?i=r.message:i=e}return i},xo=class{constructor(e,s){we(this,"initialized",!1);this.httpClient=e,this.logger=s}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Ri,errorType:Lt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Ri,errorType:Lt.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let s=ye(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&s.startsWith(zr)&&!d.capabilities.cspBlockedURLs.value.includes(s)&&(d.capabilities.cspBlockedURLs.value=[...d.capabilities.cspBlockedURLs.value,s])})}async onError(e){try{let{error:s,context:i,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??Lt.HANDLEDEXCEPTION,l=ey(s,a),u=Cc(l,this.logger);if(Ve(u))return;let c=r?`${r} - `:"",h=`${i}${z}${c}`,g=Mm(u,h),p=jr(u).includes(dc);if(!p&&!cy(g)&&a!==Lt.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await uy(g,d,this.httpClient)){let v={severity:"error",unhandled:a!==Lt.HANDLEDEXCEPTION,severityReason:{type:a}},m=fy(n,g.message,this.logger),y=ay(g,v,d,m),w=dy(g,o);this.httpClient.getAsyncData({url:d.metrics.metricsServiceUrl.value,options:{method:"POST",data:hy(y,d,w),sendRawData:!0},isRawResponse:!0})}(a===Lt.HANDLEDEXCEPTION||p)&&this.logger.error(g.message)}catch(s){this.logger.error(g_(Ri),s)}}leaveBreadcrumb(e){try{d.reporting.breadcrumbs.value=[...d.reporting.breadcrumbs.value,ty(e)]}catch(s){this.onError({error:s,context:Ri,customMessage:$u,groupingHash:$u})}}},$c=new xo(xc,Ut),Do=class{constructor(e,s={}){we(this,"plugins",[]);we(this,"byName",{});we(this,"cache",{});we(this,"config",{throws:!0});this.config={throws:!0,...s},this.logger=e}register(e,s){if(!e.name){let r=p_($s);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=v_($s,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,$(e.initialize)&&e.initialize(s)}unregister(e){let s=this.byName[e];if(!s){let r=__($s,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let i=this.plugins.indexOf(s);if(i===-1){let r=m_($s,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 s=e??".";return this.cache[s]||(this.cache[s]=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(y_($s,i.name,r)),!1}return s==="."?!0:sv(i,s)})),this.cache[s]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,s=!0,...i){let r=e;if(!r)throw new Error(l_);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(u_);let a=r.split(".");a.pop();let l=a.join(".");return(s?this.getPlugins(r):[this.getPlugins(r)[0]]).map(c=>{let h=So(c,r);if(!$(h)||n)return h;try{return h.apply(So(c,l),i)}catch(g){if(o)throw g;this.logger.error(b_($s,r,c.name),g)}return null})}invokeSingle(e,...s){return this.invoke(e,!1,...s)[0]}invokeMultiple(e,...s){return this.invoke(e,!0,...s)}},gy=new Do(Ut,{throws:!0}),py=t=>t.config.connectionMode!=="cloud"||t.config.useNativeSDKToSend===!0||t.config.useNativeSDK===!0,vy=t=>t.config.connectionMode==="hybrid"||t.config.useNativeSDKToSend===!0,Hu=t=>t.filter(py),_y=(t,e)=>`${t.replaceAll(" ","-")}___${e}`,Fc=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],my=["Bugsnag","ErrorReporting"],yy={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"}};by=t=>Mc({},(globalThis.__federation_shared__||{}).default||{});Sy=t=>{switch(t){case"BeaconQueue":return()=>st("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>tt(e,!0));case"CustomConsentManager":return()=>st("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>tt(e,!0));case"DeviceModeDestinations":return()=>st("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>tt(e,!0));case"DeviceModeTransformation":return()=>st("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>tt(e,!0));case"ExternalAnonymousId":return()=>st("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>tt(e,!0));case"GoogleLinker":return()=>st("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>tt(e,!0));case"KetchConsentManager":return()=>st("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>tt(e,!0));case"IubendaConsentManager":return()=>st("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>tt(e,!0));case"NativeDestinationQueue":return()=>st("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>tt(e,!0));case"OneTrustConsentManager":return()=>st("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>tt(e,!0));case"StorageEncryption":return()=>st("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>tt(e,!0));case"StorageEncryptionLegacy":return()=>st("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>tt(e,!0));case"StorageMigrator":return()=>st("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>tt(e,!0));case"XhrQueue":return()=>st("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>tt(e,!0));default:return}},wy=t=>{let e={};return t.forEach(s=>{if(Fc.includes(s)){let i=Sy(s);i&&(e[s]=i)}}),e},Bc=()=>({}),ky=()=>({}),Ay=t=>wy?.(t)||{},_o={...Bc(),...ky()},Iy=t=>({...Ay(t)}),No=class{constructor(e,s,i){this.engine=e,this.errorHandler=s,this.logger=i,this.onError=this.onError.bind(this)}init(){d.lifecycle.status.value="pluginsLoading",Ni("pluginsCDNPath",d.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){At(()=>{(d.plugins.activePlugins.value.length===0||d.plugins.loadedPlugins.value.length+d.plugins.failedPlugins.value.length===d.plugins.totalPluginsToLoad.value)&&Ue(()=>{d.plugins.ready.value=!0,d.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=d.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>my.includes(r)?(this.logger.warn(X_(ki,r)),!1):!0);let s=[{configurationStatus:()=>pe(d.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:d.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(om),shouldAddMissingPlugins:!0},{configurationStatus:()=>Hu(d.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Hu(d.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>pe(d.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:d.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Po)},{configurationStatus:()=>pe(d.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:d.storage.encryptionPluginName.value,supportedPlugins:Object.values(Tr)},{configurationStatus:()=>d.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],i=!1;return s.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>pe(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(Bc()),...e]}addMissingPlugins(e,s,i){let r=e.shouldAddMissingPlugins||s,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(Q_(ki,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),s=[...Object.keys(_o),...Fc],i=[],r=[];e.forEach(n=>{s.includes(n)?i.push(n):r.push(n)}),r.length>0&&this.logger.warn(tm(ki,r)),Ue(()=>{d.plugins.totalPluginsToLoad.value=e.length,d.plugins.activePlugins.value=i,d.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(_o).forEach(([s,i])=>{d.plugins.activePlugins.value.includes(s)&&($(i)?this.register([i()]):e.push(s))}),e.length>0&&(d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,...e],this.logger.error(sm(ki,e)))}registerRemotePlugins(){let e=Iy(d.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async s=>{await e[s]().then(i=>this.register([i.default()])).catch(i=>{d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,s],this.onError(i,`Failed to load plugin "${s}"`,i)})})).catch(s=>{this.onError(s)})}invokeMultiple(e,...s){try{return this.engine.invokeMultiple(e,...s)}catch(i){return this.onError(i,e),[]}}invokeSingle(e,...s){try{return this.engine.invokeSingle(e,...s)}catch(i){return this.onError(i,e),null}}register(e){e.forEach(s=>{try{this.engine.register(s,d)}catch(i){d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,s.name],this.onError(i,`Failed to register plugin "${s.name}"`)}})}unregisterLocalPlugins(){Object.keys(_o).forEach(e=>{try{this.engine.unregister(e)}catch(s){this.onError(s,`Failed to unregister plugin "${e}"`)}})}onError(e,s,i){this.errorHandler.onError({error:e,context:ki,customMessage:s,groupingHash:i})}},it="cookieStorage",ot="localStorage",dt="sessionStorage",kt="memoryStorage",ms="none",Ry="test_rudder_cookie",Ty="test_rudder_ls",Oy="test_rudder_ss",Py="rl_user_id",Cy="rl_trait",xy="rl_anonymous_id",Dy="rl_group_id",Ny="rl_group_trait",Ly="rl_page_init_referrer",$y="rl_page_init_referring_domain",Fy="rl_session",My="rl_auth_token",Fs={userId:Py,userTraits:Cy,anonymousId:xy,groupId:Dy,groupTraits:Ny,initialReferrer:Ly,initialReferringDomain:$y,sessionInfo:Fy,authToken:My},By="__tld__",Uc="clientDataInCookie",Vc="clientDataInLocalStorage",Uy="clientDataInMemory",jc="clientDataInSessionStorage",Gc=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],Ms={[it]:Uc,[ot]:Vc,[kt]:Uy,[dt]:jc},qu=(t,e)=>{try{return encodeURIComponent(t)}catch(s){e?.error(Av,s);return}},zu=t=>{try{return decodeURIComponent(t)}catch{return}},Vy=t=>{let e={},s=t.split(/\s*;\s*/),i;return s[0]&&s.forEach(r=>{i=r.split("=");let n=i[0]?zu(i[0]):void 0;n&&(e[n]=i[1]?zu(i[1]):void 0)}),e},jy=(t,e,s,i)=>{let r={...s||{}},n=`${qu(t,i)}=${qu(e,i)}`;rt(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},Lo=()=>{let t=globalThis.document.cookie;return Vy(t)},Gy=t=>Lo()[t],$t=function(t,e,s,i){switch(arguments.length){case 4:case 3:case 2:return jy(t,e,s,i);case 1:return t?Gy(t):Lo();default:return Lo()}},Hy=t=>{let e=document.createElement("a");return e.href=t,e.hostname},qy=t=>{let s=(typeof globalThis.URL!="function"?Hy(t):new URL(t).hostname)?.split(".")??[],i=s[s.length-1],r=[];if(s.length===4&&i&&i===parseInt(i,10).toString())return r;if(s.length<=1)return s[0]&&s[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=s.length-2;n>=0;n-=1)r.push(s.slice(n).join("."));return r},zy=t=>{let e=qy(t);for(let s=0;s<e.length;s+=1){let i=e[s],r=By,n={domain:`${i.indexOf("localhost")!==-1?"":"."}${i}`};try{if($t(r,1,n),$t(r))return $t(r,null,n),i}catch{try{$t(r,null,n)}catch{}}}return""},Ky=()=>{let t=`.${zy(globalThis.location.href)}`;return{maxage:Uv,path:"/",domain:!t||t==="."?void 0:t,samesite:"Lax",enabled:!0}},Wy=()=>({enabled:!0}),Jy=()=>({enabled:!0}),Yy=()=>({enabled:!0}),$o=class{constructor(e){we(this,"isEnabled",!0);we(this,"length",0);we(this,"data",{});this.options=Yy(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,s){return this.data[e]=s,this.length=Object.keys(this.data).length,s}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)}},Br=new $o(Ut);Pr={exports:{}},Qy=Pr.exports;eb=Zy(),fs=Xy(eb),Hc=t=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],s=[22,1014];return t instanceof DOMException?e.includes(t.name)||s.includes(t.code):!1},Bs=(t=ot,e,s)=>{let i,r,n=Iv(wo,t),o="unavailable",a=!0,l;try{switch(t){case kt:return!0;case it:i=e,r=Ry;break;case ot:i=e??globalThis.localStorage,r=Ty;break;case dt:i=e??globalThis.sessionStorage,r=Oy;break;default:return!1}if(i&&(i.setItem(r,"true"),i.getItem(r)))return i.removeItem(r),!0;a=!1}catch(u){a=!1,l=u,Hc(u)&&(o="full")}return a||s?.warn(`${n}${o}.`,l),!1},Fo=class{constructor(e){we(this,"isSupportAvailable",!0);we(this,"isEnabled",!0);we(this,"length",0);this.options=Wy(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isSupportAvailable=Bs(ot),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){fs.set(e,s),this.length=fs.len()}getItem(e){let s=fs.get(e);return Ve(s)?null:s}removeItem(e){fs.remove(e),this.length=fs.len()}clear(){fs.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return fs.keys()}},aa=new Fo(Ut),Mo=class{constructor(e){we(this,"isSupportAvailable",!0);we(this,"isEnabled",!0);we(this,"length",0);this.options=Jy(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isSupportAvailable=Bs(dt),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){this.store&&(this.store.setItem(e,s),this.length=this.store.length)}getItem(e){if(!this.store)return null;let s=this.store.getItem(e);return Ve(s)?null:s}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 s=0;s<this.store.length;s+=1){let i=this.store.key(s);i!==null&&e.push(i)}return e}},la=new Mo(Ut),Bo=class{constructor(e){we(this,"isSupportAvailable",!0);we(this,"isEnabled",!0);we(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=Ky()),this.options=$e(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=Bs(it,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){return $t(e,s,this.options,this.logger),this.length=Object.keys($t()).length,!0}getItem(e){let s=$t(e);return Ve(s)?null:s}removeItem(e){let s=this.setItem(e,null);return this.length=Object.keys($t()).length,s}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys($t())}},ua=new Bo(Ut),vt=t=>{switch(t){case ot:return aa;case dt:return la;case kt:return Br;case it:return ua;default:return Br}},tb=t=>{let e=ua.configure(t);d.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},sb=t=>{aa.configure(t)},ib=t=>{Br.configure(t)},rb=t=>{la.configure(t)},nb=(t={},e={},s={},i={})=>{tb(t),sb(e),ib(s),rb(i)},Uo=class{constructor(e,s,i){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=s,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:s,id:i,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[s,i,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[s,i,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:s,validKeys:i,noCompoundKey:r}=this,n=vt(kt);Object.keys(i).forEach(o=>{let a=this.get(i[o]),l=r?o:[e,s,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,s){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(_t(s,!1,[],this.logger)))}catch(r){if(Hc(r))this.logger.warn(H_(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,s);else{let n=I_(e);this.onError(r,n,n)}}}get(e){let s=this.createValidKey(e),i;try{return!s||(i=this.decrypt(this.engine.getItem(s)),mt(i)||i==="")?null:JSON.parse(i)}catch(r){let n=d.storage.encryptionPluginName.value;if(!n||!d.plugins.failedPlugins.value.includes(n)){let a=R_(e);this.onError(r,a,a)}return null}}remove(e){let s=this.createValidKey(e);s&&this.engine.removeItem(s)}getOriginalEngine(){return this.originalEngine}decrypt(e){return mt(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,s){if(!this.isEncrypted||!e||typeof e!="string"||ov(e)==="")return e;let r=`storage.${s}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,s,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:s,groupingHash:i})}},ob=(t,e)=>{let s;if(t.consents.preConsent.value.enabled)switch(t.consents.preConsent.value.storage?.strategy){case"none":s=ms;break;case"session":e!=="sessionInfo"&&(s=ms);break;case"anonymousId":e!=="anonymousId"&&(s=ms);break}return s},Vo=class{constructor(e,s,i){we(this,"stores",{});we(this,"isInitialized",!1);this.errorHandler=s,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=d.loadOptions.value,s={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};nb(Ii($e(s.cookieStorageOptions??{},d.storage.cookie?.value??{})),Ii(s.localStorageOptions),Ii(s.inMemoryStorageOptions),Ii(s.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[kt,ot,it,dt].forEach(s=>{vt(s)?.isEnabled&&this.setStore({id:Ms[s],name:Ms[s],isEncrypted:!0,noCompoundKey:!0,type:s,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=d.storage.type.value,s=d.loadOptions.value.storage?.entries,i=d.consents.postConsent.value.storage;(pe(i?.type)||pe(i?.entries))&&(e=i?.type,s=i?.entries);let r=!0,n={};Gc.forEach(o=>{let a=o,l=o,u=s?.[a]?.type,h=ob(d,o)??u??e??Oo,g=this.getResolvedStorageTypeForEntry(h,o);g!==ms&&(r=!1),n={...n,[o]:{type:g,key:Fs[l]}}}),Ue(()=>{d.storage.type.value=e,d.storage.entries.value=n,d.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,s){let i=e;switch(e){case ot:vt(ot)?.isEnabled||(i=kt);break;case dt:vt(dt)?.isEnabled||(i=kt);break;case kt:case ms:break;case it:default:vt(it)?.isEnabled?i=it:vt(ot)?.isEnabled?i=ot:vt(dt)?.isEnabled?i=dt:i=kt;break}return i!==e&&this.logger.warn(q_(uv,s,e,i)),i}setStore(e){let s=vt(e.type);return this.stores[e.id]=new Uo(e,s,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},ab=t=>ve(t)&&ve(t.source)&&!mt(t.source.id)&&ve(t.source.config)&&Array.isArray(t.source.destinations),lb=t=>typeof t=="string"&&Ec.includes(t),qc=t=>{let e=new URL(t),{host:s,protocol:i}=e,r=s.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=s,{topDomain:n,protocol:i}},ub=t=>{let{topDomain:e,protocol:s}=qc(t);return`${s}//${e}`},cb=(t,e)=>{let s=e?window.location.origin:ub(window.location.href),i=t.startsWith("/")?t.substring(1):t;return`${s}/${i}`},db=t=>{let{topDomain:e}=qc(window.location.href);return e===t},Vs=t=>t?.endsWith("/")?Vs(t.substring(0,t.length-1)):t,jo=t=>{try{return new URL(t).host}catch{return null}},zc=t=>jo(t)??"",hb=t=>{let e={};try{let s=new URL(t),i="utm_";s.searchParams.forEach((r,n)=>{if(n.startsWith(i)){let o=n.substring(i.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},fb=t=>{let e=t;try{let s=new URL(t);e=s.origin+s.pathname+s.search}catch{}return e},gb=t=>t.replace(/\/{2,}/g,"/"),js=t=>{if(!ye(t))return!1;try{return $(globalThis.URL)&&new URL(t),rm.test(t)}catch{return!1}},mo="none",yo="immediate",pb=t=>t?.statsCollection?.errors?.enabled===!0,vb=t=>t?.statsCollection?.metrics?.enabled===!0,_b=t=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(ve(t)){let s=te(t);e.storage=s.storage,Bt(s.integrations)&&(e.integrations=s.integrations),e.discardPreConsentEvents=s.discardPreConsentEvents===!0,e.sendPageEvent=s.sendPageEvent===!0,e.trackConsent=s.trackConsent===!0,Bt(s.consentManagement)&&(e.consentManagement=$e(s.consentManagement,{enabled:d.consents.enabled.value}))}return e},Wu=t=>Bt(t)||Array.isArray(t),mb=(t,e)=>{let{provider:s}=t,i=s?Po[s]:void 0;return s&&!i&&(e.error(h_(ht,s,Po)),s=void 0),{provider:s,consentManagerPluginName:i}},Kc=(t,e)=>{let s,i=[],r=[],n=!1,o,a=t?.enabled===!0;Bt(t)&&a&&({provider:o,consentManagerPluginName:s}=mb(t,e),Wu(t.allowedConsentIds)&&(i=t.allowedConsentIds,n=!0),Wu(t.deniedConsentIds)&&(r=t.deniedConsentIds,n=!0));let l={allowedConsentIds:i,deniedConsentIds:r};return a=a&&!!s,{provider:o,consentManagerPluginName:s,initialized:n,enabled:a,consentsData:l}},yb=()=>{let t=document.querySelector("script[data-rsa-write-key]");if(t&&t.dataset.rsaWriteKey===d.lifecycle.writeKey.value)return t.src;let e=document.getElementsByTagName("script"),s=/(?:^|\/)rsa(\.min)?\.js$/;for(let i of e){let r=i.getAttribute("src");if(r&&s.test(r))return r}},bb=t=>{d.reporting.isErrorReportingEnabled.value=pb(t.source.config)&&!_v(),d.reporting.isMetricsReportingEnabled.value=vb(t.source.config)},Eb=t=>{let{useServerSideCookies:e,dataServiceEndpoint:s,storage:i,setCookieDomain:r,sameDomainCookiesOnly:n}=d.loadOptions.value,o=i?.cookie,a=!1,l;if(e){a=e;let u=o.domain??r,c=pe(u)&&!db(Su(u))||n,h=cb(s??am,c);if(js(h)){l=Vs(h);let g=jo(window.location.href),f=jo(h);g!==f&&(o={...o,samesite:"None",secure:!0}),!n&&c&&f!==Su(u)&&(a=!1,t.warn(D_(ht,u,f)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},Sb=t=>{let{storage:e}=d.loadOptions.value,s=e?.type;pe(s)&&!lb(s)&&(t.warn(P_(ht,s,Oo)),s=Oo);let i=e?.encryption?.version,r=i&&Tr[i];!Ve(i)&&Ve(r)?(t.warn(C_(ht,i,Tr,ps)),i=ps):Ve(i)&&(i=ps);let n=e?.migrate,o=n&&i===ps;n===!0&&o!==n&&t.warn(x_(ht,i,ps));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:u}=Eb(t);Ue(()=>{d.storage.type.value=s,d.storage.cookie.value=u,d.serverCookies.isEnabledServerSideCookies.value=a,d.serverCookies.dataServiceUrl.value=l,d.storage.encryptionPluginName.value=Tr[i],d.storage.migrate.value=o})},wb=t=>{let{provider:e,consentManagerPluginName:s,initialized:i,enabled:r,consentsData:n}=Kc(d.loadOptions.value.consentManagement,t),o=d.loadOptions.value.preConsent,a=o?.storage?.strategy??mo,l=["none","session","anonymousId"];pe(a)&&!l.includes(a)&&(a=mo,t.warn(J_(ht,o?.storage?.strategy,mo)));let u=o?.events?.delivery??yo,c=["immediate","buffer"];pe(u)&&!c.includes(u)&&(u=yo,t.warn(Y_(ht,o?.events?.delivery,yo))),Ue(()=>{d.consents.activeConsentManagerPluginName.value=s,d.consents.initialized.value=i,d.consents.enabled.value=r,d.consents.data.value=n,d.consents.provider.value=e,d.consents.preConsent.value={enabled:d.loadOptions.value.preConsent?.enabled===!0&&i===!1&&r===!0,storage:{strategy:a},events:{delivery:u}}})},kb=t=>{let e=d.consents.resolutionStrategy.value,s;ve(t.consentManagementMetadata)&&(d.consents.provider.value&&(e=t.consentManagementMetadata.providers.find(i=>i.provider===d.consents.provider.value)?.resolutionStrategy??d.consents.resolutionStrategy.value),s=t.consentManagementMetadata),d.consents.provider.value==="custom"&&(e=void 0),Ue(()=>{d.consents.metadata.value=te(s),d.consents.resolutionStrategy.value=e})},Ab=t=>{if(d.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",s=e;d.loadOptions.value.useBeacon&&(d.capabilities.isBeaconAvailable.value?s="BeaconQueue":(s=e,t.warn(F_(ht)))),Ue(()=>{d.dataPlaneEvents.eventsQueuePluginName.value=s})}},Ib=(t,e,s,i,r)=>{let n=new URLSearchParams({p:hc,v:Di,build:Li,writeKey:e,lockIntegrationsVersion:s.toString(),lockPluginsVersion:i.toString()}),o=Rc,a=n,l="/sourceConfig/",u="";if(js(t)){let c=new URL(t);Vs(c.pathname).endsWith("/sourceConfig")||(c.pathname=`${Vs(c.pathname)}/sourceConfig/`),c.pathname=gb(c.pathname),n.forEach((h,g)=>{c.searchParams.get(g)===null&&c.searchParams.set(g,h)}),o=c.origin,l=c.pathname,a=c.searchParams,u=c.hash}else r.warn(K_(ht,t));return`${o}${l}?${a}${u}`},Rb=t=>t.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:_y(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===um})),Wc=(t,e,s,i,r,n,o)=>{let a;if(n){if(!js(n))return o.error(d_(ht,t,n)),null;a=Vs(n)}else if(a=s,d.context.app.value.installType==="cdn"){let l=yb();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${oa}/${Li}/${e}$`),`/${i}/${Li}/${e}`)),a},Tb=(t,e,s,i)=>Wc("integrations",qr,Ac,t,e,s,i),Ob=(t,e,s,i)=>Wc("plugins",kc,Ic,t,e,s,i),Go=class{constructor(e,s,i){this.errorHandler=s,this.logger=i,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){At(()=>{this.logger.setMinLogLevel(d.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:s,lockIntegrationsVersion:i,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=d.loadOptions.value,l=Tb(Di,i,n,this.logger);if(rt(l))return;let u;u=Ob(Di,r,o,this.logger),u!==null&&(this.attachEffects(),d.lifecycle.activeDataplaneUrl.value=Vs(d.lifecycle.dataPlaneUrl.value),Sb(this.logger),wb(this.logger),Ab(this.logger),Ue(()=>{d.lifecycle.integrationsCDNPath.value=l,d.lifecycle.pluginsCDNPath.value=u,e&&(d.lifecycle.logLevel.value=e),d.lifecycle.sourceConfigUrl.value=Ib(s,d.lifecycle.writeKey.value,i,r,this.logger),d.metrics.metricsServiceUrl.value=`${d.lifecycle.activeDataplaneUrl.value}/${lm}`,d.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,s,i){this.errorHandler.onError({error:e,context:ht,customMessage:s,groupingHash:i})}processConfig(e,s){if(!pe(e)){pe(s)?this.onError(s.error,Fu):this.onError(new Error(Fu));return}let i;try{ye(e)?i=JSON.parse(e):i=e}catch(n){this.onError(n,Lu);return}if(!ab(i)){this.onError(new Error(Lu));return}if(i.source.enabled===!1){this.logger.error(o_);return}bb(i);let r=i.source.destinations.length>0?Rb(i.source.destinations):[];Ue(()=>{d.source.value={config:i.source.config,name:i.source.name,id:i.source.id,workspaceId:i.source.workspaceId},d.nativeDestinations.configuredDestinations.value=r,d.plugins.pluginsToLoadFromConfig.value=d.loadOptions.value.plugins??[],kb(i),d.lifecycle.status.value="configured"})}getConfig(){let e=d.loadOptions.value.getSourceConfig;if(e){if(!$(e)){this.logger.error(c_(ht));return}let s=e();s instanceof Promise?s.then(i=>this.processConfig(i)).catch(i=>{this.onError(i,"SourceConfig")}):this.processConfig(s)}else this.httpClient.getAsyncData({url:d.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},Pb=()=>{let t=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return t?.[1]?t[1]:"NA"},Jc=(t=()=>document)=>t()?.referrer||"$direct",Cb=(t=()=>document)=>{let s=t().getElementsByTagName("link"),i="";for(let r=0;s[r];r+=1){let n=s[r];if(n.getAttribute("rel")==="canonical"&&!i){i=n.getAttribute("href")??"";break}}return i},xb=(t=()=>globalThis.navigator)=>{let e=t();if(Ve(e))return null;let{userAgent:s}=e,{brave:i}=e;if(i&&Object.getPrototypeOf(i).isBrave){let r=s.match(/(chrome)\/([\w.]+)/i);r&&(s=`${s} Brave/${r[2]}`)}return s},Db=(t=()=>globalThis.navigator)=>{let e=t();return Ve(e)?null:e.language??e.browserLanguage},Yc=(t=()=>globalThis.location,e=()=>document)=>{let s=t(),i=Cb(e),r=s.pathname,{href:n}=s,o=n,{search:a}=s;if(i)try{let h=new URL(i);h.search===""?o=i+a:o=i,r=h.pathname}catch{}let l=fb(o),{title:u}=e(),c=Jc(e);return{path:r,referrer:c,referring_domain:zc(c),search:a,title:u,url:l,tab_url:n}},Nb=(t,e="none")=>{e==="none"&&t(void 0),e==="default"&&t(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(s=>{t(s)}).catch(()=>{t()})},Lb=()=>{let t=globalThis.document.createElement("div");return t.setAttribute("data-a-b","c"),t.dataset?t.dataset.aB==="c":!1},Ho={URL:()=>!$(globalThis.URL)||!$(globalThis.URLSearchParams),Promise:()=>!$(globalThis.Promise),"Number.isNaN":()=>!$(globalThis.Number.isNaN),"Number.isInteger":()=>!$(globalThis.Number.isInteger),"Array.from":()=>!$(globalThis.Array.from),"Array.prototype.find":()=>!$(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!$(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!$(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!$(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!$(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!$(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!$(globalThis.String.fromCodePoint),"Object.entries":()=>!$(globalThis.Object.entries),"Object.values":()=>!$(globalThis.Object.values),"Object.assign":()=>!$(globalThis.Object.assign),"Object.fromEntries":()=>!$(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!Lb(),TextEncoder:()=>!$(globalThis.TextEncoder)||!$(globalThis.TextDecoder),requestAnimationFrame:()=>!$(globalThis.requestAnimationFrame)||!$(globalThis.cancelAnimationFrame),CustomEvent:()=>!$(globalThis.CustomEvent),"navigator.sendBeacon":()=>!$(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!$(globalThis.Uint8Array),Set:()=>!$(globalThis.Set),atob:()=>!$(globalThis.atob)},$b=()=>{let t=Object.keys(Ho),e=!1;for(let s=0;s<t.length;s++){let i=Ho[t[s]];if($(i)&&i()){e=!0;break}}return e},Fb="https://polyfill-fastly.io/v3/polyfill.min.js",Mb=`${Fb}?version=3.111.0&features=${Object.keys(Ho).join("%2C")}`,Bb=10*1e3,Ju="rudderstackPolyfill",Ub=()=>!mt(globalThis.crypto)&&$(globalThis.crypto.getRandomValues),Yu=()=>!mt(globalThis.navigator.userAgentData),Vb=()=>!mt(globalThis.navigator.sendBeacon)&&$(globalThis.navigator.sendBeacon),Xu=()=>{let t={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return t={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},t},qo=class{constructor(e,s,i){this.httpClient=e,this.errorHandler=s,this.logger=i,this.externalSrcLoader=new Lr(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Ue(()=>{d.capabilities.storage.isCookieStorageAvailable.value=Bs(it,vt(it),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=Bs(ot,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=Bs(dt,void 0,this.logger),d.capabilities.isBeaconAvailable.value=Vb(),d.capabilities.isUaCHAvailable.value=Yu(),d.capabilities.isCryptoAvailable.value=Ub(),d.capabilities.isOnline.value=globalThis.navigator.onLine,d.context.userAgent.value=xb(),d.context.locale.value=Db(),d.context.screen.value=Xu(),d.context.timezone.value=Pb(),Yu()&&Nb(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),At(()=>{d.loadOptions.value.sendAdblockPage===!0&&d.lifecycle.sourceConfigUrl.value!==void 0&&Dc(this.httpClient)})}prepareBrowserCapabilities(){d.capabilities.isLegacyDOM.value=$b();let e=d.loadOptions.value.polyfillURL,s=Mb;if(Us(e)&&(js(e)?s=e:this.logger.warn(Z_(wo,e))),d.loadOptions.value.polyfillIfRequired&&d.capabilities.isLegacyDOM.value&&js(s)){let r=s!==d.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${d.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,s=`${s}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:s,id:Ju,async:!0,timeout:Bb,callback:n=>{n?r||this.onReady():this.onError(new Error(W_(Ju,s)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{d.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{d.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Gv(()=>{d.context.screen.value=Xu()},this))}onReady(){this.detectBrowserCapabilities(),d.lifecycle.status.value="browserCapabilitiesReady"}onError(e,s){this.errorHandler.onError({error:e,context:wo,groupingHash:s})}},jb="web",Gb=["integrations","anonymousId","originalTimestamp"],Hb=["library","consentManagement","userAgent","ua-ch","screen"],bo=["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"],Cr="CustomContext",qb=new Set(["__proto__","constructor","prototype"]),zb=Function.prototype.toString.call(Object),Kb=t=>{if(!ve(t))return!1;let e=Object.getPrototypeOf(t);if(e===null)return!0;let s=Object.prototype.hasOwnProperty.call(e,"constructor")?e.constructor:void 0;return typeof s=="function"&&s.prototype===e&&Function.prototype.toString.call(s)===zb},ca=(t,e=new Set)=>{if(!ve(t)&&!Array.isArray(t))return!1;let s=t;return e.has(s)?!1:(e.add(s),Object.keys(s).some(i=>qb.has(i)||ca(s[i],e)))},Xc=(t,e)=>{let s={};return Object.keys(t).forEach(i=>{if(Hb.includes(i)){e.warn(L_(Cr,i));return}Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:t[i]===t?s:t[i],writable:!0})}),s},Qc=(t,e)=>{try{if(!Kb(t)){e.warn(Rr(Cr));return}let s=Xc(t,e);if(ca(s)){e.warn(Rr(Cr));return}let i=re(s,e);return te(i)}catch{e.warn(Rr(Cr));return}},zo=class{constructor(e,s){this.state=e,this.logger=s}set(e){let s=Qc(e,this.logger);if(!s)return;let i=$e(te(this.state.value),s);this.state.value=xi(i)}get(){return te(this.state.value)}clear(){this.state.value={}}},Zc=t=>typeof t=="number"&&!Number.isNaN(t),Wb=(t,e)=>e.toString().length>=t,Ur=t=>Zc(t)&&t>=0&&Number.isInteger(t),Qu=10,ed=t=>{let{cutOff:e}=t,s=Date.now();return!!(e?.enabled&&e.expiresAt&&s>e.expiresAt)},Zu=t=>!t.expiresAt||Date.now()>t.expiresAt||ed(t),Jb=()=>Date.now(),Yb=(t,e)=>!t||!Ur(t)||!Wb(Qu,t)?(e.warn(G_(gs,t,Qu)),!1):!0,Xb=t=>{if(t?.enabled)return t.expiresAt??(Ur(t.duration)?Date.now()+t.duration:void 0)},Qb=t=>{let{timeout:e,cutOff:s}=t,i=Date.now();return{id:i,expiresAt:i+e,timeout:e,autoTrack:!0,...s&&{cutOff:s}}},Zb=(t,e)=>({id:Yb(t,e)?t:Jb(),sessionStart:void 0,manualTrack:!0}),Ti=t=>t===it||t===ot||t===dt||t===kt,Ko=()=>Vr(),e0=t=>{if(tv(t)){let{entries:e,...s}=vo;return{...s,entries:{...e,anonymousId:t}}}return ve(t)&&ve(t.entries)?$e(vo,t):{...vo}},t0=t=>{let e=Yc(),s={};return Object.keys(e).forEach(i=>{s[i]=t?.[i]||e[i]}),s.initial_referrer=t?.initial_referrer||d.session.initialReferrer.value,s.initial_referring_domain=t?.initial_referring_domain||d.session.initialReferringDomain.value,s},s0=(t,e)=>{let s=e?.page||{},i=t,r=Yc();return Object.keys(r).forEach(n=>{Ve(i[n])&&(i[n]=s[n]||r[n])}),Ve(i.initial_referrer)&&(i.initial_referrer=s.initial_referrer||d.session.initialReferrer.value),Ve(i.initial_referring_domain)&&(i.initial_referring_domain=s.initial_referring_domain||d.session.initialReferringDomain.value),i},Eo=(t,e,s)=>{ve(t)&&Object.keys(t).forEach(i=>{(bo.includes(i)||bo.includes(i.toLowerCase()))&&s.warn(N_(ko,i,e,bo))})},i0=(t,e)=>{let{properties:s,traits:i,context:r}=t,{traits:n}=r;Eo(s,"properties",e),Eo(i,"traits",e),Eo(n,"context.traits",e)},r0=(t,e)=>{e.anonymousId&&ye(e.anonymousId)&&(t.anonymousId=e.anonymousId),Bt(e.integrations)&&(t.integrations=e.integrations),e.originalTimestamp&&ye(e.originalTimestamp)&&(t.originalTimestamp=e.originalTimestamp)},n0=(t,e,s)=>{let i=t,r=n=>{let o=Xc(n,s);if(ca(o)){s.warn(Rr(ko));return}i=$e(i,o)};return Object.keys(e).forEach(n=>{Gb.includes(n)||(n!=="context"?r({[n]:e[n]}):!Ve(e[n])&&ve(e[n])?r(e[n]):s.warn($_(ko)))}),i},o0=(t,e,s)=>{ve(e)&&(r0(t,e),t.context=n0(t.context,e,s))},a0=t=>{let e;return d.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=d.consents.postConsent.value.integrations??d.nativeDestinations.loadOnlyIntegrations.value:t?e=t:e=wc,te(e)},Ai=(t,e,s,i,r={})=>{let n={channel:jb,context:{traits:te(d.session.userTraits.value),sessionId:d.session.sessionInfo.value.id||void 0,sessionStart:d.session.sessionInfo.value.sessionStart||void 0,...d.consents.enabled.value&&{consentManagement:{deniedConsentIds:te(d.consents.data.value.deniedConsentIds),allowedConsentIds:te(d.consents.data.value.allowedConsentIds),provider:d.consents.provider.value,resolutionStrategy:d.consents.resolutionStrategy.value}},"ua-ch":d.context["ua-ch"].value,app:d.context.app.value,library:d.context.library.value,userAgent:d.context.userAgent.value,os:d.context.os.value,locale:d.context.locale.value,screen:d.context.screen.value,campaign:hb(globalThis.location.href),page:t0(s),timezone:d.context.timezone.value,...d.autoTrack.enabled.value&&{autoTrack:{...d.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:d.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:bv(),messageId:Vr(),userId:t.userId||d.session.userId.value};Ti(d.storage.entries.value.anonymousId?.type)?n.anonymousId=d.session.anonymousId.value:n.anonymousId=Ko(),d.storage.trulyAnonymousTracking.value&&(n.context.trulyAnonymousTracking=!0),t.type==="identify"&&(n.context.traits=d.storage.entries.value.userTraits?.type!==ms?te(d.session.userTraits.value):t.context.traits),t.type==="group"&&((t.groupId||d.session.groupId.value)&&(n.groupId=t.groupId||d.session.groupId.value),(t.traits||d.session.groupTraits.value)&&(n.traits=d.storage.entries.value.groupTraits?.type!==ms?te(d.session.groupTraits.value):t.traits));let o=$e(t,n),a=$e(o,{context:r});return a.event===void 0&&(a.event=null),a.properties===void 0&&(a.properties=null),o0(a,e,i),i0(a,i),a.integrations=a0(a.integrations),a},Wo=class{constructor(e){this.logger=e}generatePageEvent(e,s,i,r,n={}){let o=i??{};return o=s0(o,r),Ai({properties:o,name:s,category:e,type:"page"},r,o,this.logger,n)}generateTrackEvent(e,s,i,r={}){return Ai({properties:s,event:e,type:"track"},i,void 0,this.logger,r)}generateIdentifyEvent(e,s,i,r={}){return Ai({userId:e,type:"identify",context:{traits:s}},i,void 0,this.logger,r)}generateAliasEvent(e,s,i,r={}){let o=Ai({previousId:s,type:"alias"},i,void 0,this.logger,r);return o.userId=e??o.userId,o}generateGroupEvent(e,s,i,r={}){let n={type:"group"};return e&&(n.groupId=e),s&&(n.traits=s),Ai(n,i,void 0,this.logger,r)}create(e,s={}){let i,{type:r,name:n,properties:o,options:a,category:l,userId:u,traits:c,to:h,from:g,groupId:f}=e;switch(r){case"page":i=this.generatePageEvent(l,n,o,a,s);break;case"track":i=this.generateTrackEvent(n,o,a,s);break;case"identify":i=this.generateIdentifyEvent(u,c,a,s);break;case"alias":i=this.generateAliasEvent(h,g,a,s);break;default:i=this.generateGroupEvent(f,c,a,s);break}return i}},Jo=class{constructor(e,s,i,r){this.eventRepository=e,this.userSessionManager=s,this.errorHandler=i,this.logger=r,this.eventFactory=new Wo(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e,s){this.userSessionManager.refreshSession();let i=this.eventFactory.create(e,s);this.eventRepository.enqueue(i,e.callback)}},Yo=class{constructor(e,s,i,r,n){this.storeManager=s,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:s}=d.loadOptions.value,i;Us(e)&&typeof e=="string"&&(i=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(i??this.getAnonymousId(s)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let s=this.getConfiguredSessionTrackingInfo(),i=this.getSessionInfo()??ce.sessionInfo;e={autoTrack:s.autoTrack&&i.manualTrack!==!0,timeout:s.timeout,manualTrack:i.manualTrack,expiresAt:i.expiresAt,id:i.id,sessionStart:i.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=ce.sessionInfo:s.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:s.cutOff.duration,expiresAt:i.cutOff?.expiresAt})}else e=ce.sessionInfo;d.session.sessionInfo.value=e,d.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(d.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),s=this.getInitialReferringDomain();if(e&&s)this.setInitialReferrer(e),this.setInitialReferringDomain(s);else{let i=e||Jc();this.setInitialReferrer(i),this.setInitialReferringDomain(zc(i))}}isPersistenceEnabledForStorageEntry(e){return Ti(d.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=d.storage.entries.value,s=[it,ot,dt];Object.keys(e).forEach(i=>{let r=i,n=e[r]?.type,o=this.storeManager?.getStore(Ms[n]);o&&s.forEach(a=>{let l=this.storeManager?.getStore(Ms[a]);if(l&&a!==n){let u=l.get(Fs[r]);ev(u)&&o.set(Fs[r],u),l.remove(Fs[r])}})})}migrateStorageIfNeeded(e,s){if(!d.storage.migrate.value)return;let i=e??[];i.length===0&&[Uc,Vc,jc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&i.push(a)}),(s??Object.keys(Fs)).forEach(n=>{let o=Fs[n];i.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);mt(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=d.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let s,i=d.loadOptions.value.sessions?.timeout;Ur(i)?s=i:(this.logger.warn(M_(gs,i,Ao)),s=Ao),s===0&&(this.logger.warn(V_(gs)),e=!1),s>0&&s<xu&&this.logger.warn(j_(gs,s,xu));let r=this.getCutOffInfo(s);return{timeout:s,autoTrack:e,cutOff:r}}getCutOffInfo(e){let s=d.loadOptions.value.sessions.cutOff,i,r=!1;return s.enabled===!0&&(i=s.duration,r=!0,Ur(i)?i<e&&(this.logger.warn(U_(gs,i,e)),r=!1):(this.logger.warn(B_(gs,i,Cu)),i=Cu)),{enabled:r,duration:i}}onError(e,s,i){this.errorHandler.onError({error:e,context:gs,customMessage:s,groupingHash:i})}getEncryptedCookieData(e,s){let i=[];return e.forEach(r=>{let n=s?.encrypt(_t(r.value,!1,[],this.logger));Us(n)&&i.push({name:r.name,value:n})}),i}makeRequestToSetCookie(e,s){this.httpClient?.getAsyncData({url:d.serverCookies.dataServiceUrl.value,options:{method:"POST",data:_t({reqType:"setCookies",workspaceId:d.source.value?.workspaceId,data:{options:{maxAge:d.storage.cookie.value?.maxage,path:d.storage.cookie.value?.path,domain:d.storage.cookie.value?.domain,sameSite:d.storage.cookie.value?.samesite,secure:d.storage.cookie.value?.secure,expires:d.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:s})}setServerSideCookies(e,s,i){let r=Object.keys(e),n=()=>r.map(u=>({name:e[u].name,value:d.session[u].value})),o={};r.forEach(u=>{o[e[u].name]=i?.get(e[u].name)});let a=()=>{r.forEach(u=>{this.serverSideCookiesRequestInProgress[u]=!1})},l=()=>{n().forEach(u=>{s&&s(u.name,u.value)})};try{let u={};r.forEach(h=>{u[e[h].name]=d.session[h].value});let c=this.getEncryptedCookieData(n(),i);c.length>0?this.makeRequestToSetCookie(c,(h,g)=>{a(),g?.xhr?.status===200?n().forEach(f=>{let p=o[f.name],_=i?.get(f.name);_t(u[f.name],!1,[])!==_t(_,!1,[])&&(rt(p)&&rt(_)&&this.logger.error(O_(f.name)),s&&s(f.name,f.value))}):(this.logger.error(T_(g?.xhr?.status)),l())}):(l(),a())}catch(u){this.onError(u,Mu,Mu),l(),a()}}syncValueToStorage(e){let s=d.storage.entries.value,i=s[e]?.type;if(Ti(i)){let r=this.storeManager.getStore(Ms[i]),n=s[e]?.key,o=d.session[e].value;o&&(ye(o)||Bt(o))?d.serverCookies.isEnabledServerSideCookies.value&&i===it?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{let a={[e]:{name:n}};this.setServerSideCookies(a,(l,u)=>{r?.set(l,u)},r)},hm)):r?.set(n,o):r?.remove(n)}}registerEffects(){Gc.forEach(e=>{At(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,s){let i=e;(!ye(e)||!i)&&(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&s&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",s)),i=i||Ko()):i=ce.anonymousId,d.session.anonymousId.value=i}getAnonymousId(e){let s=d.storage.entries.value.anonymousId?.type;if(Ti(s)){let i=d.session.anonymousId.value;(!i||i===ce.anonymousId)&&(i=this.getEntryValue("anonymousId")),!i&&e&&(i=this.pluginsManager?.invokeSingle("storage.getAnonymousId",vt,e)),d.session.anonymousId.value=i||Ko()}return d.session.anonymousId.value}getEntryValue(e){let s=d.storage.entries.value,i=s[e]?.type;if(Ti(i)){let r=this.storeManager?.getStore(Ms[i]);this.migrateStorageIfNeeded([r],[e]);let n=s[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let s=vt(it);return s?.isEnabled?s.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?d.session[e].value:this.getEntryValue(e)}getUserId(){return this.getUserSessionValue("userId")}getUserTraits(){return this.getUserSessionValue("userTraits")}getGroupId(){return this.getUserSessionValue("groupId")}getGroupTraits(){return this.getUserSessionValue("groupTraits")}getInitialReferrer(){return this.getUserSessionValue("initialReferrer")}getInitialReferringDomain(){return this.getUserSessionValue("initialReferringDomain")}getSessionInfo(){return this.getUserSessionValue("sessionInfo")}getAuthToken(){return this.getUserSessionValue("authToken")}getSessionId(){let e=this.getSessionInfo()??ce.sessionInfo;return e.autoTrack&&!Zu(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??ce.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=d.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),d.session.sessionInfo.value=e,d.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=d.session,{manualTrack:s,autoTrack:i,timeout:r,cutOff:n}=e.sessionInfo.value;if(i){let o={...ce.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else s&&this.startManualTrackingInternal()}reset(e){let{session:s}=d,i=e0(e);Ue(()=>{Object.keys(ce).forEach(r=>{let n=r;if(i.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:s[n].value=ce[n];break}})})}setUserId(e){d.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:ce.userId}setUserTraits(e){d.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&ve(e)?$e(d.session.userTraits.value??ce.userTraits,e):ce.userTraits}setGroupId(e){d.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:ce.groupId}setGroupTraits(e){d.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&ve(e)?$e(d.session.groupTraits.value??ce.groupTraits,e):ce.groupTraits}setInitialReferrer(e){d.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:ce.initialReferrer}setInitialReferringDomain(e){d.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:ce.initialReferringDomain}startOrRenewAutoTracking(e){let s=e;if(Zu(e))s=Qb(e);else{let i=Date.now(),r=e.timeout;s.expiresAt=i+r}if(ed(s)&&(s.cutOff.expiresAt=void 0),s.cutOff){let i=Xb(s.cutOff);s.cutOff.expiresAt=i}d.session.sessionInfo.value=s}start(e){d.session.sessionInfo.value=Zb(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){d.session.sessionInfo.value=ce.sessionInfo}setAuthToken(e){d.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:ce.authToken}},l0=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],u0=l0,c0=(t,e)=>{let s=te(e);return ye(s.setCookieDomain)||(s.setCookieDomain=void 0),["Strict","Lax","None"].includes(s.sameSiteCookie)||(s.sameSiteCookie=void 0),s.secureCookie=wt(s.secureCookie,t.secureCookie),s.sameDomainCookiesOnly=wt(s.sameDomainCookiesOnly,t.sameDomainCookiesOnly),["none","default","full"].includes(s.uaChTrackLevel)||(s.uaChTrackLevel=void 0),s.integrations=Nt(s.integrations),Array.isArray(s.plugins)||(s.plugins=u0),s.useGlobalIntegrationsConfigInEvents=wt(s.useGlobalIntegrationsConfigInEvents,t.useGlobalIntegrationsConfigInEvents),s.bufferDataPlaneEventsUntilReady=wt(s.bufferDataPlaneEventsUntilReady,t.bufferDataPlaneEventsUntilReady),s.sendAdblockPage=wt(s.sendAdblockPage,t.sendAdblockPage),s.useServerSideCookies=wt(s.useServerSideCookies,t.useServerSideCookies),ye(s.dataServiceEndpoint)||(s.dataServiceEndpoint=void 0),s.sendAdblockPageOptions=Nt(s.sendAdblockPageOptions),s.loadIntegration=wt(s.loadIntegration,t.loadIntegration),Bt(s.storage)?(s.storage.migrate=wt(s.storage.migrate,t.storage?.migrate),s.storage.cookie=Nt(s.storage.cookie),s.storage.encryption=Nt(s.storage.encryption),s.storage=xi(s.storage)):s.storage=void 0,s.destinationsQueueOptions=Nt(s.destinationsQueueOptions),s.queueOptions=Nt(s.queueOptions),s.lockIntegrationsVersion=wt(s.lockIntegrationsVersion,t.lockIntegrationsVersion),s.lockPluginsVersion=wt(s.lockPluginsVersion,t.lockPluginsVersion),Zc(s.dataPlaneEventsBufferTimeout)||(s.dataPlaneEventsBufferTimeout=void 0),s.beaconQueueOptions=Nt(s.beaconQueueOptions),s.preConsent=Nt(s.preConsent),s.sourceConfigurationOverride=Nt(s.sourceConfigurationOverride),$e(t,xi(s))},ec="dataplaneEventsQueue",tc="destinationsEventsQueue",d0="transformEvent",h0=(t,e)=>Object.keys(t).filter(s=>t[s]!==!0||!e[s]).reduce((s,i)=>{let r=te(s);return r[i]=t[i],r},{}),f0=(t,e)=>{let s=te(t),i=e.nativeDestinations.integrationsConfig.value,r=h0(t.integrations,i);return s.integrations=$e(i,r),s},g0=t=>t.consents.preConsent.value.enabled&&t.consents.preConsent.value.events?.delivery==="buffer",xr=(t,e,s,i)=>{if(pe(t))if($(t))try{t(...e)}catch(r){i.error(z_(s),r)}else i.error(Sc(s))},Xo=class{constructor(e,s,i,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=i,this.logger=n,this.storeManager=s}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${ec}.init`,d,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${d0}.init`,d,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${tc}.init`,d,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),At(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=g0(d),s;At(()=>{let i=d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&d.nativeDestinations.clientDestinationsReady.value===!1;(d.nativeDestinations.activeDestinations.value.some(n=>vy(n))===!1||i===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(s),this.dataplaneEventsQueue?.start())}),d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(s=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},d.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(d.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,s){let i=f0(e,d);this.pluginsManager.invokeSingle(`${ec}.enqueue`,d,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let r=te(e);this.pluginsManager.invokeSingle(`${tc}.enqueue`,d,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${ia}`;xr(s,[i],n,this.logger)}},sc=t=>{let e=new CustomEvent(t,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},p0=t=>ye(t)&&t.trim().length>0,v0=t=>js(t),Qo=class{constructor(){this.preloadBuffer=new Ro,this.initialized=!1,this.errorHandler=$c,this.logger=Ut,this.customContextStore=new zo(d.customContext,this.logger),this.externalSrcLoader=new Lr(this.logger),this.httpClient=xc,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new qo(this.httpClient,this.errorHandler,this.logger)}load(e,s,i={}){if(d.lifecycle.status.value)return;if(!p0(e)){this.logger.error(E_(Sr,e));return}if(!v0(s)){this.logger.error(S_(Sr,s));return}let{context:r,...n}=i,o=re(n);r!==void 0&&this.customContextStore.set(r),Ue(()=>{d.lifecycle.writeKey.value=te(e),d.lifecycle.dataPlaneUrl.value=te(s),d.loadOptions.value=c0(d.loadOptions.value,o),d.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(d.loadOptions.value.logLevel??bc),Ni("state",d,e),this.startLifecycle()}setCustomContext(e){if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["setCustomContext",e]];return}this.customContextStore.set(e)}getCustomContext(){return this.customContextStore.get()}clearCustomContext(){if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["clearCustomContext"]];return}this.customContextStore.clear()}startLifecycle(){At(()=>{try{switch(d.lifecycle.status.value){case"mounted":this.onMounted();break;case"browserCapabilitiesReady":this.onBrowserCapabilitiesReady();break;case"configured":this.onConfigured();break;case"pluginsLoading":break;case"pluginsReady":this.onPluginsReady();break;case"initialized":this.onInitialized();break;case"loaded":this.onLoaded();break;case"destinationsLoading":break;case"destinationsReady":this.onDestinationsReady();break;case"ready":this.onReady();break;default:break}}catch(e){let s="Failed to load the SDK";this.errorHandler.onError({error:e,context:Sr,customMessage:s,groupingHash:s})}})}onBrowserCapabilitiesReady(){Kv(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),d.consents.preConsent.value.enabled===!0?d.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(s=>this.preloadBuffer.enqueue(te(s)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&Wv([...e],this)}}prepareInternalServices(){this.pluginsManager=new No(gy,this.errorHandler,this.logger),this.storeManager=new Vo(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Go(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Yo(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Xo(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Jo(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){d.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(d.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),d.consents.enabled.value&&!d.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",d,this.logger),d.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger)),this.eventManager?.init(),d.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Ue(()=>{d.lifecycle.loaded.value=!0,d.lifecycle.status.value="loaded"}),this.initialized=!0;let e=d.loadOptions.value.onLoaded;xr(e,[globalThis.rudderanalytics],cv,this.logger),sc("RSA_Initialised")}onReady(){d.lifecycle.status.value="readyExecuted",d.eventBuffer.readyCallbacksArray.value.forEach(e=>{xr(e,[],go,this.logger)}),sc("RSA_Ready")}processBufferedEvents(){let e=d.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let s=e.shift();d.eventBuffer.toBeProcessedArray.value=e,s&&this.processBufferedEvent(s),e=d.eventBuffer.toBeProcessedArray.value}}processBufferedEvent(e){switch(e[0]){case"setCustomContext":this.setCustomContext(e[1]);break;case"clearCustomContext":this.clearCustomContext();break;case"ready":this.ready(e[1],!0);break;case"page":this.page(e[1],!0,e[2]);break;case"track":this.track(e[1],!0,e[2]);break;case"identify":this.identify(e[1],!0,e[2]);break;case"alias":this.alias(e[1],!0,e[2]);break;case"group":this.group(e[1],!0,e[2]);break;case"reset":this.reset(e[1],!0);break;case"setAnonymousId":this.setAnonymousId(e[1],e[2],!0);break;case"startSession":this.startSession(e[1],!0);break;case"endSession":this.endSession(!0);break;case"consent":this.consent(e[1],!0);break;case"addCustomIntegration":this.addCustomIntegration(e[1],e[2],!0);break;default:return e}}getInvocationContext(e){return e===void 0?this.customContextStore.get():Qc(e,this.logger)??{}}loadDestinations(){if(d.lifecycle.status.value==="destinationsLoading"||d.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",d,this.pluginsManager,this.errorHandler,this.logger);let e=d.nativeDestinations.activeDestinations.value.length;if(e===0){Ue(()=>{d.nativeDestinations.clientDestinationsReady.value=!0,d.lifecycle.status.value="destinationsReady"});return}d.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",d,this.externalSrcLoader,this.errorHandler,this.logger),At(()=>{d.nativeDestinations.initializedDestinations.value.length+d.nativeDestinations.failedDestinations.value.length===e&&Ue(()=>{d.lifecycle.status.value="destinationsReady",d.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){d.lifecycle.status.value!=="ready"&&Ue(()=>{d.lifecycle.status.value="ready"})}ready(e,s=!1){let i="ready";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),!$(e)){this.logger.error(Sc(go));return}d.lifecycle.status.value==="readyExecuted"?xr(e,[],go,this.logger):d.eventBuffer.readyCallbacksArray.value=[...d.eventBuffer.readyCallbacksArray.value,e]}page(e,s=!1,i){let r="page";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback},n),d.capabilities.isAdBlocked.value===!0&&e.category!==Tu&&this.page(Nr(Tu,Dv,{path:Nv},d.loadOptions.value.sendAdblockPageOptions),s,n)}track(e,s=!1,i){let r="track";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event - ${e.name}`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:r,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback},n)}identify(e,s=!1,i){let r="identify";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1,e.userId&&d.session.userId.value&&e.userId!==d.session.userId.value&&this.reset(),rt(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:r,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback},n)}alias(e,s=!1,i){let r="alias";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1;let o=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:r,to:e.to,from:o,options:e.options,callback:e.callback},n)}group(e,s=!1,i){let r="group";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1,rt(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:r,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback},n)}reset(e,s=!1){let i="reset";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.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,s,i=!1){let r="setAnonymousId";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,s]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,s)}getUserId(){return d.session.userId.value}getUserTraits(){return d.session.userTraits.value}getGroupId(){return d.session.groupId.value}getGroupTraits(){return d.session.groupTraits.value}startSession(e,s=!1){let i="startSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let s="endSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,s=!1){let i="consent";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Ue(()=>{d.consents.preConsent.value={...d.consents.preConsent.value,enabled:!1},d.consents.postConsent.value=_b(e);let{initialized:r,consentsData:n}=Kc(d.consents.postConsent.value.consentManagement,this.logger);d.consents.initialized.value=r,d.consents.data.value=n}),d.consents.enabled.value&&!d.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(s)}sendTrackingEvents(e){if(d.consents.postConsent.value.trackConsent){let s=sa(Lv);e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["track",s,this.customContextStore.get()]]:this.track(s)}if(d.consents.postConsent.value.sendPageEvent){let s=Nr();e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["page",s,this.customContextStore.get()]]:this.page(s)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,s,i=!1){let r="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,s,d,this.logger);else{if(d.lifecycle.loaded.value){this.logger.error(im(Sr,e));return}d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,s]]}}},vs=class vs{constructor(){we(this,"analyticsInstances",{});we(this,"defaultAnalyticsKey","");we(this,"logger",Ut);try{if(vs.globalSingleton)return vs.globalSingleton;vs.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.setCustomContext=this.setCustomContext.bind(this),this.getCustomContext=this.getCustomContext.bind(this),this.clearCustomContext=this.clearCustomContext.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.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(),vs.globalSingleton=this,d.autoTrack.pageLifecycle.pageViewId.value=Vr(),d.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){me(e)}}createSafeAnalyticsInstance(){d.lifecycle.safeAnalyticsInstance.value={page:this.page.bind(this),track:this.track.bind(this),identify:this.identify.bind(this),alias:this.alias.bind(this),group:this.group.bind(this),getAnonymousId:this.getAnonymousId.bind(this),getUserId:this.getUserId.bind(this),getUserTraits:this.getUserTraits.bind(this),getGroupId:this.getGroupId.bind(this),getGroupTraits:this.getGroupTraits.bind(this),getSessionId:this.getSessionId.bind(this)}}static initializeGlobalResources(){$c.init(),ua.configure(),aa.configure(),la.configure(),Br.configure()}setDefaultInstanceKey(e){ye(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let s=e;return(!ye(s)||!s)&&(s=this.defaultAnalyticsKey),this.analyticsInstances[s]||(this.analyticsInstances[s]=new Qo),this.analyticsInstances[s]}catch(s){me(s);return}}load(e,s,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let r=gc(Oi);zv(r),Ni(Oi,te(r)),this.getAnalyticsInstance(e)?.load(e,s,i)}catch(r){me(r)}}trackPageLifecycleEvents(e){let{autoTrack:s,useBeacon:i}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=s??{},{events:a=[fo.UNLOADED],enabled:l=r,options:u=n}=o??{};d.autoTrack.pageLifecycle.enabled.value=l,d.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,i,u)}setupPageUnloadTracking(e,s,i){(e.length===0||e.includes(fo.UNLOADED))&&(s===!0?yv(r=>{if(r===!1&&d.lifecycle.loaded.value){let n=Date.now(),o=n-d.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(fo.UNLOADED,{timeOnPage:o},{...i,originalTimestamp:lc(new Date(n))})}},!0):this.logger.warn(em(hv)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],s=qv(e);Ni(Oi,te([...e])),s.length>0&&(s.shift(),this.load.apply(null,s))}ready(e){try{this.getAnalyticsInstance()?.ready(re(e))}catch(s){me(s)}}page(e,s,i,r,n){try{this.getAnalyticsInstance()?.page(Nr(re(e),re(s),re(i),re(r),re(n)))}catch(o){me(o)}}track(e,s,i,r){try{this.getAnalyticsInstance()?.track(sa(re(e),re(s),re(i),re(r)))}catch(n){me(n)}}identify(e,s,i,r){try{this.getAnalyticsInstance()?.identify(nc(re(e),re(s),re(i),re(r)))}catch(n){me(n)}}alias(e,s,i,r){try{this.getAnalyticsInstance()?.alias(oc(re(e),re(s),re(i),re(r)))}catch(n){me(n)}}group(e,s,i,r){try{this.getAnalyticsInstance()?.group(ac(re(e),re(s),re(i),re(r)))}catch(n){me(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(re(e))}catch(s){me(s)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(re(e))}catch(s){me(s);return}}setAnonymousId(e,s){try{this.getAnalyticsInstance()?.setAnonymousId(re(e),re(s))}catch(i){me(i)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){me(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){me(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){me(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){me(e);return}}setCustomContext(e){try{this.getAnalyticsInstance()?.setCustomContext(e)}catch(s){me(s)}}getCustomContext(){try{return this.getAnalyticsInstance()?.getCustomContext()??{}}catch(e){return me(e),{}}}clearCustomContext(){try{this.getAnalyticsInstance()?.clearCustomContext()}catch(e){me(e)}}startSession(e){try{this.getAnalyticsInstance()?.startSession(re(e))}catch(s){me(s)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){me(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){me(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(re(e))}catch(s){me(s)}}consent(e){try{this.getAnalyticsInstance()?.consent(re(e))}catch(s){me(s)}}addCustomIntegration(e,s){try{this.getAnalyticsInstance()?.addCustomIntegration(re(e),re(s))}catch(i){me(i)}}};we(vs,"globalSingleton",null);Gs=vs});var sd,id,ha,td,rd,nd,od,ad,$i=et(()=>{"use strict";sd="https://deriv.com/cdn-cgi/trace",id="https://cdn.growthbook.io",ha="https://deriv-dataplane.rudderstack.com",td="https://ph.deriv.com",rd="https://us.posthog.com",nd=()=>{if(typeof window>"u")return td;let t=window.location.hostname;return t.includes(".deriv.me")?"https://ph.deriv.me":t.includes(".deriv.be")?"https://ph.deriv.be":t.includes(".deriv.ae")?"https://ph.deriv.ae":td},od=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae","trading.game"],ad=["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 Kr(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)i!=="__proto__"&&(t[i]=s[i])}return t}function fa(t,e){function s(r,n,o){if(!(typeof document>"u")){o=Kr({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)o[l]&&(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=r+"="+t.write(n,r)+a}}function 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("="),u=l.slice(1).join("=");try{var c=decodeURIComponent(l[0]);if(c in o||(o[c]=t.read(u,c)),r===c)break}catch{}}return r?o[r]:o}}return Object.create({set:s,get:i,remove:function(r,n){s(r,"",Kr({},n,{expires:-1}))},withAttributes:function(r){return fa(this.converter,Kr({},this.attributes,r))},withConverter:function(r){return fa(Kr({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var _0,ld,ud=et(()=>{"use strict";_0={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};ld=fa(_0,{path:"/"})});var Zt,Jr,Fi,Wr,cd,ys,dd,hd,Mi=et(()=>{"use strict";ud();$i();Zt=(t,e)=>(...s)=>{e()&&console.log(`[ANALYTIC]${t}`,...s)},Jr=t=>{let e=t.split("@")[1]?.toLowerCase();return e?ad.includes(e):!1},Fi=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),Wr=null,cd=async()=>{if(Wr)return Wr;let t=JSON.parse(ld.get("website_status")||"{}")?.clients_country;return Wr=(async()=>{try{let e=await fetch(sd).catch(()=>null);if(!e)return t||"";let s=await e.text().catch(()=>"");return s?Object.fromEntries(s.split(`
5
- `).map(r=>r.split("=",2))).loc?.toLowerCase()||t||"":t||""}catch{return t||""}})(),Wr},ys=t=>{if(t==null||typeof t!="object")return t;if(Array.isArray(t)){let i=[];for(let r=0;r<t.length;r++){let n=ys(t[r]);n!=null&&i.push(n)}return i.length?i:void 0}let e={},s=!1;for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let r=ys(t[i]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[i]=r,s=!0)}return s?e:void 0},dd=(t,e)=>{for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let i=t[s];i&&typeof i=="object"&&!Array.isArray(i)?dd(i,e):e[s]=i}},hd=t=>{if(t==null||typeof t!="object"||Array.isArray(t))return t;let e={};return dd(t,e),e}});function Ed(){return bd}function ga(t){let e=2166136261,s=t.length;for(let i=0;i<s;i++)e^=t.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Bi(t,e,s){return s===2?ga(ga(t+e)+"")%1e4/1e4:s===1?ga(e+t)%1e3/1e3:null}function va(t){return t<=0?[]:new Array(t).fill(1/t)}function Zr(t,e){return t>=e[0]&&t<e[1]}function Sd(t,e){let s=Bi("__"+e[0],t,1);return s===null?!1:s>=e[1]&&s<e[2]}function wd(t,e){for(let s=0;s<e.length;s++)if(Zr(t,e[s]))return s;return-1}function _a(t){try{let e=t.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function en(t,e){if(!e.length)return!1;let s=!1,i=!1;for(let r=0;r<e.length;r++){let n=E0(t,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else s=!0,n&&(i=!0)}return i||!s}function y0(t,e,s){try{let i=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return s&&(i="\\/?"+i.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+i+"$","i").test(t)}catch{return!1}}function b0(t,e){try{let s=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),i=[[t.host,s.host,!1],[t.pathname,s.pathname,!0]];return s.hash&&i.push([t.hash,s.hash,!1]),s.searchParams.forEach((r,n)=>{i.push([t.searchParams.get(n)||"",r,!1])}),!i.some(r=>!y0(r[0],r[1],r[2]))}catch{return!1}}function E0(t,e,s){try{let i=new URL(t,"https://_");if(e==="regex"){let r=_a(s);return r?r.test(i.href)||r.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return b0(i,s);return!1}catch{return!1}}function kd(t,e,s){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=va(t);s=s||i,s.length!==t&&(s=i);let r=s.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(s=i);let n=0;return s.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function Ad(t,e,s){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=>{let[o]=n;return o===t}).map(n=>{let[,o]=n;return parseInt(o)});return r.length>0&&r[0]>=0&&r[0]<s?r[0]:null}function Id(t){try{return t()}catch(e){return console.error(e),!1}}async function es(t,e,s){if(e=e||"",s=s||globalThis.crypto&&globalThis.crypto.subtle||bd.SubtleCrypto,!s)throw new Error("No SubtleCrypto implementation found");try{let i=await s.importKey("raw",pa(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=t.split("."),o=await s.decrypt({name:"AES-CBC",iv:pa(r)},i,pa(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Ui(t){return typeof t=="string"?t:JSON.stringify(t)}function at(t){typeof t=="number"&&(t=t+""),(!t||typeof t!="string")&&(t="0");let e=t.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(s=>s.match(/^[0-9]+$/)?s.padStart(5," "):s).join("-")}function Rd(){let t;try{t="1.7.0"}catch{t=""}return t}function Td(t,e){let s,i;try{s=new URL(t),i=new URL(e)}catch(r){return console.error("Unable to merge query strings: ".concat(r)),e}return s.searchParams.forEach((r,n)=>{i.searchParams.has(n)||i.searchParams.set(n,r)}),i.toString()}function yd(t){return typeof t=="object"&&t!==null}function tn(t){return t.urlPatterns&&t.variations.some(e=>yd(e)&&"urlRedirect"in e)?"redirect":t.variations.some(e=>yd(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function sn(t,e){return new Promise(s=>{let i=!1,r,n=o=>{i||(i=!0,r&&clearTimeout(r),s(o||null))};e&&(r=setTimeout(()=>n(),e)),t.then(o=>n(o)).catch(()=>n())})}var bd,pa,Vi=et(()=>{"use strict";bd={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};pa=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0))});function Od(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),s.push.apply(s,i)}return s}function ma(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?Od(Object(s),!0).forEach(function(i){S0(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Od(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function S0(t,e,s){return(e=w0(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function w0(t){var e=k0(t,"string");return typeof e=="symbol"?e:e+""}function k0(t,e){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function xd(t){Object.assign(He,t),He.backgroundSync||ka()}async function Dd(t){let{instance:e,timeout:s,skipCache:i,allowStale:r,backgroundSync:n}=t;return n||(He.backgroundSync=!1),T0({instance:e,allowStale:r,timeout:s,skipCache:i})}function A0(t){let e=ji(t),s=Ks.get(e)||new Set;s.add(t),Ks.set(e,s)}function Nd(t){Ks.forEach(e=>e.delete(t))}function I0(){Ws.forEach(t=>{t&&(t.state="idle",Sa(t))})}function R0(){Ws.forEach(t=>{t&&t.state==="idle"&&wa(t)})}async function Cd(){try{if(!It.localStorage)return;await It.localStorage.setItem(He.cacheKey,JSON.stringify(Array.from(Vt.entries())))}catch{}}async function T0(t){let{instance:e,allowStale:s,timeout:i,skipCache:r}=t,n=ji(e),o=ba(e),a=new Date,l=new Date(a.getTime()-He.maxAge+He.staleTTL);await O0();let u=!He.disableCache&&!r?Vt.get(o):void 0;return u&&(s||u.staleAt>a)&&u.staleAt>l?(u.sse&&Js.add(n),u.staleAt<a?ya(e):Ea(e),{data:u.data,success:!0,source:"cache"}):await sn(ya(e),i)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function ji(t){let[e,s]=t.getApiInfo();return"".concat(e,"||").concat(s)}function ba(t){let e=ji(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;let s=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};i.forEach(a=>{r[a]=s[a]});let n=t.getForcedVariations(),o=t.getUrl();return"".concat(e,"||").concat(JSON.stringify({ca:r,fv:n,url:o}))}async function O0(){if(!Pd){Pd=!0;try{if(It.localStorage){let t=await It.localStorage.getItem(He.cacheKey);if(!He.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(s=>{let[i,r]=s;Vt.set(i,ma(ma({},r),{},{staleAt:new Date(r.staleAt)}))}),Ld()}}}catch{}if(!He.disableIdleStreams){let t=zs.startIdleListener();t&&(zs.stopIdleListener=t)}}}function Ld(){let t=Array.from(Vt.entries()).map(s=>{let[i,r]=s;return{key:i,staleAt:r.staleAt.getTime()}}).sort((s,i)=>s.staleAt-i.staleAt),e=Math.min(Math.max(0,Vt.size-He.maxEntries),Vt.size);for(let s=0;s<e;s++)Vt.delete(t[s].key)}function $d(t,e,s){let i=s.dateUpdated||"",r=new Date(Date.now()+He.staleTTL),n=He.disableCache?void 0:Vt.get(e);if(n&&i&&n.version===i){n.staleAt=r,Cd();return}He.disableCache||(Vt.set(e,{data:s,version:i,staleAt:r,sse:Js.has(t)}),Ld()),Cd();let o=Ks.get(t);o&&o.forEach(a=>P0(a,s))}async function P0(t,e){await t.setPayload(e||t.getPayload())}async function ya(t){let{apiHost:e,apiRequestHeaders:s}=t.getApiHosts(),i=t.getClientKey(),r="isRemoteEval"in t&&t.isRemoteEval(),n=ji(t),o=ba(t),a=rn.get(o);return a||(a=(r?zs.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:s}):zs.fetchFeaturesCall({host:e,clientKey:i,headers:s})).then(u=>{if(!u.ok)throw new Error("HTTP error: ".concat(u.status));return u.headers.get("x-sse-support")==="enabled"&&Js.add(n),u.json()}).then(u=>($d(n,o,u),Ea(t),rn.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(rn.delete(o),{data:null,source:"error",success:!1,error:u})),rn.set(o,a)),a}function Ea(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=ji(t),i=ba(t),{streamingHost:r,streamingHostRequestHeaders:n}=t.getApiHosts(),o=t.getClientKey();if(e&&Js.add(s),He.backgroundSync&&Js.has(s)&&It.EventSource){if(Ws.has(s))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let u=Ks.get(s);u&&u.forEach(c=>{ya(c)})}else if(l.type==="features"){let u=JSON.parse(l.data);$d(s,i,u)}a.errors=0}catch{Fd(a)}},errors:0,state:"active"};Ws.set(s,a),wa(a)}}function Fd(t){if(t.state!=="idle"&&(t.errors++,t.errors>3||t.src&&t.src.readyState===2)){let e=Math.pow(3,t.errors-3)*(1e3+Math.random()*1e3);Sa(t),setTimeout(()=>{["idle","active"].includes(t.state)||wa(t)},Math.min(e,3e5))}}function Sa(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,t.state==="active"&&(t.state="disabled"))}function wa(t){t.src=zs.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state="active",t.src.addEventListener("features",t.cb),t.src.addEventListener("features-updated",t.cb),t.src.onerror=()=>Fd(t),t.src.onopen=()=>{t.errors=0}}function C0(t,e){Sa(t),Ws.delete(e)}function ka(){Js.clear(),Ws.forEach(C0),Ks.clear(),zs.stopIdleListener()}function nn(t,e){if(e.streaming){if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&Ea(t,!0),A0(t)}}var He,It,zs,Ks,Pd,Vt,rn,Ws,Js,Md=et(()=>{"use strict";Vi();He={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},It=Ed(),zs={fetchFeaturesCall:t=>{let{host:e,clientKey:s,headers:i}=t;return It.fetch("".concat(e,"/api/features/").concat(s),{headers:i})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:s,payload:i,headers:r}=t,n={method:"POST",headers:ma({"Content-Type":"application/json"},r),body:JSON.stringify(i)};return It.fetch("".concat(e,"/api/eval/").concat(s),n)},eventSourceCall:t=>{let{host:e,clientKey:s,headers:i}=t;return i?new It.EventSource("".concat(e,"/sub/").concat(s),{headers:i}):new It.EventSource("".concat(e,"/sub/").concat(s))},startIdleListener:()=>{let t;if(!(typeof window<"u"&&typeof document<"u"))return;let s=()=>{document.visibilityState==="visible"?(window.clearTimeout(t),R0()):document.visibilityState==="hidden"&&(t=window.setTimeout(I0,He.idleStreamInterval))};return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(It.localStorage=globalThis.localStorage)}catch{}Ks=new Map,Pd=!1,Vt=new Map,rn=new Map,Ws=new Map,Js=new Set});function D0(t){return t==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}function cn(t){var e=un.get(t);return e||(e={element:t,attributes:{}},un.set(t,e)),e}function dn(t,e,s,i,r){var n=s(t),o={isDirty:!1,originalValue:n,virtualValue:n,mutations:[],el:t,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=s(t);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:s};return e==="position"&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,D0(e)),o}function hn(t,e){var s=e.getCurrentValue(e.el);e.virtualValue=t,t&&typeof t!="string"?(!s||t.parentNode!==s.parentNode||t.insertBeforeNode!==s.insertBeforeNode)&&(e.isDirty=!0,Bd()):t!==s&&(e.isDirty=!0,Bd())}function N0(t){var e=t.originalValue;t.mutations.forEach(function(s){return e=s.mutate(e)}),hn(W0(e),t)}function L0(t){var e=new Set(t.originalValue.split(/\s+/).filter(Boolean));t.mutations.forEach(function(s){return s.mutate(e)}),hn(Array.from(e).filter(Boolean).join(" "),t)}function $0(t){var e=t.originalValue;t.mutations.forEach(function(s){return e=s.mutate(e)}),hn(e,t)}function F0(t){var e=t.parentSelector,s=t.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var r=s?document.querySelector(s):null;return s&&!r?null:{parentNode:i,insertBeforeNode:r}}function M0(t){var e=t.originalValue;t.mutations.forEach(function(s){var i=s.mutate(),r=F0(i);e=r||e}),hn(e,t)}function Vd(t){var e=cn(t);return e.html||(e.html=dn(t,"html",B0,U0,N0)),e.html}function jd(t){var e=cn(t);return e.position||(e.position=dn(t,"position",V0,j0,M0)),e.position}function Gd(t){var e=cn(t);return e.classes||(e.classes=dn(t,"class",H0,G0,L0)),e.classes}function Hd(t,e){var s=cn(t);return s.attributes[e]||(s.attributes[e]=dn(t,e,q0(e),z0(e),$0)),s.attributes[e]}function K0(t,e){var s=un.get(t);if(s)if(e==="html"){var i,r;(i=s.html)==null||(r=i.observer)==null||r.disconnect(),delete s.html}else if(e==="class"){var n,o;(n=s.classes)==null||(o=n.observer)==null||o.disconnect(),delete s.classes}else if(e==="position"){var a,l;(a=s.position)==null||(l=a.observer)==null||l.disconnect(),delete s.position}else{var u,c,h;(u=s.attributes)==null||(c=u[e])==null||(h=c.observer)==null||h.disconnect(),delete s.attributes[e]}}function W0(t){return on||(on=document.createElement("div")),on.innerHTML=t,on.innerHTML}function an(t,e,s){if(s.isDirty){s.isDirty=!1;var i=s.virtualValue;s.mutations.length||K0(t,e),s.setValue(t,i)}}function J0(t,e){t.html&&an(e,"html",t.html),t.classes&&an(e,"class",t.classes),t.position&&an(e,"position",t.position),Object.keys(t.attributes).forEach(function(s){an(e,s,t.attributes[s])})}function Bd(){un.forEach(J0)}function Y0(t,e){var s=null;t.kind==="html"?s=Vd(e):t.kind==="class"?s=Gd(e):t.kind==="attribute"?s=Hd(e,t.attribute):t.kind==="position"&&(s=jd(e)),s&&(s.mutations.push(t),s.mutationRunner(s))}function X0(t,e){var s=null;if(t.kind==="html"?s=Vd(e):t.kind==="class"?s=Gd(e):t.kind==="attribute"?s=Hd(e,t.attribute):t.kind==="position"&&(s=jd(e)),!!s){var i=s.mutations.indexOf(t);i!==-1&&s.mutations.splice(i,1),s.mutationRunner(s)}}function qd(t){if(!(t.kind==="position"&&t.elements.size===1)){var e=new Set(t.elements),s=document.querySelectorAll(t.selector);s.forEach(function(i){e.has(i)||(t.elements.add(i),Y0(t,i))})}}function Q0(t){t.elements.forEach(function(e){return X0(t,e)}),t.elements.clear(),Ta.delete(t)}function Ud(){Ta.forEach(qd)}function Z0(){typeof document>"u"||(Aa||(Aa=new MutationObserver(function(){Ud()})),Ud(),Aa.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function fn(t){return typeof document>"u"?Ra:(Ta.add(t),qd(t),{revert:function(){Q0(t)}})}function Ia(t,e){return fn({kind:"html",elements:new Set,mutate:e,selector:t})}function zd(t,e){return fn({kind:"position",elements:new Set,mutate:e,selector:t})}function Gi(t,e){return fn({kind:"class",elements:new Set,mutate:e,selector:t})}function ln(t,e,s){return x0.test(e)?e==="class"||e==="className"?Gi(t,function(i){var r=s(Array.from(i).join(" "));i.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return i.add(n)})}):fn({kind:"attribute",attribute:e,elements:new Set,mutate:s,selector:t}):Ra}function eE(t){var e=t.selector,s=t.action,i=t.value,r=t.attribute,n=t.parentSelector,o=t.insertBeforeSelector;if(r==="html"){if(s==="append")return Ia(e,function(a){return a+(i??"")});if(s==="set")return Ia(e,function(){return i??""})}else if(r==="class"){if(s==="append")return Gi(e,function(a){i&&a.add(i)});if(s==="remove")return Gi(e,function(a){i&&a.delete(i)});if(s==="set")return Gi(e,function(a){a.clear(),i&&a.add(i)})}else if(r==="position"){if(s==="set"&&n)return zd(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(s==="append")return ln(e,r,function(a){return a!==null?a+(i??""):i??""});if(s==="set")return ln(e,r,function(){return i??""});if(s==="remove")return ln(e,r,function(){return null})}return Ra}var x0,Ra,un,Ta,B0,U0,V0,j0,G0,H0,q0,z0,on,Aa,tE,Kd,Wd=et(()=>{"use strict";x0=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Ra={revert:function(){}},un=new Map,Ta=new Set;B0=function(e){return e.innerHTML},U0=function(e,s){return e.innerHTML=s};V0=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},j0=function(e,s){s.insertBeforeNode&&!s.parentNode.contains(s.insertBeforeNode)||s.parentNode.insertBefore(e,s.insertBeforeNode)};G0=function(e,s){return s?e.className=s:e.removeAttribute("class")},H0=function(e){return e.className};q0=function(e){return function(s){var i;return(i=s.getAttribute(e))!=null?i:null}},z0=function(e){return function(s,i){return i!==null?s.setAttribute(e,i):s.removeAttribute(e)}};Z0();tE={html:Ia,classes:Gi,attribute:ln,position:zd,declarative:eE},Kd=tE});function ts(t,e,s){s=s||{};for(let[i,r]of Object.entries(e))switch(i){case"$or":if(!Xd(t,r,s))return!1;break;case"$nor":if(Xd(t,r,s))return!1;break;case"$and":if(!oE(t,r,s))return!1;break;case"$not":if(ts(t,r,s))return!1;break;default:if(!Hi(r,sE(t,i),s))return!1}return!0}function sE(t,e){let s=e.split("."),i=t;for(let r=0;r<s.length;r++)if(i&&typeof i=="object"&&s[r]in i)i=i[s[r]];else return null;return i}function Jd(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s="".concat(t).concat(e?"/i":"");return Oa[s]||(Oa[s]=new RegExp(t.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Oa[s]}function Hi(t,e,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(typeof t=="string")return i?String(e).toLowerCase()===t.toLowerCase():e+""===t;if(typeof t=="number")return e*1===t;if(typeof t=="boolean")return e!==null&&!!e===t;if(t===null)return e===null;if(Array.isArray(t)||!Qd(t))return JSON.stringify(e)===JSON.stringify(t);for(let r in t)if(!nE(r,e,t[r],s))return!1;return!0}function Qd(t){let e=Object.keys(t);return e.length>0&&e.filter(s=>s[0]==="$").length===e.length}function iE(t){if(t===null)return"null";if(Array.isArray(t))return"array";let e=typeof t;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function rE(t,e,s){if(!Array.isArray(t))return!1;let i=Qd(e)?r=>Hi(e,r,s):r=>ts(r,e,s);for(let r=0;r<t.length;r++)if(t[r]&&i(t[r]))return!0;return!1}function Ys(t,e){if(arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1){let i=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(t)?t.some(r=>e.some(n=>i(r)===i(n))):e.some(r=>i(t)===i(r))}return Array.isArray(t)?t.some(i=>e.includes(i)):e.includes(t)}function Yd(t,e,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Array.isArray(t))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<t.length;o++)if(Hi(e[r],t[o],s,i)){n=!0;break}if(!n)return!1}return!0}function nE(t,e,s,i){switch(t){case"$veq":return at(e)===at(s);case"$vne":return at(e)!==at(s);case"$vgt":return at(e)>at(s);case"$vgte":return at(e)>=at(s);case"$vlt":return at(e)<at(s);case"$vlte":return at(e)<=at(s);case"$eq":return e===s;case"$ne":return e!==s;case"$lt":return e<s;case"$lte":return e<=s;case"$gt":return e>s;case"$gte":return e>=s;case"$exists":return s?e!=null:e==null;case"$in":return Array.isArray(s)?Ys(e,s):!1;case"$ini":return Array.isArray(s)?Ys(e,s,!0):!1;case"$inGroup":return Ys(e,i[s]||[]);case"$notInGroup":return!Ys(e,i[s]||[]);case"$nin":return Array.isArray(s)?!Ys(e,s):!1;case"$nini":return Array.isArray(s)?!Ys(e,s,!0):!1;case"$not":return!Hi(s,e,i);case"$size":return Array.isArray(e)?Hi(s,e.length,i):!1;case"$elemMatch":return rE(e,s,i);case"$all":return Array.isArray(s)?Yd(e,s,i):!1;case"$alli":return Array.isArray(s)?Yd(e,s,i,!0):!1;case"$regex":try{return Jd(s).test(e)}catch{return!1}case"$regexi":try{return Jd(s,!0).test(e)}catch{return!1}case"$type":return iE(e)===s;default:return console.error("Unknown operator: "+t),!1}}function Xd(t,e,s){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(ts(t,e[i],s))return!0;return!1}function oE(t,e,s){for(let i=0;i<e.length;i++)if(!ts(t,e[i],s))return!1;return!0}var Oa,Zd=et(()=>{"use strict";Vi();Oa={}});function eh(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),s.push.apply(s,i)}return s}function Gt(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?eh(Object(s),!0).forEach(function(i){aE(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):eh(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function aE(t,e,s){return(e=lE(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function lE(t){var e=uE(t,"string");return typeof e=="symbol"?e:e+""}function uE(t,e){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function hE(t){let e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach((s,i)=>e.set(i,s)),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach((s,i)=>e.set(i,s)),e}function fE(t){return t.global.forcedVariations&&t.user.forcedVariations?Gt(Gt({},t.global.forcedVariations),t.user.forcedVariations):t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}async function Xs(t){try{await t()}catch{}}function th(t,e,s){if(t.user.trackedExperiments){let r=vn(e,s);if(t.user.trackedExperiments.has(r))return[];t.user.trackedExperiments.add(r)}t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({experiment:e,result:s,timestamp:Date.now().toString(),logType:"experiment"});let i=[];if(t.global.trackingCallback){let r=t.global.trackingCallback;i.push(Xs(()=>r(e,s,jt(t.user))))}if(t.user.trackingCallback){let r=t.user.trackingCallback;i.push(Xs(()=>r(e,s,jt(t.user))))}if(t.global.eventLogger){let r=t.global.eventLogger;i.push(Xs(()=>r(dE,{experimentId:e.key,variationId:s.key,hashAttribute:s.hashAttribute,hashValue:s.hashValue},jt(t.user))))}return i}function gE(t,e,s){if(t.user.trackedFeatureUsage){var i;let r=JSON.stringify(s.value);if(t.user.trackedFeatureUsage[e]===r)return;t.user.trackedFeatureUsage[e]=r,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:s,timestamp:Date.now().toString(),logType:"feature"}),(i=t.user.featureUsageSubs)!==null&&i!==void 0&&i.size&&t.user.featureUsageSubs.forEach(n=>{try{n(e,s)}catch(o){console.error(o)}})}if(t.global.onFeatureUsage){let r=t.global.onFeatureUsage;Xs(()=>r(e,s,jt(t.user)))}if(t.user.onFeatureUsage){let r=t.user.onFeatureUsage;Xs(()=>r(e,s))}if(t.global.eventLogger){let r=t.global.eventLogger;Xs(()=>r(cE,{feature:e,source:s.source,value:s.value,ruleId:s.source==="defaultValue"?"$default":s.ruleId||"",variationId:s.experimentResult?s.experimentResult.key:""},jt(t.user)))}}function gn(t,e){if(e.stack.evaluatedFeatures.has(t))return ss(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;let s=hE(e);if(s.has(t))return ss(e,t,s.get(t),"override");if(!e.global.features||!e.global.features[t])return ss(e,t,null,"unknownFeature");let i=e.global.features[t];if(i.rules){let n=new Set(e.stack.evaluatedFeatures);e:for(let o of i.rules){var r;if(o.parentConditions)for(let c of o.parentConditions){e.stack.evaluatedFeatures=new Set(n);let h=gn(c.id,e);if(h.source==="cyclicPrerequisite")return ss(e,t,null,"cyclicPrerequisite");let g={value:h.value};if(!ts(g,c.condition||{})){if(c.gate)return ss(e,t,null,"prerequisite");continue e}}if(o.filters&&sh(o.filters,e))continue;if("force"in o){if(o.condition&&!Da(o.condition,e)||!mE(e,o.seed||t,o.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!o.disableStickyBucketing?o.fallbackAttribute:void 0,o.range,o.coverage,o.hashVersion))continue;return o.tracks&&o.tracks.forEach(c=>{!th(e,c.experiment,c.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:c.experiment,result:c.result,user:jt(e.user)})}),ss(e,t,o.force,"force",o.id)}let a=(r=o.contextualVariations)!==null&&r!==void 0?r:o.variations;if(!a)continue;let l={variations:a,key:o.key||t};"coverage"in o&&(l.coverage=o.coverage),o.weights&&(l.weights=o.weights),o.hashAttribute&&(l.hashAttribute=o.hashAttribute),o.fallbackAttribute&&(l.fallbackAttribute=o.fallbackAttribute),o.disableStickyBucketing&&(l.disableStickyBucketing=o.disableStickyBucketing),o.bucketVersion!==void 0&&(l.bucketVersion=o.bucketVersion),o.minBucketVersion!==void 0&&(l.minBucketVersion=o.minBucketVersion),o.namespace&&(l.namespace=o.namespace),o.meta&&(l.meta=o.meta),o.ranges&&(l.ranges=o.ranges),o.name&&(l.name=o.name),o.phase&&(l.phase=o.phase),o.seed&&(l.seed=o.seed),o.hashVersion&&(l.hashVersion=o.hashVersion),o.filters&&(l.filters=o.filters),o.condition&&(l.condition=o.condition),o.contextualBanditRef&&_E(l,o.contextualBanditRef,t,e);let{result:u}=pn(l,t,e);if(l.contextualBandit&&!(u.hashUsed&&u.inExperiment)&&delete l.contextualBandit,e.global.onExperimentEval&&e.global.onExperimentEval(l,u),u.inExperiment&&!u.passthrough)return ss(e,t,u.value,"experiment",o.id,l,u)}}return ss(e,t,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function pn(t,e,s){let i=t.key,r=t.variations.length;if(r<2)return{result:Ae(s,t,-1,!1,e)};if(s.global.enabled===!1||s.user.enabled===!1)return{result:Ae(s,t,-1,!1,e)};if(t=yE(t,s),t.contextualBandit&&t.weights&&(t.contextualBandit=Gt(Gt({},t.contextualBandit),{},{variationWeights:t.weights})),t.urlPatterns&&!en(s.user.url||"",t.urlPatterns))return{result:Ae(s,t,-1,!1,e)};let n=Ad(i,s.user.url||"",r);if(n!==null)return{result:Ae(s,t,n,!1,e)};let o=fE(s);if(i in o){let v=o[i];return{result:Ae(s,t,v,!1,e)}}if(t.status==="draft"||t.active===!1)return{result:Ae(s,t,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Es(s,t.hashAttribute,s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!l)return{result:Ae(s,t,-1,!1,e)};let u=-1,c=!1,h=!1;if(s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{variation:v,versionIsBlocked:m}=SE({ctx:s,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});c=v>=0,u=v,h=!!m}if(!c){if(t.filters){if(sh(t.filters,s))return{result:Ae(s,t,-1,!1,e)}}else if(t.namespace&&!Sd(l,t.namespace))return{result:Ae(s,t,-1,!1,e)};if(t.include&&!Id(t.include))return{result:Ae(s,t,-1,!1,e)};if(t.condition&&!Da(t.condition,s))return{result:Ae(s,t,-1,!1,e)};if(t.parentConditions){let v=new Set(s.stack.evaluatedFeatures);for(let m of t.parentConditions){s.stack.evaluatedFeatures=new Set(v);let y=gn(m.id,s);if(y.source==="cyclicPrerequisite")return{result:Ae(s,t,-1,!1,e)};let w={value:y.value};if(!ts(w,m.condition||{}))return{result:Ae(s,t,-1,!1,e)}}}if(t.groups&&!EE(t.groups,s))return{result:Ae(s,t,-1,!1,e)}}if(t.url&&!bE(t.url,s))return{result:Ae(s,t,-1,!1,e)};let g=Bi(t.seed||i,l,t.hashVersion||1);if(g===null)return{result:Ae(s,t,-1,!1,e)};if(!c){let v=t.ranges||kd(r,t.coverage===void 0?1:t.coverage,t.weights);u=wd(g,v)}if(h)return{result:Ae(s,t,-1,!1,e,void 0,!0)};if(u<0)return{result:Ae(s,t,-1,!1,e)};if("force"in t)return{result:Ae(s,t,t.force===void 0?-1:t.force,!1,e)};if(s.global.qaMode||s.user.qaMode)return{result:Ae(s,t,-1,!1,e)};if(t.status==="stopped")return{result:Ae(s,t,-1,!1,e)};let f=Ae(s,t,u,!0,e,g,c);if(s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{changed:v,key:m,doc:y}=kE(s,a,Ui(l),{[Pa(t.key,t.bucketVersion)]:f.key});v&&(s.user.stickyBucketAssignmentDocs=s.user.stickyBucketAssignmentDocs||{},s.user.stickyBucketAssignmentDocs[m]=y,s.user.saveStickyBucketAssignmentDoc(y))}let p=th(s,t,f);p.length===0&&s.global.saveDeferredTrack&&s.global.saveDeferredTrack({experiment:t,result:f,user:jt(s.user)});let _=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in t&&t.changeId&&s.global.recordChangeId&&s.global.recordChangeId(t.changeId),{result:f,trackingCall:_}}function ss(t,e,s,i,r,n,o){let a={value:s,on:!!s,off:!s,source:i,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),i!=="override"&&gE(t,e,a),a}function xa(t){return Gt(Gt({},t.attributes),t.attributeOverrides)}function jt(t){return{attributes:xa(t),url:t.url}}function pE(t,e){for(let s of t.contexts||[])if(Da(s.condition||{},e))return{leafId:s.leafId,weights:s.weights};return null}function _E(t,e,s,i){var r,n;let o=(r=i.global.contextualBandits)===null||r===void 0?void 0:r[e];if(!o)return;let a=null;if(o.contexts&&o.contexts.length)try{a=pE(o,i)}catch{}if(a){t.weights=a.weights,t.contextualBandit={leafId:a.leafId,variationWeights:a.weights,banditVersion:o.banditVersion};return}t.contextualBandit={leafId:vE,variationWeights:(n=t.weights)!==null&&n!==void 0?n:va(t.variations.length),banditVersion:o.banditVersion}}function Da(t,e){return ts(xa(e.user),t,e.global.savedGroups||{})}function sh(t,e){return t.some(s=>{let{hashValue:i}=Es(e,s.attribute);if(!i)return!0;let r=Bi(s.seed,i,s.hashVersion||2);return r===null?!0:!s.ranges.some(n=>Zr(r,n))})}function mE(t,e,s,i,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=Es(t,s,i);if(!a)return!1;let l=Bi(e,a,o||1);return l===null?!1:r?Zr(l,r):n!==void 0?l<=n:!0}function Ae(t,e,s,i,r,n,o){let a=!0;(s<0||s>=e.variations.length)&&(s=0,a=!1);let{hashAttribute:l,hashValue:u}=Es(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),c=e.meta?e.meta[s]:{},h={key:c.key||""+s,featureId:r,inExperiment:a,hashUsed:i,variationId:s,value:e.variations[s],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};c.name&&(h.name=c.name),n!==void 0&&(h.bucket=n),c.passthrough&&(h.passthrough=c.passthrough);let g=e.contextualBandit;return g&&i&&a&&(h.leafId=g.leafId,h.variationWeights=g.variationWeights,g.banditVersion!==void 0&&(h.banditVersion=g.banditVersion)),h}function yE(t,e){let s=t.key,i=e.global.overrides;return i&&i[s]&&(t=Object.assign({},t,i[s]),typeof t.url=="string"&&(t.url=_a(t.url))),t}function Es(t,e,s){let i=e||"id",r="",n=xa(t.user);return n[i]&&(r=n[i]),!r&&s&&(n[s]&&(r=n[s]),r&&(i=s)),{hashAttribute:i,hashValue:r}}function bE(t,e){let s=e.user.url;if(!s)return!1;let i=s.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(t.test(s)||t.test(i))}function EE(t,e){let s=e.global.groups||{};for(let i=0;i<t.length;i++)if(s[t[i]])return!0;return!1}function SE(t){let{ctx:e,expKey:s,expBucketVersion:i,expHashAttribute:r,expFallbackAttribute:n,expMinBucketVersion:o,expMeta:a}=t;i=i||0,o=o||0,r=r||"id",a=a||[];let l=Pa(s,i),u=wE(e,r,n);if(o>0)for(let g=0;g<o;g++){let f=Pa(s,g);if(u[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=u[l];if(c===void 0)return{variation:-1};let h=a.findIndex(g=>g.key===c);return h<0?{variation:-1}:{variation:h}}function Pa(t,e){return e=e||0,"".concat(t,"__").concat(e)}function Ca(t,e){return"".concat(t,"||").concat(e)}function wE(t,e,s){if(!t.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:r}=Es(t,e),n=Ca(i,Ui(r)),{hashAttribute:o,hashValue:a}=Es(t,s),l=a?Ca(o,Ui(a)):null,u={};return l&&t.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[l].assignments||{}),t.user.stickyBucketAssignmentDocs[n]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[n].assignments||{}),u}function kE(t,e,s,i){let r=Ca(e,s),n=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[r]?t.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o=Gt(Gt({},n),i),a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:s,assignments:o},changed:a}}function AE(t,e){let s=new Set,i=e&&e.features?e.features:t.global.features||{},r=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(i).forEach(n=>{let o=i[n];if(o.rules)for(let a of o.rules)(a.variations||a.contextualVariations)&&(s.add(a.hashAttribute||"id"),a.fallbackAttribute&&s.add(a.fallbackAttribute))}),r.map(n=>{s.add(n.hashAttribute||"id"),n.fallbackAttribute&&s.add(n.fallbackAttribute)}),Array.from(s)}async function ih(t,e,s){let i=Na(t,s);return e.getAllAssignments(i)}function Na(t,e){let s={};return AE(t,e).forEach(r=>{let{hashValue:n}=Es(t,r);s[r]=Ui(n)}),s}async function rh(t,e,s){if(t=Gt({},t),t.encryptedFeatures){try{t.features=JSON.parse(await es(t.encryptedFeatures,e,s))}catch(i){console.error(i)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await es(t.encryptedExperiments,e,s))}catch(i){console.error(i)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await es(t.encryptedSavedGroups,e,s))}catch(i){console.error(i)}delete t.encryptedSavedGroups}if(t.encryptedContextualBandits){try{t.contextualBandits=JSON.parse(await es(t.encryptedContextualBandits,e,s))}catch(i){console.error(i)}delete t.encryptedContextualBandits}return t}function nh(t){let e=t.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(t.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}function vn(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}var cE,dE,vE,oh=et(()=>{"use strict";Zd();Vi();cE="Feature Evaluated",dE="Experiment Viewed";vE=-1});function ah(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),s.push.apply(s,i)}return s}function Rt(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?ah(Object(s),!0).forEach(function(i){RE(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):ah(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function RE(t,e,s){return(e=TE(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function TE(t){var e=OE(t,"string");return typeof e=="symbol"?e:e+""}function OE(t,e){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function PE(t,e){if(t==null)return{};var s,i,r=CE(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(i=0;i<n.length;i++)s=n[i],e.indexOf(s)===-1&&{}.propertyIsEnumerable.call(t,s)&&(r[s]=t[s])}return r}function CE(t,e){if(t==null)return{};var s={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;s[i]=t[i]}return s}var IE,Qs,xE,qi,lh=et(()=>{"use strict";Wd();Vi();Md();oh();IE=["data"];Qs=typeof window<"u"&&typeof document<"u",xE=Rd(),qi=class{constructor(e){if(e=e||{},this.version=xE,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._featureUsageSubs=new Set,this._customEventSubs=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 s=!1;try{s=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(s)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 s=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=i=>s.saveAssignments(i)}if(e.plugins)for(let s of e.plugins)s(this);if(e.features&&(this.ready=!0),Qs&&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 s in this._options.stickyBucketAssignmentDocs){let i=this._options.stickyBucketAssignmentDocs[s];i&&this._options.stickyBucketService.saveAssignments(i).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let s=await rh(e,this._options.decryptionKey);this._decryptedPayload=s,await this.refreshStickyBuckets(s),s.features&&(this._options.features=s.features),s.savedGroups&&(this._options.savedGroups=s.savedGroups),s.contextualBandits&&(this._options.contextualBandits=s.contextualBandits),s.experiments&&(this._options.experiments=s.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let s=e.payload;if(s.encryptedExperiments||s.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,s)),this._payload=s,this._decryptedPayload=s,s.features&&(this._options.features=s.features),s.savedGroups&&(this._options.savedGroups=s.savedGroups),s.contextualBandits&&(this._options.contextualBandits=s.contextualBandits),s.experiments&&(this._options.experiments=s.experiments,this._updateAllAutoExperiments()),this.ready=!0,nn(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&xd(e.cacheSettings),e.payload)return await this.setPayload(e.payload),nn(this,e),{success:!0,source:"init"};{let s=await this._refresh(Rt(Rt({},e),{},{allowStale:!0})),{data:i}=s,r=PE(s,IE);return nn(this,e),await this.setPayload(i||{}),r}}async loadFeatures(e){var s;e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:((s=this._options.backgroundSync)!==null&&s!==void 0?s:!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let s=await this._refresh(Rt(Rt({},e||{}),{},{allowStale:!1}));s.data&&await this.setPayload(s.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return nh(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(e){var s;let{timeout:i,skipCache:r,allowStale:n,streaming:o}=e;if(!this._options.clientKey)throw new Error("Missing clientKey");return Dd({instance:this,timeout:i,skipCache:r||this._options.disableCache,allowStale:n,backgroundSync:(s=o??this._options.backgroundSync)!==null&&s!==void 0?s:!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,s,i){let r=await es(e,s||this._options.decryptionKey,i);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,s,i){let r=await es(e,s||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(Rt(Rt({},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 Rt(Rt({},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)}}_subscribeFeatureUsage(e){return this._featureUsageSubs.add(e),()=>this._featureUsageSubs.delete(e)}_subscribeCustomEvents(e){return this._customEventSubs.add(e),()=>this._customEventSubs.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(s=>{try{s()}catch(i){console.error(i)}}),this._subscriptions.clear(),this._featureUsageSubs.clear(),this._customEventSubs.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,Nd(this),e.destroyAllStreams&&ka(),this.logs=[],Qs&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(s=>{s.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,s){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=s,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:s}=pn(e,null,this._getEvalContext());return this._onExperimentEval(e,s),s}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?Rt(Rt({},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,featureUsageSubs:this._featureUsageSubs,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,contextualBandits:this._options.contextualBandits,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,s){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=Ae(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=pn(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!s&&n.inExperiment&&i&&i.valueHash===a)return n;if(i&&this._undoActiveAutoExperiment(e),n.inExperiment){let u=tn(e);if(u==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?Td(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(en(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=c;let{navigate:h,delay:g}=this._getNavigateFunction();if(h)if(Qs){var l;Promise.all([...o?[sn(o,(l=this._options.maxNavigateDelay)!==null&&l!==void 0?l:1e3)]:[],new Promise(f=>{var p;return window.setTimeout(f,(p=this._options.navigateDelay)!==null&&p!==void 0?p:g)})]).then(()=>{try{h(c)}catch(f){console.error(f)}})}else try{h(c)}catch(f){console.error(f)}}else if(u==="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 s=this._activeAutoExperiments.get(e);s&&(s.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let s=this._options.experiments||[],i=new Set(s);this._activeAutoExperiments.forEach((r,n)=>{i.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of s){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&tn(r)==="redirect")break}}_onExperimentEval(e,s){let i=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:s}),this._subscriptions.size>0&&this._fireSubscriptions(e,s,i)}_fireSubscriptions(e,s,i){(!i||i.result.inExperiment!==s.inExperiment||i.result.variationId!==s.variationId)&&this._subscriptions.forEach(r=>{try{r(e,s)}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,s){let i=this.evalFeature(e).value;return i===null?s:i}feature(e){return this.evalFeature(e)}evalFeature(e){return gn(e,this._getEvalContext())}log(e,s){this.debug&&(this._options.log?this._options.log(e,s):console.log(e,s))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(s=>s&&s.experiment&&s.result).map(s=>[vn(s.experiment,s.result),s]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(s=>{!s||!s.experiment||!s.result?console.error("Invalid deferred tracking call",{call:s}):e.push(this._options.trackingCallback(s.experiment,s.result,s.user))}),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,s){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:s,timestamp:Date.now().toString(),logType:"event"}),this._customEventSubs.size&&this._customEventSubs.forEach(i=>{try{i(e,s||{})}catch(r){console.error(r)}}),this._options.eventLogger)try{await this._options.eventLogger(e,s||{},jt(this._getUserContext()))}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(vn(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(Qs?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let s=tn(e);if(s==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(i=>i.js))return!0}else if(s==="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}:Qs?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!Qs)return;let s=[];if(e.css){let i=document.createElement("style");i.innerHTML=e.css,document.head.appendChild(i),s.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),s.push(()=>i.remove())}return e.domMutations&&e.domMutations.forEach(i=>{s.push(Kd.declarative(i).revert)}),()=>{s.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let s=this._getEvalContext(),i=await ih(s,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=i}}generateStickyBucketAssignmentDocsSync(e,s){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let i=this._getEvalContext(),r=Na(i,s);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var uh=et(()=>{"use strict";lh()});var ch={};ho(ch,{Growthbook:()=>La});var ft,La,dh=et(()=>{"use strict";uh();da();$i();Mi();ft=class ft{constructor(e,s,i={},r=!1){this.analytics=new Gs;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Zt("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:s,user_language:i,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:u,url:c,domain:h,utm_content:g,residence_country:f,loggedIn:p,network_type:_,network_downlink:v,user_id:m,anonymous_id:y,account_mode:w})=>{let T={...this.GrowthBook.getAttributes(),id:e,...m!==void 0&&{user_id:m},...y!==void 0&&{anonymous_id:y},...s!==void 0&&{country:s},...f!==void 0&&{residence_country:f},...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},...u!==void 0&&{is_authorised:u},...c!==void 0&&{url:c},...h!==void 0&&{domain:h},...g!==void 0&&{utm_content:g},...p!==void 0&&{loggedIn:p},..._!==void 0&&{network_type:_},...v!==void 0&&{network_downlink:v},...w!==void 0&&{account_mode:w}};this.log("setAttributes | updating GrowthBook attributes",T),this.GrowthBook.setAttributes(T)};this.getFeatureValue=(e,s)=>{let i=this.GrowthBook.getFeatureValue(e,s);return this.log("getFeatureValue",{key:e,value:i,defaultValue:s}),i};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let s=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:s}),s};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let s=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:s}),s};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 qi({apiHost:id,clientKey:e,decryptionKey:s,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 s=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(s)}waitForIsLoaded(e=1e4){return new Promise((s,i)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),s()):Date.now()-r>=e&&(clearInterval(n),i(new Error("GrowthBook initialization timeout")))},100)})}};ft.getGrowthBookInstance=(e,s,i,r=!1)=>ft._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),ft._instance):(ft._instance=new ft(e,s??"",i,r),ft._instance),ft.resetInstance=()=>{ft._instance&&(ft._instance.destroy(),ft._instance=void 0)};La=ft});function Nf(t,e){if(t==null)return{};var s={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;s[i]=t[i]}return s}function k(){return k=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var s=arguments[e];for(var i in s)({}).hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},k.apply(null,arguments)}function hh(t,e,s,i,r,n,o){try{var a=t[n](o),l=a.value}catch(u){return void s(u)}a.done?e(l):Promise.resolve(l).then(i,r)}function ge(t){return function(){var e=this,s=arguments;return new Promise(function(i,r){var n=t.apply(e,s);function o(l){hh(n,i,r,o,a,"next",l)}function a(l){hh(n,i,r,o,a,"throw",l)}o(void 0)})}}function Lf(){return!(!b||b.navigator.onLine===!1)}function M(t,e){return t.indexOf(e)!==-1}function $f(t){var e,s=[];return(e=JSON.stringify(t,function(i,r){if(typeof r=="bigint")return r.toString();if(typeof r!="function"&&typeof r!="symbol"){if(r instanceof Error)return{name:r.name,message:r.message,stack:r.stack};if(r&&typeof r=="object"){for(;s.length>0&&s[s.length-1]!==this;)s.pop();if(s.includes(r))return"[Circular]";s.push(r)}return r}}))!==null&&e!==void 0?e:"null"}function Bf(t){return t===null||typeof t!="object"}function Un(t,e){return{}.toString.call(t)==="[object "+e+"]"}function mr(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Uf(t,Error)}}function eu(t){return"u">typeof Event&&Uf(t,Event)}function Uf(t,e){try{return t instanceof e}catch{return!1}}function xt(t,e,s,i,r){return e>s&&(i.warn("min cannot be greater than max."),e=s),Re(t)?t>s?(i.warn(" cannot be greater than max: "+s+". Using max value instead."),s):e>t?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(i.warn(" must be a number. using max or fallback. max: "+s+", fallback: "+r),xt(r??s,e,s,i))}function li(t){for(var e="",s=0;t.length>s;s++){var i=t.charCodeAt(s);if(55296>i||i>56319)e+=56320>i||i>57343?t[s]:"\uFFFD";else{var r=t.charCodeAt(s+1);56320>r||r>57343?e+="\uFFFD":(e+=t[s]+t[s+1],s++)}}return e}function Eh(t,e){return typeof(s=t)=="string"&&XE.test(s)?t:e();var s}function gg(t,e){var s=new Error(e);try{Object.defineProperty(s,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch{}return s}function ds(t){return t&&t.split("#")[0]}function su(t,e){var s=setTimeout(t,e);return s!=null&&s.unref&&s?.unref(),s}function Sh(t,e,s){return pg.apply(this,arguments)}function pg(){return(pg=ge(function*(t,e,s){var i;try{return yield Promise.race([t,new Promise((r,n)=>{i=su(()=>{try{s?.(),r()}catch(o){n(o)}},e)})])}finally{clearTimeout(i)}})).apply(this,arguments)}function QE(t){var e=globalThis._posthogChunkIds;if(e){var s=Object.keys(e);return Va&&s.length===bh?Va:(bh=s.length,Va=s.reduce((i,r)=>{mn||(mn={});var n=mn[r];if(n)i[n[0]]=n[1];else for(var o=t(r),a=o.length-1;a>=0;a--){var l,u=(l=o[a])==null?void 0:l.filename,c=e[r];if(u&&c){i[u]=c,mn[r]=[u,c];break}}return i},{}))}}function wl(t,e,s,i,r){var n={platform:t,filename:e,function:s==="<anonymous>"?"?":s,in_app:!!e&&!e.startsWith("webkit-masked-url://")&&e!=="<anonymous>"};return S(i)||(n.lineno=i),S(r)||(n.colno=r),n}function _g(t,e){e===void 0&&(e=40);var s=Object.keys(t);if(s.sort(),!s.length)return"[object has no keys]";for(var i=s.length;i>0;i--){var r=s.slice(0,i).join(", ");if(e>=r.length)return i===s.length?r:r.length>e?r.slice(0,e)+"...":r}return""}function zn(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:ja.enabled,max_bytes:yS(t.max_bytes,ja.max_bytes)}:k({},ja)}function yS(t,e){if(!Re(t)||t===1/0||t===-1/0)return e;var s=Math.floor(t);return 0>s?e:s}function Ah(t){return typeof t=="string"||t}function Ih(t){return typeof t=="string"?t:void 0}function Al(){return Al=ge(function*(t,e,s){e===void 0&&(e=!0);try{var i=new TextEncoder().encode(t),r=new globalThis.CompressionStream("gzip"),n=r.writable.getWriter(),o=n.write(i).then(()=>n.close()).catch((function(){var u=ge(function*(c){try{yield n.abort(c)}catch{}throw c});return function(c){return u.apply(this,arguments)}})()),a=new Response(r.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield ES(l,i),l}catch(u){if(s!=null&&s.rethrow)throw u;return e&&console.error("Failed to gzip compress data",u),null}}),Al.apply(this,arguments)}function Kn(t,e){try{return yg(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function iu(t,e,s,i){if(0>=s.remainingNodes)return{stringValue:Sl};if(s.remainingNodes--,Xe(t))return{boolValue:t};if(typeof t=="bigint")return(function(l,u){var c=l.toString(),h=BigInt("9223372036854775808");return l>=h||-h>l?(u?.debug("Attribute "+c+" is outside the int64 range; encoding it as a string"),{stringValue:c}):{intValue:c}})(t,e);if(typeof t=="number"){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var r=BigInt(t).toString();return t>=9223372036854776e3||-9223372036854776e3>t?(e?.debug("Attribute "+r+" is outside the int64 range; encoding it as a string"),{stringValue:r}):{intValue:r}}return{doubleValue:t}}if(typeof t=="string")return{stringValue:li(t)};if(typeof t=="function")return{stringValue:"[Function]"};if(typeof t=="symbol")return{stringValue:String(t)};if(typeof t=="object"&&t!==null){if(s.ancestors.has(t))return{stringValue:"[Circular]"};if(i>=20)return{stringValue:Sl};if(t instanceof Date){var n=t.getTime(),o=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:typeof o=="string"?li(o):String(o)}}s.ancestors.add(t);try{try{var a=t.toJSON;if(typeof a=="function")return iu(a.call(t),e,s,i+1)}catch{}return F(t)?{arrayValue:{values:wS(t,e,s,i+1)}}:{kvlistValue:{values:yg(t,e,s,i+1)}}}finally{s.ancestors.delete(t)}}return{stringValue:li(String(t))}}function wS(t,e,s,i){for(var r=[],n=Math.min(t.length,1e3),o=0;n>o&&s.remainingNodes>0;o++)try{var a=o in t?t[o]:void 0;if(H(a))continue;r.push(iu(a,e,s,i))}catch{r.push({stringValue:uo})}return t.length>o&&r.push({stringValue:Sl}),r}function yg(t,e,s,i){var r=[];for(var n in t)if(SS.call(t,n)){if(!n){e?.debug("Dropping an attribute with an empty key");continue}if(r.length>=1e3||0>=s.remainingNodes){e?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=t[n];if(Ie(o)||S(o))continue;r.push({key:li(n),value:iu(o,e,s,i)})}catch{r.push({key:li(n),value:{stringValue:uo}})}}return r}function bg(t,e,s){return k({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":s})}function AS(t){try{return li(String(t))}catch{return uo}}function IS(t,e,s,i){var r,n=Eg[t.level||"info"]||kS,o=n.text,a=n.number,l=((r=Re(i)?i:void 0)===void 0&&(r=Date.now()),String(r)+"000000"),u={};e.distinctId&&(u.posthogDistinctId=e.distinctId),e.sessionId&&(u.sessionId=e.sessionId),e.windowId&&(u["window.id"]=e.windowId),H(e.sessionStartTimestamp)||(u.sessionStartTimestamp=String(e.sessionStartTimestamp)),H(e.lastActivityTimestamp)||(u.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(u["url.full"]=e.currentUrl),e.screenName&&(u["screen.name"]=e.screenName),e.appState&&(u["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(u.feature_flags=e.activeFeatureFlags);var c=k({},u),h=t.attributes;if(h){var g=[];try{g=Object.keys(h)}catch{g=[]}for(var f of g){var p=void 0;try{p=h[f]}catch{p=uo}Object.defineProperty(c,f,{value:p,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:a,severityText:o,body:{stringValue:AS(t.body)},attributes:Kn(c,s)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),S(t.trace_flags)||(_.flags=t.trace_flags),_}function Sg(t,e,s){return bg(t,e,s)}function wg(t,e,s,i){return{resourceLogs:[{resource:{attributes:Kn(e)},scopeLogs:[{scope:{name:s,version:i},logRecords:t}]}]}}function Ph(t){return String(t)+"000000"}function Ch(t,e,s,i){var r="";return i&&(r=Object.keys(i).sort().map(n=>JSON.stringify(n)+":"+JSON.stringify(i[n])).join(",")),t+"\0"+e+"\0"+(s??"")+"\0"+r}function bn(t,e){F(t)&&t.forEach(e)}function ie(t,e){if(!H(t))if(F(t))t.forEach(e);else if((i=>i instanceof FormData)(t))t.forEach((i,r)=>e(i,r));else for(var s in t)Mf.call(t,s)&&e(t[s],s)}function $n(t){for(var e=Object.keys(t),s=e.length,i=new Array(s);s--;)i[s]=[e[s],t[e[s]]];return i}function Ug(t){var e=k({},t);for(var s of["name","message","stack","cause","errors"])try{s in t&&(e[s]=t[s])}catch{}return e}function ew(t){var e=t?.hostname;if(!Q(e))return!1;var s=e.split(".").slice(-2).join(".");for(var i of ZS)if(s===i)return!1;return!0}function ae(t,e,s,i){var r=i??{},n=r.capture,o=r.passive;t?.addEventListener(e,s,{capture:n!==void 0&&n,passive:o===void 0||o})}function Ul(t){return t.name==="ph_toolbar_internal"}function Gg(t,e){var s,i=t==null||(s=t.config)==null?void 0:s.get_current_url;if(!qe(i))return e;try{var r=i(e);return Q(r)&&r?r:e}catch(n){return I.error("Error in get_current_url, falling back to window.location.href",n),e}}function Bh(t){return t instanceof Element&&(t.id==="__POSTHOG_TOOLBAR__"||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function Dt(t){return!!t&&t.nodeType===1}function Ge(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Hg(t){return!!t&&t.nodeType===3}function du(t){return!!t&&t.nodeType===11&&Dt(t.host)}function hu(t){return t?no(t).split(/\s+/):[]}function Uh(t,e){var s=(function(i){var r,n=b==null||(r=b.location)==null?void 0:r.href;return S(n)?void 0:Gg(i,n)})(e);return!!(s&&t&&t.some(i=>s.match(i)))}function fi(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return hu(e)}function qg(t){return H(t)?null:no(t).split(/(\s+)/).filter(e=>ar(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function gr(t){var e="";return ci(t)&&!pr(t)&&t.childNodes&&t.childNodes.length&&ie(t.childNodes,function(s){var i;Hg(s)&&s.textContent&&(e+=(i=qg(s.textContent))!==null&&i!==void 0?i:"")}),no(e)}function or(t){var e;return S(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}function Hl(t,e){var s=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!s&&s.call(t,e)}catch{return!1}}function ql(t,e){if(S(e))return!0;var s,i=function(n){if(e.some(o=>Hl(n,o)))return{v:!0}};for(var r of t)if(s=i(r))return s.v;return!1}function zg(t){var e=t.parentNode;return!(!e||!Dt(e))&&e}function Wg(t,e){if(!b||gu(t))return!1;var s,i,r,n,o;if(Xe(e)?(s=!!e&&jh,i=void 0,r=!1):(s=(n=e?.css_selector_ignorelist)!==null&&n!==void 0?n:jh,i=e?.content_ignorelist,r=(o=e?.ignore_text_selection)!==null&&o!==void 0&&o),s===!1||r&&(function(l){return!(!l||!Dt(l))&&(!!Ge(l,"textarea")||(Ge(l,"input")?M(uw,(l.getAttribute("type")||"").toLowerCase()):(function(u){if(u.isContentEditable)return!0;var c=u.getAttribute==null?void 0:u.getAttribute("contenteditable");return c==="true"||c===""})(l)))})(t))return!1;var a=Jg(t,!1).targetElementList;return!(function(l,u){if(l===!1||S(l))return!1;var c;if(l===!0)c=Kg;else{if(!F(l))return!1;if(l.length>10)return I.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;c=l.map(h=>h.toLowerCase())}return u.some(h=>{var g=h.safeText,f=h.ariaLabel;return c.some(p=>Vh(g,p)||Vh(f,p))})})(i,a.map(l=>{var u;return{safeText:gr(l).toLowerCase(),ariaLabel:((u=l.getAttribute("aria-label"))==null?void 0:u.toLowerCase().trim())||""}}))&&!ql(a,s)}function ci(t){for(var e=new Set,s=0,i=t;i.parentNode&&!Ge(i,"body");i=i.parentNode){if(s++>=1e3||e.has(i))return!1;e.add(i);var r=fi(i);if(M(r,"ph-sensitive")||M(r,"ph-no-capture"))return!1}if(M(fi(t),"ph-include"))return!0;var n=t.type||"";if(Q(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!Q(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function pr(t){return!!(Ge(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Ge(t,"select")||Ge(t,"textarea")||t.getAttribute("contenteditable")==="true")}function hw(t){for(var e=0,s=!1,i=t.length-1;i>=0;i--){var r=t.charCodeAt(i)-48;s&&(r*=2)>9&&(r-=9),e+=r,s=!s}return e%10==0}function ar(t,e){return e===void 0&&(e=!0),!(H(t)||Q(t)&&(t=no(t),(e?Gh.test((t||"").replace(/[- ]/g,"")):(function(s){var i;for(Hh.lastIndex=0;i=Hh.exec(s);){var r=i[2];if(r)for(var n=r.replace(/[- ]/g,""),o=0;n.length>o;o++)for(var a of cw){var l=o+a;if(n.length>=l){var u=n.slice(o,l);if(Gh.test(u)&&hw(u))return!0}}}return!1})(t))||(e?dw.test(t):(function(s){var i;for(qh.lastIndex=0;i=qh.exec(s);){var r=i[1],n=i[3];if(!(r&&n&&zh.test(r)&&zh.test(n)))return!0}return!1})(t))))}function Kh(t){var e=gr(t);return ar(e=(e+" "+Yg(t)).trim())?e:""}function Yg(t){var e="";return t&&t.childNodes&&t.childNodes.length&&ie(t.childNodes,function(s){var i;if(s&&((i=s.tagName)==null?void 0:i.toLowerCase())==="span")try{var r=gr(s);e=(e+" "+r).trim(),s.childNodes&&s.childNodes.length&&(e=(e+" "+Yg(s)).trim())}catch(n){I.error("[AutoCapture]",n)}}),e}function Wh(t){return t.replace(/"|\\"/g,'\\"')}function fw(t){var e=t.attr__class;if(e)return F(e)?e:hu(e)}function Yh(t,e,s){s===void 0&&(s=!0);var i=t.config.segment;if(!i)return e();(function(r,n,o){var a=r.config.segment;if(!a)return n();var l=c=>{var h=()=>c.anonymousId()||St();r.config.get_device_id=h,o&&c.id()&&(r.register({distinct_id:c.id(),$device_id:h()}),r.persistence.set_property(je,sr)),n(o?void 0:c.anonymousId()||void 0)},u=a.user();"then"in u&&qe(u.then)?u.then(l):l(u)})(t,r=>{i.register(((n,o)=>{typeof Promise<"u"&&Promise.resolve||Sn.warn("This browser does not have Promise support, and can not use the segment integration");var a=(l,u)=>{if(!u)return l;var c=!!o&&l.event.anonymousId===o&&!l.event.userId;c||l.event.userId||l.event.anonymousId===n.get_distinct_id()||(Sn.info("No userId set, resetting PostHog"),n.reset()),c||(o=void 0),l.event.userId&&l.event.userId!==n.get_distinct_id()&&(Sn.info("UserId set, identifying with PostHog"),n.identify(l.event.userId));var h=n.calculateEventProperties(u,l.event.properties);return l.event.properties=Object.assign({},h,l.event.properties),l};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(l){return a(l,l.event.event)},page(l){return a(l,uu)},identify(l){return a(l,Bl)},screen(l){return a(l,"$screen")}}})(t,r)).then(()=>{e()},n=>{Sn.error("Failed to register the Segment integration",n),e()})},s)}function Qg(t,e){var s=e===void 0?{}:e,i=s.organization,r=s.projectId,n=s.prefix,o=s.severityAllowList,a=o===void 0?["error"]:o,l=s.sendExceptionsToPostHog,u=l===void 0||l;return c=>{var h,g,f,p,_,v;if(a!=="*"&&!a.includes(c.level)||!t.__loaded)return c;c.tags||(c.tags={});var m=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());c.tags["PostHog Person URL"]=m,t.sessionRecordingStarted()&&(c.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var y=((h=c.exception)==null?void 0:h.values)||[],w=y.map(T=>k({},T,{stacktrace:T.stacktrace?k({},T.stacktrace,{type:"raw",frames:(T.stacktrace.frames||[]).map(C=>k({},C,{platform:"web:javascript"}))}):void 0})),E={$exception_message:((g=y[0])==null?void 0:g.value)||c.message,$exception_type:(f=y[0])==null?void 0:f.type,$exception_level:c.level,$exception_list:w,$sentry_event_id:c.event_id,$sentry_exception:c.exception,$sentry_exception_message:((p=y[0])==null?void 0:p.value)||c.message,$sentry_exception_type:(_=y[0])==null?void 0:_.type,$sentry_tags:c.tags};return i&&r&&(E.$sentry_url=(n||"https://sentry.io/organizations/")+i+"/issues/?project="+r+"&query="+c.event_id),u&&((v=t.exceptions)==null||v.sendExceptionEvent(E)),c}}function tp(t,e,s){if(!A)return{};var i,r=e?[...vi,...s||[]]:[],n=sp(vr(A.URL,r,_r),t);return fe((i={},ie(bw,function(o){var a=Vl(o);i[o]=a||null}),i),n)}function sp(t,e){var s=yw.concat(e||[]),i={};return ie(s,function(r){var n=pi(t,r);i[r]=n||null}),i}function ip(t){var e=(function(n){return n?n.search("https?://(.*)google.([^/?]*)")===0?"google":n.search("https?://(.*)bing.com")===0?"bing":n.search("https?://(.*)yahoo.com")===0?"yahoo":n.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(t),s=e!="yahoo"?"q":"p",i={};if(!Ie(e)){i.$search_engine=e;var r=A?pi(A.referrer,s):"";r.length&&(i.ph_keyword=r)}return i}function Qh(){return navigator.language||navigator.userLanguage}function rp(){return A?.referrer||eo}function np(t,e,s){var i;s===void 0&&(s=!1);var r=t?[...vi,...e||[]]:[],n=(i=s?ds(Ee?.href):Ee?.href)==null?void 0:i.substring(0,1e3);return{r:rp().substring(0,1e3),u:n?vr(n,r,_r):void 0}}function op(t,e){var s;e===void 0&&(e=!1);var i=t.r,r=t.u,n=e?ds(r):r,o={$referrer:i,$referring_domain:i==null?void 0:i==eo?eo:(s=gi(i))==null?void 0:s.host};if(n){o.$current_url=n;var a=gi(n);o.$host=a?.host,o.$pathname=a?.pathname,fe(o,sp(n))}return i&&fe(o,ip(i)),o}function ap(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Ew(){try{return new Date().getTimezoneOffset()}catch{return}}function An(t){var e=!0;return{dispose(){if(e){e=!1;var s=t();s&&qe(s.then)&&s.then(void 0,()=>{})}}}}function Cw(t,e){e===void 0&&(e={});var s=(function(){var g=4294967295;return{p(f){for(var p=g,_=0;f.length>_;++_)p=Pw[255&p^f[_]]^p>>>8;g=p},d(){return 4294967295^g}}})(),i=t.length;s.p(t);var r,n,o,a,l,u,c=(a=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(g,f,p,_,v,m){var y=g.length,w=new ut(_+y+5*(1+Math.floor(y/7e3))+v),E=w.subarray(_,w.length-v),T=0;if(!f||8>y)for(var C=0;y>=C;C+=65535){var q=C+65535;y>q?T=Fn(E,T,g.subarray(C,q)):(E[C]=m,T=Fn(E,T,g.subarray(C,y)))}else{for(var x=Tw[f-1],le=x>>>13,D=8191&x,P=(1<<p)-1,G=new Qe(32768),N=new Qe(P+1),U=Math.ceil(p/3),ue=2*U,Oe=function(wi){return(g[wi]^g[wi+1]<<U^g[wi+2]<<ue)&P},he=new _i(25e3),oe=new Qe(288),O=new Qe(32),B=0,V=0,K=(C=0,0),J=0,W=0;y>C;++C){var Z=Oe(C),X=32767&C,se=N[Z];if(G[X]=se,N[Z]=X,C>=J){var xe=y-C;if((B>7e3||K>24576)&&xe>423){T=nf(g,E,0,he,oe,O,V,K,W,C-W,T),K=B=V=0,W=C;for(var Se=0;286>Se;++Se)oe[Se]=0;for(Se=0;30>Se;++Se)O[Se]=0}var j=2,Me=0,hs=D,De=X-se&32767;if(xe>2&&Z==Oe(C-De))for(var mi=Math.min(le,xe)-1,yi=Math.min(32767,C),bi=Math.min(258,xe);yi>=De&&--hs&&X!=se;){if(g[C+j]==g[C+j-De]){for(var ct=0;bi>ct&&g[C+ct]==g[C+ct-De];++ct);if(ct>j){if(j=ct,Me=De,ct>mi)break;var Ze=Math.min(De,ct-2),Ei=0;for(Se=0;Ze>Se;++Se){var Ds=C-De+Se+32768&32767,Ns=Ds-G[Ds]+32768&32767;Ns>Ei&&(Ei=Ns,se=Ds)}}}De+=(X=se)-(se=G[X])+32768&32767}if(Me){he[K++]=268435456|Kl[j]<<18|Wl[Me];var Si=31&Kl[j],Ls=31&Wl[Me];V+=pu[Si]+vu[Ls],++oe[257+Si],++O[Ls],J=C+j,++B}else he[K++]=g[C],++oe[g[C]]}}T=nf(g,E,m,he,oe,O,V,K,W,C-W,T),m||(T=Fn(E,T,Ow))}return hp(w,0,_+dp(T)+v)})(n=t,(o=e).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l,!u)),h=c.length;return(function(g,f){var p=f.filename;if(g[0]=31,g[1]=139,g[2]=8,g[8]=2>f.level?4:f.level==9?2:0,g[9]=3,f.mtime!=0&&nl(g,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),p){g[3]=8;for(var _=0;p.length>=_;++_)g[_+10]=p.charCodeAt(_)}})(c,e),nl(c,h-8,s.d()),nl(c,h-4,i),c}function Ep(){return(Ep=ge(function*(){var t=Fe?.userAgentData;if(t!=null&&t.getHighEntropyValues)try{var e,s=(e=yield t.getHighEntropyValues(["model"]))==null?void 0:e.model;return Q(s)&&s.length>0?s:void 0}catch(i){return void I.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",i)}})).apply(this,arguments)}function Bw(t,e){var s="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(s="$survey_"+e+"/"+t.id+"/"+t.current_iteration),s}function Sp(t){var e;return!((e=t.conditions)==null||(e=e.events)==null||(e=e.values)==null||!e.length)}function kp(t,e){return!t||Object.entries(t).every(s=>{var i=s[1],r=e?.[s[0]];if(r==null)return!1;var n=wp[i.operator];return!!n&&n(i.values,[String(r)])})}function al(t,e,s){return ai({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:s})}function hl(t,e){return e.length>t?e.slice(0,t)+"...":e}function sk(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!Dt(e));return e}function ik(t,e){var s,i,r=e.e,n=e.maskAllElementAttributes,o=e.maskAllText,a=e.elementAttributeIgnoreList,l=e.elementsChainAsString,u=e.disableCaptureUrlHashes;if(!Dt(t))return{props:{}};for(var c=[t],h=new Set([t]),g=t;g.parentNode&&!Ge(g,"body")&&1e3>c.length;)if(du(g.parentNode)){var f=g.parentNode.host;if(h.has(f))break;h.add(f),c.push(f),g=f}else{if(!Dt(g.parentNode)||h.has(g.parentNode))break;h.add(g.parentNode),c.push(g.parentNode),g=g.parentNode}var p=r.type==="click"&&t.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(D=>Ge(D,"button")||Ge(D,"a")):-1;p>0&&(o=o||c.slice(0,p+1).some(D=>!ci(D)||pr(D)));var _,v,m,y=[],w={},E=!1,T=!1;if(ie(c,D=>{var P=ci(D);if(Ge(D,"a")){var G=D.getAttribute("href");E=!!(P&&G&&ar(G))&&(u?ds(G):G)}M(fi(D),"ph-no-capture")&&(T=!0),y.push((function(N,U,ue,Oe,he){he===void 0&&(he=!1);var oe=N.tagName.toLowerCase(),O={tag_name:oe};fu.indexOf(oe)>-1&&!ue&&(O.$el_text=oe.toLowerCase()==="a"||oe.toLowerCase()==="button"?hl(1024,Kh(N)):hl(1024,gr(N)));var B=fi(N);B.length>0&&(O.classes=B.filter(function(W){return W!==""})),ie(N.attributes,function(W){var Z;if((!pr(N)||["name","id","class","aria-label"].indexOf(W.name)!==-1)&&(Oe==null||!Oe.includes(W.name))&&!U&&ar(W.value)&&(!Q(Z=W.name)||Z.substring(0,10)!=="_ngcontent"&&Z.substring(0,7)!=="_nghost")){var X=W.value;W.name==="class"&&(X=hu(X).join(" ")),O["attr__"+W.name]=hl(1024,W.name==="href"&&he?ds(X):X)}});for(var V=1,K=1,J=N;J=sk(J);)V++,J.tagName===N.tagName&&K++;return O.nth_child=V,O.nth_of_type=K,O})(D,n,o,a,u)),ie((function(N){if(!ci(N))return{};var U={};return ie(N.attributes,function(ue){if(ue.name&&ue.name.indexOf("data-ph-capture-attribute")===0){var Oe=ue.name.replace("data-ph-capture-attribute-",""),he=ue.value;Oe&&he&&ar(he)&&(U[Oe]=he)}}),U})(D),(N,U)=>{({}).hasOwnProperty.call(w,U)||(w[U]=N)})}),T)return{props:{},explicitNoCapture:T};if(p>0&&(t=c[p],y.splice(0,p)),o||(y[0].$el_text=Ge(t,"a")||Ge(t,"button")?Kh(t):gr(t)),E){var C,q;y[0].attr__href=E;var x=(C=gi(E))==null?void 0:C.host,le=b==null||(q=b.location)==null?void 0:q.host;x&&le&&x!==le&&(_=E)}return{props:fe((v=r.type,{$event_type:v,$ce_version:1}),l?{}:{$elements:y},{$elements_chain:(m=y,F(m)?(function(D){return D.map(P=>{var G,N,U="";if(P.tag_name&&(U+=P.tag_name),P.attr_class)for(var ue of(P.attr_class.sort(),P.attr_class))U+="."+ue.replace(/"/g,"");var Oe=k({},P.text?{text:P.text}:{},{"nth-child":(G=P.nth_child)!==null&&G!==void 0?G:0,"nth-of-type":(N=P.nth_of_type)!==null&&N!==void 0?N:0},P.href?{href:P.href}:{},P.attr_id?{attr_id:P.attr_id}:{},P.attributes),he={};return $n(Oe).sort((oe,O)=>{return(V=O[0])>(B=oe[0])?-1:B>V?1:0;var B,V}).forEach(oe=>{var O=oe[1];return he[Wh(oe[0].toString())]=Wh(O.toString())}),(U+=":")+$n(he).map(oe=>oe[0]+'="'+oe[1]+'"').join("")}).join(";")})((function(D){return D.map(P=>{var G,N,U={text:(G=P.$el_text)==null?void 0:G.slice(0,400),tag_name:P.tag_name,href:(N=P.attr__href)==null?void 0:N.slice(0,2048),attr_class:fw(P),attr_id:P.attr__id,nth_child:P.nth_child,nth_of_type:P.nth_of_type,attributes:{}};return $n(P).filter(ue=>ue[0].indexOf("attr__")===0).forEach(ue=>U.attributes[ue[0]]=ue[1]),U})})(m)):"")},(s=y[0])!=null&&s.$el_text?{$el_text:(i=y[0])==null?void 0:i.$el_text}:{},_&&r.type==="click"?{$external_click_url:_}:{},w),target:t}}function Op(t,e,s){try{if(!(e in t))return pf;var i={next:t[e]},r=s(function(){for(var n=arguments.length,o=new Array(n),a=0;n>a;a++)o[a]=arguments[a];return i.next.apply(this,o)});return qe(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:i}})),t[e]=r,()=>{if(t[e]!==r)for(var n=t[e],o=vf(n);o;){if(o.next===r)return void(o.next=i.next);o=vf(n=o.next)}else t[e]=i.next}}catch{return pf}}function fl(t){return Y(t)&&"clientX"in t&&"clientY"in t&&Re(t.clientX)&&Re(t.clientY)}function ri(t,e,s){if(H(t))return!1;switch(s){case"exact":return t===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}function Cf(t,e){var s,i,r,n,o,a,l,u=(s=t?.flushIntervalMs)!==null&&s!==void 0?s:3e3,c=(i=t?.maxBufferSize)!==null&&i!==void 0?i:100,h=e!=null&&e.consoleCapture?void 0:(r=t?.maxLogsPerInterval)!==null&&r!==void 0?r:1e3,g=S(h)?Math.max(c,2048):Math.max(c,h),f=k({},(function(){var p="",_="";try{var v=Fe?.userAgent;if(v){var m=fg(v);p=m[0],_=m[1]}}catch{}return(function(y,w){var E=(function(T){if(T)return{}.hasOwnProperty.call(Oh,T)?Oh[T]:T})(y);return k({},E?{"os.name":E}:{},w?{"os.version":w}:{})})(p,_)})(),t?.resourceAttributes);return{serviceName:(n=(o=f?.["service.name"])!==null&&o!==void 0?o:t?.serviceName)!==null&&n!==void 0?n:e?.serviceNameDefault,serviceVersion:(a=f?.["service.version"])!==null&&a!==void 0?a:t?.serviceVersion,environment:(l=f?.["deployment.environment"])!==null&&l!==void 0?l:t?.environment,resourceAttributes:f,beforeSend:t?.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:g,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var _n,DE,NE,b,ze,Fe,A,Ee,dr,Zl,fh,LE,Ye,zi,L,gh,Yt,$E,ph,no,_l,Pt,ml,FE,ME,Ff,Mf,oo,F,qe,Y,nt,S,Q,rr,Ie,H,Re,zt,Xe,BE,UE,VE,$a,jE,GE,di,hr,Vn,Vf,jf,Gf,Pn,ao,Hf,Cn,qf,zf,Kf,Wf,Jf,xn,Yf,jn,Gn,lo,Xf,Qf,Fa,Zf,vh,yl,HE,eg,bl,tg,sg,ig,rg,ng,og,ag,El,lg,ug,cg,dg,Ma,Ba,qE,zE,KE,tu,WE,hg,JE,YE,_h,fg,mh,Ua,yh,Sl,uo,mn,bh,Va,XE,ZE,vg,eS,tS,sS,iS,rS,nS,oS,wh,aS,lS,uS,cS,dS,hS,fS,gS,pS,vS,Hn,qn,_S,ja,mS,kh,Ki,bS,mg,kl,Rh,Th,yn,ES,SS,Oh,Eg,kS,RS,Ga,TS,kg,I,Te,OS,Wn,Rs,Ha,xh,Le,PS,bt,ru,qa,Jn,CS,za,Et,Il,Rl,Tl,Ol,Ag,Pl,Cl,nu,ou,xl,Ig,ui,xS,Rg,Tg,Og,Pg,Cg,ni,au,DS,NS,LS,$S,FS,pt,Ct,Dl,Ps,as,Cs,nr,Ot,Ts,Wt,ls,xg,Nl,Yn,Ll,Dn,Nn,Ln,MS,BS,US,VS,jS,GS,us,tr,fr,cs,je,$l,Dg,Ng,Lg,oi,lu,Ka,$g,Fg,Mg,Fl,HS,qS,zS,KS,WS,JS,YS,XS,Ml,os,sr,Bg,hi,Xn,uu,Dh,Bl,Nh,fe,Lh,QS,cu,ZS,Vl,tw,sw,Vg,$h,iw,St,rw,Wi,nw,Zs,be,Wa,ee,Ja,Os,Qn,ow,Ya,Xa,jg,Fh,Mh,Qa,ei,Gl,Ss,de,aw,fu,Za,Kg,lw,Vh,jh,uw,gu,Jg,Gh,Hh,cw,dw,qh,zh,En,gw,pw,Jh,Sn,Xg,vw,Xh,Ji,_w,mw,Be,ai,gi,pi,vr,Zn,Zg,ep,vi,yw,_r,bw,eo,Sw,ww,wn,kn,Ne,Kt,el,is,ti,Zh,tl,lt,Yi,sl,Jt,il,zl,kw,ef,tf,Aw,rs,lp,ut,Qe,_i,pu,vu,sf,up,cp,Kl,ws,Wl,to,_e,lr,xs,so,Iw,Rw,dp,hp,Ht,Xi,rl,Jl,rf,Qi,Fn,nf,Tw,Ow,Pw,nl,xw,fp,Mn,gp,yr,ol,pp,vp,Dw,Nw,_p,mp,yp,Yl,of,Bn,Lw,$w,Fw,Mw,af,io,si,lf,uf,bp,ro,In,wp,Xl,cf,Uw,Vw,jw,ne,Ap,Gw,Hw,qw,zw,Kw,Ww,Jw,df,Yw,ur,ll,cr,hf,Zi,ff,Ip,Xw,ul,Qw,ir,Rp,Zw,cl,ek,gf,tk,_u,Tp,dl,Rn,rk,nk,er,pf,vf,ok,ks,_f,mf,ak,lk,Tn,yf,qt,uk,On,gl,Tt,bf,Pp,ii,Ef,ck,dk,hk,fk,gk,pk,vk,Sf,wf,kf,_k,Af,As,pl,If,Rf,Tf,Of,yt,Ql,mk,yk,bk,Pf,Ek,gt,Is,Sk,xf,Cp,vl,Df,co,wk,kk,Ak,Ik,Rk,Tk,Ok,Pk,Ck,xk,Dk,Ce,xp=et(()=>{"use strict";DE=["retriesPerformedSoFar"],NE=["$set_once","$set"];b="u">typeof window?window:void 0,ze="u">typeof globalThis?globalThis:b,Fe=ze?.navigator,A=ze?.document,Ee=ze?.location,dr=ze?.fetch,Zl=ze!=null&&ze.XMLHttpRequest&&"withCredentials"in new ze.XMLHttpRequest?ze.XMLHttpRequest:void 0,fh=ze?.AbortController,LE=ze?.CompressionStream,Ye=Fe?.userAgent;zi=typeof globalThis<"u"?globalThis:b;zi&&typeof self>"u"&&(zi.self=zi),zi&&typeof File>"u"&&(zi.File=function(){});L=b??{},gh="0.8.2",Yt={DEBUG:!1,LIB_VERSION:gh,LIB_NAME:"browser-common",JS_SDK_VERSION:gh},$E=["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","pinterestbot","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"],ph=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var s=t.toLowerCase();return $E.concat(e).some(i=>{var r=i.toLowerCase();return s.indexOf(r)!==-1})};no=function(t){return t.trim()},_l=function(t){return t.replace(/^\$/,"")};Pt=(function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t})({}),ml=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({}),FE=["$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"],ME=["token"],Ff=Object.prototype,Mf=Ff.hasOwnProperty,oo=Ff.toString,F=Array.isArray||function(t){return oo.call(t)==="[object Array]"},qe=t=>typeof t=="function",Y=t=>t===Object(t)&&!F(t),nt=t=>{if(Y(t)){for(var e in t)if(Mf.call(t,e))return!1;return!0}return!1},S=t=>t===void 0,Q=t=>oo.call(t)=="[object String]",rr=t=>Q(t)&&t.trim().length===0,Ie=t=>t===null,H=t=>S(t)||Ie(t),Re=t=>oo.call(t)=="[object Number]"&&t==t,zt=t=>Re(t)&&t>0,Xe=t=>oo.call(t)==="[object Boolean]",BE=t=>M(FE,t),UE=t=>M(ME,t);VE=[!0,"true",1,"1","yes"],$a=t=>M(VE,t),jE=[!1,"false",0,"0","no"];GE=class{constructor(t){this.C={},this.I=t.I,this.R=xt(t.bucketSize,0,100,t.A),this.O=xt(t.refillRate,0,this.R,t.A),this.N=xt(t.refillInterval,0,864e5,t.A)}F(t,e){var s=Math.floor((e-t.lastAccess)/this.N);s>0&&(t.tokens=Math.min(t.tokens+s*this.O,this.R),t.lastAccess=t.lastAccess+s*this.N)}consumeRateLimit(t){var e,s=Date.now(),i=String(t),r=this.C[i];return r?this.F(r,s):this.C[i]=r={tokens:this.R,lastAccess:s},r.tokens===0||(r.tokens--,r.tokens===0&&((e=this.I)==null||e.call(this,t)),r.tokens===0)}stop(){this.C={}}},di="Mobile",hr="Android",Vn="Tablet",Vf="Android Tablet",jf="iPad",Gf="Apple Watch",Pn="Safari",ao="BlackBerry",Hf="Samsung Internet",Cn="Chrome",qf="Chrome iOS",zf="Internet Explorer",Kf="Internet Explorer Mobile",Wf="Opera",Jf="Microsoft Edge",xn="Firefox",Yf="Firefox iOS",jn="Nintendo",Gn="PlayStation",lo="Xbox",Xf="Android Mobile",Qf="Mobile Safari",Fa="Windows",Zf="Windows Phone",vh="Nokia",yl="Ouya",HE="Generic "+di.toLowerCase(),eg="Generic "+Vn.toLowerCase(),bl="Konqueror",tg="Oculus Browser",sg="Vivaldi",ig="Yandex",rg="Whale",ng="DuckDuckGo",og="Pale Moon",ag="Waterfox",El="Brave",lg="Claude",ug="Codex",cg="ChatGPT",dg="Google Search App",Ma=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ba=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),qE=new RegExp(lo,"i"),zE=new RegExp("PlayStation \\w+","i"),KE=new RegExp("Nintendo \\w+","i"),tu=new RegExp("BlackBerry|PlayBook|BB10","i"),WE={"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"},hg=function(t,e,s,i){e=e||"";var r=(function(n){return n!=null&&n.brave?El:null})(s);return r||(i!=null&&i.detectGoogleSearchApp&&M(t,"GSA/")?dg:M(t," OPR/")&&M(t,"Mini")?"Opera Mini":M(t," OPR/")?Wf:tu.test(t)?ao:M(t,"IEMobile")||M(t,"WPDesktop")?Kf:M(t,"OculusBrowser")?tg:M(t,"SamsungBrowser")?Hf:M(t,"Edge")||M(t,"Edg/")?Jf:M(t,"Vivaldi/")?sg:M(t,"YaBrowser/")?ig:M(t,"Whale/")?rg:M(t,"DuckDuckGo/")||M(t,"Ddg/")?ng:M(t,"Claude/")?lg:M(t,"Codex/")?ug:M(t,"ChatGPT/")?cg:M(t,"FBIOS")?"Facebook Mobile":M(t,"UCWEB")||M(t,"UCBrowser")?"UC Browser":M(t,"CriOS")?qf:M(t,"CrMo")||M(t,Cn)?Cn:M(t,hr)&&M(t,Pn)?Xf:M(t,"FxiOS")?Yf:M(t.toLowerCase(),bl.toLowerCase())?bl:M(t,"Brave/")?El:((n,o)=>o&&M(o,"Apple")||(function(a){return M(a,Pn)&&!M(a,Cn)&&!M(a,hr)})(n))(t,e)?M(t,di)?Qf:Pn:M(t,"PaleMoon/")?og:M(t,"Waterfox/")?ag:M(t,xn)?xn:M(t,"MSIE")||M(t,"Trident/")?zf:M(t,"Gecko")?xn:"")},JE={[Kf]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[Jf]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Cn]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[qf]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Pn]:[Ma],[Qf]:[Ma],[Wf]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[xn]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[Yf]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[bl]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[ao]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ma],[Xf]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Hf]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[tg]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[sg]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[ig]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[rg]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[El]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[lg]:[Ba],[ug]:[Ba],[cg]:[Ba],[ng]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[og]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[ag]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[dg]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[zf]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},YE=function(t,e,s,i){var r=JE[hg(t,e,s,i)];if(S(r))return null;for(var n=0;r.length>n;n++){var o=t.match(r[n]);if(o)return parseFloat(o[o.length-2])}return null},_h=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[lo,t&&t[1]||""]],[new RegExp(jn,"i"),[jn,""]],[new RegExp(Gn,"i"),[Gn,""]],[tu,[ao,""]],[new RegExp(Fa,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Zf,""];if(new RegExp(di).test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];var s=/Windows NT ([0-9.]+)/i.exec(e);if(s&&s[1]){var i=WE[s[1]]||"";return/arm/i.test(e)&&(i="RT"),[Fa,i]}return[Fa,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=S(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[hr,[t[2],t[3],t[4]||"0"].join(".")]:[hr,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],fg=function(t){for(var e=0;_h.length>e;e++){var s=_h[e],i=s[1],r=s[0].exec(t),n=r&&(qe(i)?i(r,t):i);if(n)return n}return["",""]},mh=function(t){return KE.test(t)?jn:zE.test(t)?Gn:qE.test(t)?lo:new RegExp(yl,"i").test(t)?yl:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?Zf:/iPad/.test(t)?jf:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Gf:tu.test(t)?ao:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(vh,"i").test(t)?vh:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(di).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?hr:Vf:new RegExp("(pda|Mobile)","i").test(t)?HE:new RegExp(Vn,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?eg:""},Ua=/\bFBAV\/(\d+(?:\.\d+)*)/i,yh=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Ua],[/\bFBAN\/EMA\b/i,"Facebook Lite",Ua],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Ua],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Sl="[Truncated]",uo="[Unserializable]";XE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;ZE=class{constructor(t,e,s){s===void 0&&(s=[]),this.coercers=t,this.stackParser=e,this.modifiers=s}buildFromUnknown(t,e){e===void 0&&(e={});var s=e&&e.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(s,e,0).apply(t),r=this.buildParsingContext(e),n=this.parseStacktrace(i,r);return{$exception_list:this.convertToExceptionList(n,s),$exception_level:"error"}}modifyFrames(t){var e=this;return ge(function*(){for(var s of t)s.stacktrace&&s.stacktrace.frames&&F(s.stacktrace.frames)&&(s.stacktrace.frames=yield e.applyModifiers(s.stacktrace.frames));return t})()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:(e=t.syntheticException)==null?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var s,i;return t.cause!=null&&(s=this.parseStacktrace(t.cause,e)),t.stack!=""&&t.stack!=null&&(i=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),k({},t,{cause:s,stack:i})}applyChunkIds(t,e){return t.map(s=>(s.filename&&e&&(s.chunk_id=e[s.filename]),s))}applyCoercers(t,e){for(var s of this.coercers)if(s.match(t))return s.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return ge(function*(){var s=t;for(var i of e.modifiers)s=yield i(s);return s})()}convertToExceptionList(t,e){var s,i,r,n={type:t.type,value:t.value,mechanism:{type:(s=e.type)!==null&&s!==void 0?s:"generic",handled:(i=e.handled)===null||i===void 0||i,synthetic:(r=t.synthetic)!==null&&r!==void 0&&r}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});var o=[n];return t.cause!=null&&o.push(...this.convertToExceptionList(t.cause,k({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:QE(this.stackParser),skipFirstLines:(e=t.skipFirstLines)!==null&&e!==void 0?e:1}}buildCoercingContext(t,e,s){s===void 0&&(s=0);var i=(r,n)=>{if(4>=n){var o=this.buildCoercingContext(t,e,n);return this.applyCoercers(r,o)}};return k({},e,{syntheticException:s==0?e.syntheticException:void 0,mechanism:t,apply:r=>i(r,s),next:r=>i(r,s+1)})}};vg=(t,e)=>{var s=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return s||i?[t.indexOf("@")!==-1?t.split("@")[0]:"?",s?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},eS=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,tS=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,sS=/\((\S*)(?::(\d+))(?::(\d+))\)/,iS=(t,e)=>{var s=eS.exec(t);if(s)return wl(e,s[1],"?",+s[2],+s[3]);var i=tS.exec(t);if(i){if(i[2]&&i[2].indexOf("eval")===0){var r=sS.exec(i[2]);r&&(i[2]=r[1],i[3]=r[2],i[4]=r[3])}var n=vg(i[1]||"?",i[2]);return wl(e,n[1],n[0],i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},rS=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,nS=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,oS=(t,e)=>{var s=rS.exec(t);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){var i=nS.exec(s[3]);i&&(s[1]=s[1]||"eval",s[3]=i[1],s[4]=i[2],s[5]="")}var r=s[3],n=s[1]||"?",o=vg(n,r);return wl(e,r=o[1],n=o[0],s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},wh=/\(error: (.*)\)/,aS=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var s=Q(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:s?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return Un(t,"DOMException")}isDOMError(t){return Un(t,"DOMError")}},lS=class{match(t){return mr(t)}coerce(t,e){var s,i=this.getStack(t),r=i===void 0;return{type:this.getType(t),value:this.getMessage(t,e),stack:i??((s=e.syntheticException)==null?void 0:s.stack),cause:t.cause?e.next(t.cause):void 0,synthetic:r}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var s=t.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(t){return t.stacktrace||t.stack||void 0}},uS=class{match(t){return!!Un(t,"ErrorEvent")&&(t.error!=null||this.an(t))}coerce(t,e){var s;if(t.error!=null)return e.apply(t.error);var i=e.apply(t.message);return k({},i,{stack:(s=this.sn(t))!==null&&s!==void 0?s:i.stack,synthetic:!0})}an(t){return Q(t.message)&&t.message.length>0}sn(t){var e,s,i=t,r=(e=i.lineno)!==null&&e!==void 0?e:0,n=(s=i.colno)!==null&&s!==void 0?s:0;if(Q(i.filename)&&i.filename.length!==0&&r!==0)return`Error
6
- at `+i.filename+":"+r+":"+n}},cS=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,dS=class{match(t){return typeof t=="string"}coerce(t,e){var s,i=this.getInfos(t),r=i[0],n=i[1];return{type:r??"Error",value:n??t,stack:(s=e.syntheticException)==null?void 0:s.stack,synthetic:!0}}getInfos(t){var e="Error",s=t,i=t.match(cS);return i&&(e=i[1],s=i[2]),[e,s]}},hS=["fatal","error","warning","log","info","debug"];fS=class{match(t){return typeof t=="object"&&t!==null}coerce(t,e){var s,i,r=this.getErrorPropertyFromObject(t);return r?e.apply(r):{type:this.getType(t),value:this.getValue(t),stack:(s=this.getStack(t))!==null&&s!==void 0?s:(i=e.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(eu(t))return t.constructor.name;var e="name"in t?t.name:void 0;return Q(e)&&!rr(e)?e:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){var e="'"+t.name+"' captured as exception";return"message"in t&&typeof t.message=="string"&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&typeof t.message=="string")return t.message;var s=this.getObjectClassName(t);return(s&&s!=="Object"?"'"+s+"'":"Object")+" captured as exception with keys: "+_g(t)}isSeverityLevel(t){return Q(t)&&!rr(t)&&hS.indexOf(t)>=0}getStack(t){try{return Q(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:Q(t.stack)&&t.stack.length>0?t.stack:void 0}catch{return}}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var s=t[e];if(mr(s))return s}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch{return}}},gS=class{match(t){return eu(t)}coerce(t,e){var s,i=t.constructor.name;return{type:i,value:i+" captured as exception with keys: "+_g(t),stack:(s=e.syntheticException)==null?void 0:s.stack,synthetic:!0}}},pS=class{match(t){return Bf(t)}coerce(t,e){var s;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:(s=e.syntheticException)==null?void 0:s.stack,synthetic:!0}}},vS=class{match(t){return Un(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!eu(t))return!1;try{var e=t.detail;return e!=null&&typeof e=="object"&&"reason"in e}catch{return!1}}coerce(t,e){var s,i=this.getUnhandledRejectionReason(t);return Bf(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(s=e.syntheticException)==null?void 0:s.stack,synthetic:!0}:e.apply(i)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&t.detail!=null&&typeof t.detail=="object"&&"reason"in t.detail)return t.detail.reason}catch{}return t}},Hn="$message",qn="$timestamp",_S=new Set([Hn,qn]),ja={enabled:!0,max_bytes:32768};mS=class{constructor(t){this.Gn=[],this.Zn=0,this.Rn=zn(t)}setConfig(t){this.Rn=zn(t),this.Jn()}add(t){var e=(function(i){var r;try{r=$f(i)}catch{return}try{var n=JSON.parse(r);if(!Y(n))return;var o=n,a=o[Hn],l=o[qn];return!Q(a)||a.trim().length===0||!Q(l)&&!Re(l)?void 0:{step:o,json:r}}catch{return}})(t);if(e){var s=(function(i){if("u">typeof TextEncoder)return new TextEncoder().encode(i).length;for(var r=encodeURIComponent(i),n=0,o=0;r.length>o;o++)r[o]==="%"?(n+=1,o+=2):n+=1;return n})(e.json);s>this.Rn.max_bytes||(this.Gn.push({step:e.step,bytes:s}),this.Zn+=s,this.Jn())}}getAttachable(){return this.Gn.map(t=>t.step)}clear(){this.Gn=[],this.Zn=0}size(){return this.Gn.length}Jn(){for(;this.Zn>this.Rn.max_bytes&&this.Gn.length>0;){var t=this.Gn.shift();t&&(this.Zn-=t.bytes)}}};kh=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};bS=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],mg="NativeGzipValidationError",kl=t=>t.length>=2&&t[0]===31&&t[1]===139,Rh=(t,e)=>t===ml.GZipJS||e===ml.GZipJS||e==="gzip",Th=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError",yn=t=>{throw gg(mg,"Native gzip produced invalid output: "+t)},ES=(function(){var t=ge(function*(e,s){18>e.size&&yn("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());kl(i)&&i[2]===8||yn("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(o=>{for(var a=(()=>{if(Ki)return Ki;Ki=[];for(var c=0;256>c;c++){for(var h=c,g=0;8>g;g++)h=1&h?3988292384^h>>>1:h>>>1;Ki[c]=h>>>0}return Ki})(),l=4294967295,u=0;o.length>u;u++)l=a[255&(l^o[u])]^l>>>8;return(4294967295^l)>>>0})(s)&&yn("invalid-crc");var n=s.length>>>0;r.getUint32(4,!0)!==n&&yn("invalid-size")});return function(e,s){return t.apply(this,arguments)}})();SS={}.propertyIsEnumerable;Oh={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"},Eg={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},kS=Eg.info;RS=class{constructor(t,e,s,i,r,n,o){var a;n===void 0&&(n=()=>Promise.resolve()),this._instance=t,this.Rn=e,this.A=s,this.Qn=i,this.Kn=r,this.Xn=n,this.Yn=o,this.ts=null,this.es=0,this.rs=0,this.ns=0,this.ss=0,this.ls=0,this.us=!1,this.hs=e.maxBufferSize,this.ds=Math.max((a=e.maxQueueSize)!==null&&a!==void 0?a:e.maxBufferSize,e.maxBufferSize),this.vs=e.flushIntervalMs,this.cs=e.maxBatchRecordsPerPost,this.fs=e.rateCapWindowMs,this.ps=e.maxLogsPerInterval}clearQueue(){this.rs++,this._instance.setPersistedProperty(Pt.LogsQueue,[])}reset(){this.gs(),this.ss=0,this.ls=0,this.us=!1,this.ns=0,this.cs=this.Rn.maxBatchRecordsPerPost}onReconnect(){this.ns=0,this.ys()}captureLog(t,e){var s;if(!this._instance.isDisabled&&!this._instance.optedOut&&t!=null&&t.body){var i=this.bs(t);if(i!==null)if(i.body){if(this._s()){var r={record:IS(i,(s=e?.context)!==null&&s!==void 0?s:this.Qn(),this.A,e?.occurredAtMs)};this.Kn(()=>this.ws(r))}}else this.A.info("Log was rejected in beforeSend function")}}bs(t){var e=this.Rn.beforeSend;if(!e)return t;var s=F(e)?e:[e],i=t;for(var r of s)try{var n=r(i);if(!n)return this.A.info("Log was rejected in beforeSend function"),null;i=n}catch(o){return this.A.error("Error in beforeSend function for log:",o),null}return i}_s(){if(this.ps===void 0)return!0;var t=Date.now(),e=t-this.ss;return this.fs>e&&e>=0||(this.ss=t,this.ls=0,this.us=!1),this.ps>this.ls?(this.ls++,!0):(this.us||(this.A.warn("captureLog dropping logs: exceeded "+this.ps+" logs per "+this.fs+"ms"),this.us=!0),!1)}flush(){var t=this;return ge(function*(){if(!t._instance.isDisabled)return t.ts||(t.ts=t.ks().finally(()=>{t.ts=null})),t.ts})()}ks(){var t=this;return ge(function*(){var e;t.gs();var s=(e=t._instance.getPersistedProperty(Pt.LogsQueue))!==null&&e!==void 0?e:[];if(s.length!==0)for(var i=s.length,r=0;s.length>0&&i>r;){var n,o,a=t.rs;t.es=0;var l=Math.min(s.length,t.cs),u=s.slice(0,l),c=wg(u.map(g=>g.record),t.Ss(),(n=t.Yn)!==null&&n!==void 0?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.xs(c);if(t.rs!==a)return;if(h.kind==="too-large"&&u.length>1)t.cs=Math.max(1,Math.floor(u.length/2)),t.A.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+t.cs);else if(h.kind==="retry-later"||(h.kind==="too-large"?t.A.warn("Dropping a single log record after 413 with batch size 1 \u2014 the record is larger than the server cap and cannot be split further."):h.kind==="ok"&&t.Rn.maxBatchRecordsPerPost>t.cs&&(t.cs=Math.min(t.Rn.maxBatchRecordsPerPost,t.cs+1)),yield t.Cs(u.length),s=(o=t._instance.getPersistedProperty(Pt.LogsQueue))!==null&&o!==void 0?o:[],r+=u.length,h.kind==="fatal"))throw h.error}})()}Cs(t){var e=this;return ge(function*(){var s,i=Math.max(0,t-e.es),r=(s=e._instance.getPersistedProperty(Pt.LogsQueue))!==null&&s!==void 0?s:[];e._instance.setPersistedProperty(Pt.LogsQueue,r.slice(i)),yield e.Xn()})()}Ss(){return Sg(this.Rn,this._instance.getLibraryId(),this._instance.getLibraryVersion())}ws(t){var e;if(!this._instance.optedOut){var s=(e=this._instance.getPersistedProperty(Pt.LogsQueue))!==null&&e!==void 0?e:[];this.ds>s.length||(s.shift(),this.es++,this.A.info("Logs queue is full, dropping oldest record.")),s.push(t),this._instance.setPersistedProperty(Pt.LogsQueue,s),this.hs>s.length?this.Ts():this.ys()}}Ts(t){t===void 0&&(t=this.vs),this.Ms||(this.Ms=su(()=>{this.Ms=void 0,this.ys()},t))}Is(){var t=Math.min(Math.max(0,this.ns-1),6);return this.vs*Math.pow(2,t)}Es(){var t=this._instance.getPersistedProperty(Pt.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return ge(function*(){e.gs();var s=e.flush().catch(()=>{});t!==void 0?yield Sh(s,t):yield s})()}flushWithTimeout(t){var e=this;return ge(function*(){var s=e.flush();yield Sh(s,t,()=>{s.catch(()=>{})})})()}ys(){this.flush().then(()=>{this.ns=0},t=>{this.ns++,this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Es()&&this.Ts(this.Is())})}gs(){this.Ms&&(clearTimeout(this.Ms),this.Ms=void 0)}},Ga=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];TS=class{constructor(t,e,s){this._instance=t,this.Rn=e,this.A=s,this.Rs=new Map,this.ts=null,this.As=!1,this.Ps=new Map,this.Fs=new Set,this.Os=0}count(t,e,s){e===void 0&&(e=1),this.$s({name:t,type:"count",value:e,unit:s?.unit,attributes:s?.attributes})}gauge(t,e,s){this.$s({name:t,type:"gauge",value:e,unit:s?.unit,attributes:s?.attributes})}histogram(t,e,s){this.$s({name:t,type:"histogram",value:e,unit:s?.unit,attributes:s?.attributes})}flush(){var t=this,e=this.ts,s=(function(){var i=ge(function*(){e&&(yield e.catch(()=>{})),yield t.Ds()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ts===s&&(this.ts=null)});return this.ts=s,s}drainWindow(){if(this.Rs.size===0)return null;var t=this.Rs;return this.Rs=new Map,this.As=!1,this.Ps=new Map,this.Fs=new Set,this.Ls(t)}reset(){this.Os++,this.gs(),this.Rs=new Map,this.ts=null,this.As=!1,this.Ps=new Map,this.Fs=new Set}$s(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.bs(t);if(e!==null)if(e.name&&typeof e.name=="string")if(typeof e.value=="number"&&Number.isFinite(e.value))if(e.type==="count"&&0>e.value)this.A.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var s,i;try{s=e.attributes?k({},e.attributes):void 0,i=Ch(e.type,e.name,e.unit,s)}catch(o){return void this.A.warn("Dropping metric '"+e.name+"': attributes could not be serialized",o)}var r=this.Rs.get(i);if(!r){if(!this.Ns())return;r={name:e.name,type:e.type,unit:e.unit,attributes:s,windowStartMs:Date.now()},this.Rs.set(i,r)}var n=this.Ps.get(e.name);n===void 0?this.Ps.set(e.name,e.type):n===e.type||this.Fs.has(e.name)||(this.Fs.add(e.name),this.A.warn("Metric name '"+e.name+"' is already used as a "+n+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.qs(r,e.value),this.Ts()}else this.A.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Ns(){return this.Rn.maxSeriesPerFlush>this.Rs.size||(this.As||(this.As=!0,this.A.warn("Metric series cap reached ("+this.Rn.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}qs(t,e){var s;switch(t.type){case"count":t.total=((s=t.total)!==null&&s!==void 0?s:0)+e;break;case"gauge":t.last=e;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(Ga.length+1).fill(0)});var i=t.hist;i.count+=1,i.sum+=e,i.min=Math.min(i.min,e),i.max=Math.max(i.max,e),i.bucketCounts[(function(r,n){for(var o=0;n.length>o;o++)if(n[o]>=r)return o;return n.length})(e,Ga)]+=1}}bs(t){var e=this.Rn.beforeSend;if(!e)return t;var s=F(e)?e:[e],i=t;for(var r of s)try{var n=r(i);if(!n)return this.A.info("Metric was rejected in beforeSend function"),null;i=n}catch(o){return this.A.error("Error in beforeSend function for metric:",o),null}return i}Ts(){this.Ms||(this.Ms=su(()=>{this.Ms=void 0,this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})},this.Rn.flushIntervalMs))}gs(){this.Ms&&(clearTimeout(this.Ms),this.Ms=void 0)}Ds(){var t=this;return ge(function*(){if(t.Rs.size!==0){var e=t.Rs;t.Rs=new Map,t.As=!1,t.Ps=new Map,t.Fs=new Set;var s=t.Os,i=yield t._instance.js(t.Ls(e));if(s===t.Os)switch(i.kind){case"ok":return;case"retry-later":return t.Bs(e),void t.Ts();case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",i.error)}}})()}Ls(t){return e=this.Hs(t),s=(function(n,o,a){return bg(n,o,a)})(this.Rn,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Kn(s)},scopeMetrics:[{scope:{name:i,version:r},metrics:e}]}]};var e,s,i,r}Hs(t){var e=Ph(Date.now()),s=new Map;for(var i of t.values()){var r,n=Ch(i.type,i.name,i.unit,void 0),o=s.get(n);o||(o=k({name:i.name},i.unit&&{unit:i.unit}),i.type==="count"?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:i.type==="gauge"?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},s.set(n,o));var a=Kn((r=i.attributes)!==null&&r!==void 0?r:{},this.A),l=Ph(i.windowStartMs);if(i.type==="count"){var u,c={attributes:a,startTimeUnixNano:l,timeUnixNano:e,asDouble:(u=i.total)!==null&&u!==void 0?u:0};o.sum.dataPoints.push(c)}else if(i.type==="gauge"){var h,g={attributes:a,timeUnixNano:e,asDouble:(h=i.last)!==null&&h!==void 0?h:0};o.gauge.dataPoints.push(g)}else i.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:e,count:i.hist.count,sum:i.hist.sum,min:i.hist.min,max:i.hist.max,bucketCounts:i.hist.bucketCounts,explicitBounds:Ga})}return Array.from(s.values())}Bs(t){var e,s;for(var i of t){var r=i[0],n=i[1],o=this.Rs.get(r);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=((e=o.total)!==null&&e!==void 0?e:0)+((s=n.total)!==null&&s!==void 0?s:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Ns()&&this.Rs.set(r,n)}}},kg=function(t,e){var s=(e===void 0?{}:e).debugEnabled,i={q(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];b&&(Yt.DEBUG||b.POSTHOG_DEBUG||s)&&!S(b.console)&&b.console&&("__rrweb_original__"in b.console[r]?b.console[r].__rrweb_original__:b.console[r])(t,...o)},debug(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.q("debug",...n)},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.q("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.q("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.q("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(t,...n)},uninitializedWarning(r){i.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>kg(t+" "+r,n)};return i},I=kg("[PostHog.js]"),Te=I.createLogger,OS=Te("[ExternalScriptsLoader]"),Wn=t=>{var e=A?.querySelectorAll("script");if(e){for(var s=0;e.length>s;s++)if(e[s].src===t||e[s].getAttribute("src")===t)return e[s]}},Rs=(t,e,s)=>{if(t.config.disable_external_dependency_loading)return OS.warn(e+" was requested but loading of external scripts is disabled."),s("Loading of external scripts is disabled");var i=Wn(e);if(i){if(i.__posthog_loading_callback_fired)return s();var r=i.__posthog_loading_error;return r?s(r):(i.addEventListener("load",o=>{i.__posthog_loading_callback_fired=!0,s(void 0,o)}),void i.addEventListener("error",o=>{i.__posthog_loading_error=o,s(o)}))}var n=()=>{if(!A)return s("document not found");if(Wn(e))return Rs(t,e,s);var o=A.createElement("script");if(o.type="text/javascript",o.crossOrigin="anonymous",o.src=e,o.onload=u=>{o.__posthog_loading_callback_fired=!0,s(void 0,u)},o.onerror=u=>{o.__posthog_loading_error=u,s(u)},t.config.prepare_external_dependency_script&&(o=t.config.prepare_external_dependency_script(o)),!o)return s("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")A.head.appendChild(o);else{var a,l=A.querySelectorAll("body > script");l.length>0?(a=l[0].parentNode)==null||a.insertBefore(o,l[0]):A.body.appendChild(o)}};A!=null&&A.body?n():A?.addEventListener("DOMContentLoaded",n)},Ha={},xh=(t,e)=>{var s="/static/"+e+".js?v="+t.version;if(e==="toolbar"){var i=3e5;s=s+"&t="+Math.floor(Date.now()/i)*i}return t.requestRouter.endpointFor("assets",s)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(t,e,s)=>{if(e!=="remote-config"){var i=t.config.strict_script_versioning;if(i){var r=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js"),n=Ha[r];if(i==="fallback"&&n){if(Wn(n))return void Rs(t,n,s);delete Ha[r]}Rs(t,r,i==="fallback"?(o,a)=>{if(o)if(typeof o=="string")s(o);else{var l,u=xh(t,e);Ha[r]=u;var c=Wn(r);c==null||(l=c.parentNode)==null||l.removeChild(c),Rs(t,u,s)}else s(void 0,a)}:s)}else Rs(t,xh(t,e),s)}else Rs(t,t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js"),s)},L.__PosthogExtensions__.loadSiteApp=(t,e,s)=>{Rs(t,t.requestRouter.endpointFor("api",e),s)},Yt.DEBUG=!1,Yt.LIB_VERSION="1.428.7",Yt.LIB_NAME="web";Le=Yt,PS="$people_distinct_id",bt="distinct_id",ru="$device_id",qa="$device_model",Jn="__alias",CS="__cmpns",za="$fbc",Et="$fbc_persistence",Il="__timers",Rl="$autocapture_disabled_server_side",Tl="$heatmaps_enabled_server_side",Ol="$exception_capture_enabled_server_side",Ag="$error_tracking_suppression_rules",Pl="$error_tracking_capture_extension_exceptions",Cl="$web_vitals_enabled_server_side",nu="$dead_clicks_enabled_server_side",ou="$product_tours_enabled_server_side",xl="$logs_capture_enabled_server_side",Ig="$web_vitals_allowed_metrics",ui="$session_recording_remote_config",xS="$session_recording_enabled_server_side",Rg="$replay_sample_rate",Tg="$replay_override_sampling",Og="$replay_override_linked_flag",Pg="$replay_override_url_trigger",Cg="$replay_override_event_trigger",ni="$sesid",au="$session_is_sampled",DS="$session_past_minimum_duration",NS="$session_recording_url_trigger_activated_session",LS="$session_recording_event_trigger_activated_session",$S="$debug_first_full_snapshot_timestamp",FS="$sess_rec_flush_size",pt="$enabled_feature_flags",Ct="$active_feature_flags",Dl="$early_access_features",Ps="$feature_flag_details",as="$feature_flag_payloads",Cs="$feature_flag_request_id",nr="$minimal_flag_called_events",Ot="$override_feature_flags",Ts="$override_feature_flag_payloads",Wt="$stored_person_properties",ls="$stored_group_properties",xg="$groups",Nl="$surveys",Yn="$surveys_loaded_at",Ll="$surveys_activated",Dn="$surveys_activated_session",Nn="$surveys_activated_timestamps",Ln="ph_product_tours",MS="$product_tours_activated",BS="$product_tours_activated_session",US="$conversations_widget_session_id",VS="$conversations_ticket_id",jS="$conversations_widget_state",GS="$conversations_user_traits",us="$flag_call_reported",tr="$flag_call_reported_session_id",fr="$feature_flag_errors",cs="$feature_flag_evaluated_at",je="$user_state",$l="$client_session_props",Dg="$capture_rate_limit",Ng="$initial_campaign_params",Lg="$initial_referrer_info",oi="$initial_person_info",lu="$epp",Ka="$posthog_cookieless",$g="$cookieless_mode",Fg="$sdk_debug_extensions_init_method",Mg="$sdk_debug_extensions_init_time_ms",Fl="$sdk_debug_recording_script_not_loaded",HS="$sdk_debug_replay_event_trigger_status",qS="$sdk_debug_replay_linked_flag_trigger_status",zS="$sdk_debug_replay_matched_recording_trigger_groups",KS="$sdk_debug_replay_pending_trigger_conditions",WS="$sdk_debug_replay_remote_trigger_matching_config",JS="$sdk_debug_replay_trigger_groups_count",YS="$sdk_debug_replay_url_trigger_status",XS="$session_recording_start_reason",Ml="PostHog loadExternalDependency extension not found.",os="anonymous",sr="identified",Bg="identified_only",hi="visibilitychange",Xn="beforeunload",uu="$pageview",Dh="$pageleave",Bl="$identify",Nh="$groupidentify";fe=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;e>i;i++)s[i-1]=arguments[i];for(var r of s)for(var n in r)r[n]!==void 0&&(t[n]=r[n]);return t};Lh=function(t){try{return t()}catch{return}},QS=function(t){return function(){try{for(var e=arguments.length,s=new Array(e),i=0;e>i;i++)s[i]=arguments[i];return t.apply(this,s)}catch(r){I.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),I.critical(r)}}},cu=function(t){var e={};return ie(t,function(s,i){(Q(s)&&s.length>0||Re(s))&&(e[i]=s)}),e};ZS=["herokuapp.com","vercel.app","netlify.app"];Vl=t=>{if(A){try{for(var e=t+"=",s=A.cookie.split(";").filter(n=>n.length),i=0;s.length>i;i++){for(var r=s[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}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Re(t)&&isFinite(t)&&Math.floor(t)===t});tw=class jl{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,s,i,r){if(!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>s||0>i||0>r||e>0xffffffffffff||s>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/256,n[5]=e,n[6]=112|s>>>8,n[7]=s,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 jl(n)}toString(){for(var e="",s=0;this.bytes.length>s;s++)e=e+(this.bytes[s]>>>4).toString(16)+(15&this.bytes[s]).toString(16),s!==3&&s!==5&&s!==7&&s!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new jl(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var s=0;16>s;s++){var i=this.bytes[s]-e.bytes[s];if(i!==0)return Math.sign(i)}return 0}},sw=class{generate(){var t=this.generateOrAbort();if(!S(t))return t;this.Ct=0;var e=this.generateOrAbort();if(S(e))throw new Error("Could not generate UUID after timestamp reset");return e}generateOrAbort(){var t,e=(t=Date.now(),Re(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0);if(e>this.Ct)this.Ct=e,this.Mt();else{if(this.Ct>=e+1e4)return;this.Tt++,this.Tt>4398046511103&&(this.Ct++,this.Mt())}return tw.fromFieldsV7(this.Ct,Math.trunc(this.Tt/Math.pow(2,30)),this.Tt&Math.pow(2,30)-1,this.It.nextUint32())}Mt(){this.Tt=1024*this.It.nextUint32()+(1023&this.It.nextUint32())}constructor(){this.Ct=0,this.Tt=0,this.It=new iw}},Vg=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};b&&!S(b.crypto)&&crypto.getRandomValues&&(Vg=t=>crypto.getRandomValues(t));iw=class{nextUint32(){return this.Rt.length>this.At||(Vg(this.Rt),this.At=0),this.Rt[this.At++]}constructor(){this.Rt=new Uint32Array(8),this.At=1/0}},St=()=>rw().toString(),rw=()=>($h||($h=new sw)).generate(),Wi="",nw=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Zs=null,be={Et(){if(!Ie(Zs))return Zs;if(Zs=!1,A)try{var t="__ph_cookie_support_"+St();be.Ot(t,"xyz"),Zs=Vl(t)==='"xyz"',be.Dt(t)}catch{Zs=!1}return Zs},Pt(t){I.error("cookieStore error: "+t)},Lt:Vl,Nt(t){var e;try{e=JSON.parse(be.Lt(t))||{}}catch{}return e},Ot(t,e,s,i,r){if(!A)return!1;try{var n="",o="",a=(function(c,h){if(h){var g=(function(p,_){if(_===void 0&&(_=A),Wi)return Wi;if(!_||["localhost","127.0.0.1"].includes(p))return"";for(var v=p.split("."),m=Math.min(v.length,8),y="dmn_chk_"+St();!Wi&&m--;){var w=v.slice(m).join("."),E=y+"=1;domain=."+w+";path=/";_.cookie=E+";max-age=3",_.cookie.includes(y)&&(_.cookie=E+";max-age=0",Wi=w)}return Wi})(c);if(!g){var f=(p=>{var _=p.match(nw);return _?_[0]:""})(c);f!==g&&I.info("Warning: cookie subdomain discovery mismatch",f,g),g=f}return g?"; domain=."+g:""}return""})(A.location.hostname,i);if(s){var l=new Date;l.setTime(l.getTime()+864e5*s),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&I.warn("cookieStore warning: large cookie, len="+u.length),A.cookie=u,!0}catch{return!1}},Dt(t,e){if(A!=null&&A.cookie)try{be.Ot(t,"",-1,e)}catch{return}}},Wa=null,ee={Et(){if(!Ie(Wa))return Wa;var t=!0;if(S(b))t=!1;else try{var e="__mplssupport__";ee.Ot(e,"xyz"),ee.Lt(e)!=='"xyz"'&&(t=!1),ee.Dt(e)}catch{t=!1}return t||I.error("localStorage unsupported; falling back to cookie store"),Wa=t,t},Pt(t){I.error("localStorage error: "+t)},Lt(t){try{return b?.localStorage.getItem(t)}catch(e){ee.Pt(e)}return null},Nt(t){try{return JSON.parse(ee.Lt(t))||{}}catch{}return null},Ot(t,e){try{return b?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(s){ee.Pt(s)}return!1},Dt(t){try{b?.localStorage.removeItem(t)}catch(e){ee.Pt(e)}}},Ja=[Wt,Ct,pt,Ps,as,Cs,cs,fr,us],Os=[ru,bt,ni,au,lu,oi,Et,je],Qn=t=>t+"_cpm",ow=["__proto__","constructor","prototype"],Ya=t=>{if(!Y(t))return{};var e={};return Object.keys(t).forEach(s=>{ow.indexOf(s)===-1&&(e[s]=t[s])}),e},Xa=function(t,e){e===void 0&&(e=[]);var s={};return[...Os,...e].forEach(i=>{var r=t[i];S(r)||Ie(r)||r===""||(s[i]=r)}),s},jg=t=>{for(var e=5381,s=2166136261,i=0;t.length>i;i++){var r=t.charCodeAt(i);e=33*e^r,s=Math.imul(s^r,16777619)}return t.length.toString(36)+"."+(e>>>0).toString(36)+"."+(s>>>0).toString(36)},Fh=(t,e)=>({p:e,f:jg(JSON.stringify(t))}),Mh=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{var s=be.Nt(Qn(t)),i=s?.f===jg(e)&&F(s.p);return{properties:i?s.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},Qa=(t,e)=>e+"|"+(be.Lt(Qn(t))||""),ei={},Gl={Et:()=>!0,Pt(t){I.error("memoryStorage error: "+t)},Lt:t=>t in ei?ei[t]:null,Nt:t=>t in ei?ei[t]:null,Ot:(t,e)=>(ei[t]=e,!0),Dt(t){delete ei[t]}},Ss=null,de={Et(){if(!Ie(Ss))return Ss;if(Ss=!0,S(b))Ss=!1;else try{var t="__support__";de.Ot(t,"xyz"),de.Lt(t)!=='"xyz"'&&(Ss=!1),de.Dt(t)}catch{Ss=!1}return Ss},Pt(t){I.error("sessionStorage error: ",t)},Lt(t){try{return b?.sessionStorage.getItem(t)}catch(e){de.Pt(e)}return null},Nt(t){try{return JSON.parse(de.Lt(t))||null}catch{}return null},Ot(t,e){try{return b?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(s){de.Pt(s)}return!1},Dt(t){try{b?.sessionStorage.removeItem(t)}catch(e){de.Pt(e)}}},aw=class{constructor(t){this._instance=t}get Rn(){return this._instance.config}get consent(){return this.vo()?0:this.co}isOptedOut(){return this.Rn.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Rn.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Rn.opt_out_capturing_by_default}optInOut(t){this.fo.Ot(this.po,t?1:0,this.Rn.cookie_expiration,this.Rn.cross_subdomain_cookie,this.Rn.secure_cookie)}reset(){this.fo.Dt(this.po,this.Rn.cross_subdomain_cookie)}get po(){var t=this._instance.config,e=t.token,s=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(s?s+e:"__ph_opt_in_out_"+e)}get co(){var t=this.fo.Lt(this.po);return $a(t)?1:M(jE,t)?0:-1}get fo(){var t=this.Rn.opt_out_capturing_persistence_type,e=t==="localStorage"?ee:be,s=e.Et()?e:Gl;if(!this.mo||this.mo!==s){this.mo=s;var i=t==="localStorage"?be:ee;i.Lt(this.po)&&(this.mo.Lt(this.po)||this.optInOut($a(i.Lt(this.po))),i.Dt(this.po,this.Rn.cross_subdomain_cookie))}return this.mo}vo(){return!!this.Rn.respect_dnt&&[Fe?.doNotTrack,Fe?.msDoNotTrack,L.doNotTrack,Fe?.globalPrivacyControl].some(t=>$a(t))}};fu=["a","button","form","input","select","textarea","label"];Za=[".ph-no-autocapture","[data-ph-no-autocapture]"],Kg=["next","previous","prev",">","<"],lw=[...Kg,"+","-","\u2212","\u2013"],Vh=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,jh=[".ph-no-rageclick",".ph-no-capture"],uw=["","text","search","email","password","url","tel","number"];gu=t=>!t||Ge(t,"html")||!Dt(t),Jg=(t,e)=>{if(!b||gu(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var s=!1,i=[t],r=t;r.parentNode&&!Ge(r,"body");)if(du(r.parentNode))i.push(r.parentNode.host),r=r.parentNode.host;else{var n=zg(r);if(!n)break;if(e||fu.indexOf(n.tagName.toLowerCase())>-1)s=!0;else try{var o=b.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(s=!0)}catch{}i.push(n),r=n}return{parentIsUsefulElement:s,targetElementList:i}};Gh=new RegExp("^(?:(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}))$"),Hh=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,cw=[16,15,14,13],dw=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),qh=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),zh=/[0-9A-Za-z_]/;En=Te("[Dead Clicks]"),gw=()=>!0,pw=t=>{var e,s=!((e=t.instance.persistence)==null||!e.get_property(nu)),i=t.instance.config.capture_dead_clicks;return Xe(i)?i:!!Y(i)||s},Jh=class{get lazyLoadedDeadClicksAutocapture(){return this.yo}constructor(t,e,s){this.instance=t,this.isEnabled=e,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[nu]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.bo(()=>{this._o()}):this.stop()}bo(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture?t():(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?En.error("failed to load script",i):t()})}_o(){var t;if(A){if(!this.yo&&(t=L.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture){var e=Y(this.instance.config.capture_dead_clicks)?k({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.yo=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.yo.start(A),En.info("starting...")}}else En.error("`document` not found. Cannot start.")}stop(){this.yo&&(this.yo.stop(),this.yo=void 0,En.info("stopping..."))}},Sn=Te("[SegmentIntegration]");Xg="posthog-js";vw=class{constructor(t,e,s,i,r,n){this.name=Xg,this.setupOnce=function(o){o(Qg(t,{organization:e,projectId:s,prefix:i,severityAllowList:r,sendExceptionsToPostHog:n==null||n}))}}},Xh=class{constructor(t){this.wo=(e,s,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(I.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this.ko=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.So()}So(){var t;this.xo=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(this.wo)}destroy(){var t;(t=this.xo)==null||t.call(this),this.xo=void 0}doPageView(t,e){var s,i=this.Co(t,e);return this.ko={pathname:(s=b?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:e,timestamp:t},this._instance.scrollManager.resetContext(),i}doPageLeave(t){var e;return this.Co(t,(e=this.ko)==null?void 0:e.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.ko)==null?void 0:t.pageViewId}}Co(t,e){var s=this.ko;if(!s)return{$pageview_id:e};var i={$pageview_id:e,$prev_pageview_id:s.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var n=r.maxScrollHeight,o=r.lastScrollY,a=r.maxScrollY,l=r.maxContentHeight,u=r.lastContentY,c=r.maxContentY;if(!(S(n)||S(o)||S(a)||S(l)||S(u)||S(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var h=n>1?xt(o/n,0,1,I):1,g=n>1?xt(a/n,0,1,I):1,f=l>1?xt(u/l,0,1,I):1,p=l>1?xt(c/l,0,1,I):1;i=fe(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:f,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:p})}}return s.pathname&&(i.$prev_pageview_pathname=s.pathname),s.timestamp&&(i.$prev_pageview_duration=(t.getTime()-s.timestamp.getTime())/1e3),i}},Ji=["flags","surveys"],_w={[PS]:{exposure:"hidden"},[Jn]:{exposure:"hidden"},[CS]:{exposure:"hidden"},[Il]:{exposure:"hidden"},[Et]:{exposure:"hidden"},[Rl]:{exposure:"event"},[Tl]:{exposure:"hidden"},[xl]:{exposure:"hidden"},[Ol]:{exposure:"event"},[Ag]:{exposure:"hidden"},[Pl]:{exposure:"event"},[Cl]:{exposure:"event"},[nu]:{exposure:"event"},[ou]:{exposure:"hidden"},[Ig]:{exposure:"event"},[ui]:{exposure:"hidden"},[xS]:{exposure:"hidden"},[ni]:{exposure:"hidden"},[au]:{exposure:"event"},[Rg]:{exposure:"event",shouldSkipFromEventProperties:t=>Ie(t)},[DS]:{exposure:"event"},[NS]:{exposure:"event"},[LS]:{exposure:"event"},[$S]:{exposure:"event"},[FS]:{exposure:"hidden"},[pt]:{exposure:"hidden",storageGroup:"flags"},[Ct]:{exposure:"hidden",storageGroup:"flags"},[Dl]:{exposure:"hidden"},[Ps]:{exposure:"hidden",storageGroup:"flags"},[as]:{exposure:"hidden",storageGroup:"flags"},[Cs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[nr]:{exposure:"hidden",storageGroup:"flags"},[Ot]:{exposure:"hidden"},[Ts]:{exposure:"hidden"},[Wt]:{exposure:"hidden"},[ls]:{exposure:"hidden"},[Nl]:{exposure:"hidden",storageGroup:"surveys"},[Yn]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Ll]:{exposure:"event"},[Dn]:{exposure:"hidden"},[Nn]:{exposure:"hidden"},[Ln]:{exposure:"hidden"},[MS]:{exposure:"hidden"},[BS]:{exposure:"hidden"},[US]:{exposure:"event"},[VS]:{exposure:"event"},[jS]:{exposure:"event"},[GS]:{exposure:"event"},[us]:{exposure:"hidden"},[tr]:{exposure:"hidden"},[xg]:{exposure:"event"},[fr]:{exposure:"hidden"},[cs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[je]:{exposure:"hidden"},[$l]:{exposure:"hidden"},[Dg]:{exposure:"hidden"},[Ng]:{exposure:"hidden"},[Lg]:{exposure:"hidden"},[oi]:{exposure:"hidden"},[lu]:{exposure:"hidden"},[Tg]:{exposure:"event"},[Og]:{exposure:"event"},[Pg]:{exposure:"event"},[Cg]:{exposure:"event"},[Fg]:{exposure:"event"},[Mg]:{exposure:"event"},[Fl]:{exposure:"event"},[HS]:{exposure:"event"},[qS]:{exposure:"event"},[zS]:{exposure:"event"},[KS]:{exposure:"event"},[WS]:{exposure:"event"},[JS]:{exposure:"event"},[YS]:{exposure:"event"},[XS]:{exposure:"event"}},mw=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Be=t=>{var e=_w[t];if(e)return e;for(var s of mw){var i=s[1];if(t.indexOf(s[0])===0)return i}},ai=(t,e)=>{try{var s;return JSON.stringify(t,(i,r)=>mr(r)?(s!=null||(s=new WeakMap),s.has(r)||s.set(r,Ug(r)),s.get(r)):typeof r=="bigint"?r.toString():r,e)}catch{return $f(t)}},gi=t=>{var e=A?.createElement("a");return S(e)?null:(e.href=t,e)},pi=function(t,e){for(var s,i=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;i.length>r;r++){var n=i[r].split("=");if(n[0]===e){s=n;break}}if(!F(s)||2>s.length)return"";var o=s[1];try{o=decodeURIComponent(o)}catch{I.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},vr=function(t,e,s){if(!t||!e||!e.length)return t;for(var i=t.split("#"),r=i[1],n=(i[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var h=l[c].split("=");F(h)&&(e.includes(h[0])?u.push(h[0]+"="+s):u.push(l[c]))}var g=a;return o!=null&&(g+="?"+u.join("&")),r!=null&&(g+="#"+r),g},Zn=function(t,e){var s=t.match(new RegExp(e+"=([^&]*)"));return s?s[1]:null},Zg=(t,e)=>t>=e&&Lf(),ep=(t,e,s,i)=>{if(t===0){if(Lf()){var r=e+1;return r===s&&i(),r}return e}return 0},vi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],yw=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...vi],_r="<masked>",bw=["li_fat_id"];eo="$direct";Sw={flags:cs,surveys:Yn},ww=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],wn=t=>t+"_cookie_identity_change_pending",kn=t=>{var e="",s=0;for(var i of t){var r=encodeURIComponent(JSON.stringify(i).slice(1,-1)).length;if(s+r>1e3)break;e+=i,s+=r}return e},Ne="main",Kt=[pt,Ct,Ps,as,Cs,cs,nr,Wt],el=t=>Kt.indexOf(t)!==-1,is=(t,e)=>{try{return JSON.stringify(t)===JSON.stringify(e)}catch{return t===e}},ti=t=>{if(!t)return{};var e=JSON.parse(t);return Y(e)?e:{}},Zh=(t,e)=>{ie(t,(s,i)=>{var r=Be(i);r&&r.exposure!=="event"||{}.hasOwnProperty.call(e,i)||delete t[i]})},tl=class{constructor(t,e,s){if(s===void 0&&(s=!0),this.To={},this.Mo=!1,this.Io=!1,this.Eo=!1,this.Ro=!1,this.Ao=!1,this.Po=new Map,this.Fo=!1,this.Oo=!1,this.$o=!1,this.Do=!1,this.Lo=new Set,this.Rn=t,this.No=s,this.props={},this.qo=void 0,this.jo=(r=>{var n="";return r.token&&(n=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+n+"_posthog"})(t),this.fo=this.Bo(t),this.Eo=this.Ho(t),this.load(),this.zo(),t.debug&&I.info("Persistence loaded",t.persistence,k({},this.props)),this.update_config(t,t,e),this.save(),b){var i=()=>this.flush();ae(b,"beforeunload",i,{capture:!1}),ae(b,"pagehide",i,{capture:!1}),this.Uo=r=>{if(this.Mo&&(!r.storageArea||r.storageArea===b?.localStorage)&&r.key)if(r.key!==this.jo){if(this.Eo){var n=Ji.find(o=>r.key===this.Wo(o));n&&this.Vo(r.key,n)}}else this.Vo(r.key,Ne)},ae(b,"storage",this.Uo)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(e=>{var s=e[0],i=e[1],r=this.Po.get(s);if(el(s)&&r!==!0)if(i!==!0){var n=new Set(r||[]);i.forEach(o=>n.add(o)),n.size&&this.Go(s,n)}else this.Go(s,!0)})}onCrossTabFeatureFlagChange(t){return this.Lo.add(t),()=>this.Lo.delete(t)}destroy(){this.Uo&&b&&(b.removeEventListener("storage",this.Uo),this.Uo=void 0),this.Lo.clear()}Vo(t,e,s){if(s===void 0&&(s=!0),this.gi)return!1;var i,r;try{if(r=ee.Lt(t),Ie(r)){var n=this.Zo(e);return n.storageValue=null,e!==Ne&&(n.persisted=!1),!1}i=ti(r)}catch{return!1}var o=e===Ne?i:ee.Nt(this.jo);if(o&&this.Jo(o))return!1;var a=this.Qo(i,e,s);return e===Ne&&this.Eo&&!is(this.Ko().main,i)||this.Xo(i,e,!0,r),a}Jo(t){var e=this.props[bt],s=t[bt];return!S(e)&&!S(s)&&e!==s}Xo(t,e,s,i){var r=this.Zo(e);r.storageValue=i,e!==Ne&&(r.persisted=s);try{r.fingerprint=this.Yo(t,e)}catch{r.fingerprint=void 0}}Qo(t,e,s){var i=!1;return Kt.forEach(r=>{var n,o=(n=Be(r))==null?void 0:n.storageGroup;if(!(e===Ne&&this.Eo&&o||e!==Ne&&o!==e)){var a=r in t,l=this.ta(r,a?t[r]:void 0),u=this.Po.has(r)?r in this.props:a;u===r in this.props&&is(l,this.props[r])||(u?this.ea(r,l,!1):this.ia(r,!1),i=!0)}}),i&&s&&this.Lo.forEach(r=>r()),i}ra(){if(!this.Mo)return!1;try{this.$o=!1;var t,e=ee.Lt(this.jo),s=this.Zo(Ne),i=!1,r=!1;if(e!==s.storageValue)if(Ie(e))s.storageValue=null;else{if(t=ti(e),this.$o=!this.Oo&&this.Jo(t),this.$o)return!1;r=this.Qo(t,Ne,!1),!this.Eo||is(this.Ko().main,t)?this.Xo(t,Ne,!0,e):s.storageValue=e,i=!0}return this.Eo&&Ji.forEach(n=>{var o=ee.Lt(this.Wo(n)),a=this.Zo(n),l=t||{},u=i&&Kt.some(h=>{var g;return((g=Be(h))==null?void 0:g.storageGroup)===n&&h in l});if(o!==a.storageValue||u){if(Ie(o))return a.storageValue=null,a.persisted=!1,void(u&&(r=this.Qo(l,n,!1)||r));var c=ti(o);r=this.Qo(c,n,!1)||r,this.Xo(c,n,!0,o)}}),r}catch{return!1}}Go(t,e){this.Po.set(t,e);var s=Be(t);s!=null&&s.volatile||(this.Zo((this.Eo?s?.storageGroup:void 0)||Ne).fingerprint=void 0,this.na(t))}sa(){Kt.forEach(t=>this.Po.set(t,!0))}zo(){if(this.Mo)try{var t=ee.Lt(this.jo),e=ti(t);this.Zo(Ne).storageValue=t,Kt.forEach(s=>{var i,r=this.Eo?(i=Be(s))==null?void 0:i.storageGroup:void 0,n=r?ee.Lt(this.Wo(r)):null;if(r){var o=this.Zo(r);o.storageValue=n,o.persisted=!Ie(n)}var a=r&&!Ie(n)?ti(n):e;s in this.props?this.oa(s,a[s],this.props[s]):s in a&&this.Go(s,!0)})}catch{}}ta(t,e){var s=this.Po.get(t);if(!s)return e;if(s===!0)return this.props[t];if(t==="$active_feature_flags"){var i=new Set(F(e)?e:[]),r=new Set(F(this.props[t])?this.props[t]:[]);return s.forEach(a=>r.has(a)?i.add(a):i.delete(a)),Array.from(i)}var n=Y(e)?k({},e):{},o=Y(this.props[t])?this.props[t]:{};return s.forEach(a=>{a in o?n[a]=o[a]:delete n[a]}),n}oa(t,e,s){if(el(t)){var i=this.Po.get(t);if(i!==!0){var r=e;if(this.Mo)try{var n,o=this.Eo?(n=Be(t))==null?void 0:n.storageGroup:void 0,a=o?this.Wo(o):this.jo;r=ti(ee.Lt(a))[t]}catch{}var l=new Set(i||[]);if(t==="$active_feature_flags"){if(!S(e)&&!F(e)||!S(r)&&!F(r)||!F(s))return void this.Go(t,!0);var u=new Set(e||[]),c=new Set(r||[]),h=new Set(s);new Set([...u,...h]).forEach(p=>{u.has(p)!==h.has(p)&&l.add(p)}),l.forEach(p=>{c.has(p)===h.has(p)&&l.delete(p)})}else{if(!Y(s))return void(is(r,s)?this.Po.delete(t):this.Go(t,!0));if(!S(e)&&!Y(e)||S(e)&&nt(s)&&S(r))return void this.Go(t,!0);var g=Y(e)?e:{},f=Y(r)?r:{};new Set([...Object.keys(g),...Object.keys(s)]).forEach(p=>{p in g==p in s&&is(g[p],s[p])||l.add(p)}),l.forEach(p=>{p in f==p in s&&is(f[p],s[p])&&l.delete(p)})}l.size?this.Go(t,l):this.Po.delete(t)}}}aa(){var t,e=(t=this.Rn)==null?void 0:t.persistence_save_debounce_ms;return Re(e)&&e>0?e:0}la(t){if(this.Rn.cookieWinsOnConflict&&this.Rn.persistence.toLowerCase()==="localstorage+cookie")if(t)try{var e=Xa(t,this.Rn.cookie_persisted_properties||[]),s=Fh(e,this.Rn.cookie_persisted_properties||[]),i=JSON.stringify(e)+"|"+JSON.stringify(s),r=be.Lt(this.jo)||void 0;r&&Qa(this.jo,r)===i&&(this.ua=i,this.ha=r)}catch{}else try{var n=be.Lt(this.jo)||void 0;this.ua=n?Qa(this.jo,n):void 0,this.ha=n}catch{}}syncCookieProperties(){return this.da(this.Rn)}da(t,e){if(e===void 0&&(e=!1),this.gi&&!e||this.Ao||!t.cookieWinsOnConflict||t.persistence.toLowerCase()!=="localstorage+cookie")return!1;var s;try{s=be.Lt(this.jo)||void 0}catch{}if(!s||s===this.ha)return!1;var i,r=Qa(this.jo,s);try{i=Ya(JSON.parse(s))}catch{return!1}if((be.Lt(this.jo)||void 0)!==s)return!1;this.ua=r,this.ha=s;var n=Mh(this.jo,s),o=[...Os,...n.properties],a={};if(Object.keys(i).forEach(_=>{var v=i[_];(S(v)||Ie(v)||v===""||_==="$user_state"&&v!=="anonymous"&&v!=="identified")&&(a[_]=!0,delete i[_])}),nt(i))return!1;var l="distinct_id"in i||i.$user_state==="anonymous"||i.$user_state==="identified",u=this.props,c=u[bt],h=u[je],g=fe({},u);[...Os,...t.cookie_persisted_properties||[]].forEach(_=>{if(o.indexOf(_)!==-1&&!(_ in i)&&!a[_]&&(l||_!=="distinct_id"&&_!=="$user_state")){var v=g[_];(n.isValid||Os.indexOf(_)===-1||v!==!1&&v!==0)&&delete g[_]}}),this.props=fe(g,i),Kt.forEach(_=>{var v=_ in this.props;_ in u===v&&is(u[_],this.props[_])||(v?this.oa(_,u[_],this.props[_]):this.Go(_,!0))}),!l||"$user_state"in i||"$user_state"in this.props||this.ea(je,os);var f=this.props[bt],p=this.props[je];return!l||f===c&&p===h||(this.Oo=!0,this.Ro=!0,de.Ot(wn(this.jo),!0),this.ia(Wt),this.ia(Ct),this.ia(pt),this.ia(Ps),this.ia(as),this.ia(Cs),this.ia(cs),this.ia(fr),this.ia(us),p!=="anonymous"||h!=="identified"&&i.$user_state!=="anonymous"&&(S(c)||f===c)||(Zh(this.props,i),this.ia(ls)),p==="identified"?this.props.$user_id=f:delete this.props.$user_id,this.ia(Jn)),!0}consumeCookieIdentityChange(){var t=wn(this.jo),e=this.Ro||!!de.Lt(t);return this.Ro=!1,e&&de.Dt(t),e}va(t){return t===void 0&&(t=!1),!(this.Ao||this.gi&&!t||!this.Rn.cookieWinsOnConflict||this.Rn.persistence.toLowerCase()!=="localstorage+cookie"||(this.Ao=!0,0))}ca(){this.Ao&&(S(this.fa)||(clearTimeout(this.fa),this.fa=void 0),delete this.To[Ne],this.pa(!0))}ga(t){if(t===void 0&&(t=!0),this.Ao)try{t?this.ca():S(this.fa)||(clearTimeout(this.fa),this.fa=void 0)}finally{this.Ao=!1}}isDisabled(){return!!this.gi}Bo(t){ww.indexOf(t.persistence.toLowerCase())===-1&&(I.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var e,s=(function(o,a){o===void 0&&(o=[]),a===void 0&&(a=!1);var l=[...Os,...o];return k({},ee,{Nt(u){try{var c,h={};try{c=be.Lt(u)||void 0,h=c?Ya(JSON.parse(c)):{}}catch{}var g,f=JSON.parse(ee.Lt(u)||"{}");if(a){var p=Mh(u,c),_=[...Os,...p.properties],v={};Object.keys(h).forEach(T=>{var C=h[T];Ie(C)||C===""||T==="$user_state"&&C!=="anonymous"&&C!=="identified"||(v[T]=C)});var m="distinct_id"in v||v.$user_state==="anonymous"||v.$user_state==="identified";if(Object.keys(v).length>0){var y,w=f[bt],E=(y=f.$user_state)!==null&&y!==void 0?y:"anonymous";l.forEach(T=>{if(_.indexOf(T)!==-1&&!(T in h)&&(m||T!=="distinct_id"&&T!=="$user_state")){var C=f[T];(p.isValid||Os.indexOf(T)===-1||C!==!1&&C!==0)&&delete f[T]}}),!m||"$user_state"in h||"$user_state"in f||(f[je]=os),!m||("distinct_id"in v?v[bt]:f[bt])===w&&("$user_state"in v?v[je]:f[je])===E||(Ja.forEach(T=>delete f[T]),v.$user_state==="identified"&&"distinct_id"in v?f.$user_id=v[bt]:delete f.$user_id,v.$user_state!=="identified"&&(delete f[xg],delete f[ls]),delete f.__alias)}g=fe(f,v)}else g=fe(h,f);return ee.Ot(u,g),g}catch{}return null},Ot(u,c,h,g,f,p){var _=ee.Ot(u,c,void 0,void 0,p);try{var v=Xa(c,o);if(Object.keys(v).length){if(a){var m=Qn(u),y=Fh(v,o);if(be.Ot(m,y,h,g,f,p),be.Lt(m)!==JSON.stringify(y)){be.Dt(m,g);var w=Xa(c);return be.Ot(u,w,h,g,f,p),_}}be.Ot(u,v,h,g,f,p)}}catch(E){ee.Pt(E)}return _},Dt(u,c){try{b?.localStorage.removeItem(u),be.Dt(u,c),be.Dt(Qn(u),c)}catch(h){ee.Pt(h)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),i=!1,r=!1,n=t.persistence.toLowerCase();return n==="localstorage"&&ee.Et()?(e=ee,r=!0):n==="localstorage+cookie"&&s.Et()?(e=s,r=!0,i=!0):n==="sessionstorage"&&de.Et()?e=de:n==="memory"?e=Gl:n==="cookie"&&be.Et()?(e=be,i=!0):s.Et()?(e=s,r=!0,i=!0):be.Et()?(e=be,i=!0):e=Gl,this.Mo=r,this.Io=i,e}Wo(t){return this.jo+"__"+t}Ho(t){return this.Mo&&!!t.split_storage}properties(){var t={};return ie(this.props,(e,s)=>{var i=Be(s);if(!i||i.exposure==="event"){if(i!=null&&i.shouldSkipFromEventProperties!=null&&i.shouldSkipFromEventProperties(e))return;t[s]=e}}),t}load(t){if(t===void 0&&(t=!1),!this.gi||t){var e=this.Rn.cookieWinsOnConflict&&this.Rn.persistence.toLowerCase()==="localstorage+cookie",s=e?ee.Nt(this.jo):null,i={};if(e)try{ie(i=Ya(be.Nt(this.jo)),(f,p)=>{(S(f)||Ie(f)||f==="")&&delete i[p]})}catch{}var r=this.fo.Nt(this.jo);if(r&&(this.props=fe({},r)),this.Eo&&this.ma(),e&&r){var n,o,a=s?.[bt],l=(n=s?.$user_state)!==null&&n!==void 0?n:"anonymous",u=r[bt],c=(o=r.$user_state)!==null&&o!==void 0?o:"anonymous";if(u!==a||c!==l){this.Ro=!0,de.Ot(wn(this.jo),!0);var h=fe({},this.props);Ja.forEach(f=>delete h[f]),c!=="anonymous"||l!=="identified"&&i.$user_state!=="anonymous"&&(S(a)||u===a)||(Zh(h,i),delete h[ls]),this.props=h;var g=new Set;Ja.forEach(f=>{var p,_=(p=Be(f))==null?void 0:p.storageGroup;_&&g.add(_)}),g.forEach(f=>{var p={};ie(this.props,(_,v)=>{var m;((m=Be(v))==null?void 0:m.storageGroup)===f&&(p[v]=_)}),nt(p)?(ee.Dt(this.Wo(f)),this.To[f]={}):ee.Ot(this.Wo(f),p)&&(this.To[f]={persisted:!0,fingerprint:this.Yo(p,f)})})}}de.Lt(wn(this.jo))&&(this.Ro=!0)}}ma(){for(var t of Ji){var e=ee.Nt(this.Wo(t));if(e&&!nt(e)){var s=this.Zo(t);s.persisted=!0,this.ya(t)||(s.fingerprint=this.Yo(e,t)),this.ba(t,e)||fe(this.props,e)}}}ya(t){return Object.keys(this.props).some(e=>{var s;return((s=Be(e))==null?void 0:s.storageGroup)===t})}ba(t,e){var s=Sw[t];if(!s)return!1;var i=e[s],r=this.props[s];return Re(i)&&Re(r)&&r>i}refreshKey(t){var e;if(!(this.gi||t==="$fbc_persistence"&&this.Do)){var s=this.Eo?(e=Be(t))==null?void 0:e.storageGroup:void 0,i=s?ee.Nt(this.Wo(s)):this.fo.Nt(this.jo);if(i&&t in i)this.ea(t,i[t],!1);else{if(s){var r=this.fo.Nt(this.jo);if(r&&t in r)return void this.ea(t,r[t],!1)}this.ia(t,!1)}}}save(){if(!this.gi){var t=this.aa();t>0?S(this.fa)&&(this.fa=setTimeout(()=>{this.fa=void 0,this.pa()},t)):this.pa()}}flush(){S(this.fa)||(clearTimeout(this.fa),this.fa=void 0,this.pa())}pa(t){if(t===void 0&&(t=!1),!(this.gi||this.Ao&&!t)){t||(this.syncCookieProperties(),this.Do||this.Rn.cookieWinsOnConflict&&this.Rn.persistence.toLowerCase()==="localstorage+cookie"||this.refreshKey(Et));var e=!t&&!this.Fo;e||(this.$o=!1);var s=!!e&&this.ra();if(this.$o)this.Rn.debug&&I.warn("skipping persistence write because storage belongs to a different distinct ID");else{if(this.Eo)return this._a(),void(s&&this.Lo.forEach(r=>r()));var i=this.wa(this.fo,this.jo,this.props,Ne);i==="written"&&this.la(this.props),i!=="failed"&&(this.Po.clear(),this.Oo=!1,this.Do=!1),s&&this.Lo.forEach(r=>r())}}}_a(){var t=this,e=this.Ko(),s=e.main,i=e.groups,r=this.wa(this.fo,this.jo,s,Ne);r==="written"&&this.la(s),r!=="failed"&&(this.Oo=!1,this.Do=!1,Kt.forEach(a=>{var l;(l=Be(a))!=null&&l.storageGroup||this.Po.delete(a)}));var n=function(a){var l,u=i[a];if(nt(u)&&((l=t.To[a])==null||!l.persisted))return Kt.forEach(h=>{var g;((g=Be(h))==null?void 0:g.storageGroup)===a&&t.Po.delete(h)}),1;var c=t.wa(ee,t.Wo(a),u,a);c!=="failed"&&Kt.forEach(h=>{var g=Be(h);g?.storageGroup!==a||c!=="written"&&g.volatile||t.Po.delete(h)})};for(var o of Ji)n(o)}Ko(){var t={},e={flags:{},surveys:{}};return ie(this.props,(s,i)=>{var r,n=(r=Be(i))==null?void 0:r.storageGroup;n?e[n][i]=s:t[i]=s}),{main:t,groups:e}}Yo(t,e){if(e===Ne)return JSON.stringify(t)+"|"+this.ka+"|"+this.Sa+"|"+this.xa;var s={};return ie(t,(i,r)=>{var n;s[r]=(n=Be(r))!=null&&n.volatile?"__volatile__":i}),JSON.stringify(s)}wa(t,e,s,i){var r,n=this.Zo(i);if(i!==Ne&&!n.dirty&&!S(n.fingerprint))return"skipped";try{if((r=this.Yo(s,i))===n.fingerprint)return n.dirty=!1,"skipped"}catch{r=void 0}return t.Ot(e,s,this.ka,this.Sa,this.xa,this.Rn.debug)?(n.dirty=!1,i!==Ne&&(n.persisted=!0),S(r)||(n.fingerprint=r),this.Mo&&(n.storageValue=ee.Lt(e)),"written"):(this.Rn.debug&&I.warn('failed to persist storage entry "'+e+'"; will retry on next save'),"failed")}remove(t){var e=(t===void 0?{}:t).keepGroupEntries,s=e!==void 0&&e;if(this.sa(),S(this.fa)||(clearTimeout(this.fa),this.fa=void 0),this.fo.Dt(this.jo,!1),this.fo.Dt(this.jo,!0),!s&&this.No)for(var i of Ji)ee.Dt(this.Wo(i));s?delete this.To[Ne]:this.To={},this.ua=void 0,this.ha=void 0}clear(){this.remove(),this.props={}}register_once(t,e,s){if(Y(t)){this.syncCookieProperties(),S(e)&&(e="None"),this.ka=S(s)?this.Ca:s;var i=!1;if(ie(t,(r,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==e||(this.ea(n,r),i=!0)}),i)return this.save(),!0}return!1}register(t,e){if(Y(t)){this.syncCookieProperties(),this.ka=S(e)?this.Ca:e;var s=!1;if(ie(t,(i,r)=>{t.hasOwnProperty(r)&&(this.props[r]!==i||Y(i)||F(i))&&(this.ea(r,i),s=!0)}),s)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var e=typeof t=="string"?[t]:t,s=!1;for(var i of e)i in this.props&&(this.ia(i),s=!0);s&&this.save()}update_campaign_params(){var t=A?.URL;if(t!==this.qo){var e=tp(this.Rn.custom_campaign_params,this.Rn.mask_personal_data_properties,this.Rn.custom_personal_data_properties),s=!nt(cu(e));return s&&this.register(e),this.qo=t,s?e:void 0}}update_search_keyword(){var t;this.register((t=A?.referrer)?ip(t):{})}update_referrer_info(){var t;this.register_once({$referrer:rp(),$referring_domain:A!=null&&A.referrer&&((t=gi(A.referrer))==null?void 0:t.host)||eo},void 0)}set_initial_person_info(){if(!this.props.$initial_campaign_params&&!this.props.$initial_referrer_info){var t=np(this.Rn.mask_personal_data_properties,this.Rn.custom_personal_data_properties,this.Rn.disable_capture_url_hashes);this.register_once({[oi]:this.Io?{r:kn(t.r),u:t.u?kn(t.u):void 0}:t},void 0)}}get_initial_props(){var t={};ie([Lg,Ng],s=>{var i=this.props[s];i&&ie(i,function(r,n){t["$initial_"+_l(n)]=r})});var e=this.props[oi];return e&&fe(t,(function(s,i){i===void 0&&(i=!1);var r=op(s,i),n={};return ie(r,function(o,a){n["$initial_"+_l(a)]=o}),n})(e,this.Rn.disable_capture_url_hashes)),t}safe_merge(t){return ie(this.props,function(e,s){s in t||(t[s]=e)}),t}update_config(t,e,s){var i=t.persistence!==e.persistence,r=!((p,_)=>{if(p.length!==_.length)return!1;var v=[...p].sort(),m=[..._].sort();return v.every((y,w)=>y===m[w])})(t.cookie_persisted_properties||[],e.cookie_persisted_properties||[]),n=i||r,o=t.cookieWinsOnConflict!==e.cookieWinsOnConflict,a=t.disable_persistence||!!s,l=!!this.gi&&!a;a||this.da(e,l),this.Rn=t,!a&&(i||r||o)&&(this.ua=void 0,this.ha=void 0,this.da(k({},t,{cookie_persisted_properties:e.cookie_persisted_properties}),l));var u=n||o?this.Bo(t):this.fo;this.Ta();var c=this.Ho(t),h=n||c!==this.Eo,g=!a&&(h||t.cross_subdomain_cookie!==this.Sa||t.secure_cookie!==this.xa)&&this.va(l);this.Fo=h;try{if(this.Ca=this.ka=t.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),h){var f=this.props;this.clear(),this.fo=u,this.Eo=c,this.props=f,this.save()}else o&&(this.fo=u,a||(delete this.To[Ne],this.pa()))}finally{this.Fo=!1,g&&this.ga()}}Ta(){var t=this.props[oi];if(this.Io&&Y(t)&&typeof t.r=="string"){var e=kn(t.r),s=typeof t.u=="string"?kn(t.u):t.u;e===t.r&&s===t.u||this.ea(oi,k({},t,{r:e,u:s}))}}set_disabled(t){this.gi=t,this.gi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Sa&&(this.Sa=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.xa&&(this.xa=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,e){var s=this.props.__timers||{};s[t]=e,this.ea(Il,s),this.save()}remove_event_timer(t){var e=this.props.__timers||{},s=e[t];return S(s)||(delete e[t],this.ea(Il,e),this.save()),s}get_property(t){return this.props[t]}set_property(t,e){this.ea(t,e),this.save()}ea(t,e,s){var i;s===void 0&&(s=!0);var r=this.props[t];this.props[t]=e,s&&(t!=="distinct_id"&&t!=="$user_state"||r===e||(this.Oo=!0),t!=="$fbc_persistence"||is(r,e)||(this.Do=!0),this.oa(t,r,e),(i=Be(t))!=null&&i.volatile||this.na(t))}ia(t,e){e===void 0&&(e=!0),delete this.props[t],e&&(el(t)&&this.Go(t,!0),t==="$fbc_persistence"&&(this.Do=!0),this.na(t))}na(t){var e,s=(e=Be(t))==null?void 0:e.storageGroup;s&&(this.Zo(s).dirty=!0)}Zo(t){return this.To[t]||(this.To[t]={})}},lt={GZipJS:"gzip-js",Base64:"base64"},Yi={Activation:"events",Cancellation:"cancelEvents"},sl={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Jt={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},il={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},zl={Popover:"popover",Inline:"inline"};kw={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"},ef={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"},tf=Te("[RateLimiter]"),Aw=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var s=e.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(i=>{tf.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void tf.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:s})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return((t=this.instance.config.rate_limiting)==null?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)==null?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var e,s,i;t===void 0&&(t=!1);var r=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=new Date().getTime(),a=(e=(s=this.instance.persistence)==null?void 0:s.get_property("$capture_rate_limit"))!==null&&e!==void 0?e:{tokens:r,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>r&&(a.tokens=r);var l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var u=(Re(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Ma(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,(i=this.instance.persistence)==null||i.set_property(Dg,a),{isRateLimited:l,remainingTokens:a.tokens}}Ia(t){var e=this.instance.config.property_denylist;return!F(e)||!e.includes(t)}Ea(){var t;if(this.Ia("$current_url")&&this.Ia("$pathname")&&Ee!=null&&Ee.pathname)return""+((t=Ee.origin)!==null&&t!==void 0?t:"")+Ee.pathname}Ma(t){var e,s,i=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,n=this.Ea(),o=this.Ia("$session_id")?(e=(s=this.instance).get_session_id)==null?void 0:e.call(s):void 0,a=[t+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+r+" events per second and "+i+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var e=this.serverLimits[t||"events"]||!1;return e!==!1&&new Date().getTime()<e}},rs=Te("[RemoteConfig]"),lp=class{constructor(t){this._instance=t}get remoteConfig(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.config}Ra(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.loadExternalDependency?(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Aa(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return rs.info("Using preloaded remote config",this.remoteConfig),void this.Pa(this.remoteConfig);if(this._instance.Fa())return void rs.warn("Remote config is disabled. Falling back to local config.");this.Ra(t=>{if(!t)return rs.info("No config found after loading remote JS config. Falling back to JSON."),void this.Aa(e=>{this.Pa(e.json,e)});this.Pa(t)})}catch(t){rs.error("Error loading remote config",t),this.Pa()}}Pa(t,e){!t&&e&&(e.statusCode===0?e.error||rs.warn("Failed to fetch remote config from PostHog."):rs.error("Failed to fetch remote config from PostHog."));try{this._instance.Pa(t?{ok:!0,config:t}:{ok:!1})}catch(i){rs.error("Error applying remote config",i)}if(t?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var s;(s=this._instance.featureFlags)==null||s.ensureFlagsLoaded()}catch(i){rs.error("Error loading feature flags",i)}}},ut=Uint8Array,Qe=Uint16Array,_i=Uint32Array,pu=new ut([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]),vu=new ut([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]),sf=new ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),up=function(t,e){for(var s=new Qe(31),i=0;31>i;++i)s[i]=e+=1<<t[i-1];var r=new _i(s[30]);for(i=1;30>i;++i)for(var n=s[i];s[i+1]>n;++n)r[n]=n-s[i]<<5|i;return[s,r]},cp=up(pu,2),Kl=cp[1];cp[0][28]=258,Kl[258]=28;for(Wl=up(vu,0)[1],to=new Qe(32768),_e=0;32768>_e;++_e)ws=(43690&_e)>>>1|(21845&_e)<<1,to[_e]=((65280&(ws=(61680&(ws=(52428&ws)>>>2|(13107&ws)<<2))>>>4|(3855&ws)<<4))>>>8|(255&ws)<<8)>>>1;lr=function(t,e,s){for(var i=t.length,r=0,n=new Qe(e);i>r;++r)++n[t[r]-1];var o,a=new Qe(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(s){o=new Qe(1<<e);var l=15-e;for(r=0;i>r;++r)if(t[r])for(var u=r<<4|t[r],c=e-t[r],h=a[t[r]-1]++<<c,g=h|(1<<c)-1;g>=h;++h)o[to[h]>>>l]=u}else for(o=new Qe(i),r=0;i>r;++r)o[r]=to[a[t[r]-1]++]>>>15-t[r];return o},xs=new ut(288);for(_e=0;144>_e;++_e)xs[_e]=8;for(_e=144;256>_e;++_e)xs[_e]=9;for(_e=256;280>_e;++_e)xs[_e]=7;for(_e=280;288>_e;++_e)xs[_e]=8;so=new ut(32);for(_e=0;32>_e;++_e)so[_e]=5;Iw=lr(xs,9,0),Rw=lr(so,5,0),dp=function(t){return(t/8|0)+(7&t&&1)},hp=function(t,e,s){(e==null||0>e)&&(e=0),(s==null||s>t.length)&&(s=t.length);var i=new(t instanceof Qe?Qe:t instanceof _i?_i:ut)(s-e);return i.set(t.subarray(e,s)),i},Ht=function(t,e,s){var i=e/8|0;t[i]|=s<<=7&e,t[i+1]|=s>>>8},Xi=function(t,e,s){var i=e/8|0;t[i]|=s<<=7&e,t[i+1]|=s>>>8,t[i+2]|=s>>>16},rl=function(t,e){for(var s=[],i=0;t.length>i;++i)t[i]&&s.push({s:i,f:t[i]});var r=s.length,n=s.slice();if(!r)return[new ut(0),0];if(r==1){var o=new ut(s[0].s+1);return o[s[0].s]=1,[o,1]}s.sort(function(T,C){return T.f-C.f}),s.push({s:-1,f:25001});var a=s[0],l=s[1],u=0,c=1,h=2;for(s[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=s[s[h].f>s[u].f?u++:h++],l=s[u!=c&&s[h].f>s[u].f?u++:h++],s[c++]={s:-1,f:a.f+l.f,l:a,r:l};var g=n[0].s;for(i=1;r>i;++i)n[i].s>g&&(g=n[i].s);var f=new Qe(g+1),p=Jl(s[c-1],f,0);if(p>e){i=0;var _=0,v=p-e,m=1<<v;for(n.sort(function(T,C){return f[C.s]-f[T.s]||T.f-C.f});r>i;++i){var y=n[i].s;if(e>=f[y])break;_+=m-(1<<p-f[y]),f[y]=e}for(_>>>=v;_>0;){var w=n[i].s;e>f[w]?_-=1<<e-f[w]++-1:++i}for(;i>=0&&_;--i){var E=n[i].s;f[E]==e&&(--f[E],++_)}p=e}return[new ut(f),p]},Jl=function(t,e,s){return t.s==-1?Math.max(Jl(t.l,e,s+1),Jl(t.r,e,s+1)):e[t.s]=s},rf=function(t){for(var e=t.length;e&&!t[--e];);for(var s=new Qe(++e),i=0,r=t[0],n=1,o=function(l){s[i++]=l},a=1;e>=a;++a)if(t[a]==r&&a!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=t[a]}return[s.subarray(0,i),e]},Qi=function(t,e){for(var s=0,i=0;e.length>i;++i)s+=t[i]*e[i];return s},Fn=function(t,e,s){var i=s.length,r=dp(e+2);t[r]=255&i,t[r+1]=i>>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var n=0;i>n;++n)t[r+n+4]=s[n];return 8*(r+4+i)},nf=function(t,e,s,i,r,n,o,a,l,u,c){Ht(e,c++,s),++r[256];for(var h=rl(r,15),g=h[0],f=h[1],p=rl(n,15),_=p[0],v=p[1],m=rf(g),y=m[0],w=m[1],E=rf(_),T=E[0],C=E[1],q=new Qe(19),x=0;y.length>x;++x)q[31&y[x]]++;for(x=0;T.length>x;++x)q[31&T[x]]++;for(var le=rl(q,7),D=le[0],P=le[1],G=19;G>4&&!D[sf[G-1]];--G);var N,U,ue,Oe,he=u+5<<3,oe=Qi(r,xs)+Qi(n,so)+o,O=Qi(r,g)+Qi(n,_)+o+14+3*G+Qi(q,D)+(2*q[16]+3*q[17]+7*q[18]);if(oe>=he&&O>=he)return Fn(e,c,t.subarray(l,l+u));if(Ht(e,c,1+(oe>O)),c+=2,oe>O){N=lr(g,f,0),U=g,ue=lr(_,v,0),Oe=_;var B=lr(D,P,0);for(Ht(e,c,w-257),Ht(e,c+5,C-1),Ht(e,c+10,G-4),c+=14,x=0;G>x;++x)Ht(e,c+3*x,D[sf[x]]);c+=3*G;for(var V=[y,T],K=0;2>K;++K){var J=V[K];for(x=0;J.length>x;++x)Ht(e,c,B[W=31&J[x]]),c+=D[W],W>15&&(Ht(e,c,J[x]>>>5&127),c+=J[x]>>>12)}}else N=Iw,U=xs,ue=Rw,Oe=so;for(x=0;a>x;++x)if(i[x]>255){var W;Xi(e,c,N[257+(W=i[x]>>>18&31)]),c+=U[W+257],W>7&&(Ht(e,c,i[x]>>>23&31),c+=pu[W]);var Z=31&i[x];Xi(e,c,ue[Z]),c+=Oe[Z],Z>3&&(Xi(e,c,i[x]>>>5&8191),c+=vu[Z])}else Xi(e,c,N[i[x]]),c+=U[i[x]];return Xi(e,c,N[256]),c+U[256]},Tw=new _i([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ow=new ut(0),Pw=(function(){for(var t=new _i(256),e=0;256>e;++e){for(var s=e,i=9;--i;)s=(1&s&&3988292384)^s>>>1;t[e]=s}return t})(),nl=function(t,e,s){for(;s;++e)t[e]=s,s>>>=8};xw=!!Zl||!!dr,fp="text/plain",Mn=!1,gp=(t,e)=>{var s=t.split("#"),i=s[1],r=s[0].split("?"),n=r[0],o=r[1];if(!o)return t;var a=o.split("&").filter(l=>l.split("=")[0]!==e).join("&");return n+(a?"?"+a:"")+(i?"#"+i:"")},yr=function(t,e,s){var i;s===void 0&&(s=!0);var r=t.split("?"),n=r[0],o=r[1],a=k({},e),l=(i=o?.split("&").map(c=>{var h,g=c.split("="),f=g[0],p=s&&(h=a[f])!==null&&h!==void 0?h:g[1];return delete a[f],f+"="+p}))!==null&&i!==void 0?i:[],u=(function(c,h){var g,f;h===void 0&&(h="&");var p=[];return ie(c,function(_,v){S(_)||S(v)||v==="undefined"||(g=encodeURIComponent((m=>m instanceof File)(_)?_.name:_.toString()),f=encodeURIComponent(v),p[p.length]=f+"="+g)}),p.join(h)})(a);return u&&l.push(u),l.length>0?n+"?"+l.join("&"):n},ol=t=>{if(t.Oa)return t.Oa;var e=t.data,s=t.compression;if(e){if(s===lt.GZipJS){var i=Cw((function(o){var a=o.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(o);for(var l=new ut(o.length+(o.length>>>1)),u=0,c=function(p){l[u++]=p},h=0;a>h;++h){if(u+5>l.length){var g=new ut(u+8+(a-h<<1));g.set(l),l=g}var f=o.charCodeAt(h);128>f?c(f):2048>f?(c(192|f>>>6),c(128|63&f)):f>55295&&57344>f?(c(240|(f=65536+(1047552&f)|1023&o.charCodeAt(++h))>>>18),c(128|f>>>12&63),c(128|f>>>6&63),c(128|63&f)):(c(224|f>>>12),c(128|f>>>6&63),c(128|63&f))}return hp(l,0,u)})(ai(e)),{mtime:0});return{contentType:fp,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(s===lt.Base64){var r=(o=>"data="+encodeURIComponent(typeof o=="string"?o:ai(o)))((function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(ai(e)));return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var n=ai(e);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}}},pp=t=>{var e,s,i=()=>t.transport==="sendBeacon"?{url:yr(t.url,{compression:lt.Base64}),encodedBody:ol(k({},t,{compression:lt.Base64,Oa:void 0}))}:{url:gp(t.url,"compression"),encodedBody:ol(k({},t,{compression:void 0,Oa:void 0}))};try{e=ol(t)}catch(r){if(Rh(t.compression,pi(t.url,"compression")))return I.error("Failed to gzip request body, sending uncompressed payload",r),i();throw r}return e&&Rh(t.compression,pi(t.url,"compression"))&&!((s=e.body)instanceof ArrayBuffer?kl(new Uint8Array(s)):ArrayBuffer.isView(s)&&kl(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(Mn=!0,i()):{url:t.url,encodedBody:e}},vp=t=>{try{return pp(t)}catch(e){return I.error(e),void(t.callback==null||t.callback({statusCode:0,error:e}))}},Dw=(function(){var t=ge(function*(e){var s=yield(function(r,n,o){return Al.apply(this,arguments)})(ai(e.data),Le.DEBUG,{rethrow:!0});if(!s)return e;var i=yield s.arrayBuffer();return k({},e,{Oa:{contentType:fp,body:i,estimatedSize:i.byteLength}})});return function(e){return t.apply(this,arguments)}})(),Nw=/Failed to fetch|NetworkError|Load failed/i,_p=t=>t?.name==="TypeError"&&Nw.test(t?.message||""),mp=t=>{var e=vp(t);if(e){var s=new Zl,i=e.encodedBody;s.open(t.method||"GET",e.url,!0);var r=i??{},n=r.contentType,o=r.body;ie(t.headers,function(a,l){s.setRequestHeader(l,a)}),n&&s.setRequestHeader("Content-Type",n),t.timeout&&(s.timeout=t.timeout),s.onreadystatechange=()=>{if(s.readyState===4){var a={statusCode:s.status,text:s.responseText};if(s.status===200)try{a.json=JSON.parse(s.responseText)}catch{}t.callback==null||t.callback(a)}},s.send(o)}},yp=t=>{var e=vp(t);if(e){var s=e.url,i=e.encodedBody,r=i??{},n=r.contentType,o=r.body,a=r.estimatedSize,l=new Headers;ie(t.headers,function(p,_){l.append(_,p)}),n&&l.append("Content-Type",n);var u=null,c=!1;if(fh){var h=new fh;u={signal:h.signal,timeout:setTimeout(()=>{var p;c=!0,h.abort(gg("AbortError","PostHog request timed out"+((p=t.timeout)?" after "+p+"ms":"")))},t.timeout)}}var g=p=>{c&&p?.name==="AbortError"||_p(p)?I.warn(p):I.error(p),t.callback==null||t.callback({statusCode:0,error:p})};try{var f;dr(s,k({method:t?.method||"GET",headers:l,keepalive:t.method==="POST"&&!t.$a&&52428.8>(a||0),body:o,signal:(f=u)==null?void 0:f.signal},t.fetchOptions)).then(p=>p.text().then(_=>{var v={statusCode:p.status,text:_};if(p.status===200)try{v.json=JSON.parse(_)}catch(m){I.error(m)}t.callback==null||t.callback(v)})).catch(g).finally(()=>u?clearTimeout(u.timeout):null)}catch(p){u&&clearTimeout(u.timeout),g(p)}}},Yl=t=>{try{var e,s=pp(t),i=s.url,r=s.encodedBody,n=r??{},o=n.body,a=n.estimatedSize;if(!o)return;var l=o instanceof Blob?o:new Blob([o],{type:n.contentType});if(Fe.sendBeacon(i,l))return;var u=F(t.data)?t.data:(e=t.data)==null?void 0:e.batch;if(F(u)&&u.length>1&&(a??0)>16384){var c=Math.ceil(u.length/2),h=g=>F(t.data)?g:k({},t.data,{batch:g});return Yl(k({},t,{data:h(u.slice(0,c))})),void Yl(k({},t,{data:h(u.slice(c))}))}I.warn("Beacon of ~"+(a??0)+" bytes was rejected by the browser, falling back to "+(dr?"fetch":"XHR")),dr?yp(k({},t,{$a:!0})):mp(t)}catch(g){I.warn("Beacon send failed",g)}},of=(t,e,s,i)=>{var r=i==="query"?e==="POST"?"sent_at":"_":void 0;return yr(s===lt.GZipJS?gp(t,"compression"):t,k({},r?{[r]:Date.now().toString()}:{},s===lt.GZipJS?{}:{compression:s}))},Bn=[];dr&&Bn.push({transport:"fetch",method:yp}),Zl&&Bn.push({transport:"XHR",method:mp}),Fe!=null&&Fe.sendBeacon&&Bn.push({transport:"sendBeacon",method:Yl});Lw=class{constructor(t,e){this.Da=!0,this.La=[],this.Na=xt(e?.flush_interval_ms||3e3,250,5e3,I.createLogger("flush interval"),3e3),this.qa=t}enqueue(t){this.La.push(t),this.ja||this.Ba()}unload(){this.Ha();var t=this.La.length>0?this.za():{},e=Object.values(t);[...e.filter(s=>s.url.indexOf("/e")===0),...e.filter(s=>s.url.indexOf("/e")!==0)].map(s=>{this.Ua(k({},s,{transport:"sendBeacon"}))})}enable(){this.Da=!1,this.Ba()}Ba(){var t=this;this.Da||(this.ja=setTimeout(()=>{if(this.Ha(),this.La.length>0){var e=this.za(),s=function(){var r=e[i],n=new Date().getTime();r.data&&F(r.data)&&ie(r.data,o=>{o.offset=Math.abs(o.timestamp-n),delete o.timestamp}),t.Ua(r)};for(var i in e)s()}},this.Na))}Ua(t){try{this.qa(t)}catch(e){I.error(e)}}Ha(){clearTimeout(this.ja),this.ja=void 0}za(){var t={};return ie(this.La,e=>{var s,i=e,r=(i?i.batchKey:null)||i.url;S(t[r])&&(t[r]=k({},i,{data:[]})),(s=t[r].data)==null||s.push(i.data)}),this.La=[],t}},$w=class{constructor(t){this._instance=t,this.Wa=!1,this.Va=3e3,this.La=[],this.La=[],this.Ga=!0,this.resume()}resume(){if(!S(b)&&"onLine"in b.navigator){if(this.Ga=b.navigator.onLine,this.Za)return;this.Za=()=>{this.Ga=!0,this.Ja()},this.Qa=()=>{this.Ga=!1},ae(b,"online",this.Za),ae(b,"offline",this.Qa)}}get length(){return this.La.length}retriableRequest(t){var e=t.retriesPerformedSoFar,s=Nf(t,DE);zt(e)&&(s.url=yr(s.url,{retry_count:e})),this._instance._send_request(k({},s,{callback:i=>{if(i.statusCode!==200&&(400>i.statusCode||i.statusCode>=500)){if((i.statusCode===0?3:10)>(e??0))return void this.ws(k({retriesPerformedSoFar:e},s));i.statusCode===0&&I.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(e??0)+" retries.")}s.callback==null||s.callback(i)}}))}ws(t){var e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;var s=(function(n){var o=3e3*Math.pow(2,n),a=o/2,l=Math.min(18e5,o),u=(Math.random()-.5)*(l-a);return Math.ceil(l+u)})(e),i=Date.now()+s;this.La.push({retryAt:i,requestOptions:t});var r="Enqueued failed request for retry in "+s;navigator.onLine||(r+=" (Browser is offline)"),I.warn(r),this.Wa||(this.Wa=!0,this.Ka())}Ka(){if(this.Xa&&clearTimeout(this.Xa),this.La.length===0)return this.Wa=!1,void(this.Xa=void 0);this.Xa=setTimeout(()=>{this.Ga&&this.La.length>0&&this.Ja(),this.Ka()},this.Va)}Ja(){var t=Date.now(),e=[],s=this.La.filter(r=>t>r.retryAt||(e.push(r),!1));if(this.La=e,s.length>0)for(var i of s)this.retriableRequest(i.requestOptions)}unload(){for(var t of(this.Xa&&(clearTimeout(this.Xa),this.Xa=void 0),this.Wa=!1,S(b)||(this.Za&&(b.removeEventListener("online",this.Za),this.Za=void 0),this.Qa&&(b.removeEventListener("offline",this.Qa),this.Qa=void 0)),this.La)){var e=t.requestOptions;try{this._instance._send_request(k({},e,{transport:"sendBeacon"}))}catch(s){I.error(s)}}this.La=[]}},Fw=class{constructor(t){this._instance=t,this.Ya=()=>{var e,s,i,r;this.tl||(this.tl={});var n=this.scrollElement(),o=this.scrollY(),a=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=o+(n?.clientHeight||0),u=n?.scrollHeight||0;this.tl.lastScrollY=Math.ceil(o),this.tl.maxScrollY=Math.max(o,(e=this.tl.maxScrollY)!==null&&e!==void 0?e:0),this.tl.maxScrollHeight=Math.max(a,(s=this.tl.maxScrollHeight)!==null&&s!==void 0?s:0),this.tl.lastContentY=l,this.tl.maxContentY=Math.max(l,(i=this.tl.maxContentY)!==null&&i!==void 0?i:0),this.tl.maxContentHeight=Math.max(u,(r=this.tl.maxContentHeight)!==null&&r!==void 0?r:0)}}get el(){return this._instance.config.scroll_root_selector}getContext(){return this.tl}resetContext(){var t=this.tl;return setTimeout(this.Ya,0),t}startMeasuringScrollPosition(){ae(b,"scroll",this.Ya,{capture:!0}),ae(b,"scrollend",this.Ya,{capture:!0}),ae(b,"resize",this.Ya)}scrollElement(){var t;if(!this.el)return b==null||(t=b.document)==null?void 0:t.documentElement;for(var e of F(this.el)?this.el:[this.el]){var s,i=b==null||(s=b.document)==null?void 0:s.querySelector(e);if(i)return i}}il(t){var e,s,i=t==="y"?"scrollTop":"scrollLeft";if(this.el){var r=this.scrollElement();return r&&r[i]||0}return b?t==="y"?b.scrollY||b.pageYOffset||((e=b.document)==null||(e=e.documentElement)==null?void 0:e.scrollTop)||0:b.scrollX||b.pageXOffset||((s=b.document)==null||(s=s.documentElement)==null?void 0:s.scrollLeft)||0:0}scrollY(){return this.il("y")}scrollX(){return this.il("x")}},Mw=t=>np(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes),af=class{constructor(t,e,s,i){this.Be=r=>{var n=this.rl();if(!n||n.sessionId!==r){var o={sessionId:r,props:this.nl(this._instance)};this.sl.register({[$l]:o})}},this._instance=t,this.ol=e,this.sl=s,this.nl=i||Mw,this.ol.onSessionId(this.Be)}rl(){return this.sl.props[$l]}getSetOnceProps(){var t,e=(t=this.rl())==null?void 0:t.props;return e?"r"in e?op(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var t={};return ie(cu(this.getSetOnceProps()),(e,s)=>{s==="$current_url"&&(s="url"),t["$session_entry_"+_l(s)]=e}),t}},io=class{on(t,e){return this.al[t]||(this.al[t]=[]),this.al[t].push(e),()=>{this.al[t]=this.al[t].filter(s=>s!==e)}}emit(t,e){for(var s of this.al[t]||[])s(e);for(var i of this.al["*"]||[])i(t,e)}constructor(){this.al={}}},si=Te("[SessionId]"),lf=864e5,uf=class{on(t,e){return this.ll.on(t,e)}constructor(t,e,s){var i;if(this.ul=null,this.hl=null,this.dl=[],this.vl=void 0,this.cl=!1,this.ll=new io,this.fl=(a,l)=>!(!zt(a)||!zt(l))&&Math.abs(a-l)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Rn=t.config,this.sl=t.persistence,this.He=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.pl=void 0,this._sessionActivityTimestamp=null,this.gl=e||St,this.ml=s||St;var r=this.Rn.persistence_name||this.Rn.token;if(this._sessionTimeoutMs=1e3*xt(this.Rn.session_idle_timeout_seconds||1800,60,36e3,si.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.yl(),this.bl="ph_"+r+"_window_id",this._l="ph_"+r+"_primary_window_exists",this.wl()){var n=de.Nt(this.bl),o=de.Nt(this._l);n&&!o?this.He=n:de.Dt(this.bl),de.Ot(this._l,!0)}(i=this.Rn.bootstrap)!=null&&i.sessionID&&this.setBootstrapSessionId(this.Rn.bootstrap.sessionID),this.kl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return S(this.dl)&&(this.dl=[]),this.dl.push(t),this.Xt&&t(this.Xt,this.He),()=>{this.dl=this.dl.filter(e=>e!==t)}}wl(){return this.Rn.persistence!=="memory"&&!this.sl.gi&&de.Et()}Sl(t){t!==this.He&&(this.He=t,this.wl()&&de.Ot(this.bl,t))}xl(){return this.He?this.He:this.wl()?de.Nt(this.bl):null}Cl(t){var e=this.ul;return!Ie(e)&&!Ie(t)&&5e3>Math.abs(t-e)}Tl(t,e,s){var i=e!==this._sessionActivityTimestamp,r=!(t!==this.Xt||s!==this._sessionStartTimestamp);this._sessionStartTimestamp=s,this._sessionActivityTimestamp=e,this.Xt=t,r&&!i||r&&this.Cl(e)||(this.ul=e,this.sl.register({[ni]:[e,t,s]}))}Ml(){var t,e=(t=this.Rn)==null?void 0:t.persistence_save_debounce_ms;return zt(e)&&e>0}Il(){this.Ml()?this.sl.refreshKey(ni):(this.sl.flush(),this.sl.load())}El(){var t;if(!Ie(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.ul){this.Il();var e=this.Rl();e[1]===this.Xt&&e[2]===this._sessionStartTimestamp&&(this.ul=this._sessionActivityTimestamp,this.sl.register({[ni]:[this._sessionActivityTimestamp,(t=this.Xt)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.sl.flush())}}Al(){var t=this.Rl()[0],e=zt(t)?t:0,s=zt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,s)}Pl(t){return this.Il(),this.fl(t,this.Al())}Rl(){var t=this.sl.props[ni];return F(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.ul=null,this.pl=void 0,clearTimeout(this.Fl),this.Fl=void 0,this.Tl(null,null,null)}setBootstrapSessionId(t,e){e===void 0&&(e=!1);var s=(function(i,r){r===void 0&&(r=new Date().getTime());try{var n=(o=>{var a=o.replace(/-/g,"");if(a.length!==32)throw new Error("Not a valid UUID");if(a[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(a.substring(0,12),16)})(i);return n>r+6e4?void si.error("Bootstrap sessionID cannot be in the future"):n}catch(o){return void si.error("Invalid sessionID in bootstrap",o)}})(t);return!S(s)&&(e?this.pl={sessionId:t,sessionStartTimestamp:s}:this.Tl(t,new Date().getTime(),s),!0)}destroy(){this.cl=!0,this.El(),clearTimeout(this.Fl),this.Fl=void 0,this.vl&&b&&(b.removeEventListener(Xn,this.vl,{capture:!1}),this.vl=void 0),this.dl=[]}kl(){this.vl=()=>{this.El(),this.wl()&&de.Dt(this._l)},ae(b,Xn,this.vl,{capture:!1})}checkAndGetSessionAndWindowId(t,e,s){if(t===void 0&&(t=!1),e===void 0&&(e=null),s===void 0&&(s=!1),this.Rn.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=e||new Date().getTime(),r=this.Xt;if(s)this.hl=i;else if(Ie(this.hl)||this.hl>i||i-this.hl>=1e3){var n,o;(n=(o=this.sl).syncCookieProperties)==null||n.call(o),this.hl=i}var a=this.Rl(),l=a[1],u=a[2],c=!S(r)&&l!==r,h=this.Al(),g=this.xl(),f=this.pl,p=!!f&&(f.sessionStartTimestamp>i+6e4||i-f.sessionStartTimestamp>lf),_=f?p:zt(u)&&Math.abs(i-u)>lf,v=!1,m=c,y=!l||!!f,w=l,E=!y&&!t&&this.fl(i,h);if(E){(E=this.Pl(i))||si.info("cross-tab refresh kept the session alive",{sessionId:l});var T=this.Rl();l=T[1],u=T[2]}if(y||E||_){m=!1;var C=f&&!p;l=C?f.sessionId:this.gl(),g=this.ml(),si.info("new session ID assigned",{sessionId:l,windowId:g,bootstrapped:!!C,changeReason:{noSessionId:y,activityTimeout:E,sessionPastMaximumLength:_}}),u=C?f.sessionStartTimestamp:i,this.pl=void 0,v=!0}else g||(g=this.ml(),v=!0),(m=m||l!==w)&&(si.info("adopted cross-tab session id",{sessionId:l,windowId:g}),v=!0);var q=zt(h)&&t&&!_?h:i,x=zt(u)?u:new Date().getTime();this.Sl(g),this.Tl(l,q,x),t||this.yl();var le={noSessionId:y,activityTimeout:E,sessionPastMaximumLength:_,crossTabAdoption:m};return v&&this.dl.forEach(D=>D(l,g,le)),{sessionId:l,windowId:g,sessionStartTimestamp:x,changeReason:v?le:void 0,lastActivityTimestamp:h}}yl(){this.cl||(clearTimeout(this.Fl),this.Fl=setTimeout(()=>{if(!this.cl)if(this.Pl(new Date().getTime())){var t=this.Xt;this.resetSessionId(),this.ll.emit("forcedIdleReset",{idleSessionId:t})}else this.yl()},1.1*this.sessionTimeoutMs))}},bp=function(t,e){if(!t)return!1;var s=t.userAgent;if(s&&ph(s,e))return!0;try{var i=t?.userAgentData;if(i!=null&&i.brands&&i.brands.some(r=>ph(r?.brand,e)))return!0}catch{}return!!t.webdriver};ro=(t,e)=>{if(!(s=>{try{new RegExp(s)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}},In=t=>t.toLowerCase(),wp={exact:(t,e)=>e.some(s=>t.some(i=>s===i)),is_not:(t,e)=>e.every(s=>t.every(i=>s!==i)),regex:(t,e)=>e.some(s=>t.some(i=>ro(s,i))),not_regex:(t,e)=>e.every(s=>t.every(i=>!ro(s,i))),icontains:(t,e)=>e.map(In).some(s=>t.map(In).some(i=>s.includes(i))),not_icontains:(t,e)=>e.map(In).every(s=>t.map(In).every(i=>!s.includes(i))),gt:(t,e)=>e.some(s=>{var i=parseFloat(s);return!isNaN(i)&&t.some(r=>i>parseFloat(r))}),lt:(t,e)=>e.some(s=>{var i=parseFloat(s);return!isNaN(i)&&t.some(r=>i<parseFloat(r))})};Xl="custom",cf="i.posthog.com",Uw=/^\/static\//,Vw=["/s/","/e/","/i/"],jw=class{constructor(t){this.Ol={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,e=(t=this.instance.config.ui_host)==null?void 0:t.replace(/\/$/,"");return e||(e=this.apiHost.replace("."+cf,".posthog.com")),e==="https://app.posthog.com"?"https://us.posthog.com":e}get region(){return this.Ol[this.apiHost]||(this.Ol[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":Xl),this.Ol[this.apiHost]}$l(t){if(Uw.test(t)){var e=this.instance.config.asset_host;if(typeof e=="string")return e.trim().replace(/\/$/,"")||void 0}}Dl(t){var e=gi(t);return e?e.protocol+"//"+e.host+e.pathname:void 0}Ll(t,e,s){if(t==="ui")return s;var i=s,r=this.instance.config.rewriteRequestPath;if(r){var n,o=((n=gi(s))==null?void 0:n.href)||s;i=r(new URL(o)).toString()}if(r&&t==="api"&&Vw.some(h=>e.indexOf(h)===0)){var a=this.Dl(i);if(a){var l,u=this.apiHost,c=this.Nl;((l=c)==null?void 0:l.apiHost)===u&&c.rewriteRequestPath===r||(this.Nl=c={apiHost:u,rewriteRequestPath:r,urls:new Set}),c.urls.add(a)}}return i}isIngestionEndpoint(t){var e=this.Nl,s=this.Dl(t);return e?.apiHost===this.apiHost&&e.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!s&&e.urls.has(s)}endpointFor(t,e){if(e===void 0&&(e=""),e&&(e=e[0]==="/"?e:"/"+e),t==="ui")return this.Ll(t,e,this.uiHost+e);if(t==="flags")return this.Ll(t,e,this.flagsApiHost+e);if(t==="assets"){var s=this.$l(e);if(s)return this.Ll(t,e,""+s+e)}if(this.region===Xl)return this.Ll(t,e,this.apiHost+e);var i=cf+e;switch(t){case"assets":return this.Ll(t,e,"https://"+this.region+"-assets."+i);case"api":return this.Ll(t,e,"https://"+this.region+"."+i)}}},ne=Te("[Surveys]"),Ap=t=>{try{var e=(s=>((i,r)=>"seenSurvey_"+(function(n){return n.current_iteration&&n.current_iteration>0?n.id+"_"+n.current_iteration:n.id})(r))(0,s))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(s){ne.error("Failed to persist survey seen state",s)}},Gw=[sl.Popover,sl.Widget,sl.API],Hw={ignoreConditions:!1,ignoreDelay:!1,displayType:zl.Popover},qw=Te("[PostHog ExternalIntegrations]"),zw={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Kw=class{constructor(t){this._instance=t}bo(t,e){var s;(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,t,i=>{if(i)return qw.error("failed to load script",i);e()})}startIfEnabledOrStop(){var t=this,e=function(){var r,n,o,a=s[0],l=s[1];!l||(r=L.__PosthogExtensions__)!=null&&(r=r.integrations)!=null&&r[a]||t.bo(zw[a],()=>{var u;(u=L.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[a])==null||u.start(t._instance)}),!l&&(n=L.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[a]&&((o=L.__PosthogExtensions__)==null||(o=o.integrations)==null||(o=o[a])==null||o.stop())};for(var s of Object.entries((i=this._instance.config.integrations)!==null&&i!==void 0?i:{})){var i;e()}}},Ww=class{constructor(t,e){this.A=t,this.Js=e,this.ql=new Map,this.ro=!1}add(t){var e=this;return ge(function*(){if(e.ro)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(e.ql.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');e.ql.set(t.name,t);try{var s=t.setup(e.Js);s&&(yield s)}catch(r){var i=e.ql.get(t.name)===t;i&&e.ql.delete(t.name),e.A.error('Failed to set up browser extension "'+t.name+'"',r),i&&e.jl(t)}})()}getExtension(t){return this.ql.get(t)}dispose(){if(!this.ro){this.ro=!0;var t=Array.from(this.ql.values()).reverse();for(var e of(this.ql.clear(),t))this.jl(e)}}jl(t){try{var e=t.dispose==null?void 0:t.dispose();e&&qe(e.then)&&e.then(void 0,s=>{this.A.error('Failed to dispose browser extension "'+t.name+'"',s)})}catch(s){this.A.error('Failed to dispose browser extension "'+t.name+'"',s)}}},Jw=class{constructor(t){this._instance=t}initialize(){}get(t){var e=this._instance.persistence;if(typeof t=="string")return e?.get_property(t);var s={};for(var i of t){var r=e?.get_property(i);S(r)||(s[i]=r)}return s}set(t,e){var s;(s=this._instance.persistence)==null||s.register(typeof t=="string"?{[t]:e}:t)}remove(t){var e;(e=this._instance.persistence)==null||e.unregister(t)}},df="extensionsRemoteConfig",Yw=class{constructor(t){this.instance=t,this.ro=!1,this.A=I,this.Bl=t.Hl,this.kv=new Jw(t),this.onEvent=e=>An(this.instance.on("eventCaptured",s=>{try{e({event:s.event,properties:s.properties})}catch(i){this.A.error("Browser extension event listener failed",i)}})),this.onRemoteConfig=e=>{if(this.ro)return An(()=>{});var s=r=>{try{e(r)}catch(n){this.A.error("Browser extension remote config listener failed",n)}},i=this.instance.zl.on(df,s);return this.Bl&&s(this.Bl),An(i)},this.Ul=new Ww(I.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return(t=this.instance.get_property("$device_id"))!==null&&t!==void 0?t:this.distinctId}get deviceId(){var t=this.instance.get_property(ru);return typeof t=="string"?t:void 0}get library(){return{name:Le.LIB_NAME,version:Le.LIB_VERSION}}get initialPersonProperties(){var t,e;return(t=(e=this.instance.persistence)==null?void 0:e.get_initial_props())!==null&&t!==void 0?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,e,s,i,r=(t=this.instance.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:(e=r?.sessionId)!==null&&e!==void 0?e:"",windowId:(s=r?.windowId)!==null&&s!==void 0?s:"",sessionStartTimestamp:(i=r?.sessionStartTimestamp)!==null&&i!==void 0?i:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.Ul.add(t)}getExtension(t){return this.Ul.getExtension(t)}capture(t,e,s){var i=this;return ge(function*(){s?i.instance.capture(t,e,{timestamp:s.timestamp,uuid:s.uuid,$set:s.set,$set_once:s.setOnce}):i.instance.capture(t,e)})()}registerDynamicEventProperties(t){return An(this.instance.Wl(t))}handleRemoteConfig(t){this.ro||(this.Bl=t,this.instance.zl.emit(df,t))}sendRequest(t,e){var s=this;return ge(function*(){var i;e===void 0&&(e={});var r=s.instance.requestRouter.endpointFor((i=e.target)!==null&&i!==void 0?i:"api",t),n={method:e.method,url:e.query?yr(r,e.query):r,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,compressionFallback:e.target==="flags"&&e.compression==="best-available"?ml.Base64:void 0,timestampMode:e.sentAt};return e.transport==="sendBeacon"?(s.instance._send_request(n),{statusCode:202}):new Promise(o=>{n.callback=o,s.instance._send_request(n)})})()}dispose(){this.ro||(this.ro=!0,this.Ul.dispose())}},ur={},ll=0,cr=()=>{},hf='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Zi="Surveys module not available",ff="sanitize_properties is deprecated. Use before_send instead",Ip="Invalid value for property_denylist config: ",Xw=/^[A-Za-z0-9_-]{1,400}$/,ul=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Qw=["token","distinct_id",$g],ir="posthog",Rp=!xw&&Ye?.indexOf("MSIE")===-1&&Ye?.indexOf("Mozilla")===-1,Zw=t=>{var e={};return t&&t!=="unset"&&("2025-11-30">t||(e.strictMinimumDuration=!0),"2026-05-30">t||(e.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(e.streamNetworkBody=!0),"2026-08-30">t||(e.captureJsonLd=!0)),e},cl=t=>{var e;return k({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:ew(A?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:cr,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Ee&&Q(Ee?.search)&&Ee.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,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(b==null||(e=b.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(s){I.error("Bad HTTP status: "+s.statusCode+" "+s.text)},get_device_id:s=>s,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Bg,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:cr},(s=>({rageclick:s&&s>="2026-05-30"?{content_ignorelist:lw,ignore_text_selection:!0}:!s||"2025-11-30">s||{content_ignorelist:!0},capture_pageview:!s||"2025-05-24">s||"history_change",session_recording:Zw(s),external_scripts_inject_target:s&&s>="2026-01-30"?"head":"body",internal_or_test_user_hostname:s&&s>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:s&&s>="2026-05-30"?250:0,split_storage:!(!s||"2026-05-30">s),detect_google_search_app:!(!s||"2026-05-30">s),disable_capture_url_hashes:!(!s||"2026-06-25">s),cookieWinsOnConflict:!(!s||s==="unset"||"2026-08-29">s)}))(t))},ek=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],gf=t=>{var e={};for(var s of ek){var i=s[0],r=s[1];S(t[i])||(e[r]=t[i])}var n=fe({},e,t),o=t.__preview_external_dependency_versioned_paths;return S(o)||(S(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),Q(o)&&S(t.asset_host)&&(n.asset_host=o)),F(t.property_blacklist)&&(S(t.property_denylist)?n.property_denylist=t.property_blacklist:F(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:I.error(Ip+t.property_denylist)),n},tk=class{constructor(){this.__forceAllowLocalhost=!1}get Vl(){return this.__forceAllowLocalhost}set Vl(t){I.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},_u=(_n=class ns{Gl(e){if(e){var s=this.ql.indexOf(e);s!==-1&&this.ql.splice(s,1)}}Zl(e,s){return this.Gl(e),this.ql.push(s),s.initialize==null||s.initialize(),s}Jl(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}Ql(){if(!(this.Kl||this.config.reuseAnonymousId||this.config.segment||this.Jl())){var e,s,i,r=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";(r||this.config.disable_persistence)&&(this.Xl||(r?(e="persistence is set to '"+this.config.persistence+"'",s=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",i="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(e="persistence is disabled (disable_persistence is true)",s="on every page load",i="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.Kl=!0,console.warn("[PostHog.js]",e+" but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID "+s+", so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. "+i)))}}Yl(){if(!this.Jl()&&this.get_distinct_id()==="$posthog_cookieless"){var e=this.persistence;if(e){this.tu()||e.load(!0);var s=this.get_distinct_id();if(!s||s==="$posthog_cookieless"){var i=this.config.get_device_id(St());this.register({distinct_id:i,$device_id:i}),e.set_property(je,os)}this.eu()}}}get decideEndpointWasHit(){var e,s;return(e=(s=this.featureFlags)==null?void 0:s.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,s;return(e=(s=this.featureFlags)==null?void 0:s.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.iu=!1,this.ru=!1,this.webPerformance=new tk,this.nu=!1,this.version=Le.LIB_VERSION,this.su=new Set,this.ou="",this.zl=new io,this.ql=[],this.au=[],this.Xl=!1,this.Kl=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=cl(),this.SentryIntegration=vw,this.sentryIntegration=i=>(function(r,n){var o=Qg(r,n);return{name:Xg,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.lu=!1,this.uu=null,this.hu=null,this.du=null,this.scrollManager=new Fw(this),this.pageViewManager=new Xh(this),this.rateLimiter=new Aw(this),this.requestRouter=new jw(this),this.consent=new aw(this),this.externalIntegrations=new Kw(this);var s=(e=ns.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(i,r,n)=>{var o=Q(i)?{[i]:r}:i;this.setPersonProperties(o),n?.({})},set_once:(i,r,n)=>{var o=Q(i)?{[i]:r}:i;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",i=>I.info('send "'+i?.event+'"',i))}init(e,s,i){if(i&&i!==ir){var r,n=(r=ur[i])!==null&&r!==void 0?r:new ns;return n._init(e,s,i),ur[i]=n,ur[ir][i]=n,n}return this._init(e,s,i)}_init(e,s,i){var r,n,o;s===void 0&&(s={});var a,l=Q(e)?e.trim():"";if(!l)return I.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 l!==((a=this.config)==null?void 0:a.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+l+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=cl(s.defaults),s.debug=this.vu(s.debug),this.cu=s,this.fu=[],s.person_profiles?this.hu=s.person_profiles:s.process_person&&(this.hu=s.process_person);var u=cl(s.defaults),c=gf(s),h=fe({},u,c,{name:i,token:l});Y(u.rageclick)&&Y(c.rageclick)&&(h.rageclick=fe({},u.rageclick,c.rageclick)),Y(u.session_recording)&&Y(c.session_recording)&&(h.session_recording=fe({},u.session_recording,c.session_recording)),this.set_config(h),this.config.on_xhr_error&&I.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:lt.GZipJS;var g=this.tu();if(this.persistence=new tl(this.config,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tl(k({},this.config,{persistence:"sessionStorage"}),g,!1),this.ou="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!g&&de.Et()){var f=de.Nt(this.ou);F(f)&&f.forEach(x=>{Q(x)&&this.su.add(x)})}else de.Dt(this.ou);var p=k({},this.persistence.props),_=k({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.pu=new Lw(x=>this.gu(x),this.config.request_queue_config),this.mu=new $w(this),this.__request_queue=[];var v=this.Jl();v||(this.sessionManager=new uf(this),this.sessionPropsManager=new af(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((x,le,D)=>{(D!=null&&D.activityTimeout||D!=null&&D.sessionPastMaximumLength||D!=null&&D.crossTabAdoption)&&this.yu()})),this.bu(),this.config.__preview_deferred_init_extensions?(I.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this._u(v)},0)):(I.info("Initializing extensions synchronously"),this._u(v)),Le.DEBUG=Le.DEBUG||this.config.debug,Le.DEBUG&&I.info("Starting in debug mode",{this:this,config:s,thisC:k({},this.config),p,s:_}),!this.config.identity_distinct_id||(r=s.bootstrap)!=null&&r.distinctID||(s.bootstrap=k({},s.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));var m=(n=s.bootstrap)==null?void 0:n.distinctID;if(this.Xl=!!m&&!rr(m),((o=s.bootstrap)==null?void 0:o.distinctID)!==void 0){var y=s.bootstrap.distinctID,w=this.get_distinct_id(),E=this.persistence.get_property(je);if(s.bootstrap.isIdentifiedID&&w!=null&&w!==y&&E==="anonymous")this.identify(y);else if(s.bootstrap.isIdentifiedID&&w!=null&&w!==y&&E==="identified")I.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 T=this.config.get_device_id(St()),C=s.bootstrap.isIdentifiedID?T:y;this.persistence.set_property(je,s.bootstrap.isIdentifiedID?sr:os),this.register({distinct_id:y,$device_id:C})}}if(v)this.register_once({distinct_id:Ka,$device_id:null},"");else if(!this.get_distinct_id()){var q=this.config.get_device_id(St());this.register_once({distinct_id:q,$device_id:q},""),this.persistence.set_property(je,os)}return ae(b,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),ae(b,"pageshow",()=>{var x;this.iu=!1,this.ru||(x=this.mu)==null||x.resume()}),s.segment?Yh(this,()=>this.wu()):this.wu(),qe(this.config._onCapture)&&this.config._onCapture!==cr&&(I.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",x=>this.config._onCapture(x.event,x))),this.config.ip&&I.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.config.disableDeviceModel||(function(){return Ep.apply(this,arguments)})().then(x=>{x&&this.register({[qa]:x})}).catch(cr),this}ku(e){var s=e;return Q(s.name)&&qe(s.setup)}Su(e,s){this.ku(e)?s.push(()=>{this.xu().add(e).catch(()=>e.dispose==null?void 0:e.dispose()).catch(i=>{I.error('Failed to dispose browser extension "'+e.name+'"',i)})}):this.ql.push(e)}bu(){var e,s,i,r,n,o,a=(e=(s=this.config.__extensionClasses)==null?void 0:s.featureFlags)!==null&&e!==void 0?e:(i=ns.__defaultExtensionClasses)==null?void 0:i.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||((o=this.Cu)==null||o.call(this),this.Cu=void 0,this.featureFlags=new a(this)),qe(this.featureFlags.onReloading)&&qe(this.featureFlags.setup)?this.Cu||(this.Cu=this.featureFlags.onReloading(()=>{this.zl.emit("featureFlagsReloading",!0)}),this.xu().add(this.featureFlags)):(r=(n=this.featureFlags).initialize)==null||r.call(n))}_u(e){var s,i,r,n,o,a,l,u=performance.now(),c=k({},ns.__defaultExtensionClasses,this.config.__extensionClasses),h=[];c.exceptions&&this.ql.push(this.exceptions=(s=this.exceptions)!==null&&s!==void 0?s:new c.exceptions(this)),c.historyAutocapture&&this.ql.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this.ql.push(this.tracingHeaders=new c.tracingHeaders(this)),c.siteApps&&this.ql.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this.ql.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||h.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),c.autocapture&&this.Su(this.autocapture=new c.autocapture(this),h),c.surveys&&this.Su(this.surveys=(i=this.surveys)!==null&&i!==void 0?i:new c.surveys(this),h),c.logs&&this.Su(this.logs=(r=this.logs)!==null&&r!==void 0?r:new c.logs(this),h),c.metrics&&this.ql.push(this.metrics=(n=this.metrics)!==null&&n!==void 0?n:new c.metrics(this)),c.conversations&&this.ql.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new c.conversations(this)),c.productTours&&this.ql.push(this.productTours=new c.productTours(this)),c.heatmaps&&this.ql.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this.ql.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this.ql.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this.ql.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,pw)),c.toolbar&&this.ql.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new c.toolbar(this)),c.experiments&&this.ql.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new c.experiments(this)),this.ql.forEach(g=>{g.initialize&&h.push(()=>{g.initialize==null||g.initialize()})}),h.push(()=>{if(this.Tu){var g=this.Tu;this.Tu=void 0,this.ql.forEach(f=>f.onRemoteConfig==null?void 0:f.onRemoteConfig(g))}}),this.Mu(h,u)}Mu(e,s){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&e.length>0)return void setTimeout(()=>{this.Mu(e,s)},0);var i=e.shift();if(i)try{i()}catch(n){I.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-s);this.register_for_session({[Fg]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Mg]:r}),this.config.__preview_deferred_init_extensions&&I.info("PostHog extensions initialized ("+r+"ms)")}Pa(e){var s;if(!A||!A.body)return I.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Pa(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Tu=e),this.Hl=e,this.compression=void 0,e.ok){var i,r=e.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=M(r.supportedCompression,lt.GZipJS)?lt.GZipJS:M(r.supportedCompression,lt.Base64)?lt.Base64:void 0),(i=r.analytics)!=null&&i.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.hu?this.hu:Bg}),(s=this.Iu)==null||s.handleRemoteConfig(e),this.ql.forEach(n=>n.onRemoteConfig==null?void 0:n.onRemoteConfig(e))}wu(){try{this.config.loaded(this)}catch(i){I.critical("`loaded` function failed",i)}if(this.Eu(),this.config.internal_or_test_user_hostname&&Ee!=null&&Ee.hostname){var e=Ee.hostname,s=this.config.internal_or_test_user_hostname;(typeof s=="string"?e===s:s.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.Jl())&&this.Ru()},1),this.Au=new lp(this),this.Au.load()}Eu(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.pu)==null||e.enable())}_dom_loaded(){this.is_capturing()&&bn(this.__request_queue,e=>this.gu(e)),this.__request_queue=[],this.Eu()}_handle_unload(){var e,s,i,r,n;this.iu=!0,(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(s=this.metrics)==null||s.flush("sendBeacon"),this.config.request_batching?(this.Pu()&&this.capture(Dh),(i=this.logs)==null||i.flushLogs("sendBeacon"),(r=this.pu)==null||r.unload(),(n=this.mu)==null||n.unload()):this.Pu()&&this.capture(Dh,null,{transport:"sendBeacon"})}_send_request(e){var s;this.__loaded?Rp?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=k({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?(s=this.compression)!==null&&s!==void 0?s:e.compressionFallback:e.compression,(S(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(i=>{var r,n,o,a=k({},i);a.timeout=a.timeout||6e4;var l,u,c,h,g,f=(r=a.transport)!==null&&r!==void 0?r:"fetch";f==="sendBeacon"&&S(a.compression)&&a.data&&(a.compression=lt.Base64),a.method==="POST"&&a.data&&(a.timestampMode==="capture-body"?a.data={api_key:(u=(g=(h=(F(l=a.data)?l:[l]).map(m=>k({},m,m.timestamp instanceof Date&&!isNaN(m.timestamp.getTime())?{timestamp:m.timestamp.toISOString()}:{})))[0])==null||(c=g.properties)==null?void 0:c.token)!==null&&u!==void 0?u:g?.token,batch:h,sent_at:new Date().toISOString()}:a.timestampMode==="body"&&(a.data=(function(m,y){return y===void 0&&(y=new Date().toISOString()),F(m)?m.map(w=>k({},w,{sent_at:y})):k({},m,{sent_at:y})})(a.data))),a.url=of(a.url,a.method,a.compression,a.timestampMode);var p=Bn.filter(m=>!a.disableTransport||!m.transport||!a.disableTransport.includes(m.transport)),_=(n=(o=(function(m,y){for(var w=0;m.length>w;w++)if(y(m[w]))return m[w]})(p,m=>m.transport===f))==null?void 0:o.method)!==null&&n!==void 0?n:p[0].method;if(!_)throw new Error("No available transport method");var v=m=>{try{_(m)}catch(y){_p(y)?I.warn(y):I.error(y),a.callback==null||a.callback({statusCode:0,error:y})}};f!=="sendBeacon"&&a.data&&a.compression===lt.GZipJS&&LE&&typeof Promise<"u"&&!Mn?Dw(a).then(m=>{v(m)}).catch(m=>{if(Th(m))return Mn=!0,void v(k({},a,{compression:void 0,url:of(i.url,i.method,void 0,i.timestampMode)}));(y=>{if(!y||typeof y!="object")return!1;var w="name"in y?String(y.name):"";return Th(y)||w===mg})(m)&&(Mn=!0),v(a)}):_(a)})(k({},e,{callback:i=>{var r,n;this.rateLimiter.checkForLimiting(i),400>i.statusCode||(r=(n=this.config).on_request_error)==null||r.call(n,i),e.callback==null||e.callback(i)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}gu(e){this.mu?this.mu.retriableRequest(e):this._send_request(e)}_execute_array(e){ll++;try{var s,i=[],r=[],n=[];bn(e,a=>{if(a)if(F(s=a[0]))n.push(a);else if(qe(a))try{a.call(this)}catch(l){I.error("Error executing queued PostHog call",a,l)}else F(a)&&s==="alias"?i.push(a):F(a)&&s.indexOf("capture")!==-1&&qe(this[s])?n.push(a):r.push(a)});var o=function(a,l){bn(a,function(u){try{if(F(u[0])){var c=l;ie(u,function(h){c=c[h[0]].apply(c,h.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(h){I.error("Error executing queued PostHog call",u,h)}})};o(i,this),o(r,this),o(n,this)}finally{ll--}}push(e){if(ll>0&&F(e)&&Q(e[0])){var s=ns.prototype[e[0]];qe(s)&&s.apply(this,e.slice(1))}else this._execute_array([e])}Fu(){var e,s=(e=this.persistence)==null?void 0:e.get_property(Et);return Q(s)&&ul.test(s)?{value:s,delivered:!1}:Y(s)&&Q(s.value)&&ul.test(s.value)?{value:s.value,delivered:s.delivered===!0}:void 0}Ou(e,s,i,r){if(this.persistence){this.persistence.refreshKey(Et);var n=this.Fu();if(!r){if(i)return Q(s)&&ul.test(s)?(s!==n?.value&&this.persistence.register({[Et]:{value:s,delivered:!1}}),{value:s,pending:s!==n?.value||!n.delivered}):void this.persistence.unregister(Et);if(Q(e)&&Xw.test(e)){if(n?.value.split(".")[3]===e)return{value:n.value,pending:!n.delivered};var o="fb.1."+Date.now()+"."+e;return this.persistence.register({[Et]:{value:o,delivered:!1}}),{value:o,pending:!0}}return n?{value:n.value,pending:!n.delivered}:void 0}this.persistence.unregister(Et)}}$u(e){if(this.persistence){this.persistence.refreshKey(Et);var s=this.Fu();s?.value!==e||s.delivered||this.persistence.register({[Et]:{value:e,delivered:!0}})}}capture(e,s,i){var r,n,o,a,l,u,c,h,g,f;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.pu){if(this.is_capturing())if(!S(e)&&Q(e)){this.Yl();var p=!this.config.opt_out_useragent_filter&&this._is_bot();if(!p||this.config.__preview_capture_bot_pageviews){var _=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(_==null||!_.isRateLimited){var v;s!=null&&s.$current_url&&!Q(s?.$current_url)&&(I.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),s==null||delete s.$current_url),e!=="$exception"||i!=null&&i.Du||I.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&&(v=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 m=new Date,y=i?.timestamp||m,w=Eh(i?.uuid,St),E={uuid:w,event:e,properties:this.calculateEventProperties(e,s||{},y,w)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&p&&(E.event="$bot_pageview",E.properties.$browser_type="bot"),_&&(E.properties.$lib_rate_limit_remaining_tokens=_.remainingTokens);var T=e==="$feature_flag_called"&&E.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;i!=null&&i.$set&&!T&&(E.$set=i?.$set);var C=Y(s?.$set)?s.$set:void 0,q=!(i==null||!i.$set)&&"$fbc"in i.$set,x=q||!!C&&"$fbc"in C,le=q?i==null||(r=i.$set)==null?void 0:r[za]:C?.[za],D=F(s?.$unset)?s.$unset:[],P=i?.$unset||[],G=D.indexOf("$fbc")!==-1||P.indexOf("$fbc")!==-1,N=this.Ou((n=v)==null?void 0:n.fbclid,le,x,G);N&&E.properties.$process_person_profile===!0&&N.pending&&!x&&!T&&(E.$set=k({[za]:N.value},E.$set));var U=i?.$unset;U&&(E.$unset=U);var ue=T?void 0:this.Lu(i?.$set_once,e!==Nh,e===Bl);if(ue&&(E.$set_once=ue),i!=null&&i._noTruncate||(c=this.config.properties_string_max_length,h=E,g=X=>Q(X)?X.slice(0,c):X,f=new Set,E=(function X(se,xe){if(se!==Object(se))return g?g(se):se;if(!f.has(se)){var Se;if(f.add(se),F(se))Se=[],bn(se,Me=>{Se.push(X(Me))});else{var j={};ie(mr(se)?Ug(se):se,(Me,hs)=>{f.has(Me)||(j[hs]=X(Me,hs))}),Se=j}return Se}})(h)),E.timestamp=y,S(i?.timestamp)||(E.properties.$event_time_override_provided=!0,E.properties.$event_time_override_system_time=m),T&&(E.properties=(function(X,se){se===void 0&&(se=[]);var xe={},Se=j=>{X[j]!==void 0&&(xe[j]=X[j])};return bS.forEach(Se),se.forEach(Se),xe})(E.properties,Qw)),e===Jt.DISMISSED||e===Jt.SENT){var Oe=s?.[il.SURVEY_ID],he=s?.[il.SURVEY_ITERATION];Ap({id:Oe,current_iteration:he}),E.$set=k({},E.$set,{[Bw({id:Oe,current_iteration:he},e===Jt.SENT?"responded":"dismissed")]:!0})}else e===Jt.SHOWN&&(E.$set=k({},E.$set,{[il.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===kw.SHOWN){var oe=s?.[ef.TOUR_TYPE];oe&&(E.$set=k({},E.$set,{[ef.TOUR_LAST_SEEN_DATE+"/"+oe]:new Date().toISOString()}))}var O=k({},E.properties.$set,E.$set);if(nt(O)||this.setPersonPropertiesForFlags(O),!H(this.config.before_send)){var B=this.bs(E);if(!B)return;(E=B).uuid=Eh(E.uuid,St)}var V=(o=(a=E.$set)==null?void 0:a.$fbc)!==null&&o!==void 0?o:Y((l=E.properties)==null?void 0:l.$set)?E.properties.$set.$fbc:void 0,K=N!=null&&N.pending&&V===N.value?N.value:void 0;this.zl.emit("eventCaptured",E);var J,W=(u=i?._url)!==null&&u!==void 0?u:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),Z=k({method:"POST",url:W,data:E,compression:"best-available",timestampMode:i?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(W)?"body":"capture-body",batchKey:i?._batchKey},i!=null&&i.transport?{transport:i.transport}:{},K?{fireCallbackOnDrop:!0,callback:X=>{X.statusCode>=200&&300>X.statusCode&&this.$u(K)}}:{});return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly||K?(!Z.transport&&!Z.callback&&nt((J=this.config.request_headers)!==null&&J!==void 0?J:{})&&this.iu&&(Z.transport="sendBeacon"),this.gu(Z)):this.pu.enqueue(Z),E}I.critical("This capture call is ignored due to client rate limiting.")}}else I.error("No event name provided to posthog.capture")}else I.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",s=>e(s.event,s))}getExtension(e){var s;return(s=this.Iu)==null?void 0:s.getExtension(e)}xu(){var e;return(e=this.Iu)!==null&&e!==void 0?e:this.Iu=new Yw(this)}Wl(e){this.au.push(e);var s=!0;return()=>{if(s){s=!1;var i=this.au.indexOf(e);i!==-1&&this.au.splice(i,1)}}}Nu(e){var s,i,r;return e===void 0&&(e=!0),!((s=this.persistence)==null||!s.consumeCookieIdentityChange())&&(this.du=null,this.persistence.get_property("$user_state")==="anonymous"&&((r=this.sessionPersistence)==null||r.clear(),this.su.clear(),this.qu()),(i=this.featureFlags)==null||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,s,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return s;this.persistence.syncCookieProperties(),this.Nu();var o=n?void 0:this.persistence.remove_event_timer(e),a=k({},s);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.Jl()&&(a[$g]=!0),e==="$snapshot"){var l=k({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Q(a.distinct_id)&&!Re(a.distinct_id)||rr(a.distinct_id))&&I.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=(function(q,x,le,D){var P,G,N,U;if(D===void 0&&(D=!1),!Ye)return{};var ue,Oe=q?[...vi,...x||[]]:[],he=fg(Ye),oe=he[0],O=he[1],B=(function(Ds){for(var Ns=0;yh.length>Ns;Ns++){var Si,Ls=yh[Ns],wi=Ls[1],yu=Ls[2],bu=Ds.match(Ls[0]);if(bu)return[wi,((Si=yu&&Ds.match(yu)||bu)==null?void 0:Si[1])||""]}return["",""]})(Ye),V=B[0],K=B[1],J=(ue="u">typeof navigator?navigator:void 0)!=null&&ue.brave?{brave:!0}:{},W={};S(le)||(W.detectGoogleSearchApp=le);var Z={},X=(P=navigator)==null||(P=P.userAgentData)==null?void 0:P.platform,se=(G=navigator)==null?void 0:G.maxTouchPoints,xe=b==null||(N=b.screen)==null?void 0:N.width,Se=b==null||(U=b.screen)==null?void 0:U.height,j=b?.devicePixelRatio;S(X)||(Z.userAgentDataPlatform=X),S(se)||(Z.maxTouchPoints=se),S(xe)||(Z.screenWidth=xe),S(Se)||(Z.screenHeight=Se),S(j)||(Z.devicePixelRatio=j);var Me,hs,De,mi,yi,bi,ct,Ze,Ei=fe(cu({$os:oe,$os_version:O,$browser:hg(Ye,navigator.vendor,J,W),$webview_app:V,$webview_app_version:K,$device:mh(Ye),$device_type:(hs=Ye,De=Z,Ze=mh(hs),Ze===jf||Ze===Vf||Ze==="Kobo"||Ze==="Kindle Fire"||Ze===eg?Vn:Ze===jn||Ze===lo||Ze===Gn||Ze===yl?"Console":Ze===Gf?"Wearable":Ze?di:De?.userAgentDataPlatform==="Android"&&((mi=De?.maxTouchPoints)!==null&&mi!==void 0?mi:0)>0?600>Math.min((yi=De?.screenWidth)!==null&&yi!==void 0?yi:0,(bi=De?.screenHeight)!==null&&bi!==void 0?bi:0)/((ct=De?.devicePixelRatio)!==null&&ct!==void 0?ct:1)?di:Vn:"Desktop"),$timezone:ap(),$timezone_offset:Ew()}),{$current_url:vr(D?ds(Ee?.href):Ee?.href,Oe,_r),$host:Ee?.host,$pathname:Ee?.pathname,$raw_user_agent:Ye.length>1e3?Ye.substring(0,997)+"...":Ye,$browser_version:YE(Ye,navigator.vendor,J,W),$browser_language:Qh(),$browser_language_prefix:(Me=Qh(),typeof Me=="string"?Me.split("-")[0]:void 0),$screen_height:b?.screen.height,$screen_width:b?.screen.width,$viewport_height:b?.innerHeight,$viewport_width:b?.innerWidth,$lib:Yt.LIB_NAME,$lib_version:Yt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Yt.SDK_DIST_CHANNEL&&(Ei.$sdk_dist_channel=Yt.SDK_DIST_CHANNEL),Ei})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var h=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0),g=h.windowId;a.$session_id=h.sessionId,a.$window_id=g}this.sessionPropsManager&&fe(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&fe(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this.mu)==null?void 0:f.length}catch(q){a.$sdk_debug_error_capturing_properties=String(q)}if(this.requestRouter.region===Xl&&(a.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||n?e!=="$pageleave"||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=fe(a,u),e==="$pageview"&&A&&(a.title=A.title),!S(o)){var p=i.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}Ye&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");var _=this.persistence.properties(),v=this.sessionPersistence.properties(),m=a.$groups,y=_.$groups;Y(m)&&!nt(m)&&(a.$groups=k({},Y(y)?y:{},m)),ie(["$referrer","$referring_domain"],q=>{q in _&&delete v[q]});var w={};if(this.au.length>0)for(var E of this.au.slice())try{fe(w,E())}catch(q){I.error("Failed to produce browser extension event properties",q)}(a=fe({},c,_,v,k({},w,a))).$is_identified=this._isIdentified(),F(this.config.property_denylist)?ie(this.config.property_denylist,function(q){delete a[q]}):I.error(Ip+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var T=this.config.sanitize_properties;T&&(I.error(ff),a=T(a,e));var C=this.ju();return a.$process_person_profile=C,C&&!n&&this.Bu("_calculate_event_properties"),a}Lu(e,s,i){var r;if(s===void 0&&(s=!0),i===void 0&&(i=!1),!this.persistence||!this.ju()||this.nu&&!i)return e;var n=fe({},this.persistence.get_initial_props(),((r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps())||{},e||{}),o=this.config.sanitize_properties;return o&&(I.error(ff),n=o(n,"$set_once")),s&&(this.nu=!0),nt(n)?void 0:n}register(e,s){var i;(i=this.persistence)==null||i.register(e,s)}register_once(e,s,i){var r;(r=this.persistence)==null||r.register_once(e,s,i)}register_for_session(e){var s,i;(s=this.persistence)==null||s.syncCookieProperties(),this.Nu(),(i=this.sessionPersistence)==null||i.register(e),Object.keys(e).forEach(r=>this.su.add(r)),this.qu()}unregister(e){var s;(s=this.persistence)==null||s.unregister(e)}unregister_for_session(e){var s;(s=this.sessionPersistence)==null||s.unregister(e),this.su.delete(e),this.qu()}Hu(e,s){this.register({[e]:s})}yu(){this.su.forEach(e=>{var s;(s=this.sessionPersistence)==null||s.unregister(e)}),this.su.clear(),this.qu()}qu(){var e;if(this.ou)if(this.config.persistence==="memory"||(e=this.sessionPersistence)!=null&&e.gi||!de.Et())de.Dt(this.ou);else{var s=[];this.su.forEach(i=>s.push(i)),s.length>0?de.Ot(this.ou,s):de.Dt(this.ou)}}getFeatureFlag(e,s){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlag(e,s)}getFeatureFlagPayload(e){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlagPayload(e)}getFeatureFlagResult(e,s){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagResult(e,s)}getAllFeatureFlags(){var e,s;return(e=(s=this.featureFlags)==null?void 0:s.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,s){var i,r;return(i=(r=this.featureFlags)==null?void 0:r.isFeatureEnabled(e,s))!==null&&i!==void 0?i:s?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,s,i){var r;(r=this.featureFlags)==null||r.updateFlags(e,s,i)}updateEarlyAccessFeatureEnrollment(e,s,i){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,s,i)}getEarlyAccessFeatures(e,s,i){var r;return s===void 0&&(s=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,s,i)}on(e,s){return this.zl.on(e,s)}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:Zi}),()=>{})}onSessionId(e){var s,i;return(s=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&s!==void 0?s:()=>{}}getSurveys(e,s){s===void 0&&(s=!1),this.surveys?this.surveys.getSurveys(e,s):e([],{isLoaded:!1,error:Zi})}getActiveMatchingSurveys(e,s){s===void 0&&(s=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,s):e([],{isLoaded:!1,error:Zi})}renderSurvey(e,s){var i;(i=this.surveys)==null||i.renderSurvey(e,s)}displaySurvey(e,s){var i;s===void 0&&(s=Hw),(i=this.surveys)==null||i.displaySurvey(e,s)}cancelPendingSurvey(e){var s;(s=this.surveys)==null||s.cancelPendingSurvey(e)}canRenderSurvey(e){var s,i;return(s=(i=this.surveys)==null?void 0:i.canRenderSurvey(e))!==null&&s!==void 0?s:{visible:!1,disabledReason:Zi}}canRenderSurveyAsync(e,s){var i,r;return s===void 0&&(s=!1),(i=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,s))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:Zi})}zu(e){return!e||rr(e)?(I.critical("Unique user id has not been set in posthog.identify"),!1):e==="$posthog_cookieless"?(I.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())||(I.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,s,i){if(!this.__loaded||!this.persistence)return I.uninitializedWarning("posthog.identify");if(Re(e)&&(e=e.toString(),I.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.zu(e)&&this.Bu("posthog.identify")){this.Yl();var r=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,o=this.Nu(!1),a=this.persistence.va(),l=!1;try{var u=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:u},""),e!==u&&e!==this.get_property("__alias")&&(this.unregister(Jn),this.register({distinct_id:e}));var c=(this.persistence.get_property("$user_state")||"anonymous")===os,h=e!==u,g=!h&&c;if(h&&c){var f,p=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:u};this.persistence.set_property(je,sr),this.setPersonPropertiesForFlags({$set:s||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.ca(),this.capture(Bl,p,{$set:s||{},$set_once:i||{}}),this.du=al(e,s,i),(f=this.featureFlags)==null||f.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:u)}else if(g){this.persistence.set_property(je,sr);var _=s||{},v=i||{};this.setPersonPropertiesForFlags({$set:_,$set_once:v},!1),this.config.cookieWinsOnConflict&&this.persistence.ca(),this.capture("$set",{$set:_,$set_once:v}),this.du=al(e,s,i)}else(s||i)&&this.setPersonProperties(s,i);h||n||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(us)):g&&(s||i)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.ga(l)}}}setPersonProperties(e,s){if((e||s)&&this.Bu("posthog.setPersonProperties")){var i=al(this.get_distinct_id(),e,s);this.du!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:s||{}},!0),this.capture("$set",{$set:e||{},$set_once:s||{}}),this.du=i):I.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var s,i=(F(e)?e:[e]).filter(r=>Q(r)&&r.length>0);i.length!==0&&this.Bu("posthog.unsetPersonProperties")&&((s=this.featureFlags)==null||s.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.du=null)}group(e,s,i){var r;if(e&&s){(r=this.persistence)==null||r.syncCookieProperties(),this.Nu();var n=this.getGroups(),o=n[e]!==s;if(o&&this.resetGroupPropertiesForFlags(e),this.register({$groups:k({},n,{[e]:s})}),(o||i)&&this.ju()){var a={$group_type:e,$group_key:s};i&&(a.$group_set=i),this.capture(Nh,a)}i&&this.setGroupPropertiesForFlags({[e]:i}),o&&!i&&this.reloadFeatureFlags()}else I.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,s){var i;s===void 0&&(s=!0),(i=this.featureFlags)==null||i.setPersonPropertiesForFlags(e,s)}resetPersonPropertiesForFlags(e){var s;e===void 0&&(e=!0),(s=this.featureFlags)==null||s.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,s){var i;s===void 0&&(s=!0),this.Bu("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)==null||i.setGroupPropertiesForFlags(e,s))}resetGroupPropertiesForFlags(e){var s;(s=this.featureFlags)==null||s.resetGroupPropertiesForFlags(e)}reset(e){var s=Xe(e)?e:e?.resetDeviceID,i=Xe(e)||e==null?void 0:e.bootstrap;this.Uu(s,!1,i)}Uu(e,s,i){var r,n,o,a;if(s===void 0&&(s=!1),I.info("reset"),!this.__loaded)return I.uninitializedWarning("posthog.reset");var l=i?.sessionID;this.config.bootstrap=i||((r=this.cu)==null?void 0:r.bootstrap)||{},(n=this.featureFlags)==null||n.updateConfig==null||n.updateConfig(this.config,this.Fa());var u=this.get_property(ru),c=this.get_property(qa),h=this.get_property(ui);(o=this.sessionRecording)==null||o.flushBeforeIdentityReset();var g=this.is_capturing();this.consent.reset(),s||!g||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var f=(a=this.persistence)==null||a.va==null?void 0:a.va(),p=!1;try{var _,v,m,y,w,E,T,C,q,x,le,D,P;if((_=this.persistence)==null||_.clear(),(v=this.sessionPersistence)==null||v.clear(),this.su.clear(),this.qu(),S(h)||(m=this.persistence)==null||m.register({[ui]:h}),(y=this.surveys)==null||y.reset(),(w=this.featureFlags)==null||w.reset(),(E=this.conversations)==null||E.reset(),(T=this.logs)==null||T.reset(),(C=this.metrics)==null||C.reset(),(q=this.persistence)==null||q.set_property(je,os),(x=this.sessionManager)==null||x.resetSessionId(),this.du=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Ka,$device_id:null},"");else{var G=this.config.get_device_id(St());this.register_once({distinct_id:G,$device_id:e?G:u},""),e||S(c)||this.register({[qa]:c})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID===void 0||this.Jl()||((P=this.persistence)==null||P.set_property(je,i.isIdentifiedID?sr:os),this.register({distinct_id:i.distinctID})),(le=this.featureFlags)==null||le.initialize(),!(S(l)||(D=this.sessionManager)!=null&&D.setBootstrapSessionId(l,!0)))){var N=k({},i);delete N.sessionID,this.config.bootstrap=N}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,p=!0}finally{var U;f&&((U=this.persistence)==null||U.ga==null||U.ga(p))}this.reloadFeatureFlags()}shutdown(e){var s=this;return ge(function*(){var i,r,n,o,a,l,u;if(s.__loaded){s.ru=!0,s.xu().dispose(),(i=s.sessionRecording)==null||i.dispose(),(r=s.logs)==null||r.flushLogs("sendBeacon"),(n=s.metrics)==null||n.flush("sendBeacon"),(o=s.pu)==null||o.unload(),(a=s.mu)==null||a.unload();try{var c;(c=s.featureFlags)==null||c.destroy()}catch(h){I.error("Error while destroying feature flags",h)}(l=s.persistence)==null||l.destroy(),(u=s.sessionPersistence)==null||u.destroy()}else I.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,s){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=s,this.alias(e),(i=this.conversations)==null||i.Wu()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)==null||e.Vu()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,s;return(e=(s=this.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var s=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=s.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+s.sessionId);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,s){return e===this.get_property("$people_distinct_id")?(I.critical("Attempting to create alias for existing People user - aborting."),-2):this.Bu("posthog.alias")?(S(s)&&(s=this.get_distinct_id()),e!==s?(this.Hu(Jn,e),this.capture("$create_alias",{alias:e,distinct_id:s})):(I.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var s=k({},this.config);if(Y(e)){var i,r,n,o,a,l,u,c,h,g,f,p,_;fe(this.config,gf(e));var v=this.tu();(i=this.persistence)==null||i.update_config(this.config,s,v),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tl(k({},this.config,{persistence:"sessionStorage"}),v,!1);var m=this.vu(this.config.debug);Xe(m)&&(this.config.debug=m),Xe(this.config.debug)&&(this.config.debug?(Le.DEBUG=!0,ee.Et()&&ee.Ot("ph_debug",!0),I.info("set_config",{config:e,oldConfig:s,newConfig:k({},this.config)})):(Le.DEBUG=!1,ee.Et()&&ee.Dt("ph_debug"))),(r=this.featureFlags)==null||r.updateConfig==null||r.updateConfig(this.config,this.Fa()),(n=this.exceptionObserver)==null||n.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(l=this.tracingHeaders)==null||l.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(c=this.heatmaps)==null||c.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&((h=this.historyAutocapture)==null||h.startIfEnabledOrStop()),(g=this.exceptionObserver)==null||g.startIfEnabledOrStop(),(f=this.deadClicksAutocapture)==null||f.startIfEnabledOrStop(),(p=this.surveys)==null||p.loadIfEnabled(),this.eu(),(_=this.externalIntegrations)==null||_.startIfEnabledOrStop(),!s.segment&&this.config.segment&&this.persistence&&Yh(this,cr,!1)}}_overrideSDKInfo(e,s){Le.LIB_NAME=e,Le.LIB_VERSION=s}startSessionRecording(e){var s,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)&&((s=this.sessionManager)==null||s.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,s){try{if(!this.exceptions)return;var i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(k({},i,s))}catch{return}}addExceptionStep(e,s){var i;(i=this.exceptions)==null||i.addExceptionStep(e,s)}captureLog(e){var s;(s=this.logs)==null||s.captureLog(e)}get logger(){var e,s;return(e=(s=this.logs)==null?void 0:s.logger)!==null&&e!==void 0?e:ns.Gu}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var s,i;return(s=(i=this.toolbar)==null?void 0:i.loadToolbar(e))!==null&&s!==void 0&&s}get_property(e){var s;return(s=this.persistence)==null?void 0:s.props[e]}getSessionProperty(e){var s;return(s=this.sessionPersistence)==null?void 0:s.props[e]}toString(){var e,s=(e=this.config.name)!==null&&e!==void 0?e:ir;return s!==ir&&(s="posthog."+s),s}_isIdentified(){var e,s;return((e=this.persistence)==null?void 0:e.get_property("$user_state"))==="identified"||((s=this.sessionPersistence)==null?void 0:s.get_property("$user_state"))==="identified"}ju(){var e,s;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&nt(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e.__alias)&&((s=this.persistence)==null||(s=s.props)==null||!s.$epp))}Pu(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.ju()||this.Bu("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Bu("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Bu(e){return this.config.person_profiles==="never"?(I.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Ql(),this.Hu(lu,!0),!0)}tu(){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!=="on_reject")}eu(){var e,s,i,r,n,o=this.tu();return this.is_capturing()||(e=this.logs)==null||e.Zu(),((s=this.persistence)==null?void 0:s.gi)!==o&&((i=this.persistence)==null||i.set_disabled(o)),((r=this.sessionPersistence)==null?void 0:r.gi)!==o&&((n=this.sessionPersistence)==null||n.set_disabled(o)),o&&(this.su.clear(),this.qu()),o}opt_in_capturing(e){var s,i,r;if(this.config.cookieless_mode!=="always"){if(this.Jl()){var n,o,a,l,u,c;(n=this.sessionRecording)==null||n.dispose({discardBufferedEvents:!0}),this.Uu(!0,!0),(o=this.sessionManager)==null||o.destroy(),(a=this.pageViewManager)==null||a.destroy(),this.sessionManager=new uf(this),this.pageViewManager=new Xh(this),this.persistence&&(this.sessionPropsManager=new af(this,this.sessionManager,this.persistence));var h,g=(l=(u=this.config.__extensionClasses)==null?void 0:u.sessionRecording)!==null&&l!==void 0?l:(c=ns.__defaultExtensionClasses)==null?void 0:c.sessionRecording;g&&(this.sessionRecording=this.Zl(this.sessionRecording,new g(this)),this.Hl&&((h=this.sessionRecording)==null||h.onRemoteConfig==null||h.onRemoteConfig(this.Hl)))}this.consent.optInOut(!0),this.eu(),this.Eu(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((i=this.surveys)==null||i.loadIfEnabled()),(S(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((r=e?.captureEventName)!==null&&r!==void 0?r:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ru()}else I.warn(hf)}opt_out_capturing(){if(this.config.cookieless_mode!=="always"){var e,s,i=this.config.cookieless_mode==="on_reject"?this.sessionRecording:void 0;i?.dispose({discardBufferedEvents:!0}),this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.Uu(!0,!0),this.consent.optInOut(!1),this.eu(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:Ka,$device_id:null}),this.Gl(i),this.sessionRecording=void 0,(e=this.sessionManager)==null||e.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Ru(),this.Eu())}else I.warn(hf)}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==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.eu()}_is_bot(){return Fe?bp(Fe,this.config.custom_blocked_useragents):void 0}Ru(){A&&(A.visibilityState==="visible"?this.lu||(this.lu=!0,this.capture(uu,{title:A.title},{send_instantly:!0}),this.uu&&(A.removeEventListener(hi,this.uu),this.uu=null)):this.uu||(this.uu=this.Ru.bind(this),ae(A,hi,this.uu)))}debug(e){e===!1?(b?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(b?.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}))}Fa(){var e=this.cu||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(I.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):(function(s,i,r,n,o){var a=i in s&&!H(s[i]),l=r in s&&!H(s[r]);return a?s[i]:!!l&&(o&&o.warn("Config field '"+r+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),s[r])})(e,"advanced_disable_flags","advanced_disable_decide",0,I)}bs(e){var s;if(H(this.config.before_send))return e;var i=Object.keys((s=e.properties)!==null&&s!==void 0?s:{}).filter(UE),r=F(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var o of r)try{if(n=o(n),H(n)){var a="Event '"+e.event+"' was rejected in beforeSend function";return BE(e.event)?I.warn(a+". This can cause unexpected behavior."):I.info(a),null}n.properties&&!nt(n.properties)||I.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}catch(u){return I.error("Error in beforeSend function for event '"+e.event+"':",u),null}for(var l of i)if(n.properties&&H(n.properties[l]))return I.warn("Event '"+e.event+"' had its '"+l+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return n}getPageViewId(){var e;return(e=this.pageViewManager.ko)==null?void 0:e.pageViewId}captureTraceFeedback(e,s){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:s})}captureTraceMetric(e,s,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:s,$ai_metric_value:String(i)})}vu(e){var s=Xe(e)&&!e,i=ee.Et()&&ee.Lt("ph_debug")==="true";return!s&&(!!i||e)}},_n.__defaultExtensionClasses={},_n.Gu=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),_n);(function(t,e){for(var s=0;e.length>s;s++)t.prototype[e[s]]=QS(t.prototype[e[s]])})(_u,["identify"]);Tp=class{constructor(t){this.disabled=t===!1;var e=Y(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,s){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(t-i.x)+Math.abs(e-i.y)<this.thresholdPx&&this.timeoutMs>s-i.timestamp){if(this.clicks.push({x:t,y:e,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:s}];return!1}},dl="$copy_autocapture",Rn=Te("[AutoCapture]");rk=class{zs(){this.Us=void 0,clearTimeout(this.Ws),this.Ws=void 0}Vs(t){var e;if(!ci(t))return!0;for(var s,i=(e=this.Gs().css_selector_ignorelist)!==null&&e!==void 0?e:Za,r=new Set,n=t,o=function(){if(r.size>=1e3||r.has(n))return{v:!0};r.add(n);var a=n,l=fi(a);if(M(l,"ph-no-capture")||M(l,"ph-sensitive")||pr(a)||i.some(c=>Hl(a,c)))return{v:!0};var u=n.parentNode;n=du(u)?u.host:u&&Dt(u)?u:null};n;)if(s=o())return s.v;return!1}Zs(t){if(this.isEnabled&&t.type!=="pointercancel")if(t.type!=="pointerdown"){var e=this.Us;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.zs():t.type==="pointerup"&&(e.released=!0,this.Ws=setTimeout(()=>this.zs(),0)))}else{var s;this.zs();var i=or(t);t.isPrimary&&t.button===0&&!t.ctrlKey&&i&&Dt(i)&&(this.Us={target:i,excluded:this.Vs(i),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:(s=this.Js)==null?void 0:s.distinctId})}else this.zs()}Qs(t){var e,s=this.Us;this.zs();var i=or(t);if(s!=null&&s.released&&s.target.isConnected&&s.distinctId===((e=this.Js)==null?void 0:e.distinctId)&&t.pointerId===s.id&&(t.detail>0||t.pointerType==="touch"||t.pointerType==="pen")&&t.button===0&&5>=Math.abs(t.clientX-s.x)&&5>=Math.abs(t.clientY-s.y)&&i&&(Ge(i,"html")||Ge(i,"body"))){var r;if(s.excluded)return null;var n=(r=this.Gs().css_selector_ignorelist)!==null&&r!==void 0?r:Za;return[i,A?.documentElement,A?.body].some(o=>{if(!o)return!1;var a=fi(o);return M(a,"ph-no-capture")||M(a,"ph-sensitive")||!ci(o)||pr(o)||n.some(l=>Hl(o,l))})?null:s.target}}constructor(t){this.Ks=t,this.name="autocapture",this.Xs=!1,this.Ys=null,this.eo=!1,this.io=!1,this.Rn={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.ro=!1,this.Ks.refresh(this.Rn),this.rageclicks=new Tp(this.Rn.rageclick),this.no=null}setup(t){this.so(),this.Js=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.ro?e.dispose():(this.oo=e,this.startIfEnabled())}dispose(){var t;this.ro||(this.ro=!0,this.Js=void 0,(t=this.oo)==null||t.dispose(),this.oo=void 0,this.ao())}Gs(){return this.Ks.refresh(this.Rn),this.Rn}so(){var t,e;return this.Gs(),this.Rn.url_allowlist=(t=this.Rn.url_allowlist)==null?void 0:t.map(s=>new RegExp(s)),this.Rn.url_ignorelist=(e=this.Rn.url_ignorelist)==null?void 0:e.map(s=>new RegExp(s)),this.Rn}lo(){if(this.isBrowserSupported()){if(b&&A){var t=this.uo=s=>{s=s||b?.event;try{if(s.type==="blur")return void this.zs();if(s.type.indexOf("pointer")===0)return void this.Zs(s);var i=s.type==="click"?this.Qs(s):void 0;if(Ie(i))return;this.ho(s,"$autocapture",i)}catch(r){Rn.error("Failed to capture event",r)}};if(ae(b,"blur",t),ae(A,"submit",t,{capture:!0}),ae(A,"change",t,{capture:!0}),ae(A,"click",t,{capture:!0}),ie(["pointerdown","pointermove","pointerup","pointercancel"],s=>{ae(A,s,t,{capture:!0})}),this.Gs().capture_copied_text){var e=this.do=s=>{s=s||b?.event;try{this.ho(s,dl)}catch(i){Rn.error("Failed to capture clipboard event",i)}};ae(A,"copy",e,{capture:!0}),ae(A,"cut",e,{capture:!0}),ae(A,"paste",e,{capture:!0})}}}else Rn.info("Disabling Automatic Event Collection because this browser is not supported")}ao(){this.zs(),this.uo&&(b?.removeEventListener("blur",this.uo),ie(["pointerdown","pointermove","pointerup","pointercancel"],t=>{A?.removeEventListener(t,this.uo,!0)}),A?.removeEventListener("submit",this.uo,!0),A?.removeEventListener("change",this.uo,!0),A?.removeEventListener("click",this.uo,!0),this.uo=void 0),this.do&&(A?.removeEventListener("copy",this.do,!0),A?.removeEventListener("cut",this.do,!0),A?.removeEventListener("paste",this.do,!0),this.do=void 0),this.Xs=!1}startIfEnabled(){this.isEnabled||this.zs(),!this.ro&&this.Js&&this.isEnabled&&!this.Xs&&(this.lo(),this.Xs=!0)}onRemoteConfig(t){if(!this.ro)if(this.eo=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.io=e.elementsChainAsString);var s,i=e.autocapture_opt_out;Xe(i)&&((s=this.Js)==null||s.kv.set(Rl,i),this.Ys=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.no=t}getElementSelectors(t,e){var s,i=[];return(s=this.no)==null||s.forEach(r=>{var n;A==null||(n=A.querySelectorAll(r))==null||n.forEach(o=>{t!==o&&e!==o||M(i,r)||i.push(r)})}),i}get isEnabled(){var t,e;if(this.ro)return!1;var s=(t=this.Js)==null?void 0:t.kv.get(Rl),i=this.Ys,r=this.Gs();if(!r.remoteRequestsDisabled&&!this.eo)return!1;var n=r.remoteRequestsDisabled&&!this.eo;if(Ie(i)&&!Xe(s)&&!n)return!1;var o=(e=this.Ys)!==null&&e!==void 0?e:!!s;return!!r.enabled&&!o}ho(t,e,s){if(e===void 0&&(e="$autocapture"),this.isEnabled){var i=s||or(t);Hg(i)&&(i=i.parentNode||null);var r,n=this.so();e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&n.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&Wg(i,n.rageclick)&&this.ho(t,"$rageclick",s);var o=e===dl,a=o?k({},n,{dom_event_allowlist:void 0}):n;if(i&&(function(m,y,w,E,T,C){var q;if(!b||gu(m)||w!=null&&w.url_allowlist&&!Uh(w.url_allowlist,C)||w!=null&&w.url_ignorelist&&Uh(w.url_ignorelist,C))return!1;if(w!=null&&w.dom_event_allowlist){var x=w.dom_event_allowlist;if(x&&!x.some(U=>y.type===U))return!1}var le=Jg(m,E),D=le.parentIsUsefulElement,P=le.targetElementList;if(!(function(U,ue){var Oe=ue?.element_allowlist;if(S(Oe))return!0;var he,oe=function(B){if(Oe.some(V=>B.tagName.toLowerCase()===V))return{v:!0}};for(var O of U)if(he=oe(O))return he.v;return!1})(P,w)||!ql(P,w?.css_selector_allowlist)||ql(P,(q=w?.css_selector_ignorelist)!==null&&q!==void 0?q:Za))return!1;try{var G=b.getComputedStyle(m);if(G&&G.getPropertyValue("cursor")==="pointer"&&y.type==="click")return!0}catch{}var N=m.tagName.toLowerCase();switch(N){case"html":return!1;case"form":return(T||["submit"]).indexOf(y.type)>=0;case"input":case"select":case"textarea":return(T||["change","click"]).indexOf(y.type)>=0;default:return D?(T||["click"]).indexOf(y.type)>=0:(T||["click"]).indexOf(y.type)>=0&&(fu.indexOf(N)>-1||m.getAttribute("contenteditable")==="true")}})(i,t,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l,u=ik(i,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.io,disableCaptureUrlHashes:n.disableCaptureUrlHashes}),c=u.props;if(u.explicitNoCapture)return!1;var h=this.getElementSelectors(i,u.target);if(h&&h.length>0&&(c.$element_selectors=h),e===dl){var g=t.type||"clipboard";if(g!=="paste"){var f,p,_=b==null||(f=b.getSelection())==null?void 0:f.toString(),v=qg(_);if(!v)return!1;c.$selected_content=v,c.$clipboard_text_length=(p=_?.length)!==null&&p!==void 0?p:0}c.$copy_type=g}return(l=this.Js)==null||l.capture(e,c).catch(m=>Rn.error("Failed to capture event",m)),!0}}else this.zs()}isBrowserSupported(){return qe(A?.querySelectorAll)}},nk=class{constructor(t){this._instance=t}refresh(t){var e=this._instance.config,s=Y(e.autocapture)?e.autocapture:void 0;t.enabled=!!e.autocapture,t.rageclick=e.rageclick,t.maskAllElementAttributes=e.mask_all_element_attributes,t.maskAllText=e.mask_all_text,t.disableCaptureUrlHashes=e.disable_capture_url_hashes,t.getCurrentUrl=e.get_current_url,t.remoteRequestsDisabled=this._instance.Fa(),t.url_allowlist=s?.url_allowlist,t.url_ignorelist=s?.url_ignorelist,t.dom_event_allowlist=s?.dom_event_allowlist,t.element_allowlist=s?.element_allowlist,t.css_selector_allowlist=s?.css_selector_allowlist,t.css_selector_ignorelist=s?.css_selector_ignorelist,t.element_attribute_ignorelist=s?.element_attribute_ignorelist,t.capture_copied_text=s?.capture_copied_text}},er=Te("[ExceptionAutocapture]"),pf=()=>{},vf=t=>{var e;if(qe(t))return(e=t.__posthog_layer__)!==null&&e!==void 0?e:t.__rrweb_layer__};ok=Te("[TracingHeaders]"),ks=Te("[Web Vitals]"),_f=9e5,mf=["CLS","FCP","INP","LCP"],ak=["INP","LCP"],lk=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Tn="disabled",yf="lazy_loading",qt=Te("[SessionRecording]"),uk=Te("[Heatmaps]");On=Te("[Product Tours]"),gl=t=>{var e;return!t.config.disable_product_tours&&!((e=t.persistence)==null||!e.get_property(ou))},Tt=Te("[SiteApps]"),bf="Error while initializing PostHog app with config id ",Pp=(t,e)=>t!=null&&t.then?t.then(e):e(t),ii="SDK is not enabled or survey functionality is not yet loaded",Ef="Disabled. Not loading surveys.",ck=class{constructor(t,e){this.Ks=t,this.Ju=e,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Qu=!1,this.Ku=[],this.Xu=null,this.Yu=null,this.ro=!1,this.th=new Set,this.onRemoteConfig=s=>{if(!this.ro&&!this.Rn.disableSurveys){if(!s.ok)return ne.warn("Remote config unavailable. Not loading surveys.");var i=s.config.surveys;if(H(i))return ne.warn("Flags not loaded yet. Not loading surveys.");this.eh=Xe(i)?i:i.length>0,ne.info("flags response received, isSurveysEnabled: "+this.eh),this.loadIfEnabled()}}}setup(t){if(!this.ro)return this.ih=t,Pp(t.kv.initialize(),()=>{if(this.ih===t&&!this.ro){this.ih=void 0,this.Js=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.ro?e.dispose():(this.oo=e,this.loadIfEnabled())}})}dispose(){var t,e,s;this.ro||(this.ro=!0,this.ih=void 0,this.Js=void 0,(t=this.oo)==null||t.dispose(),this.oo=void 0,(e=this._surveyEventReceiver)==null||e.dispose(),this._surveyEventReceiver=null,(s=this._surveyManager)==null||s.dispose==null||s.dispose(),this._surveyManager=null,this.Ku=[],this.Xu=null,this.th.forEach(i=>clearTimeout(i)),this.th.clear())}get Rn(){return this.Ks.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;(t=this._surveyEventReceiver)==null||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],s=0;s<localStorage.length;s++){var i=localStorage.key(s);(i!=null&&i.startsWith("seenSurvey_")||i!=null&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach(r=>localStorage.removeItem(r))}catch{}}loadIfEnabled(){if(!this.ro&&this.Js){var t=this.Rn;if(!this._surveyManager)if(this.Qu)ne.info("Already initializing surveys, skipping...");else if(t.disableSurveys)ne.info(Ef);else if(t.cookielessMode&&this.Ks.isOptedOut())ne.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Ks.getExtensions();if(e){if(!S(this.eh)||t.advancedEnableSurveys){var s=this.eh||t.advancedEnableSurveys;this.Qu=!0;try{var i=e.generateSurveys;if(i)return this.rh(i,s),void(this.Qu=!1);var r=e.loadExternalDependency;if(!r)return this.nh(Ml),void(this.Qu=!1);r(n=>{try{if(this.ro)return;var o=this.Ks.getExtensions();n||o==null||!o.generateSurveys?this.nh("Could not load surveys script",n):this.rh(o.generateSurveys,s)}finally{this.Qu=!1}})}catch(n){throw this.Qu=!1,this.nh("Error initializing surveys",n),n}}}else ne.error("PostHog Extensions not found.")}}}rh(t,e){this.ro||(this._surveyManager=t(e),this._surveyEventReceiver=this.Ks.createEventReceiver(),ne.info("Surveys loaded successfully"),this.sh({isLoaded:!0}))}nh(t,e){ne.error(t,e),this.sh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ku.push(t),this._surveyManager&&this.sh({isLoaded:!0}),()=>{this.Ku=this.Ku.filter(e=>e!==t)}}getSurveys(t,e){var s;e===void 0&&(e=!1);var i=(s=this.Js)!==null&&s!==void 0?s:this.Ju;if(i&&!this.ro){if(this.Rn.disableSurveys)return ne.info(Ef),t([]);var r=i.kv.get(Nl);if(r&&!e)return t(r,{isLoaded:!0}),void(this.oh()&&this.getSurveys(()=>{},!0));if(this.Xu)this.Xu.then(a=>{this.ro||t(a.surveys,a.context)}).catch(a=>ne.error("Error in survey callback",a));else{var n=this.ah("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Rn.requestTimeoutMs}).then(a=>{try{return this.uh(i,a)}catch(l){return ne.error("Error processing surveys response",l),this.uh(i,{statusCode:0,error:l})}},a=>this.uh(i,{statusCode:0,error:a}));this.Xu=n;var o=()=>{this.Xu===n&&(this.Xu=null)};n.then(a=>{o(),this.ro||t(a.surveys,a.context)},o).catch(a=>ne.error("Error in survey callback",a))}}}ah(t,e){var s=this.Js;return s?s.sendRequest(t,e):new Promise(i=>i({statusCode:0,error:new Error(ii)}))}uh(t,e){var s;if(this.ro)return{surveys:[],context:{isLoaded:!1,error:ii}};var i=e.statusCode;if(i!==200||!e.json){var r="Surveys API could not be loaded, status: "+i;return i!==0?ne.error(r):e.error||ne.warn(r),this.Yu=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Yu=null;var n=e.json.surveys||[],o=n.filter(a=>(function(l){return!(!l.start_date||l.end_date)})(a)&&(Sp(a)||(function(l){var u;return!((u=l.conditions)==null||(u=u.actions)==null||(u=u.values)==null||!u.length)})(a)));return o.length>0&&((s=this._surveyEventReceiver)==null||s.register(o)),t.kv.set({[Nl]:n,[Yn]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}oh(){return this.hh()&&!this.Xu&&!this.dh()}hh(){var t,e,s=(t=(e=this.Js)!==null&&e!==void 0?e:this.Ju)==null?void 0:t.kv.get(Yn);return Re(s)&&Date.now()-s>3e5}dh(){return Re(this.Yu)&&3e5>Date.now()-this.Yu}markSurveyAsSeen(t,e){var s;Ap({id:t,current_iteration:(s=e?.iteration)!==null&&s!==void 0?s:null});try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}sh(t){for(var e of this.Ku)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(s){ne.error("Error in survey callback",s)}}getActiveMatchingSurveys(t,e){if(e===void 0&&(e=!1),!H(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ne.warn("init was not called")}fh(t){var e=null;return this.getSurveys(s=>{var i;e=(i=s.find(r=>r.id===t))!==null&&i!==void 0?i:null}),e}ph(t){if(H(this._surveyManager))return{eligible:!1,reason:ii};var e=typeof t=="string"?this.fh(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}gh(t){if(H(this._surveyManager))return{eligible:!1,reason:ii};var e=typeof t=="string"?this.fh(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(H(this._surveyManager))return ne.warn("init was not called"),{visible:!1,disabledReason:ii};var e=this.gh(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return H(this._surveyManager)?(ne.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ii})):new Promise(s=>{this.getSurveys(i=>{var r,n=(r=i.find(a=>a.id===t))!==null&&r!==void 0?r:null;if(n){var o=this.gh(n);s({visible:o.eligible,disabledReason:o.reason})}else s({visible:!1,disabledReason:"Survey not found"})},e)})}renderSurvey(t,e,s){var i;if(H(this._surveyManager))ne.warn("init was not called");else{var r=typeof t=="string"?this.fh(t):t;if(r!=null&&r.id)if(Gw.includes(r.type)){var n=A?.querySelector(e);if(n)if((i=r.appearance)!=null&&i.surveyPopupDelaySeconds){ne.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds");var o=setTimeout(()=>{var a,l;this.th.delete(o),this.ro||(ne.info("Rendering survey "+r.id+" with delay of "+((a=r.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(r,n,s),ne.info("Survey "+r.id+" rendered"))},1e3*r.appearance.surveyPopupDelaySeconds);this.th.add(o)}else this._surveyManager.renderSurvey(r,n,s);else ne.warn("Survey element not found")}else ne.warn("Surveys of type "+r.type+" cannot be rendered in the app");else ne.warn("Survey not found")}}displaySurvey(t,e){var s;if(H(this._surveyManager))ne.warn("init was not called");else{var i=this.fh(t);if(i){var r=i;if((s=i.appearance)!=null&&s.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=k({},i,{appearance:k({},i.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==zl.Popover&&e.initialResponses&&ne.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.ph(i);if(!n.eligible)return void ne.warn("Survey is not eligible to be displayed: ",n.reason)}e.displayType!==zl.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else ne.warn("Survey not found")}}cancelPendingSurvey(t){H(this._surveyManager)?ne.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload==null||t.handlePageUnload()}};dk=class{constructor(t){this._instance=t,this.mh=new Set,this.yh=new Set,this.bh=new io,this._h=(e,s)=>this.wh(e,s)&&this.kh(e,s)&&this.Sh(e,s)&&this.xh(e,s),this.wh=(e,s)=>s==null||!s.event||e?.event===s?.event}init(){var t,e;S((t=this._instance)==null?void 0:t._addCaptureHook)||(this.Ch=(e=this._instance)==null?void 0:e._addCaptureHook((s,i)=>{this.on(s,i)}))}dispose(){var t;(t=this.Ch)==null||t.call(this),this.Ch=void 0,this.bh=new io}register(t){var e,s;if(!S((e=this._instance)==null?void 0:e._addCaptureHook)&&(t.forEach(r=>{var n;this.mh.add(r),(n=r.steps)==null||n.forEach(o=>{this.yh.add(o?.event||"")})}),(s=this._instance)!=null&&s.autocapture)){var i=new Set;this.mh.forEach(r=>{var n;(n=r.steps)==null||n.forEach(o=>{o!=null&&o.selector&&i.add(o.selector)})}),this._instance.autocapture.setElementSelectors(i)}}replace(t){this.mh.clear(),this.yh.clear(),this.register(t)}on(t,e){e!=null&&t.length!=0&&(this.yh.has(t)||this.yh.has(e.event))&&this.mh.forEach(s=>{this.Th(e,s)&&this.bh.emit("actionCaptured",s.name)})}Mh(t){this.onAction("actionCaptured",e=>t(e))}Th(t,e){if(e?.steps==null)return!1;for(var s of e.steps)if(this._h(t,s))return!0;return!1}onAction(t,e){return this.bh.on(t,e)}kh(t,e){if(e!=null&&e.url){var s,i=t==null||(s=t.properties)==null?void 0:s.$current_url;if(!i||typeof i!="string"||!ri(i,e.url,e.url_matching||"contains"))return!1}return!0}Sh(t,e){return!!this.Ih(t,e)&&!!this.Eh(t,e)&&!!this.Rh(t,e)}Ih(t,e){var s;if(e==null||!e.href)return!0;var i=this.Ah(t);if(i.length>0)return i.some(o=>ri(o.href,e.href,e.href_matching||"exact"));var r,n=(t==null||(s=t.properties)==null?void 0:s.$elements_chain)||"";return!!n&&ri((r=n.match(/(?::|")href="(.*?)"/))?r[1]:"",e.href,e.href_matching||"exact")}Eh(t,e){var s;if(e==null||!e.text)return!0;var i=this.Ah(t);if(i.length>0)return i.some(l=>ri(l.text,e.text,e.text_matching||"exact")||ri(l.$el_text,e.text,e.text_matching||"exact"));var r,n,o,a=(t==null||(s=t.properties)==null?void 0:s.$elements_chain)||"";return!!a&&(r=(function(l){for(var u,c=[],h=/(?::|")text="(.*?)"/g;!H(u=h.exec(l));)c.includes(u[1])||c.push(u[1]);return c})(a),n=e.text,o=e.text_matching||"exact",r.some(l=>ri(l,n,o)))}Rh(t,e){var s,i;if(e==null||!e.selector||t!=null&&(s=t.properties)!=null&&(s=s.$element_selectors)!=null&&s.includes(e.selector))return!0;var r=(t==null||(i=t.properties)==null?void 0:i.$elements_chain)||"";if(e.selector_regex&&r)try{return new RegExp(e.selector_regex).test(r)}catch{return!1}return!1}Ah(t){var e;return(t==null||(e=t.properties)==null?void 0:e.$elements)==null?[]:t?.properties.$elements}xh(t,e){return e==null||!e.properties||e.properties.length===0||kp(e.properties.reduce((s,i)=>{var r=F(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return s[i.key]={values:r,operator:i.operator||"exact"},s},{}),t?.properties)}},hk=class{constructor(t){var e;this.Ph=[],this._instance=t,this.Fh=new Map,this.Oh=new Map,this.$h=new Map,this.Dh=(e=this._instance)==null||e.onSessionId==null?void 0:e.onSessionId(s=>this.Lh(s))}Nh(t){return!1}qh(){return null}jh(t){}Bh(){}Hh(t,e){return!!t&&kp(t.propertyFilters,e?.properties)}zh(t,e){var s=new Map;return t.forEach(i=>{var r;(r=i.conditions)==null||(r=r[e])==null||(r=r.values)==null||r.forEach(n=>{if(n!=null&&n.name){var o=s.get(n.name)||[];o.push(i.id),s.set(n.name,o)}})}),s}Uh(t,e,s){var i=(s===Yi.Activation?this.Fh:this.Oh).get(t),r=[];return this.Wh(n=>{r=n.filter(o=>i?.includes(o.id))}),r.filter(n=>{var o,a=(o=n.conditions)==null||(o=o[s])==null||(o=o.values)==null?void 0:o.find(l=>l.name===t);return this.Hh(a,e)})}register(t){this.Vh(t,!1)}replace(t){this.Vh(t,!0)}Vh(t,e){var s;S((s=this._instance)==null?void 0:s._addCaptureHook)||(this.Gh(t,e),this.Zh(t,e))}Zh(t,e){var s=t.filter(n=>{var o;return(o=n.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length});if(e&&this.$h.clear(),s.length!==0){this.Jh||(this.Jh=new dk(this._instance),this.Jh.init(),this.Jh.Mh(n=>this.onAction(n)));var i=[];s.forEach(n=>{var o;(o=n.conditions)==null||(o=o.actions)==null||o.values.forEach(a=>{if(i.push(a),a.name){var l,u=(l=this.$h.get(a.name))!==null&&l!==void 0?l:[];u.includes(n.id)||u.push(n.id),this.$h.set(a.name,u)}})}),e?this.Jh.replace(i):this.Jh.register(i)}else{var r;e&&((r=this.Jh)==null||r.replace([]))}}Qh(t,e){e.forEach((s,i)=>{var r,n=(r=t.get(i))!==null&&r!==void 0?r:[];s.forEach(o=>{n.includes(o)||n.push(o)}),t.set(i,n)})}Gh(t,e){var s,i,r=t.filter(l=>{var u,c;return((u=l.conditions)==null?void 0:u.events)&&((c=l.conditions)==null||(c=c.events)==null||(c=c.values)==null?void 0:c.length)>0}),n=t.filter(l=>{var u,c;return((u=l.conditions)==null?void 0:u.cancelEvents)&&((c=l.conditions)==null||(c=c.cancelEvents)==null||(c=c.values)==null?void 0:c.length)>0}),o=this.zh(t,Yi.Activation),a=this.zh(t,Yi.Cancellation);e?(this.Fh=o,this.Oh=a):(this.Qh(this.Fh,o),this.Qh(this.Oh,a)),(r.length!==0||n.length!==0)&&((s=this.Ch)!==null&&s!==void 0||(this.Ch=(i=this._instance)==null?void 0:i._addCaptureHook((l,u)=>{this.onEvent(l,u)})))}onEvent(t,e){var s,i,r=this.Kh(),n=(e==null||(s=e.properties)==null?void 0:s.$survey_id)||(e==null||(i=e.properties)==null?void 0:i.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.Xh(t,n);if(o==="consume")return r.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Yh([n]);if(o==="persist")return r.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.td(n),void this.ed([n])}if(this.Oh.has(t)){var a=this.Uh(t,e,Yi.Cancellation);a.length>0&&(r.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map(u=>u.id)}),this.Yh(a.map(u=>u.id)),a.forEach(u=>this.rd(u.id)))}if(this.Fh.has(t)){r.info("event name matched",{event:t,eventPayload:e,items:this.Fh.get(t)});var l=this.Uh(t,e,Yi.Activation);this.nd(l.map(u=>u.id))}}onAction(t){this.$h.has(t)&&this.nd(this.$h.get(t)||[])}nd(t){var e;if(t.length!==0){var s=!((e=this._instance)==null||e.get_session_id==null||!e.get_session_id()),i=[];for(var r of t)s&&this.Nh(r)?this.td(r)&&this.sd(r):i.push(r);i.length>0&&(this.Ph=[...new Set([...this.Ph,...i])]),this.Kh().info("updating activated items",{activatedItems:this.getActivatedIds()})}}td(t){this.Ph=this.Ph.filter(s=>s!==t);var e=this.od();return!e.includes(t)&&(this.ad([...e,t]),this.ld(),!0)}Yh(t){var e=new Set(t);this.Ph=this.Ph.filter(r=>!e.has(r));var s=this.ud(),i=s.filter(r=>!e.has(r));i.length!==s.length&&(this.ad(i),i.length===0&&this.hd()),this.ed(t)}dd(){var t,e=this.qh();if(!e)return{};var s=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[e];return s&&typeof s=="object"?s:{}}sd(t){if(this.qh()){var e=this.dd();this.jh(k({},e,{[t]:Date.now()}))}}ed(t){if(this.qh()){var e=this.dd(),s={},i=!1;for(var r of Object.entries(e)){var n=r[0],o=r[1];t.includes(n)?i=!0:s[n]=o}i&&(nt(s)?this.Bh():this.jh(s))}}vd(){this.qh()&&this.Bh()}getActivationTimestamp(t){if(this.od().includes(t)){var e=this.dd()[t];return Re(e)?e:void 0}}ud(){var t,e=this.fd();return((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[e])||[]}od(){var t,e,s=this.ud();if(s.length===0)return[];var i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.pd()],r=(e=this._instance)==null||e.get_session_id==null?void 0:e.get_session_id();return r&&i===r?s:[]}ld(){var t,e=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();e&&this.gd(e)}hd(){this.md()}Lh(t){var e,s=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.pd()];if(s&&s!==t){var i=this.ud(),r=this.dd();i.length>0&&(this.ad([]),i.filter(n=>Re(r[n])).forEach(n=>this.rd(n))),this.hd(),this.vd()}}getActivatedIds(){return[...new Set([...this.od(),...this.Ph])].filter(t=>!this.yd(t))}dispose(){var t,e,s;(t=this.Dh)==null||t.call(this),this.Dh=void 0,(e=this.Ch)==null||e.call(this),this.Ch=void 0,(s=this.Jh)==null||s.dispose(),this.Jh=void 0}reset(){this.Ph=[],this.ud().length>0&&this.ad([]),this.hd(),this.vd()}getEventToItemsMap(){return this.Fh}bd(){return this.Jh}},fk=class extends hk{constructor(t){super(t)}fd(){return Ll}pd(){return Dn}qh(){return Nn}jh(t){var e;(e=this._instance)==null||(e=e.persistence)==null||e.register({[Nn]:t})}Bh(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Nn)}Nh(t){var e,s;this.Wh(r=>{s=r.find(n=>n.id===t)});var i=(e=s)==null||(e=e.appearance)==null?void 0:e.surveyPopupDelaySeconds;return Re(i)&&i>0}_d(){return Jt.SHOWN}Wh(t){var e;(e=this._instance)==null||e.getSurveys(t)}rd(t){var e;(e=this._instance)==null||e.cancelPendingSurvey(t)}Kh(){return ne}ad(t){var e;(e=this._instance)==null||(e=e.persistence)==null||e.register({[Ll]:t})}gd(t){var e;(e=this._instance)==null||(e=e.persistence)==null||e.register({[Dn]:t})}md(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Dn)}yd(){return!1}Xh(t,e){var s;return this.Wh(i=>{s=i.find(r=>r.id===e)}),!s||(function(i){var r;return Sp(i)&&!((r=i.conditions)==null||(r=r.events)==null||!r.repeatedActivation)||i.schedule==="always"})(s)?t===Jt.SHOWN?"consume":"ignore":t===Jt.SHOWN?"persist":t===Jt.DISMISSED||t===Jt.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},gk=class{constructor(t){this._instance=t}initialize(){}get(t){if(typeof t=="string")return this._instance.get_property(t);var e={};for(var s of t){var i=this._instance.get_property(s);S(i)||(e[s]=i)}return e}set(t,e){this._instance.register(typeof t=="string"?{[t]:e}:t)}remove(t){typeof t!="string"?t.forEach(e=>this._instance.unregister(e)):this._instance.unregister(t)}},pk=class{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var t=L?.__PosthogExtensions__;if(t){var e=t.generateSurveys,s=t.loadExternalDependency;return{generateSurveys:e?i=>e(this._instance,i):void 0,loadExternalDependency:s?i=>s(this._instance,"surveys",i):void 0}}}createEventReceiver(){return new fk(this._instance)}},vk=b!=null&&b.location?Zn(b.location.hash,"__posthog")||Zn(location.hash,"state"):null,Sf="_postHogToolbarParams",wf=Te("[Toolbar]"),kf=Te("[FeatureFlags]"),_k=class{constructor(t,e){e===void 0&&(e=!1),this.wd=!1,this.update(t,e)}update(t,e){this.kd=((s,i)=>{var r,n,o,a,l;return{bootstrap:{featureFlags:(r=s.bootstrap)==null?void 0:r.featureFlags,featureFlagPayloads:(n=s.bootstrap)==null?void 0:n.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!s.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!s.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!s.advanced_feature_flags_dedup_per_session,cacheTtlMs:s.feature_flag_cache_ttl_ms,refreshIntervalMs:(o=s.remote_config_refresh_interval_ms)!==null&&o!==void 0?o:3e5,requestTimeoutMs:s.feature_flag_request_timeout_ms,compression:s.disable_compression?void 0:"best-available",evaluationContexts:(a=(l=s.evaluation_contexts)!==null&&l!==void 0?l:s.evaluation_environments)!==null&&a!==void 0?a:[],flagKeys:F(s.flag_keys)?s.flag_keys:void 0}})(t,e),!t.evaluation_environments||t.evaluation_contexts||this.wd||(kf.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.wd=!0),S(t.flag_keys)||F(t.flag_keys)||kf.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.kd}},Af=Te("[FeatureFlags]"),As=Te("[FeatureFlags]",{debugEnabled:!0}),pl=`" failed. Feature flags didn't load in time.`,If="connection_error",Rf=t=>{for(var e={},s=0;t.length>s;s++)e[t[s]]=!0;return e},Tf=t=>{var e={};for(var s of $n(t||{})){var i=s[1];i&&(e[s[0]]=i)}return e},Of=t=>mr(t)&&(t.name==="RangeError"&&t.message.indexOf("Maximum call stack size exceeded")===0||t.name==="InternalError"&&t.message==="too much recursion"),yt=Te("[Error tracking]"),Ql="webkit-masked-url:",mk=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],yk=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Ql],bk=["__firefox__","__gCrWeb"],Pf="Refusing to render web experiment since the viewer is a likely bot",Ek={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>ro(e,t),not_regex:(t,e)=>!ro(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},gt=Te("[Conversations]"),Is="Conversations not available yet.";Sk=["debug","log","warn","error","info"],xf="console",Cp="__posthogHandledLogsRequestError",vl=(t,e)=>{var s=t instanceof Error?t:new Error(e);return s[Cp]=!0,s},Df=t=>!!t&&typeof t=="object"&&t[Cp]===!0,co={featureFlags:class{constructor(t){this.name="featureFlags",this.Sd=!1,this.featureFlagEventHandlers=[],this.A=Af,this.xd={},this.Cd={},this.Td=[],this.Md=!1,this.Id=!1,this.Ed=0,this.Rd=!1,this.Ad=!1,this.Pd=!1,this.Fd=!1,this.Od=0,this.nr=()=>{var e=this.$d();this.Od=0,e&&this.reloadFeatureFlags()},this.Dd=()=>{var e,s=this.Ld;S(s)||this.Rn.remoteRequestsDisabled||!A||A.visibilityState==="hidden"||Date.now()-((e=this.Nd)!==null&&e!==void 0?e:0)<s||(this.reloadFeatureFlags(),this.qd())},this.ar=()=>{A?.visibilityState==="visible"&&this.Dd()},"get"in t?this.Ks=t:(this._instance=t,this.jd=new _k(t.config,t.Fa()),this.Ks=this.jd)}updateConfig(t,e){var s;(s=this.jd)==null||s.update(t,e),this.Js&&this.Bd()}setup(t){return this.ih=t,this.A=t.logger.createLogger("[FeatureFlags]"),Pp(t.kv.initialize(),()=>{this.ih===t&&(this.ih=void 0,this.Js=t,this.Hd(t))})}Hd(t){var e;if(this.Js===t)return b&&ae(b,"online",this.nr),this.Bd(),this.zd=t.registerDynamicEventProperties(()=>this.Ud()?this.xd:this.Cd),this.Wd=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Vd(),this.Gd(),this.Zd()}),this.Gd(),this.initialize()}Bd(){var t=this.Rn.refreshIntervalMs,e=!this.Rn.remoteRequestsDisabled&&A&&!S(t)&&t>0?t:void 0;e!==this.Ld&&(this.Jd(),S(e)||(this.Ld=e,this.qd(),A!=null&&A.addEventListener&&ae(A,hi,this.ar)))}qd(){S(this.Ld)||(S(this.Qd)||clearInterval(this.Qd),this.Nd=Date.now(),this.Qd=setInterval(this.Dd,this.Ld))}Jd(){S(this.Qd)||(clearInterval(this.Qd),this.Qd=void 0,A==null||A.removeEventListener==null||A.removeEventListener(hi,this.ar)),this.Ld=void 0,this.Nd=void 0}destroy(){this.Kd()}dispose(){this.Kd()}Kd(){var t,e;this.Jd(),this.Ed++,this.Ad=!1,this.ih=void 0,this.Js&&(this.Xd(),(t=this.zd)==null||t.dispose(),this.zd=void 0,(e=this.Wd)==null||e.call(this),this.Wd=void 0,this.Td=[],b?.removeEventListener("online",this.nr),this.Js=void 0)}get Rn(){return this.Ks.get()}Yd(t){var e;return this.tv&&t in this.tv?this.tv[t]:(e=this.Js)==null?void 0:e.kv.get(t)}Vd(){return!!this.tv&&(this.tv=void 0,!0)}ev(){var t;return!S((t=this.Js)==null?void 0:t.kv.get("$enabled_feature_flags"))&&this.Vd()}Ot(t){this.iv(()=>{var e;return(e=this.Js)==null?void 0:e.kv.set(t)})}rv(t,e,s){var i;if((i=this._instance)!=null&&i.persistence&&t.$enabled_feature_flags){var r=this.Yd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},o=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(y=>{var w=y[1];return!(w!=null&&w.failed)}).map(y=>y[0]):[],l=!!e.errorsWhileComputingFlags&&!!e.flags,u=l?a:s&&!F(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(r),...Object.keys(n)])),c=this.Yd("$feature_flag_payloads")||{},h=t.$feature_flag_payloads||{},g=l||s?u:Array.from(new Set([...Object.keys(c),...Object.keys(h)])),f=!l&&!s,p=!!f||u,_=!!f||g,v={[Ct]:p,[pt]:p,[as]:_};for(var m of(t.$feature_flag_details&&(v[Ps]=p),[Cs,cs,nr]))S(t[m])||(v[m]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(v)}}Dt(t){this.iv(()=>{var e;return(e=this.Js)==null?void 0:e.kv.remove(t)})}iv(t){try{t()}catch(e){this.A.error("Failed to update feature flag persistence",e)}}Gd(){var t={};for(var e of[Ct,as,Cs,Ot]){var s=this.Yd(e);S(s)||(t[e]=s)}this.xd=t;var i=k({},t),r=this.Yd(pt);if(r)for(var n of Object.entries(r))i["$feature/"+n[0]]=n[1];this.Cd=i}Ud(){var t=this.Rn.cacheTtlMs;if(!t||0>=t)return!1;var e=this.Yd(cs);return typeof e!="number"||Date.now()-e>t}nv(){return!!this.Ud()&&(this.Fd||this.Id||(this.Fd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}sv(){var t=this.Rn.evaluationContexts;return t!=null&&t.length?t.filter(e=>{var s=e&&typeof e=="string"&&e.trim().length>0;return s||this.A.error("Invalid evaluation context found:",e,"Expected non-empty string"),s}):[]}ov(){var t=this.Rn.flagKeys;if(!S(t))return t.filter(e=>{var s=e&&typeof e=="string"&&e.trim().length>0;return s||this.A.error("Invalid flag key found:",e,"Expected non-empty string"),s})}initialize(){var t,e,s=this.Rn,i=(t=(e=s.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(i).length){var r,n,o=(r=(n=s.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(i).filter(u=>!S(i[u])).reduce((u,c)=>(u[c]=i[c],u),{}),l=Object.keys(o).filter(u=>a[u]).reduce((u,c)=>(u[c]=o[c],u),{});return this.av({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,e,s){var i,r,n=s!=null&&s.merge&&(i=this.Yd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},o=s!=null&&s.merge&&(r=this.Yd("$feature_flag_payloads"))!==null&&r!==void 0?r:{},a=k({},n,t),l=k({},o,e),u={};for(var c of Object.entries(a)){var h=c[0],g=c[1];u[h]={key:h,enabled:Ah(g),variant:Ih(g),reason:void 0,metadata:S(l?.[h])?void 0:{id:0,version:void 0,description:void 0,payload:l[h]}}}this.av({flags:u})}get hasLoadedFlags(){return this.Md}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Yd(Ps),e=this.Yd(Ot),s=this.Yd(Ts);if(!s&&!e)return t||{};var i=fe({},t||{});for(var r of[...new Set([...Object.keys(s||{}),...Object.keys(e||{})])]){var n,o,a=i[r],l=e?.[r],u=S(l)?(n=a?.enabled)!==null&&n!==void 0&&n:!!l,c=S(l)?a?.variant:typeof l=="string"?l:void 0,h=s?.[r],g=k({},a,{enabled:u,variant:u?c??a?.variant:void 0});u!==a?.enabled&&(g.original_enabled=a?.enabled),c!==a?.variant&&(g.original_variant=a?.variant),h&&(g.metadata=k({},a?.metadata,{payload:h,original_payload:a==null||(o=a.metadata)==null?void 0:o.payload})),i[r]=g}return this.Sd||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:s,finalDetails:i}),this.Sd=!0),i}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(s=>{var i=t[s];return{key:s,enabled:Ah(i),variant:Ih(i),payload:kh(e[s])}})}getFlagVariants(){var t=this.Yd(pt),e=this.Yd(Ot);if(!e)return t||{};for(var s=fe({},t||{}),i=Object.keys(e),r=0;i.length>r;r++)s[i[r]]=e[i[r]];return this.Sd||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:s}),this.Sd=!0),s}getFlagPayloads(){var t=this.Yd(as),e=this.Yd(Ts);if(!e)return t||{};for(var s=fe({},t||{}),i=Object.keys(e),r=0;i.length>r;r++)s[i[r]]=e[i[r]];return this.Sd||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:s}),this.Sd=!0),s}reloadFeatureFlags(){this.Rd||this.Rn.featureFlagsDisabled||this.$d()||(this.Id&&(this.Ad=!0),this.lv||(this.Td.slice().forEach(t=>{try{t()}catch(e){this.A.error("Error while running feature flags reloading callback",e)}}),this.lv=setTimeout(()=>{this.uv()},5)))}Xd(){clearTimeout(this.lv),this.lv=void 0}onReloading(t){return this.Td.push(t),()=>{this.Td=this.Td.filter(e=>e!==t)}}ensureFlagsLoaded(){this.Md||this.Id||this.lv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Rd=t}resetFlagCallReported(){this.Dt(us)}uv(t){this.Xd();var e=this.Js;if(e&&!this.Rn.remoteRequestsDisabled&&!this.$d())if(this.Id)this.Ad=!0;else{var s={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:k({},e.initialPersonProperties,this.Yd("$stored_person_properties")||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.Yd(ls),timezone:ap()};S(e.deviceId)||(s.$device_id=e.deviceId),(t!=null&&t.disableFlags||this.Rn.featureFlagsDisabled)&&(s.disable_flags=!0);var i=this.sv();i.length&&(s.evaluation_contexts=i);var r=this.ov();S(r)||(s.flag_keys=r);var n=this.Rn.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.Ed;this.Id=!0;var l=()=>{this.Ad&&(this.Ad=!1,this.uv())},u=c=>{this.Id=!1,a===this.Ed&&(this.Ot({[fr]:[If]}),this.A.error("Feature flag request failed",c),this.ev()&&this.Zd(!0)),l()};try{e.sendRequest(o,{target:"flags",method:"POST",body:s,compression:this.Rn.compression,sentAt:"body",timeoutMs:this.Rn.requestTimeoutMs}).then(c=>{var h,g,f=(h=c.json)!==null&&h!==void 0?h:{},p=c.statusCode!==200;if(this.Id=!1,a===this.Ed){if(this.hv(c.statusCode),p||this.Ad||(this.$anon_distinct_id=void 0),!s.disable_flags||this.Ad){this.Pd=!p;var _=[];c.error?_.push(c.error instanceof Error&&c.error.name==="AbortError"?"timeout":c.error instanceof Error?If:"unknown_error"):c.statusCode!==200&&_.push("api_error_"+c.statusCode),f.errorsWhileComputingFlags&&_.push("errors_while_computing_flags");var v=!((g=f.quotaLimited)==null||!g.includes("feature_flags"));v&&_.push("quota_limited"),this.Ot({[fr]:_}),v?this.A.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."):s.disable_flags||this.av(f,p,{partialResponse:n}),l()}}else l()}).catch(u)}catch(c){u(c)}}}$d(){return Zg(this.Od,3)}hv(t){this.Od=ep(t,this.Od,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,e){var s;if(e===void 0&&(e={}),!e.fresh||this.Pd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.nv()){var i=this.getFeatureFlagResult(t,e);return(s=i?.variant)!==null&&s!==void 0?s:i?.enabled}}else this.A.warn('getFeatureFlag for key "'+t+pl)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e;return(e=this.getFeatureFlagResult(t,{send_event:!1}))==null?void 0:e.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.Pd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.nv()){var s,i=this.getFlagVariants(),r=t in i,n=i[t],o=this.getFlagPayloads()[t],a=String(n),l=this.Yd("$feature_flag_request_id")||void 0,u=this.Yd("$feature_flag_evaluated_at")||void 0,c=this.Yd("$flag_call_reported")||{};if(this.Rn.deduplicateCallsPerSession){var h,g=(h=this.Js)==null?void 0:h.session.sessionId,f=this.Yd(tr);g&&g!==f&&(c={},s=g)}if(e.send_event||!("send_event"in e))if(t in c&&c[t].includes(a))s&&this.Ot({[us]:c,[tr]:s});else{var p,_,v,m,y,w,E,T,C,q,x,le,D;F(c[t])?c[t].push(a):c[t]=[a],this.Ot(k({[us]:c},s?{[tr]:s}:{}));var P=this.getFeatureFlagDetails(t),G=[...(p=this.Yd("$feature_flag_errors"))!==null&&p!==void 0?p:[]];S(n)&&G.push("flag_missing");var N={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:o??null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(_=(v=this.Rn.bootstrap)==null||(v=v.featureFlags)==null?void 0:v[t])!==null&&_!==void 0?_:null,$feature_flag_bootstrapped_payload:(m=(y=this.Rn.bootstrap)==null||(y=y.featureFlagPayloads)==null?void 0:y[t])!==null&&m!==void 0?m:null,$used_bootstrap_value:!this.Pd};S(P==null||(w=P.metadata)==null?void 0:w.has_experiment)||(N.$feature_flag_has_experiment=P.metadata.has_experiment),S(P==null||(E=P.metadata)==null?void 0:E.version)||(N.$feature_flag_version=P.metadata.version);var U=(T=P==null||(C=P.reason)==null?void 0:C.description)!==null&&T!==void 0?T:P==null||(q=P.reason)==null?void 0:q.code;U&&(N.$feature_flag_reason=U),P!=null&&(x=P.metadata)!=null&&x.id&&(N.$feature_flag_id=P.metadata.id),S(P?.original_variant)&&S(P?.original_enabled)||(N.$feature_flag_original_response=S(P.original_variant)?P.original_enabled:P.original_variant),P!=null&&(le=P.metadata)!=null&&le.original_payload&&(N.$feature_flag_original_payload=P==null||(D=P.metadata)==null?void 0:D.original_payload),G.length&&(N.$feature_flag_error=G.join(",")),this.dv(N)}else s&&this.Ot({[us]:c,[tr]:s});if(r)return{key:t,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:kh(o)}}}else this.A.warn('getFeatureFlagResult for key "'+t+pl)}dv(t){try{var e;(e=this.Js)==null||e.capture("$feature_flag_called",t).catch(s=>{this.A.error("Failed to capture feature flag call",s)})}catch(s){this.A.error("Failed to capture feature flag call",s)}}getRemoteConfigPayload(t,e){this.vv(t,e)}vv(t,e){var s=this;return ge(function*(){var i=s.Js;if(i){var r={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},n=s.sv();n.length&&(r.evaluation_contexts=n);var o,a=s.ov();S(a)||(r.flag_keys=a);try{var l;o=((l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:s.Rn.compression,sentAt:"body",timeoutMs:s.Rn.requestTimeoutMs})).json)==null||(l=l.featureFlagPayloads)==null?void 0:l[t])||void 0}catch(u){return void s.A.error("Remote config feature flag request failed",u)}try{e(o)}catch(u){s.A.error("Remote config feature flag callback failed",u)}}})()}isFeatureEnabled(t,e){if(e===void 0&&(e={}),e.fresh&&!this.Pd)return e.defaultValue;if(!(this.Md||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+pl),e.defaultValue;var s=this.getFeatureFlag(t,e);return S(s)?e.defaultValue:!!s}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(e=>e!==t)}receivedFeatureFlags(t,e,s){this.av(t,e,s)}av(t,e,s){if(this.Js){this.Md=!0;var i=(function(n,o,a,l,u,c){o===void 0&&(o={}),a===void 0&&(a={}),l===void 0&&(l={}),c===void 0&&(c=Af);var h=((D,P)=>{var G=D.flags;return G?k({},D,{featureFlags:Object.fromEntries(Object.keys(G).map(N=>{var U;return[N,(U=G[N].variant)!==null&&U!==void 0?U:G[N].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(G).filter(N=>G[N].enabled).filter(N=>{var U;return!S((U=G[N].metadata)==null?void 0:U.payload)}).map(N=>{var U;return[N,(U=G[N].metadata)==null?void 0:U.payload]}))}):(D.featureFlags&&P.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),D)})(n,c),g=h.flags,f=h.featureFlags,p=h.featureFlagPayloads;if(f){var _=n.requestId,v=n.evaluatedAt;if(F(f)){c.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(f)for(var y=0;f.length>y;y++)m[f[y]]=!0;return{[Ct]:f,[pt]:m,[nr]:!1}}var w=f,E=p,T=g;if(u!=null&&u.partialResponse){var C=Object.keys(w),q=E||{};w=k({},o,w),E=k({},a,q),C.forEach(D=>{var P;D in q||(P=E)==null||delete P[D]}),T=k({},l,T)}else if(n.errorsWhileComputingFlags)if(g){var x=new Set(Object.keys(g).filter(D=>{var P;return!((P=g[D])!=null&&P.failed)}));w=k({},o,Object.fromEntries(Object.entries(w).filter(D=>x.has(D[0]))));var le=Object.fromEntries(Object.entries(E||{}).filter(D=>x.has(D[0])));E=k({},a,le),x.forEach(D=>{var P;D in le||(P=E)==null||delete P[D]}),T=k({},l,Object.fromEntries(Object.entries(T||{}).filter(D=>x.has(D[0]))))}else w=k({},o,w),E=k({},a,E),T=k({},l,T);return k({[Ct]:Object.keys(Tf(w)),[pt]:w||{},[as]:E||{},[Ps]:T||{},[nr]:n.minimalFlagCalledEvents===!0},_?{[Cs]:_}:{},v?{[cs]:v}:{})}})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),s,this.A);if(i)if(s?.persist===!1){var r=!S(this.Js.kv.get(pt));this.tv=i,r||this.Ot(i)}else this.Vd(),this.rv(i,t,!(s==null||!s.partialResponse)),this.Ot(i);else e&&this.ev();e||(this.Fd=!1),this.Zd(e)}}override(t,e){e===void 0&&(e=!1),this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.fv(t)}fv(t){if(this.Js){if(t===!1)return this.Dt([Ot,Ts]),this.Zd(),void As.info("All overrides cleared");if(F(t))return this.Ot({[Ot]:Rf(t)}),this.Zd(),void As.info("Flag overrides set",{flags:t});if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var e,s=t;this.Sd=!!((e=s.suppressWarning)!==null&&e!==void 0&&e);var i={},r=s.flags,n=s.payloads;return r&&(i[Ot]=F(r)?Rf(r):r),n&&(i[Ts]=n),Object.keys(i).length&&this.Ot(i),r===!1&&n===!1?this.Dt([Ot,Ts]):r===!1?this.Dt(Ot):n===!1&&this.Dt(Ts),this.Zd(),r===!1?As.info("Flag overrides cleared"):r&&As.info("Flag overrides set",{flags:r}),void(n===!1?As.info("Payload overrides cleared"):n&&As.info("Payload overrides set",{payloads:n}))}if(t&&typeof t=="object")return this.Ot({[Ot]:t}),this.Zd(),void As.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Md){var e=this.pv(),s=e.flags,i=e.flagVariants;try{t(s,i)}catch(r){this.A.error("Error while running feature flags callback",r)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,s){var i,r=(this.Yd("$early_access_features")||[]).find(u=>u.flagKey===t),n={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),s&&(o.$feature_enrollment_stage=s);var a=k({},this.getFlagVariants(),{[t]:e});(i=this._instance)==null||(i=i.persistence)==null||i.markCrossTabFeatureFlagChanges({[Ct]:[t],[pt]:[t],[Wt]:Object.keys(n)}),this.Ot({[Ct]:Object.keys(Tf(a)),[pt]:a,[Wt]:k({},this.Yd("$stored_person_properties")||{},n)}),this.Zd();try{var l;(l=this.Js)==null||l.capture("$feature_enrollment_update",o).catch(u=>{this.A.error("Failed to capture early access feature enrollment",u)})}catch(u){this.A.error("Failed to capture early access feature enrollment",u)}}getEarlyAccessFeatures(t,e,s){e===void 0&&(e=!1);var i=this.Yd(Dl);!i||e?this.gv(t,s):t(i)}gv(t,e){var s=this;return ge(function*(){var i=s.Js;if(i){var r,n=e?"&"+e.map(a=>"stage="+a).join("&"):"";try{var o=yield i.sendRequest("/api/early_access_features/?token="+i.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;r=o.json.earlyAccessFeatures,s.Ot({[Dl]:r})}catch(a){return void s.A.error("Early access feature request failed",a)}try{t(r)}catch(a){s.A.error("Early access feature callback failed",a)}}})()}pv(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter(s=>e[s]),flagVariants:Object.keys(e).filter(s=>e[s]).reduce((s,i)=>(s[i]=e[i],s),{})}}Zd(t){this.Gd();var e=this.pv(),s=e.flags,i=e.flagVariants;this.featureFlagEventHandlers.forEach(r=>{try{r(s,i,{errorsLoading:t})}catch(n){this.A.error("Error while running feature flags callback",n)}})}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0),this.mv(t,e)}mv(t,e){e===void 0&&(e=!0);var s=this.Yd("$stored_person_properties")||{},i=t?.$set||(t!=null&&t.$set_once?{}:t),r=t?.$set_once,n={};if(r)for(var o in r)({}).hasOwnProperty.call(r,o)&&(o in s||(n[o]=r[o]));this.Ot({[Wt]:k({},s,n,i)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var s=k({},this.Yd("$stored_person_properties")||{});t.forEach(i=>{delete s[i]}),this.Ot({[Wt]:s}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){t===void 0&&(t=!0),this.Dt(Wt),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var s=this.Yd("$stored_group_properties")||{},i=k({},s);for(var r of Object.keys(t))i[r]=k({},s[r],t[r]);this.Ot({[ls]:i}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.Yd("$stored_group_properties")||{};this.Ot({[ls]:k({},e,{[t]:{}})})}else this.Dt(ls)}reset(){this.Ed++,this.Ad=!1,this.xd={},this.Cd={},this.tv=void 0,this.Md=!1,this.Rd=!1,this.Pd=!1,this.$anon_distinct_id=void 0,this.Xd(),this.Sd=!1,this.Od=0}}},wk={sessionRecording:class{get Rn(){return this._instance.config}get sl(){return this._instance.persistence}get started(){var t;return!((t=this.yv)==null||!t.isStarted)}get status(){var t,e;return this.bv==="awaiting_config"||this.bv==="missing_config"?this.bv:(t=(e=this.yv)==null?void 0:e.status)!==null&&t!==void 0?t:this.bv}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.bv=Tn,this._v=void 0,this.wv=!1,this.Ke=(()=>{var e;if(A==null||!A.visibilityState||A.visibilityState==="visible")return!0;var s=b==null||(e=b.performance)==null||e.getEntriesByType==null?void 0:e.getEntriesByType("visibility-state");return!(s!=null&&s.length)||s.some(i=>i.name==="visible")})(),this.ar=()=>{var e;A?.visibilityState==="visible"&&(this.Ke=!0,(e=this.yv)==null||e.setDocumentWasEverVisible==null||e.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw qt.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Rn.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');A!=null&&A.addEventListener&&ae(A,"visibilitychange",this.ar)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(t===void 0?{}:t).discardBufferedEvents,s=e!==void 0&&e;this.wv=!0,A==null||A.removeEventListener==null||A.removeEventListener("visibilitychange",this.ar),s?this.Sv(!0):this.stopRecording()}get xv(){var t,e=!((t=this._instance.get_property(ui))==null||!t.enabled),s=!this.Rn.disable_session_recording,i=this.Rn.disable_session_recording||this._instance.consent.isOptedOut();return b&&e&&s&&!i}startIfEnabledOrStop(t){var e;if(!(this.wv||this.xv&&(e=this.yv)!=null&&e.isStarted)){var s=!S(Object.assign)&&!S(Array.from);this.xv&&s?(this.Cv(t),qt.info("starting")):(this.bv=Tn,this.stopRecording())}}Cv(t){var e,s;if(this.xv)if(this.bv!=="awaiting_config"&&this.bv!=="missing_config"&&(this.bv=yf),L!=null&&(e=L.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(s=L.__PosthogExtensions__)!=null&&s.initSessionRecording)this.Tv(t);else{var i,r=this._instance.sessionManager;(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Mv,n=>{if(!this.wv&&this.xv&&this._instance.sessionManager===r)return n?(this._instance.register_for_session({[Fl]:!0}),qt.error("could not load recorder",n)):void this.Tv(t);this.bv=Tn})}}stopRecording(){var t,e;(t=this._v)==null||t.call(this),this._v=void 0,(e=this.yv)==null||e.stop()}Sv(t){var e,s;t===void 0&&(t=!1),(e=this._v)==null||e.call(this),this._v=void 0,(s=this.yv)==null||s.discard({discardProducerEvents:t})}Iv(){var t,e;(t=this.sl)==null||t.unregister(au),(e=this.sl)==null||e.unregister(Rg)}Ev(t,e){if(H(t))return null;var s,i=Re(t)?t:parseFloat(t);return typeof(s=i)!="number"||!Number.isFinite(s)||0>s||s>1?(qt.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):i}Rv(t){if(this.sl){var e,s,i=this.sl,r=()=>{var n,o=t.sessionRecording===!1?void 0:t.sessionRecording,a=this.Ev((n=this.Rn.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.Ev(o?.sampleRate,"remote config sampleRate"),u=a??l;H(u)&&this.Iv();var c=o?.minimumDurationMilliseconds;i.register({[ui]:k({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:k({capturePerformance:t.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:S(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};r(),(e=this._v)==null||e.call(this),this._v=(s=this._instance.sessionManager)==null?void 0:s.onSessionId(r)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.Rv(e),void this.Sv()):(this.Rv(e),void this.startIfEnabledOrStop()):(this.bv==="awaiting_config"&&(this.bv="missing_config",qt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var s;e===void 0&&(e="log"),(s=this.yv)!=null&&s.log?this.yv.log(t,e):qt.warn("log called before recorder was ready")}get Mv(){var t;return((t=this._instance)==null||(t=t.persistence)==null||(t=t.get_property("$session_recording_remote_config"))==null||(t=t.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Av(){var t,e=this._instance.get_property(ui);if(!e)return!1;try{t=typeof e=="object"?e:JSON.parse(e)}catch(s){return qt.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}return!H(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Tv(t){var e,s,i;if(!this.wv&&this.xv&&this._instance.sessionManager){if((e=L.__PosthogExtensions__)==null||!e.initSessionRecording)return qt.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Fl]:!0});var r;if(this.yv||(this.yv=(r=L.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance,this.Ke),this.yv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Av())return this.bv==="missing_config"||this.bv==="awaiting_config"?void 0:(this.bv="awaiting_config",qt.info("persisted remote config is stale, requesting fresh config before starting"),void new lp(this._instance).load());this.bv=yf,(s=(i=this.yv).setDocumentWasEverVisible)==null||s.call(i,this.Ke),this.yv.start(t)}else this.bv=Tn}onRRwebEmit(t){var e;(e=this.yv)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.yv||(t=this.sl)==null||t.register({[Og]:!0}),(e=this.yv)==null||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.yv||(t=this.sl)==null||t.register({[Tg]:!0}),(e=this.yv)==null||e.overrideSampling()}overrideTrigger(t){var e,s;this.yv||(e=this.sl)==null||e.register({[t==="url"?Pg:Cg]:!0}),(s=this.yv)==null||s.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.yv)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var s;return!((s=this.yv)==null||!s.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;(t=this.yv)==null||t.flushBeforeIdentityReset==null||t.flushBeforeIdentityReset()}}},kk={autocapture:class extends rk{constructor(t){super(new nk(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.Pv=this.Fv()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Ov();return!!(t.path||t.search||this.$v(t))}startIfEnabled(){this.isEnabled&&(I.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Pv=this.Fv(),this.startIfEnabled()}stop(){this.Dv&&this.Dv(),this.Dv=void 0,this.Lv&&this.Lv(),this.Lv=void 0,I.info("History API monitoring stopped")}monitorHistoryChanges(){b&&b.history&&(this.Nv("pushState"),this.Nv("replaceState"),this.qv(),this.$v()&&this.jv())}Nv(t){var e;if(b&&((e=b.history[t])==null||!e.__posthog_wrapped__)){var s=this;Op(b.history,t,i=>function(r,n,o){i.call(this,r,n,o),s.Bv(t)})}}Fv(){var t=b?.location;if(t!=null&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Ov(){var t=this._instance.config.capture_pageview;return t==="history_change"?{path:!0}:Y(t)?t:{}}$v(t){return t===void 0&&(t=this.Ov()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Hv(t){var e=this.Ov(),s=this.Pv;return!(!s||!(e.path&&t.pathname!==s.pathname||e.search&&t.search!==s.search||this.$v(e)&&t.hash!==s.hash))}Bv(t){try{var e=this.Fv();if(!e)return;this.Hv(e)&&this._instance.capture(uu,{navigation_type:t}),this.Pv=e}catch(s){I.error("Error capturing "+t+" pageview",s)}}qv(){if(!this.Dv){var t=()=>{this.Bv("popstate")};ae(b,"popstate",t),this.Dv=()=>{b&&b.removeEventListener("popstate",t)}}}jv(){if(!this.Lv){var t=()=>{this.Bv("hashchange")};ae(b,"hashchange",t),this.Lv=()=>{b&&b.removeEventListener("hashchange",t)}}}},heatmaps:class{get Rn(){return this.instance.config}constructor(t){var e;this.zv=!1,this.Xs=!1,this.Uv=null,this.instance=t,this.zv=!((e=this.instance.persistence)==null||!e.props[Tl]),this.rageclicks=new Tp(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return Y(this.Rn.capture_heatmaps)&&this.Rn.capture_heatmaps.flush_interval_milliseconds&&(t=this.Rn.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return H(this.Rn.capture_heatmaps)?H(this.Rn.enable_heatmaps)?this.zv:this.Rn.enable_heatmaps:this.Rn.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Xs)return;uk.info("starting..."),this.Wv(),this.ar()}else{var t;clearInterval((t=this.Uv)!==null&&t!==void 0?t:void 0),this.Vv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var s=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Tl]:s}),this.zv=s,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}Gv(t){fl(t.originalEvent)&&this.vn(t.originalEvent,"deadclick")}ar(){this.Uv&&clearInterval(this.Uv),this.Uv=A?.visibilityState==="visible"?setInterval(this.Ja.bind(this),this.flushIntervalMilliseconds):null}Wv(){b&&A&&(this.Zv=this.Ja.bind(this),ae(b,Xn,this.Zv),this.Jv=t=>this.vn(t||b?.event),ae(A,"click",this.Jv,{capture:!0}),this.Qv=t=>this.Kv(t||b?.event),ae(A,"mousemove",this.Qv,{capture:!0}),this.Xv=new Jh(this.instance,gw,this.Gv.bind(this)),this.Xv.startIfEnabledOrStop(),this.Yv=this.ar.bind(this),ae(A,hi,this.Yv),this.Xs=!0)}Vv(){var t;b&&A&&(this.Zv&&b.removeEventListener(Xn,this.Zv),this.Jv&&A.removeEventListener("click",this.Jv,{capture:!0}),this.Qv&&A.removeEventListener("mousemove",this.Qv,{capture:!0}),this.Yv&&A.removeEventListener(hi,this.Yv),clearTimeout(this.tc),(t=this.Xv)==null||t.stop(),this.Xs=!1)}ec(t,e){var s=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var u=o;u&&Dt(u)&&!Ge(u,"body");){if(u===l)return!1;var c=void 0;try{var h,g,f;c=(h=(g=(f=u.ownerDocument)==null?void 0:f.defaultView)!==null&&g!==void 0?g:b)==null?void 0:h.getComputedStyle(u).position}catch{return!1}if(M(a,c))return!0;u=zg(u)}return!1})(or(t),["fixed","sticky"],r);return{x:t.clientX+(n?0:i),y:t.clientY+(n?0:s),target_fixed:n,type:e}}vn(t,e){var s;if(e===void 0&&(e="click"),!Bh(t.target)&&fl(t)){var i=this.ec(t,e);(s=this.rageclicks)!=null&&s.isRageClick(t.clientX,t.clientY,new Date().getTime())&&Wg(or(t),this.instance.config.rageclick)&&this.$s(k({},i,{type:"rageclick"})),this.$s(i)}}Kv(t){!Bh(t.target)&&fl(t)&&(clearTimeout(this.tc),this.tc=setTimeout(()=>{this.$s(this.ec(t,"mousemove"))},500))}$s(t){if(b){var e=this.Rn.disable_capture_url_hashes?ds(b.location.href):b.location.href,s=this.Rn.custom_personal_data_properties,i=vr(e,this.Rn.mask_personal_data_properties?[...vi,...s||[]]:[],_r);this.Rt=this.Rt||{},this.Rt[i]||(this.Rt[i]=[]),this.Rt[i].push(t)}}Ja(){this.Rt&&!nt(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Jh,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.zv=!1,this.Xs=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.rc=()=>{clearTimeout(this.nc),this.nc=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",k({$current_url:this.Rt.url},this.Rt.metrics.reduce((s,i)=>k({},s,{["$web_vitals_"+i.name+"_event"]:k({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.sc=s=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},H(s?.name)||H(s?.value))ks.error("Invalid metric received",s);else{var r=typeof s.navigationURL=="string"?s.navigationURL:void 0,n=this.oc(r);if(!S(n)){var o=Re(s.navigationId)||typeof s.navigationId=="string"?"navigation:"+s.navigationId:"url:"+n;if(!this.ac||this.ac>s.value){this.Rt.navigationKey!==o&&(this.rc(),this.nc=setTimeout(this.rc,this.flushToCaptureTimeoutMs)),S(this.Rt.navigationKey)&&(this.Rt.navigationKey=o,this.Rt.url=n),this.Rt.firstMetricTimestamp=S(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var a=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0),l=k({},s,r?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});if(delete l.entries,Y(s.attribution)&&this.attributionMetrics.indexOf(s.name)>-1){var u={};for(var c of lk){var h=c==="url"&&typeof s.attribution[c]=="string"?this.oc(s.attribution[c]):s.attribution[c];S(h)||(u[c]=h)}l.attribution=u}else delete l.attribution;S(a)||(l.$session_id=a.sessionId,l.$window_id=a.windowId),this.Rt.metrics.push(l),this.Rt.metrics.length===this.allowedMetrics.length&&this.rc()}else ks.error("Ignoring metric with value >= "+this.ac,s)}}},this.lc=()=>{if(!this.Xs){var s,i,r,n,o=!1,a=L.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,u=l?.[this.uc]||(this.uc==="web-vitals"&&S(l)?a?.postHogWebVitalsCallbacks:void 0);if(!S(u)){var c=u.withoutAttribution,h=this.attributionMetrics;o=!S(c),s=h.indexOf("LCP")>-1?u.onLCP:c?.onLCP||u.onLCP,i=h.indexOf("CLS")>-1?u.onCLS:c?.onCLS||u.onCLS,r=h.indexOf("FCP")>-1?u.onFCP:c?.onFCP||u.onFCP,n=h.indexOf("INP")>-1?u.onINP:c?.onINP||u.onINP}if(s&&i&&r&&n){var g={reportSoftNavs:this.useSoftNavs},f=o&&this.attributionMetrics.indexOf("INP")>-1?k({},g,{includeProcessedEventEntries:!1}):g;this.allowedMetrics.indexOf("LCP")>-1&&s(this.sc.bind(this),g),this.allowedMetrics.indexOf("CLS")>-1&&i(this.sc.bind(this),g),this.allowedMetrics.indexOf("FCP")>-1&&r(this.sc.bind(this),g),this.allowedMetrics.indexOf("INP")>-1&&n(this.sc.bind(this),f),this.Xs=!0}else ks.error("web vitals callbacks not loaded - not starting")}},this.zv=!((e=this._instance.persistence)==null||!e.props[Cl]),this.startIfEnabled()}get hc(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,s=Y(this.hc)?(t=this.hc)==null?void 0:t.web_vitals_allowed_metrics:void 0;return H(s)?((e=this._instance.persistence)==null?void 0:e.props.$web_vitals_allowed_metrics)||mf:s}get flushToCaptureTimeoutMs(){return(Y(this.hc)?this.hc.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=Y(this.hc)?this.hc.web_vitals_attribution:void 0;return Xe(t)?t?mf:[]:F(t)?t:ak}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return(t=Y(this.hc)?this.hc.__preview_web_vitals_soft_navs:void 0)!==null&&t!==void 0&&t}get ac(){var t=Y(this.hc)&&Re(this.hc.__web_vitals_max_value)?this.hc.__web_vitals_max_value:_f;return t>0&&6e4>=t?_f:t}get isEnabled(){var t=Ee?.protocol;if(t!=="http:"&&t!=="https:")return ks.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=Y(this.hc)?this.hc.web_vitals:Xe(this.hc)?this.hc:void 0;return Xe(e)?e:this.zv}startIfEnabled(){this.isEnabled&&!this.Xs&&(ks.info("enabled, starting..."),this.bo(this.lc))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var s=Y(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=Y(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Cl]:s}),this._instance.persistence.register({[Ig]:i})),this.zv=s,this.startIfEnabled()}}}get uc(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}bo(t){var e=L.__PosthogExtensions__,s=this.uc,i=e?.postHogWebVitalsCallbacksByFlavor;i!=null&&i[s]||s==="web-vitals"&&S(i)&&e!=null&&e.postHogWebVitalsCallbacks?t():e==null||e.loadExternalDependency==null||e.loadExternalDependency(this._instance,s,r=>{r?ks.error("failed to load script",r):t()})}oc(t){var e=t||b?.location.href;if(e){var s=this._instance.config.disable_capture_url_hashes?ds(e):e,i=this._instance.config.custom_personal_data_properties;return vr(s,this._instance.config.mask_personal_data_properties?[...vi,...i||[]]:[],_r)}ks.error("Could not determine current URL")}}},Ak={exceptionObserver:class{constructor(t){var e;this.lc=()=>{var s;if(b&&this.isEnabled&&(s=L.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var i=L.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=L.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=L.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.dc&&this.Rn.capture_unhandled_errors&&(this.dc=i(this.captureException.bind(this))),!this.vc&&this.Rn.capture_unhandled_rejections&&(this.vc=r(this.captureException.bind(this))),!this.cc&&this.Rn.capture_console_errors&&(this.cc=n(this.captureException.bind(this)))}catch(o){er.error("failed to start",o),this.fc()}}},this._instance=t,this.gc=!((e=this._instance.persistence)==null||!e.props[Ol]),this.wt=new GE(k({},(function(s){var i,r,n,o;return s===void 0&&(s={}),{refillRate:(i=(r=s.exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:s.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(n=(o=s.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:s.__exceptionRateLimiterBucketSize)!==null&&n!==void 0?n:10}})(this._instance.config.error_tracking),{refillInterval:1e4,A:er})),this.Rn=this.mc(),this.startIfEnabledOrStop()}mc(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Y(t)?e=k({},e,t):(S(t)?this.gc:t)&&(e=k({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Rn.capture_console_errors||this.Rn.capture_unhandled_errors||this.Rn.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(er.info("enabled"),this.fc(),this.bo(this.lc)):this.fc()}bo(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.errorWrappingFunctions?t():(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return er.error("failed to load script",i);t()})}fc(){var t,e,s;(t=this.dc)==null||t.call(this),this.dc=void 0,(e=this.vc)==null||e.call(this),this.vc=void 0,(s=this.cc)==null||s.call(this),this.cc=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.gc=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ol]:this.gc}),this.Rn=this.mc(),this.startIfEnabledOrStop())}}onConfigChange(){this.Rn=this.mc()}captureException(t){try{var e,s,i,r=(e=t==null||(s=t.$exception_list)==null||(s=s[0])==null?void 0:s.type)!==null&&e!==void 0?e:"Exception";if(this.wt.consumeRateLimit(r))return void er.info("Skipping exception capture because of client rate limiting.",{exception:r});(i=this._instance.exceptions)==null||i.sendExceptionEvent(t)}catch{}}},exceptions:class{constructor(t){var e,s;this.yc=[],this.bc=new ZE([new aS,new vS,new uS,new lS,new gS,new fS,new dS,new pS],(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 u=[],c=a.split(`
7
- `),h=l;c.length>h;h++){var g=c[h];if(1024>=g.length){var f=wh.test(g)?g.replace(wh,"$1"):g;if(!f.match(/\S*Error: /)){for(var p of n){var _=p(f,i);if(_){u.push(_);break}}if(u.length>=50)break}}}return(function(v){if(!v.length)return[];var m=Array.from(v);return m.reverse(),m.slice(0,50).map(y=>{return k({},y,{filename:y.filename||(w=m,w[w.length-1]||{}).filename,function:y.function||"?"});var w})})(u)}})("web:javascript",iS,oS)),this._instance=t,this.yc=(e=(s=this._instance.persistence)==null?void 0:s.get_property("$error_tracking_suppression_rules"))!==null&&e!==void 0?e:[],this._c=zn(this.wc()),this.kc=new mS(this._c)}onConfigChange(){this._c=zn(this.wc()),this.kc.setConfig(this._c)}onRemoteConfig(t){var e,s,i;if(t.ok){var r=t.config;if("errorTracking"in r){var n=(e=(s=r.errorTracking)==null?void 0:s.suppressionRules)!==null&&e!==void 0?e:[],o=(i=r.errorTracking)==null?void 0:i.captureExtensionExceptions;this.yc=n,this._instance.persistence&&this._instance.persistence.register({[Ag]:this.yc,[Pl]:o})}}}get Sc(){var t,e,s=!!this._instance.get_property(Pl);return(t=(e=this._instance.config.error_tracking.captureExtensionExceptions)!==null&&e!==void 0?e:s)!==null&&t!==void 0&&t}buildProperties(t,e){return this.bc.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this._c.enabled)try{if(!Q(t)||t.trim().length===0)return void yt.warn("Ignoring exception step because message must be a non-empty string");var s=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};var o=[];return{sanitizedProperties:Object.keys(n).reduce((a,l)=>_S.has(l)?(o.push(l),a):(a[l]=n[l],a),{}),droppedKeys:o}})(this.xc(e)),i=s.sanitizedProperties,r=s.droppedKeys;r.length>0&&yt.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.kc.add(k({[Hn]:t,[qn]:new Date().toISOString()},i))}catch(n){yt.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Cc(e)){if(this.Tc(e))return this.Mc("Exception dropped: matched a suppression rule"),void yt.info("Skipping exception capture because a suppression rule matched");if(!this.Sc&&this.Ic(e))return this.Mc("Exception dropped: thrown by a browser extension"),void yt.info("Skipping exception capture because it was thrown by an extension");if(!this.Sc&&this.Ec(e))return this.Mc("Exception dropped: thrown by an injected browser script"),void yt.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Rc(e))return this.Mc("Exception dropped: thrown by the PostHog SDK"),void yt.info("Skipping exception capture because it was thrown by the PostHog SDK")}var s=this._c.enabled&&H(t.$exception_steps)?this.Ac(t):t,i=typeof(n=globalThis._posthogReleaseId)=="string"&&n.length>0?n:void 0;i&&(s.$release_id=i);try{var r=this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",Du:!0});return r&&this.kc.clear(),r}catch(o){return Of(o)||yt.error("Failed to capture exception event. Dropping this exception.",o),void this.kc.clear()}}catch(o){return void(Of(o)||yt.error("Failed to process exception event. Ignoring this exception.",o))}var n}Ac(t){try{var e=this.kc.getAttachable();return e.length===0?t:k({},t,{$exception_steps:e})}catch(s){return yt.error("Failed to read buffered exception steps. Capturing exception without steps.",s),t}}Mc(t){this._c.enabled&&this.kc.add({[Hn]:t,[qn]:new Date().toISOString()})}xc(t){return Y(t)?k({},t):{}}wc(){var t,e;return(t=(e=this._instance.config.error_tracking)==null?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}Tc(t){if(t.length===0)return!1;try{var e=t.reduce((s,i)=>{var r=i.type,n=i.value;return Q(r)&&r.length>0&&s.$exception_types.push(r),Q(n)&&n.length>0&&s.$exception_values.push(n),s},{$exception_types:[],$exception_values:[]});return this.yc.some(s=>{var i=s.values.map(r=>{var n=wp[r.operator],o=e[r.key];if(!n||!o)return!1;var a=F(r.value)?r.value:[r.value];return a.length>0&&n(a,o)});return s.type==="OR"?i.some(Boolean):i.every(Boolean)})}catch(s){return yt.warn("Failed to evaluate suppression rules. Capturing the exception.",s),!1}}Ic(t){var e=t.flatMap(i=>{var r,n;return(r=(n=i.stacktrace)==null?void 0:n.frames)!==null&&r!==void 0?r:[]}),s=e.filter(i=>{var r=i.filename;return!!r&&yk.some(n=>r.startsWith(n))});return s.length!==0&&(!s.every(i=>{var r=i.filename;return!!r&&r.startsWith(Ql)})||t.some(i=>{var r=i.value;return i.type==="NoResponse"||Q(r)&&mk.some(n=>{var o=n.value;return n.exact?r===o:r.includes(o)})})&&!e.some(i=>{var r=i.filename;return i.in_app&&!(r!=null&&r.startsWith(Ql))}))}Ec(t){return t.some(e=>{var s=e.value;return Q(s)&&bk.some(i=>s.includes(i))})}Rc(t){if(t.length>0){var e,s,i,r,n=(e=(s=t[0].stacktrace)==null?void 0:s.frames)!==null&&e!==void 0?e:[];return(i=(r=n[n.length-1])==null||(r=r.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}Cc(t){return!H(t)&&F(t)}}},Ik=k({productTours:class{get sl(){return this._instance.persistence}constructor(t){this.Pc=null,this.Fc=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var e=t.config;if("productTours"in e){var s,i;if(this.sl&&this.sl.register({[ou]:!!e.productTours}),!gl(this._instance))return!this.Pc&&H((s=this.sl)==null?void 0:s.props.ph_product_tours)||On.info("product tours disabled; stopping and clearing cached tours"),(i=this.Pc)==null||i.stop(),this.Pc=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Pc&&gl(this._instance)&&this.bo(()=>this.Oc())}bo(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.generateProductTours?t():(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"product-tours",i=>{i?On.error("Could not load product tours script",i):t()})}Oc(){var t;!this.Pc&&(t=L.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.Pc=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(e===void 0&&(e=!1),!F(this.Fc)||e){var s=this.sl;if(s){var i=s.props[Ln];if(F(i)&&!e)return this.Fc=i,void t(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:r=>{if(gl(this._instance)){var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return n===0?r.error||On.warn(o):On.error(o),void t([],{isLoaded:!1,error:o})}var a=F(r.json.product_tours)?r.json.product_tours:[];this.Fc=a,s&&s.register({[Ln]:a}),t(a,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Fc,{isLoaded:!0})}getActiveProductTours(t){H(this.Pc)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Pc.getActiveProductTours(t)}showProductTour(t){var e;(e=this.Pc)==null||e.showTourById(t)}previewTour(t){this.Pc?this.Pc.previewTour(t):this.bo(()=>{var e;this.Oc(),(e=this.Pc)==null||e.previewTour(t)})}dismissProductTour(){var t;(t=this.Pc)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.Pc)==null||t.nextStep()}previousStep(){var t;(t=this.Pc)==null||t.previousStep()}clearCache(){var t;this.Fc=null,(t=this.sl)==null||t.unregister(Ln)}resetTour(t){var e;(e=this.Pc)==null||e.resetTour(t)}resetAllTours(){var t;(t=this.Pc)==null||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.Pc)==null||e.cancelPendingTour(t)}}},co),Rk={siteApps:class{constructor(t){this._instance=t,this.$c=0,this.Dc=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Lc(t,e){if(e){var s=this.globalsForEvent(e);this.Dc.push(s),this.Dc.length>1e3&&(this.Dc=this.Dc.slice(10))}}get siteAppLoaders(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Lc.bind(this));this.Nc=()=>{t(),this.Dc=[],this.Nc=void 0}}}globalsForEvent(t){var e,s,i,r,n,o,a;if(!t)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var h of Object.entries(c)){var g=h[0];l[g]={id:u[g],type:g,properties:h[1]}}var f=t.$set_once,p=t.$set;return{event:k({},Nf(t,NE),{properties:k({},t.properties,p?{$set:k({},(e=(s=t.properties)==null?void 0:s.$set)!==null&&e!==void 0?e:{},p)}:{},f?{$set_once:k({},(i=(r=t.properties)==null?void 0:r.$set_once)!==null&&i!==void 0?i:{},f)}:{}),elements_chain:(n=(o=t.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=t.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}qc(t){var e,s=(e=t.tagName)==null?void 0:e.toLowerCase();return s==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Tt.error("prepare_external_dependency_stylesheet returned null"),null):s==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Tt.error("prepare_external_dependency_script returned null"),null):t}jc(){var t,e,s,i,r,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=A?.defaultView,u=l==null||(t=l.Node)==null?void 0:t.prototype;if(!l||!u)return()=>{};if(this.$c++,this.Bc)return this.Hc();var c=[],h=this,g=new WeakSet,f=(v,m,y)=>{if(v!=null&&v[m]){var w=v[m];v[m]=y(w),c.push(()=>{v[m]=w})}},p=v=>{if(g.has(v))return v;var m=h.qc(v);return m&&g.add(m),m},_=v=>v.map(m=>typeof m=="string"?m:p(m)).filter(m=>!Ie(m));return f(u,"appendChild",v=>function(m){var y=p(m);return y?v.call(this,y):m}),f(u,"insertBefore",v=>function(m,y){var w=p(m);return w?v.call(this,w,y):m}),f(u,"replaceChild",v=>function(m,y){var w=p(m);return w?v.call(this,w,y):y}),[(e=l.Element)==null?void 0:e.prototype,(s=l.Document)==null?void 0:s.prototype,(i=l.DocumentFragment)==null?void 0:i.prototype].forEach(v=>{f(v,"append",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];return m.apply(this,_(w))}),f(v,"prepend",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];return m.apply(this,_(w))})}),[(r=l.Element)==null?void 0:r.prototype,(n=l.CharacterData)==null?void 0:n.prototype,(o=l.DocumentType)==null?void 0:o.prototype].forEach(v=>{f(v,"before",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];return m.apply(this,_(w))}),f(v,"after",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];return m.apply(this,_(w))}),f(v,"replaceWith",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];var T=_(w);return w.length&&!T.length?void 0:m.apply(this,T)})}),f((a=l.Element)==null?void 0:a.prototype,"insertAdjacentElement",v=>function(m,y){var w=p(y);return w?v.call(this,m,w):null}),this.Bc=()=>{c.forEach(v=>v()),this.Bc=void 0},this.Hc()}Hc(){var t=!1;return()=>{var e;t||(t=!0,this.$c--,this.$c===0&&((e=this.Bc)==null||e.call(this)))}}zc(t,e){e===void 0&&(e=!0);var s=this.jc();try{var i=t(s);return e&&s(),i}catch(r){throw s(),r}}setupSiteApp(t){var e=this.apps[t.id],s=()=>{var o;!e.errored&&this.Dc.length&&(Tt.info("Processing "+this.Dc.length+" events for site app with id "+t.id),this.Dc.forEach(a=>this.zc(()=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every(a=>a.processedBuffer||a.errored)&&((o=this.Nc)==null||o.call(this))},i=!1,r=o=>{e.errored=!o,e.loaded=!0,Tt.info("Site app with id "+t.id+" "+(o?"loaded":"errored")),i&&s()};try{var n=this.zc(o=>t.init({posthog:this._instance,callback(a){o(),r(a)}}),!1).processEvent;n&&(e.processEvent=n),i=!0}catch(o){Tt.error(bf+t.id,o),r(!1)}if(i&&e.loaded)try{s()}catch(o){Tt.error("Error while processing buffered events PostHog app with config id "+t.id,o),e.errored=!0}}Uc(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var s of t)this.setupSiteApp(s)}Wc(t){var e=this;if(Object.keys(this.apps).length!==0){var s=this.globalsForEvent(t),i=function(n){try{e.zc(()=>n.processEvent==null?void 0:n.processEvent(s))}catch(o){Tt.error("Error while processing event "+t.event+" for site app "+n.id,o)}};for(var r of Object.values(this.apps))i(r)}}onRemoteConfig(t){var e,s,i,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.Uc(),void this._instance.on("eventCaptured",l=>this.Wc(l))):void Tt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.Nc)==null||s.call(this),t.ok){var n=t.config;if((i=n.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(){var l,u=a.id,c=a.url;L["__$$ph_site_app_"+u]=r._instance,(l=L.__PosthogExtensions__)==null||l.loadSiteApp==null||l.loadSiteApp(r._instance,c,h=>{if(h)return Tt.error(bf+u,h)})};for(var a of n.siteApps)o()}else Tt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Tk={tracingHeaders:class{constructor(t){this._instance=t,this.Vc=void 0,this.Gc=void 0,this.Zc=void 0,this.lc=()=>{var e,s,i=this.Jc();i?(S(this.Vc)&&(this.Vc=(e=L.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null?void 0:e._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),S(this.Gc)&&(this.Gc=(s=L.__PosthogExtensions__)==null||(s=s.tracingHeadersPatchFns)==null?void 0:s._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.fc()}}initialize(){this.startIfEnabledOrStop()}bo(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns?t():(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return ok.error("failed to load script",i);t()})}Qc(){var t,e;return(t=(e=this._instance.config.tracing_headers)!==null&&e!==void 0?e:this._instance.config.addTracingHeaders)!==null&&t!==void 0?t:this._instance.config.__add_tracing_headers}Jc(){var t=this.Qc();return F(t)?(F(this.Zc)?this.Zc.splice(0,this.Zc.length,...t):this.Zc=[...t],t.length>0?this.Zc:void 0):(F(this.Zc)&&this.Zc.splice(0),this.Zc=t||void 0,this.Zc)}fc(){var t,e;(t=this.Vc)==null||t.call(this),(e=this.Gc)==null||e.call(this),this.Vc=void 0,this.Gc=void 0}startIfEnabledOrStop(){this.Jc()?this.bo(this.lc):this.fc()}}},Ok=k({surveys:class extends ck{constructor(t){var e;super(new pk(t),(e=t,{get projectToken(){return e.config.token},kv:new gk(e)})),this._instance=t}ah(t,e){var s=e.query?yr(t,e.query):t;return new Promise(i=>{var r;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor((r=e.target)!==null&&r!==void 0?r:"api",s),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:i})})}}},co),Pk={toolbar:class{constructor(t){this.instance=t}Kc(t){L.ph_toolbar_state=t}Xc(){var t;return(t=L.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,s){if(t===void 0&&(t=void 0),e===void 0&&(e=void 0),s===void 0&&(s=void 0),Ul(this.instance.config)||!b||!A)return!1;t=t??b.location,s=s??b.history;try{if(!e){try{b.localStorage.setItem("test","test"),b.localStorage.removeItem("test")}catch{return!1}e=b?.localStorage}var i,r=vk||Zn(t.hash,"__posthog")||Zn(t.hash,"state"),n=r?Lh(()=>JSON.parse(atob(decodeURIComponent(r))))||Lh(()=>JSON.parse(decodeURIComponent(r))):null;return n&&n.action==="ph_authorize"?((i=n).source="url",i&&Object.keys(i).length>0&&(n.desiredHash?t.hash=n.desiredHash:s?s.replaceState(s.state,"",t.pathname+t.search):t.hash="")):((i=JSON.parse(e.getItem(Sf)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}Yc(t){var e=L.ph_load_toolbar||L.ph_load_editor;!H(e)&&qe(e)?e(t,this.instance):wf.warn("No toolbar load function found")}loadToolbar(t){var e=!(A==null||!A.getElementById("__POSTHOG_TOOLBAR__"));if(!b||e)return!1;var s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=k({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(b.localStorage.setItem(Sf,JSON.stringify(k({},i,{source:void 0}))),this.Xc()===2)this.Yc(i);else if(this.Xc()===0){var r;this.Kc(1),(r=L.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",n=>{if(n)return wf.error("[Toolbar] Failed to load",n),void this.Kc(0);this.Kc(2),this.Yc(i)}),ae(b,"turbolinks:load",()=>{this.Kc(0),this.loadToolbar(i)})}return!0}tf(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,s){return t===void 0&&(t=void 0),e===void 0&&(e=void 0),s===void 0&&(s=void 0),this.maybeLoadToolbar(t,e,s)}}},Ck=k({experiments:class Je{get Rn(){return this._instance.config}constructor(e){var s=this;this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),s.getWebExperiments(r=>{Je.ef("retrieved web experiments from the server"),s.if=new Map,r.forEach(n=>{if(n.feature_flag_key){var o;s.if&&(Je.ef("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=s.if)==null||o.set(n.feature_flag_key,n));var a=s._instance.getFeatureFlag(n.feature_flag_key);Q(a)&&n.variants[a]&&s.rf(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];Je.nf(u,s._instance)&&s.rf(n.name,l,u.transforms)}})},i)},this._instance.onFeatureFlags(i=>{this.onFeatureFlags(i)})}initialize(){}onFeatureFlags(e){if(this._is_bot())Je.ef(Pf);else if(!this.Rn.disable_web_experiments){if(H(this.if))return this.if=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Je.ef("applying feature flags",e),e.forEach(s=>{var i;if(this.if&&(i=this.if)!=null&&i.has(s)){var r,n=this._instance.getFeatureFlag(s),o=(r=this.if)==null?void 0:r.get(s);n&&o!=null&&o.variants[n]&&this.rf(o.name,n,o.variants[n].transforms)}})}}previewWebExperiment(){var e=Je.getWindowLocation();if(e!=null&&e.search){var s=pi(e?.search,"__experiment_id"),i=pi(e?.search,"__experiment_variant");s&&i&&(Je.ef("previewing web experiments "+s+" && "+i),this.getWebExperiments(r=>{this.sf(parseInt(s),i,r)},!1,!0))}}loadIfEnabled(){this.Rn.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,s,i){if(this.Rn.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!s)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Rn.token),method:"GET",timestampMode:"query",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}sf(e,s,i){var r=i.filter(n=>n.id===e);r&&r.length>0&&(Je.ef("Previewing web experiment ["+r[0].name+"] with variant ["+s+"]"),this.rf(r[0].name,s,r[0].variants[s].transforms))}static nf(e,s){return!H(e.conditions)&&Je.af(e,s)&&Je.lf(e)}static af(e,s){var i;if(H(e.conditions)||H((i=e.conditions)==null?void 0:i.url))return!0;var r=Je.getWindowLocation();if(r){var n,o,a,l=Gg(s,r.href);return(n=e.conditions)==null||!n.url||Ek[(o=(a=e.conditions)==null?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return b?.location}static lf(e){var s;if(H(e.conditions)||H((s=e.conditions)==null?void 0:s.utm))return!0;var i=tp();if(i.utm_source){var r,n,o,a,l,u,c,h,g=(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,f=(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||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==i.utm_medium,_=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return g&&p&&_&&f}return!1}static ef(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;s>r;r++)i[r-1]=arguments[r];I.info("[WebExperiments] "+e,i)}rf(e,s,i){this._is_bot()?Je.ef(Pf):s!=="control"?i.forEach(r=>{var n;r.selector&&(Je.ef("applying transform of variant "+s+" for experiment "+e+" ",r),(n=document)==null||(n=n.querySelectorAll(r.selector))==null||n.forEach(o=>{var a=o;r.html&&(a.innerHTML=r.html),r.css&&a.setAttribute("style",r.css)}))}):Je.ef("Control variants leave the page unmodified.")}_is_bot(){return Fe&&this._instance?bp(Fe,this.Rn.custom_blocked_useragents):void 0}}},co),xk=k({},co,wk,kk,Ak,Ik,Rk,Ok,Tk,Pk,Ck,{conversations:class{constructor(t){this._instance=t,this.uf=void 0,this._conversationsManager=null,this.hf=!1,this.re=null,this.df=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.vf=t.ok,t.ok)){var e=t.config.conversations;H(e)||(Xe(e)?this.uf=e:(this.uf=e.enabled,this.re=e),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.uf=void 0,this.re=null,this.vf=void 0,this.df=!1}loadIfEnabled(){if(!(this._conversationsManager||this.hf||this._instance.config.disable_conversations||Ul(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=L?.__PosthogExtensions__;if(t&&!S(this.uf)&&this.uf)if(this.re&&this.re.token){this.hf=!0;try{var e=t.initConversations;if(e)return this.cf(e),void(this.hf=!1);var s=t.loadExternalDependency;if(!s)return void this.ff(Ml);s(this._instance,"conversations",i=>{i||!t.initConversations?this.ff("Could not load conversations script",i):this.cf(t.initConversations),this.hf=!1})}catch(i){this.ff("Error initializing conversations",i),this.hf=!1}}else gt.error("Conversations enabled but missing token in remote config.")}}cf(t){if(this.re)try{this._conversationsManager=t(this.re,this._instance),this.df=!1,gt.info("Conversations loaded successfully")}catch(e){this.ff("Error completing conversations initialization",e)}else gt.error("Cannot complete initialization: remote config is null")}ff(t,e){gt.error(t,e),this._conversationsManager=null,this.hf=!1,this.df=!0}show(){this._conversationsManager?this._conversationsManager.show():gt.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.uf===!0&&!Ie(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Ul(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.vf===!1?"remote_config_failed":S(this.uf)?this.vf?"disabled_in_project":"remote_config_pending":this.uf?H(this.re)||!this.re.token?"missing_token":L!=null&&L.__PosthogExtensions__?this.hf?"initializing":this.df?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,s){var i=this;return ge(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(t,e,s):(gt.warn(Is),null)})()}getMessages(t,e){var s=this;return ge(function*(){return s._conversationsManager?s._conversationsManager.getMessages(t,e):(gt.warn(Is),null)})()}markAsRead(t){var e=this;return ge(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(gt.warn(Is),null)})()}getTickets(t){var e=this;return ge(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(gt.warn(Is),null)})()}requestRestoreLink(t){var e=this;return ge(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(gt.warn(Is),null)})()}restoreFromToken(t){var e=this;return ge(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(gt.warn(Is),null)})()}restoreFromUrlToken(){var t=this;return ge(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(gt.warn(Is),null)})()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}Wu(){var t;(t=this._conversationsManager)==null||t.setIdentity()}Vu(){var t;(t=this._conversationsManager)==null||t.clearIdentity()}}},{logs:class{constructor(t){var e,s=this;this._instance=t,this.name="logs",this.pf=!1,this.gf=!1,this.mf=!1,this.A=Te("[logs]"),this.yf=k({},this.A,{error(){for(var i=arguments.length,r=new Array(i),n=0;i>n;n++)r[n]=arguments[n];r.some(Df)||s.A.error(...r)}}),this.La=[],this.bf=[],this.Od=0,this.ro=!1,this._f=[],this.wf=[],this.kf=!1,this.Sf=!1,this.xf=()=>{var i,r;this.ro||(this.Od=0,(i=this.Cf)==null||i.onReconnect(),(r=this.Tf)==null||r.onReconnect())},this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.pf=!0),b&&ae(b,"online",this.xf)}Mf(t,e,s,i){var r,n=Cf((r=this._instance)==null||(r=r.config)==null?void 0:r.logs,s);return[new RS(this.If(t,e),n,this.yf,()=>this.Ef(),o=>o(),void 0,i),n]}Rf(){var t,e=(t=this._instance)==null||(t=t.config)==null?void 0:t.logs;if(!this.Cf||this.Af!==e){var s;(s=this.Cf)==null||s.reset(),this.Af=e;var i=this.Mf(()=>this.La,r=>{this.La=r});this.Cf=i[0],this.Pf=i[1]}return this.Cf}Ff(){var t,e=(t=this._instance)==null||(t=t.config)==null?void 0:t.logs;if(!this.Tf||this.Of!==e){var s;(s=this.Tf)==null||s.reset(),this.Of=e;var i=this.Mf(()=>this.bf,r=>{this.bf=r},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},xf);this.Tf=i[0],this.$f=i[1]}return this.Tf}setup(t){var e;if(!this.ro){this.Js=t,(e=this._instance)!=null&&(e=e.config)!=null&&(e=e.logs)!=null&&e.captureConsoleLogs&&(this.pf=!0),(this.pf||this.Df()&&this.Lf())&&this.Nf();var s=!1,i=t.onRemoteConfig(r=>{var n;s=r.ok&&((n=r.config.logs)==null?void 0:n.captureConsoleLogs)===!0,this.onRemoteConfig(r)});this.ro?i.dispose():(this.oo=i,s||this.loadIfEnabled())}}dispose(){var t,e,s,i;this.ro||(this.ro=!0,this.qf(),(t=this.oo)==null||t.dispose(),this.oo=void 0,this.Js=void 0,this.mf=!1,b?.removeEventListener("online",this.xf),(e=this.jf)==null||e.call(this),this.jf=void 0,(s=this.Cf)==null||s.reset(),(i=this.Tf)==null||i.reset())}onRemoteConfig(t){var e,s;if(!this.ro){var i=t.ok?(e=t.config.logs)==null?void 0:e.captureConsoleLogs:void 0;H(i)?this.Bf():((s=this._instance)==null||(s=s.persistence)==null||s.register({[xl]:!!i}),i?(this.pf=!0,this.gf||this.Nf(),this.loadIfEnabled()):this.Bf())}}reset(){var t,e,s,i;this.qf(),(t=this.Cf)==null||t.clearQueue(),this.La=[],(e=this.Cf)==null||e.reset(),(s=this.Tf)==null||s.clearQueue(),this.bf=[],(i=this.Tf)==null||i.reset(),this.Od=0}captureLog(t){this.ro||this.Rf().captureLog(t)}captureConsoleLog(t){this.ro||this.Ff().captureLog(t)}captureBufferedConsoleLog(t,e,s){this.ro||this.Ff().captureLog(t,{context:e,occurredAtMs:s})}Lf(){var t;return!((t=this._instance)==null||(t=t.persistence)==null||(t=t.props)==null||!t[xl])}Df(){var t,e;return(t=this._instance)==null||t.Fa==null||!t.Fa()||!((e=L._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null||!e.config)}Zu(){var t;this.qf(),(t=this.Tf)==null||t.clearQueue(),this.bf=[]}Bf(){this.pf||this.qf()}Nf(){var t,e=this;if(!this.kf&&L!=null&&L.console){var s=Cf((t=this._instance)==null||(t=t.config)==null?void 0:t.logs).maxBufferSize,i=function(n){var o;try{o=(a=>{for(;(l=a)!=null&&l.__rrweb_original__;){var l;a=a.__rrweb_original__}return a})(L.console[n])}catch{return 0}if(!o)return 0;e.wf.push(Op(L.console,n,a=>{var l=function(){for(var u=arguments.length,c=new Array(u),h=0;u>h;h++)c[h]=arguments[h];try{e.Hf(n,c,s)}catch{}return a.apply(L.console,c)};return l.__rrweb_original__=o,l}))};for(var r of Sk)i(r);this.kf=!0,this.zf=setTimeout(()=>{this.qf()},3e4)}}Hf(t,e,s){var i;if(this.kf&&!this.Sf&&e.length!==0)if((i=this._instance)!=null&&i.is_capturing()){if(s>this._f.length){this.Sf=!0;try{this._f.push({level:t,args:e,occurredAtMs:Date.now(),context:this.Ef()})}finally{this.Sf=!1}}}else this.qf()}qf(){if(this._f=[],this.kf){for(var t of(this.kf=!1,this.zf&&(clearTimeout(this.zf),this.zf=void 0),this.wf))t();this.wf=[]}}Uf(){var t=this._f;return this.qf(),t}get logger(){return this.Wf||(this.Wf={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Wf}flushLogs(t){t?this.Vf(t):(this.Cf&&this.Cf.flush().catch(e=>this.Gf(e)),this.Tf&&this.Tf.flush().catch(e=>this.Gf(e)))}Gf(t){Df(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.ro&&this.pf&&!this.gf&&!this.mf){var t=L?.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.qf();var e=t.loadExternalDependency;if(!e)return this.A.error(Ml),void this.qf();this.mf=!0;try{e(this._instance,"logs",s=>{if(this.mf=!1,!this.ro&&this.pf){var i=t.logs;if(s||i==null||!i.initializeLogs)this.A.error("Could not load logs script",s),this.qf();else{var r,n,o=this.Uf();this.jf=i.initializeLogs((r=this.Js)!==null&&r!==void 0?r:this._instance),this.gf=!0,o.length>0&&(i.replayConsoleBuffer==null||i.replayConsoleBuffer((n=this.Js)!==null&&n!==void 0?n:this._instance,o))}}})}catch(s){throw this.mf=!1,s}}}If(t,e){var s=this._instance;return{get isDisabled(){return!1},get optedOut(){return!s.is_capturing()},getPersistedProperty:i=>i===Pt.LogsQueue?t():void 0,setPersistedProperty(i,r){i===Pt.LogsQueue&&e(r??[])},xs:i=>this.xs(i),getLibraryId:()=>Le.LIB_NAME,getLibraryVersion:()=>Le.LIB_VERSION}}xs(t){return new Promise(e=>{if(Zg(this.Od,3))e({kind:"fatal",error:vl(void 0,"logs endpoint is unreachable, dropping batch")});else{var s=!1,i=n=>{s||(s=!0,clearTimeout(r),e(n))},r=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:vl(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Zf(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:n=>{var o=n.statusCode;if(this.Jf(o),o>=200&&300>o)i({kind:"ok"});else if(o===413)i({kind:"too-large"});else if(o!==0&&o!==408&&o!==429&&500>o)i({kind:"fatal",error:new Error("logs request failed with status "+o)});else{var a;o===0?(n.error||this.A.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:vl(n.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(a=n.error)!==null&&a!==void 0?a:new Error("logs request failed with status "+o)})}}})}})}Jf(t){(t!==0||this._instance.__loaded)&&(this.Od=ep(t,this.Od,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Vf(t){this.La.length>0&&this.Qf(t,this.La,this.Pf,Le.LIB_NAME,e=>{this.La=e}),this.bf.length>0&&this.Qf(t,this.bf,this.$f,xf,e=>{this.bf=e})}Qf(t,e,s,i,r){if(e.length!==0){var n=e.map(a=>a.record);r([]);var o=wg(n,Sg(s,Le.LIB_NAME,Le.LIB_VERSION),i,Le.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Zf(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}Zf(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Ef(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var s=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),i=s.windowId,r=s.sessionStartTimestamp,n=s.lastActivityTimestamp;e.sessionId=s.sessionId,e.windowId=i,H(r)||(e.sessionStartTimestamp=r),H(n)||(e.lastActivityTimestamp=n)}if(L!=null&&(t=L.location)!=null&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?ds(L.location.href):L.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(e.activeFeatureFlags=o)}return e}}},{metrics:class{constructor(t){this._instance=t,this.A=Te("[metrics]")}initialize(){}Rf(){var t,e,s=(t=this._instance)==null||(t=t.config)==null?void 0:t.metrics;return this.Cf&&this.Af===s||((e=this.Cf)==null||e.reset(),this.Af=s,this.Cf=new TS(this.If(),(function(i){var r,n,o,a,l,u=i?.resourceAttributes;return{serviceName:(r=u?.["service.name"])!==null&&r!==void 0?r:i?.serviceName,serviceVersion:(n=u?.["service.version"])!==null&&n!==void 0?n:i?.serviceVersion,environment:(o=u?.["deployment.environment"])!==null&&o!==void 0?o:i?.environment,resourceAttributes:u,beforeSend:i?.beforeSend,flushIntervalMs:(a=i?.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=i?.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(s),this.A)),this.Cf}count(t,e,s){e===void 0&&(e=1),this.Rf().count(t,e,s)}gauge(t,e,s){this.Rf().gauge(t,e,s)}histogram(t,e,s){this.Rf().histogram(t,e,s)}flush(t){if(!this.Cf)return Promise.resolve();if(t){var e=this.Cf.drainWindow();return e&&this.js(e,t),Promise.resolve()}return this.Cf.flush().catch(s=>this.A.error("PostHog metrics flush failed:",s))}reset(){var t;(t=this.Cf)==null||t.reset()}If(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},js:s=>e.js(s),getLibraryId:()=>Le.LIB_NAME,getLibraryVersion:()=>Le.LIB_VERSION}}js(t,e){return new Promise(s=>{var i=!1,r=o=>{i||(i=!0,clearTimeout(n),s(o))},n=setTimeout(()=>r({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(k({method:"POST",url:this.Kf(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(o){var a,l=o.statusCode;r(l>=200&&300>l?{kind:"ok"}:l===413?{kind:"too-large"}:l!==0&&l!==408&&l!==429&&500>l?{kind:"fatal",error:new Error("metrics request failed with status "+l)}:{kind:"retry-later",error:(a=o.error)!==null&&a!==void 0?a:new Error("metrics request failed with status "+l)})}}))})}Kf(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}});_u.__defaultExtensionClasses=k({},xk);Dk=(function(){Le.SDK_DIST_CHANNEL="npm";var t=ur[ir]=new _u;return(function(){function e(){e.done||(e.done=!0,Rp=!1,ie(ur,function(s){s._dom_loaded()}))}A!=null&&A.addEventListener?A.readyState==="complete"?e():ae(A,"DOMContentLoaded",e,{capture:!1}):b&&I.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),t})(),Ce=Dk});var Dp={};ho(Dp,{Posthog:()=>mu});var Ke,mu,Np=et(()=>{"use strict";xp();$i();Mi();Ke=class Ke{constructor(e,s=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=Zt("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let s=`ph_${e}_posthog`,i=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==s);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(u=>{let c=u?`; Domain=${u}`:"";document.cookie=`${a}=; path=/${c}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(u=>u.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:s,config:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}if(Ke._hasLoaded||Ce.__loaded){this.log("init | PostHog already initialized, skipping re-init"),this.has_initialized=!0;return}this.cleanupStalePosthogCookies(e);let r=s||nd();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:rd,autocapture:{dom_event_allowlist:["click"]},rate_limiting:{events_per_second:10,events_burst_limit:100},...i,person_profiles:"identified_only",capture_pageview:"history_change",capture_pageleave:!0,session_recording:{...i.session_recording,recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,maskAllInputs:!0},before_send:o=>{if(typeof window>"u"||!o)return null;if(o.timestamp){let u=o.timestamp.getTime(),c=Date.now();if(u<c-6048e5||u>c+6048e5)return this.log("init | before_send dropped event with bad timestamp",{event:o.event,timestamp:o.timestamp.toISOString()}),null}let a=window.location.hostname;if(a!=="localhost"&&a!=="127.0.0.1"&&!od.some(u=>a.endsWith(`.${u}`)||a===u))return this.log("init | before_send blocked event from disallowed host",{currentHost:a}),null;if(i.before_send){let l=Array.isArray(i.before_send)?i.before_send:[i.before_send],u=o;for(let c of l)u=u?c(u):null;return u}return o}};Ce.init(e,n),this.options.app_version&&Ce.register({app_version:this.options.app_version}),Ke._hasLoaded=!0,this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.resetIfStaleId=(e,s,i)=>{Ke.isAnonymousId(e)||(this.log(`${i} | stale identified user, resetting`,{previous:e,next:s}),Ce.reset())};this.identifyEvent=(e,s={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{if(!e||!e.trim()||Ke.ILLEGAL_IDS.has(e.toLowerCase())){this.log("identifyEvent | skipped \u2014 invalid user_id",{user_id:e});return}let i=Ce.get_distinct_id();if(i===e){this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e});return}this.resetIfStaleId(i,e,"identifyEvent"),this.log("identifyEvent | identifying user",{user_id:e,traits:s}),Ce.identify(e,{...s,client_id:e}),this.has_identified=!0}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),Ce.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:s,language:i,country_of_residence:r})=>{if(!(!this.has_initialized||!e)){if(!e.trim()||Ke.ILLEGAL_IDS.has(e.toLowerCase())){this.log("backfillPersonProperties | skipped \u2014 invalid user_id",{user_id:e});return}try{let n=Ce.get_distinct_id(),o=n===e;o||this.resetIfStaleId(n,e,"backfillPersonProperties");let a={};if(Ce.get_property("client_id")||(a.client_id=e),s&&Ce.get_property("is_internal")==null&&(a.is_internal=Jr(s)),i&&!Ce.get_property("language")&&(a.language=i),r&&!Ce.get_property("country_of_residence")&&(a.country_of_residence=r),o){if(Object.keys(a).length===0){this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e});return}this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:a}),Ce.setPersonProperties(a)}else a.client_id||(a.client_id=e),this.log("backfillPersonProperties | user not identified, identifying now",{user_id:e,updates:a}),Ce.identify(e,a),this.has_identified=!0}catch(n){console.error("Posthog: Failed to backfill person properties",n)}}};this.capture=(e,s)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:s}),Ce.capture(e,s)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let s=Ce.isFeatureEnabled(e);return this.log("isFeatureEnabled",{key:e,result:s}),s}catch(s){console.error("Posthog: Failed to check feature flag",s);return}};this.getFeatureFlag=e=>{if(this.has_initialized)try{let s=Ce.getFeatureFlag(e);return this.log("getFeatureFlag",{key:e,result:s}),s}catch(s){console.error("Posthog: Failed to get feature flag",s);return}};this.getFeatureFlagPayload=e=>{if(this.has_initialized)try{let s=Ce.getFeatureFlagResult(e)?.payload;return this.log("getFeatureFlagPayload",{key:e,result:s}),s}catch(s){console.error("Posthog: Failed to get feature flag payload",s);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let e=Ce.featureFlags?.getFlagVariants()??{},s=Object.fromEntries(Object.entries(e).filter(i=>i[1]!=null));return this.log("getAllFlags",{result:s}),s}catch(e){return console.error("Posthog: Failed to get all feature flags",e),{}}};this.onFeatureFlags=e=>{if(!this.has_initialized)return()=>{};try{this.log("onFeatureFlags | subscribing to feature flag changes");let s=Ce.onFeatureFlags(e);return typeof s=="function"?s:()=>{}}catch(s){return console.error("Posthog: Failed to subscribe to feature flags",s),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),Ce.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=s,this.init()}};Ke._hasLoaded=!1,Ke.ILLEGAL_IDS=new Set(["restored","null","undefined","anonymous","guest","distinctid","distinct_id","id","not_authenticated","email","true","false","0","none","nan"]),Ke.getPosthogInstance=(e,s=!1)=>(Ke._instance?e.apiKey&&e.apiKey!==Ke._instance.options.apiKey&&console.warn("Posthog: getPosthogInstance called with a different API key \u2014 returning existing instance"):Ke._instance=new Ke(e,s),Ke._instance),Ke.isAnonymousId=e=>e?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!0;mu=Ke});var Lk={};ho(Lk,{Analytics:()=>Lp});da();$i();Mi();var m0=4320*60*60,bs=class bs{constructor(e,s,i=!1,r){this.analytics=new Gs;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=Zt("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let s=window.location.hostname,n=["webflow.io"].some(u=>s.endsWith(u))?s:s.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let u=new Uint8Array(16);crypto.getRandomValues(u),u[6]=u[6]&15|64,u[8]=u[8]&63|128;let c=Array.from(u,h=>h.toString(16).padStart(2,"0")).join("");o=`${c.slice(0,8)}-${c.slice(8,12)}-${c.slice(12,16)}-${c.slice(16,20)}-${c.slice(20)}`}else throw new Error("Crypto API not available for secure random UUID generation");let l=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${this.rudderstack_anonymous_cookie_key}=${o}; path=/; Domain=${n}; max-age=${m0}; SameSite=Lax${l}`}catch(s){console.warn("RudderStack: Failed to set anonymous ID cookie",s)}};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:ha});try{this.setCookieIfNotExists(),this.analytics.load(e,ha,{...this.app_version&&{context:{app_version:this.app_version}},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(s){console.error("RudderStack: Failed to initialize",s)}};this.identifyEvent=(e,s)=>{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:s}),this.analytics.identify(e,s||{}),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,s="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:s,current_page:e,properties:n}),this.analytics.page(s,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,s)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:s}),this.analytics.track(e,s)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=s,this.debug=i,this.app_version=r,this.init(e)}};bs.getRudderStackInstance=(e,s,i=!1,r)=>(bs._instance||(bs._instance=new bs(e,s,i,r)),bs._instance);var Yr=bs;var Xr="cached_analytics_events",Qr="cached_analytics_page_views",fd=(t,e)=>{try{let s=localStorage.getItem(Xr),i=s?JSON.parse(s):[];i.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(Xr,JSON.stringify(i))}catch(s){console.warn("Analytics: Failed to cache event",s)}},gd=(t,e)=>{try{let s=localStorage.getItem(Qr),i=s?JSON.parse(s):[];i.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(Qr,JSON.stringify(i))}catch(s){console.warn("Analytics: Failed to cache page view",s)}},pd=()=>{try{let t=localStorage.getItem(Xr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached events",t)}return[]},vd=()=>{try{let t=localStorage.getItem(Qr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached pages",t)}return[]},_d=()=>{try{localStorage.removeItem(Xr)}catch(t){console.warn("Analytics: Failed to clear cached events",t)}},md=()=>{try{localStorage.removeItem(Qr)}catch(t){console.warn("Analytics: Failed to clear cached page views",t)}};Mi();function Nk(t){let e=t?.debug??!1,s=Zt("",()=>e),i,r,n,o={},a={},l=[],u=[],c=!1,h=()=>{if(!c&&r?.has_initialized){c=!0;try{let O=pd();O.length>0&&(s(`processStorageCache | replaying ${O.length} cached event(s)`,O),O.forEach(V=>{let K=ys(V.properties);r?.track(V.name,K)}),_d());let B=vd();B.length>0&&(s(`processStorageCache | replaying ${B.length} cached page view(s)`,B),B.forEach(V=>{r?.pageView(V.name,"Deriv App",E(),V.properties)}),md())}catch(O){console.warn("Analytics: Failed to process storage cache",O)}}},g=()=>{s("onSdkLoaded | RudderStack SDK loaded"),h(),u.length>0&&s(`onSdkLoaded | flushing ${u.length} pending identify call(s)`),u.forEach(({userId:O,traits:B})=>{O&&r?.identifyEvent(O,B)}),u=[]},f=async({growthbookKey:O,growthbookDecryptionKey:B,rudderstackKey:V,app_version:K,growthbookOptions:J,posthogOptions:W,debug:Z})=>{var X,se;Z!==void 0&&(e=Z),s("initialise | starting analytics initialization",{rudderstack:!!V,growthbook:!!O,posthog:!!W});try{let xe=J?.attributes?.country||(O?await cd():void 0);if(V&&(s("initialise | initializing RudderStack"),r=Yr.getRudderStackInstance(V,g,e,K)),J?.attributes&&Object.keys(J.attributes).length>0){let j=J.attributes,Me=r?.getAnonymousId();o={...o,country:xe,...j.user_language&&{user_language:j.user_language},...j.account_type&&{account_type:j.account_type},...j.app_id&&{app_id:j.app_id},...j.residence_country&&{residence_country:j.residence_country},...j.device_type&&{device_type:j.device_type},...j.url&&{url:j.url},...j.email_hash&&{email_hash:j.email_hash},...j.network_type&&{network_type:j.network_type},...j.network_rtt&&{network_rtt:j.network_rtt},...j.network_downlink&&{network_downlink:j.network_downlink},...j.account_currency&&{account_currency:j.account_currency},...j.account_mode&&{account_mode:j.account_mode},loggedIn:!!j.loggedIn,...j.user_id&&!Fi(j.user_id)&&{user_id:j.user_id},...Me&&{anonymous_id:Me}}}J??(J={}),J.attributes??(J.attributes={});let Se=r?.getAnonymousId();if((X=J.attributes).id??(X.id=Se),(se=J.attributes).country??(se.country=xe),O){s("initialise | initializing GrowthBook");let{Growthbook:j}=await Promise.resolve().then(()=>(dh(),ch));i=j.getGrowthBookInstance(O,B,J,e),s("initialise | GrowthBook initialized");let Me=setInterval(()=>{Object.keys(a).length>0?clearInterval(Me):a=v("tracking-buttons-config",{})},1e3)}if(W){s("initialise | initializing PostHog");let{Posthog:j}=await Promise.resolve().then(()=>(Np(),Dp));n=j.getPosthogInstance({app_version:K,...W},e),s("initialise | PostHog initialized")}s("initialise | analytics initialization complete")}catch(xe){console.warn("Analytics: Failed to initialize",xe)}},p=O=>{s("setAttributes | received attributes",O);let{user_id:B,...V}=O,K=B??E();if(i){let J={...V};B&&!Fi(B)&&(J.user_id=B),K&&(J.id=K,J.user_id=K),s("setAttributes | called GrowthBook setAttributes",J),i.setAttributes(J)}o={...o,...Object.fromEntries(Object.entries(V).filter(([,J])=>J!==void 0)),...B!==void 0&&!Fi(B)&&{user_id:B}},s("setAttributes | updated core_data",o)},_=O=>i?.getFeatureState(O)?.experimentResult?.name,v=(O,B)=>i?.getFeatureValue(O,B),m=async()=>await i?.getStatus(),y=O=>i?.isOn(O),w=O=>i?.setUrl(O),E=()=>{let O=r?.getUserId()||"";return O&&!Fi(O)?O:""},oe={initialise:f,setAttributes:p,identifyEvent:(O,B)=>{let V=O||E();if(!V){s("identifyEvent | skipped \u2014 no user_id available");return}s("identifyEvent | called",{user_id:V,traits:B});let K=X=>{if(!X)return X;let{email:se,...xe}=X;return{...xe,...se&&{is_internal:Jr(se)}}},J=B?.rudderstack!==void 0||B?.posthog!==void 0,W,Z;if(J){let{rudderstack:X,posthog:se,...xe}=B;W=K({...xe,...X}),Z=K({...xe,...se})}else W=K(B),Z=K(B);r&&(r.has_initialized?(s("identifyEvent | calling RudderStack identify",{user_id:V,traits:W}),r.identifyEvent(V,W)):u.some(X=>X.userId===V)||(s("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:V}),u.push({userId:V,traits:W}))),n?.has_initialized&&(s("identifyEvent | calling PostHog identify",{user_id:V,traits:Z}),n.identifyEvent(V,Z))},backfillPersonProperties:({user_id:O,email:B,language:V,country_of_residence:K})=>{s("backfillPersonProperties | called",{user_id:O}),n?.has_initialized?(s("backfillPersonProperties | backfilling person properties in PostHog",{user_id:O}),n.backfillPersonProperties({user_id:O,email:B,language:V,country_of_residence:K})):s("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:_,getFeatureValue:v,getGrowthbookStatus:m,isFeatureOn:y,setUrl:w,getId:E,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(O,B)=>{let V=E();s("trackEvent | called",{event:O,analytics_data:B,userId:V,core_data:o});let K={...o,...B,...V&&!o.user_id&&{user_id:V}};if(s("trackEvent | built payload",{event:O,final_payload:K}),!(!(O in a)||a[O])){s("trackEvent | skipped \u2014 event disabled by tracking_config",{event:O});return}let W=r?.has_initialized;if(!navigator.onLine||!W)W?(s("trackEvent | offline \u2014 caching event to memory",{event:O}),l.push({event:O,payload:K})):(s("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:O}),fd(O,K));else{l.length>0&&(s(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(X=>{let se=ys(X.payload);r?.track(X.event,se)}),l=[]);let Z=ys(K);s("trackEvent | sending event to RudderStack",{event:O,payload:Z}),r?.track(O,Z)}if(n?.has_initialized){let Z=ys(hd(K));s("trackEvent | sending event to PostHog",{event:O,payload:Z}),n.capture(O,Z)}},getInstances:()=>({ab:i,tracking:r,posthog:n}),pageView:(O,B="Deriv App",V)=>{let K=E();s("pageView | called",{current_page:O,platform:B,properties:V,userId:K}),r?.has_initialized?(s("pageView | sending page view to RudderStack",{current_page:O,platform:B}),r.pageView(O,B,K,V)):(s("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:O}),gd(O,{platform:B,...V}))},reset:()=>{s("reset | resetting all providers"),r?.has_initialized&&(s("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(s("reset | resetting PostHog"),n.reset())},isPosthogFeatureEnabled:O=>n?.isFeatureEnabled(O),getPosthogFeatureFlag:O=>n?.getFeatureFlag(O),getPosthogFeatureFlagPayload:O=>n?.getFeatureFlagPayload(O),getPosthogAllFlags:()=>n?.getAllFlags()??{},onPosthogFeatureFlags:O=>n?.onFeatureFlags(O)??(()=>{}),reloadPosthogFeatureFlags:()=>n?.reloadFeatureFlags()};return typeof window<"u"&&(window.AnalyticsInstance=oe),oe}var Lp=Nk();return Vp(Lk);})();
2
+ "use strict";var DerivAnalytics=(()=>{var Sn=Object.defineProperty;var Gv=Object.getOwnPropertyDescriptor;var Hv=Object.getOwnPropertyNames;var zv=Object.prototype.hasOwnProperty;var qv=(t,e,s)=>e in t?Sn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var Ze=(t,e,s)=>()=>{if(s)throw s[0];try{return t&&(e=t(t=0)),e}catch(i){throw s=[i],i}};var go=(t,e)=>{for(var s in e)Sn(t,s,{get:e[s],enumerable:!0})},Wv=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Hv(e))!zv.call(t,n)&&n!==s&&Sn(t,n,{get:()=>e[n],enumerable:!(i=Gv(e,n))||i.enumerable});return t};var Kv=t=>Wv(Sn({},"__esModule",{value:!0}),t);var Se=(t,e,s)=>qv(t,typeof e!="symbol"?e+"":e,s);function Ie(t){return t!=null&&typeof t=="object"&&t["@@functional/placeholder"]===!0}function xt(t){return function e(s){return arguments.length===0||Ie(s)?e:t.apply(this,arguments)}}function Jt(t){return function e(s,i){switch(arguments.length){case 0:return e;case 1:return Ie(s)?e:xt(function(n){return t(s,n)});default:return Ie(s)&&Ie(i)?e:Ie(s)?xt(function(n){return t(n,i)}):Ie(i)?xt(function(n){return t(s,n)}):t(s,i)}}}function Xo(t){return function e(s,i,n){switch(arguments.length){case 0:return e;case 1:return Ie(s)?e:Jt(function(r,o){return t(s,r,o)});case 2:return Ie(s)&&Ie(i)?e:Ie(s)?Jt(function(r,o){return t(r,i,o)}):Ie(i)?Jt(function(r,o){return t(s,r,o)}):xt(function(r){return t(s,i,r)});default:return Ie(s)&&Ie(i)&&Ie(n)?e:Ie(s)&&Ie(i)?Jt(function(r,o){return t(r,o,n)}):Ie(s)&&Ie(n)?Jt(function(r,o){return t(r,i,o)}):Ie(i)&&Ie(n)?Jt(function(r,o){return t(s,r,o)}):Ie(s)?xt(function(r){return t(r,i,n)}):Ie(i)?xt(function(r){return t(s,r,n)}):Ie(n)?xt(function(r){return t(s,i,r)}):t(s,i,n)}}}function kn(t,e){return Object.prototype.hasOwnProperty.call(e,t)}function Rc(t){return Object.prototype.toString.call(t)==="[object Object]"}function Jv(t,e){var s=t<0?e.length+t:t;return e[s]}function Xv(t){return new RegExp(t.source,t.flags?t.flags:(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":"")+(t.dotAll?"s":""))}function hu(t,e,s){if(s||(s=new e_),Zv(t))return t;var i=function(r){var o=s.get(t);if(o)return o;s.set(t,r);for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=hu(t[a],!0,s));return r};switch(Yv(t)){case"Object":return i(Object.create(Object.getPrototypeOf(t)));case"Array":return i(Array(t.length));case"Date":return new Date(t.valueOf());case"RegExp":return Xv(t);case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return t.slice();default:return t}}function Zv(t){var e=typeof t;return t==null||e!="object"&&e!="function"}function t_(t,e){for(var s=e,i=0;i<t.length;i+=1){if(s==null)return;var n=t[i];Qv(n)?s=Jv(n,s):s=s[n]}return s}function b_(t){return crypto.getRandomValues(new Uint8Array(t))}function E_(){(!_o||Xt+16>Oc)&&(_o=b_(Oc),Xt=0);for(var t=0,e,s="";t<16;t++)e=_o[Xt+t],t==6?s+=Cn[e&15|64]:t==8?s+=Cn[e&63|128]:s+=Cn[e],t&1&&t>1&&t<11&&(s+="-");return Xt+=16,s}function w_(){var t=0,e,s="";if(!Tn||_s+16>256){for(Tn=Array(t=256);t--;)Tn[t]=256*Math.random()|0;t=_s=0}for(;t<16;t++)e=Tn[_s+t],t==6?s+=On[e&15|64]:t==8?s+=On[e&63|128]:s+=On[e],t&1&&t>1&&t<11&&(s+="-");return _s++,s}function Q_(t,e,s=Y_){let i;return(...n)=>{globalThis.clearTimeout(i),i=globalThis.setTimeout(()=>{t.apply(e,n)},s)}}function Qn(){if(Dt>1)Dt--;else{var t,e=!1;for((function(){var n=Gn;for(Gn=void 0;n!==void 0;){var r=n.S;if(r.v===n.v)for(var o=r.t;o!==void 0;o=o.x)o.i===n.i&&(o.i=r.i);n=n.o}})();Ii!==void 0;){var s=Ii;for(Ii=void 0,jn++;s!==void 0;){var i=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&Tu(s))try{s.c()}catch(n){e||(t=n,e=!0)}s=i}}if(jn=0,Dt--,e)throw t}}function Fe(t){if(Dt>0)return t();Io=++lm,Dt++;try{return t()}finally{Qn()}}function Jn(t){var e=ke,s=Ti;ke=void 0,Ti=void 0;try{return t()}finally{ke=e,Ti=s}}function Au(t){if(ke!==void 0){var e=t.n;if(e===void 0||e.t!==ke)return e={i:0,S:t,p:ke.s,n:void 0,t:ke,e:void 0,x:void 0,r:e},ke.s!==void 0&&(ke.s.n=e),ke.s=e,t.n=e,32&ke.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=ke.s,e.n=void 0,ke.s.n=e,ke.s=e),e}}function We(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function C(t,e){return new We(t,e)}function Tu(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Iu(t){for(var e=t.s;e!==void 0;e=e.n){var s=e.S.n;if(s!==void 0&&(e.r=s),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Ru(t){for(var e=t.s,s=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)):s=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=i}t.s=s}function qs(t,e){We.call(this,void 0,e),this.x=t,this.s=void 0,this.g=Hn-1,this.f=4}function Cu(t){var e=t.m;if(t.m=void 0,typeof e=="function"){Dt++;var s=ke;ke=void 0;try{e()}catch(i){throw t.f&=-2,t.f|=8,ia(t),i}finally{ke=s,Qn()}}}function ia(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Cu(t)}function cm(t){if(ke!==this)throw new Error("Out-of-order effect");Ru(this),ke=t,this.f&=-2,8&this.f&&ia(this),Qn()}function Ws(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,Ti&&Ti.push(this)}function Mt(t,e){var s=new Ws(t,e);try{s.c()}catch(n){throw s.d(),n}var i=s.d.bind(s);return i[Symbol.dispose]=i,i}function Lu(t){if(!t?.includes(":"))return[t||void 0,void 0,void 0];let e=t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1):t,s=qy.exec(e);return s?[s[1]||void 0,s[2]===void 0?void 0:Number(s[2]),s[3]===void 0?void 0:Number(s[3])]:[void 0,void 0,void 0]}function Wy(t){if(!Fu.test(t))return null;t.includes("(eval ")&&(t=t.replaceAll("eval code","eval").replaceAll(/(\(eval at [^()]*)|(,.*$)/g,""));let e=t.replace(/^\s+/,"").replaceAll("(eval code","(").replace(/^.*?\s+/,""),s=/ (\(.+\)$)/.exec(e),i=s?e.replace(s[0],""):e,[n,r,o]=Lu(s?s[1]:e);return{functionName:s&&i||void 0,fileName:n==="eval"||n==="<anonymous>"?void 0:n,lineNumber:r,columnNumber:o}}function Ky(t){if(zy.test(t))return null;if(t.includes(" > eval")&&(t=t.replaceAll(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),!t.includes("@")&&!t.includes(":"))return{functionName:t,fileName:void 0,lineNumber:void 0,columnNumber:void 0};let e=t.lastIndexOf("@"),s=e>0?t.slice(0,e):void 0,[i,n,r]=Lu(t.slice(e+1));return{functionName:s,fileName:i,lineNumber:n,columnNumber:r}}function Yy(t){if(!t.stack)throw new Error("Cannot parse given Error object");let e=t.stack.split(`
3
+ `);return e.some(s=>Fu.test(s))?e.map(Wy).filter(s=>s!==null):e.map(Ky).filter(s=>s!==null)}function Wc(t,e,s,i){return{errorClass:qc(t),message:`${s}${qc(e)}`,type:"browserjs",stacktrace:i.reduce((n,r)=>{let o=Jy(r);try{return JSON.stringify(o)==="{}"?n:n.concat(o)}catch{return n}},[])}}function qu(t,e){let s=Object.assign(t,e);for(let i of Object.keys(s))typeof s[i]=="object"&&typeof e[i]=="object"&&(s[i]=qu(s[i],e[i]));return s}async function F0(t){let e=N0[t];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((s,i)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(r=>{import(r).then(o=>{if(!e.inited){let a=M0();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}s(e.lib)}).catch(i)})})}function et(t,e){if(!t?.default&&e){let s=Object.create(null);return s.default=t,s.__esModule=!0,s}return t}function tt(t,e){return F0(t).then(s=>s.get(e).then(i=>i()))}function hb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function gb(){return tu||(tu=1,(function(t,e){(function(s,i){t.exports=i()})(fb,function(){function s(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 n(g){if(typeof g=="string")try{return JSON.parse(g)}catch{return g}}function r(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",m="yes";try{g||(g=window.localStorage),g.setItem(p,m),g.removeItem(p)}catch{var v={};v._data={},v.setItem=function(y,w){return v._data[y]=String(w)},v.getItem=function(y){return v._data.hasOwnProperty(y)?v._data[y]:void 0},v.removeItem=function(y){return delete v._data[y]},v.clear=function(){return v._data={}},g=v}finally{g.getItem(p)===m&&g.removeItem(p)}return g}var l=a();function c(){if(!(this instanceof c))return new c}c.prototype={set:function(p,m){if(p&&!s(p))l.setItem(p,i(m));else if(s(p))for(var v in p)this.set(v,p[v]);return this},get:function(p){if(p===void 0){var m={};return this.forEach(function(I,k){return m[I]=k}),m}if(p.charAt(0)==="?")return this.has(p.substr(1));var v=arguments;if(v.length>1){for(var b={},y=0,w=v.length;y<w;y++){var A=n(l.getItem(v[y]));this.has(v[y])&&(b[v[y]]=A)}return b}return n(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var m=this.get(p);return l.removeItem(p),m},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(m){p.push(m)}),p},forEach:function(p){for(var m=0,v=l.length;m<v;m++){var b=l.key(m);p(b,this.get(b))}return this},search:function(p){for(var m=this.keys(),v={},b=0,y=m.length;b<y;b++)m[b].indexOf(p)>-1&&(v[m[b]]=this.get(m[b]));return v},len:function(){return l.length}};var u=null;function h(g,p){var m=arguments,v=null;if(u||(u=c()),m.length===0)return u.get();if(m.length===1){if(typeof g=="string")return u.get(g);if(s(g))return u.set(g)}if(m.length===2&&typeof g=="string"){if(!p)return u.remove(g);if(p&&typeof p=="string")return u.set(g,p);p&&r(p)&&(v=null,v=p(g,u.get(g)),h.set(g,v))}if(m.length===2&&o(g)&&r(p))for(var b=0,y=g.length;b<y;b++)v=p(g[b],u.get(g[b])),h.set(g[b],v);return h}for(var d in c.prototype)h[d]=c.prototype[d];return h})})(Nn)),Nn.exports}var Yv,Qv,e_,te,s_,i_,n_,r_,fu,F,ge,st,Ve,at,o_,ce,js,a_,Zo,Cc,So,l_,c_,u_,fe,d_,$e,Nt,wi,Ri,Ot,wt,ea,h_,gu,Un,f_,g_,Bn,ta,pu,vu,_u,po,Wn,ko,qe,Ao,Ls,fs,Si,Us,p_,vo,v_,__,m_,y_,An,Oc,Cn,Xt,_o,_s,On,Tn,S_,Kn,k_,A_,T_,mu,I_,j,R_,Pc,C_,O_,P_,$c,$_,x_,D_,xc,N_,yu,M_,rt,F_,bu,oe,Eu,Yn,sa,be,Dc,Ci,L_,wu,U_,Nc,B_,V_,Ai,j_,G_,H_,Mc,z_,Fc,q_,W_,Lc,To,Uc,K_,Y_,Su,Oi,ku,Bc,J_,X_,Z_,em,tm,sm,im,nm,rm,om,Vn,am,Ti,ke,Ii,Dt,jn,lm,Io,Gn,Hn,Ro,In,Vc,Ou,um,dm,hm,Co,Ft,Pt,Pi,fm,jc,gm,pm,vm,_m,mm,ym,bm,Em,Gc,wm,Sm,km,Am,Tm,Im,Rm,Hc,Cm,Om,Pu,Pm,$m,xm,Dm,Nm,Mm,Fm,Lm,zc,Um,Bm,Vm,jm,Gm,Hm,zm,qm,Wm,Km,Pn,Ym,Qm,Jm,Xm,Zm,ey,ty,sy,iy,ny,ry,oy,ay,ly,cy,uy,dy,hy,fy,gy,py,vy,_y,$u,Xn,xu,my,$i,xi,na,Du,Nu,Mu,gs,yy,Oo,$n,by,Ey,wy,Sy,ky,Ay,ue,xn,Ty,Iy,Ry,Cy,Oy,Py,$y,xy,Dy,Ny,My,Fy,Ly,Uy,By,Vy,jy,Gy,Hy,f,Fu,zy,qy,Uu,Qy,Jy,qc,Bu,Xy,Kc,Dn,Zy,e0,t0,s0,i0,n0,r0,o0,Yc,Qc,Po,Vu,a0,l0,c0,u0,d0,h0,f0,g0,p0,v0,_0,m0,y0,b0,E0,w0,S0,Jc,Zn,Rn,k0,A0,ju,Gu,T0,I0,R0,C0,$o,Hu,xo,O0,P0,$0,Xc,x0,zu,D0,N0,M0,L0,U0,Wu,B0,V0,mo,j0,Do,ze,ot,ht,St,Zt,G0,H0,z0,q0,W0,K0,Y0,Q0,J0,X0,Z0,eb,Bs,tb,Ku,Yu,sb,Qu,Ju,ps,Zc,eu,ib,nb,No,rb,$t,ob,ab,Xu,lb,cb,ub,db,Mo,zn,Nn,fb,tu,pb,hs,Zu,Vs,Fo,ra,Lo,oa,Uo,aa,pt,vb,_b,mb,yb,bb,Bo,Eb,Vo,wb,su,ed,Sb,kb,Ab,Tb,Mn,Ib,Rb,Gs,Cb,Ob,td,Pb,$b,xb,Hs,yo,bo,Db,Nb,Mb,iu,Fb,sd,Lb,Ub,Bb,Vb,jb,Gb,Hb,zb,qb,Wb,Kb,id,Yb,Qb,jo,Jb,nd,Xb,Zb,eE,rd,tE,sE,Go,iE,nE,rE,oE,nu,aE,lE,ru,cE,ou,Ho,uE,dE,hE,Eo,Fn,fE,gE,pE,la,od,ad,zo,ld,vE,qn,au,cd,lu,_E,mE,yE,bE,EE,ki,qo,wE,SE,kE,AE,wo,TE,IE,RE,CE,OE,Ei,Wo,Ko,Yo,PE,$E,xE,cu,uu,DE,NE,ME,FE,Ln,Qo,du,LE,UE,Jo,vs,zs,ca=Ze(()=>{"use strict";Yv=xt(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Qv=Number.isInteger||function(e){return e<<0===e};e_=(function(){function t(){this.map={},this.length=0}return t.prototype.set=function(e,s){var i=this.hash(e),n=this.map[i];n||(this.map[i]=n=[]),n.push([e,s]),this.length+=1},t.prototype.hash=function(e){var s=[];for(var i in e)s.push(Object.prototype.toString.call(e[i]));return s.join()},t.prototype.get=function(e){if(this.length<=180){for(var s in this.map)for(var o=this.map[s],i=0;i<o.length;i+=1){var n=o[i];if(n[0]===e)return n[1]}return}var r=this.hash(e),o=this.map[r];if(o)for(var i=0;i<o.length;i+=1){var n=o[i];if(n[0]===e)return n[1]}},t})(),te=xt(function(e){return e!=null&&typeof e.clone=="function"?e.clone():hu(e)});s_=Xo(function(e,s,i){var n={},r;s=s||{},i=i||{};for(r in s)kn(r,s)&&(n[r]=kn(r,i)?e(r,s[r],i[r]):s[r]);for(r in i)kn(r,i)&&!kn(r,n)&&(n[r]=i[r]);return n}),i_=Xo(function t(e,s,i){return s_(function(n,r,o){return Rc(r)&&Rc(o)?t(e,r,o):e(n,r,o)},s,i)}),n_=Xo(function(e,s,i){return i_(function(n,r,o){return e(r,o)},s,i)}),r_=Jt(t_),fu=Jt(function(e,s){var i={};for(var n in s)e(s[n],n,s)&&(i[n]=s[n]);return i}),F=t=>typeof t=="function"&&!!(t.constructor&&t.call&&t.apply),ge=t=>typeof t=="string",st=t=>t===null,Ve=t=>typeof t>"u",at=t=>st(t)||Ve(t),o_=t=>typeof t=="bigint",ce=t=>!Ve(t),js=t=>!at(t),a_=t=>js(t)&&t!=="",Zo=t=>{switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return t instanceof Error}},Cc=t=>typeof t=="boolean",So=(t,e)=>{let s=e.split(".");return r_(s,t)},l_=(t,e)=>!!So(t,e),c_=t=>typeof t=="object",u_=t=>!st(t)&&c_(t)&&!Array.isArray(t),fe=t=>!st(t)&&Object.prototype.toString.call(t)==="[object Object]",d_=(t,e)=>{if(!Array.isArray(t)||!Array.isArray(e))return te(e);let s=te(t);return e.forEach((i,n)=>{s[n]=Array.isArray(i)||u_(i)?$e(s[n],i):i}),s},$e=(t,e)=>n_(d_,t,e),Nt=t=>fe(t)&&Object.keys(t).length>0,wi=t=>{let e=fu(ce,t);return Object.keys(e).forEach(s=>{let i=e[s];fe(i)&&(e[s]=wi(i))}),e},Ri=t=>{let e=fu(js,t);return Object.keys(e).forEach(s=>{let i=e[s];fe(i)&&(e[s]=Ri(i))}),e},Ot=t=>{if(Nt(t))return Ri(t)},wt=(t,e)=>typeof t=="boolean"?t:e,ea=t=>(Object.getOwnPropertyNames(t).forEach(function(e){t[e]&&typeof t[e]=="object"&&ea(t[e])}),Object.freeze(t)),h_=t=>t.replace(/^\s+|\s+$/gm,""),gu=t=>t.replace(/^\.+/,""),Un=t=>{let e=t;if(!ge(t)&&!at(t))try{e=JSON.stringify(t)}catch{e=null}return e},f_=t=>{let e=Array.from(t,s=>String.fromCodePoint(s)).join("");return globalThis.btoa(e)},g_=t=>f_(new TextEncoder().encode(t)),Bn=(t,e,s,i,n)=>{let r={category:t,name:e,properties:s,options:i,callback:void 0};F(n)&&(r.callback=n),F(i)&&(r.category=t,r.name=e,r.properties=s,r.options=void 0,r.callback=i),F(s)&&(r.category=t,r.name=e,r.properties=void 0,r.options=void 0,r.callback=s),F(e)&&(r.category=t,r.name=void 0,r.properties=void 0,r.options=void 0,r.callback=e),F(t)&&(r.category=void 0,r.name=void 0,r.properties=void 0,r.options=void 0,r.callback=t),fe(t)?(r.name=void 0,r.category=void 0,r.properties=t,F(e)?r.options=void 0:r.options=e):fe(e)&&(r.name=void 0,r.properties=e,F(s)?r.options=void 0:r.options=s),ge(t)&&!ge(e)&&(r.category=void 0,r.name=t),ce(r.category)||(r.category=void 0),ce(r.name)||(r.name=void 0),r.properties=r.properties?te(r.properties):{},ce(r.options)?r.options=te(r.options):r.options=void 0;let o=ge(r.name)?r.name:r.properties.name,a=ge(r.category)?r.category:r.properties.category;return r.properties=$e(fe(r.properties)?r.properties:{},{...o&&{name:o},...a&&{category:a}}),r},ta=(t,e,s,i)=>{let n={name:t,properties:e,options:s,callback:void 0};return F(i)&&(n.callback=i),F(s)&&(n.properties=e,n.options=void 0,n.callback=s),F(e)&&(n.properties=void 0,n.options=void 0,n.callback=e),n.properties=js(n.properties)?te(n.properties):{},ce(n.options)?n.options=te(n.options):n.options=void 0,n},pu=(t,e,s,i)=>{let n={userId:t,traits:e,options:s,callback:void 0};return F(i)&&(n.callback=i),F(s)&&(n.userId=t,n.traits=e,n.options=void 0,n.callback=s),F(e)&&(n.userId=t,n.traits=void 0,n.options=void 0,n.callback=e),(fe(t)||st(t))&&(n.userId=null,n.traits=t,F(e)?n.options=void 0:n.options=e),n.userId=Un(n.userId),fe(n.traits)?n.traits=te(n.traits):n.traits=void 0,ce(n.options)?n.options=te(n.options):n.options=void 0,n},vu=(t,e,s,i)=>{let n={to:t,from:e,options:s,callback:void 0};return F(i)&&(n.callback=i),F(s)&&(n.to=t,n.from=e,n.options=void 0,n.callback=s),F(e)?(n.to=t,n.from=void 0,n.options=void 0,n.callback=e):(fe(e)||st(e))&&(n.to=t,n.from=void 0,n.options=e),ce(n.to)&&(n.to=Un(n.to)),ce(n.from)?n.from=Un(n.from):n.from=void 0,ce(n.options)?n.options=te(n.options):n.options=void 0,n},_u=(t,e,s,i)=>{let n={groupId:t,traits:e,options:s,callback:void 0};return F(i)&&(n.callback=i),F(s)&&(n.groupId=t,n.traits=e,n.options=void 0,n.callback=s),F(e)&&(n.groupId=t,n.traits=void 0,n.options=void 0,n.callback=e),(fe(t)||st(t))&&(n.groupId=null,n.traits=t,F(e)?n.options=void 0:n.options=e),n.groupId=Un(n.groupId),fe(n.traits)?n.traits=te(n.traits):n.traits=void 0,ce(n.options)?n.options=te(n.options):n.options=void 0,n},po=(function(t){return t.UNLOADED="Page Unloaded",t})({}),Wn="API",ko="CapabilitiesManager",qe="ConfigManager",Ao="EventManager",Ls="PluginsManager",fs="UserSessionManager",Si="ErrorHandler",Us="PluginEngine",p_="StoreManager",vo=`Ready${Wn}`,v_=`Load${Wn}`,__=`Consent${Wn}`,m_="HttpClient",y_="RudderStackAnalytics",An="AnalyticsCore";Oc=4096,Cn=[],Xt=0;for(;Xt<256;Xt++)Cn[Xt]=(Xt+256).toString(16).substring(1);_s=256,On=[];for(;_s--;)On[_s]=(_s+256).toString(16).substring(1);S_=()=>!at(globalThis.crypto)&&F(globalThis.crypto.getRandomValues),Kn=()=>S_()?E_():w_(),k_=()=>!!window.chrome?.runtime?.id,A_=()=>ge(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),T_=(t,e=!1)=>{let s=!1,i=!1;function n(){s||(s=!0,t(i),setTimeout(()=>{s=!1},0))}(e||A_())&&globalThis.addEventListener("beforeunload",()=>{i=!1,n()}),globalThis.addEventListener("blur",()=>{i=!0,n()}),globalThis.addEventListener("focus",()=>{s=!1}),document.addEventListener("pagehide",()=>{i=document.visibilityState==="hidden",n()}),document.addEventListener("visibilitychange",()=>{i=!0,document.visibilityState==="hidden"?n():s=!1})},mu=t=>t.toISOString(),I_=()=>mu(new Date),j=":: ",R_=t=>`A script with the id "${t}" is already loaded. Skipping the loading of this script to prevent conflicts`,Pc=(t,e,s)=>`Unable to load (${ge(s)?s:s.type}) the script with the id "${t}" from URL "${e}"`,C_=(t,e,s)=>`A timeout of ${s} ms occurred while trying to load the script with id "${t}" from URL "${e}"`,O_=(t,e)=>`${t}${j}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,P_="Failed to convert the value to a JSON string.",$c=(t,e)=>`${t}${j}A bad data (like circular reference, BigInt) has been detected in the object and the property "${e}" has been dropped from the output.`,$_="Failed to encode the cookie data.",x_=(t,e)=>`${t}${j}The "${e}" storage type is `,D_="JSONStringify",xc="JSON",N_="[BigInt]",yu="[Circular Reference]",M_=(t,e,s)=>{let i=[];return function(n,r){if(!e?.includes(n)&&!(t&&at(r))){if(typeof r!="object"||st(r))return r;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(r)?(s?.warn(O_(D_,n)),yu):(i.push(r),r)}}},rt=(t,e,s,i)=>{try{return JSON.stringify(t,M_(e,s,i))}catch(n){return i?.warn(P_,n),null}},F_=t=>{let e=[];return function(i,n){if(o_(n))return t?.warn($c(xc,i)),N_;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(n)?(t?.warn($c(xc,i)),yu):(e.push(n),n)}},bu=(t,e)=>{let s=Array.isArray(t)?[]:{};for(let i in t)if(Object.hasOwnProperty.call(t,i)){let n=t[i],r=e.call(t,i,n);fe(r)||Array.isArray(r)?s[i]=bu(r,e):s[i]=r}return s},oe=(t,e)=>{let s=F_(e),i=s.call(t,"",t);return fe(t)||Array.isArray(t)?bu(t,s):i},Eu="[SDK DISPATCHED ERROR]",Yn=t=>{let{stack:e}=t;if(typeof e=="string"&&e)return e},sa=(t,e)=>{if(!Zo(t))return new Error(`${e}: ${rt(t)}`);try{let s=t.constructor,i=new s(`${e}: ${t.message}`),n=Yn(t);return n&&(i.stack=n),Object.getOwnPropertyNames(t).forEach(r=>{if(r!=="message"&&r!=="stack"&&r!=="name")try{i[r]=t[r]}catch{}}),i}catch{return new Error(`${e}: ${rt(t)}`)}},be=t=>{if(Zo(t)){let e=Yn(t);e&&(t.stack=`${e}
4
+ ${Eu}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:t,bubbles:!0,cancelable:!0,composed:!0}))},Dc="RudderLabs JavaScript SDK",Ci="3.34.3",L_="com.rudderlabs.javascript",wu="npm",U_="modern",Nc="RudderJS-Initiated",B_="ad-block page request",V_="/ad-blocked",Ai="preloadedEventsBuffer",j_="Consent Management Interaction",G_="ajs_trait_",H_="ajs_prop_",Mc="ajs_aid",z_="ajs_uid",Fc="ajs_event",q_=10*1e3,W_=31536e3*1e3,Lc=720*60*1e3,To=1800*1e3,Uc=10*1e3,K_=10*1e3,Y_=250,Su=(t="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[t]||(globalThis.RudderStackGlobals[t]={})},Oi=(t,e,s="app")=>{Su(s),globalThis.RudderStackGlobals[s][t]=e},ku=(t,e="app")=>(Su(e),globalThis.RudderStackGlobals[e][t]);Bc=(t,e)=>{let s={};return t.forEach((i,n)=>{if(n.startsWith(e)){let r=n.substring(e.length);s[r]=t.get(n)}}),s},J_=(t=[])=>{let e={trait:G_,properties:H_},s=new URLSearchParams(globalThis.location.search);s.get(Fc)&&t.unshift(["track",s.get(Fc),Bc(s,e.properties)]);let i=s.get(z_),n=Bc(s,e.trait);if(i||Nt(n)){let r=[...i?[i]:[],n];t.unshift(["identify",...r])}s.get(Mc)&&t.unshift(["setAnonymousId",s.get(Mc)])},X_=t=>{let e="load",s=[],i=0;for(;i<t.length;){if(t[i]&&t[i][0]===e){s=te(t[i]),t.splice(i,1);break}i+=1}return s},Z_=t=>{let e="consent",s=t.filter(n=>n[0]===e),i=t.filter(n=>n[0]!==e);t.splice(0,t.length,...s,...i)},em=t=>{let e=ku(Ai)||[];J_(e),e.length>0&&(t.enqueuePreloadBufferEvents(e),Oi(Ai,[]))},tm=(t,e)=>{let s=t.shift(),i;if(F(e[s])){switch(s){case"page":i=Bn(...t);break;case"track":i=ta(...t);break;case"identify":i=pu(...t);break;case"alias":i=vu(...t);break;case"group":i=_u(...t);break;default:e[s](...t);break}i&&e[s](i)}},sm=10*1e3,im="RS_JS_SDK",nm=(t,e,s=!0,i=null,n=null,r={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=i,o.onerror=n,o.src=t,o.id=e,o.async=s,Object.keys(r).forEach(a=>{o.setAttribute(a,r[a])}),o.setAttribute("data-loader",im),o},rm=t=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(t,e[0]?.firstChild);return}let s=document.getElementsByTagName("script");if(s.length>0&&s[0]?.parentNode){s[0]?.parentNode.insertBefore(t,s[0]);return}let i=document.createElement("head");i.appendChild(t);let n=document.getElementsByTagName("html")[0];n?.insertBefore(i,n.firstChild)},om=(t,e,s,i=!0,n)=>new Promise((r,o)=>{document.getElementById(e)&&o(new Error(R_(e)));try{let l;rm(nm(t,e,i,()=>{globalThis.clearTimeout(l),r(e)},h=>{globalThis.clearTimeout(l),o(new Error(Pc(e,t,h)))},n)),l=globalThis.setTimeout(()=>{o(new Error(C_(e,t,s)))},s)}catch(l){o(sa(l,Pc(e,t,"unknown")))}}),Vn=class{constructor(e,s=sm){this.logger=e,this.timeout=s}loadJSFile(e){let{url:s,id:i,timeout:n,async:r,callback:o,extraAttributes:a}=e,l=!F(o);om(s,i,n||this.timeout,r,a).then(c=>{l||o(c)}).catch(c=>{l||o(i,c)})}},am=Symbol.for("preact-signals");ke=void 0;Ii=void 0,Dt=0,jn=0,lm=0,Io=0,Gn=void 0,Hn=0;We.prototype.brand=am;We.prototype.h=function(){return!0};We.prototype.S=function(t){var e=this,s=this.t;s!==t&&t.e===void 0&&(t.x=s,this.t=t,s!==void 0?s.e=t:Jn(function(){var i;(i=e.W)==null||i.call(e)}))};We.prototype.U=function(t){var e=this;if(this.t!==void 0){var s=t.e,i=t.x;s!==void 0&&(s.x=i,t.e=void 0),i!==void 0&&(i.e=s,t.x=void 0),t===this.t&&(this.t=i,i===void 0&&Jn(function(){var n;(n=e.Z)==null||n.call(e)}))}};We.prototype.subscribe=function(t){var e=this;return Mt(function(){var s=e.value;Jn(function(){return t(s)})},{name:"sub"})};We.prototype.valueOf=function(){return this.value};We.prototype.toString=function(){return this.value+""};We.prototype.toJSON=function(){return this.value};We.prototype.peek=function(){var t=this;return Jn(function(){return t.value})};Object.defineProperty(We.prototype,"value",{get:function(){var t=Au(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(jn>100)throw new Error("Cycle detected");(function(s){Dt!==0&&jn===0&&s.l!==Io&&(s.l=Io,Gn={S:s,v:s.v,i:s.i,o:Gn})})(this),this.v=t,this.i++,Hn++,Dt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Qn()}}}});qs.prototype=new We;qs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Hn))return!0;if(this.g=Hn,this.f|=1,this.i>0&&!Tu(this))return this.f&=-2,!0;var t=ke;try{Iu(this),ke=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return ke=t,Ru(this),this.f&=-2,!0};qs.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}We.prototype.S.call(this,t)};qs.prototype.U=function(t){if(this.t!==void 0&&(We.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};qs.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(qs.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Au(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});Ws.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};Ws.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Cu(this),Iu(this),Dt++;var t=ke;return ke=this,cm.bind(this,t)};Ws.prototype.N=function(){2&this.f||(this.f|=2,this.u=Ii,Ii=this)};Ws.prototype.d=function(){this.f|=8,1&this.f||ia(this)};Ws.prototype.dispose=function(){this.d()};Ro=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=[]}},In={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Vc="LOG",Ou="ERROR",um="RS SDK",dm="font-weight: bold; background: black; color: white;",hm="font-weight: normal;",Co=class{constructor(e=Vc,s="",i=console){this.minLogLevel=In[e],this.scope=s,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,s){this.minLogLevel<=In[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(s))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=In[e],Ve(this.minLogLevel)&&(this.minLogLevel=In[Vc])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let s=`%c ${um}`;this.scope&&(s=`${s} - ${this.scope}`);let i=ge(e[0])?e[0].trim():"";s=`${s} %c ${i}`;let n=[s,dm,hm];return ge(e[0])||n.push(e[0]),n.push(...e.slice(1)),n}return e}},Ft=new Co,Pt=(function(t){return t.HANDLEDEXCEPTION="handledException",t.UNHANDLEDEXCEPTION="unhandledException",t.UNHANDLEDREJECTION="unhandledPromiseRejection",t})({}),Pi=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],fm="cookieStorage",jc="Unable to process/parse source configuration response",gm="The source is disabled. Please enable the source in the dashboard to send events.",pm="Failed to prepare data for the request.",vm="Failed to invoke plugin because the extension point name is missing.",_m="Failed to invoke plugin because the extension point name is invalid.",mm=t=>`${t}${j}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,ym=(t,e,s)=>`${t}${j}The base URL "${s}" for ${e} is not valid.`,bm=(t,e,s)=>`${t}${j}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(s)}".`,Em=(t,e)=>`${t}${j}Ignoring a non-error: ${e}.`,Gc="Failed to log breadcrumb",wm=t=>`${t}${j}Failed to handle the error.`,Sm=t=>`${t}${j}Plugin name is missing.`,km=(t,e)=>`${t}${j}Plugin "${e}" already exists.`,Am=(t,e)=>`${t}${j}Plugin "${e}" not found.`,Tm=(t,e)=>`${t}${j}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.`,Im=(t,e,s)=>`${t}${j}Plugin "${e}" could not be loaded because some of its dependencies "${s}" do not exist.`,Rm=(t,e,s)=>`${t}${j}Failed to invoke the "${e}" extension point of plugin "${s}".`,Hc="Failed to fetch the source config",Cm=(t,e)=>`${t}${j}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,Om=(t,e)=>`${t}${j}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.`,Pu=t=>`${t}${j}The provided callback parameter is not a function.`,Pm=(t,e,s,i,n)=>`${t} with status ${e} (${s}) for URL: ${i}. Response: ${n.trim()}`,$m=(t,e,s)=>`${t} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${s}`,xm=(t,e)=>`${t} for URL: ${e}`,Dm=t=>`Failed to save the value for "${t}" to storage`,Nm=t=>`Failed to retrieve or parse data for "${t}" from storage`,Mm=(t,e)=>`${t}${j}The server side cookies functionality is disabled as the provided data server URL, "${e}" is invalid.`,Fm=t=>`The server responded with status ${t} while setting the cookies. As a fallback, the cookies will be set client side.`,Lm=t=>`The server failed to set the ${t} cookie. As a fallback, the cookies will be set client side.`,zc="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",Um=(t,e)=>`The server did not set ${t.length} of the ${e} cookies sent in one request: ${t.join(", ")}. A fallback to set them client side was attempted. Check that the data service and any proxy preserve every "Set-Cookie" header, and that the cookie domain and SameSite/Secure attributes are valid.`,Bm=(t,e)=>`${t}${j}The storage type "${e}" is not supported. Please choose one of the following supported types: "${Pi}". The default storage type will be used instead.`,Vm=(t,e,s)=>`${t}${j}The storage type "${s}" configured for the entry "${e}" is not supported. Please choose one of the following supported types: "${Pi}". The default storage type will be used instead.`,jm=(t,e,s,i)=>`${t}${j}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(s)}". The default version "${i}" will be used instead.`,Gm=(t,e,s)=>`${t}${j}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${s}). To enable storage data migration, please update the storage encryption version to the latest version.`,Hm=(t,e,s)=>`${t}${j}The provided cookie domain (${e}) does not match the current webpage's domain (${s}). Hence, the cookies will be set client-side.`,zm=(t,e,s)=>`${t}${j}The data service host (${e}) cannot set cookies for the current webpage (${s}). Hence, the cookies will be set client-side instead of server-side.`,qm=(t,e,s,i)=>`${t}${j}The "${e}" property defined under "${s}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i}).`,Wm=(t,e)=>`${t}${j}The top-level custom context property "${e}" is reserved and was ignored.`,Km=t=>`${t}${j}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,Pn=t=>`${t}${j}Invalid custom context. Use a plain object without prototype pollution keys.`,Ym=t=>`${t}${j}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,Qm=(t,e,s)=>`${t}${j}The session timeout value "${e}" is not a number. The default timeout of ${s} ms will be used instead.`,Jm=(t,e,s)=>`${t}${j}The session cut off duration value "${e}" is not a number. The default cut off duration of ${s} ms will be used instead.`,Xm=(t,e,s)=>`${t}${j}The session cut off duration value "${e}" ms is less than the session timeout value "${s}" ms. The cut off functionality will be disabled.`,Zm=t=>`${t}${j}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.`,ey=(t,e,s)=>`${t}${j}The session timeout value ${e} ms is less than the recommended minimum of ${s} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,ty=(t,e,s)=>`${t}${j}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${s}" digits long. A new session ID will be auto-generated instead.`,sy=t=>`${t}${j}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,iy=(t,e,s,i)=>`${t}${j}The storage type "${s}" is not available for entry "${e}". The SDK will initialize the entry with "${i}" storage type instead.`,ny=t=>`${t}${j}The callback threw an exception`,ry=(t,e)=>`${t}${j}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,oy=(t,e)=>`Failed to load the polyfill script with ID "${t}" from URL ${e}.`,ay=(t,e,s)=>`${t}${j}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${s}" will be used instead.`,ly=t=>`${t}${j}The pre-consent storage strategy option is deprecated. Please enable "storage" in the pre-consent options and use the "storage" load API option instead.`,cy=(t,e,s)=>`${t}${j}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${s}" will be used instead.`,uy=(t,e)=>`${t}${j}${e} plugin is deprecated. Please exclude it from the load API options.`,dy=(t,e,s,i)=>{let n=s.length===1,r=n?` '${s[0]}' plugin was`:` ['${s.join("', '")}'] plugins were`,o=`${t}${j}${e}, but${r} not configured to load.`;return i?`${o} So, ${n?"the plugin":"those plugins"} will be loaded automatically.`:`${o} Ignore if this was intentional. Otherwise, consider adding ${n?"it":"them"} to the 'plugins' load API option.`},hy=(t,e)=>`${t}${j}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,fy=t=>`${t}${j}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,gy=(t,e)=>`${t}${j}Ignoring unknown plugins: ${e.join(", ")}.`,py=(t,e,s)=>`${t}${j}Failed to load plugin "${e}" - ${s}`,vy=(t,e)=>`${t}${j}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.`,_y=(t,e)=>`${t}${j}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,$u={All:!0},Xn="js-integrations",xu="plugins",my=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_]*)?$"),$i="modern",xi="https://cdn.rudderlabs.com",na="v3",Du=`${xi}/${na}/${$i}/${Xn}`,Nu=`${xi}/${na}/${$i}/${xu}`,Mu="https://api.rudderstack.com",gs="v3",yy="xhr",Oo={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},$n={[gs]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},by={[yy]:"XhrQueue",beacon:"BeaconQueue"},Ey="rsaRequest",wy="rsaMetrics",Sy="Custom Device Mode",ky={configUrl:Mu,loadIntegration:!0,sessions:{autoTrack:!0,timeout:To,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:$u,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:K_,storage:{encryption:{version:gs},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},Ay=C(te(ky)),ue=ea({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),xn=ea({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Ty=10,Iy={userId:C(ue.userId),userTraits:C(ue.userTraits),anonymousId:C(ue.anonymousId),groupId:C(ue.groupId),groupTraits:C(ue.groupTraits),initialReferrer:C(ue.initialReferrer),initialReferringDomain:C(ue.initialReferringDomain),sessionInfo:C(ue.sessionInfo),authToken:C(ue.authToken)},Ry={isOnline:C(!0),storage:{isLocalStorageAvailable:C(!1),isCookieStorageAvailable:C(!1),isSessionStorageAvailable:C(!1)},isBeaconAvailable:C(!1),isLegacyDOM:C(!1),isUaCHAvailable:C(!1),isCryptoAvailable:C(!1),isAdBlockerDetectionInProgress:C(!1),isAdBlocked:C(void 0),cspViolations:C([]),sdkCdnProbe:C({})},Cy={isErrorReportingEnabled:C(!1),isMetricsReportingEnabled:C(!1),breadcrumbs:C([])},Oy=C(void 0),Py={activeDataplaneUrl:C(void 0),integrationsCDNPath:C(Du),pluginsCDNPath:C(Nu),sourceConfigUrl:C(void 0),status:C(void 0),initialized:C(!1),logLevel:C(Ou),loaded:C(!1),readyCallbacks:C([]),writeKey:C(void 0),dataPlaneUrl:C(void 0),safeAnalyticsInstance:C(void 0)},$y={enabled:C(!1),initialized:C(!1),data:C({}),activeConsentManagerPluginName:C(void 0),preConsent:C({enabled:!1}),postConsent:C({}),resolutionStrategy:C("and"),provider:C(void 0),metadata:C(void 0)},xy={retries:C(0),dropped:C(0),sent:C(0),queued:C(0),triggered:C(0),metricsServiceUrl:C(void 0)},Dy=()=>U_,Ny={app:C({name:Dc,namespace:L_,version:Ci,installType:wu}),traits:C(null),library:C({name:Dc,version:Ci,snippetVersion:globalThis.RudderSnippetVersion,variant:Dy()}),userAgent:C(null),device:C(null),network:C(null),os:C({name:"",version:""}),locale:C(null),screen:C({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":C(void 0),timezone:C(void 0)},My=C({}),Fy={configuredDestinations:C([]),activeDestinations:C([]),loadOnlyIntegrations:C({}),failedDestinations:C([]),loadIntegration:C(!0),initializedDestinations:C([]),clientDestinationsReady:C(!1),integrationsConfig:C({})},Ly={toBeProcessedArray:C([]),readyCallbacksArray:C([])},Uy={ready:C(!1),loadedPlugins:C([]),failedPlugins:C([]),pluginsToLoadFromConfig:C([]),activePlugins:C([]),totalPluginsToLoad:C(0)},By={encryptionPluginName:C(void 0),migrate:C(!1),cookie:C(void 0),entries:C({}),trulyAnonymousTracking:C(!1)},Vy={isEnabledServerSideCookies:C(!1),dataServiceUrl:C(void 0),isCollapsedBatchErrorLogged:C(!1)},jy={eventsQueuePluginName:C(void 0),deliveryEnabled:C(!0)},Gy={enabled:C(!1),pageLifecycle:{enabled:C(!1),pageViewId:C(void 0),pageLoadedTimestamp:C(void 0)}},Hy={capabilities:Ry,consents:$y,context:Ny,customContext:My,eventBuffer:Ly,lifecycle:Py,loadOptions:Ay,metrics:xy,nativeDestinations:Fy,plugins:Uy,reporting:Cy,session:Iy,source:Oy,storage:By,serverCookies:Vy,dataPlaneEvents:jy,autoTrack:Gy},f={...te(Hy)},Fu=/^\s*at /,zy=/^(eval@)?(\[native code])?$/,qy=/(.+?)(?::(\d+))?(?::(\d+))?$/;Uu="global code",Qy=t=>ce(t)&&/^global code$/i.test(t)?Uu:t,Jy=t=>{let e={file:t.fileName,method:Qy(t.functionName),lineNumber:t.lineNumber,columnNumber:t.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Uu),e},qc=t=>ge(t)?t:"";Bu=(t,e)=>{let s;return Zo(t)&&ge(Yn(t))?s=t:(e.warn(Em(Si,rt(t))),s=void 0),s},Xy=(t,e)=>{try{let s=Yy(t);return Wc(t.name,t.message,e,s)}catch{return Wc(t.name,t.message,e,[])}},Kc=(t,e)=>{try{return JSON.parse(t||"")}catch(s){let i=sa(s,"Failed to parse response data");e(i)}},Dn="The request failed",Zy=[/Failed to fetch dynamically imported module: .*/,/error loading dynamically imported module: .*/],e0=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],t0=[new RegExp(`${Dn}.*`),/A script with the id .* is already loaded\./],s0=[...Zy,...e0],i0="integrations",n0="sdk",r0=n0,o0={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Yc=(t,e,s)=>{let i=$e(o0,e||{});return s&&(i.headers=$e(i.headers,{Authorization:s})),i.url=t,i},Qc=(t,e=q_,s)=>new Promise((i,n)=>{let r;if(t.sendRawData===!0)r=t.data;else if(r=rt(t.data,!1,[],s),st(r)){n({error:new Error(pm),undefined:void 0,options:t});return}let o=new XMLHttpRequest,a=c=>{n({error:new Error(Pm(Dn,o.status,o.statusText,t.url,o.responseText)),xhr:o,options:t})},l=c=>{n({error:new Error($m(Dn,c,t.url)),xhr:o,options:t,...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:t}):a()},o.open(t.method,t.url,!0),t.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(t.headers).forEach(c=>{t.headers[c]&&o.setRequestHeader(c,t.headers[c])});try{o.send(r)}catch(c){n({error:sa(c,xm(Dn,t.url)),xhr:o,options:t})}}),Po=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:s,options:i,timeout:n,isRawResponse:r,skipAuthHeader:o}=e;try{let a=await Qc(Yc(s,i,this.getAuthHeader(o)),n,this.logger);return{data:r?a.response:Kc(a.response,this.onError),details:a}}catch(a){return{data:void 0,details:a}}}getAsyncData(e){let{callback:s,url:i,options:n,timeout:r,isRawResponse:o,skipAuthHeader:a}=e,l=!F(s);Qc(Yc(i,n,this.getAuthHeader(a)),r,this.logger).then(c=>{l||s(o?c.response:Kc(c.response,this.onError),c)},c=>{l||s(void 0,c)}).catch(this.onError)}onError(e,s){this.errorHandler?.onError({error:e,context:m_,groupingHash:s})}getAuthHeader(e){return e===!0?void 0:this.basicAuthHeader}setAuthHeader(e,s=!1){let i=s?e:g_(`${e}:`);this.basicAuthHeader=`Basic ${i}`}resetAuthHeader(){this.basicAuthHeader=void 0}},Vu=new Po(Ft),a0="1",l0=()=>["rsa"],c0=["www.test-host.com","localhost","127.0.0.1","[::1]"],u0=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","customContext","traits","authToken"],d0="RudderStack JavaScript SDK",h0="git+https://github.com/rudderlabs/rudder-sdk-js.git",f0="js",g0=(t,e)=>{switch(e){case Pt.UNHANDLEDEXCEPTION:{let{error:s}=t;return s||t}case Pt.UNHANDLEDREJECTION:return t.reason;case Pt.HANDLEDEXCEPTION:default:return t}},p0=t=>({type:"manual",name:t,timestamp:new Date,metaData:{}}),v0=(t=()=>window.location.hostname)=>{let e=t();return!e||e&&c0.includes(e)?"development":"production"},_0=t=>{let e=rt(t,!1,u0);return e!==null?JSON.parse(e):{}},m0=()=>globalThis.location.href.split("?")[0],y0=(t,e,s,i)=>({id:`${t.value?.id??s.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${i.pageLifecycle.pageViewId.value??"NA"}`,name:t.value?.name??"NA"}),b0=(t,e)=>({locale:t.value??"NA",userAgent:e.value??"NA",time:new Date}),E0=(t,e,s,i)=>{let{context:n,lifecycle:r,session:o,source:a,reporting:l,autoTrack:c}=s,{app:u,locale:h,userAgent:d,timezone:g,screen:p,library:m}=n;return{payloadVersion:"5",notifier:{name:d0,version:u.value.version,url:h0},events:[{exceptions:[te(t)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:u.value.version,releaseStage:v0(),type:u.value.installType},device:b0(h,d),request:{url:m0(),clientIp:"[NOT COLLECTED]"},breadcrumbs:te(l.breadcrumbs.value),context:t.message,groupingHash:i,metaData:{app:{snippetVersion:m.value.snippetVersion},device:{...p.value,timezone:g.value},..._0(s)},user:y0(a,o,r,c)}]}},w0=["script-src-elem","script-src","default-src"],S0=["connect-src","default-src"],Jc=(t,e,s)=>t.capabilities.cspViolations.value.some(i=>s.includes(i.directive)&&Zn(e,i.blockedURL)),Zn=(t,e)=>{if(t===e)return!0;if(!t.startsWith(e))return!1;let s=t.charAt(e.length);return s==="/"||s==="?"||s==="#"},Rn=new Map,k0=(t,e,s,i)=>{if(ce(t.capabilities.sdkCdnProbe.value[s])){i();return}let n=Rn.get(s);if(n){n.push(i);return}Rn.set(s,[i]),e.getAsyncData({url:s,skipAuthHeader:!0,options:{method:"HEAD",headers:{"Content-Type":void 0,Accept:void 0}},isRawResponse:!0,callback:(r,o)=>{let a=o?.xhr?.status??0,l=o?.xhr?.responseURL;t.capabilities.sdkCdnProbe.value={...t.capabilities.sdkCdnProbe.value,[s]:{status:a,timedOut:o?.timedOut===!0,redirectedOffCdn:a!==0&&ge(l)&&l!==s&&!Zn(l,xi)}};let c=Rn.get(s)??[];Rn.delete(s),c.forEach(u=>u())}})},A0=(t,e,s)=>{let i=t.message;return new Promise(n=>{if(s0.some(r=>r.test(i))){let r=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(i)?.[0];ge(r)?Zn(r,xi)?k0(e,s,r,()=>{let o=Jc(e,r,w0),a=e.capabilities.sdkCdnProbe.value[r],l=Jc(e,r,S0),c=a!==void 0&&!a.timedOut&&!l&&(a.status===0||a.redirectedOffCdn);n(!o&&!c)}):n(!1):n(!0)}else n(!t0.some(r=>r.test(i)))})},ju=t=>t?t.split("/").at(-2):void 0,Gu=t=>{let e=t.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},T0=t=>{let e=Gu(t);if(!e)return!1;let s=e.substring(e.lastIndexOf("/")+1);return ju(e)===Xn||l0().some(n=>s.startsWith(n)&&s.endsWith(".js"))},I0=(t,e)=>{if(e)return e;let s=Gu(t);return ju(s)===Xn?i0:r0},R0=(t,e,s)=>{let i={version:a0,message_id:Kn(),source:{name:f0,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:s},errors:t};return rt(i)},C0=(t,e,s)=>{let i;if(!ce(t))i=e;else if(ge(t))i=t;else{let n=Bu(t,s);ce(n)?i=n.message:i=e}return i},$o=class{constructor(e,s){Se(this,"initialized",!1);this.httpClient=e,this.logger=s}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Si,errorType:Pt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Si,errorType:Pt.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let s=ge(e.blockedURI)?e.blockedURI:"",i=ge(e.effectiveDirective)?e.effectiveDirective:"";if(e.disposition!=="enforce"||!Zn(s,xi))return;f.capabilities.cspViolations.value.some(r=>r.blockedURL===s&&r.directive===i)||(f.capabilities.cspViolations.value=[...f.capabilities.cspViolations.value,{blockedURL:s,directive:i}])})}async onError(e){try{let{error:s,context:i,customMessage:n,groupingHash:r,category:o}=e,a=e.errorType??Pt.HANDLEDEXCEPTION,l=g0(s,a),c=Bu(l,this.logger);if(Ve(c))return;let u=n?`${n} - `:"",h=`${i}${j}${u}`,d=Xy(c,h),p=Yn(c).includes(Eu);if(!p&&!T0(d)&&a!==Pt.HANDLEDEXCEPTION)return;if(f.reporting.isErrorReportingEnabled.value&&await A0(d,f,this.httpClient)){let v={severity:"error",unhandled:a!==Pt.HANDLEDEXCEPTION,severityReason:{type:a}},b=C0(r,d.message,this.logger),y=E0(d,v,f,b),w=I0(d,o);this.httpClient.getAsyncData({url:f.metrics.metricsServiceUrl.value,options:{method:"POST",data:R0(y,f,w),sendRawData:!0},isRawResponse:!0})}(a===Pt.HANDLEDEXCEPTION||p)&&this.logger.error(d.message)}catch(s){this.logger.error(wm(Si),s)}}leaveBreadcrumb(e){try{f.reporting.breadcrumbs.value=[...f.reporting.breadcrumbs.value,p0(e)]}catch(s){this.onError({error:s,context:Si,customMessage:Gc,groupingHash:Gc})}}},Hu=new $o(Vu,Ft),xo=class{constructor(e,s={}){Se(this,"plugins",[]);Se(this,"byName",{});Se(this,"cache",{});Se(this,"config",{throws:!0});this.config={throws:!0,...s},this.logger=e}register(e,s){if(!e.name){let n=Sm(Us);if(this.config.throws)throw new Error(n);this.logger.error(n,e);return}if(this.byName[e.name]){let n=km(Us,e.name);if(this.config.throws)throw new Error(n);this.logger.error(n);return}this.cache={},this.plugins=this.plugins.slice();let i=this.plugins.length;this.plugins.forEach((n,r)=>{n.deps?.includes(e.name)&&(i=Math.min(i,r))}),this.plugins.splice(i,0,e),this.byName[e.name]=e,F(e.initialize)&&e.initialize(s)}unregister(e){let s=this.byName[e];if(!s){let n=Am(Us,e);if(this.config.throws)throw new Error(n);this.logger.error(n);return}let i=this.plugins.indexOf(s);if(i===-1){let n=Tm(Us,e);if(this.config.throws)throw new Error(n);this.logger.error(n);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 s=e??".";return this.cache[s]||(this.cache[s]=this.plugins.filter(i=>{if(i.deps?.some(n=>!this.byName[n])){let n=i.deps.filter(r=>!this.byName[r]);return this.logger.error(Im(Us,i.name,n)),!1}return s==="."?!0:l_(i,s)})),this.cache[s]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,s=!0,...i){let n=e;if(!n)throw new Error(vm);let r=n.startsWith("!"),o=this.config.throws??n.endsWith("!");if(n=n.replace(/(^!|!$)/g,""),!n)throw new Error(_m);let a=n.split(".");a.pop();let l=a.join(".");return(s?this.getPlugins(n):[this.getPlugins(n)[0]]).map(u=>{let h=So(u,n);if(!F(h)||r)return h;try{return h.apply(So(u,l),i)}catch(d){if(o)throw d;this.logger.error(Rm(Us,n,u.name),d)}return null})}invokeSingle(e,...s){return this.invoke(e,!1,...s)[0]}invokeMultiple(e,...s){return this.invoke(e,!0,...s)}},O0=new xo(Ft,{throws:!0}),P0=t=>t.config.connectionMode!=="cloud"||t.config.useNativeSDKToSend===!0||t.config.useNativeSDK===!0,$0=t=>t.config.connectionMode==="hybrid"||t.config.useNativeSDKToSend===!0,Xc=t=>t.filter(P0),x0=(t,e)=>`${t.replaceAll(" ","-")}___${e}`,zu=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],D0=["Bugsnag","ErrorReporting"],N0={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//rsa-plugins.js"),format:"esm",from:"vite"}};M0=t=>qu({},(globalThis.__federation_shared__||{}).default||{});L0=t=>{switch(t){case"BeaconQueue":return()=>tt("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>et(e,!0));case"CustomConsentManager":return()=>tt("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>et(e,!0));case"DeviceModeDestinations":return()=>tt("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>et(e,!0));case"DeviceModeTransformation":return()=>tt("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>et(e,!0));case"ExternalAnonymousId":return()=>tt("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>et(e,!0));case"GoogleLinker":return()=>tt("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>et(e,!0));case"KetchConsentManager":return()=>tt("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>et(e,!0));case"IubendaConsentManager":return()=>tt("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>et(e,!0));case"NativeDestinationQueue":return()=>tt("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>et(e,!0));case"OneTrustConsentManager":return()=>tt("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>et(e,!0));case"StorageEncryption":return()=>tt("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>et(e,!0));case"StorageEncryptionLegacy":return()=>tt("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>et(e,!0));case"StorageMigrator":return()=>tt("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>et(e,!0));case"XhrQueue":return()=>tt("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>et(e,!0));default:return}},U0=t=>{let e={};return t.forEach(s=>{if(zu.includes(s)){let i=L0(s);i&&(e[s]=i)}}),e},Wu=()=>({}),B0=()=>({}),V0=t=>U0?.(t)||{},mo={...Wu(),...B0()},j0=t=>({...V0(t)}),Do=class{constructor(e,s,i){this.engine=e,this.errorHandler=s,this.logger=i,this.onError=this.onError.bind(this)}init(){f.lifecycle.status.value="pluginsLoading",Oi("pluginsCDNPath",f.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){Mt(()=>{(f.plugins.activePlugins.value.length===0||f.plugins.loadedPlugins.value.length+f.plugins.failedPlugins.value.length===f.plugins.totalPluginsToLoad.value)&&Fe(()=>{f.plugins.ready.value=!0,f.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=f.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(n=>D0.includes(n)?(this.logger.warn(uy(Ls,n)),!1):!0);let s=[{configurationStatus:()=>ce(f.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:f.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(by),shouldAddMissingPlugins:!0},{configurationStatus:()=>Xc(f.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Xc(f.nativeDestinations.configuredDestinations.value).some(n=>n.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>ce(f.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:f.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Oo)},{configurationStatus:()=>ce(f.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:f.storage.encryptionPluginName.value,supportedPlugins:Object.values($n)},{configurationStatus:()=>f.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],i=!1;return s.forEach(n=>{n.configurationStatus()?(e=e.filter(n.activePluginName?r=>!(r!==n.activePluginName&&n.supportedPlugins.includes(r)):r=>ce(r)),this.addMissingPlugins(n,i,e)):e=e.filter(n.basePlugins!==void 0?r=>!(n.basePlugins.includes(r)||n.supportedPlugins.includes(r)):r=>!n.supportedPlugins.includes(r))}),[...Object.keys(Wu()),...e]}addMissingPlugins(e,s,i){let n=e.shouldAddMissingPlugins||s,r;e.activePluginName?r=[...e.basePlugins||[],e.activePluginName]:r=[...e.supportedPlugins];let o=r.filter(a=>!i.includes(a));o.length>0&&(n&&i.push(...o),this.logger.warn(dy(Ls,e.configurationStatusStr,o,n)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),s=[...Object.keys(mo),...zu],i=[],n=[];e.forEach(r=>{s.includes(r)?i.push(r):n.push(r)}),n.length>0&&this.logger.warn(gy(Ls,n)),Fe(()=>{f.plugins.totalPluginsToLoad.value=e.length,f.plugins.activePlugins.value=i,f.plugins.failedPlugins.value=n})}registerLocalPlugins(){let e=[];Object.entries(mo).forEach(([s,i])=>{f.plugins.activePlugins.value.includes(s)&&(F(i)?this.register([i()]):e.push(s))}),e.length>0&&(f.plugins.failedPlugins.value=[...f.plugins.failedPlugins.value,...e],this.logger.error(vy(Ls,e)))}registerRemotePlugins(){let e=j0(f.plugins.activePlugins.value),s=[],i=[];return Promise.all(Object.keys(e).map(async n=>{await e[n]().then(r=>this.register([r.default()])).catch(r=>{i.push(n),f.plugins.failedPlugins.value=[...f.plugins.failedPlugins.value,n],this.logger.error(py(Ls,n,r?.message??String(r))),s.push(r)})})).then(()=>{if(i.length===0)return;let n=s[0];this.onError(n,`Failed to load plugins: ${i.join(", ")}`,n)}).catch(n=>{this.onError(n)})}invokeMultiple(e,...s){try{return this.engine.invokeMultiple(e,...s)}catch(i){return this.onError(i,e),[]}}invokeSingle(e,...s){try{return this.engine.invokeSingle(e,...s)}catch(i){return this.onError(i,e),null}}register(e){e.forEach(s=>{try{this.engine.register(s,f)}catch(i){f.plugins.failedPlugins.value=[...f.plugins.failedPlugins.value,s.name],this.onError(i,`Failed to register plugin "${s.name}"`)}})}unregisterLocalPlugins(){Object.keys(mo).forEach(e=>{try{this.engine.unregister(e)}catch(s){this.onError(s,`Failed to unregister plugin "${e}"`)}})}onError(e,s,i){this.errorHandler.onError({error:e,context:Ls,customMessage:s,groupingHash:i})}},ze="cookieStorage",ot="localStorage",ht="sessionStorage",St="memoryStorage",Zt="none",G0="test_rudder_cookie",H0="test_rudder_ls",z0="test_rudder_ss",q0="rl_user_id",W0="rl_trait",K0="rl_anonymous_id",Y0="rl_group_id",Q0="rl_group_trait",J0="rl_page_init_referrer",X0="rl_page_init_referring_domain",Z0="rl_session",eb="rl_auth_token",Bs={userId:q0,userTraits:W0,anonymousId:K0,groupId:Y0,groupTraits:Q0,initialReferrer:J0,initialReferringDomain:X0,sessionInfo:Z0,authToken:eb},tb="__tld__",Ku="clientDataInCookie",Yu="clientDataInLocalStorage",sb="clientDataInMemory",Qu="clientDataInSessionStorage",Ju=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ps={[ze]:Ku,[ot]:Yu,[St]:sb,[ht]:Qu},Zc=(t,e)=>{try{return encodeURIComponent(t)}catch(s){e?.error($_,s);return}},eu=t=>{try{return decodeURIComponent(t)}catch{return}},ib=t=>{let e={},s=t.split(/\s*;\s*/),i;return s[0]&&s.forEach(n=>{i=n.split("=");let r=i[0]?eu(i[0]):void 0;r&&(e[r]=i[1]?eu(i[1]):void 0)}),e},nb=(t,e,s,i)=>{let n={...s||{}},r=`${Zc(t,i)}=${Zc(e,i)}`;st(e)&&(n.maxage=-1),n.maxage&&(n.expires=new Date(+new Date+n.maxage)),n.path&&(r+=`; path=${n.path}`),n.domain&&(r+=`; domain=${n.domain}`),n.expires&&(r+=`; expires=${n.expires.toUTCString()}`),n.samesite&&(r+=`; samesite=${n.samesite}`),n.secure&&(r+="; secure"),globalThis.document.cookie=r},No=()=>{let t=globalThis.document.cookie;return ib(t)},rb=t=>No()[t],$t=function(t,e,s,i){switch(arguments.length){case 4:case 3:case 2:return nb(t,e,s,i);case 1:return t?rb(t):No();default:return No()}},ob=t=>{let e=document.createElement("a");return e.href=t,e.hostname},ab=t=>{let s=(typeof globalThis.URL!="function"?ob(t):new URL(t).hostname)?.split(".")??[],i=s[s.length-1],n=[];if(s.length===4&&i&&i===parseInt(i,10).toString())return n;if(s.length<=1)return s[0]&&s[0].indexOf("localhost")!==-1?["localhost"]:n;for(let r=s.length-2;r>=0;r-=1)n.push(s.slice(r).join("."));return n},Xu=t=>{let e=ab(t);for(let s=0;s<e.length;s+=1){let i=e[s],n=tb,r={domain:`${i.indexOf("localhost")!==-1?"":"."}${i}`};try{if($t(n,1,r),$t(n))return $t(n,null,r),i}catch{try{$t(n,null,r)}catch{}}}return""},lb=()=>{let t=`.${Xu(globalThis.location.href)}`;return{maxage:W_,path:"/",domain:!t||t==="."?void 0:t,samesite:"Lax",enabled:!0}},cb=()=>({enabled:!0}),ub=()=>({enabled:!0}),db=()=>({enabled:!0}),Mo=class{constructor(e){Se(this,"isEnabled",!0);Se(this,"length",0);Se(this,"data",{});this.options=db(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,s){return this.data[e]=s,this.length=Object.keys(this.data).length,s}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)}},zn=new Mo(Ft);Nn={exports:{}},fb=Nn.exports;pb=gb(),hs=hb(pb),Zu=t=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],s=[22,1014];return t instanceof DOMException?e.includes(t.name)||s.includes(t.code):!1},Vs=(t=ot,e,s)=>{let i,n,r=x_(ko,t),o="unavailable",a=!0,l;try{switch(t){case St:return!0;case ze:i=e,n=G0;break;case ot:i=e??globalThis.localStorage,n=H0;break;case ht:i=e??globalThis.sessionStorage,n=z0;break;default:return!1}if(i&&(i.setItem(n,"true"),i.getItem(n)))return i.removeItem(n),!0;a=!1}catch(c){a=!1,l=c,Zu(c)&&(o="full")}return a||s?.warn(`${r}${o}.`,l),!1},Fo=class{constructor(e){Se(this,"isSupportAvailable",!0);Se(this,"isEnabled",!0);Se(this,"length",0);this.options=cb(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isSupportAvailable=Vs(ot),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){hs.set(e,s),this.length=hs.len()}getItem(e){let s=hs.get(e);return Ve(s)?null:s}removeItem(e){hs.remove(e),this.length=hs.len()}clear(){hs.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return hs.keys()}},ra=new Fo(Ft),Lo=class{constructor(e){Se(this,"isSupportAvailable",!0);Se(this,"isEnabled",!0);Se(this,"length",0);this.options=ub(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isSupportAvailable=Vs(ht),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){this.store&&(this.store.setItem(e,s),this.length=this.store.length)}getItem(e){if(!this.store)return null;let s=this.store.getItem(e);return Ve(s)?null:s}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 s=0;s<this.store.length;s+=1){let i=this.store.key(s);i!==null&&e.push(i)}return e}},oa=new Lo(Ft),Uo=class{constructor(e){Se(this,"isSupportAvailable",!0);Se(this,"isEnabled",!0);Se(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=lb()),this.options=$e(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=Vs(ze,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){return $t(e,s,this.options,this.logger),this.length=Object.keys($t()).length,!0}getItem(e){let s=$t(e);return Ve(s)?null:s}removeItem(e){let s=this.setItem(e,null);return this.length=Object.keys($t()).length,s}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys($t())}},aa=new Uo(Ft),pt=t=>{switch(t){case ot:return ra;case ht:return oa;case St:return zn;case ze:return aa;default:return zn}},vb=t=>{let e=aa.configure(t);f.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},_b=t=>{ra.configure(t)},mb=t=>{zn.configure(t)},yb=t=>{oa.configure(t)},bb=(t={},e={},s={},i={})=>{vb(t),_b(e),mb(s),yb(i)},Bo=class{constructor(e,s,i){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=s,this.noKeyValidation=Object.keys(this.validKeys).length===0,this.noCompoundKey=e.noCompoundKey,this.noSwapOnQuota=e.noSwapOnQuota,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=i}createValidKey(e){let{name:s,id:i,validKeys:n,noKeyValidation:r,noCompoundKey:o}=this;if(r)return o?e:[s,i,e].join(".");let a;return Object.values(n).forEach(l=>{l===e&&(a=o?e:[s,i,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{validKeys:e,noCompoundKey:s}=this,i=pt(St),n=this.engine,r=Object.values(e).map(a=>[a,this.get(a)]),o=!s&&n!==i;this.engine=i,r.forEach(([a,l])=>{if(at(l))return;this.set(a,l);let c=this.createValidKey(a);if(o&&c&&!at(this.get(a)))try{n.removeItem(c)}catch{}})}set(e,s){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(rt(s,!1,[],this.logger)))}catch(n){if(Zu(n)){if(this.logger.warn(sy(`Store ${this.id}`)),this.noSwapOnQuota)return;this.swapQueueStoreToInMemoryEngine(),this.set(e,s)}else{let r=Dm(e);this.onError(n,r,r)}}}get(e){let s=this.createValidKey(e),i;try{return!s||(i=this.decrypt(this.engine.getItem(s)),at(i)||i==="")?null:JSON.parse(i)}catch(n){let r=f.storage.encryptionPluginName.value;if(!r||!f.plugins.failedPlugins.value.includes(r)){let a=Nm(e);this.onError(n,a,a)}return null}}remove(e){let s=this.createValidKey(e);s&&this.engine.removeItem(s)}getOriginalEngine(){return this.originalEngine}decrypt(e){return at(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,s){if(!this.isEncrypted||!e||typeof e!="string"||h_(e)==="")return e;let n=`storage.${s}`,r=this.pluginsManager?this.pluginsManager.invokeSingle(n,e):e;return typeof r>"u"?e:r??""}onError(e,s,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:s,groupingHash:i})}},Eb=(t,e)=>{let s;if(t.consents.preConsent.value.enabled)switch(t.consents.preConsent.value.storage?.strategy){case"none":s=Zt;break;case"session":e!=="sessionInfo"&&(s=Zt);break;case"anonymousId":e!=="anonymousId"&&(s=Zt);break}return s},Vo=class{constructor(e,s,i){Se(this,"stores",{});Se(this,"isInitialized",!1);this.errorHandler=s,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=f.loadOptions.value,s={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};bb(wi($e(s.cookieStorageOptions??{},f.storage.cookie?.value??{})),wi(s.localStorageOptions),wi(s.inMemoryStorageOptions),wi(s.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[St,ot,ze,ht].forEach(s=>{pt(s)?.isEnabled&&this.setStore({id:ps[s],name:ps[s],isEncrypted:!0,noCompoundKey:!0,type:s,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=f.loadOptions.value.storage?.type,s=f.loadOptions.value.storage?.entries,i=f.consents.postConsent.value.storage;(ce(i?.type)||ce(i?.entries))&&(e=i?.type,s=i?.entries);let n=f.consents.preConsent.value,o=n.enabled===!0&&!n.storage?.strategy?Zt:fm;e!==void 0&&!Pi.includes(e)&&(e=void 0);let a=!0,l={};Ju.forEach(c=>{let u=c,h=c,d=s?.[u]?.type,p=Eb(f,c)??d??e??o;Pi.includes(p)||(p=o);let m=this.getResolvedStorageTypeForEntry(p,c);m!==Zt&&(a=!1),l={...l,[c]:{type:m,key:Bs[h]}}}),Fe(()=>{f.storage.entries.value=l,f.storage.trulyAnonymousTracking.value=a})}getResolvedStorageTypeForEntry(e,s){let i=e;switch(e){case ot:pt(ot)?.isEnabled||(i=St);break;case ht:pt(ht)?.isEnabled||(i=St);break;case St:case Zt:break;case ze:default:pt(ze)?.isEnabled?i=ze:pt(ot)?.isEnabled?i=ot:pt(ht)?.isEnabled?i=ht:i=St;break}return i!==e&&this.logger.warn(iy(p_,s,e,i)),i}setStore(e){let s=pt(e.type);return this.stores[e.id]=new Bo(e,s,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},wb=t=>fe(t)&&fe(t.source)&&!at(t.source.id)&&fe(t.source.config)&&Array.isArray(t.source.destinations),su=t=>typeof t=="string"&&Pi.includes(t),ed=(t,e,s)=>{if(!fe(t))return;let{type:i,entries:n}=t;ce(i)&&!su(i)&&s?.warn(Bm(e,i)),n&&Object.entries(n).forEach(([r,o])=>{let a=o?.type;ce(a)&&!su(a)&&s?.warn(Vm(e,r,a))})},Sb=t=>{let e=document.createElement("a");return e.href=t,{host:e.host,protocol:e.protocol}},kb=t=>{let{host:e,protocol:s}=typeof globalThis.URL!="function"?Sb(t):new URL(t),i=e.split("."),n;return i.length>2?n=i.slice(-2).join("."):n=e,{topDomain:n,protocol:s}},Ab=/^https?:\/\//i,Tb=(t,e,s)=>{if(Ab.test(t))return t;let i=e||!s?window.location.origin:`${window.location.protocol}//${s}`,n=t.startsWith("/")?t.substring(1):t;return`${i}/${n}`},Mn=(t,e)=>t===e||t.endsWith(`.${e}`),Ib=(t,e,s)=>s||!e?t===globalThis.location.hostname:Mn(t,e),Rb=t=>{let{topDomain:e}=kb(window.location.href);return e===t},Gs=t=>t?.endsWith("/")?Gs(t.substring(0,t.length-1)):t,Cb=t=>{try{return new URL(t).host}catch{return null}},Ob=t=>{try{return new URL(t).hostname}catch{return null}},td=t=>Cb(t)??"",Pb=t=>{let e={};try{let s=new URL(t),i="utm_";s.searchParams.forEach((n,r)=>{if(r.startsWith(i)){let o=r.substring(i.length);o==="campaign"&&(o="name"),e[o]=n}})}catch{}return e},$b=t=>{let e=t;try{let s=new URL(t);e=s.origin+s.pathname+s.search}catch{}return e},xb=t=>t.replace(/\/{2,}/g,"/"),Hs=t=>{if(!ge(t))return!1;try{return F(globalThis.URL)&&new URL(t),my.test(t)}catch{return!1}},yo="none",bo="immediate",Db=t=>t?.statsCollection?.errors?.enabled===!0,Nb=t=>t?.statsCollection?.metrics?.enabled===!0,Mb=(t,e)=>{let s={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(s.storage=f.consents.postConsent.value.storage,fe(t)){let i=te(t);ce(i.storage)&&(ed(i.storage,__,e),s.storage=i.storage),Nt(i.integrations)&&(s.integrations=i.integrations),s.discardPreConsentEvents=i.discardPreConsentEvents===!0,s.sendPageEvent=i.sendPageEvent===!0,s.trackConsent=i.trackConsent===!0,Nt(i.consentManagement)&&(s.consentManagement=$e(i.consentManagement,{enabled:f.consents.enabled.value}))}return s},iu=t=>Nt(t)||Array.isArray(t),Fb=(t,e)=>{let{provider:s}=t,i=s?Oo[s]:void 0;return s&&!i&&(e.error(bm(qe,s,Oo)),s=void 0),{provider:s,consentManagerPluginName:i}},sd=(t,e)=>{let s,i=[],n=[],r=!1,o,a=t?.enabled===!0;Nt(t)&&a&&({provider:o,consentManagerPluginName:s}=Fb(t,e),iu(t.allowedConsentIds)&&(i=t.allowedConsentIds,r=!0),iu(t.deniedConsentIds)&&(n=t.deniedConsentIds,r=!0));let l={allowedConsentIds:i,deniedConsentIds:n};return a=a&&!!s,{provider:o,consentManagerPluginName:s,initialized:r,enabled:a,consentsData:l}},Lb=()=>{let t=document.querySelector("script[data-rsa-write-key]");if(t&&t.dataset.rsaWriteKey===f.lifecycle.writeKey.value)return t.src;let e=document.getElementsByTagName("script"),s=/(?:^|\/)rsa(\.min)?\.js$/;for(let i of e){let n=i.getAttribute("src");if(n&&s.test(n))return n}},Ub=t=>{f.reporting.isErrorReportingEnabled.value=Db(t.source.config)&&!k_(),f.reporting.isMetricsReportingEnabled.value=Nb(t.source.config)},Bb=()=>{let t=Xu(globalThis.location.href),{port:e}=globalThis.location;return{topDomain:t,topHost:t&&e?`${t}:${e}`:t}},Vb=(t,e,s,i,n)=>{if(!Ib(t,s.topDomain,i))return n.error(zm(qe,t,s.hostname)),!1;if(i||!ce(e))return!0;let r=gu(e).toLowerCase();return!Mn(t,r)||!Mn(s.hostname,r)||s.topDomain&&!Mn(r,s.topDomain)?(n.error(Hm(qe,e,s.hostname)),!1):!0},jb=t=>{let{useServerSideCookies:e,dataServiceEndpoint:s,storage:i,setCookieDomain:n,sameDomainCookiesOnly:r}=f.loadOptions.value,o=i?.cookie,a=!1,l;if(e){a=e;let c=o.domain??n,u=ce(c)&&!Rb(gu(c))||r,{hostname:h}=globalThis.location,{topDomain:d,topHost:g}=Bb(),p=Tb(s??Ey,u,g),m=Ob(p);Hs(p)&&m?(l=Gs(p),a=Vb(m,c,{hostname:h,topDomain:d},r,t),a&&h!==m&&(o={...o,samesite:"None",secure:!0})):(t.error(Mm(qe,p)),a=!1)}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},Gb=t=>{let{storage:e}=f.loadOptions.value;ed(e,qe,t);let s=e?.encryption?.version,i=s&&$n[s];!Ve(s)&&Ve(i)?(t.warn(jm(qe,s,$n,gs)),s=gs):Ve(s)&&(s=gs);let n=e?.migrate,r=n&&s===gs;n===!0&&r!==n&&t.warn(Gm(qe,s,gs));let{sscEnabled:o,finalDataServiceUrl:a,cookieOptions:l}=jb(t);Fe(()=>{f.storage.cookie.value=l,f.serverCookies.isEnabledServerSideCookies.value=o,f.serverCookies.dataServiceUrl.value=a,f.storage.encryptionPluginName.value=$n[s],f.storage.migrate.value=r})},Hb=t=>{let{provider:e,consentManagerPluginName:s,initialized:i,enabled:n,consentsData:r}=sd(f.loadOptions.value.consentManagement,t),o=f.loadOptions.value.preConsent,a=o?.storage?.strategy;ce(a)&&t.warn(ly(qe));let l;o?.storage?.enabled!==!0&&(l=a??yo,["none","session","anonymousId"].includes(l)||(l=yo,t.warn(ay(qe,a,yo))));let c=o?.events?.delivery??bo,u=["immediate","buffer"];ce(c)&&!u.includes(c)&&(c=bo,t.warn(cy(qe,o?.events?.delivery,bo))),Fe(()=>{f.consents.activeConsentManagerPluginName.value=s,f.consents.initialized.value=i,f.consents.enabled.value=n,f.consents.data.value=r,f.consents.provider.value=e,f.consents.preConsent.value={enabled:f.loadOptions.value.preConsent?.enabled===!0&&i===!1&&n===!0,storage:{strategy:l},events:{delivery:c}}})},zb=t=>{let e=f.consents.resolutionStrategy.value,s;fe(t.consentManagementMetadata)&&(f.consents.provider.value&&(e=t.consentManagementMetadata.providers.find(i=>i.provider===f.consents.provider.value)?.resolutionStrategy??f.consents.resolutionStrategy.value),s=t.consentManagementMetadata),f.consents.provider.value==="custom"&&(e=void 0),Fe(()=>{f.consents.metadata.value=te(s),f.consents.resolutionStrategy.value=e})},qb=t=>{if(f.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",s=e;f.loadOptions.value.useBeacon&&(f.capabilities.isBeaconAvailable.value?s="BeaconQueue":(s=e,t.warn(Ym(qe)))),Fe(()=>{f.dataPlaneEvents.eventsQueuePluginName.value=s})}},Wb=(t,e,s,i,n)=>{let r=new URLSearchParams({p:wu,v:Ci,build:$i,writeKey:e,lockIntegrationsVersion:s.toString(),lockPluginsVersion:i.toString()}),o=Mu,a=r,l="/sourceConfig/",c="";if(Hs(t)){let u=new URL(t);Gs(u.pathname).endsWith("/sourceConfig")||(u.pathname=`${Gs(u.pathname)}/sourceConfig/`),u.pathname=xb(u.pathname),r.forEach((h,d)=>{u.searchParams.get(d)===null&&u.searchParams.set(d,h)}),o=u.origin,l=u.pathname,a=u.searchParams,c=u.hash}else n.warn(ry(qe,t));return`${o}${l}?${a}${c}`},Kb=t=>t.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:x0(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===Sy})),id=(t,e,s,i,n,r,o)=>{let a;if(r){if(!Hs(r))return o.error(ym(qe,t,r)),null;a=Gs(r)}else if(a=s,f.context.app.value.installType==="cdn"){let l=Lb();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return n&&(a=a.replace(new RegExp(`/${na}/${$i}/${e}$`),`/${i}/${$i}/${e}`)),a},Yb=(t,e,s,i)=>id("integrations",Xn,Du,t,e,s,i),Qb=(t,e,s,i)=>id("plugins",xu,Nu,t,e,s,i),jo=class{constructor(e,s,i){this.errorHandler=s,this.logger=i,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){Mt(()=>{this.logger.setMinLogLevel(f.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:s,lockIntegrationsVersion:i,lockPluginsVersion:n,destSDKBaseURL:r,pluginsSDKBaseURL:o,integrations:a}=f.loadOptions.value,l=Yb(Ci,i,r,this.logger);if(st(l))return;let c;c=Qb(Ci,n,o,this.logger),c!==null&&(e&&(f.lifecycle.logLevel.value=e),this.attachEffects(),f.lifecycle.activeDataplaneUrl.value=Gs(f.lifecycle.dataPlaneUrl.value),Gb(this.logger),Hb(this.logger),qb(this.logger),Fe(()=>{f.lifecycle.integrationsCDNPath.value=l,f.lifecycle.pluginsCDNPath.value=c,f.lifecycle.sourceConfigUrl.value=Wb(s,f.lifecycle.writeKey.value,i,n,this.logger),f.metrics.metricsServiceUrl.value=`${f.lifecycle.activeDataplaneUrl.value}/${wy}`,f.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,s,i){this.errorHandler.onError({error:e,context:qe,customMessage:s,groupingHash:i})}processConfig(e,s){if(!ce(e)){ce(s)?this.onError(s.error,Hc):this.onError(new Error(Hc));return}let i;try{ge(e)?i=JSON.parse(e):i=e}catch(r){this.onError(r,jc);return}if(!wb(i)){this.onError(new Error(jc));return}if(i.source.enabled===!1){this.logger.error(gm);return}Ub(i);let n=i.source.destinations.length>0?Kb(i.source.destinations):[];Fe(()=>{f.source.value={config:i.source.config,name:i.source.name,id:i.source.id,workspaceId:i.source.workspaceId},f.nativeDestinations.configuredDestinations.value=n,f.plugins.pluginsToLoadFromConfig.value=f.loadOptions.value.plugins??[],zb(i),f.lifecycle.status.value="configured"})}getConfig(){let e=f.loadOptions.value.getSourceConfig;if(e){if(!F(e)){this.logger.error(mm(qe));return}let s=e();s instanceof Promise?s.then(i=>this.processConfig(i)).catch(i=>{this.onError(i,"SourceConfig")}):this.processConfig(s)}else this.httpClient.getAsyncData({url:f.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},Jb=()=>{let t=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return t?.[1]?t[1]:"NA"},nd=(t=()=>document)=>t()?.referrer||"$direct",Xb=(t=()=>document)=>{let s=t().getElementsByTagName("link"),i="";for(let n=0;s[n];n+=1){let r=s[n];if(r.getAttribute("rel")==="canonical"&&!i){i=r.getAttribute("href")??"";break}}return i},Zb=(t=()=>globalThis.navigator)=>{let e=t();if(Ve(e))return null;let{userAgent:s}=e,{brave:i}=e;if(i&&Object.getPrototypeOf(i).isBrave){let n=s.match(/(chrome)\/([\w.]+)/i);n&&(s=`${s} Brave/${n[2]}`)}return s},eE=(t=()=>globalThis.navigator)=>{let e=t();return Ve(e)?null:e.language??e.browserLanguage},rd=(t=()=>globalThis.location,e=()=>document)=>{let s=t(),i=Xb(e),n=s.pathname,{href:r}=s,o=r,{search:a}=s;if(i)try{let h=new URL(i);h.search===""?o=i+a:o=i,n=h.pathname}catch{}let l=$b(o),{title:c}=e(),u=nd(e);return{path:n,referrer:u,referring_domain:td(u),search:a,title:c,url:l,tab_url:r}},tE=(t,e="none")=>{e==="none"&&t(void 0),e==="default"&&t(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(s=>{t(s)}).catch(()=>{t()})},sE=()=>{let t=globalThis.document.createElement("div");return t.setAttribute("data-a-b","c"),t.dataset?t.dataset.aB==="c":!1},Go={URL:()=>!F(globalThis.URL)||!F(globalThis.URLSearchParams),Promise:()=>!F(globalThis.Promise),"Number.isNaN":()=>!F(globalThis.Number.isNaN),"Number.isInteger":()=>!F(globalThis.Number.isInteger),"Array.from":()=>!F(globalThis.Array.from),"Array.prototype.find":()=>!F(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!F(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!F(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!F(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!F(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!F(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!F(globalThis.String.fromCodePoint),"Object.entries":()=>!F(globalThis.Object.entries),"Object.values":()=>!F(globalThis.Object.values),"Object.assign":()=>!F(globalThis.Object.assign),"Object.fromEntries":()=>!F(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!sE(),TextEncoder:()=>!F(globalThis.TextEncoder)||!F(globalThis.TextDecoder),requestAnimationFrame:()=>!F(globalThis.requestAnimationFrame)||!F(globalThis.cancelAnimationFrame),CustomEvent:()=>!F(globalThis.CustomEvent),"navigator.sendBeacon":()=>!F(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!F(globalThis.Uint8Array),Set:()=>!F(globalThis.Set),atob:()=>!F(globalThis.atob)},iE=()=>{let t=Object.keys(Go),e=!1;for(let s=0;s<t.length;s++){let i=Go[t[s]];if(F(i)&&i()){e=!0;break}}return e},nE="https://polyfill-fastly.io/v3/polyfill.min.js",rE=`${nE}?version=3.111.0&features=${Object.keys(Go).join("%2C")}`,oE=10*1e3,nu="rudderstackPolyfill",aE=t=>{f.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(f.lifecycle.sourceConfigUrl.value),s=`${e.origin}${e.pathname}?view=ad`;t.getAsyncData({url:s,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(i,n)=>{f.capabilities.isAdBlockerDetectionInProgress.value=!1,f.capabilities.isAdBlocked.value=n?.error!==void 0||n?.xhr?.responseURL!==s}})}catch(e){throw f.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},lE=()=>!at(globalThis.crypto)&&F(globalThis.crypto.getRandomValues),ru=()=>!at(globalThis.navigator.userAgentData),cE=()=>!at(globalThis.navigator.sendBeacon)&&F(globalThis.navigator.sendBeacon),ou=()=>{let t={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return t={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},t},Ho=class{constructor(e,s,i){this.httpClient=e,this.errorHandler=s,this.logger=i,this.externalSrcLoader=new Vn(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Fe(()=>{f.capabilities.storage.isCookieStorageAvailable.value=Vs(ze,pt(ze),this.logger),f.capabilities.storage.isLocalStorageAvailable.value=Vs(ot,void 0,this.logger),f.capabilities.storage.isSessionStorageAvailable.value=Vs(ht,void 0,this.logger),f.capabilities.isBeaconAvailable.value=cE(),f.capabilities.isUaCHAvailable.value=ru(),f.capabilities.isCryptoAvailable.value=lE(),f.capabilities.isOnline.value=globalThis.navigator.onLine,f.context.userAgent.value=Zb(),f.context.locale.value=eE(),f.context.screen.value=ou(),f.context.timezone.value=Jb(),ru()&&tE(e=>{f.context["ua-ch"].value=e},f.loadOptions.value.uaChTrackLevel)}),Mt(()=>{f.loadOptions.value.sendAdblockPage===!0&&f.lifecycle.sourceConfigUrl.value!==void 0&&aE(this.httpClient)})}prepareBrowserCapabilities(){f.capabilities.isLegacyDOM.value=iE();let e=f.loadOptions.value.polyfillURL,s=rE;if(js(e)&&(Hs(e)?s=e:this.logger.warn(hy(ko,e))),f.loadOptions.value.polyfillIfRequired&&f.capabilities.isLegacyDOM.value&&Hs(s)){let n=s!==f.loadOptions.value.polyfillURL;if(n){let r=`RS_polyfillCallback_${f.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[r]};globalThis[r]=o,s=`${s}&callback=${r}`}this.externalSrcLoader.loadJSFile({url:s,id:nu,async:!0,timeout:oE,callback:r=>{r?n||this.onReady():this.onError(new Error(oy(nu,s)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{f.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{f.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Q_(()=>{f.context.screen.value=ou()},this))}onReady(){this.detectBrowserCapabilities(),f.lifecycle.status.value="browserCapabilitiesReady"}onError(e,s){this.errorHandler.onError({error:e,context:ko,groupingHash:s})}},uE="web",dE=["integrations","anonymousId","originalTimestamp"],hE=["library","consentManagement","userAgent","ua-ch","screen"],Eo=["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"],Fn="CustomContext",fE=new Set(["__proto__","constructor","prototype"]),gE=Function.prototype.toString.call(Object),pE=t=>{if(!fe(t))return!1;let e=Object.getPrototypeOf(t);if(e===null)return!0;let s=Object.prototype.hasOwnProperty.call(e,"constructor")?e.constructor:void 0;return typeof s=="function"&&s.prototype===e&&Function.prototype.toString.call(s)===gE},la=(t,e=new Set)=>{if(!fe(t)&&!Array.isArray(t))return!1;let s=t;return e.has(s)?!1:(e.add(s),Object.keys(s).some(i=>fE.has(i)||la(s[i],e)))},od=(t,e)=>{let s={};return Object.keys(t).forEach(i=>{if(hE.includes(i)){e.warn(Wm(Fn,i));return}Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:t[i]===t?s:t[i],writable:!0})}),s},ad=(t,e)=>{try{if(!pE(t)){e.warn(Pn(Fn));return}let s=od(t,e);if(la(s)){e.warn(Pn(Fn));return}let i=oe(s,e);return te(i)}catch{e.warn(Pn(Fn));return}},zo=class{constructor(e,s){this.state=e,this.logger=s}set(e){let s=ad(e,this.logger);if(!s)return;let i=$e(te(this.state.value),s);this.state.value=Ri(i)}get(){return te(this.state.value)}clear(){this.state.value={}}},ld=t=>typeof t=="number"&&!Number.isNaN(t),vE=(t,e)=>e.toString().length>=t,qn=t=>ld(t)&&t>=0&&Number.isInteger(t),au=10,cd=t=>{let{cutOff:e}=t,s=Date.now();return!!(e?.enabled&&e.expiresAt&&s>e.expiresAt)},lu=t=>!t.expiresAt||Date.now()>t.expiresAt||cd(t),_E=()=>Date.now(),mE=(t,e)=>!t||!qn(t)||!vE(au,t)?(e.warn(ty(fs,t,au)),!1):!0,yE=t=>{if(t?.enabled)return t.expiresAt??(qn(t.duration)?Date.now()+t.duration:void 0)},bE=t=>{let{timeout:e,cutOff:s}=t,i=Date.now();return{id:i,expiresAt:i+e,timeout:e,autoTrack:!0,...s&&{cutOff:s}}},EE=(t,e)=>({id:mE(t,e)?t:_E(),sessionStart:void 0,manualTrack:!0}),ki=t=>t===ze||t===ot||t===ht||t===St,qo=()=>Kn(),wE=t=>Object.prototype.hasOwnProperty.call(xn.entries,t),SE=t=>{if(Cc(t)){let{entries:e,...s}=xn;return{...s,entries:{...e,anonymousId:t}}}if(fe(t)&&fe(t.entries)){let e=t.entries,s=Object.keys(e).reduce((i,n)=>{if(wE(n)){let r=e[n];Cc(r)&&(i[n]=r)}return i},{});return $e(xn,{entries:s})}return{...xn}},kE=t=>{let e=rd(),s={};return Object.keys(e).forEach(i=>{s[i]=t?.[i]||e[i]}),s.initial_referrer=t?.initial_referrer||f.session.initialReferrer.value,s.initial_referring_domain=t?.initial_referring_domain||f.session.initialReferringDomain.value,s},AE=(t,e)=>{let s=e?.page||{},i=t,n=rd();return Object.keys(n).forEach(r=>{Ve(i[r])&&(i[r]=s[r]||n[r])}),Ve(i.initial_referrer)&&(i.initial_referrer=s.initial_referrer||f.session.initialReferrer.value),Ve(i.initial_referring_domain)&&(i.initial_referring_domain=s.initial_referring_domain||f.session.initialReferringDomain.value),i},wo=(t,e,s)=>{fe(t)&&Object.keys(t).forEach(i=>{(Eo.includes(i)||Eo.includes(i.toLowerCase()))&&s.warn(qm(Ao,i,e,Eo))})},TE=(t,e)=>{let{properties:s,traits:i,context:n}=t,{traits:r}=n;wo(s,"properties",e),wo(i,"traits",e),wo(r,"context.traits",e)},IE=(t,e)=>{e.anonymousId&&ge(e.anonymousId)&&(t.anonymousId=e.anonymousId),Nt(e.integrations)&&(t.integrations=e.integrations),e.originalTimestamp&&ge(e.originalTimestamp)&&(t.originalTimestamp=e.originalTimestamp)},RE=(t,e,s)=>{let i=t,n=r=>{let o=od(r,s);if(la(o)){s.warn(Pn(Ao));return}i=$e(i,o)};return Object.keys(e).forEach(r=>{dE.includes(r)||(r!=="context"?n({[r]:e[r]}):!Ve(e[r])&&fe(e[r])?n(e[r]):s.warn(Km(Ao)))}),i},CE=(t,e,s)=>{fe(e)&&(IE(t,e),t.context=RE(t.context,e,s))},OE=t=>{let e;return f.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=f.consents.postConsent.value.integrations??f.nativeDestinations.loadOnlyIntegrations.value:t?e=t:e=$u,te(e)},Ei=(t,e,s,i,n={})=>{let r={channel:uE,context:{traits:te(f.session.userTraits.value),sessionId:f.session.sessionInfo.value.id||void 0,sessionStart:f.session.sessionInfo.value.sessionStart||void 0,...f.consents.enabled.value&&{consentManagement:{deniedConsentIds:te(f.consents.data.value.deniedConsentIds),allowedConsentIds:te(f.consents.data.value.allowedConsentIds),provider:f.consents.provider.value,resolutionStrategy:f.consents.resolutionStrategy.value}},"ua-ch":f.context["ua-ch"].value,app:f.context.app.value,library:f.context.library.value,userAgent:f.context.userAgent.value,os:f.context.os.value,locale:f.context.locale.value,screen:f.context.screen.value,campaign:Pb(globalThis.location.href),page:kE(s),timezone:f.context.timezone.value,...f.autoTrack.enabled.value&&{autoTrack:{...f.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:f.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:I_(),messageId:Kn(),userId:t.userId||f.session.userId.value};ki(f.storage.entries.value.anonymousId?.type)?r.anonymousId=f.session.anonymousId.value:r.anonymousId=qo(),f.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),t.type==="identify"&&(r.context.traits=f.storage.entries.value.userTraits?.type!==Zt?te(f.session.userTraits.value):t.context.traits),t.type==="group"&&((t.groupId||f.session.groupId.value)&&(r.groupId=t.groupId||f.session.groupId.value),(t.traits||f.session.groupTraits.value)&&(r.traits=f.storage.entries.value.groupTraits?.type!==Zt?te(f.session.groupTraits.value):t.traits));let o=$e(t,r),a=$e(o,{context:n});return a.event===void 0&&(a.event=null),a.properties===void 0&&(a.properties=null),CE(a,e,i),TE(a,i),a.integrations=OE(a.integrations),a},Wo=class{constructor(e){this.logger=e}generatePageEvent(e,s,i,n,r={}){let o=i??{};return o=AE(o,n),Ei({properties:o,name:s,category:e,type:"page"},n,o,this.logger,r)}generateTrackEvent(e,s,i,n={}){return Ei({properties:s,event:e,type:"track"},i,void 0,this.logger,n)}generateIdentifyEvent(e,s,i,n={}){return Ei({userId:e,type:"identify",context:{traits:s}},i,void 0,this.logger,n)}generateAliasEvent(e,s,i,n={}){let o=Ei({previousId:s,type:"alias"},i,void 0,this.logger,n);return o.userId=e??o.userId,o}generateGroupEvent(e,s,i,n={}){let r={type:"group"};return e&&(r.groupId=e),s&&(r.traits=s),Ei(r,i,void 0,this.logger,n)}create(e,s={}){let i,{type:n,name:r,properties:o,options:a,category:l,userId:c,traits:u,to:h,from:d,groupId:g}=e;switch(n){case"page":i=this.generatePageEvent(l,r,o,a,s);break;case"track":i=this.generateTrackEvent(r,o,a,s);break;case"identify":i=this.generateIdentifyEvent(c,u,a,s);break;case"alias":i=this.generateAliasEvent(h,d,a,s);break;default:i=this.generateGroupEvent(g,u,a,s);break}return i}},Ko=class{constructor(e,s,i,n){this.eventRepository=e,this.userSessionManager=s,this.errorHandler=i,this.logger=n,this.eventFactory=new Wo(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e,s){this.userSessionManager.refreshSession();let i=this.eventFactory.create(e,s);this.eventRepository.enqueue(i,e.callback)}},Yo=class{constructor(e,s,i,n,r){this.storeManager=s,this.pluginsManager=e,this.logger=r,this.errorHandler=n,this.httpClient=i,this.onError=this.onError.bind(this),this.serverSideCookiesDebounceTimer=0,this.serverSideCookiesPending={},this.serverSideCookiesRequestInProgress={},this.lastSyncedValues={}}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:s}=f.loadOptions.value,i;js(e)&&typeof e=="string"&&(i=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(i??this.getAnonymousId(s)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let s=this.getConfiguredSessionTrackingInfo(),i=this.getSessionInfo()??ue.sessionInfo;e={autoTrack:s.autoTrack&&i.manualTrack!==!0,timeout:s.timeout,manualTrack:i.manualTrack,expiresAt:i.expiresAt,id:i.id,sessionStart:i.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=ue.sessionInfo:s.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:s.cutOff.duration,expiresAt:i.cutOff?.expiresAt})}else e=ue.sessionInfo;f.session.sessionInfo.value=e,f.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(f.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),s=this.getInitialReferringDomain();if(e&&s)this.setInitialReferrer(e),this.setInitialReferringDomain(s);else{let i=e||nd();this.setInitialReferrer(i),this.setInitialReferringDomain(td(i))}}isPersistenceEnabledForStorageEntry(e){return ki(f.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=f.storage.entries.value,s=[ze,ot,ht];Object.keys(e).forEach(i=>{let n=i,r=e[n]?.type,o=this.storeManager?.getStore(ps[r]);o&&s.forEach(a=>{let l=this.storeManager?.getStore(ps[a]);if(l&&a!==r){let c=l.get(Bs[n]);a_(c)&&o.set(Bs[n],c),l.remove(Bs[n])}})})}migrateStorageIfNeeded(e,s){if(!f.storage.migrate.value)return;let i=e??[];i.length===0&&[Ku,Yu,Qu].forEach(o=>{let a=this.storeManager?.getStore(o);a&&i.push(a)}),(s??Object.keys(Bs)).forEach(r=>{let o=Bs[r];i.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);at(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=f.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let s,i=f.loadOptions.value.sessions?.timeout;qn(i)?s=i:(this.logger.warn(Qm(fs,i,To)),s=To),s===0&&(this.logger.warn(Zm(fs)),e=!1),s>0&&s<Uc&&this.logger.warn(ey(fs,s,Uc));let n=this.getCutOffInfo(s);return{timeout:s,autoTrack:e,cutOff:n}}getCutOffInfo(e){let s=f.loadOptions.value.sessions.cutOff,i,n=!1;return s.enabled===!0&&(i=s.duration,n=!0,qn(i)?i<e&&(this.logger.warn(Xm(fs,i,e)),n=!1):(this.logger.warn(Jm(fs,i,Lc)),i=Lc)),{enabled:n,duration:i}}onError(e,s,i){this.errorHandler.onError({error:e,context:fs,customMessage:s,groupingHash:i})}getEncryptedCookieData(e,s){let i=[];return e.forEach(n=>{let r=s?.encrypt(rt(n.value,!1,[],this.logger));js(r)&&i.push({name:n.name,value:r})}),i}makeRequestToSetCookie(e,s){this.httpClient?.getAsyncData({url:f.serverCookies.dataServiceUrl.value,options:{method:"POST",data:rt({reqType:"setCookies",workspaceId:f.source.value?.workspaceId,data:{options:{maxAge:f.storage.cookie.value?.maxage,path:f.storage.cookie.value?.path,domain:f.storage.cookie.value?.domain,sameSite:f.storage.cookie.value?.samesite,secure:f.storage.cookie.value?.secure,expires:f.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:s})}setServerSideCookies(e,s,i){let n=Object.keys(e),r=()=>n.map(c=>({name:e[c].name,value:f.session[c].value})),o={};n.forEach(c=>{o[e[c].name]=i?.get(e[c].name)});let a=()=>{n.forEach(c=>{this.serverSideCookiesRequestInProgress[c]=!1})},l=()=>{r().forEach(c=>{s&&s(c.name,c.value)})};try{let c={};n.forEach(h=>{c[e[h].name]=f.session[h].value});let u=this.getEncryptedCookieData(r(),i);u.length>0?this.makeRequestToSetCookie(u,(h,d)=>{if(a(),d?.xhr?.status===200){let g=new Set(u.map(m=>m.name)),p=[];r().forEach(m=>{let v=o[m.name],b=i?.get(m.name);rt(c[m.name],!1,[])!==rt(b,!1,[])&&(g.has(m.name)&&rt(v,!1,[])===rt(b,!1,[])&&p.push(m.name),st(v)&&st(b)&&this.logger.error(Lm(m.name)),s&&s(m.name,m.value))}),u.length>1&&p.length>0&&!f.serverCookies.isCollapsedBatchErrorLogged.value&&(f.serverCookies.isCollapsedBatchErrorLogged.value=!0,this.logger.error(Um(p,u.length)))}else this.logger.error(Fm(d?.xhr?.status)),l()}):(l(),a())}catch(c){this.onError(c,zc,zc),l(),a()}}flushServerSideCookies(){this.serverSideCookiesDebounceTimer=0;let e=Object.entries(this.serverSideCookiesPending).reduce((i,[n,r])=>(i[n]={name:r},i),{});if(this.serverSideCookiesPending={},Object.keys(e).length===0)return;let s=this.storeManager.getStore(ps[ze]);this.setServerSideCookies(e,(i,n)=>{s?.set(i,n)},s)}syncValueToStorage(e){let s=f.storage.entries.value,i=s[e]?.type;if(ki(i)){let n=this.storeManager.getStore(ps[i]),r=s[e]?.key,o=f.session[e].value;o&&(ge(o)||Nt(o))?f.serverCookies.isEnabledServerSideCookies.value&&i===ze?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookiesPending[e]=r,this.serverSideCookiesDebounceTimer&&globalThis.clearTimeout(this.serverSideCookiesDebounceTimer),this.serverSideCookiesDebounceTimer=globalThis.setTimeout(()=>{this.flushServerSideCookies()},Ty)):n?.set(r,o):n?.remove(r)}}registerEffects(){Ju.forEach(e=>{Mt(()=>{let s=f.session[e].value;this.syncValueToStorage(e),this.lastSyncedValues[e]=s})})}setAnonymousId(e,s){let i=e;(!ge(e)||!i)&&(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&s&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",s)),i=i||qo()):i=ue.anonymousId,f.session.anonymousId.value=i}getAnonymousId(e){let s=f.storage.entries.value.anonymousId?.type;if(ki(s)){let i=f.session.anonymousId.value;(!i||i===ue.anonymousId)&&(i=this.getEntryValue("anonymousId")),!i&&e&&(i=this.pluginsManager?.invokeSingle("storage.getAnonymousId",pt,e)),f.session.anonymousId.value=i||qo()}return f.session.anonymousId.value}getEntryValue(e){let s=f.storage.entries.value,i=s[e]?.type;if(ki(i)){let n=this.storeManager?.getStore(ps[i]);this.migrateStorageIfNeeded([n],[e]);let r=s[e]?.key;return n?.get(r)??null}return null}getExternalAnonymousIdByCookieName(e){let s=pt(ze);return s?.isEnabled?s.getItem(e)??null:null}getUserSessionValue(e){let s=f.session[e].peek();return this.isPersistenceEnabledForStorageEntry(e)&&e in this.lastSyncedValues&&s!==this.lastSyncedValues[e]||this.serverSideCookiesRequestInProgress[e]?s: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()??ue.sessionInfo;return e.autoTrack&&!lu(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??ue.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=f.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),f.session.sessionInfo.value=e,f.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=f.session,{manualTrack:s,autoTrack:i,timeout:n,cutOff:r}=e.sessionInfo.value;if(i){let o={...ue.sessionInfo,timeout:n};r&&(o.cutOff={enabled:r.enabled,duration:r.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else s&&this.startManualTrackingInternal()}reset(e){let{session:s}=f,i=SE(e);Fe(()=>{Object.keys(ue).forEach(n=>{let r=n;if(i.entries[r]===!0)switch(n){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:s[r].value=ue[r];break}})})}setUserId(e){f.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:ue.userId}setUserTraits(e){f.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&fe(e)?$e(f.session.userTraits.value??ue.userTraits,e):ue.userTraits}setGroupId(e){f.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:ue.groupId}setGroupTraits(e){f.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&fe(e)?$e(f.session.groupTraits.value??ue.groupTraits,e):ue.groupTraits}setInitialReferrer(e){f.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:ue.initialReferrer}setInitialReferringDomain(e){f.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:ue.initialReferringDomain}startOrRenewAutoTracking(e){let s=e;if(lu(e))s=bE(e);else{let i=Date.now(),n=e.timeout;s.expiresAt=i+n}if(cd(s)&&(s.cutOff.expiresAt=void 0),s.cutOff){let i=yE(s.cutOff);s.cutOff.expiresAt=i}f.session.sessionInfo.value=s}start(e){f.session.sessionInfo.value=EE(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){f.session.sessionInfo.value=ue.sessionInfo}setAuthToken(e){f.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:ue.authToken}},PE=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],$E=PE,xE=(t,e)=>{let s=te(e);return ge(s.setCookieDomain)||(s.setCookieDomain=void 0),["Strict","Lax","None"].includes(s.sameSiteCookie)||(s.sameSiteCookie=void 0),s.secureCookie=wt(s.secureCookie,t.secureCookie),s.sameDomainCookiesOnly=wt(s.sameDomainCookiesOnly,t.sameDomainCookiesOnly),["none","default","full"].includes(s.uaChTrackLevel)||(s.uaChTrackLevel=void 0),s.integrations=Ot(s.integrations),Array.isArray(s.plugins)||(s.plugins=$E),s.useGlobalIntegrationsConfigInEvents=wt(s.useGlobalIntegrationsConfigInEvents,t.useGlobalIntegrationsConfigInEvents),s.bufferDataPlaneEventsUntilReady=wt(s.bufferDataPlaneEventsUntilReady,t.bufferDataPlaneEventsUntilReady),s.sendAdblockPage=wt(s.sendAdblockPage,t.sendAdblockPage),s.useServerSideCookies=wt(s.useServerSideCookies,t.useServerSideCookies),ge(s.dataServiceEndpoint)||(s.dataServiceEndpoint=void 0),s.sendAdblockPageOptions=Ot(s.sendAdblockPageOptions),s.loadIntegration=wt(s.loadIntegration,t.loadIntegration),Nt(s.storage)?(s.storage.migrate=wt(s.storage.migrate,t.storage?.migrate),s.storage.cookie=Ot(s.storage.cookie),s.storage.encryption=Ot(s.storage.encryption),s.storage=Ri(s.storage)):s.storage=void 0,s.destinationsQueueOptions=Ot(s.destinationsQueueOptions),s.queueOptions=Ot(s.queueOptions),s.lockIntegrationsVersion=wt(s.lockIntegrationsVersion,t.lockIntegrationsVersion),s.lockPluginsVersion=wt(s.lockPluginsVersion,t.lockPluginsVersion),ld(s.dataPlaneEventsBufferTimeout)||(s.dataPlaneEventsBufferTimeout=void 0),s.beaconQueueOptions=Ot(s.beaconQueueOptions),s.preConsent=Ot(s.preConsent),s.sourceConfigurationOverride=Ot(s.sourceConfigurationOverride),$e(t,Ri(s))},cu="dataplaneEventsQueue",uu="destinationsEventsQueue",DE="transformEvent",NE=(t,e)=>Object.keys(t).filter(s=>t[s]!==!0||!e[s]).reduce((s,i)=>{let n=te(s);return n[i]=t[i],n},{}),ME=(t,e)=>{let s=te(t),i=e.nativeDestinations.integrationsConfig.value,n=NE(t.integrations,i);return s.integrations=$e(i,n),s},FE=t=>t.consents.preConsent.value.enabled&&t.consents.preConsent.value.events?.delivery==="buffer",Ln=(t,e,s,i)=>{if(ce(t))if(F(t))try{t(...e)}catch(n){i.error(ny(s),n)}else i.error(Pu(s))},Qo=class{constructor(e,s,i,n,r){this.pluginsManager=e,this.errorHandler=n,this.httpClient=i,this.logger=r,this.storeManager=s}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${cu}.init`,f,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${DE}.init`,f,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${uu}.init`,f,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),Mt(()=>{f.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=FE(f),s;Mt(()=>{let i=f.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&f.nativeDestinations.clientDestinationsReady.value===!1;(f.nativeDestinations.activeDestinations.value.some(r=>$0(r))===!1||i===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(s),this.dataplaneEventsQueue?.start())}),f.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(s=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},f.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(f.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,s){let i=ME(e,f);this.pluginsManager.invokeSingle(`${cu}.enqueue`,f,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let n=te(e);this.pluginsManager.invokeSingle(`${uu}.enqueue`,f,this.destinationsEventsQueue,n,this.errorHandler,this.logger);let r=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${Wn}`;Ln(s,[i],r,this.logger)}},du=t=>{let e=new CustomEvent(t,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},LE=t=>ge(t)&&t.trim().length>0,UE=t=>Hs(t),Jo=class{constructor(){this.preloadBuffer=new Ro,this.initialized=!1,this.errorHandler=Hu,this.logger=Ft,this.customContextStore=new zo(f.customContext,this.logger),this.externalSrcLoader=new Vn(this.logger),this.httpClient=Vu,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new Ho(this.httpClient,this.errorHandler,this.logger)}load(e,s,i={}){if(f.lifecycle.status.value)return;if(!LE(e)){this.logger.error(Cm(An,e));return}if(!UE(s)){this.logger.error(Om(An,s));return}let{context:n,...r}=i,o=oe(r);n!==void 0&&this.customContextStore.set(n),Fe(()=>{f.lifecycle.writeKey.value=te(e),f.lifecycle.dataPlaneUrl.value=te(s),f.loadOptions.value=xE(f.loadOptions.value,o),f.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(f.loadOptions.value.logLevel??Ou),Oi("state",f,e),this.startLifecycle()}setCustomContext(e){if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,["setCustomContext",e]];return}this.customContextStore.set(e)}getCustomContext(){return this.customContextStore.get()}clearCustomContext(){if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,["clearCustomContext"]];return}this.customContextStore.clear()}startLifecycle(){Mt(()=>{try{switch(f.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 s="Failed to load the SDK";this.errorHandler.onError({error:e,context:An,customMessage:s,groupingHash:s})}})}onBrowserCapabilitiesReady(){em(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),f.consents.preConsent.value.enabled===!0?f.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(s=>this.preloadBuffer.enqueue(te(s)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&tm([...e],this)}}prepareInternalServices(){this.pluginsManager=new Do(O0,this.errorHandler,this.logger),this.storeManager=new Vo(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new jo(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Yo(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Qo(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Ko(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){f.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(f.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),f.consents.enabled.value&&!f.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",f,this.logger),f.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",f,this.storeManager,this.logger)),this.eventManager?.init(),f.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Fe(()=>{f.lifecycle.loaded.value=!0,f.lifecycle.status.value="loaded"}),this.initialized=!0;let e=f.loadOptions.value.onLoaded;Ln(e,[globalThis.rudderanalytics],v_,this.logger),du("RSA_Initialised")}onReady(){f.lifecycle.status.value="readyExecuted",f.eventBuffer.readyCallbacksArray.value.forEach(e=>{Ln(e,[],vo,this.logger)}),du("RSA_Ready")}processBufferedEvents(){let e=f.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let s=e.shift();f.eventBuffer.toBeProcessedArray.value=e,s&&this.processBufferedEvent(s),e=f.eventBuffer.toBeProcessedArray.value}}processBufferedEvent(e){switch(e[0]){case"setCustomContext":this.setCustomContext(e[1]);break;case"clearCustomContext":this.clearCustomContext();break;case"ready":this.ready(e[1],!0);break;case"page":this.page(e[1],!0,e[2]);break;case"track":this.track(e[1],!0,e[2]);break;case"identify":this.identify(e[1],!0,e[2]);break;case"alias":this.alias(e[1],!0,e[2]);break;case"group":this.group(e[1],!0,e[2]);break;case"reset":this.reset(e[1],!0);break;case"setAnonymousId":this.setAnonymousId(e[1],e[2],!0);break;case"startSession":this.startSession(e[1],!0);break;case"endSession":this.endSession(!0);break;case"consent":this.consent(e[1],!0);break;case"addCustomIntegration":this.addCustomIntegration(e[1],e[2],!0);break;default:return e}}getInvocationContext(e){return e===void 0?this.customContextStore.get():ad(e,this.logger)??{}}loadDestinations(){if(f.lifecycle.status.value==="destinationsLoading"||f.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",f,this.pluginsManager,this.errorHandler,this.logger);let e=f.nativeDestinations.activeDestinations.value.length;if(e===0){Fe(()=>{f.nativeDestinations.clientDestinationsReady.value=!0,f.lifecycle.status.value="destinationsReady"});return}f.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",f,this.externalSrcLoader,this.errorHandler,this.logger),Mt(()=>{f.nativeDestinations.initializedDestinations.value.length+f.nativeDestinations.failedDestinations.value.length===e&&Fe(()=>{f.lifecycle.status.value="destinationsReady",f.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){f.lifecycle.status.value!=="ready"&&Fe(()=>{f.lifecycle.status.value="ready"})}ready(e,s=!1){let i="ready";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[i,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),!F(e)){this.logger.error(Pu(vo));return}f.lifecycle.status.value==="readyExecuted"?Ln(e,[],vo,this.logger):f.eventBuffer.readyCallbacksArray.value=[...f.eventBuffer.readyCallbacksArray.value,e]}page(e,s=!1,i){let n="page";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event`),f.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback},r),f.capabilities.isAdBlocked.value===!0&&e.category!==Nc&&this.page(Bn(Nc,B_,{path:V_},f.loadOptions.value.sendAdblockPageOptions),s,r)}track(e,s=!1,i){let n="track";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event - ${e.name}`),f.metrics.triggered.value+=1,this.eventManager?.addEvent({type:n,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback},r)}identify(e,s=!1,i){let n="identify";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event`),f.metrics.triggered.value+=1,e.userId&&f.session.userId.value&&e.userId!==f.session.userId.value&&this.reset(),st(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:n,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback},r)}alias(e,s=!1,i){let n="alias";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event`),f.metrics.triggered.value+=1;let o=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:n,to:e.to,from:o,options:e.options,callback:e.callback},r)}group(e,s=!1,i){let n="group";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event`),f.metrics.triggered.value+=1,st(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:n,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback},r)}reset(e,s=!1){let i="reset";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.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,s,i=!1){let n="setAnonymousId";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e,s]];return}this.errorHandler.leaveBreadcrumb(`New ${n} invocation`),this.userSessionManager?.setAnonymousId(e,s)}getUserId(){return f.session.userId.value}getUserTraits(){return f.session.userTraits.value}getGroupId(){return f.session.groupId.value}getGroupTraits(){return f.session.groupTraits.value}startSession(e,s=!1){let i="startSession";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let s="endSession";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[s]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,s=!1){let i="consent";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Fe(()=>{f.consents.preConsent.value={...f.consents.preConsent.value,enabled:!1},f.consents.postConsent.value=Mb(e,this.logger);let{initialized:n,consentsData:r}=sd(f.consents.postConsent.value.consentManagement,this.logger);f.consents.initialized.value=n,f.consents.data.value=r}),f.consents.enabled.value&&!f.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",f,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(s)}sendTrackingEvents(e){if(f.consents.postConsent.value.trackConsent){let s=ta(j_);e?f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,["track",s,this.customContextStore.get()]]:this.track(s)}if(f.consents.postConsent.value.sendPageEvent){let s=Bn();e?f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,["page",s,this.customContextStore.get()]]:this.page(s)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,s,i=!1){let n="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${n} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,s,f,this.logger);else{if(f.lifecycle.loaded.value){this.logger.error(_y(An,e));return}f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e,s]]}}},vs=class vs{constructor(){Se(this,"analyticsInstances",{});Se(this,"defaultAnalyticsKey","");Se(this,"logger",Ft);try{if(vs.globalSingleton)return vs.globalSingleton;vs.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.setCustomContext=this.setCustomContext.bind(this),this.getCustomContext=this.getCustomContext.bind(this),this.clearCustomContext=this.clearCustomContext.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.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(),vs.globalSingleton=this,f.autoTrack.pageLifecycle.pageViewId.value=Kn(),f.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){be(e)}}createSafeAnalyticsInstance(){f.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(){Hu.init(),aa.configure(),ra.configure(),oa.configure(),zn.configure()}setDefaultInstanceKey(e){ge(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let s=e;return(!ge(s)||!s)&&(s=this.defaultAnalyticsKey),this.analyticsInstances[s]||(this.analyticsInstances[s]=new Jo),this.analyticsInstances[s]}catch(s){be(s);return}}load(e,s,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let n=ku(Ai);Z_(n),Oi(Ai,te(n)),this.getAnalyticsInstance(e)?.load(e,s,i)}catch(n){be(n)}}trackPageLifecycleEvents(e){let{autoTrack:s,useBeacon:i}=e??{},{enabled:n=!1,options:r={},pageLifecycle:o}=s??{},{events:a=[po.UNLOADED],enabled:l=n,options:c=r}=o??{};f.autoTrack.pageLifecycle.enabled.value=l,f.autoTrack.enabled.value=n||l,l&&this.setupPageUnloadTracking(a,i,c)}setupPageUnloadTracking(e,s,i){(e.length===0||e.includes(po.UNLOADED))&&(s===!0?T_(n=>{if(n===!1&&f.lifecycle.loaded.value){let r=Date.now(),o=r-f.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(po.UNLOADED,{timeOnPage:o},{...i,originalTimestamp:mu(new Date(r))})}},!0):this.logger.warn(fy(y_)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],s=X_(e);Oi(Ai,te([...e])),s.length>0&&(s.shift(),this.load.apply(null,s))}ready(e){try{this.getAnalyticsInstance()?.ready(oe(e))}catch(s){be(s)}}page(e,s,i,n,r){try{this.getAnalyticsInstance()?.page(Bn(oe(e),oe(s),oe(i),oe(n),oe(r)))}catch(o){be(o)}}track(e,s,i,n){try{this.getAnalyticsInstance()?.track(ta(oe(e),oe(s),oe(i),oe(n)))}catch(r){be(r)}}identify(e,s,i,n){try{this.getAnalyticsInstance()?.identify(pu(oe(e),oe(s),oe(i),oe(n)))}catch(r){be(r)}}alias(e,s,i,n){try{this.getAnalyticsInstance()?.alias(vu(oe(e),oe(s),oe(i),oe(n)))}catch(r){be(r)}}group(e,s,i,n){try{this.getAnalyticsInstance()?.group(_u(oe(e),oe(s),oe(i),oe(n)))}catch(r){be(r)}}reset(e){try{this.getAnalyticsInstance()?.reset(oe(e))}catch(s){be(s)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(oe(e))}catch(s){be(s);return}}setAnonymousId(e,s){try{this.getAnalyticsInstance()?.setAnonymousId(oe(e),oe(s))}catch(i){be(i)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){be(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){be(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){be(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){be(e);return}}setCustomContext(e){try{this.getAnalyticsInstance()?.setCustomContext(e)}catch(s){be(s)}}getCustomContext(){try{return this.getAnalyticsInstance()?.getCustomContext()??{}}catch(e){return be(e),{}}}clearCustomContext(){try{this.getAnalyticsInstance()?.clearCustomContext()}catch(e){be(e)}}startSession(e){try{this.getAnalyticsInstance()?.startSession(oe(e))}catch(s){be(s)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){be(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){be(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(oe(e))}catch(s){be(s)}}consent(e){try{this.getAnalyticsInstance()?.consent(oe(e))}catch(s){be(s)}}addCustomIntegration(e,s){try{this.getAnalyticsInstance()?.addCustomIntegration(oe(e),oe(s))}catch(i){be(i)}}};Se(vs,"globalSingleton",null);zs=vs});var dd,hd,ua,ud,fd,gd,pd,vd,Di=Ze(()=>{"use strict";dd="https://deriv.com/cdn-cgi/trace",hd="https://cdn.growthbook.io",ua="https://deriv-dataplane.rudderstack.com",ud="https://ph.deriv.com",fd="https://us.posthog.com",gd=()=>{if(typeof window>"u")return ud;let t=window.location.hostname;return t.includes(".deriv.me")?"https://ph.deriv.me":t.includes(".deriv.be")?"https://ph.deriv.be":t.includes(".deriv.ae")?"https://ph.deriv.ae":ud},pd=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae","trading.game"],vd=["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 er(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)i!=="__proto__"&&(t[i]=s[i])}return t}function da(t,e){function s(n,r,o){if(!(typeof document>"u")){o=er({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),n=encodeURIComponent(n).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=n+"="+t.write(r,n)+a}}function i(n){if(!(typeof document>"u"||arguments.length&&!n)){for(var r=document.cookie?document.cookie.split("; "):[],o={},a=0;a<r.length;a++){var l=r[a].split("="),c=l.slice(1).join("=");try{var u=decodeURIComponent(l[0]);if(u in o||(o[u]=t.read(c,u)),n===u)break}catch{}}return n?o[n]:o}}return Object.create({set:s,get:i,remove:function(n,r){s(n,"",er({},r,{expires:-1}))},withAttributes:function(n){return da(this.converter,er({},this.attributes,n))},withConverter:function(n){return da(er({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var BE,_d,md=Ze(()=>{"use strict";BE={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};_d=da(BE,{path:"/"})});var es,sr,Ni,tr,yd,ms,bd,Ed,Mi=Ze(()=>{"use strict";md();Di();es=(t,e)=>(...s)=>{e()&&console.log(`[ANALYTIC]${t}`,...s)},sr=t=>{let e=t.split("@")[1]?.toLowerCase();return e?vd.includes(e):!1},Ni=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),tr=null,yd=async()=>{if(tr)return tr;let t=JSON.parse(_d.get("website_status")||"{}")?.clients_country;return tr=(async()=>{try{let e=await fetch(dd).catch(()=>null);if(!e)return t||"";let s=await e.text().catch(()=>"");return s?Object.fromEntries(s.split(`
5
+ `).map(n=>n.split("=",2))).loc?.toLowerCase()||t||"":t||""}catch{return t||""}})(),tr},ms=t=>{if(t==null||typeof t!="object")return t;if(Array.isArray(t)){let i=[];for(let n=0;n<t.length;n++){let r=ms(t[n]);r!=null&&i.push(r)}return i.length?i:void 0}let e={},s=!1;for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let n=ms(t[i]);n==null||n===""||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0||Array.isArray(n)&&n.length===0||(e[i]=n,s=!0)}return s?e:void 0},bd=(t,e)=>{for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let i=t[s];i&&typeof i=="object"&&!Array.isArray(i)?bd(i,e):e[s]=i}},Ed=t=>{if(t==null||typeof t!="object"||Array.isArray(t))return t;let e={};return bd(t,e),e}});function Od(){return Cd}function ha(t){let e=2166136261,s=t.length;for(let i=0;i<s;i++)e^=t.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Fi(t,e,s){return s===2?ha(ha(t+e)+"")%1e4/1e4:s===1?ha(e+t)%1e3/1e3:null}function ga(t){return t<=0?[]:new Array(t).fill(1/t)}function or(t,e){return t>=e[0]&&t<e[1]}function Pd(t,e){let s=Fi("__"+e[0],t,1);return s===null?!1:s>=e[1]&&s<e[2]}function $d(t,e){for(let s=0;s<e.length;s++)if(or(t,e[s]))return s;return-1}function pa(t){try{let e=t.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function ar(t,e){if(!e.length)return!1;let s=!1,i=!1;for(let n=0;n<e.length;n++){let r=HE(t,e[n].type,e[n].pattern);if(e[n].include===!1){if(r)return!1}else s=!0,r&&(i=!0)}return i||!s}function jE(t,e,s){try{let i=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return s&&(i="\\/?"+i.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+i+"$","i").test(t)}catch{return!1}}function GE(t,e){try{let s=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),i=[[t.host,s.host,!1],[t.pathname,s.pathname,!0]];return s.hash&&i.push([t.hash,s.hash,!1]),s.searchParams.forEach((n,r)=>{i.push([t.searchParams.get(r)||"",n,!1])}),!i.some(n=>!jE(n[0],n[1],n[2]))}catch{return!1}}function HE(t,e,s){try{let i=new URL(t,"https://_");if(e==="regex"){let n=pa(s);return n?n.test(i.href)||n.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return GE(i,s);return!1}catch{return!1}}function xd(t,e,s){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=ga(t);s=s||i,s.length!==t&&(s=i);let n=s.reduce((o,a)=>a+o,0);(n<.99||n>1.01)&&(s=i);let r=0;return s.map(o=>{let a=r;return r+=o,[a,a+e*o]})}function Dd(t,e,s){if(!e)return null;let i=e.split("?")[1];if(!i)return null;let n=i.replace(/#.*/,"").split("&").map(r=>r.split("=",2)).filter(([r])=>r===t).map(([,r])=>parseInt(r));return n.length>0&&n[0]>=0&&n[0]<s?n[0]:null}function Nd(t){try{return t()}catch(e){return console.error(e),!1}}async function ts(t,e,s){if(e=e||"",s=s||globalThis.crypto&&globalThis.crypto.subtle||Cd.SubtleCrypto,!s)throw new Error("No SubtleCrypto implementation found");try{let i=await s.importKey("raw",fa(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[n,r]=t.split("."),o=await s.decrypt({name:"AES-CBC",iv:fa(n)},i,fa(r));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Li(t){return typeof t=="string"?t:JSON.stringify(t)}function lt(t){typeof t=="number"&&(t=t+""),(!t||typeof t!="string")&&(t="0");let e=t.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(s=>s.match(/^[0-9]+$/)?s.padStart(5," "):s).join("-")}function Md(){let t;try{t="1.8.0"}catch{t=""}return t}function Fd(t,e){let s,i;try{s=new URL(t),i=new URL(e)}catch(n){return console.error(`Unable to merge query strings: ${n}`),e}return s.searchParams.forEach((n,r)=>{i.searchParams.has(r)||i.searchParams.set(r,n)}),i.toString()}function Rd(t){return typeof t=="object"&&t!==null}function lr(t){return t.urlPatterns&&t.variations.some(e=>Rd(e)&&"urlRedirect"in e)?"redirect":t.variations.some(e=>Rd(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function cr(t,e){return new Promise(s=>{let i=!1,n,r=o=>{i||(i=!0,n&&clearTimeout(n),s(o||null))};e&&(n=setTimeout(()=>r(),e)),t.then(o=>r(o)).catch(()=>r())})}var Cd,fa,Ui=Ze(()=>{"use strict";Cd={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};fa=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0))});function Bd(t){Object.assign(De,t),De.backgroundSync||wa()}async function Vd({instance:t,timeout:e,skipCache:s,allowStale:i,backgroundSync:n}){return n||(De.backgroundSync=!1),YE({instance:t,allowStale:i,timeout:e,skipCache:s})}function zE(t){let e=Ss(t),s=bs.get(e)||new Set;s.add(t),bs.set(e,s)}function jd(t){bs.forEach((e,s)=>{e.delete(t);let i=e.size?void 0:Es.get(s);i&&hr(i,s)})}function qE(){Ut.forEach(t=>{t&&(t.state="idle",ba(t))})}function WE(){Ut.forEach(t=>{t&&t.state==="idle"&&Ea(t)})}function Gd(t,e,s){return Math.min(t*Math.pow(e,s)*(1+Math.random()),KE)}function Hd(t){console.warn(`[GrowthBook] ${t}`)}function _a(t){va.has(t)||(va.add(t),Hd(`Streaming is enabled, but not active: ${t}. Features will not be updated in the background. Set \`pollingInterval\` to refresh on a timer instead, or see https://docs.growthbook.io/lib/node#refreshing-features`))}async function Ud(){try{if(!vt.localStorage)return;await vt.localStorage.setItem(De.cacheKey,JSON.stringify(Array.from(Lt.entries())))}catch{}}async function YE({instance:t,allowStale:e,timeout:s,skipCache:i}){let n=Ss(t),r=ma(t),o=new Date,a=new Date(o.getTime()-De.maxAge+De.staleTTL);await QE();let l=!De.disableCache&&!i?Lt.get(r):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&ws.add(n),l.staleAt<o?dr(t):ya(t),{data:l.data,success:!0,source:"cache"}):await cr(dr(t),s)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function Ss(t){let[e,s]=t.getApiInfo();return`${e}||${s}`}function ma(t){let e=Ss(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;let s=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),n={};i.forEach(a=>{n[a]=s[a]});let r=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:n,fv:r,url:o})}`}async function QE(){if(!Ld){Ld=!0;try{if(vt.localStorage){let t=await vt.localStorage.getItem(De.cacheKey);if(!De.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(([s,i])=>{Lt.set(s,{...i,staleAt:new Date(i.staleAt)})}),zd()}}}catch{}if(!De.disableIdleStreams){let t=Ks.startIdleListener();t&&(Ks.stopIdleListener=t)}}}function zd(){let t=Array.from(Lt.entries()).map(([s,i])=>({key:s,staleAt:i.staleAt.getTime()})).sort((s,i)=>s.staleAt-i.staleAt),e=Math.min(Math.max(0,Lt.size-De.maxEntries),Lt.size);for(let s=0;s<e;s++)Lt.delete(t[s].key)}function qd(t,e,s){let i=s.dateUpdated||"",n=new Date(Date.now()+De.staleTTL),r=De.disableCache?void 0:Lt.get(e);if(r&&i&&r.version===i){r.staleAt=n,Ud();return}De.disableCache||(Lt.set(e,{data:s,version:i,staleAt:n,sse:ws.has(t)}),zd()),Ud();let o=bs.get(t);o&&o.forEach(a=>JE(a,s))}async function JE(t,e){await t.setPayload(e||t.getPayload())}async function dr(t){let{apiHost:e,apiRequestHeaders:s}=t.getApiHosts(),i=t.getClientKey(),n="isRemoteEval"in t&&t.isRemoteEval(),r=Ss(t),o=ma(t),a=ur.get(o);return a||(a=(n?Ks.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:s}):Ks.fetchFeaturesCall({host:e,clientKey:i,headers:s})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&ws.add(r),c.json()}).then(c=>(qd(r,o,c),ya(t),ur.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(ur.delete(o),{data:null,source:"error",success:!1,error:c})),ur.set(o,a)),a}function ya(t,e=!1){let s=Ss(t),i=ma(t),{streamingHost:n,streamingHostRequestHeaders:r}=t.getApiHosts(),o=t.getClientKey();if(e&&ws.add(s),De.backgroundSync&&ws.has(s)&&vt.EventSource){if(Ut.has(s))return;let a={src:null,key:s,host:n,clientKey:o,headers:r,cb:l=>{try{if(l.type==="features-updated"){let c=bs.get(s);c&&c.forEach(u=>{dr(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);qd(s,i,c)}a.errors=0}catch{Wd(a)}},errors:0,state:"active"};Ut.set(s,a),Ea(a)}}function Wd(t){if(t.state!=="idle"&&(t.errors++,t.errors>3||t.src&&t.src.readyState===2)){let e=Gd(1e3,3,t.errors-3);ba(t),setTimeout(()=>{["idle","active"].includes(t.state)||Ut.get(t.key)===t&&Ea(t)},e)}}function ba(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,t.state==="active"&&(t.state="disabled"))}function Ea(t){try{t.src=Ks.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state="active",t.src.addEventListener("features",t.cb),t.src.addEventListener("features-updated",t.cb),t.src.onerror=()=>Wd(t),t.src.onopen=()=>{t.errors=0;let e=Es.get(t.key);e&&hr(e,t.key)}}catch(e){try{t.src&&(t.src.close(),t.src.onerror=null,t.src.onopen=null)}catch{}t.src=null,t.state="disabled",Ut.get(t.key)===t&&Ut.delete(t.key),_a(`the EventSource implementation threw an error (${e?e.message:"unknown error"})`)}}function XE(t,e){ba(t),Ut.delete(e)}function ZE(t,e){if(!Number.isFinite(e)||e<1||e>2147483647){Hd(`Ignoring invalid pollingInterval (${e}). Expected a finite number of milliseconds between 1 and 2147483647.`);return}if(Es.has(t))return;let s={timer:null,interval:e,errors:0};Es.set(t,s),Kd(t,s)}function Kd(t,e){let s=e.errors>0?Gd(e.interval,2,e.errors-1):e.interval,i=setTimeout(()=>{let n=bs.get(t),r=n&&n.values().next().value;if(!r){hr(e,t);return}dr(r).then(o=>{e.errors=o.success?0:e.errors+1,Es.get(t)===e&&Kd(t,e)})},s);i.unref&&i.unref(),e.timer=i}function hr(t,e){t.timer&&clearTimeout(t.timer),Es.delete(e)}function wa(){ws.clear(),va.clear(),Ut.forEach(XE),Es.forEach(hr),bs.clear(),Ks.stopIdleListener()}function fr(t,e){if(!e.streaming&&e.pollingInterval===void 0)return;if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming or polling");e.streaming&&(e.payload&&ya(t,!0),vt.EventSource?De.backgroundSync&&!ws.has(Ss(t))&&_a("the API host did not report SSE support (missing `x-sse-support` response header). This is also expected when the initial payload fetch fails"):_a("no EventSource implementation is available. In Node.js, install the `eventsource` package and pass it to setPolyfills({ EventSource })")),zE(t);let s=Ss(t);e.pollingInterval!==void 0&&De.backgroundSync&&ZE(s,e.pollingInterval)}var De,vt,Ks,bs,Ld,Lt,ur,Ut,Es,ws,va,KE,Yd=Ze(()=>{"use strict";Ui();De={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},vt=Od(),Ks={fetchFeaturesCall:({host:t,clientKey:e,headers:s})=>vt.fetch(`${t}/api/features/${e}`,{headers:s}),fetchRemoteEvalCall:({host:t,clientKey:e,payload:s,headers:i})=>{let n={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(s)};return vt.fetch(`${t}/api/eval/${e}`,n)},eventSourceCall:({host:t,clientKey:e,headers:s})=>s?new vt.EventSource(`${t}/sub/${e}`,{headers:s}):new vt.EventSource(`${t}/sub/${e}`),startIdleListener:()=>{let t;if(!(typeof window<"u"&&typeof document<"u"))return;let s=()=>{document.visibilityState==="visible"?(window.clearTimeout(t),WE()):document.visibilityState==="hidden"&&(t=window.setTimeout(qE,De.idleStreamInterval))};return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(vt.localStorage=globalThis.localStorage)}catch{}bs=new Map,Ld=!1,Lt=new Map,ur=new Map,Ut=new Map,Es=new Map,ws=new Set,va=new Set;KE=1e3*60*5});function tw(t){return t==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}function mr(t){var e=_r.get(t);return e||(e={element:t,attributes:{}},_r.set(t,e)),e}function yr(t,e,s,i,n){var r=s(t),o={isDirty:!1,originalValue:r,virtualValue:r,mutations:[],el:t,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=s(t);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,n(o))}}),mutationRunner:n,setValue:i,getCurrentValue:s};return e==="position"&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,tw(e)),o}function br(t,e){var s=e.getCurrentValue(e.el);e.virtualValue=t,t&&typeof t!="string"?(!s||t.parentNode!==s.parentNode||t.insertBeforeNode!==s.insertBeforeNode)&&(e.isDirty=!0,Qd()):t!==s&&(e.isDirty=!0,Qd())}function sw(t){var e=t.originalValue;t.mutations.forEach(function(s){return e=s.mutate(e)}),br(vw(e),t)}function iw(t){var e=new Set(t.originalValue.split(/\s+/).filter(Boolean));t.mutations.forEach(function(s){return s.mutate(e)}),br(Array.from(e).filter(Boolean).join(" "),t)}function nw(t){var e=t.originalValue;t.mutations.forEach(function(s){return e=s.mutate(e)}),br(e,t)}function rw(t){var e=t.parentSelector,s=t.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var n=s?document.querySelector(s):null;return s&&!n?null:{parentNode:i,insertBeforeNode:n}}function ow(t){var e=t.originalValue;t.mutations.forEach(function(s){var i=s.mutate(),n=rw(i);e=n||e}),br(e,t)}function Xd(t){var e=mr(t);return e.html||(e.html=yr(t,"html",aw,lw,sw)),e.html}function Zd(t){var e=mr(t);return e.position||(e.position=yr(t,"position",cw,uw,ow)),e.position}function eh(t){var e=mr(t);return e.classes||(e.classes=yr(t,"class",hw,dw,iw)),e.classes}function th(t,e){var s=mr(t);return s.attributes[e]||(s.attributes[e]=yr(t,e,fw(e),gw(e),nw)),s.attributes[e]}function pw(t,e){var s=_r.get(t);if(s)if(e==="html"){var i,n;(i=s.html)==null||(n=i.observer)==null||n.disconnect(),delete s.html}else if(e==="class"){var r,o;(r=s.classes)==null||(o=r.observer)==null||o.disconnect(),delete s.classes}else if(e==="position"){var a,l;(a=s.position)==null||(l=a.observer)==null||l.disconnect(),delete s.position}else{var c,u,h;(c=s.attributes)==null||(u=c[e])==null||(h=u.observer)==null||h.disconnect(),delete s.attributes[e]}}function vw(t){return gr||(gr=document.createElement("div")),gr.innerHTML=t,gr.innerHTML}function pr(t,e,s){if(s.isDirty){s.isDirty=!1;var i=s.virtualValue;s.mutations.length||pw(t,e),s.setValue(t,i)}}function _w(t,e){t.html&&pr(e,"html",t.html),t.classes&&pr(e,"class",t.classes),t.position&&pr(e,"position",t.position),Object.keys(t.attributes).forEach(function(s){pr(e,s,t.attributes[s])})}function Qd(){_r.forEach(_w)}function mw(t,e){var s=null;t.kind==="html"?s=Xd(e):t.kind==="class"?s=eh(e):t.kind==="attribute"?s=th(e,t.attribute):t.kind==="position"&&(s=Zd(e)),s&&(s.mutations.push(t),s.mutationRunner(s))}function yw(t,e){var s=null;if(t.kind==="html"?s=Xd(e):t.kind==="class"?s=eh(e):t.kind==="attribute"?s=th(e,t.attribute):t.kind==="position"&&(s=Zd(e)),!!s){var i=s.mutations.indexOf(t);i!==-1&&s.mutations.splice(i,1),s.mutationRunner(s)}}function sh(t){if(!(t.kind==="position"&&t.elements.size===1)){var e=new Set(t.elements),s=document.querySelectorAll(t.selector);s.forEach(function(i){e.has(i)||(t.elements.add(i),mw(t,i))})}}function bw(t){t.elements.forEach(function(e){return yw(t,e)}),t.elements.clear(),Ta.delete(t)}function Jd(){Ta.forEach(sh)}function Ew(){typeof document>"u"||(Sa||(Sa=new MutationObserver(function(){Jd()})),Jd(),Sa.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Er(t){return typeof document>"u"?Aa:(Ta.add(t),sh(t),{revert:function(){bw(t)}})}function ka(t,e){return Er({kind:"html",elements:new Set,mutate:e,selector:t})}function ih(t,e){return Er({kind:"position",elements:new Set,mutate:e,selector:t})}function Bi(t,e){return Er({kind:"class",elements:new Set,mutate:e,selector:t})}function vr(t,e,s){return ew.test(e)?e==="class"||e==="className"?Bi(t,function(i){var n=s(Array.from(i).join(" "));i.clear(),n&&n.split(/\s+/g).filter(Boolean).forEach(function(r){return i.add(r)})}):Er({kind:"attribute",attribute:e,elements:new Set,mutate:s,selector:t}):Aa}function ww(t){var e=t.selector,s=t.action,i=t.value,n=t.attribute,r=t.parentSelector,o=t.insertBeforeSelector;if(n==="html"){if(s==="append")return ka(e,function(a){return a+(i??"")});if(s==="set")return ka(e,function(){return i??""})}else if(n==="class"){if(s==="append")return Bi(e,function(a){i&&a.add(i)});if(s==="remove")return Bi(e,function(a){i&&a.delete(i)});if(s==="set")return Bi(e,function(a){a.clear(),i&&a.add(i)})}else if(n==="position"){if(s==="set"&&r)return ih(e,function(){return{insertBeforeSelector:o,parentSelector:r}})}else{if(s==="append")return vr(e,n,function(a){return a!==null?a+(i??""):i??""});if(s==="set")return vr(e,n,function(){return i??""});if(s==="remove")return vr(e,n,function(){return null})}return Aa}var ew,Aa,_r,Ta,aw,lw,cw,uw,dw,hw,fw,gw,gr,Sa,Sw,nh,rh=Ze(()=>{"use strict";ew=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Aa={revert:function(){}},_r=new Map,Ta=new Set;aw=function(e){return e.innerHTML},lw=function(e,s){return e.innerHTML=s};cw=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},uw=function(e,s){s.insertBeforeNode&&!s.parentNode.contains(s.insertBeforeNode)||s.parentNode.insertBefore(e,s.insertBeforeNode)};dw=function(e,s){return s?e.className=s:e.removeAttribute("class")},hw=function(e){return e.className};fw=function(e){return function(s){var i;return(i=s.getAttribute(e))!=null?i:null}},gw=function(e){return function(s,i){return i!==null?s.setAttribute(e,i):s.removeAttribute(e)}};Ew();Sw={html:ka,classes:Bi,attribute:vr,position:ih,declarative:ww},nh=Sw});function Bt(t,e,s,i){s=s||{},i=i||new Set;for(let[n,r]of Object.entries(e))switch(n){case"$or":if(!ch(t,r,s,i))return!1;break;case"$nor":if(ch(t,r,s,i))return!1;break;case"$and":if(!Rw(t,r,s,i))return!1;break;case"$not":if(Bt(t,r,s,i))return!1;break;case"$savedGroup":if(!kw(t,r,s,i))return!1;break;default:if(!Vi(r,uh(t,n),s,!1,i))return!1}return!0}function kw(t,e,s,i){if(!e||typeof e!="object"||Array.isArray(e))return!1;let{id:n,attributeKey:r}=e;if(typeof n!="string"||i.has(n)||r!==void 0&&typeof r!="string")return!1;let o=s[n];if(!o||Array.isArray(o)||typeof o!="object")return!1;let a=new Set(i).add(n);if(o.type==="list"){let l=r??o.attributeKey;return typeof l!="string"||!Array.isArray(o.values)?!1:ks(uh(t,l),o.values)}return o.type==="condition"?!o.condition||typeof o.condition!="object"?!1:Bt(t,o.condition,s,a):!1}function uh(t,e){let s=e.split("."),i=t;for(let n=0;n<s.length;n++)if(i&&typeof i=="object"&&s[n]in i)i=i[s[n]];else return null;return i}function oh(t,e=!1){let s=`${t}${e?"/i":""}`;return Ia[s]||(Ia[s]=new RegExp(t.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Ia[s]}function Vi(t,e,s,i=!1,n=new Set){if(typeof t=="string")return i?String(e).toLowerCase()===t.toLowerCase():e+""===t;if(typeof t=="number")return e*1===t;if(typeof t=="boolean")return e!==null&&!!e===t;if(t===null)return e===null;if(Array.isArray(t)||!dh(t))return JSON.stringify(e)===JSON.stringify(t);for(let r in t)if(!Iw(r,e,t[r],s,n))return!1;return!0}function dh(t){let e=Object.keys(t);return e.length>0&&e.filter(s=>s[0]==="$").length===e.length}function Aw(t){if(t===null)return"null";if(Array.isArray(t))return"array";let e=typeof t;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function Tw(t,e,s,i){if(!Array.isArray(t))return!1;let n=dh(e)?r=>Vi(e,r,s,!1,i):r=>Bt(r,e,s,i);for(let r=0;r<t.length;r++)if((t[r]??null)!==null&&n(t[r]))return!0;return!1}function ks(t,e,s=!1){if(s){let i=n=>typeof n=="string"?n.toLowerCase():n;return Array.isArray(t)?t.some(n=>e.some(r=>i(n)===i(r))):e.some(n=>i(t)===i(n))}return Array.isArray(t)?t.some(i=>e.includes(i)):e.includes(t)}function ah(t){return t===void 0?[]:Array.isArray(t)?t:t&&typeof t=="object"&&t.type==="list"&&Array.isArray(t.values)?t.values:null}function lh(t,e,s,i=!1,n=new Set){if(!Array.isArray(t))return!1;for(let r=0;r<e.length;r++){let o=!1;for(let a=0;a<t.length;a++)if(Vi(e[r],t[a],s,i,n)){o=!0;break}if(!o)return!1}return!0}function Iw(t,e,s,i,n=new Set){switch(t){case"$veq":return lt(e)===lt(s);case"$vne":return lt(e)!==lt(s);case"$vgt":return lt(e)>lt(s);case"$vgte":return lt(e)>=lt(s);case"$vlt":return lt(e)<lt(s);case"$vlte":return lt(e)<=lt(s);case"$eq":return e===s;case"$ne":return e!==s;case"$lt":return e<s;case"$lte":return e<=s;case"$gt":return e>s;case"$gte":return e>=s;case"$exists":return s?e!=null:e==null;case"$in":return Array.isArray(s)?ks(e,s):!1;case"$ini":return Array.isArray(s)?ks(e,s,!0):!1;case"$inGroup":{let r=ah(i[s]);return r===null?!1:ks(e,r)}case"$notInGroup":{let r=ah(i[s]);return r===null?!1:!ks(e,r)}case"$nin":return Array.isArray(s)?!ks(e,s):!1;case"$nini":return Array.isArray(s)?!ks(e,s,!0):!1;case"$not":return!Vi(s,e,i,!1,n);case"$size":return Array.isArray(e)?Vi(s,e.length,i,!1,n):!1;case"$elemMatch":return Tw(e,s,i,n);case"$all":return Array.isArray(s)?lh(e,s,i,!1,n):!1;case"$alli":return Array.isArray(s)?lh(e,s,i,!0,n):!1;case"$regex":try{return oh(s).test(e)}catch{return!1}case"$regexi":try{return oh(s,!0).test(e)}catch{return!1}case"$type":return Aw(e)===s;default:return console.error("Unknown operator: "+t),!1}}function ch(t,e,s,i){if(!e.length)return!0;for(let n=0;n<e.length;n++)if(Bt(t,e[n],s,i))return!0;return!1}function Rw(t,e,s,i){for(let n=0;n<e.length;n++)if(!Bt(t,e[n],s,i))return!1;return!0}var Ia,hh=Ze(()=>{"use strict";Ui();Ia={}});function Pw(t){let e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach((s,i)=>e.set(i,s)),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach((s,i)=>e.set(i,s)),e}function $w(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}async function Ys(t){try{await t()}catch{}}function fh(t,e,s){if(t.user.trackedExperiments){let n=kr(e,s);if(t.user.trackedExperiments.has(n))return[];t.user.trackedExperiments.add(n)}t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({experiment:e,result:s,timestamp:Date.now().toString(),logType:"experiment"});let i=[];if(t.global.trackingCallback){let n=t.global.trackingCallback;i.push(Ys(()=>n(e,s,kt(t.user))))}if(t.user.trackingCallback){let n=t.user.trackingCallback;i.push(Ys(()=>n(e,s,kt(t.user))))}if(t.global.eventLogger){let n=t.global.eventLogger;i.push(Ys(()=>n(Ow,{experimentId:e.key,variationId:s.key,hashAttribute:s.hashAttribute,hashValue:s.hashValue},kt(t.user))))}if(t.user.experimentViewedSubs?.size){let n=kt(t.user);t.user.experimentViewedSubs.forEach(r=>{try{r(e,s,n)}catch(o){console.error(o)}})}return i}function xw(t,e,s){if(t.user.trackedFeatureUsage){let i=JSON.stringify(s.value);if(t.user.trackedFeatureUsage[e]===i)return;t.user.trackedFeatureUsage[e]=i,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:s,timestamp:Date.now().toString(),logType:"feature"}),t.user.featureUsageSubs?.size&&t.user.featureUsageSubs.forEach(n=>{try{n(e,s)}catch(r){console.error(r)}})}if(t.global.onFeatureUsage){let i=t.global.onFeatureUsage;Ys(()=>i(e,s,kt(t.user)))}if(t.user.onFeatureUsage){let i=t.user.onFeatureUsage;Ys(()=>i(e,s))}if(t.global.eventLogger){let i=t.global.eventLogger;Ys(()=>i(Cw,{feature:e,source:s.source,value:s.value,ruleId:s.source==="defaultValue"?"$default":s.ruleId||"",variationId:s.experimentResult?s.experimentResult.key:""},kt(t.user)))}}function wr(t,e){if(e.stack.evaluatedFeatures.has(t))return ss(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;let s=Pw(e);if(s.has(t))return ss(e,t,s.get(t),"override");if(!e.global.features||!e.global.features[t])return ss(e,t,null,"unknownFeature");let i=e.global.features[t];if(i.rules){let n=new Set(e.stack.evaluatedFeatures);e:for(let r of i.rules){if(r.parentConditions)for(let c of r.parentConditions){e.stack.evaluatedFeatures=new Set(n);let u=wr(c.id,e);if(u.source==="cyclicPrerequisite")return ss(e,t,null,"cyclicPrerequisite");let h={value:u.value};if(!Bt(h,c.condition||{},e.global.savedGroups||{})){if(c.gate)return ss(e,t,null,"prerequisite");continue e}}if(r.filters&&gh(r.filters,e))continue;if("force"in r){if(r.condition&&!Pa(r.condition,e)||!Fw(e,r.seed||t,r.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!r.disableStickyBucketing?r.fallbackAttribute:void 0,r.range,r.coverage,r.hashVersion))continue;return r.tracks&&r.tracks.forEach(c=>{!fh(e,c.experiment,c.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:c.experiment,result:c.result,user:kt(e.user)})}),ss(e,t,r.force,"force",r.id)}let o=r.contextualVariations??r.variations;if(!o)continue;let a={variations:o,key:r.key||t};"coverage"in r&&(a.coverage=r.coverage),r.weights&&(a.weights=r.weights),r.hashAttribute&&(a.hashAttribute=r.hashAttribute),r.fallbackAttribute&&(a.fallbackAttribute=r.fallbackAttribute),r.disableStickyBucketing&&(a.disableStickyBucketing=r.disableStickyBucketing),r.bucketVersion!==void 0&&(a.bucketVersion=r.bucketVersion),r.minBucketVersion!==void 0&&(a.minBucketVersion=r.minBucketVersion),r.namespace&&(a.namespace=r.namespace),r.meta&&(a.meta=r.meta),r.ranges&&(a.ranges=r.ranges),r.name&&(a.name=r.name),r.phase&&(a.phase=r.phase),r.seed&&(a.seed=r.seed),r.hashVersion&&(a.hashVersion=r.hashVersion),r.filters&&(a.filters=r.filters),r.condition&&(a.condition=r.condition),r.contextualBanditRef&&Mw(a,r.contextualBanditRef,t,e);let{result:l}=Sr(a,t,e);if(a.contextualBandit&&!(l.hashUsed&&l.inExperiment)&&delete a.contextualBandit,e.global.onExperimentEval&&e.global.onExperimentEval(a,l),l.inExperiment&&!l.passthrough)return ss(e,t,l.value,"experiment",r.id,a,l)}}return ss(e,t,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function Sr(t,e,s){let i=t.key,n=t.variations.length;if(n<2)return{result:Ae(s,t,-1,!1,e)};if(s.global.enabled===!1||s.user.enabled===!1)return{result:Ae(s,t,-1,!1,e)};if(t=Lw(t,s),t.contextualBandit&&t.weights&&(t.contextualBandit={...t.contextualBandit,variationWeights:t.weights}),t.urlPatterns&&!ar(s.user.url||"",t.urlPatterns))return{result:Ae(s,t,-1,!1,e)};let r=Dd(i,s.user.url||"",n);if(r!==null)return{result:Ae(s,t,r,!1,e)};let o=$w(s);if(i in o){let v=o[i];return{result:Ae(s,t,v,!1,e)}}if(t.status==="draft"||t.active===!1)return{result:Ae(s,t,-1,!1,e)};let{hashAttribute:a,hashValue:l}=As(s,t.hashAttribute,s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!l)return{result:Ae(s,t,-1,!1,e)};let c=-1,u=!1,h=!1;if(s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{variation:v,versionIsBlocked:b}=Vw({ctx:s,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});u=v>=0,c=v,h=!!b}if(!u){if(t.filters){if(gh(t.filters,s))return{result:Ae(s,t,-1,!1,e)}}else if(t.namespace&&!Pd(l,t.namespace))return{result:Ae(s,t,-1,!1,e)};if(t.include&&!Nd(t.include))return{result:Ae(s,t,-1,!1,e)};if(t.condition&&!Pa(t.condition,s))return{result:Ae(s,t,-1,!1,e)};if(t.parentConditions){let v=new Set(s.stack.evaluatedFeatures);for(let b of t.parentConditions){s.stack.evaluatedFeatures=new Set(v);let y=wr(b.id,s);if(y.source==="cyclicPrerequisite")return{result:Ae(s,t,-1,!1,e)};let w={value:y.value};if(!Bt(w,b.condition||{},s.global.savedGroups||{}))return{result:Ae(s,t,-1,!1,e)}}}if(t.groups&&!Bw(t.groups,s))return{result:Ae(s,t,-1,!1,e)}}if(t.url&&!Uw(t.url,s))return{result:Ae(s,t,-1,!1,e)};let d=Fi(t.seed||i,l,t.hashVersion||1);if(d===null)return{result:Ae(s,t,-1,!1,e)};if(!u){let v=t.ranges||xd(n,t.coverage===void 0?1:t.coverage,t.weights);c=$d(d,v)}if(h)return{result:Ae(s,t,-1,!1,e,void 0,!0)};if(c<0)return{result:Ae(s,t,-1,!1,e)};if("force"in t)return{result:Ae(s,t,t.force===void 0?-1:t.force,!1,e)};if(s.global.qaMode||s.user.qaMode)return{result:Ae(s,t,-1,!1,e)};if(t.status==="stopped")return{result:Ae(s,t,-1,!1,e)};let g=Ae(s,t,c,!0,e,d,u);if(s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{changed:v,key:b,doc:y}=Gw(s,a,Li(l),{[Ra(t.key,t.bucketVersion)]:g.key});v&&(s.user.stickyBucketAssignmentDocs=s.user.stickyBucketAssignmentDocs||{},s.user.stickyBucketAssignmentDocs[b]=y,s.user.saveStickyBucketAssignmentDoc(y))}let p=fh(s,t,g);p.length===0&&s.global.saveDeferredTrack&&s.global.saveDeferredTrack({experiment:t,result:g,user:kt(s.user)});let m=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in t&&t.changeId&&s.global.recordChangeId&&s.global.recordChangeId(t.changeId),{result:g,trackingCall:m}}function ss(t,e,s,i,n,r,o){let a={value:s,on:!!s,off:!s,source:i,ruleId:n||""};return r&&(a.experiment=r),o&&(a.experimentResult=o),i!=="override"&&xw(t,e,a),a}function Oa(t){return{...t.attributes,...t.attributeOverrides}}function kt(t){return{attributes:Oa(t),url:t.url}}function Dw(t,e){for(let s of t.contexts||[])if(Pa(s.condition||{},e))return{leafId:s.leafId,weights:s.weights};return null}function Mw(t,e,s,i){let n=i.global.contextualBandits?.[e];if(!n)return;let r=null;if(n.contexts&&n.contexts.length)try{r=Dw(n,i)}catch{}if(r){t.weights=r.weights,t.contextualBandit={leafId:r.leafId,variationWeights:r.weights,banditVersion:n.banditVersion};return}t.contextualBandit={leafId:Nw,variationWeights:t.weights??ga(t.variations.length),banditVersion:n.banditVersion}}function Pa(t,e){return Bt(Oa(e.user),t,e.global.savedGroups||{})}function gh(t,e){return t.some(s=>{let{hashValue:i}=As(e,s.attribute);if(!i)return!0;let n=Fi(s.seed,i,s.hashVersion||2);return n===null?!0:!s.ranges.some(r=>or(n,r))})}function Fw(t,e,s,i,n,r,o){if(!n&&r===void 0)return!0;if(!n&&r===0)return!1;let{hashValue:a}=As(t,s,i);if(!a)return!1;let l=Fi(e,a,o||1);return l===null?!1:n?or(l,n):r!==void 0?l<=r:!0}function Ae(t,e,s,i,n,r,o){let a=!0;(s<0||s>=e.variations.length)&&(s=0,a=!1);let{hashAttribute:l,hashValue:c}=As(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),u=e.meta?e.meta[s]:{},h={key:u.key||""+s,featureId:n,inExperiment:a,hashUsed:i,variationId:s,value:e.variations[s],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};u.name&&(h.name=u.name),r!==void 0&&(h.bucket=r),u.passthrough&&(h.passthrough=u.passthrough);let d=e.contextualBandit;return d&&i&&a&&(h.leafId=d.leafId,h.variationWeights=d.variationWeights,d.banditVersion!==void 0&&(h.banditVersion=d.banditVersion)),h}function Lw(t,e){let s=t.key,i=e.global.overrides;return i&&i[s]&&(t=Object.assign({},t,i[s]),typeof t.url=="string"&&(t.url=pa(t.url))),t}function As(t,e,s){let i=e||"id",n="",r=Oa(t.user);return r[i]&&(n=r[i]),!n&&s&&(r[s]&&(n=r[s]),n&&(i=s)),{hashAttribute:i,hashValue:n}}function Uw(t,e){let s=e.user.url;if(!s)return!1;let i=s.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(t.test(s)||t.test(i))}function Bw(t,e){let s=e.global.groups||{};for(let i=0;i<t.length;i++)if(s[t[i]])return!0;return!1}function Vw({ctx:t,expKey:e,expBucketVersion:s,expHashAttribute:i,expFallbackAttribute:n,expMinBucketVersion:r,expMeta:o}){s=s||0,r=r||0,i=i||"id",o=o||[];let a=Ra(e,s),l=jw(t,i,n);if(r>0)for(let h=0;h<r;h++){let d=Ra(e,h);if(l[d]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=l[a];if(c===void 0)return{variation:-1};let u=o.findIndex(h=>h.key===c);return u<0?{variation:-1}:{variation:u}}function Ra(t,e){return e=e||0,`${t}__${e}`}function Ca(t,e){return`${t}||${e}`}function jw(t,e,s){if(!t.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:n}=As(t,e),r=Ca(i,Li(n)),{hashAttribute:o,hashValue:a}=As(t,s),l=a?Ca(o,Li(a)):null,c={};return l&&t.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,t.user.stickyBucketAssignmentDocs[l].assignments||{}),t.user.stickyBucketAssignmentDocs[r]&&Object.assign(c,t.user.stickyBucketAssignmentDocs[r].assignments||{}),c}function Gw(t,e,s,i){let n=Ca(e,s),r=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[n]?t.user.stickyBucketAssignmentDocs[n].assignments||{}:{},o={...r,...i},a=JSON.stringify(r)!==JSON.stringify(o);return{key:n,doc:{attributeName:e,attributeValue:s,assignments:o},changed:a}}function Hw(t,e){let s=new Set,i=e&&e.features?e.features:t.global.features||{},n=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(i).forEach(r=>{let o=i[r];if(o.rules)for(let a of o.rules)(a.variations||a.contextualVariations)&&(s.add(a.hashAttribute||"id"),a.fallbackAttribute&&s.add(a.fallbackAttribute))}),n.map(r=>{s.add(r.hashAttribute||"id"),r.fallbackAttribute&&s.add(r.fallbackAttribute)}),Array.from(s)}async function ph(t,e,s){let i=$a(t,s);return e.getAllAssignments(i)}function $a(t,e){let s={};return Hw(t,e).forEach(n=>{let{hashValue:r}=As(t,n);s[n]=Li(r)}),s}async function vh(t,e,s){if(t={...t},t.encryptedFeatures){try{t.features=JSON.parse(await ts(t.encryptedFeatures,e,s))}catch(i){console.error(i)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await ts(t.encryptedExperiments,e,s))}catch(i){console.error(i)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await ts(t.encryptedSavedGroups,e,s))}catch(i){console.error(i)}delete t.encryptedSavedGroups}if(t.encryptedContextualBandits){try{t.contextualBandits=JSON.parse(await ts(t.encryptedContextualBandits,e,s))}catch(i){console.error(i)}delete t.encryptedContextualBandits}return t}function _h(t){let e=t.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(t.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}function kr(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}var Cw,Ow,Nw,mh=Ze(()=>{"use strict";hh();Ui();Cw="Feature Evaluated",Ow="Experiment Viewed";Nw=-1});var Qs,zw,ji,yh=Ze(()=>{"use strict";rh();Ui();Yd();mh();Qs=typeof window<"u"&&typeof document<"u",zw=Md(),ji=class{constructor(e){if(e=e||{},this.version=zw,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._featureUsageSubs=new Set,this._customEventSubs=new Set,this._experimentViewedSubs=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 s=!1;try{s=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(s)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 s=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=i=>s.saveAssignments(i)}if(e.plugins)for(let s of e.plugins)s(this);if(e.features&&(this.ready=!0),Qs&&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 s in this._options.stickyBucketAssignmentDocs){let i=this._options.stickyBucketAssignmentDocs[s];i&&this._options.stickyBucketService.saveAssignments(i).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let s=await vh(e,this._options.decryptionKey);this._decryptedPayload=s,await this.refreshStickyBuckets(s),s.features&&(this._options.features=s.features),s.savedGroups&&(this._options.savedGroups=s.savedGroups),s.contextualBandits&&(this._options.contextualBandits=s.contextualBandits),s.experiments&&(this._options.experiments=s.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let s=e.payload;if(s.encryptedExperiments||s.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,s)),this._payload=s,this._decryptedPayload=s,s.features&&(this._options.features=s.features),s.savedGroups&&(this._options.savedGroups=s.savedGroups),s.contextualBandits&&(this._options.contextualBandits=s.contextualBandits),s.experiments&&(this._options.experiments=s.experiments,this._updateAllAutoExperiments()),this.ready=!0,fr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Bd(e.cacheSettings),e.payload)return await this.setPayload(e.payload),fr(this,e),{success:!0,source:"init"};{let{data:s,...i}=await this._refresh({...e,allowStale:!0});return fr(this,e),await this.setPayload(s||{}),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 s=await this._refresh({...e||{},allowStale:!1});s.data&&await this.setPayload(s.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return _h(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:s,allowStale:i,streaming:n}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Vd({instance:this,timeout:e,skipCache:s||this._options.disableCache,allowStale:i,backgroundSync:n??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,s,i){let n=await ts(e,s||this._options.decryptionKey,i);this.setFeatures(JSON.parse(n))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,s,i){let n=await ts(e,s||this._options.decryptionKey,i);this.setExperiments(JSON.parse(n))}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)}}_subscribeFeatureUsage(e){return this._featureUsageSubs.add(e),()=>this._featureUsageSubs.delete(e)}_subscribeExperimentViewed(e){return this._experimentViewedSubs.add(e),()=>this._experimentViewedSubs.delete(e)}_subscribeCustomEvents(e){return this._customEventSubs.add(e),()=>this._customEventSubs.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(s=>{try{s()}catch(i){console.error(i)}}),this._subscriptions.clear(),this._featureUsageSubs.clear(),this._customEventSubs.clear(),this._experimentViewedSubs.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,jd(this),e.destroyAllStreams&&wa(),this.logs=[],Qs&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(s=>{s.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,s){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=s,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:s}=Sr(e,null,this._getEvalContext());return this._onExperimentEval(e,s),s}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,featureUsageSubs:this._featureUsageSubs,experimentViewedSubs:this._experimentViewedSubs,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,contextualBandits:this._options.contextualBandits,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,s){let i=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!i)return null;let n=this._isAutoExperimentBlockedByContext(e),r,o;n?r=Ae(this._getEvalContext(),e,-1,!1,""):({result:r,trackingCall:o}=Sr(e,null,this._getEvalContext()),this._onExperimentEval(e,r));let a=JSON.stringify(r.value);if(!s&&r.inExperiment&&i&&i.valueHash===a)return r;if(i&&this._undoActiveAutoExperiment(e),r.inExperiment){let l=lr(e);if(l==="redirect"&&r.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?Fd(this._getContextUrl(),r.value.urlRedirect):r.value.urlRedirect;if(ar(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),r;this._redirectedUrl=c;let{navigate:u,delay:h}=this._getNavigateFunction();if(u)if(Qs)Promise.all([...o?[cr(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(d=>window.setTimeout(d,this._options.navigateDelay??h))]).then(()=>{try{u(c)}catch(d){console.error(d)}});else try{u(c)}catch(d){console.error(d)}}else if(l==="visual"){let c=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(r.value):this._applyDOMChanges(r.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return r}_undoActiveAutoExperiment(e){let s=this._activeAutoExperiments.get(e);s&&(s.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let s=this._options.experiments||[],i=new Set(s);this._activeAutoExperiments.forEach((n,r)=>{i.has(r)||(n.undo(),this._activeAutoExperiments.delete(r))});for(let n of s){let r=this._runAutoExperiment(n,e);if(r&&r.inExperiment&&lr(n)==="redirect")break}}_onExperimentEval(e,s){let i=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:s}),this._subscriptions.size>0&&this._fireSubscriptions(e,s,i)}_fireSubscriptions(e,s,i){(!i||i.result.inExperiment!==s.inExperiment||i.result.variationId!==s.variationId)&&this._subscriptions.forEach(n=>{try{n(e,s)}catch(r){console.error(r)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,s){let i=this.evalFeature(e).value;return i===null?s:i}feature(e){return this.evalFeature(e)}evalFeature(e){return wr(e,this._getEvalContext())}log(e,s){this.debug&&(this._options.log?this._options.log(e,s):console.log(e,s))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(s=>s&&s.experiment&&s.result).map(s=>[kr(s.experiment,s.result),s]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(s=>{!s||!s.experiment||!s.result?console.error("Invalid deferred tracking call",{call:s}):e.push(this._options.trackingCallback(s.experiment,s.result,s.user))}),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,s){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:s,timestamp:Date.now().toString(),logType:"event"}),this._customEventSubs.size&&this._customEventSubs.forEach(i=>{try{i(e,s||{})}catch(n){console.error(n)}}),this._options.eventLogger)try{await this._options.eventLogger(e,s||{},kt(this._getUserContext()))}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(kr(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(Qs?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let s=lr(e);if(s==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(i=>i.js))return!0}else if(s==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let i=new URL(this._getContextUrl());for(let n of e.variations){if(!n||!n.urlRedirect)continue;let r=new URL(n.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(r.protocol!==i.protocol||r.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}:Qs?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!Qs)return;let s=[];if(e.css){let i=document.createElement("style");i.innerHTML=e.css,document.head.appendChild(i),s.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),s.push(()=>i.remove())}return e.domMutations&&e.domMutations.forEach(i=>{s.push(nh.declarative(i).revert)}),()=>{s.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let s=this._getEvalContext(),i=await ph(s,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=i}}generateStickyBucketAssignmentDocsSync(e,s){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let i=this._getEvalContext(),n=$a(i,s);return e.getAllAssignmentsSync(n)}inDevMode(){return!!this._options.enableDevMode}}});var bh=Ze(()=>{"use strict";yh()});var Eh={};go(Eh,{Growthbook:()=>xa});var ft,xa,wh=Ze(()=>{"use strict";bh();ca();Di();Mi();ft=class ft{constructor(e,s,i={},n=!1){this.analytics=new zs;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=es("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:s,user_language:i,device_language:n,device_type:r,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:c,url:u,domain:h,utm_content:d,residence_country:g,loggedIn:p,network_type:m,network_downlink:v,user_id:b,anonymous_id:y,account_mode:w})=>{let I={...this.GrowthBook.getAttributes(),id:e,...b!==void 0&&{user_id:b},...y!==void 0&&{anonymous_id:y},...s!==void 0&&{country:s},...g!==void 0&&{residence_country:g},...i!==void 0&&{user_language:i},...n!==void 0&&{device_language:n},...r!==void 0&&{device_type:r},...o!==void 0&&{utm_source:o},...a!==void 0&&{utm_medium:a},...l!==void 0&&{utm_campaign:l},...c!==void 0&&{is_authorised:c},...u!==void 0&&{url:u},...h!==void 0&&{domain:h},...d!==void 0&&{utm_content:d},...p!==void 0&&{loggedIn:p},...m!==void 0&&{network_type:m},...v!==void 0&&{network_downlink:v},...w!==void 0&&{account_mode:w}};this.log("setAttributes | updating GrowthBook attributes",I),this.GrowthBook.setAttributes(I)};this.getFeatureValue=(e,s)=>{let i=this.GrowthBook.getFeatureValue(e,s);return this.log("getFeatureValue",{key:e,value:i,defaultValue:s}),i};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let s=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:s}),s};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let s=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:s}),s};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=n;let r=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new ji({apiHost:hd,clientKey:e,decryptionKey:s,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:r,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 s=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(s)}waitForIsLoaded(e=1e4){return new Promise((s,i)=>{let n=Date.now(),r=setInterval(()=>{this.isLoaded?(clearInterval(r),s()):Date.now()-n>=e&&(clearInterval(r),i(new Error("GrowthBook initialization timeout")))},100)})}};ft.getGrowthBookInstance=(e,s,i,n=!1)=>ft._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),ft._instance):(ft._instance=new ft(e,s??"",i,n),ft._instance),ft.resetInstance=()=>{ft._instance&&(ft._instance.destroy(),ft._instance=void 0)};xa=ft});function M(t,e){return t.indexOf(e)!==-1}function og(t){var e;let s=[];return(e=JSON.stringify(t,function(i,n){if(typeof n=="bigint")return n.toString();if(typeof n!="function"&&typeof n!="symbol"){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n=="object"){for(;s.length>0&&s[s.length-1]!==this;)s.pop();if(s.includes(n))return"[Circular]";s.push(n)}return n}}))!==null&&e!==void 0?e:"null"}function lg(t){return t===null||typeof t!="object"}function Br(t,e){return{}.toString.call(t)===`[object ${e}]`}function bi(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return cg(t,Error)}}function ec(t){return"u">typeof Event&&cg(t,Event)}function cg(t,e){try{return t instanceof e}catch{return!1}}function Ah(t,e,s,i,n,r,o){try{var a=t[r](o),l=a.value}catch(c){return void s(c)}a.done?e(l):Promise.resolve(l).then(i,n)}function he(t){return function(){var e=this,s=arguments;return new Promise(function(i,n){var r=t.apply(e,s);function o(l){Ah(r,i,n,o,a,"next",l)}function a(l){Ah(r,i,n,o,a,"throw",l)}o(void 0)})}}function Rt(t,e,s,i,n){return e>s&&(i.warn("min cannot be greater than max."),e=s),Te(t)?t>s?(i.warn(" cannot be greater than max: "+s+". Using max value instead."),s):e>t?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(i.warn(" must be a number. using max or fallback. max: "+s+", fallback: "+n),Rt(n??s,e,s,i))}function ci(t){let e="";for(let s=0;t.length>s;s++){let i=t.charCodeAt(s);if(55296>i||i>56319)e+=56320>i||i>57343?t[s]:"\uFFFD";else{let n=t.charCodeAt(s+1);56320>n||n>57343?e+="\uFFFD":(e+=t[s]+t[s+1],s++)}}return e}function Lg(t,e){if(!e)return t;let s=[];try{s=Object.keys(e)}catch{s=[]}for(let i of s){let n;try{n=e[i]}catch{n=En}Object.defineProperty(t,i,{value:n,enumerable:!0,writable:!0,configurable:!0})}return t}function Oh(t,e){return typeof(s=t)=="string"&&cS.test(s)?t:e();var s}function Bg(t,e){let s=new Error(e);try{Object.defineProperty(s,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch{}return s}function ds(t){return t&&t.split("#")[0]}function Ph(t){try{return t()}catch{return}}function Vg(t,e){let s=setTimeout(t,e);return s!=null&&s.unref&&s?.unref(),s}function $h(t,e,s){return jg.apply(this,arguments)}function jg(){return(jg=he(function*(t,e,s){let i;try{return yield Promise.race([t,new Promise((n,r)=>{i=Vg(()=>{try{s?.(),n()}catch(o){r(o)}},e)})])}finally{clearTimeout(i)}})).apply(this,arguments)}function nn(t){return nn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nn(t)}function uS(t,e,s){return(e=(function(i){var n=(function(r){if(nn(r)!="object"||!r)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var a=o.call(r,"string");if(nn(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)})(i);return nn(n)=="symbol"?n:n+""})(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function xh(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,i)}return s}function _(t){for(var e=1;arguments.length>e;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?xh(Object(s),!0).forEach(function(i){uS(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):xh(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function dS(t){var e;let s=globalThis._posthogChunkIds,i=globalThis._debugIds;if(!s&&!i)return;let n=s?Object.keys(s):[],r=i?Object.keys(i):[];if(Js&&Mh(s,n,Dh)&&Mh(i,r,Nh))return Js;Dh=s?_({},s):void 0,Nh=i?_({},i):void 0,Js={},(e=Hi)!==null&&e!==void 0||(Hi={});let o=(a,l)=>{for(let u of a){let h=l[u];if(!h)continue;let d=Hi?.[u];if(d){Js[d]=h;continue}let g=t(u);for(let p=g.length-1;p>=0;p--){var c;let m=(c=g[p])===null||c===void 0?void 0:c.filename;if(m){Js[m]=h,Hi[u]=m;break}}}};return i&&o(r,i),s&&o(n,s),Js}function Mh(t,e,s){return t&&s?e.length===Object.keys(s).length&&e.every(i=>t[i]===s[i]):t===s}function pS(t){if(!t||t==="<anonymous>")return!1;let e=fS.exec(t);return!e||gS.includes(e[1].toLowerCase())}function Il(t,e,s,i,n){let r={platform:t,filename:e,function:s==="<anonymous>"?"?":s,in_app:pS(e)};return S(i)||(r.lineno=i),S(n)||(r.colno=n),r}function sc(t,e){return t.filename===e.filename&&t.function===e.function&&t.module===e.module&&t.lineno===e.lineno&&t.colno===e.colno}function SS(t){for(let e=1;10>=e;e++){let s=t.length-2*e;if(0>s)break;let i=!0;for(let n=0;e>n;n++)if(!sc(t[s+n],t[s+e+n])){i=!1;break}if(i){for(let n=0;e>n;n++)t[s+n]=t[s+e+n];return t.length=s+e,{start:s,length:e}}}}function kS(t,e){let s=e.start+e.length,i=zg(t,e);i&&t.splice(s+i===t.length?s:e.start,i)}function Hg(t,e){let s=e.start;for(;s>0&&sc(t[s-1],t[s-1+e.length]);)s--;return e.start-s}function zg(t,e){let s=e.start+e.length,i=s;for(;t.length>i&&sc(t[i],t[i-e.length]);)i++;return i-s}function AS(t,e){let s=e[0],i=t.length-(s?Hg(t,s):0);for(let n of e)i-=zg(t,n);return i}function TS(t,e,s){for(let i=0;t.length>i;i++){let n=t[(e+i)%t.length],r=t[(s+i)%t.length];if(n!==r)return r>n}return!1}function qg(t,e=40){let s=Object.keys(t);if(s.sort(),!s.length)return"[object has no keys]";for(let i=s.length;i>0;i--){let n=s.slice(0,i).join(", ");if(e>=n.length)return i===s.length?n:n.length>e?`${n.slice(0,e)}...`:n}return""}function qr(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:Ua.enabled,max_bytes:US(t.max_bytes,Ua.max_bytes)}:_({},Ua)}function US(t,e){if(!Te(t)||t===1/0||t===-1/0)return e;let s=Math.floor(t);return 0>s?e:s}function Uh(t){return typeof t=="string"||t}function Bh(t){return typeof t=="string"?t:void 0}function Cl(){return Cl=he(function*(t,e=!0,s){try{let n=new TextEncoder().encode(t),r=new globalThis.CompressionStream("gzip"),o=r.writable.getWriter(),a=o.write(n).then(()=>o.close()).catch((i=he(function*(u){try{yield o.abort(u)}catch{}throw u}),function(u){return i.apply(this,arguments)})),l=new Response(r.readable).blob(),[c]=yield Promise.all([l,a]);return yield VS(c,n),c}catch(n){if(s?.rethrow)throw n;return e&&console.error("Failed to gzip compress data",n),null}var i}),Cl.apply(this,arguments)}function Kg(t,e){if(t==null)return{};var s,i,n=(function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.includes(c))continue;l[c]=o[c]}return l})(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(i=0;r.length>i;i++)e.includes(s=r[i])||{}.propertyIsEnumerable.call(t,s)&&(n[s]=t[s])}return n}function Ol(t){return(function(e){return KS.test(e)})(t)||XS.test(t)||ZS.test(t)}function Ba(t){return t.split("&",129).length>128}function lk(t,e,s){return Ol(t)||e.includes(";")&&(function(i){return i.split(";").some(n=>Ol(n.split("=",1)[0]))})(e)?je:Qg.test(e)?s?ic(e,{allowNestedUrls:!1,stripPunctuation:!0}):je:e}function Xg(t,e){let s=new URLSearchParams,i=!1,n=!1;for(let[r,o]of new URLSearchParams(t)){let a=Wr(r),l=Wr(o);i||(i=a!==r||l!==o);let c=lk(a,l,e);i||(i=c!==l),n=Ol(a)||c!==l,s.append(a,c)}return{changed:i,lastFieldSensitive:n,serialized:s.toString()}}function zh(t,e){if(!t.includes("="))return{value:ck(t,e),lastFieldSensitive:!1};let s=Xg(t,e);return{value:s.changed?s.serialized:t,lastFieldSensitive:s.lastFieldSensitive}}function ck(t,e){return e?ic(t,{allowNestedUrls:!1,stripPunctuation:!0}):Qg.test(t)?je:t}function uk(t,e,s){return t==="#"?!e.fragment&&(e.fragment=!0):t==="?"&&(e.fragment?s!=="="&&!e.fragmentQuery&&(e.fragmentQuery=!0):!e.query&&(e.query=!0))}function Va(t,e){var s;if(t.length>8192&&QS.test(t))return je;let{address:i,suffix:n}=e.stripPunctuation?(function(v){let b=v.length;for(;b>0&&".,;:!?)]}'".includes(v[b-1]);)b--;return{address:v.slice(0,b),suffix:v.slice(b)}})(t):{address:t,suffix:""},r;try{r=new URL(i)}catch{return je+n}let o=r.search.slice(1),a=r.hash!=="",l=(function(v){let b=v.slice(1),y=b.indexOf("?");return 0>y?{head:b,tail:null}:{head:b.slice(0,y),tail:b.slice(y+1)}})(r.hash);if(Ba(o)||Ba(l.head)||Ba((s=l.tail)!==null&&s!==void 0?s:""))return je+n;let c=!1;(r.username||r.password)&&(r.username=je,r.password="",c=!0);let u=Xg(o,e.allowNestedUrls);u.changed&&(r.search=u.serialized,c=!0);let h=zh(l.head,e.allowNestedUrls),d=l.tail===null?null:(g=l.tail,h.lastFieldSensitive?{value:g===""?"":je,lastFieldSensitive:!0}:zh(g,e.allowNestedUrls));var g;let p=d===null?h.value:`${h.value}?${d.value}`;p!==r.hash.slice(1)&&(r.hash=p,c=!0);let m=a?d??h:u;return(c?Wr(r.toString()):i)+(m.lastFieldSensitive?"":n)}function ic(t,e){return t.replace(Yg,s=>(function(i,n){let r=(function(l){if(!l.includes("://"))return[];let c=[...l.matchAll(JS)].map(m=>m.index),u=[],h={query:!1,fragment:!1,fragmentQuery:!1},d=0,g=!1,p="";for(let m=0;l.length>m&&c.length>d;m++){c[d]===m&&(m>0&&p!=="="&&u.push(m),d++);let v=l[m];uk(v,h,p)?(p=v,g=!0):g&&"=&".includes(v)&&(p=v)}return u})(i);if(r.length===0)return Va(i,n);let o="",a=0;for(let l of r)o+=Va(i.slice(a,l),_(_({},n),{},{stripPunctuation:!1})),a=l;return o+Va(i.slice(a),n)})(s,_(_({},e),{},{stripPunctuation:e.stripPunctuation&&s.length!==t.length})))}function Wr(t){return t.replace(WS,je)}function dk(t,e){return(function(s){return s.length>=10240&&(jS.test(s)||(function(i){let n=zS.exec(i);if(!n)return!1;let r;try{r=decodeURIComponent(i.slice(n[0].length))}catch{return!1}return qS.test(r.replace(/[\r\n]/g,""))})(s)||HS.test(s)&&GS.test(s))})(t)?"[binary data redacted - not supported by PostHog MCP analytics]":(function(s,i,n){let r=4*n.maxStringLength;if(s.length>r){let o=i(s.slice(0,(function(a,l){let c=l;for(;c>0&&!YS.test(a[c-1]);)c--;return c})(s,r)));if(o.length>=2*n.maxStringLength)return o+n.truncationSuffix}return i(s)})(t,s=>(function(i){return ic(i,{allowNestedUrls:!0,stripPunctuation:!0})})((function(i){let n=i.replace(ek," ");return n=n.replace(tk,je),n=n.replace(sk,je),n=n.replace(ik,`$1${je}`),n=n.replace(rk,fk),n=n.replace(nk,je),n=n.replace(ok,`$1${je}`),n=n.replace(ak,`$1${je}`),n})(Wr(s))),e)}function hk(t){let e=0,s=!1;for(let i=t.length-1;i>=0;i--){let n=t.charCodeAt(i)-48;if(0>n||n>9)return!1;s&&(n*=2,n>9&&(n-=9)),e+=n,s=!s}return e%10==0}function fk(t){let e=[];for(let r=Hh.exec(t);r!==null;r=Hh.exec(t))e.push({digits:r[0],start:r.index,end:r.index+r[0].length});let s="",i=0,n=0;for(;e.length>n;){let r="",o=-1;for(let a=n;e.length>a&&(r+=e[a].digits,19>=r.length);a++)r.length>=13&&hk(r)&&(o=a);0>o?n++:(s+=t.slice(i,e[n].start)+je,i=e[o].end,n=o+1)}return s+t.slice(i)}function Kr(t,e){try{return Zg(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function nc(t,e,s,i){if(0>=s.remainingNodes)return{stringValue:Tl};if(s.remainingNodes--,Je(t))return{boolValue:t};if(typeof t=="bigint")return(function(n,r){let o=n.toString(),a=BigInt("9223372036854775808");return n>=a||-a>n?(r?.debug(`Attribute ${o} is outside the int64 range; encoding it as a string`),{stringValue:o}):{intValue:o}})(t,e);if(typeof t=="number"){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};let n=BigInt(t).toString();return t>=9223372036854776e3||-9223372036854776e3>t?(e?.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}return{doubleValue:t}}if(typeof t=="string")return{stringValue:ci(t)};if(typeof t=="function")return{stringValue:"[Function]"};if(typeof t=="symbol")return{stringValue:String(t)};if(typeof t=="object"&&t!==null){if(s.ancestors.has(t))return{stringValue:"[Circular]"};if(i>=20)return{stringValue:Tl};if(t instanceof Date){let n=t.getTime(),r=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:typeof r=="string"?ci(r):String(r)}}s.ancestors.add(t);try{try{let n=t.toJSON;if(typeof n=="function")return nc(n.call(t),e,s,i+1)}catch{}return N(t)?{arrayValue:{values:pk(t,e,s,i+1)}}:{kvlistValue:{values:Zg(t,e,s,i+1)}}}finally{s.ancestors.delete(t)}}return{stringValue:ci(String(t))}}function pk(t,e,s,i){let n=[],r=Math.min(t.length,1e3),o=0;for(;r>o&&s.remainingNodes>0;o++)try{let a=o in t?t[o]:void 0;if(B(a))continue;n.push(nc(a,e,s,i))}catch{n.push({stringValue:En})}return t.length>o&&n.push({stringValue:Tl}),n}function Zg(t,e,s,i){let n=[];for(let r in t)if(gk.call(t,r)){if(!r){e?.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=s.remainingNodes){e?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{let o=t[r];if(we(o)||S(o))continue;n.push({key:ci(r),value:nc(o,e,s,i)})}catch{n.push({key:ci(r),value:{stringValue:En}})}}return n}function ep(t,e,s){return _(_(_(_({},Lg({},t.resourceAttributes)),{},{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment}),t.serviceVersion&&{"service.version":t.serviceVersion}),{},{"telemetry.sdk.name":e,"telemetry.sdk.version":s})}function tp(t,e){let s=Lg({},t),i={};for(let n of vk)({}).hasOwnProperty.call(s,n)&&(i[n]=s[n],delete s[n]);return[...Kr(s,e),...Kr(i,e)]}function mk(t){try{return ci(String(t))}catch{return En}}function yk(t,e,s,i){let n=t.level||"info",{text:r,number:o}=sp[n]||_k,a=(function(d=Date.now()){return String(d)+"000000"})(Te(i)?i:void 0),l={};e.distinctId&&(l.posthogDistinctId=e.distinctId),e.sessionId&&(l.sessionId=e.sessionId),e.windowId&&(l["window.id"]=e.windowId),B(e.sessionStartTimestamp)||(l.sessionStartTimestamp=String(e.sessionStartTimestamp)),B(e.lastActivityTimestamp)||(l.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(l["url.full"]=e.currentUrl),e.screenName&&(l["screen.name"]=e.screenName),e.appState&&(l["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(l.feature_flags=e.activeFeatureFlags);let c=_({},l),u=t.attributes;if(u){let d=[];try{d=Object.keys(u)}catch{d=[]}for(let g of d){let p;try{p=u[g]}catch{p=En}Object.defineProperty(c,g,{value:p,enumerable:!0,writable:!0,configurable:!0})}}let h={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:mk(t.body)},attributes:Kr(c,s)};return t.trace_id&&(h.traceId=t.trace_id),t.span_id&&(h.spanId=t.span_id),S(t.trace_flags)||(h.flags=t.trace_flags),h}function ip(t,e,s){return ep(t,e,s)}function np(t,e,s,i){return{resourceLogs:[{resource:{attributes:tp(e)},scopeLogs:[{scope:{name:s,version:i},logRecords:t}]}]}}function op(){return .75+.5*Math.random()}function ap(t,e,s,i){let n=Math.min(Math.max(0,e-1),6),r=t*Math.pow(2,n);return Math.round((i===void 0?r:Math.min(r,Math.max(i,t)))*s)}function Wh(t){return String(t)+"000000"}function Kh(t,e,s,i){let n="";return i&&(n=Object.keys(i).sort().map(r=>`${JSON.stringify(r)}:${JSON.stringify(i[r])}`).join(",")),`${t}\0${e}\0${s??""}\0${n}`}function ai(t,e){N(t)&&t.forEach(e)}function re(t,e){if(!B(t))if(N(t))t.forEach(e);else if((s=>s instanceof FormData)(t))t.forEach((s,i)=>e(s,i));else for(let s in t)Zl.call(t,s)&&e(t[s],s)}function Fr(t){let e=Object.keys(t),s=e.length,i=new Array(s);for(;s--;)i[s]=[e[s],t[e[s]]];return i}function $p(t){let e=_({},t);for(let s of["name","message","stack","cause","errors"])try{s in t&&(e[s]=t[s])}catch{}return e}function qk(t){let e=t?.hostname;if(!H(e))return!1;let s=e.split(".").slice(-2).join(".");for(let i of zk)if(s===i)return!1;return!0}function se(t,e,s,i){let{capture:n=!1,passive:r=!0}=i??{};t?.addEventListener(e,s,{capture:n,passive:r})}function Ul(t){return t.name==="ph_toolbar_internal"}function Np(t,e){var s;let i=t==null||(s=t.config)===null||s===void 0?void 0:s.get_current_url;if(!Ce(i))return e;try{let n=i(e);return H(n)&&n?n:e}catch(n){return R.error("Error in get_current_url, falling back to window.location.href",n),e}}function nf(t){var e;return t instanceof Element&&(t.id==="__POSTHOG_TOOLBAR__"||!!(!((e=t.closest)===null||e===void 0)&&e.call(t,".toolbar-global-fade-container")))}function Et(t){return!!t&&t.nodeType===1}function Ue(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Mp(t){return!!t&&t.nodeType===3}function gc(t){return!!t&&t.nodeType===11&&Et(t.host)}function pc(t){return t?hi(t).split(/\s+/):[]}function rf(t,e){let s=(function(i){var n;let r=E==null||(n=E.location)===null||n===void 0?void 0:n.href;return S(r)?void 0:Np(i,r)})(e);return!!(s&&t&&t.some(i=>s.match(i)))}function gi(t){let e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return pc(e)}function Fp(t){return B(t)?null:hi(t).split(/(\s+)/).filter(e=>di(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function mn(t){let e="";return Ms(t)&&!pi(t)&&t.childNodes&&t.childNodes.length&&re(t.childNodes,function(s){var i;Mp(s)&&s.textContent&&(e+=(i=Fp(s.textContent))!==null&&i!==void 0?i:"")}),hi(e)}function cn(t){var e;return S(t.target)?t.srcElement||null:!((e=t.target)===null||e===void 0)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}function jl(t,e){let s=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!s&&s.call(t,e)}catch{return!1}}function Gl(t,e){if(S(e))return!0;for(let s of t)if(e.some(i=>jl(s,i)))return!0;return!1}function Lp(t){let e=t.parentNode;return!(!e||!Et(e))&&e}function Xa(t){let e="",s="",i=o=>{Et(o)&&Ms(o)&&!pi(o)&&(e+=` ${mn(o)}`,s=s||o.getAttribute("aria-label")||"",re(o.childNodes,i))};i(t),e=hi(e.replace(/\s+/g," "));let n=(di(e)?e:"").toLowerCase(),r=t.getAttribute("aria-label")||(n?"":s);return{safeText:n,ariaLabel:hi(r).toLowerCase()}}function Bp(t,e){if(!E||mc(t))return!1;let s,i,n;var r,o;if(Je(e)?(s=!!e&&lf,i=void 0,n=!1):(s=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:lf,i=e?.content_ignorelist,n=(o=e?.ignore_text_selection)!==null&&o!==void 0&&o),s===!1||n&&(function(l){return!(!l||!Et(l))&&(!!Ue(l,"textarea")||(Ue(l,"input")?M(iA,(l.getAttribute("type")||"").toLowerCase()):(function(c){var u;if(c.isContentEditable)return!0;let h=(u=c.getAttribute)===null||u===void 0?void 0:u.call(c,"contenteditable");return h==="true"||h===""})(l)))})(t))return!1;let{targetElementList:a}=Vp(t,!1);return!(i&&(function(l,{safeText:c,ariaLabel:u}){let h;if(l===!0)h=Up;else{if(!N(l))return!1;if(l.length>of)return R.error(`[PostHog] content_ignorelist array cannot exceed ${of} items. Use css_selector_ignorelist for more complex matching.`),!1;h=l.map(d=>d.toLowerCase())}return h.some(d=>af(c,d)||af(u,d))})(i,(function(l,c){for(let u of c)if(sA(u))return Xa(u);for(let u of c){try{if(E?.getComputedStyle(u).getPropertyValue("cursor")!=="pointer")break}catch{break}let h=Xa(u);if(h.safeText||h.ariaLabel)return h}return Xa(l)})(t,a))||Gl(a,s))}function Ms(t){let e=new Set,s=0;for(let r=t;r.parentNode&&!Ue(r,"body");r=r.parentNode){if(s++>=1e3||e.has(r))return!1;e.add(r);let o=gi(r);if(M(o,"ph-sensitive")||M(o,"ph-no-capture"))return!1}if(M(gi(t),"ph-include"))return!0;let i=t.type||"";if(H(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}let n=t.name||t.id||"";return!H(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function pi(t){return!!(Ue(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Ue(t,"select")||Ue(t,"textarea")||t.getAttribute("contenteditable")==="true")}function oA(t){let e=0,s=!1;for(let i=t.length-1;i>=0;i--){let n=t.charCodeAt(i)-48;s&&(n*=2,n>9&&(n-=9)),e+=n,s=!s}return e%10==0}function di(t,e=!0){return!(B(t)||H(t)&&(t=hi(t),(e?cf.test((t||"").replace(/[- ]/g,"")):(function(s){let i;for(uf.lastIndex=0;i=uf.exec(s);){let n=i[2];if(!n)continue;let r=n.replace(/[- ]/g,"");for(let o=0;r.length>o;o++)for(let a of nA){let l=o+a;if(r.length>=l){let c=r.slice(o,l);if(cf.test(c)&&oA(c))return!0}}}return!1})(t))||(e?rA.test(t):(function(s){let i;for(df.lastIndex=0;i=df.exec(s);){let n=i[1],r=i[3];if(!(n&&r&&hf.test(n)&&hf.test(r)))return!0}return!1})(t))))}function ff(t){let e=mn(t);return e=`${e} ${jp(t)}`.trim(),di(e)?e:""}function jp(t){let e="";return t&&t.childNodes&&t.childNodes.length&&re(t.childNodes,function(s){var i;if(s&&((i=s.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{let n=mn(s);e=`${e} ${n}`.trim(),s.childNodes&&s.childNodes.length&&(e=`${e} ${jp(s)}`.trim())}catch(n){R.error("[AutoCapture]",n)}}),e}function gf(t){return t.replace(/"|\\"/g,'\\"')}function aA(t){let e=t.attr__class;if(e)return N(e)?e:pc(e)}function vf(t,e,s=!0){let i=t.config.segment;if(!i)return e();let{analytics:n,filterProperties:r}=(a=>Ce(a.register))(o=i)?{analytics:o}:o;var o;(function(a,l,c,u){let h=g=>{let p=()=>g.anonymousId()||bt();a.config.get_device_id=p,u&&g.id()&&(a.register({distinct_id:g.id(),$device_id:p()}),a.persistence.set_property(Qe,Mr)),c(u?void 0:g.anonymousId()||void 0)},d=l.user();"then"in d&&Ce(d.then)?d.then(h):h(d)})(t,n,a=>{n.register(((l,c,{filterProperties:u}={})=>{typeof Promise<"u"&&Promise.resolve||Wi.warn("This browser does not have Promise support, and can not use the segment integration");let h=(d,g)=>{if(!g)return d;let p=!!c&&d.event.anonymousId===c&&!d.event.userId;p||d.event.userId||d.event.anonymousId===l.get_distinct_id()||(Wi.info("No userId set, resetting PostHog"),l.reset()),p||(c=void 0),d.event.userId&&d.event.userId!==l.get_distinct_id()&&(Wi.info("UserId set, identifying with PostHog"),l.identify(d.event.userId));let m=l.calculateEventProperties(g,d.event.properties);if(!B(u)){let v=d.event.properties||{},b={};for(let w of Object.keys(m))Zl.call(v,w)||(b[w]=m[w]);let y=((w,A)=>{let I=N(w)?w:[w],k=_({},A);for(let $ of I)try{if(k=$(k),B(k))return null}catch(O){return Wi.error("Error in Segment filterProperties:",O),null}return k})(u,b);if(B(y))return d;m=y}return d.event.properties=Object.assign({},m,d.event.properties),d};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(d){return h(d,d.event.event)},page(d){return h(d,hc)},identify(d){return h(d,Pp)},screen(d){return h(d,"$screen")}}})(t,a,{filterProperties:r})).then(()=>{e()},l=>{Wi.error("Failed to register the Segment integration",l),e()})},s)}function Hp(t,{organization:e,projectId:s,prefix:i,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,h;if(n!=="*"&&!n.includes(o.level)||!t.__loaded)return o;o.tags||(o.tags={});let d=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);o.tags["PostHog Person URL"]=d,t.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));let g=((a=o.exception)===null||a===void 0?void 0:a.values)||[],p=g.map(b=>_(_({},b),{},{stacktrace:b.stacktrace?_(_({},b.stacktrace),{},{type:"raw",frames:(b.stacktrace.frames||[]).map(y=>_(_({},y),{},{platform:"web:javascript"}))}):void 0})),m={$exception_message:((l=g[0])===null||l===void 0?void 0:l.value)||o.message,$exception_type:(c=g[0])===null||c===void 0?void 0:c.type,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((u=g[0])===null||u===void 0?void 0:u.value)||o.message,$sentry_exception_type:(h=g[0])===null||h===void 0?void 0:h.type,$sentry_tags:o.tags};var v;return e&&s&&(m.$sentry_url=(i||"https://sentry.io/organizations/")+e+"/issues/?project="+s+"&query="+o.event_id),r&&((v=t.exceptions)===null||v===void 0||v.sendExceptionEvent(m)),o}}function zp(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Yp(t,e,s){if(!T)return{};let i=e?[..._i,...s||[]]:[],n=Qp(yn(T.URL,i,bn),t),r=(function(){let o={};return re(gA,function(a){let l=ln(a);o[a]=l||null}),o})();return ve(r,n)}function Qp(t,e){let s=fA.concat(e||[]),i={};return re(s,function(n){let r=vi(t,n);i[n]=r||null}),i}function Jp(t){let e=(function(n){return n?n.search("https?://(.*)google.([^/?]*)")===0?"google":n.search("https?://(.*)bing.com")===0?"bing":n.search("https?://(.*)yahoo.com")===0?"yahoo":n.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(t),s=e!="yahoo"?"q":"p",i={};if(!we(e)){i.$search_engine=e;let n=T?vi(T.referrer,s):"";n.length&&(i.ph_keyword=n)}return i}function Xp(){return navigator.language||navigator.userLanguage}function pA(){let t=Xp();return typeof t=="string"?t.split("-")[0]:void 0}function Zp(){return T?.referrer||to}function ev(t,e,s=!1){let i=t?[..._i,...e||[]]:[],n=s?ds(pe?.href):pe?.href,r=n?.substring(0,1e3);return{r:Zp().substring(0,1e3),u:r?yn(r,i,bn):void 0}}function tv(t,e=!1){var s;let{r:i,u:n}=t,r=e?ds(n):n,o={$referrer:i,$referring_domain:i==null?void 0:i==to?to:(s=Kt(i))===null||s===void 0?void 0:s.host};if(r){o.$current_url=r;let a=Kt(r);o.$host=a?.host,o.$pathname=a?.pathname;let l=Qp(r);ve(o,l)}if(i){let a=Jp(i);ve(o,a)}return o}function vA(){try{return new Date().getTimezoneOffset()}catch{return}}function il(t){let e=!0;return{dispose(){if(e){e=!1;let s=t();s&&Ce(s.then)&&s.then(void 0,()=>{})}}}}function TA(t,e){e===void 0&&(e={});var s=(function(){var d=4294967295;return{p(g){for(var p=d,m=0;g.length>m;++m)p=AA[255&p^g[m]]^p>>>8;d=p},d(){return 4294967295^d}}})(),i=t.length;s.p(t);var n,r,o,a,l,c,u=(a=10+((n=e).filename&&n.filename.length+1||0),l=8,(function(d,g,p,m,v,b){var y=d.length,w=new dt(m+y+5*(1+Math.floor(y/7e3))+v),A=w.subarray(m,w.length-v),I=0;if(!g||8>y)for(var k=0;y>=k;k+=65535){var $=k+65535;y>$?I=Lr(A,I,d.subarray(k,$)):(A[k]=b,I=Lr(A,I,d.subarray(k,y)))}else{for(var O=SA[g-1],x=O>>>13,Y=8191&O,X=(1<<p)-1,Z=new Xe(32768),ae=new Xe(X+1),D=Math.ceil(p/3),K=2*D,q=function(fo){return(d[fo]^d[fo+1]<<D^d[fo+2]<<K)&X},ie=new mi(25e3),Q=new Xe(288),P=new Xe(32),U=0,V=0,W=(k=0,0),ee=0,le=0;y>k;++k){var _e=q(k),Re=32767&k,xe=ae[_e];if(Z[Re]=xe,ae[_e]=Re,k>=ee){var Me=y-k;if((U>7e3||W>24576)&&Me>423){I=kf(d,A,0,ie,Q,P,V,W,le,k-le,I),W=U=V=0,le=k;for(var Be=0;286>Be;++Be)Q[Be]=0;for(Be=0;30>Be;++Be)P[Be]=0}var z=2,Ct=0,Lv=Y,Yt=Re-xe&32767;if(Me>2&&_e==q(k-Yt))for(var Uv=Math.min(x,Me)-1,Bv=Math.min(32767,k),Vv=Math.min(258,Me);Bv>=Yt&&--Lv&&Re!=xe;){if(d[k+z]==d[k+z-Yt]){for(var Qt=0;Vv>Qt&&d[k+Qt]==d[k+Qt-Yt];++Qt);if(Qt>z){if(z=Qt,Ct=Yt,Qt>Uv)break;var jv=Math.min(Yt,Qt-2),kc=0;for(Be=0;jv>Be;++Be){var ho=k-Yt+Be+32768&32767,Ac=ho-Z[ho]+32768&32767;Ac>kc&&(kc=Ac,xe=ho)}}}Yt+=(Re=xe)-(xe=Z[Re])+32768&32767}if(Ct){ie[W++]=268435456|zl[z]<<18|ql[Ct];var Tc=31&zl[z],Ic=31&ql[Ct];V+=yc[Tc]+bc[Ic],++Q[257+Tc],++P[Ic],ee=k+z,++U}else ie[W++]=d[k],++Q[d[k]]}}I=kf(d,A,b,ie,Q,P,V,W,le,k-le,I),b||(I=Lr(A,I,kA))}return av(w,0,m+ov(I)+v)})(r=t,(o=e).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,a,l,!c)),h=u.length;return(function(d,g){var p=g.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>g.level?4:g.level==9?2:0,d[9]=3,g.mtime!=0&&rl(d,4,Math.floor(new Date(g.mtime||Date.now())/1e3)),p){d[3]=8;for(var m=0;p.length>=m;++m)d[m+10]=p.charCodeAt(m)}})(u,e),rl(u,h-8,s.d()),rl(u,h-4,i),u}function mv(t,e,s){var i,n,r;s&&(e=_(_({},e),{},{callback:o=>s(o)})),t.__loaded?_v?t.__request_queue.push(e):t.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&((n=e.callback)===null||n===void 0||n.call(e,{statusCode:429})):(e.transport=e.transport||t.config.api_transport,e.headers=_(_({},t.config.request_headers),e.headers),e.compression=e.compression==="best-available"?(i=t.compression)!==null&&i!==void 0?i:e.compressionFallback:e.compression,(S(t.config.disable_beacon)?t.config.__preview_disable_beacon:t.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||t.config.fetch_options,((o,a)=>{var l,c,u;let h=_(_({},o),{},{callback:a??(v=>{var b;return(b=o.callback)===null||b===void 0?void 0:b.call(o,v)})});h.timeout=h.timeout||6e4;let d=(l=h.transport)!==null&&l!==void 0?l:"fetch";d==="sendBeacon"&&S(h.compression)&&h.data&&(h.compression=ut.Base64),h.method==="POST"&&h.data&&(h.timestampMode==="capture-body"?h.data=(v=>{var b,y;let w=(N(v)?v:[v]).map(I=>_(_({},I),I.timestamp instanceof Date&&!isNaN(I.timestamp.getTime())?{timestamp:I.timestamp.toISOString()}:{})),A=w[0];return{api_key:(b=A==null||(y=A.properties)===null||y===void 0?void 0:y.token)!==null&&b!==void 0?b:A?.token,batch:w,sent_at:new Date().toISOString()}})(h.data):h.timestampMode==="body"&&(h.data=((v,b=new Date().toISOString())=>N(v)?v.map(y=>_(_({},y),{},{sent_at:b})):_(_({},v),{},{sent_at:b}))(h.data))),h.url=Af(h.url,h.method,h.compression,h.timestampMode);let g=OA.filter(v=>!h.disableTransport||!v.transport||!h.disableTransport.includes(v.transport)),p=(c=(u=(function(v,b){for(let y=0;v.length>y;y++)if(b(v[y]))return v[y]})(g,v=>v.transport===d))===null||u===void 0?void 0:u.method)!==null&&c!==void 0?c:g[0].method;if(!p)throw new Error("No available transport method");let m=v=>{try{p(v)}catch(y){var b;fv(y)?R.warn(y):R.error(y),(b=h.callback)===null||b===void 0||b.call(h,{statusCode:0,error:y})}};d!=="sendBeacon"&&!h.preferSyncCompression&&h.data&&h.compression===ut.GZipJS&&qw&&typeof Promise<"u"&&!Ur?RA(h).then(v=>{m(v)}).catch(v=>{if(jh(v))return Ur=!0,void m(_(_({},h),{},{compression:void 0,url:Af(o.url,o.method,void 0,o.timestampMode)}));(b=>{if(!b||typeof b!="object")return!1;let y="name"in b?String(b.name):"";return jh(b)||y===Wg})(v)&&(Ur=!0),m(h)}):m(h)})(e,(o,a)=>{var l,c,u;t.rateLimiter.checkForLimiting(o),400>o.statusCode||(l=(c=t.config).on_request_error)===null||l===void 0||l.call(c,o),s?s(o,a):(u=e.callback)===null||u===void 0||u.call(e,o)})):e.fireCallbackOnDrop&&((r=e.callback)===null||r===void 0||r.call(e,{statusCode:0}))}function bv(){return(bv=he(function*(){let t=Le?.userAgentData;if(t?.getHighEntropyValues)try{let e=yield t.getHighEntropyValues(["model"]),s=e?.model;return H(s)&&s.length>0?s:void 0}catch(e){return void R.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function MA(t,e){let s=`$survey_${e}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(s=`$survey_${e}/${t.id}/${t.current_iteration}`),s}function Ev(t){var e;return!!(!((e=t.conditions)===null||e===void 0||(e=e.events)===null||e===void 0||(e=e.values)===null||e===void 0)&&e.length)}function Sv(t,e){return!t||Object.entries(t).every(([s,i])=>{let n=e?.[s];if(n==null)return!1;let r=wv[i.operator];return!!r&&r(i.values.map(String),[String(n)])})}function ll(t,e,s){return li({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:s})}function fl(t,e){return e.length>t?e.slice(0,t)+"...":e}function eT(t){if(t.previousElementSibling)return t.previousElementSibling;let e=t;do e=e.previousSibling;while(e&&!Et(e));return e}function tT(t,{e,maskAllElementAttributes:s,maskAllText:i,elementAttributeIgnoreList:n,elementsChainAsString:r,disableCaptureUrlHashes:o}){var a,l;if(!Et(t))return{props:{}};let c=[t],u=new Set([t]),h=t;for(;h.parentNode&&!Ue(h,"body")&&1e3>c.length;){if(gc(h.parentNode)){let k=h.parentNode.host;if(u.has(k))break;u.add(k),c.push(k),h=k;continue}if(!Et(h.parentNode)||u.has(h.parentNode))break;u.add(h.parentNode),c.push(h.parentNode),h=h.parentNode}let d=e.type==="click"&&t.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(k=>Ue(k,"button")||Ue(k,"a")):-1;d>0&&(i=i||c.slice(0,d+1).some(k=>!Ms(k)||pi(k)));let g=[],p={},m,v=!1,b=!1;if(re(c,k=>{let $=Ms(k);if(Ue(k,"a")&&!s&&!n?.includes("href")){let O=k.getAttribute("href");v=!!($&&O&&di(O))&&(o?ds(O):O)}M(gi(k),"ph-no-capture")&&(b=!0),g.push((function(O,x,Y,X,Z=!1){let ae=O.tagName.toLowerCase(),D={tag_name:ae};vc.indexOf(ae)>-1&&!Y&&(D.$el_text=ae.toLowerCase()==="a"||ae.toLowerCase()==="button"?fl(1024,ff(O)):fl(1024,mn(O)));let K=gi(O);x||X?.includes("class")||0>=K.length||(D.classes=K.filter(function(P){return P!==""})),re(O.attributes,function(P){var U;if((!pi(O)||["name","id","class","aria-label"].indexOf(P.name)!==-1)&&!X?.includes(P.name)&&!x&&di(P.value)&&(!H(U=P.name)||U.substring(0,10)!=="_ngcontent"&&U.substring(0,7)!=="_nghost")){let V=P.value;P.name==="class"&&(V=pc(V).join(" ")),D["attr__"+P.name]=fl(1024,P.name==="href"&&Z?ds(V):V)}});let q=1,ie=1,Q=O;for(;Q=eT(Q);)q++,Q.tagName===O.tagName&&ie++;return D.nth_child=q,D.nth_of_type=ie,D})(k,s,i,n,o)),re((function(O){if(!Ms(O))return{};let x={};return re(O.attributes,function(Y){if(Y.name&&Y.name.indexOf("data-ph-capture-attribute")===0){let X=Y.name.replace("data-ph-capture-attribute-",""),Z=Y.value;X&&Z&&di(Z)&&(x[X]=Z)}}),x})(k),(O,x)=>{({}).hasOwnProperty.call(p,x)||(p[x]=O)})}),b)return{props:{},explicitNoCapture:b};if(d>0&&(t=c[d],g.splice(0,d)),i||(g[0].$el_text=Ue(t,"a")||Ue(t,"button")?ff(t):mn(t)),v){var y,w;g[0].attr__href=v;let k=(y=Kt(v))===null||y===void 0?void 0:y.host,$=E==null||(w=E.location)===null||w===void 0?void 0:w.host;k&&$&&k!==$&&(m=v)}return{props:ve((I=e.type,{$event_type:I,$ce_version:1}),r?{}:{$elements:g},{$elements_chain:(A=g,N(A)?(function(k){return k.map($=>{var O,x;let Y="";if($.tag_name&&(Y+=$.tag_name),$.attr_class){$.attr_class.sort();for(let ae of $.attr_class)Y+=`.${ae.replace(/"/g,"")}`}let X=_(_(_(_({},$.text?{text:$.text}:{}),{},{"nth-child":(O=$.nth_child)!==null&&O!==void 0?O:0,"nth-of-type":(x=$.nth_of_type)!==null&&x!==void 0?x:0},$.href?{href:$.href}:{}),$.attr_id?{attr_id:$.attr_id}:{}),$.attributes),Z={};return Fr(X).sort(([ae],[D])=>(function(K,q){return q>K?-1:K>q?1:0})(ae,D)).forEach(([ae,D])=>Z[gf(ae.toString())]=gf(D.toString())),Y+=":",Y+=Fr(Z).map(([ae,D])=>`${ae}="${D}"`).join(""),Y}).join(";")})((function(k){return k.map($=>{var O,x;let Y={text:(O=$.$el_text)===null||O===void 0?void 0:O.slice(0,400),tag_name:$.tag_name,href:(x=$.attr__href)===null||x===void 0?void 0:x.slice(0,2048),attr_class:aA($),attr_id:$.attr__id,nth_child:$.nth_child,nth_of_type:$.nth_of_type,attributes:{}};return Fr($).filter(([X])=>X.indexOf("attr__")===0).forEach(([X,Z])=>Y.attributes[X]=Z),Y})})(A)):"")},!((a=g[0])===null||a===void 0)&&a.$el_text?{$el_text:(l=g[0])===null||l===void 0?void 0:l.$el_text}:{},m&&e.type==="click"?{$external_click_url:m}:{},p),target:t};var A,I}function yi(t,e,s){try{if(!(e in t))return Mf;let i={next:t[e]},n=s(function(...r){return i.next.apply(this,r)});return Ce(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:i}})),t[e]=n,()=>{if(t[e]===n)return void(t[e]=i.next);let r=t[e],o=Ff(r);for(;o;){if(o.next===n)return void(o.next=i.next);r=o.next,o=Ff(r)}}}catch{return Mf}}function pl(t){return G(t)&&"clientX"in t&&"clientY"in t&&Te(t.clientX)&&Te(t.clientY)}function ni(t,e,s){if(B(t))return!1;switch(s){case"exact":return t===e;case"contains":{let i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(t)}case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}function Zf(t,e){var s,i,n,r,o,a,l;let c=(s=t?.flushIntervalMs)!==null&&s!==void 0?s:3e3,u=(i=t?.maxBufferSize)!==null&&i!==void 0?i:100,h=e?.consoleCapture?void 0:(n=t?.maxLogsPerInterval)!==null&&n!==void 0?n:1e3,d=S(h)?Math.max(u,2048):Math.max(u,h),g=_(_({},(function(){let p="",m="";try{var v;let b="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,y=b==null||(v=b.navigator)===null||v===void 0?void 0:v.userAgent;y&&([p,m]=Mg(y))}catch{}return(function(b,y){let w=(function(A){if(A)return{}.hasOwnProperty.call(qh,A)?qh[A]:A})(b);return _(_({},w?{"os.name":w}:{}),y?{"os.version":y}:{})})(p,m)})()),t?.resourceAttributes);return{serviceName:(r=(o=g?.["service.name"])!==null&&o!==void 0?o:t?.serviceName)!==null&&r!==void 0?r:e?.serviceNameDefault,serviceVersion:(a=g?.["service.version"])!==null&&a!==void 0?a:t?.serviceVersion,environment:(l=g?.["deployment.environment"])!==null&&l!==void 0?l:t?.environment,resourceAttributes:g,beforeSend:t?.beforeSend,flushIntervalMs:c,maxBufferSize:u,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}function ig(t){if(t)return t===!0?{intent:!0,model:!0}:{intent:t.intent!==!1,model:t.model!==!1}}function yl(t,e){return{}.hasOwnProperty.call(t,e)}function bl(t,e){let s=Object.create(t);return e&&Object.defineProperty(s,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),s}function ng(t,e,s=!1){if(!H(t))return;let i=t.trim();return i?(s?dk(i,$T):i).slice(0,e):void 0}function rg(t){try{return G(t)&&t.isError===!0}catch{return!1}}var E,Ge,Le,T,pe,gn,Xl,Sh,qw,Ye,Gi,L,kh,Wt,It,El,Ww,Kw,hi,wl,ag,Zl,ao,N,Ce,G,nt,S,H,sn,we,B,Te,Gt,Je,Yw,Qw,Jw,Da,Xw,Zw,Ar,Th,eS,fi,pn,Vr,ug,dg,hg,$r,lo,fg,xr,gg,pg,vg,_g,mg,Dr,yg,jr,Gr,co,bg,Eg,Na,wg,Ih,Sl,tS,Sg,kl,kg,Ag,Tg,Ig,Rg,Cg,Og,Al,Pg,$g,xg,Dg,Ma,Fa,sS,iS,nS,tc,rS,Ng,oS,aS,Rh,Mg,Fg,lS,La,Ch,Tl,En,Nr,Ug,cS,Hi,Dh,Nh,Js,hS,fS,gS,Gg,vS,_S,mS,yS,bS,ES,wS,Fh,IS,RS,CS,OS,PS,$S,xS,DS,NS,MS,Hr,zr,FS,Ua,LS,Lh,BS,Wg,Rl,Vh,jh,zi,Tr,VS,Gh,je,jS,GS,HS,zS,qS,WS,KS,Yg,YS,Qg,Jg,QS,JS,XS,ZS,ek,tk,sk,ik,nk,rk,Hh,ok,ak,gk,vk,qh,sp,_k,rp,bk,ja,Ek,lp,R,ye,wk,Yr,Ps,Ga,Yh,it,Pl,zt,Ds,vn,us,Ns,rn,yt,os,as,ls,Zi,cs,Tt,$s,_n,Sk,mt,rc,Ha,Qr,kk,Qh,ui,Jh,on,$l,cp,xl,Dl,up,Nl,Ml,oc,ac,dp,hp,an,Ak,Tk,Ik,Rk,Ck,Ok,ri,fp,Pk,$k,xk,Dk,Nk,gp,en,Jr,pp,vp,_p,Fl,Mk,Fk,Lk,Uk,Bk,Vk,Qe,Ll,jk,mp,yp,oi,lc,za,bp,Ep,wp,cc,uc,Sp,kp,Ap,Tp,Ip,Rp,Cp,Gk,dc,qt,Mr,Op,Xr,hc,Xh,Pp,Zh,ve,Hk,fc,zk,ln,Wk,Kk,xp,Yk,ef,bt,Qk,qi,Jk,Xs,Ee,qa,J,Wa,xs,Zr,Xk,Ka,Ya,Dp,tf,sf,Qa,Zs,Vl,Ts,de,Zk,vc,Ja,Up,_c,of,eA,tA,af,sA,lf,iA,mc,Vp,cf,uf,nA,rA,df,hf,Ir,lA,cA,pf,Wi,Gp,uA,_f,Ki,dA,hA,Ne,qp,Wp,Kp,li,Kt,vi,yn,eo,_i,fA,bn,gA,to,_A,mA,Rr,Cr,Pe,Ht,Za,sv,mf,is,ei,yf,el,ut,Yi,tl,ct,sl,Hl,yA,bf,Ef,bA,ns,iv,dt,Xe,mi,yc,bc,wf,nv,rv,zl,Is,ql,so,me,un,Fs,io,EA,wA,ov,av,Vt,Qi,nl,Wl,Sf,Ji,Lr,kf,SA,kA,AA,rl,IA,lv,cv,ol,Ur,uv,wn,al,dv,hv,RA,CA,fv,gv,pv,vv,Kl,Af,OA,_v,PA,$A,xA,DA,NA,Tf,no,ti,If,Rf,yv,ro,Or,wv,Yl,Cf,FA,LA,UA,ne,kv,BA,VA,jA,GA,HA,Av,Tv,Iv,Rv,zA,qA,dn,cl,hn,Of,si,Pf,Cv,WA,KA,$f,YA,xf,Df,QA,tn,JA,ul,XA,Nf,ZA,fn,Ov,dl,hl,sT,iT,Xi,Mf,Ff,nT,Rs,Lf,Uf,rT,oT,gl,Bf,jt,aT,lT,Pr,vl,cT,At,Vf,Ec,ii,jf,uT,dT,hT,fT,gT,pT,vT,Gf,Hf,zf,Cs,_l,_T,qf,Wf,Kf,Yf,mT,Qf,yT,Jf,_t,Ql,bT,ET,wT,Xf,ST,gt,Os,kT,AT,eg,Pv,ml,tg,TT,oo,wc,IT,RT,$v,Jl,xv,CT,OT,sg,PT,$T,uo,xT,DT,NT,MT,FT,LT,UT,BT,VT,jT,GT,HT,zT,qT,Oe,Dv=Ze(()=>{"use strict";E="u">typeof window?window:void 0,Ge="u">typeof globalThis?globalThis:E,Le=Ge?.navigator,T=Ge?.document,pe=Ge?.location,gn=Ge?.fetch,Xl=Ge?.XMLHttpRequest&&"withCredentials"in new Ge.XMLHttpRequest?Ge.XMLHttpRequest:void 0,Sh=Ge?.AbortController,qw=Ge?.CompressionStream,Ye=Le?.userAgent,Gi=typeof globalThis<"u"?globalThis:E;Gi&&typeof self>"u"&&(Gi.self=Gi),Gi&&typeof File>"u"&&(Gi.File=function(){});L=E??{},kh="0.9.4",Wt={DEBUG:!1,LIB_VERSION:kh,LIB_NAME:"browser-common",JS_SDK_VERSION:kh},It=(function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t})({}),El=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({}),Ww=["$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"],Kw=["token"];hi=function(t){return t.trim()},wl=function(t){return t.replace(/^\$/,"")};ag=Object.prototype,Zl=ag.hasOwnProperty,ao=ag.toString,N=Array.isArray||function(t){return ao.call(t)==="[object Array]"},Ce=t=>typeof t=="function",G=t=>t===Object(t)&&!N(t),nt=t=>{if(G(t)){for(let e in t)if(Zl.call(t,e))return!1;return!0}return!1},S=t=>t===void 0,H=t=>ao.call(t)=="[object String]",sn=t=>H(t)&&t.trim().length===0,we=t=>t===null,B=t=>S(t)||we(t),Te=t=>ao.call(t)=="[object Number]"&&t==t,Gt=t=>Te(t)&&t>0,Je=t=>ao.call(t)==="[object Boolean]",Yw=t=>M(Ww,t),Qw=t=>M(Kw,t);Jw=[!0,"true",1,"1","yes"],Da=t=>M(Jw,t),Xw=[!1,"false",0,"0","no"];Zw=["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","pinterestbot","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"],Ar=new Map,Th=function(t,e=[]){if(!t)return!1;let s=(function(o,a){let l="";for(let c=0;a.length>c;c++){let u=a[c];l+=u.length+":"+u}return o.length+":"+o+"|"+a.length+":"+l})(t,e),i=Ar.get(s);if(i!==void 0)return i;let n=t.toLowerCase(),r=Zw.concat(e).some(o=>n.indexOf(o.toLowerCase())!==-1);return 256>Ar.size||Ar.clear(),Ar.set(s,r),r};eS=class{constructor(t){this.C={},this.I=t.I,this.R=Rt(t.bucketSize,0,100,t.A),this.$=Rt(t.refillRate,0,this.R,t.A),this.O=Rt(t.refillInterval,0,864e5,t.A)}F(t,e){let s=Math.floor((e-t.lastAccess)/this.O);s>0&&(t.tokens=Math.min(t.tokens+s*this.$,this.R),t.lastAccess=t.lastAccess+s*this.O)}consumeRateLimit(t){var e;let s=Date.now(),i=String(t),n=this.C[i];return n?this.F(n,s):(n={tokens:this.R,lastAccess:s},this.C[i]=n),n.tokens===0||(n.tokens--,n.tokens===0&&((e=this.I)===null||e===void 0||e.call(this,t)),n.tokens===0)}stop(){this.C={}}},fi="Mobile",pn="Android",Vr="Tablet",ug="Android Tablet",dg="iPad",hg="Apple Watch",$r="Safari",lo="BlackBerry",fg="Samsung Internet",xr="Chrome",gg="Chrome iOS",pg="Internet Explorer",vg="Internet Explorer Mobile",_g="Opera",mg="Microsoft Edge",Dr="Firefox",yg="Firefox iOS",jr="Nintendo",Gr="PlayStation",co="Xbox",bg="Android Mobile",Eg="Mobile Safari",Na="Windows",wg="Windows Phone",Ih="Nokia",Sl="Ouya",tS="Generic "+fi.toLowerCase(),Sg="Generic "+Vr.toLowerCase(),kl="Konqueror",kg="Oculus Browser",Ag="Vivaldi",Tg="Yandex",Ig="Whale",Rg="DuckDuckGo",Cg="Pale Moon",Og="Waterfox",Al="Brave",Pg="Claude",$g="Codex",xg="ChatGPT",Dg="Google Search App",Ma=new RegExp("Version/(\\d+(\\.\\d+)?)"),Fa=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),sS=new RegExp(co,"i"),iS=new RegExp("PlayStation \\w+","i"),nS=new RegExp("Nintendo \\w+","i"),tc=new RegExp("BlackBerry|PlayBook|BB10","i"),rS={"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"},Ng=function(t,e,s,i){return e=e||"",(function(r){return r?.brave?Al:null})(s)||(i?.detectGoogleSearchApp&&M(t,"GSA/")?Dg:M(t," OPR/")&&M(t,"Mini")?"Opera Mini":M(t," OPR/")?_g:tc.test(t)?lo:M(t,"IEMobile")||M(t,"WPDesktop")?vg:M(t,"OculusBrowser")?kg:M(t,"SamsungBrowser")?fg:M(t,"Edge")||M(t,"Edg/")?mg:M(t,"Vivaldi/")?Ag:M(t,"YaBrowser/")?Tg:M(t,"Whale/")?Ig:M(t,"DuckDuckGo/")||M(t,"Ddg/")?Rg:M(t,"Claude/")?Pg:M(t,"Codex/")?$g:M(t,"ChatGPT/")?xg:M(t,"FBIOS")?"Facebook Mobile":M(t,"UCWEB")||M(t,"UCBrowser")?"UC Browser":M(t,"CriOS")?gg:M(t,"CrMo")||M(t,xr)?xr:M(t,pn)&&M(t,$r)?bg:M(t,"FxiOS")?yg:M(t.toLowerCase(),kl.toLowerCase())?kl:M(t,"Brave/")?Al:((r,o)=>o&&M(o,"Apple")||(function(a){return M(a,$r)&&!M(a,xr)&&!M(a,pn)})(r))(t,e)?M(t,fi)?Eg:$r:M(t,"PaleMoon/")?Cg:M(t,"Waterfox/")?Og:M(t,Dr)?Dr:M(t,"MSIE")||M(t,"Trident/")?pg:M(t,"Gecko")?Dr:"")},oS={[vg]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[mg]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[xr]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[gg]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[$r]:[Ma],[Eg]:[Ma],[_g]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Dr]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[yg]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[kl]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[lo]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ma],[bg]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[fg]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[kg]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[Ag]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[Tg]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Ig]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Al]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Pg]:[Fa],[$g]:[Fa],[xg]:[Fa],[Rg]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Cg]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Og]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Dg]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[pg]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},aS=function(t,e,s,i){let n=Ng(t,e,s,i),r=oS[n];if(S(r))return null;for(let o=0;r.length>o;o++){let a=t.match(r[o]);if(a)return parseFloat(a[a.length-2])}return null},Rh=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[co,t&&t[1]||""]],[new RegExp(jr,"i"),[jr,""]],[new RegExp(Gr,"i"),[Gr,""]],[tc,[lo,""]],[new RegExp(Na,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[wg,""];if(new RegExp(fi).test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];let s=/Windows NT ([0-9.]+)/i.exec(e);if(s&&s[1]){let i=rS[s[1]]||"";return/arm/i.test(e)&&(i="RT"),[Na,i]}return[Na,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{let e="";return t&&t.length>=3&&(e=S(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[pn,[t[2],t[3],t[4]||"0"].join(".")]:[pn,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{let e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Mg=function(t){for(let e=0;Rh.length>e;e++){let[s,i]=Rh[e],n=s.exec(t),r=n&&(Ce(i)?i(n,t):i);if(r)return r}return["",""]},Fg=function(t){return nS.test(t)?jr:iS.test(t)?Gr:sS.test(t)?co:new RegExp(Sl,"i").test(t)?Sl:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?wg:/iPad/.test(t)?dg:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?hg:tc.test(t)?lo:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Ih,"i").test(t)?Ih:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(fi).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?pn:ug:new RegExp("(pda|Mobile)","i").test(t)?tS:new RegExp(Vr,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?Sg:""},lS=function(t,e){var s;let i=Fg(t);return i===dg||i===ug||i==="Kobo"||i==="Kindle Fire"||i===Sg?Vr:i===jr||i===co||i===Gr||i===Sl?"Console":i===hg?"Wearable":i?fi:e?.userAgentDataPlatform==="Android"&&((s=e?.maxTouchPoints)!==null&&s!==void 0?s:0)>0?600>Math.min((n=e?.screenWidth)!==null&&n!==void 0?n:0,(r=e?.screenHeight)!==null&&r!==void 0?r:0)/((o=e?.devicePixelRatio)!==null&&o!==void 0?o:1)?fi:Vr:"Desktop";var n,r,o},La=/\bFBAV\/(\d+(?:\.\d+)*)/i,Ch=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",La],[/\bFBAN\/EMA\b/i,"Facebook Lite",La],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",La],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Tl="[Truncated]",En="[Unserializable]";Nr=3e5,Ug=class{record(t){if(t.kind==="too-large")return;if(t.kind!=="retry-later")return void this.reset();if(!t.retryAfterMs)return;let e=this.isOpen(),s=Date.now(),i=Math.min(t.retryAfterMs,Nr);if(!e)return this.ts=s,void(this.es=s+i);this.es=Math.max(this.es,Math.min(s+i,this.ts+Nr))}remainingMs(){let t=Date.now();if(this.ts-5e3>t)return this.reset(),0;let e=Math.min(Nr,Math.max(0,this.es-t));return e===0&&this.reset(),e}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}},cS=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;hS=class{constructor(t,e,s=[]){this.coercers=t,this.stackParser=e,this.modifiers=s}buildFromUnknown(t,e={}){let s=e&&e.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(s,e,0).apply(t),n=this.buildParsingContext(e),r=this.parseStacktrace(i,n);return{$exception_list:this.convertToExceptionList(r,s),$exception_level:"error"}}modifyFrames(t){var e=this;return he(function*(){for(let s of t)s.stacktrace&&s.stacktrace.frames&&N(s.stacktrace.frames)&&(s.stacktrace.frames=yield e.applyModifiers(s.stacktrace.frames));return t})()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:(e=t.syntheticException)===null||e===void 0?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var s;let i,n;if(t.cause!=null&&(i=this.parseStacktrace(t.cause,e)),t.stack!=""&&t.stack!=null)try{n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)}catch{}return _(_({},t),{},{cause:i,stack:n,errors:(s=t.errors)===null||s===void 0?void 0:s.map(r=>this.parseStacktrace(r,e))})}applyChunkIds(t,e){return t.map(s=>(s.filename&&e&&(s.chunk_id=e[s.filename]),s))}applyCoercers(t,e){for(let s of this.coercers)if(s.match(t))return s.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return he(function*(){let s=t;for(let i of e.modifiers)s=yield i(s);return s})()}convertToExceptionList(t,e){let s=[],i=(n,r,o)=>{var a;let l=s.length,c=r===void 0?_(_({type:typeof e.type=="string"&&e.type.length>0?e.type:"generic"},typeof e.handled=="boolean"?{handled:e.handled}:e.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof e.synthetic=="boolean"?e.synthetic:n.synthetic,exception_id:l}):{type:"chained",source:o,synthetic:n.synthetic,exception_id:l,parent_id:r},u={type:n.type,value:n.value,mechanism:c};n.stack&&(u.stacktrace={type:"raw",frames:n.stack}),s.push(u),n.cause&&i(n.cause,l,"cause");for(let h of(a=n.errors)!==null&&a!==void 0?a:[])i(h,l,"member")};return i(t),s}buildParsingContext(t){var e;return{chunkIdMap:dS(this.stackParser),skipFirstLines:(e=t.skipFirstLines)!==null&&e!==void 0?e:1}}getAggregateErrors(t){try{if(bi(t)){let s=Object.getPrototypeOf(t);for(let i=0;s&&100>i;i++){var e;let n=(e=Object.getOwnPropertyDescriptor(s,"constructor"))===null||e===void 0?void 0:e.value;if(typeof n=="function"&&n.name==="AggregateError"){let r=t.errors;return N(r)?r:void 0}s=Object.getPrototypeOf(s)}}}catch{}}buildCoercingContext(t,e,s=0){let i=0,n=0,r=!1,o=new Set,a=[],l={},c=(d,g,p=0)=>{let m=u(g,p),v=m.apply;if(m.apply=k=>{a.push(d);try{return v(k)}finally{a.pop()}},p>4||p>0&&a.indexOf(d)!==-1)return this.coerceFallback(m);let b=typeof d=="object"&&d!==null||typeof d=="function";if(p===0&&i>=50||b&&o.has(d))return;b&&o.add(d),p===0&&i++;let y=this.getAggregateErrors(d),w,A;r||(r=!!y);try{if(w=this.applyCoercers(d,m),!w)throw l}catch(k){if(k===l)return void(p===0&&i--);if(!r)throw k;w=this.coerceFallback(m)}if(!y||i>=50)return w;try{A=y.length}catch{return w}if(!Number.isInteger(A)||0>A||A>4294967295)return w;let I=[];for(let k=0;50>i&&1e3>n&&A>k;k++){let $;n++;try{$=m.next(y[k])}catch{i++,$=this.coerceFallback(u(g+1))}$&&I.push($)}return _(_({},w),{},{errors:I})},u=(d,g=0)=>_(_({},e),{},{syntheticException:d==0?e.syntheticException:void 0,mechanism:d==0?t:{},apply(p){let m=c(p,d,g+1);if(!m)throw l;return m},next:p=>c(p,d+1)}),h=u(s);return _(_({},h),{},{apply:d=>{var g;return(g=c(d,s))!==null&&g!==void 0?g:this.coerceFallback(h)}})}},fS=/^([a-z][a-z0-9.+-]+):/i,gS=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];Gg=(t,e)=>{let s=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return s||i?[t.indexOf("@")!==-1?t.split("@")[0]:"?",s?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]},vS=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,_S=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,mS=/\((\S*)(?::(\d+))(?::(\d+))\)/,yS=(t,e)=>{let s=vS.exec(t);if(s){let[,n,r,o]=s;return Il(e,n,"?",+r,+o)}let i=_S.exec(t);if(i){if(i[2]&&i[2].indexOf("eval")===0){let o=mS.exec(i[2]);o&&(i[2]=o[1],i[3]=o[2],i[4]=o[3])}let[n,r]=Gg(i[1]||"?",i[2]);return Il(e,r,n,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},bS=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ES=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,wS=(t,e)=>{let s=bS.exec(t);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){let r=ES.exec(s[3]);r&&(s[1]=s[1]||"eval",s[3]=r[1],s[4]=r[2],s[5]="")}let i=s[3],n=s[1]||"?";return[n,i]=Gg(n,i),Il(e,i,n,s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},Fh=/\(error: (.*)\)/;IS=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){let s=H(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:s?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){let e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${e}: ${t.message}`:e}isDOMException(t){return Br(t,"DOMException")}isDOMError(t){return Br(t,"DOMError")}},RS=class{match(t){return bi(t)}coerce(t,e){var s;let i=this.getStack(t),n=i===void 0?(s=e.syntheticException)===null||s===void 0?void 0:s.stack:void 0,r=!!n;return{type:this.getType(t),value:this.getMessage(t,e),stack:i??n,cause:t.cause?e.next(t.cause):void 0,synthetic:r}}getType(t){return t.name||t.constructor.name}getMessage(t,e){let s=t.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(t){try{let e=t.stacktrace;if(typeof e=="string"&&e.length>0)return e;let s=t.stack;return typeof s=="string"&&s.length>0?s:void 0}catch{return}}},CS=class{match(t){return!!Br(t,"ErrorEvent")&&(t.error!=null||this.ar(t))}coerce(t,e){var s;if(t.error!=null)return e.apply(t.error);let i=e.apply(t.message);return _(_({},i),{},{stack:(s=this.lr(t))!==null&&s!==void 0?s:i.stack,synthetic:!0})}ar(t){return H(t.message)&&t.message.length>0}lr(t){var e,s;let i=t,n=(e=i.lineno)!==null&&e!==void 0?e:0,r=(s=i.colno)!==null&&s!==void 0?s:0;if(H(i.filename)&&i.filename.length!==0&&n!==0)return`Error
6
+ at ${i.filename}:${n}:${r}`}},OS=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,PS=class{match(t){return typeof t=="string"}coerce(t,e){var s;let[i,n]=this.getInfos(t);return{type:i??"Error",value:n??t,stack:(s=e.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}getInfos(t){let e="Error",s=t,i=t.match(OS);return i&&(e=i[1],s=i[2]),[e,s]}},$S=["fatal","error","warning","log","info","debug"];xS=class{match(t){return typeof t=="object"&&t!==null}coerce(t,e){var s,i;let n=this.getErrorPropertyFromObject(t);return n?e.apply(n):{type:this.getType(t),value:this.getValue(t),stack:(s=this.getStack(t))!==null&&s!==void 0?s:(i=e.syntheticException)===null||i===void 0?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(ec(t))return t.constructor.name;let e="name"in t?t.name:void 0;return H(e)&&!sn(e)?e:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let s=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(s+=` with message: '${t.message}'`),s}if("message"in t&&typeof t.message=="string")return t.message;let e=this.getObjectClassName(t);return`${e&&e!=="Object"?`'${e}'`:"Object"} captured as exception with keys: ${qg(t)}`}isSeverityLevel(t){return H(t)&&!sn(t)&&$S.indexOf(t)>=0}getStack(t){try{return H(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:H(t.stack)&&t.stack.length>0?t.stack:void 0}catch{return}}getErrorPropertyFromObject(t){for(let e in t)if({}.hasOwnProperty.call(t,e)){let s=t[e];if(bi(s))return s}}getObjectClassName(t){try{let e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch{return}}},DS=class{match(t){return ec(t)}coerce(t,e){var s;let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${qg(t)}`,stack:(s=e.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},NS=class{match(t){return lg(t)}coerce(t,e){var s;return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:(s=e.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},MS=class{match(t){return Br(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!ec(t))return!1;try{let e=t.detail;return e!=null&&typeof e=="object"&&"reason"in e}catch{return!1}}coerce(t,e){var s;let i=this.getUnhandledRejectionReason(t);return lg(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:(s=e.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}:e.apply(i)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&t.detail!=null&&typeof t.detail=="object"&&"reason"in t.detail)return t.detail.reason}catch{}return t}},Hr="$message",zr="$timestamp",FS=new Set([Hr,zr]),Ua={enabled:!0,max_bytes:32768};LS=class{constructor(t){this.ns=[],this.ss=0,this.Mr=qr(t)}setConfig(t){this.Mr=qr(t),this.rs()}add(t){let e=(function(i){let n;try{n=og(i)}catch{return}try{let r=JSON.parse(n);if(!G(r))return;let o=r,a=o[Hr],l=o[zr];return!H(a)||a.trim().length===0||!H(l)&&!Te(l)?void 0:{step:o,json:n}}catch{return}})(t);if(!e)return;let s=(function(i){if("u">typeof TextEncoder)return new TextEncoder().encode(i).length;let n=encodeURIComponent(i),r=0;for(let o=0;n.length>o;o++)n[o]==="%"?(r+=1,o+=2):r+=1;return r})(e.json);s>this.Mr.max_bytes||(this.ns.push({step:e.step,bytes:s}),this.ss+=s,this.rs())}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Mr.max_bytes&&this.ns.length>0;){let t=this.ns.shift();t&&(this.ss-=t.bytes)}}};Lh=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};BS=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Wg="NativeGzipValidationError",Rl=t=>t.length>=2&&t[0]===31&&t[1]===139,Vh=(t,e)=>t===El.GZipJS||e===El.GZipJS||e==="gzip",jh=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError",Tr=t=>{throw Bg(Wg,`Native gzip produced invalid output: ${t}`)},VS=(Gh=he(function*(t,e){18>t.size&&Tr("too-short");let s=new Uint8Array(yield t.slice(0,10).arrayBuffer());Rl(s)&&s[2]===8||Tr("invalid-header");let i=new DataView(yield t.slice(t.size-8).arrayBuffer());i.getUint32(0,!0)!==(r=>{let o=(()=>{if(zi)return zi;zi=[];for(let l=0;256>l;l++){let c=l;for(let u=0;8>u;u++)c=1&c?3988292384^c>>>1:c>>>1;zi[l]=c>>>0}return zi})(),a=4294967295;for(let l=0;r.length>l;l++)a=o[255&(a^r[l])]^a>>>8;return(4294967295^a)>>>0})(e)&&Tr("invalid-crc");let n=e.length>>>0;i.getUint32(4,!0)!==n&&Tr("invalid-size")}),function(t,e){return Gh.apply(this,arguments)});je="[redacted]",jS=/^[A-Za-z0-9+/\n\r]+=*$/,GS=/^[A-Za-z0-9_-]+={0,2}$/,HS=/[-_]/,zS=/^data:[^,\s]*;base64,/i,qS=/^[A-Za-z0-9+/_-]+={0,2}$/,WS=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,KS=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Yg=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,YS=/[\s<>"]/,Qg=new RegExp(Yg.source,"i"),Jg=/[a-z][a-z0-9+.-]{0,63}:\/\//i,QS=new RegExp(`^${Jg.source}`,"i"),JS=new RegExp(Jg.source,"gi"),XS=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,ZS=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,ek=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,tk=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,sk=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,ik=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,nk=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,rk=/\b\d(?:[ ./-]?\d){12,}\b/g,Hh=/\d+/g,ok=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,ak=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;gk={}.propertyIsEnumerable;vk=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];qh={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"},sp={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},_k=sp.info;rp=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.cs}arm(t){this.clear(),this.us=Date.now()+t,this.cs=Vg(()=>{this.cs=void 0,this.ls()},t)}armNoEarlierThan(t){this.cs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};bk=class{constructor(t,e,s,i,n,r=()=>Promise.resolve(),o){var a;this._instance=t,this.Mr=e,this.A=s,this.hs=i,this.ds=n,this.vs=r,this.fs=o,this.ps=new rp(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new Ug,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=e.maxBufferSize,this.Is=Math.max((a=e.maxQueueSize)!==null&&a!==void 0?a:e.maxBufferSize,e.maxBufferSize),this.Ms=e.flushIntervalMs,this.Es=e.maxBatchRecordsPerPost,this.Ps=e.rateCapWindowMs,this.Rs=e.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(It.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(t,e){var s;if(this._instance.isDisabled||this._instance.optedOut||!t?.body)return;let i=this.Os(t);if(i===null)return;if(!i.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;let n={record:yk(i,(s=e?.context)!==null&&s!==void 0?s:this.hs(),this.A,e?.occurredAtMs)};this.ds(()=>this.Ls(n))}Os(t){let e=this.Mr.beforeSend;if(!e)return t;let s=N(e)?e:[e],i=t;for(let n of s)try{let r=n(i);if(!r)return this.A.info("Log was rejected in beforeSend function"),null;i=r}catch(r){return this.A.error("Error in beforeSend function for log:",r),null}return i}Ds(){if(this.Rs===void 0)return!0;let t=Date.now(),e=t-this.xs;return this.Ps>e&&e>=0||(this.xs=t,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var t=this;return he(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return he(function*(){var e;t.ps.clear();let s=(e=t._instance.getPersistedProperty(It.LogsQueue))!==null&&e!==void 0?e:[];if(s.length===0)return;let i=s.length,n=0;for(;s.length>0&&i>n;){var r,o;let a=t._s;t.bs=0;let l=Math.min(s.length,t.Es),c=s.slice(0,l),u=np(c.map(d=>d.record),t.qs(),(r=t.fs)!==null&&r!==void 0?r:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.js(u);if(t._s!==a)return;if(h.kind==="too-large"&&c.length>1)t.Es=Math.max(1,Math.floor(c.length/2)),t.A.warn(`Logs batch of size ${c.length} was too large for the ingestion endpoint, reducing batch size to ${t.Es}`);else if(t.ws.record(h),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.remainingMs())),h.kind==="retry-later"||(h.kind==="too-large"?t.A.warn("Dropping a single log record with batch size 1 \u2014 the record is larger than the server cap and cannot be split further."):h.kind==="ok"&&t.Mr.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Mr.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(c.length),s=(o=t._instance.getPersistedProperty(It.LogsQueue))!==null&&o!==void 0?o:[],n+=c.length,h.kind==="fatal"))throw h.error}})()}Bs(t){var e=this;return he(function*(){var s;let i=Math.max(0,t-e.bs),n=(s=e._instance.getPersistedProperty(It.LogsQueue))!==null&&s!==void 0?s:[];e._instance.setPersistedProperty(It.LogsQueue,n.slice(i)),yield e.vs()})()}qs(){return ip(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var e;if(this._instance.optedOut)return;let s=(e=this._instance.getPersistedProperty(It.LogsQueue))!==null&&e!==void 0?e:[];this.Is>s.length||(s.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),s.push(t),this._instance.setPersistedProperty(It.LogsQueue,s),this.Ts>s.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(ap(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){let t=this._instance.getPersistedProperty(It.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return he(function*(){e.ps.clear();let s=e.flush().catch(()=>{});t!==void 0?yield $h(s,t):yield s})()}flushWithTimeout(t){var e=this;return he(function*(){let s=e.flush();yield $h(s,t,()=>{s.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=op(),this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.zs())})}},ja=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];Ek=class{constructor(t,e,s){this._instance=t,this.Mr=e,this.A=s,this.Hs=new Map,this.ps=new rp(()=>this.flush().catch(i=>{this.A.error("Metrics flush failed:",i)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new Ug,this.ks=0,this.Ss=1,this.Gs=0}count(t,e=1,s){this.Qs({name:t,type:"count",value:e,unit:s?.unit,attributes:s?.attributes})}gauge(t,e,s){this.Qs({name:t,type:"gauge",value:e,unit:s?.unit,attributes:s?.attributes})}histogram(t,e,s){this.Qs({name:t,type:"histogram",value:e,unit:s?.unit,attributes:s?.attributes})}flush(){var t=this;let e=this.ys,s=(function(){var i=he(function*(){e&&(yield e.catch(()=>{})),yield t.Zs()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===s&&(this.ys=null)});return this.ys=s,s}drainWindow(){if(this.Hs.size===0)return null;let t=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(t){if(this._instance.isDisabled||this._instance.optedOut)return;let e=this.Os(t);if(e===null)return;if(!e.name||typeof e.name!="string")return void this.A.warn("Dropping metric with empty name");if(typeof e.value!="number"||!Number.isFinite(e.value))return void this.A.warn(`Dropping metric '${e.name}': value must be a finite number`);if(e.type==="count"&&0>e.value)return void this.A.warn(`Dropping count '${e.name}': counters are monotonic, value must be >= 0`);let s,i;try{s=e.attributes?_({},e.attributes):void 0,i=Kh(e.type,e.name,e.unit,s)}catch(o){return void this.A.warn(`Dropping metric '${e.name}': attributes could not be serialized`,o)}let n=this.Hs.get(i);if(!n){if(!this.Ks())return;n={name:e.name,type:e.type,unit:e.unit,attributes:s,windowStartMs:Date.now()},this.Hs.set(i,n)}let r=this.Ws.get(e.name);r===void 0?this.Ws.set(e.name,e.type):r===e.type||this.Vs.has(e.name)||(this.Vs.add(e.name),this.A.warn(`Metric name '${e.name}' is already used as a ${r}; recording it as a ${e.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(n,e.value),this.Fs()}Ks(){return this.Mr.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(t,e){switch(t.type){case"count":var s;t.total=((s=t.total)!==null&&s!==void 0?s:0)+e;break;case"gauge":t.last=e;break;case"histogram":{t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(ja.length+1).fill(0)});let i=t.hist;i.count+=1,i.sum+=e,i.min=Math.min(i.min,e),i.max=Math.max(i.max,e),i.bucketCounts[(function(n,r){for(let o=0;r.length>o;o++)if(r[o]>=n)return o;return r.length})(e,ja)]+=1;break}}}Os(t){let e=this.Mr.beforeSend;if(!e)return t;let s=N(e)?e:[e],i=t;for(let n of s)try{let r=n(i);if(!r)return this.A.info("Metric was rejected in beforeSend function"),null;i=r}catch(r){return this.A.error("Error in beforeSend function for metric:",r),null}return i}Fs(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(ap(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Zs(){var t=this;return he(function*(){if(t.ps.clear(),t.Hs.size===0)return;let e=t.Hs;t.Hs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;let s=t.Gs,i=yield t._instance.Ys(t.Js(e));if(s===t.Gs)switch(t.ws.record(i),i.kind==="retry-later"?(t.ks++,t.Ss=op()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.zs()),i.kind){case"ok":return;case"retry-later":return t.co(e),void t.ps.armNoEarlierThan(t.zs());case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",i.error)}})()}Js(t){return e=this.ho(t),s=(function(r,o,a){return ep(r,o,a)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:tp(s)},scopeMetrics:[{scope:{name:i,version:n},metrics:e}]}]};var e,s,i,n}ho(t){let e=Wh(Date.now()),s=new Map;for(let o of t.values()){var i;let a=Kh(o.type,o.name,o.unit,void 0),l=s.get(a);l||(l=_({name:o.name},o.unit&&{unit:o.unit}),o.type==="count"?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:o.type==="gauge"?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},s.set(a,l));let c=Kr((i=o.attributes)!==null&&i!==void 0?i:{},this.A),u=Wh(o.windowStartMs);if(o.type==="count"){var n;let h={attributes:c,startTimeUnixNano:u,timeUnixNano:e,asDouble:(n=o.total)!==null&&n!==void 0?n:0};l.sum.dataPoints.push(h)}else if(o.type==="gauge"){var r;let h={attributes:c,timeUnixNano:e,asDouble:(r=o.last)!==null&&r!==void 0?r:0};l.gauge.dataPoints.push(h)}else o.hist&&l.histogram.dataPoints.push({attributes:c,startTimeUnixNano:u,timeUnixNano:e,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:ja})}return Array.from(s.values())}co(t){for(let[i,n]of t){let r=this.Hs.get(i);if(r)switch(r.windowStartMs=Math.min(r.windowStartMs,n.windowStartMs),r.type){case"count":var e,s;r.total=((e=r.total)!==null&&e!==void 0?e:0)+((s=n.total)!==null&&s!==void 0?s:0);break;case"gauge":break;case"histogram":if(n.hist)if(r.hist){r.hist.count+=n.hist.count,r.hist.sum+=n.hist.sum,r.hist.min=Math.min(r.hist.min,n.hist.min),r.hist.max=Math.max(r.hist.max,n.hist.max);for(let o=0;r.hist.bucketCounts.length>o;o++)r.hist.bucketCounts[o]+=n.hist.bucketCounts[o]}else r.hist=n.hist}else this.Ks()&&this.Hs.set(i,n)}}},lp=(t,{debugEnabled:e}={})=>{let s={N(i,...n){let r;try{r=typeof window>"u"?void 0:window}catch{return}r&&(Wt.DEBUG||r.POSTHOG_DEBUG||e)&&!S(r.console)&&r.console&&("__rrweb_original__"in r.console[i]?r.console[i].__rrweb_original__:r.console[i])(t,...n)},debug(...i){s.N("debug",...i)},info(...i){s.N("log",...i)},warn(...i){s.N("warn",...i)},error(...i){s.N("error",...i)},critical(...i){console.error(t,...i)},uninitializedWarning(i){s.error(`You must initialize PostHog before calling ${i}`)},createLogger:(i,n)=>lp(`${t} ${i}`,n)};return s},R=lp("[PostHog.js]"),ye=R.createLogger,wk=ye("[ExternalScriptsLoader]"),Yr=t=>{let e=T?.querySelectorAll("script");if(e){for(let s=0;e.length>s;s++)if(e[s].src===t||e[s].getAttribute("src")===t)return e[s]}},Ps=(t,e,s)=>{if(t.config.disable_external_dependency_loading)return wk.warn(`${e} was requested but loading of external scripts is disabled.`),s("Loading of external scripts is disabled");let i=Yr(e);if(i){if(i.__posthog_loading_callback_fired)return s();let r=i.__posthog_loading_error;return r?s(r):(i.addEventListener("load",o=>{i.__posthog_loading_callback_fired=!0,s(void 0,o)}),void i.addEventListener("error",o=>{i.__posthog_loading_error=o,s(o)}))}let n=()=>{if(!T)return s("document not found");if(Yr(e))return Ps(t,e,s);let r=T.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=e,r.onload=a=>{r.__posthog_loading_callback_fired=!0,s(void 0,a)},r.onerror=a=>{r.__posthog_loading_error=a,s(a)},t.config.prepare_external_dependency_script&&(r=t.config.prepare_external_dependency_script(r)),!r)return s("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")T.head.appendChild(r);else{let a=T.querySelectorAll("body > script");var o;a.length>0?(o=a[0].parentNode)===null||o===void 0||o.insertBefore(r,a[0]):T.body.appendChild(r)}};T?.body?n():T?.addEventListener("DOMContentLoaded",n)},Ga={},Yh=(t,e)=>{let s=`/static/${e}.js?v=${t.version}`;return e==="toolbar"&&(s=`${s}&t=${Math.floor(Date.now()/3e5)*3e5}`),t.requestRouter.endpointFor("assets",s)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(t,e,s)=>{if(e==="remote-config"){let n=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void Ps(t,n,s)}let i=t.config.strict_script_versioning;if(i){let n=t.requestRouter.endpointFor("assets",`/static/${t.version}/${e}.js`),r=Ga[n];if(i==="fallback"&&r){if(Yr(r))return void Ps(t,r,s);delete Ga[n]}return void Ps(t,n,i==="fallback"?(o,a)=>{if(o)if(typeof o=="string")s(o);else{var l;let c=Yh(t,e);Ga[n]=c;let u=Yr(n);u==null||(l=u.parentNode)===null||l===void 0||l.removeChild(u),Ps(t,c,s)}else s(void 0,a)}:s)}Ps(t,Yh(t,e),s)},L.__PosthogExtensions__.loadSiteApp=(t,e,s)=>{let i=t.requestRouter.endpointFor("api",e);Ps(t,i,s)},Wt.DEBUG=!1,Wt.LIB_VERSION="1.438.7",Wt.LIB_NAME="web";it=Wt,Pl="$early_access_features",zt="$active_feature_flags",Ds="$feature_flag_details",vn="$feature_flag_errors",us="$feature_flag_evaluated_at",Ns="$feature_flag_request_id",rn="$minimal_flag_called_events",yt="$enabled_feature_flags",os="$stored_group_properties",as="$stored_person_properties",ls="$flag_call_reported",Zi="$flag_call_reported_session_id",cs="$feature_flag_payloads",Tt="$override_feature_flags",$s="$override_feature_flag_payloads",_n="visibilitychange",Sk="$people_distinct_id",mt="distinct_id",rc="$device_id",Ha="$device_model",Qr="__alias",kk="__cmpns",Qh="$fbc",ui="$fbc_persistence",Jh="$fbp",on="$fbp_persistence",$l="__timers",cp="$autocapture_disabled_server_side",xl="$heatmaps_enabled_server_side",Dl="$exception_capture_enabled_server_side",up="$error_tracking_suppression_rules",Nl="$error_tracking_capture_extension_exceptions",Ml="$web_vitals_enabled_server_side",oc="$dead_clicks_enabled_server_side",ac="$product_tours_enabled_server_side",dp="$logs_capture_enabled_server_side",hp="$web_vitals_allowed_metrics",an="$session_recording_remote_config",Ak="$session_recording_enabled_server_side",Tk="$replay_sample_rate",Ik="$replay_override_sampling",Rk="$replay_override_linked_flag",Ck="$replay_override_url_trigger",Ok="$replay_override_event_trigger",ri="$sesid",fp="$session_is_sampled",Pk="$session_past_minimum_duration",$k="$session_recording_url_trigger_activated_session",xk="$session_recording_event_trigger_activated_session",Dk="$debug_first_full_snapshot_timestamp",Nk="$sess_rec_flush_size",gp="$groups",en="$surveys",Jr="$surveys_loaded_at",pp="$surveys_activated",vp="$surveys_activated_session",_p="$surveys_activated_timestamps",Fl="ph_product_tours",Mk="$product_tours_activated",Fk="$product_tours_activated_session",Lk="$conversations_widget_session_id",Uk="$conversations_ticket_id",Bk="$conversations_widget_state",Vk="$conversations_user_traits",Qe="$user_state",Ll="$client_session_props",jk="$capture_rate_limit",mp="$initial_campaign_params",yp="$initial_referrer_info",oi="$initial_person_info",lc="$epp",za="$posthog_cookieless",bp="$cookieless_mode",Ep="$sdk_debug_extensions_init_method",wp="$sdk_debug_extensions_init_time_ms",cc="$sdk_debug_recording_script_not_loaded",uc="$sdk_debug_replay_stale_config",Sp="$sdk_debug_replay_event_trigger_status",kp="$sdk_debug_replay_linked_flag_trigger_status",Ap="$sdk_debug_replay_matched_recording_trigger_groups",Tp="$sdk_debug_replay_pending_trigger_conditions",Ip="$sdk_debug_replay_remote_trigger_matching_config",Rp="$sdk_debug_replay_trigger_groups_count",Cp="$sdk_debug_replay_url_trigger_status",Gk="$session_recording_start_reason",dc="PostHog loadExternalDependency extension not found.",qt="anonymous",Mr="identified",Op="identified_only",Xr="beforeunload",hc="$pageview",Xh="$pageleave",Pp="$identify",Zh="$groupidentify";ve=function(t,...e){for(let s of e)for(let i in s)s[i]!==void 0&&(t[i]=s[i]);return t};Hk=function(t){return function(...e){try{return t.apply(this,e)}catch(s){R.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),R.critical(s)}}},fc=function(t){let e={};return re(t,function(s,i){(H(s)&&s.length>0||Te(s))&&(e[i]=s)}),e};zk=["herokuapp.com","vercel.app","netlify.app"];ln=t=>{if(T){try{let e=t+"=",s=T.cookie.split(";").filter(i=>i.length);for(let i=0;s.length>i;i++){let n=s[i];for(;n.charAt(0)==" ";)n=n.substring(1,n.length);if(n.indexOf(e)===0)return decodeURIComponent(n.substring(e.length,n.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Te(t)&&isFinite(t)&&Math.floor(t)===t});Wk=class Bl{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,s,i,n){if(!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(i)||!Number.isInteger(n)||0>e||0>s||0>i||0>n||e>0xffffffffffff||s>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/256,r[5]=e,r[6]=112|s>>>8,r[7]=s,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new Bl(r)}toString(){let e="";for(let s=0;this.bytes.length>s;s++)e=e+(this.bytes[s]>>>4).toString(16)+(15&this.bytes[s]).toString(16),s!==3&&s!==5&&s!==7&&s!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Bl(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let s=0;16>s;s++){let i=this.bytes[s]-e.bytes[s];if(i!==0)return Math.sign(i)}return 0}},Kk=class{generate(){let t=this.generateOrAbort();if(!S(t))return t;{this.Ct=0;let e=this.generateOrAbort();if(S(e))throw new Error("Could not generate UUID after timestamp reset");return e}}generateOrAbort(){let t=(()=>{let e=Date.now();return Te(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(t>this.Ct)this.Ct=t,this.It();else{if(this.Ct>=t+1e4)return;this.Mt++,this.Mt>4398046511103&&(this.Ct++,this.It())}return Wk.fromFieldsV7(this.Ct,Math.trunc(this.Mt/Math.pow(2,30)),this.Mt&Math.pow(2,30)-1,this.Tt.nextUint32())}It(){this.Mt=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.Mt=0,this.Tt=new Yk}},xp=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};E&&!S(E.crypto)&&crypto.getRandomValues&&(xp=t=>crypto.getRandomValues(t));Yk=class{nextUint32(){return this.Rt.length>this.Et||(xp(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}},bt=()=>Qk().toString(),Qk=()=>(ef||(ef=new Kk)).generate(),qi="",Jk=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Xs=null,Ee={At(){if(!we(Xs))return Xs;if(Xs=!1,T)try{let t=`__ph_cookie_support_${bt()}`;Ee.$t(t,"xyz"),Xs=ln(t)==='"xyz"',Ee.Pt(t)}catch{Xs=!1}return Xs},Lt(t){R.error("cookieStore error: "+t)},Ot:ln,Dt(t){let e;try{e=JSON.parse(Ee.Ot(t))||{}}catch{}return e},$t(t,e,s,i,n){if(!T)return!1;try{let r="",o="",a=(function(c,u){if(u){let h=(function(d,g=T){if(qi)return qi;if(!g||["localhost","127.0.0.1"].includes(d))return"";let p=d.split("."),m=Math.min(p.length,8),v="dmn_chk_"+bt();for(;!qi&&m--;){let b=p.slice(m).join("."),y=v+"=1;domain=."+b+";path=/";g.cookie=y+";max-age=3",g.cookie.includes(v)&&(g.cookie=y+";max-age=0",qi=b)}return qi})(c);if(!h){let d=(g=>{let p=g.match(Jk);return p?p[0]:""})(c);d!==h&&R.info("Warning: cookie subdomain discovery mismatch",d,h),h=d}return h?"; domain=."+h:""}return""})(T.location.hostname,i);if(s){let c=new Date;c.setTime(c.getTime()+864e5*s),r="; expires="+c.toUTCString()}n&&(o="; secure");let l=t+"="+encodeURIComponent(JSON.stringify(e))+r+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&R.warn("cookieStore warning: large cookie, len="+l.length),T.cookie=l,!0}catch{return!1}},Pt(t,e){if(T?.cookie&&(!e||!we(ln(t))))try{Ee.$t(t,"",-1,e)}catch{return}}},qa=null,J={At(){if(!we(qa))return qa;let t=!0;if(S(E))t=!1;else try{let e="__mplssupport__";J.$t(e,"xyz"),J.Ot(e)!=='"xyz"'&&(t=!1),J.Pt(e)}catch{t=!1}return t||R.error("localStorage unsupported; falling back to cookie store"),qa=t,t},Lt(t){R.error("localStorage error: "+t)},Ot(t){try{return E?.localStorage.getItem(t)}catch(e){J.Lt(e)}return null},Dt(t){try{return JSON.parse(J.Ot(t))||{}}catch{}return null},$t(t,e){try{return E?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(s){J.Lt(s)}return!1},Pt(t){try{E?.localStorage.removeItem(t)}catch(e){J.Lt(e)}}},Wa=[as,zt,yt,Ds,cs,Ns,us,vn,ls],xs=[rc,mt,ri,fp,lc,oi,ui,Qe],Zr=t=>t+"_cpm",Xk=["__proto__","constructor","prototype"],Ka=t=>{if(!G(t))return{};let e={};return Object.keys(t).forEach(s=>{Xk.indexOf(s)===-1&&(e[s]=t[s])}),e},Ya=(t,e=[])=>{let s={};return[...xs,...e].forEach(i=>{let n=t[i];S(n)||we(n)||n===""||(s[i]=n)}),s},Dp=t=>{let e=5381,s=2166136261;for(let i=0;t.length>i;i++){let n=t.charCodeAt(i);e=33*e^n,s=Math.imul(s^n,16777619)}return t.length.toString(36)+"."+(e>>>0).toString(36)+"."+(s>>>0).toString(36)},tf=(t,e)=>({p:e,f:Dp(JSON.stringify(t))}),sf=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{let s=Ee.Dt(Zr(t)),i=s?.f===Dp(e)&&N(s.p);return{properties:i?s.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},Qa=(t,e)=>e+"|"+(Ee.Ot(Zr(t))||""),Zs={},Vl={At:()=>!0,Lt(t){R.error("memoryStorage error: "+t)},Ot:t=>t in Zs?Zs[t]:null,Dt:t=>t in Zs?Zs[t]:null,$t:(t,e)=>(Zs[t]=e,!0),Pt(t){delete Zs[t]}},Ts=null,de={At(){if(!we(Ts))return Ts;if(Ts=!0,S(E))Ts=!1;else try{let t="__support__";de.$t(t,"xyz"),de.Ot(t)!=='"xyz"'&&(Ts=!1),de.Pt(t)}catch{Ts=!1}return Ts},Lt(t){R.error("sessionStorage error: ",t)},Ot(t){try{return E?.sessionStorage.getItem(t)}catch(e){de.Lt(e)}return null},Dt(t){try{return JSON.parse(de.Ot(t))||null}catch{}return null},$t(t,e){try{return E?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(s){de.Lt(s)}return!1},Pt(t){try{E?.sessionStorage.removeItem(t)}catch(e){de.Lt(e)}}},Zk=class{constructor(t){this._instance=t}get Mr(){return this._instance.config}get consent(){return this.Do()?0:this.Lo}isOptedOut(){return this.Mr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Mr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Mr.opt_out_capturing_by_default}optInOut(t){this.No.$t(this.qo,t?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.No.Pt(this.qo,this.Mr.cross_subdomain_cookie)}get qo(){let{token:t,opt_out_capturing_cookie_prefix:e,consent_persistence_name:s}=this._instance.config;return s||(e?e+t:"__ph_opt_in_out_"+t)}get Lo(){let t=this.No.Ot(this.qo);return Da(t)?1:M(Xw,t)?0:-1}get No(){let t=this.Mr.opt_out_capturing_persistence_type,e=t==="localStorage"?J:Ee,s=e.At()?e:Vl;if(!this.jo||this.jo!==s){this.jo=s;let i=t==="localStorage"?Ee:J;i.Ot(this.qo)&&(this.jo.Ot(this.qo)||this.optInOut(Da(i.Ot(this.qo))),i.Pt(this.qo,this.Mr.cross_subdomain_cookie))}return this.jo}Do(){return!!this.Mr.respect_dnt&&[Le?.doNotTrack,Le?.msDoNotTrack,L.doNotTrack,Le?.globalPrivacyControl].some(t=>Da(t))}};vc=["a","button","form","input","select","textarea","label"];Ja=[".ph-no-autocapture","[data-ph-no-autocapture]"],Up=["next","previous","prev",">","<","\u2192","\u2190","\u203A","\u2039","\xBB","\xAB","\u25B6","\u25C0","\u276F","\u276E"],_c=[...Up,"+","-","\u2212","\u2013"],of=_c.length+10,eA=["button","a","input","select","textarea","label"],tA=["button","link","tab","menuitem","option"],af=(t,e)=>/[a-z0-9]/i.test(e)?M(_c,e)?new RegExp(`\\b${e}\\b`).test(t):t.includes(e):t===e,sA=t=>M(eA,t.tagName.toLowerCase())||M(tA,(t.getAttribute("role")||"").toLowerCase());lf=[".ph-no-rageclick",".ph-no-capture"],iA=["","text","search","email","password","url","tel","number"];mc=t=>!t||Ue(t,"html")||!Et(t),Vp=(t,e)=>{if(!E||mc(t))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1,i=[t],n=t;for(;n.parentNode&&!Ue(n,"body");){if(gc(n.parentNode)){i.push(n.parentNode.host),n=n.parentNode.host;continue}let r=Lp(n);if(!r)break;if(e||vc.indexOf(r.tagName.toLowerCase())>-1)s=!0;else try{let o=E.getComputedStyle(r);o&&o.getPropertyValue("cursor")==="pointer"&&(s=!0)}catch{}i.push(r),n=r}return{parentIsUsefulElement:s,targetElementList:i}};cf=new RegExp("^(?:(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}))$"),uf=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,nA=[16,15,14,13],rA=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),df=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),hf=/[0-9A-Za-z_]/;Ir=ye("[Dead Clicks]"),lA=()=>!0,cA=t=>{var e;let s=!!(!((e=t.instance.persistence)===null||e===void 0)&&e.get_property(oc)),i=t.instance.config.capture_dead_clicks;return Je(i)?i:!!G(i)||s},pf=class{get lazyLoadedDeadClicksAutocapture(){return this.Bo}constructor(t,e,s){this.instance=t,this.isEnabled=e,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(t){if(!t.ok)return;let e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[oc]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.zo(()=>{this.Ho()}):this.stop()}zo(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture?t():(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this.instance,"dead-clicks-autocapture",n=>{n?Ir.error("failed to load script",n):t()})}Ho(){var t;if(T){if(!this.Bo&&(!((t=L.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture)){let e=G(this.instance.config.capture_dead_clicks)?_({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Bo=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Bo.start(T),Ir.info("starting...")}}else Ir.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,Ir.info("stopping..."))}},Wi=ye("[SegmentIntegration]");Gp="posthog-js";uA=class{constructor(t,e,s,i,n,r){this.name=Gp,this.setupOnce=function(o){o(Hp(t,{organization:e,projectId:s,prefix:i,severityAllowList:n,sendExceptionsToPostHog:r==null||r}))}}},_f=class{constructor(t){this.Uo=(e,s,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(R.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this.Wo=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Vo()}Vo(){var t;this.Go=(t=this._instance.sessionManager)===null||t===void 0?void 0:t.onSessionId(this.Uo)}destroy(){var t;(t=this.Go)===null||t===void 0||t.call(this),this.Go=void 0}doPageView(t,e){var s;let i=this.Qo(t,e);return this.Wo={pathname:(s=E?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:e,timestamp:t},this._instance.scrollManager.resetContext(),i}doPageLeave(t){var e;return this.Qo(t,(e=this.Wo)===null||e===void 0?void 0:e.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.Wo)===null||t===void 0?void 0:t.pageViewId}}Qo(t,e){let s=this.Wo;if(!s)return{$pageview_id:e};let i={$pageview_id:e,$prev_pageview_id:s.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:r,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=n;if(!(S(r)||S(o)||S(a)||S(l)||S(c)||S(u))){r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);let h=r>1?Rt(o/r,0,1,R):1,d=r>1?Rt(a/r,0,1,R):1,g=l>1?Rt(c/l,0,1,R):1,p=l>1?Rt(u/l,0,1,R):1;i=ve(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:g,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return s.pathname&&(i.$prev_pageview_pathname=s.pathname),s.timestamp&&(i.$prev_pageview_duration=(t.getTime()-s.timestamp.getTime())/1e3),i}},Ki=["flags","surveys"],dA={[Sk]:{exposure:"hidden"},[Qr]:{exposure:"hidden"},[kk]:{exposure:"hidden"},[$l]:{exposure:"hidden"},[ui]:{exposure:"hidden"},[on]:{exposure:"hidden"},[cp]:{exposure:"event"},[xl]:{exposure:"hidden"},[dp]:{exposure:"hidden"},[Dl]:{exposure:"event"},[up]:{exposure:"hidden"},[Nl]:{exposure:"event"},[Ml]:{exposure:"event"},[oc]:{exposure:"event"},[ac]:{exposure:"hidden"},[hp]:{exposure:"event"},[an]:{exposure:"hidden"},[Ak]:{exposure:"hidden"},[ri]:{exposure:"hidden"},[fp]:{exposure:"event"},[Tk]:{exposure:"event",shouldSkipFromEventProperties:t=>we(t)},[Pk]:{exposure:"event"},[$k]:{exposure:"event"},[xk]:{exposure:"event"},[Dk]:{exposure:"event"},[Nk]:{exposure:"hidden"},[yt]:{exposure:"hidden",storageGroup:"flags"},[zt]:{exposure:"hidden",storageGroup:"flags"},[Pl]:{exposure:"hidden"},[Ds]:{exposure:"hidden",storageGroup:"flags"},[cs]:{exposure:"hidden",storageGroup:"flags"},[Ns]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[rn]:{exposure:"hidden",storageGroup:"flags"},[Tt]:{exposure:"hidden"},[$s]:{exposure:"hidden"},[as]:{exposure:"hidden"},[os]:{exposure:"hidden"},[en]:{exposure:"hidden",storageGroup:"surveys"},[Jr]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[pp]:{exposure:"event"},[vp]:{exposure:"hidden"},[_p]:{exposure:"hidden"},[Fl]:{exposure:"hidden"},[Mk]:{exposure:"hidden"},[Fk]:{exposure:"hidden"},[Lk]:{exposure:"event"},[Uk]:{exposure:"event"},[Bk]:{exposure:"event"},[Vk]:{exposure:"event"},[ls]:{exposure:"hidden"},[Zi]:{exposure:"hidden"},[gp]:{exposure:"event"},[vn]:{exposure:"hidden"},[us]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Qe]:{exposure:"hidden"},[Ll]:{exposure:"hidden"},[jk]:{exposure:"hidden"},[mp]:{exposure:"hidden"},[yp]:{exposure:"hidden"},[oi]:{exposure:"hidden"},[lc]:{exposure:"hidden"},[Ik]:{exposure:"event"},[Rk]:{exposure:"event"},[Ck]:{exposure:"event"},[Ok]:{exposure:"event"},[Ep]:{exposure:"event"},[wp]:{exposure:"event"},[cc]:{exposure:"hidden"},[uc]:{exposure:"hidden"},[Sp]:{exposure:"hidden"},[kp]:{exposure:"hidden"},[Ap]:{exposure:"hidden"},[Tp]:{exposure:"hidden"},[Ip]:{exposure:"hidden"},[Rp]:{exposure:"hidden"},[Cp]:{exposure:"hidden"},[Gk]:{exposure:"event"}},hA=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Ne=t=>{let e=dA[t];if(e)return e;for(let[s,i]of hA)if(t.indexOf(s)===0)return i};qp=()=>{try{return"u">typeof window&&window.navigator.onLine!==!1}catch{return!1}},Wp=(t,e)=>t>=e&&qp(),Kp=(t,e,s,i)=>{if(t===0){if(qp()){let n=e+1;return n===s&&i(),n}return e}return 0},li=(t,e)=>{try{let s;return JSON.stringify(t,(i,n)=>{var r;return bi(n)?((r=s)!==null&&r!==void 0||(s=new WeakMap),s.has(n)||s.set(n,$p(n)),s.get(n)):typeof n=="bigint"?n.toString():n},e)}catch{return og(t)}},Kt=t=>{let e=T?.createElement("a");return S(e)?null:(e.href=t,e)},vi=function(t,e){let s=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i;for(let n=0;s.length>n;n++){let r=s[n].split("=");if(r[0]===e){i=r;break}}if(!N(i)||2>i.length)return"";{let n=i[1];try{n=decodeURIComponent(n)}catch{R.error("Skipping decoding for malformed query param: "+n)}return n.replace(/\+/g," ")}},yn=function(t,e,s){if(!t||!e||!e.length)return t;let i=t.split("#"),n=i[1],r=(i[0]||"").split("?"),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let h=0;l.length>h;h++){let d=l[h].split("=");N(d)&&(e.includes(d[0])?c.push(d[0]+"="+s):c.push(l[h]))}let u=a;return o!=null&&(u+="?"+c.join("&")),n!=null&&(u+="#"+n),u},eo=function(t,e){let s=t.match(new RegExp(e+"=([^&]*)"));return s?s[1]:null},_i=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx"],fA=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",..._i],bn="<masked>",gA=["li_fat_id"];to="$direct";_A={flags:us,surveys:Jr},mA=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Rr=t=>`${t}_cookie_identity_change_pending`,Cr=t=>{let e="",s=0;for(let i of t){let n=encodeURIComponent(JSON.stringify(i).slice(1,-1)).length;if(s+n>1e3)break;e+=i,s+=n}return e},Pe="main",Ht=[yt,zt,Ds,cs,Ns,us,rn,as],Za=t=>Ht.indexOf(t)!==-1,sv=[ui,on],mf=t=>sv.indexOf(t)!==-1,is=(t,e)=>{try{return JSON.stringify(t)===JSON.stringify(e)}catch{return t===e}},ei=t=>{if(!t)return{};let e=JSON.parse(t);return G(e)?e:{}},yf=(t,e)=>{re(t,(s,i)=>{let n=Ne(i);n&&n.exposure!=="event"||{}.hasOwnProperty.call(e,i)||delete t[i]})},el=class{constructor(t,e,s=!0,i=!t.cookieless_mode){if(this.Zo={},this.Jo=!1,this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=!1,this.ea=new Map,this.ia=!1,this.na=!1,this.sa=!1,this.ra=new Set,this.oa=new Set,this.Mr=t,this.aa=s,this.props={},this.la=void 0,this.ua=(n=>{let r="";return n.token&&(r=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+r+"_posthog"})(t),this.hi=t.disable_persistence||!!e,this.No=this.ca(t),this.Xo=this.ha(t),this.load(i),this.da(),t.debug&&R.info("Persistence loaded",t.persistence,_({},this.props)),this.update_config(t,t,e),this.save(),E){let n=()=>this.flush();se(E,"beforeunload",n,{capture:!1}),se(E,"pagehide",n,{capture:!1}),this.va=r=>{if(this.Jo&&(!r.storageArea||r.storageArea===E?.localStorage)&&r.key)if(r.key!==this.ua){if(this.Xo){let o=Ki.find(a=>r.key===this.fa(a));o&&this.pa(r.key,o)}}else this.pa(r.key,Pe)},se(E,"storage",this.va)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(([e,s])=>{let i=this.ea.get(e);if(!Za(e)||i===!0)return;if(s===!0)return void this.ga(e,!0);let n=new Set(i||[]);s.forEach(r=>n.add(r)),n.size&&this.ga(e,n)})}onCrossTabFeatureFlagChange(t){return this.oa.add(t),()=>this.oa.delete(t)}destroy(){this.va&&E&&(E.removeEventListener("storage",this.va),this.va=void 0),this.oa.clear()}pa(t,e,s=!0){if(this.hi)return!1;let i,n;try{if(n=J.Ot(t),we(n)){let a=this.ma(e);return a.storageValue=null,e!==Pe&&(a.persisted=!1),!1}i=ei(n)}catch{return!1}let r=e===Pe?i:J.Dt(this.ua);if(r&&this.ya(r))return!1;let o=this.ba(i,e,s);return e===Pe&&this.Xo&&!is(this._a().main,i)||this.wa(i,e,!0,n),o}ya(t){let e=this.props[mt],s=t[mt];return!S(e)&&!S(s)&&e!==s}wa(t,e,s,i){let n=this.ma(e);n.storageValue=i,e!==Pe&&(n.persisted=s);try{n.fingerprint=this.ka(t,e)}catch{n.fingerprint=void 0}}ba(t,e,s){let i=!1;return Ht.forEach(n=>{var r;let o=(r=Ne(n))===null||r===void 0?void 0:r.storageGroup;if(e===Pe&&this.Xo&&o||e!==Pe&&o!==e)return;let a=n in t,l=this.Sa(n,a?t[n]:void 0),c=this.ea.has(n)?n in this.props:a;c===n in this.props&&is(l,this.props[n])||(c?this.xa(n,l,!1):this.$a(n,!1),i=!0)}),i&&s&&this.oa.forEach(n=>n()),i}Ca(){if(!this.Jo)return!1;try{this.sa=!1;let t=J.Ot(this.ua),e=this.ma(Pe),s,i=!1,n=!1;if(t!==e.storageValue)if(we(t))e.storageValue=null;else{if(s=ei(t),this.sa=!this.na&&this.ya(s),this.sa)return!1;n=this.ba(s,Pe,!1),!this.Xo||is(this._a().main,s)?this.wa(s,Pe,!0,t):e.storageValue=t,i=!0}return this.Xo&&Ki.forEach(r=>{let o=J.Ot(this.fa(r)),a=this.ma(r),l=s||{},c=i&&Ht.some(h=>{var d;return((d=Ne(h))===null||d===void 0?void 0:d.storageGroup)===r&&h in l});if(o===a.storageValue&&!c)return;if(we(o))return a.storageValue=null,a.persisted=!1,void(c&&(n=this.ba(l,r,!1)||n));let u=ei(o);n=this.ba(u,r,!1)||n,this.wa(u,r,!0,o)}),n}catch{return!1}}ga(t,e){this.ea.set(t,e);let s=Ne(t);s?.volatile||(this.ma((this.Xo?s?.storageGroup:void 0)||Pe).fingerprint=void 0,this.Ta(t))}Ia(){Ht.forEach(t=>this.ea.set(t,!0))}da(){if(this.Jo)try{let t=J.Ot(this.ua),e=ei(t);this.ma(Pe).storageValue=t,Ht.forEach(s=>{var i;let n=this.Xo?(i=Ne(s))===null||i===void 0?void 0:i.storageGroup:void 0,r=n?J.Ot(this.fa(n)):null;if(n){let a=this.ma(n);a.storageValue=r,a.persisted=!we(r)}let o=n&&!we(r)?ei(r):e;s in this.props?this.Ma(s,o[s],this.props[s]):s in o&&this.ga(s,!0)})}catch{}}Sa(t,e){let s=this.ea.get(t);if(!s)return e;if(s===!0)return this.props[t];if(t==="$active_feature_flags"){let r=new Set(N(e)?e:[]),o=new Set(N(this.props[t])?this.props[t]:[]);return s.forEach(a=>o.has(a)?r.add(a):r.delete(a)),Array.from(r)}let i=G(e)?_({},e):{},n=G(this.props[t])?this.props[t]:{};return s.forEach(r=>{r in n?i[r]=n[r]:delete i[r]}),i}Ma(t,e,s){if(!Za(t))return;let i=this.ea.get(t);if(i===!0)return;let n=e;if(this.Jo)try{var r;let a=this.Xo?(r=Ne(t))===null||r===void 0?void 0:r.storageGroup:void 0,l=a?this.fa(a):this.ua;n=ei(J.Ot(l))[t]}catch{}let o=new Set(i||[]);if(t==="$active_feature_flags"){if(!S(e)&&!N(e)||!S(n)&&!N(n)||!N(s))return void this.ga(t,!0);let a=new Set(e||[]),l=new Set(n||[]),c=new Set(s);new Set([...a,...c]).forEach(u=>{a.has(u)!==c.has(u)&&o.add(u)}),o.forEach(u=>{l.has(u)===c.has(u)&&o.delete(u)})}else{if(!G(s))return void(is(n,s)?this.ea.delete(t):this.ga(t,!0));{if(!S(e)&&!G(e)||S(e)&&nt(s)&&S(n))return void this.ga(t,!0);let a=G(e)?e:{},l=G(n)?n:{};new Set([...Object.keys(a),...Object.keys(s)]).forEach(c=>{c in a==c in s&&is(a[c],s[c])||o.add(c)}),o.forEach(c=>{c in l==c in s&&is(l[c],s[c])&&o.delete(c)})}}o.size?this.ga(t,o):this.ea.delete(t)}Ea(){var t;let e=(t=this.Mr)===null||t===void 0?void 0:t.persistence_save_debounce_ms;return Te(e)&&e>0?e:0}Pa(t){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(t)try{let e=Ya(t,this.Mr.cookie_persisted_properties||[]),s=tf(e,this.Mr.cookie_persisted_properties||[]),i=JSON.stringify(e)+"|"+JSON.stringify(s),n=Ee.Ot(this.ua)||void 0;n&&Qa(this.ua,n)===i&&(this.Ra=i,this.Aa=n)}catch{}else try{let e=Ee.Ot(this.ua)||void 0;this.Ra=e?Qa(this.ua,e):void 0,this.Aa=e}catch{}}syncCookieProperties(){return this.Fa(this.Mr)}Fa(t,e=!1){if(this.hi&&!e||this.ta||!t.cookieWinsOnConflict||t.persistence.toLowerCase()!=="localstorage+cookie")return!1;let s;try{s=Ee.Ot(this.ua)||void 0}catch{}if(!s||s===this.Aa)return!1;let i=Qa(this.ua,s),n;try{n=Ka(JSON.parse(s))}catch{return!1}if((Ee.Ot(this.ua)||void 0)!==s)return!1;this.Ra=i,this.Aa=s;let r=sf(this.ua,s),o=[...xs,...r.properties],a={};if(Object.keys(n).forEach(m=>{let v=n[m];(S(v)||we(v)||v===""||m==="$user_state"&&v!=="anonymous"&&v!=="identified")&&(a[m]=!0,delete n[m])}),nt(n))return!1;let l="distinct_id"in n||n.$user_state==="anonymous"||n.$user_state==="identified",c=this.props,u=c[mt],h=c[Qe],d=ve({},c);[...xs,...t.cookie_persisted_properties||[]].forEach(m=>{if(o.indexOf(m)!==-1&&!(m in n)&&!a[m]&&(l||m!=="distinct_id"&&m!=="$user_state")){let v=d[m];(r.isValid||xs.indexOf(m)===-1||v!==!1&&v!==0)&&delete d[m]}}),this.props=ve(d,n),Ht.forEach(m=>{let v=m in this.props;m in c===v&&is(c[m],this.props[m])||(v?this.Ma(m,c[m],this.props[m]):this.ga(m,!0))}),!l||"$user_state"in n||"$user_state"in this.props||this.xa(Qe,qt);let g=this.props[mt],p=this.props[Qe];return!l||g===u&&p===h||(this.na=!0,this.Yo=!0,de.$t(Rr(this.ua),!0),this.$a(as),this.$a(zt),this.$a(yt),this.$a(Ds),this.$a(cs),this.$a(Ns),this.$a(us),this.$a(vn),this.$a(ls),p!=="anonymous"||h!=="identified"&&n.$user_state!=="anonymous"&&(S(u)||g===u)||(yf(this.props,n),this.$a(os)),p==="identified"?this.props.$user_id=g:delete this.props.$user_id,this.$a(Qr)),!0}consumeCookieIdentityChange(){let t=Rr(this.ua),e=this.Yo||!!de.Ot(t);return this.Yo=!1,e&&de.Pt(t),e}Oa(t=!1){return!(this.ta||this.hi&&!t||!this.Mr.cookieWinsOnConflict||this.Mr.persistence.toLowerCase()!=="localstorage+cookie"||(this.ta=!0,0))}Da(){this.ta&&(S(this.La)||(clearTimeout(this.La),this.La=void 0),delete this.Zo[Pe],this.Na(!0))}qa(t=!0){if(this.ta)try{t?this.Da():S(this.La)||(clearTimeout(this.La),this.La=void 0)}finally{this.ta=!1}}isDisabled(){return!!this.hi}ca(t){mA.indexOf(t.persistence.toLowerCase())===-1&&(R.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");let e=((o=[],a=!1,l=()=>!1)=>{let c=[...xs,...o];return _(_({},J),{},{Dt(u){try{let d,g={};try{d=Ee.Ot(u)||void 0,g=d?Ka(JSON.parse(d)):{}}catch{}let p=JSON.parse(J.Ot(u)||"{}"),m;if(a){let v=sf(u,d),b=[...xs,...v.properties],y={};Object.keys(g).forEach(A=>{let I=g[A];we(I)||I===""||A==="$user_state"&&I!=="anonymous"&&I!=="identified"||(y[A]=I)});let w="distinct_id"in y||y.$user_state==="anonymous"||y.$user_state==="identified";if(Object.keys(y).length>0){var h;let A=p[mt],I=(h=p.$user_state)!==null&&h!==void 0?h:qt;c.forEach(k=>{if(b.indexOf(k)!==-1&&!(k in g)&&(w||k!=="distinct_id"&&k!=="$user_state")){let $=p[k];(v.isValid||xs.indexOf(k)===-1||$!==!1&&$!==0)&&delete p[k]}}),!w||"$user_state"in g||"$user_state"in p||(p[Qe]=qt),!w||("distinct_id"in y?y[mt]:p[mt])===A&&("$user_state"in y?y[Qe]:p[Qe])===I||(Wa.forEach(k=>delete p[k]),y.$user_state==="identified"&&"distinct_id"in y?p.$user_id=y[mt]:delete p.$user_id,y.$user_state!=="identified"&&(delete p[gp],delete p[os]),delete p.__alias)}m=ve(p,y)}else m=ve(g,p);return l()||J.$t(u,m),m}catch{}return null},$t(u,h,d,g,p,m){let v=J.$t(u,h,void 0,void 0,m);try{let b=Ya(h,o);if(Object.keys(b).length){if(a){let y=Zr(u),w=tf(b,o);if(Ee.$t(y,w,d,g,p,m),Ee.Ot(y)!==JSON.stringify(w)){Ee.Pt(y,g);let A=Ya(h);return Ee.$t(u,A,d,g,p,m),v}}Ee.$t(u,b,d,g,p,m)}}catch(b){J.Lt(b)}return v},Pt(u,h){try{E?.localStorage.removeItem(u),Ee.Pt(u,h),Ee.Pt(Zr(u),h)}catch(d){J.Lt(d)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict,()=>!!this.hi),s,i=!1,n=!1,r=t.persistence.toLowerCase();return r==="localstorage"&&J.At()?(s=J,n=!0):r==="localstorage+cookie"&&e.At()?(s=e,n=!0,i=!0):r==="sessionstorage"&&de.At()?s=de:r==="memory"?s=Vl:r==="cookie"&&Ee.At()?(s=Ee,i=!0):e.At()?(s=e,n=!0,i=!0):Ee.At()?(s=Ee,i=!0):s=Vl,this.Jo=n,this.Ko=i,s}fa(t){return`${this.ua}__${t}`}ha(t){return this.Jo&&!!t.split_storage}properties(){let t={};return re(this.props,(e,s)=>{let i=Ne(s);if(!i||i.exposure==="event"){var n;if(!(i==null||(n=i.shouldSkipFromEventProperties)===null||n===void 0)&&n.call(i,e))return;t[s]=e}}),t}load(t=!1){if(this.hi&&!t)return;let e=this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie",s=e?J.Dt(this.ua):null,i={};if(e)try{i=Ka(Ee.Dt(this.ua)),re(i,(a,l)=>{(S(a)||we(a)||a==="")&&delete i[l]})}catch{}let n=this.No.Dt(this.ua);if(n&&(this.props=ve({},n)),this.Xo&&this.ja(),e&&n){var r,o;let a=s?.[mt],l=(r=s?.$user_state)!==null&&r!==void 0?r:qt,c=n[mt],u=(o=n.$user_state)!==null&&o!==void 0?o:qt;if(c!==a||u!==l){this.Yo=!0,this.hi||de.$t(Rr(this.ua),!0);let h=ve({},this.props);Wa.forEach(g=>delete h[g]),u!=="anonymous"||l!=="identified"&&i.$user_state!=="anonymous"&&(S(a)||c===a)||(yf(h,i),delete h[os]),this.props=h;let d=new Set;Wa.forEach(g=>{var p;let m=(p=Ne(g))===null||p===void 0?void 0:p.storageGroup;m&&d.add(m)}),d.forEach(g=>{if(this.hi)return;let p={};re(this.props,(m,v)=>{var b;((b=Ne(v))===null||b===void 0?void 0:b.storageGroup)===g&&(p[v]=m)}),nt(p)?(J.Pt(this.fa(g)),this.Zo[g]={}):J.$t(this.fa(g),p)&&(this.Zo[g]={persisted:!0,fingerprint:this.ka(p,g)})})}}de.Ot(Rr(this.ua))&&(this.Yo=!0)}ja(){for(let t of Ki){let e=J.Dt(this.fa(t));if(e&&!nt(e)){let s=this.ma(t);s.persisted=!0,this.Ba(t)||(s.fingerprint=this.ka(e,t)),this.za(t,e)||ve(this.props,e)}}}Ba(t){return Object.keys(this.props).some(e=>{var s;return((s=Ne(e))===null||s===void 0?void 0:s.storageGroup)===t})}za(t,e){let s=_A[t];if(!s)return!1;let i=e[s],n=this.props[s];return Te(i)&&Te(n)&&n>i}refreshKey(t){var e;if(this.hi||this.ra.has(t))return;let s=this.Xo?(e=Ne(t))===null||e===void 0?void 0:e.storageGroup:void 0,i=s?J.Dt(this.fa(s)):this.No.Dt(this.ua);if(i&&t in i)this.xa(t,i[t],!1);else{if(s){let n=this.No.Dt(this.ua);if(n&&t in n)return void this.xa(t,n[t],!1)}this.$a(t,!1)}}save(){if(this.hi)return;let t=this.Ea();t>0?S(this.La)&&(this.La=setTimeout(()=>{this.La=void 0,this.Na()},t)):this.Na()}flush(){S(this.La)||(clearTimeout(this.La),this.La=void 0,this.Na())}Na(t=!1){if(this.hi||this.ta&&!t)return;t||(this.syncCookieProperties(),this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie"||sv.forEach(n=>this.refreshKey(n)));let e=!t&&!this.ia;e||(this.sa=!1);let s=!!e&&this.Ca();if(this.sa)return void(this.Mr.debug&&R.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Xo)return this.Ha(),void(s&&this.oa.forEach(n=>n()));let i=this.Ua(this.No,this.ua,this.props,Pe);i==="written"&&this.Pa(this.props),i!=="failed"&&(this.ea.clear(),this.na=!1,this.ra.clear()),s&&this.oa.forEach(n=>n())}Ha(){let{main:t,groups:e}=this._a(),s=this.Ua(this.No,this.ua,t,Pe);s==="written"&&this.Pa(t),s!=="failed"&&(this.na=!1,this.ra.clear(),Ht.forEach(n=>{var r;!((r=Ne(n))===null||r===void 0)&&r.storageGroup||this.ea.delete(n)}));for(let n of Ki){var i;let r=e[n];if(nt(r)&&!(!((i=this.Zo[n])===null||i===void 0)&&i.persisted)){Ht.forEach(a=>{var l;((l=Ne(a))===null||l===void 0?void 0:l.storageGroup)===n&&this.ea.delete(a)});continue}let o=this.Ua(J,this.fa(n),r,n);o!=="failed"&&Ht.forEach(a=>{let l=Ne(a);l?.storageGroup!==n||o!=="written"&&l.volatile||this.ea.delete(a)})}}_a(){let t={},e={flags:{},surveys:{}};return re(this.props,(s,i)=>{var n;let r=(n=Ne(i))===null||n===void 0?void 0:n.storageGroup;r?e[r][i]=s:t[i]=s}),{main:t,groups:e}}ka(t,e){if(e===Pe)return JSON.stringify(t)+"|"+this.Wa+"|"+this.Va+"|"+this.Ga;let s={};return re(t,(i,n)=>{var r;s[n]=!((r=Ne(n))===null||r===void 0)&&r.volatile?"__volatile__":i}),JSON.stringify(s)}Ua(t,e,s,i){let n=this.ma(i);if(i!==Pe&&!n.dirty&&!S(n.fingerprint))return"skipped";let r;try{if(r=this.ka(s,i),r===n.fingerprint)return n.dirty=!1,"skipped"}catch{r=void 0}return t.$t(e,s,this.Wa,this.Va,this.Ga,this.Mr.debug)?(n.dirty=!1,i!==Pe&&(n.persisted=!0),S(r)||(n.fingerprint=r),this.Jo&&(n.storageValue=J.Ot(e)),"written"):(this.Mr.debug&&R.warn(`failed to persist storage entry "${e}"; will retry on next save`),"failed")}remove({keepGroupEntries:t=!1}={}){if(this.Ia(),S(this.La)||(clearTimeout(this.La),this.La=void 0),this.No.Pt(this.ua,!1),this.No.Pt(this.ua,!0),!t&&this.aa)for(let e of Ki)J.Pt(this.fa(e));t?delete this.Zo[Pe]:this.Zo={},this.Ra=void 0,this.Aa=void 0}clear(){this.remove(),this.props={}}register_once(t,e,s){if(G(t)){this.syncCookieProperties(),S(e)&&(e="None"),this.Wa=S(s)?this.Qa:s;let i=!1;if(re(t,(n,r)=>{this.props.hasOwnProperty(r)&&this.props[r]!==e||(this.xa(r,n),i=!0)}),i)return this.save(),!0}return!1}register(t,e){if(G(t)){this.syncCookieProperties(),this.Wa=S(e)?this.Qa:e;let s=!1;if(re(t,(i,n)=>{t.hasOwnProperty(n)&&(this.props[n]!==i||G(i)||N(i))&&(this.xa(n,i),s=!0)}),s)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();let e=typeof t=="string"?[t]:t,s=!1;for(let i of e)i in this.props&&(this.$a(i),s=!0);s&&this.save()}update_campaign_params(){let t=T?.URL;if(t===this.la)return;let e=Yp(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),s=!nt(fc(e));return s&&this.register(e),this.la=t,s?e:void 0}update_search_keyword(){this.register((function(){let t=T?.referrer;return t?Jp(t):{}})())}update_referrer_info(){var t;this.register_once({$referrer:Zp(),$referring_domain:T?.referrer&&((t=Kt(T.referrer))===null||t===void 0?void 0:t.host)||to},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;let t=ev(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[oi]:this.Ko?{r:Cr(t.r),u:t.u?Cr(t.u):void 0}:t},void 0)}get_initial_props(){let t={};re([yp,mp],s=>{let i=this.props[s];i&&re(i,function(n,r){t["$initial_"+wl(r)]=n})});let e=this.props[oi];if(e){let s=(function(i,n=!1){let r=tv(i,n),o={};return re(r,function(a,l){o[`$initial_${wl(l)}`]=a}),o})(e,this.Mr.disable_capture_url_hashes);ve(t,s)}return t}safe_merge(t){return re(this.props,function(e,s){s in t||(t[s]=e)}),t}update_config(t,e,s){let i=t.persistence!==e.persistence,n=!((g,p)=>{if(g.length!==p.length)return!1;let m=[...g].sort(),v=[...p].sort();return m.every((b,y)=>b===v[y])})(t.cookie_persisted_properties||[],e.cookie_persisted_properties||[]),r=i||n,o=t.cookieWinsOnConflict!==e.cookieWinsOnConflict,a=t.disable_persistence||!!s,l=!!this.hi&&!a;a||this.Fa(e,l),this.Mr=t,!a&&(i||n||o)&&(this.Ra=void 0,this.Aa=void 0,this.Fa(_(_({},t),{},{cookie_persisted_properties:e.cookie_persisted_properties}),l));let c=r||o?this.ca(t):this.No;this.Za();let u=this.ha(t),h=r||u!==this.Xo,d=!a&&(h||t.cross_subdomain_cookie!==this.Va||t.secure_cookie!==this.Ga)&&this.Oa(l);this.ia=h;try{if(this.Qa=this.Wa=t.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),h){let g=this.props;this.clear(),this.No=c,this.Xo=u,this.props=g,this.save()}else o&&(this.No=c,a||(delete this.Zo[Pe],this.Na()))}finally{this.ia=!1,d&&this.qa()}}Za(){let t=this.props[oi];if(!this.Ko||!G(t)||typeof t.r!="string")return;let e=Cr(t.r),s=typeof t.u=="string"?Cr(t.u):t.u;e===t.r&&s===t.u||this.xa(oi,_(_({},t),{},{r:e,u:s}))}set_disabled(t){this.hi=t,this.hi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Va&&(this.Va=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Ga&&(this.Ga=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,e){let s=this.props.__timers||{};s[t]=e,this.xa($l,s),this.save()}remove_event_timer(t){let e=this.props.__timers||{},s=e[t];return S(s)||(delete e[t],this.xa($l,e),this.save()),s}get_property(t){return this.props[t]}set_property(t,e){this.xa(t,e),this.save()}xa(t,e,s=!0){var i;let n=this.props[t];this.props[t]=e,s&&(t!=="distinct_id"&&t!=="$user_state"||n===e||(this.na=!0),mf(t)&&!is(n,e)&&this.ra.add(t),this.Ma(t,n,e),!((i=Ne(t))===null||i===void 0)&&i.volatile||this.Ta(t))}$a(t,e=!0){delete this.props[t],e&&(Za(t)&&this.ga(t,!0),mf(t)&&this.ra.add(t),this.Ta(t))}Ta(t){var e;let s=(e=Ne(t))===null||e===void 0?void 0:e.storageGroup;s&&(this.ma(s).dirty=!0)}ma(t){return this.Zo[t]||(this.Zo[t]={})}},ut={GZipJS:"gzip-js",Base64:"base64"},Yi={Activation:"events",Cancellation:"cancelEvents"},tl={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},ct={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},sl={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Hl={Popover:"popover",Inline:"inline"};yA={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"},bf={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"},Ef=ye("[RateLimiter]"),bA=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{let s=e.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(i=>{Ef.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void Ef.warn(`could not rate limit - continuing. Error: "${i?.message}"`,{text:s})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return((t=this.instance.config.rate_limiting)===null||t===void 0?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)===null||t===void 0?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t=!1){var e,s,i;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=new Date().getTime(),a=(e=(s=this.instance.persistence)===null||s===void 0?void 0:s.get_property("$capture_rate_limit"))!==null&&e!==void 0?e:{tokens:n,last:o};a.tokens+=(o-a.last)/1e3*r,a.last=o,a.tokens>n&&(a.tokens=n);let l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){let c=(Te(a.dropped)?a.dropped:0)+1;a.dropped=c,!this.lastEventRateLimited&&this.Ja(c)&&(a.dropped=0)}return this.lastEventRateLimited=l,(i=this.instance.persistence)===null||i===void 0||i.set_property("$capture_rate_limit",a),{isRateLimited:l,remainingTokens:a.tokens}}Ka(t){let e=this.instance.config.property_denylist;return!N(e)||!e.includes(t)}Xa(){var t;if(this.Ka("$current_url")&&this.Ka("$pathname")&&pe?.pathname)return`${(t=pe.origin)!==null&&t!==void 0?t:""}${pe.pathname}`}Ja(t){var e,s;let{captureEventsBurstLimit:i,captureEventsPerSecond:n}=this,r=this.Xa(),o=this.Ka("$session_id")?(e=(s=this.instance).get_session_id)===null||e===void 0?void 0:e.call(s):void 0,a=[`${t} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${a}. Config is set to ${n} events per second and ${i} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(t){let e=this.serverLimits[t||"events"]||!1;return e!==!1&&new Date().getTime()<e}},ns=ye("[RemoteConfig]"),iv=class{constructor(t){this._instance=t}get remoteConfig(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(t=t[this._instance.config.token])===null||t===void 0?void 0:t.config}Ya(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.loadExternalDependency?(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"remote-config",()=>t(this.remoteConfig)):t()}tl(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:t})}load(){try{if(this.remoteConfig)return ns.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance.il())return void ns.warn("Remote config is disabled. Falling back to local config.");this.Ya(t=>{if(!t)return ns.info("No config found after loading remote JS config. Falling back to JSON."),void this.tl(e=>{this.el(e.json,e)});this.el(t)})}catch(t){ns.error("Error loading remote config",t),this.el()}}el(t,e){!t&&e&&(e.statusCode===0?e.error||ns.warn("Failed to fetch remote config from PostHog."):ns.error("Failed to fetch remote config from PostHog."));try{this._instance.el(t?{ok:!0,config:t}:{ok:!1})}catch(i){ns.error("Error applying remote config",i)}if(t?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var s;(s=this._instance.featureFlags)===null||s===void 0||s.ensureFlagsLoaded()}catch(i){ns.error("Error loading feature flags",i)}}},dt=Uint8Array,Xe=Uint16Array,mi=Uint32Array,yc=new dt([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]),bc=new dt([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]),wf=new dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),nv=function(t,e){for(var s=new Xe(31),i=0;31>i;++i)s[i]=e+=1<<t[i-1];var n=new mi(s[30]);for(i=1;30>i;++i)for(var r=s[i];s[i+1]>r;++r)n[r]=r-s[i]<<5|i;return[s,n]},rv=nv(yc,2),zl=rv[1];rv[0][28]=258,zl[258]=28;for(ql=nv(bc,0)[1],so=new Xe(32768),me=0;32768>me;++me)Is=(43690&me)>>>1|(21845&me)<<1,so[me]=((65280&(Is=(61680&(Is=(52428&Is)>>>2|(13107&Is)<<2))>>>4|(3855&Is)<<4))>>>8|(255&Is)<<8)>>>1;un=function(t,e,s){for(var i=t.length,n=0,r=new Xe(e);i>n;++n)++r[t[n]-1];var o,a=new Xe(e);for(n=0;e>n;++n)a[n]=a[n-1]+r[n-1]<<1;if(s){o=new Xe(1<<e);var l=15-e;for(n=0;i>n;++n)if(t[n])for(var c=n<<4|t[n],u=e-t[n],h=a[t[n]-1]++<<u,d=h|(1<<u)-1;d>=h;++h)o[so[h]>>>l]=c}else for(o=new Xe(i),n=0;i>n;++n)o[n]=so[a[t[n]-1]++]>>>15-t[n];return o},Fs=new dt(288);for(me=0;144>me;++me)Fs[me]=8;for(me=144;256>me;++me)Fs[me]=9;for(me=256;280>me;++me)Fs[me]=7;for(me=280;288>me;++me)Fs[me]=8;io=new dt(32);for(me=0;32>me;++me)io[me]=5;EA=un(Fs,9,0),wA=un(io,5,0),ov=function(t){return(t/8|0)+(7&t&&1)},av=function(t,e,s){(e==null||0>e)&&(e=0),(s==null||s>t.length)&&(s=t.length);var i=new(t instanceof Xe?Xe:t instanceof mi?mi:dt)(s-e);return i.set(t.subarray(e,s)),i},Vt=function(t,e,s){var i=e/8|0;t[i]|=s<<=7&e,t[i+1]|=s>>>8},Qi=function(t,e,s){var i=e/8|0;t[i]|=s<<=7&e,t[i+1]|=s>>>8,t[i+2]|=s>>>16},nl=function(t,e){for(var s=[],i=0;t.length>i;++i)t[i]&&s.push({s:i,f:t[i]});var n=s.length,r=s.slice();if(!n)return[new dt(0),0];if(n==1){var o=new dt(s[0].s+1);return o[s[0].s]=1,[o,1]}s.sort(function(I,k){return I.f-k.f}),s.push({s:-1,f:25001});var a=s[0],l=s[1],c=0,u=1,h=2;for(s[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=s[s[h].f>s[c].f?c++:h++],l=s[c!=u&&s[h].f>s[c].f?c++:h++],s[u++]={s:-1,f:a.f+l.f,l:a,r:l};var d=r[0].s;for(i=1;n>i;++i)r[i].s>d&&(d=r[i].s);var g=new Xe(d+1),p=Wl(s[u-1],g,0);if(p>e){i=0;var m=0,v=p-e,b=1<<v;for(r.sort(function(I,k){return g[k.s]-g[I.s]||I.f-k.f});n>i;++i){var y=r[i].s;if(e>=g[y])break;m+=b-(1<<p-g[y]),g[y]=e}for(m>>>=v;m>0;){var w=r[i].s;e>g[w]?m-=1<<e-g[w]++-1:++i}for(;i>=0&&m;--i){var A=r[i].s;g[A]==e&&(--g[A],++m)}p=e}return[new dt(g),p]},Wl=function(t,e,s){return t.s==-1?Math.max(Wl(t.l,e,s+1),Wl(t.r,e,s+1)):e[t.s]=s},Sf=function(t){for(var e=t.length;e&&!t[--e];);for(var s=new Xe(++e),i=0,n=t[0],r=1,o=function(l){s[i++]=l},a=1;e>=a;++a)if(t[a]==n&&a!=e)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=t[a]}return[s.subarray(0,i),e]},Ji=function(t,e){for(var s=0,i=0;e.length>i;++i)s+=t[i]*e[i];return s},Lr=function(t,e,s){var i=s.length,n=ov(e+2);t[n]=255&i,t[n+1]=i>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var r=0;i>r;++r)t[n+r+4]=s[r];return 8*(n+4+i)},kf=function(t,e,s,i,n,r,o,a,l,c,u){Vt(e,u++,s),++n[256];for(var h=nl(n,15),d=h[0],g=h[1],p=nl(r,15),m=p[0],v=p[1],b=Sf(d),y=b[0],w=b[1],A=Sf(m),I=A[0],k=A[1],$=new Xe(19),O=0;y.length>O;++O)$[31&y[O]]++;for(O=0;I.length>O;++O)$[31&I[O]]++;for(var x=nl($,7),Y=x[0],X=x[1],Z=19;Z>4&&!Y[wf[Z-1]];--Z);var ae,D,K,q,ie=c+5<<3,Q=Ji(n,Fs)+Ji(r,io)+o,P=Ji(n,d)+Ji(r,m)+o+14+3*Z+Ji($,Y)+(2*$[16]+3*$[17]+7*$[18]);if(Q>=ie&&P>=ie)return Lr(e,u,t.subarray(l,l+c));if(Vt(e,u,1+(Q>P)),u+=2,Q>P){ae=un(d,g,0),D=d,K=un(m,v,0),q=m;var U=un(Y,X,0);for(Vt(e,u,w-257),Vt(e,u+5,k-1),Vt(e,u+10,Z-4),u+=14,O=0;Z>O;++O)Vt(e,u+3*O,Y[wf[O]]);u+=3*Z;for(var V=[y,I],W=0;2>W;++W){var ee=V[W];for(O=0;ee.length>O;++O)Vt(e,u,U[le=31&ee[O]]),u+=Y[le],le>15&&(Vt(e,u,ee[O]>>>5&127),u+=ee[O]>>>12)}}else ae=EA,D=Fs,K=wA,q=io;for(O=0;a>O;++O)if(i[O]>255){var le;Qi(e,u,ae[257+(le=i[O]>>>18&31)]),u+=D[le+257],le>7&&(Vt(e,u,i[O]>>>23&31),u+=yc[le]);var _e=31&i[O];Qi(e,u,K[_e]),u+=q[_e],_e>3&&(Qi(e,u,i[O]>>>5&8191),u+=bc[_e])}else Qi(e,u,ae[i[O]]),u+=D[i[O]];return Qi(e,u,ae[256]),u+D[256]},SA=new mi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kA=new dt(0),AA=(function(){for(var t=new mi(256),e=0;256>e;++e){for(var s=e,i=9;--i;)s=(1&s&&3988292384)^s>>>1;t[e]=s}return t})(),rl=function(t,e,s){for(;s;++e)t[e]=s,s>>>=8};IA=!!Xl||!!gn,lv=new WeakMap,cv="text/plain",ol=0,Ur=!1,uv=(t,e)=>{let[s,i]=t.split("#"),[n,r]=s.split("?");if(!r)return t;let o=r.split("&").filter(a=>a.split("=")[0]!==e).join("&");return`${n}${o?`?${o}`:""}${i?`#${i}`:""}`},wn=(t,e,s=!0)=>{var i;let[n,r]=t.split("?"),o=_({},e),a=(i=r?.split("&").map(c=>{var u;let[h,d]=c.split("="),g=s&&(u=o[h])!==null&&u!==void 0?u:d;return delete o[h],`${h}=${g}`}))!==null&&i!==void 0?i:[],l=(function(c,u="&"){let h,d,g=[];return re(c,function(p,m){S(p)||S(m)||m==="undefined"||(h=encodeURIComponent((v=>v instanceof File)(p)?p.name:p.toString()),d=encodeURIComponent(m),g[g.length]=d+"="+h)}),g.join(u)})(o);return l&&a.push(l),a.length>0?`${n}?${a.join("&")}`:n},al=t=>{if(t.nl)return t.nl;let{data:e,compression:s}=t;if(!e)return;if(s===ut.GZipJS){let n=TA((function(r){var o=r.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new dt(r.length+(r.length>>>1)),l=0,c=function(g){a[l++]=g},u=0;o>u;++u){if(l+5>a.length){var h=new dt(l+8+(o-u<<1));h.set(a),a=h}var d=r.charCodeAt(u);128>d?c(d):2048>d?(c(192|d>>>6),c(128|63&d)):d>55295&&57344>d?(c(240|(d=65536+(1047552&d)|1023&r.charCodeAt(++u))>>>18),c(128|d>>>12&63),c(128|d>>>6&63),c(128|63&d)):(c(224|d>>>12),c(128|d>>>6&63),c(128|63&d))}return av(a,0,l)})(li(e)),{mtime:0});return{contentType:cv,body:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),estimatedSize:n.byteLength}}if(s===ut.Base64){let n=(function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(li(e)),r=(o=>"data="+encodeURIComponent(typeof o=="string"?o:li(o)))(n);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}let i=li(e);return{contentType:"application/json",body:i,estimatedSize:new Blob([i]).size}},dv=t=>{let e=()=>t.transport==="sendBeacon"?{url:wn(t.url,{compression:ut.Base64}),encodedBody:al(_(_({},t),{},{compression:ut.Base64,nl:void 0}))}:{url:uv(t.url,"compression"),encodedBody:al(_(_({},t),{},{compression:void 0,nl:void 0}))},s;try{s=al(t)}catch(n){if(Vh(t.compression,vi(t.url,"compression")))return R.error("Failed to gzip request body, sending uncompressed payload",n),e();throw n}return s&&Vh(t.compression,vi(t.url,"compression"))&&!((i=s.body)instanceof ArrayBuffer?Rl(new Uint8Array(i)):ArrayBuffer.isView(i)&&Rl(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(Ur=!0,e()):{url:t.url,encodedBody:s};var i},hv=t=>{try{return dv(t)}catch(s){var e;return R.error(s),void((e=t.callback)===null||e===void 0||e.call(t,{statusCode:0,error:s}))}},RA=(function(){var t=he(function*(e){let s=yield(function(n){return Cl.apply(this,arguments)})(li(e.data),it.DEBUG,{rethrow:!0});if(!s)return e;let i=yield s.arrayBuffer();return _(_({},e),{},{nl:{contentType:cv,body:i,estimatedSize:i.byteLength}})});return function(e){return t.apply(this,arguments)}})(),CA=/Failed to fetch|NetworkError|Load failed/i,fv=t=>t?.name==="TypeError"&&CA.test(t?.message||""),gv=t=>{try{let e=(function(s,i=Date.now()){if(typeof s!="string"||!s)return;let n=s.trim(),r=/^\d+\s*,/.test(n)?n.slice(0,n.indexOf(",")).trim():n;if(/^\d+$/.test(r)){let l=1e3*Math.min(Number(r),300);return l>0?l:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(r))return;let o=/^\w{3} \w{3} /.test(r)?r+" GMT":r,a=Date.parse(o)-i;return Number.isFinite(a)&&a>0?Math.min(a,Nr):void 0})(t());return S(e)?void 0:Math.min(e,3e4)}catch{return}},pv=t=>{let e=hv(t);if(!e)return;let s=new Xl;lv.set(s,!0);let{url:i,encodedBody:n}=e;s.open(t.method||"GET",i,!0);let{contentType:r,body:o}=n??{};re(t.headers,function(a,l){s.setRequestHeader(l,a)}),r&&s.setRequestHeader("Content-Type",r),t.timeout&&(s.timeout=t.timeout),s.onreadystatechange=()=>{if(s.readyState===4){var a;let l={statusCode:s.status,text:s.responseText};if(s.status===200)try{l.json=JSON.parse(s.responseText)}catch{}(a=t.callback)===null||a===void 0||a.call(t,l,gv(()=>s.getResponseHeader("Retry-After")))}},s.send(o)},vv=t=>{let e=hv(t);if(!e)return;let{url:s,encodedBody:i}=e,{contentType:n,body:r,estimatedSize:o}=i??{},a=new Headers;re(t.headers,function(p,m){a.append(m,p)}),n&&a.append("Content-Type",n);let l=null,c=!1;if(Sh){let p=new Sh;l={signal:p.signal,timeout:setTimeout(()=>{c=!0;try{p.abort(Bg("AbortError","PostHog request timed out"+((m=t.timeout)?` after ${m}ms`:"")))}catch(v){h(v)}var m},t.timeout)}}let u=!1,h=p=>{var m;u||(u=!0,c&&p?.name==="AbortError"||fv(p)?R.warn(p):R.error(p),(m=t.callback)===null||m===void 0||m.call(t,{statusCode:0,error:p}))},d=0,g=()=>{ol-=d,d=0,l&&clearTimeout(l.timeout)};try{let p=_({method:t?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:r,signal:l?.signal},t.fetchOptions),m=o??(S(r)?0:void 0);p.keepalive=p.method==="POST"&&!t.sl&&p.keepalive!==!1&&p.body===r&&!S(m)&&m>=0&&52428.8>ol+m,p.keepalive&&(d=m,ol+=d),gn(s,p).then(v=>v.text().then(b=>{var y;if(u)return;let w={statusCode:v.status,text:b};if(v.status===200)try{w.json=JSON.parse(b)}catch(A){R.error(A)}u=!0,g(),(y=t.callback)===null||y===void 0||y.call(t,w,gv(()=>v.headers.get("Retry-After")))})).catch(v=>{g(),h(v)}).finally(g)}catch(p){g(),h(p)}},Kl=t=>{try{var e;let{url:s,encodedBody:i}=dv(t),{contentType:n,body:r,estimatedSize:o}=i??{};if(!r)return;let a=r instanceof Blob?r:new Blob([r],{type:n});if(Le.sendBeacon(s,a))return;let l=N(t.data)?t.data:(e=t.data)===null||e===void 0?void 0:e.batch;if(N(l)&&l.length>1&&(o??0)>16384){let c=Math.ceil(l.length/2),u=h=>N(t.data)?h:_(_({},t.data),{},{batch:h});return Kl(_(_({},t),{},{data:u(l.slice(0,c))})),void Kl(_(_({},t),{},{data:u(l.slice(c))}))}R.warn(`Beacon of ~${o??0} bytes was rejected by the browser, falling back to ${gn?"fetch":"XHR"}`),gn?vv(_(_({},t),{},{sl:!0})):pv(t)}catch(s){R.warn("Beacon send failed",s)}},Af=(t,e,s,i)=>{let n=i==="query"?e==="POST"?"sent_at":"_":void 0;return wn(s===ut.GZipJS?uv(t,"compression"):t,_(_({},n?{[n]:Date.now().toString()}:{}),s===ut.GZipJS?{}:{compression:s}))},OA=(()=>{let t=[];return gn&&t.push({transport:"fetch",method:vv}),Xl&&t.push({transport:"XHR",method:pv}),Le?.sendBeacon&&t.push({transport:"sendBeacon",method:Kl}),t})(),_v=!IA&&Ye?.indexOf("MSIE")===-1&&Ye?.indexOf("Mozilla")===-1;PA=class{constructor(t,e){this.rl=!0,this.ol=[],this.al=Rt(e?.flush_interval_ms||3e3,250,5e3,R.createLogger("flush interval"),3e3),this.ll=t}enqueue(t){this.ol.push(t),this.ul||this.cl()}unload(){this.hl();let t=this.ol.length>0?this.dl():{},e=Object.values(t);[...e.filter(s=>s.url.indexOf("/e")===0),...e.filter(s=>s.url.indexOf("/e")!==0)].map(s=>{this.vl(_(_({},s),{},{callback:void 0}),"sendBeacon")})}enable(){this.rl=!1,this.cl()}cl(){this.rl||(this.ul=setTimeout(()=>{this.hl(),this.fl()},this.al))}fl(){if(this.ol.length>0){let t=this.dl();for(let e in t)this.vl(t[e])}}vl(t,e){try{this.ll(t,e)}catch(s){R.error(s)}}hl(){clearTimeout(this.ul),this.ul=void 0}dl(){let t={},e={};re(this.ol,s=>{var i;let n=s,r=((n?n.batchKey:null)||n.url)+(n.batchGroup?`:${n.batchGroup}`:"");S(t[r])&&(t[r]=_(_({},n),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),e[r]=[]),(i=t[r].data)===null||i===void 0||i.push(n.data),n.callback&&e[r].push(n.callback)});for(let s in e){let i=e[s];i.length&&(t[s].callback=n=>{for(let r of i)r(n)})}return this.ol=[],t}},$A=["retriesPerformedSoFar"],xA=class{constructor(t){this._instance=t,this.pl=!1,this.gl=3e3,this.ol=[],this.ol=[],this.ml=!0,this.resume()}resume(){if(!S(E)&&"onLine"in E.navigator){if(this.ml=E.navigator.onLine,this.yl)return;this.yl=()=>{this.ml=!0,this.fl()},this.bl=()=>{this.ml=!1},se(E,"online",this.yl),se(E,"offline",this.bl)}}get length(){return this.ol.length}retriableRequest(t,e){let{retriesPerformedSoFar:s}=t,i=Kg(t,$A);Gt(s)&&(i.url=wn(i.url,{retry_count:s})),mv(this._instance,e?_(_({},i),{},{transport:e}):i,(n,r)=>{var o;if(n.statusCode!==200&&(400>n.statusCode||n.statusCode>=500)){if((n.statusCode===0?3:10)>(s??0))return void this.Ls(_({retriesPerformedSoFar:s},i),r);n.statusCode===0&&R.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${s??0} retries.`)}(o=i.callback)===null||o===void 0||o.call(i,n)})}Ls(t,e){let s=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=s+1;let i=Math.max((function(o){let a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(s),e??0),n=Date.now()+i;this.ol.push({retryAt:n,requestOptions:t});let r=`Enqueued failed request for retry in ${i}`;navigator.onLine||(r+=" (Browser is offline)"),R.warn(r),this.pl||(this.pl=!0,this._l())}_l(){if(this.wl&&clearTimeout(this.wl),this.ol.length===0)return this.pl=!1,void(this.wl=void 0);this.wl=setTimeout(()=>{this.ml&&this.ol.length>0&&this.fl(),this._l()},this.gl)}fl(){let t=Date.now(),e=[],s=this.ol.filter(i=>t>i.retryAt||(e.push(i),!1));if(this.ol=e,s.length>0)for(let{requestOptions:i}of s)this.retriableRequest(i)}unload(){this.wl&&(clearTimeout(this.wl),this.wl=void 0),this.pl=!1,S(E)||(this.yl&&(E.removeEventListener("online",this.yl),this.yl=void 0),this.bl&&(E.removeEventListener("offline",this.bl),this.bl=void 0));for(let{requestOptions:t}of this.ol)try{this._instance._send_request(_(_({},t),{},{callback:N(t.data)?void 0:t.callback,transport:"sendBeacon"}))}catch(e){R.error(e)}this.ol=[]}},DA=class{constructor(t){this._instance=t,this.kl=()=>{var e,s,i,n;this.Sl||(this.Sl={});let r=this.scrollElement(),o=this.scrollY(),a=r?Math.max(0,r.scrollHeight-r.clientHeight):0,l=o+(r?.clientHeight||0),c=r?.scrollHeight||0;this.Sl.lastScrollY=Math.ceil(o),this.Sl.maxScrollY=Math.max(o,(e=this.Sl.maxScrollY)!==null&&e!==void 0?e:0),this.Sl.maxScrollHeight=Math.max(a,(s=this.Sl.maxScrollHeight)!==null&&s!==void 0?s:0),this.Sl.lastContentY=l,this.Sl.maxContentY=Math.max(l,(i=this.Sl.maxContentY)!==null&&i!==void 0?i:0),this.Sl.maxContentHeight=Math.max(c,(n=this.Sl.maxContentHeight)!==null&&n!==void 0?n:0)}}get xl(){return this._instance.config.scroll_root_selector}getContext(){return this.Sl}resetContext(){let t=this.Sl;return this.Sl=void 0,setTimeout(this.kl,0),t}startMeasuringScrollPosition(){se(E,"scroll",this.kl,{capture:!0}),se(E,"scrollend",this.kl,{capture:!0}),se(E,"resize",this.kl)}scrollElement(){if(this.xl){let s=N(this.xl)?this.xl:[this.xl];for(let i of s){var t;let n=E==null||(t=E.document)===null||t===void 0?void 0:t.querySelector(i);if(n)return n}return}var e;return E==null||(e=E.document)===null||e===void 0?void 0:e.documentElement}$l(t){var e,s;let i=t==="y"?"scrollTop":"scrollLeft";if(this.xl){let n=this.scrollElement();return n&&n[i]||0}return E?t==="y"?E.scrollY||E.pageYOffset||((e=E.document)===null||e===void 0||(e=e.documentElement)===null||e===void 0?void 0:e.scrollTop)||0:E.scrollX||E.pageXOffset||((s=E.document)===null||s===void 0||(s=s.documentElement)===null||s===void 0?void 0:s.scrollLeft)||0:0}scrollY(){return this.$l("y")}scrollX(){return this.$l("x")}},NA=t=>ev(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes),Tf=class{constructor(t,e,s,i){this.qe=n=>{let r=this.Cl();if(r&&r.sessionId===n)return;let o={sessionId:n,props:this.Tl(this._instance)};this.Il.register({[Ll]:o})},this._instance=t,this.Ml=e,this.Il=s,this.Tl=i||NA,this.Ml.onSessionId(this.qe)}Cl(){return this.Il.props[Ll]}getSetOnceProps(){var t;let e=(t=this.Cl())===null||t===void 0?void 0:t.props;return e?"r"in e?tv(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){let t={};return re(fc(this.getSetOnceProps()),(e,s)=>{s==="$current_url"&&(s="url"),t[`$session_entry_${wl(s)}`]=e}),t}},no=class{on(t,e){return this.El[t]||(this.El[t]=[]),this.El[t].push(e),()=>{this.El[t]=this.El[t].filter(s=>s!==e)}}emit(t,e){for(let s of this.El[t]||[])s(e);for(let s of this.El["*"]||[])s(t,e)}constructor(){this.El={}}},ti=ye("[SessionId]"),If=864e5,Rf=class{on(t,e){return this.Pl.on(t,e)}constructor(t,e,s){var i;if(this.Rl=null,this.Al=null,this.Fl=[],this.Ol=void 0,this.Dl=!1,this.Pl=new no,this.Ll=(r,o)=>!(!Gt(r)||!Gt(o))&&Math.abs(r-o)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=t.config,this.Il=t.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Nl=void 0,this._sessionActivityTimestamp=null,this.ql=e||bt,this.jl=s||bt;let n=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*Rt(this.Mr.session_idle_timeout_seconds||1800,60,36e3,ti.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Bl(),this.zl="ph_"+n+"_window_id",this.Hl="ph_"+n+"_primary_window_exists",this.Ul()){let r=de.Dt(this.zl),o=de.Dt(this.Hl);r&&!o?this.je=r:de.Pt(this.zl),de.$t(this.Hl,!0)}!((i=this.Mr.bootstrap)===null||i===void 0)&&i.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Wl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return S(this.Fl)&&(this.Fl=[]),this.Fl.push(t),this.Xt&&t(this.Xt,this.je),()=>{this.Fl=this.Fl.filter(e=>e!==t)}}Ul(){return this.Mr.persistence!=="memory"&&!this.Il.hi&&de.At()}Vl(t){t!==this.je&&(this.je=t,this.Ul()&&de.$t(this.zl,t))}Gl(){return this.je?this.je:this.Ul()?de.Dt(this.zl):null}Ql(t){let e=this.Rl;return!we(e)&&!we(t)&&5e3>Math.abs(t-e)}Zl(t,e,s){let i=e!==this._sessionActivityTimestamp,n=!(t!==this.Xt||s!==this._sessionStartTimestamp);this._sessionStartTimestamp=s,this._sessionActivityTimestamp=e,this.Xt=t,n&&!i||n&&this.Ql(e)||(this.Rl=e,this.Il.register({[ri]:[e,t,s]}))}Jl(){var t;let e=(t=this.Mr)===null||t===void 0?void 0:t.persistence_save_debounce_ms;return Gt(e)&&e>0}Kl(){this.Jl()?this.Il.refreshKey(ri):(this.Il.flush(),this.Il.load())}Xl(){var t;if(we(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Rl)return;this.Kl();let[,e,s]=this.Yl();e===this.Xt&&s===this._sessionStartTimestamp&&(this.Rl=this._sessionActivityTimestamp,this.Il.register({[ri]:[this._sessionActivityTimestamp,(t=this.Xt)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.Il.flush())}tu(){let[t]=this.Yl(),e=Gt(t)?t:0,s=Gt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,s)}eu(t){return this.Kl(),this.Ll(t,this.tu())}Yl(){let t=this.Il.props[ri];return N(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Rl=null,this.Nl=void 0,clearTimeout(this.iu),this.iu=void 0,this.Zl(null,null,null)}setBootstrapSessionId(t,e=!1){let s=((i,n=new Date().getTime())=>{try{let r=(o=>{let a=o.replace(/-/g,"");if(a.length!==32)throw new Error("Not a valid UUID");if(a[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(a.substring(0,12),16)})(i);return r>n+6e4?void ti.error("Bootstrap sessionID cannot be in the future"):r}catch(r){return void ti.error("Invalid sessionID in bootstrap",r)}})(t);return!S(s)&&(e?this.Nl={sessionId:t,sessionStartTimestamp:s}:this.Zl(t,new Date().getTime(),s),!0)}destroy(){this.Dl=!0,this.Xl(),clearTimeout(this.iu),this.iu=void 0,this.Ol&&E&&(E.removeEventListener(Xr,this.Ol,{capture:!1}),this.Ol=void 0),this.Fl=[]}Wl(){this.Ol=()=>{this.Xl(),this.Ul()&&de.Pt(this.Hl)},se(E,Xr,this.Ol,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,e=null,s=!1){if(this.Mr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');let i=e||new Date().getTime(),n=this.Xt;if(s)this.Al=i;else if(we(this.Al)||this.Al>i||i-this.Al>=1e3){var r,o;(r=(o=this.Il).syncCookieProperties)===null||r===void 0||r.call(o),this.Al=i}let[,a,l]=this.Yl(),c=!S(n)&&a!==n,u=this.tu(),h=this.Gl(),d=this.Nl,g=!!d&&(d.sessionStartTimestamp>i+6e4||i-d.sessionStartTimestamp>If),p=d?g:Gt(l)&&Math.abs(i-l)>If,m=!1,v=c,b=!a||!!d,y=a,w=!b&&!t&&this.Ll(i,u);if(w&&(w=this.eu(i),w||ti.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this.Yl(),w||(b=!a||!!d)),b||w||p){v=!1;let $=d&&!g;a=$?d.sessionId:this.ql(),h=this.jl(),ti.info("new session ID assigned",{sessionId:a,windowId:h,bootstrapped:!!$,changeReason:{noSessionId:b,activityTimeout:w,sessionPastMaximumLength:p}}),l=$?d.sessionStartTimestamp:i,this.Nl=void 0,m=!0}else h||(h=this.jl(),m=!0),v=v||a!==y,v&&(ti.info("adopted cross-tab session id",{sessionId:a,windowId:h}),m=!0);let A=Gt(u)&&t&&!p?u:i,I=Gt(l)?l:new Date().getTime();this.Vl(h),this.Zl(a,A,I),t||this.Bl();let k={noSessionId:b,activityTimeout:w,sessionPastMaximumLength:p,crossTabAdoption:v};return m&&this.Fl.forEach($=>$(a,h,k)),{sessionId:a,windowId:h,sessionStartTimestamp:I,changeReason:m?k:void 0,lastActivityTimestamp:u}}Bl(){this.Dl||(clearTimeout(this.iu),this.iu=setTimeout(()=>{if(!this.Dl)if(this.eu(new Date().getTime())){let t=this.Xt;this.resetSessionId(),this.Pl.emit("forcedIdleReset",{idleSessionId:t})}else this.Bl()},1.1*this.sessionTimeoutMs))}},yv=function(t,e){if(!t)return!1;let s=t.userAgent;if(s&&Th(s,e))return!0;try{let i=t?.userAgentData;if(i?.brands&&i.brands.some(n=>Th(n?.brand,e)))return!0}catch{}return!!t.webdriver};ro=(t,e)=>{if(!(s=>{try{new RegExp(s)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}},Or=t=>t.toLowerCase(),wv={exact:(t,e)=>e.some(s=>t.some(i=>s===i)),is_not:(t,e)=>e.every(s=>t.every(i=>s!==i)),regex:(t,e)=>e.some(s=>t.some(i=>ro(s,i))),not_regex:(t,e)=>e.every(s=>t.every(i=>!ro(s,i))),icontains:(t,e)=>e.map(Or).some(s=>t.map(Or).some(i=>s.includes(i))),not_icontains:(t,e)=>e.map(Or).every(s=>t.map(Or).every(i=>!s.includes(i))),gt:(t,e)=>e.some(s=>{let i=parseFloat(s);return!isNaN(i)&&t.some(n=>i>parseFloat(n))}),lt:(t,e)=>e.some(s=>{let i=parseFloat(s);return!isNaN(i)&&t.some(n=>i<parseFloat(n))})};Yl="custom",Cf="i.posthog.com",FA=/^\/static\//,LA=["/s/","/e/","/i/"],UA=class{constructor(t){this.nu={},this.instance=t}get apiHost(){let t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){let t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let e=(t=this.instance.config.ui_host)===null||t===void 0?void 0:t.replace(/\/$/,"");return e||(e=this.apiHost.replace(`.${Cf}`,".posthog.com")),e==="https://app.posthog.com"?"https://us.posthog.com":e}get region(){return this.nu[this.apiHost]||(this.nu[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":Yl),this.nu[this.apiHost]}su(t){if(!FA.test(t))return;let e=this.instance.config.asset_host;return typeof e=="string"&&e.trim().replace(/\/$/,"")||void 0}ru(t){let e=Kt(t);return e?e.protocol+"//"+e.host+e.pathname:void 0}ou(t,e,s){if(t==="ui")return s;let i=s,n=this.instance.config.rewriteRequestPath;if(n){var r;let o=((r=Kt(s))===null||r===void 0?void 0:r.href)||s;i=n(new URL(o)).toString()}if(n&&t==="api"&&LA.some(o=>e.indexOf(o)===0)){let o=this.ru(i);if(o){let a=this.apiHost,l=this.au;l?.apiHost===a&&l.rewriteRequestPath===n||(l={apiHost:a,rewriteRequestPath:n,urls:new Set},this.au=l),l.urls.add(o)}}return i}isIngestionEndpoint(t){let e=this.au,s=this.ru(t);return e?.apiHost===this.apiHost&&e.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!s&&e.urls.has(s)}endpointFor(t,e=""){if(e&&(e=e[0]==="/"?e:`/${e}`),t==="ui")return this.ou(t,e,this.uiHost+e);if(t==="flags")return this.ou(t,e,this.flagsApiHost+e);if(t==="assets"){let i=this.su(e);if(i)return this.ou(t,e,`${i}${e}`)}if(this.region===Yl)return this.ou(t,e,this.apiHost+e);let s=Cf+e;switch(t){case"assets":return this.ou(t,e,`https://${this.region}-assets.${s}`);case"api":return this.ou(t,e,`https://${this.region}.${s}`)}}},ne=ye("[Surveys]"),kv=t=>{try{let e=(s=>((i,n)=>`seenSurvey_${(function(r){return r.current_iteration&&r.current_iteration>0?`${r.id}_${r.current_iteration}`:r.id})(n)}`)(0,s))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(e){ne.error("Failed to persist survey seen state",e)}},BA=[tl.Popover,tl.Widget,tl.API],VA={ignoreConditions:!1,ignoreDelay:!1,displayType:Hl.Popover},jA=ye("[PostHog ExternalIntegrations]"),GA={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},HA=class{constructor(t){this._instance=t}zo(t,e){var s,i;(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,t,n=>{if(n)return jA.error("failed to load script",n);e()})}startIfEnabledOrStop(){var t;for(let[n,r]of Object.entries((t=this._instance.config.integrations)!==null&&t!==void 0?t:{})){var e,s,i;r&&!(!((e=L.__PosthogExtensions__)===null||e===void 0||(e=e.integrations)===null||e===void 0)&&e[n])&&this.zo(GA[n],()=>{var o;(o=L.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0||(o=o[n])===null||o===void 0||o.start(this._instance)}),!r&&(!((s=L.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0)&&s[n])&&((i=L.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[n])===null||i===void 0||i.stop())}}},Av="autocapture",Tv="featureFlags",Iv="logs",Rv="surveys",zA=class{constructor(t){this._instance=t}initialize(){}get(t){let e=this._instance.persistence;if(typeof t=="string")return e?.get_property(t);let s={};for(let i of t){let n=e?.get_property(i);S(n)||(s[i]=n)}return s}set(t,e){var s;(s=this._instance.persistence)===null||s===void 0||s.register(typeof t=="string"?{[t]:e}:t)}remove(t){var e;(e=this._instance.persistence)===null||e===void 0||e.unregister(t)}},qA=class{constructor(t){this.instance=t,this.A=R,this.kv=new zA(t),this.onEvent=e=>il(this.instance._addCaptureHook((s,i)=>{if(i)try{e({event:s,properties:i.properties})}catch(n){this.A.error("Browser extension event listener failed",n)}})),this.onRemoteConfig=e=>{let s=n=>{try{e(n)}catch(r){this.A.error("Browser extension remote config listener failed",r)}},i=this.instance.lu.on("extensionsRemoteConfig",s);return this.instance.uu&&s(this.instance.uu),il(i)}}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return(t=this.instance.get_property("$device_id"))!==null&&t!==void 0?t:this.distinctId}get deviceId(){let t=this.instance.get_property(rc);return typeof t=="string"?t:void 0}get library(){return{name:it.LIB_NAME,version:it.LIB_VERSION}}get initialPersonProperties(){var t,e;return(t=(e=this.instance.persistence)===null||e===void 0?void 0:e.get_initial_props())!==null&&t!==void 0?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,e,s,i,n;let r=(t=this.instance.sessionManager)===null||t===void 0?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:(e=r?.sessionId)!==null&&e!==void 0?e:"",windowId:(s=r?.windowId)!==null&&s!==void 0?s:"",sessionStartTimestamp:(i=r?.sessionStartTimestamp)!==null&&i!==void 0?i:0,lastActivityTimestamp:(n=r?.lastActivityTimestamp)!==null&&n!==void 0?n:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return Ce(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get projectToken(){return this.instance.config.token}getExtension(t){let e;switch(t){case Tv:case"featureFlagsCommon":e=this.instance.featureFlags;break;case Iv:e=this.instance.logs;break;case Rv:e=this.instance.surveys;break;case Av:e=this.instance.autocapture}return e}capture(t,e,s){s?this.instance.capture(t,e,{timestamp:s.timestamp,uuid:s.uuid,$set:s.set,$set_once:s.setOnce}):this.instance.capture(t,e)}registerDynamicEventProperties(t){return il(this.instance.cu(t))}sendRequest(t){var e=this;return he(function*(s,i={}){var n;let r=(n=i.target)!==null&&n!==void 0?n:"api",o=e.instance.requestRouter.endpointFor(r,s),a=r==="api"&&s==="/i/v1/logs",l={method:i.method,url:i.query?wn(o,i.query):o,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:i.target==="flags"&&i.compression==="best-available"?El.Base64:void 0,timestampMode:i.sentAt};return a&&(l.batchKey="logs"),i.transport==="sendBeacon"?(e.instance._send_request(l),{statusCode:202}):new Promise(c=>{l.callback=c,e.instance._send_request(l)})}).apply(this,arguments)}},dn={},cl=0,hn=()=>{},Of='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',si="Surveys module not available",Pf="sanitize_properties is deprecated. Use before_send instead",Cv="Invalid value for property_denylist config: ",WA=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],KA=["$feature_flag_called","$$heatmap","$snapshot"],$f=t=>t.charAt(0)==="$"&&!M(KA,t),YA=/^[A-Za-z0-9_-]{1,400}$/,xf=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Df=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,QA=["token","distinct_id",bp],tn="posthog",JA=t=>{let e={};return t&&t!=="unset"&&("2025-11-30">t||(e.strictMinimumDuration=!0),"2026-05-30">t||(e.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(e.streamNetworkBody=!0),"2026-08-30">t||(e.captureJsonLd=!0)),e},ul=t=>{var e;return _({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:qk(T?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:hn,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_replay_sync_fetch:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:pe&&H(pe?.search)&&pe.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,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(E==null||(e=E.location)===null||e===void 0?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,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(s){R.error("Bad HTTP status: "+s.statusCode+" "+s.text)},get_device_id:s=>s,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Op,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:hn},(s=>({rageclick:s&&s>="2026-05-30"?{content_ignorelist:_c,ignore_text_selection:!0}:!s||"2025-11-30">s||{content_ignorelist:!0},capture_pageview:!s||"2025-05-24">s||"history_change",session_recording:JA(s),external_scripts_inject_target:s&&s>="2026-01-30"?"head":"body",internal_or_test_user_hostname:s&&s>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:s&&s>="2026-05-30"?250:0,split_storage:!(!s||"2026-05-30">s),detect_google_search_app:!(!s||"2026-05-30">s),disable_capture_url_hashes:!(!s||"2026-06-25">s),cookieWinsOnConflict:!(!s||s==="unset"||"2026-08-29">s)}))(t))},XA=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],Nf=t=>{let e={};for(let[n,r]of XA)S(t[n])||(e[r]=t[n]);let s=ve({},e,t),i=t.__preview_external_dependency_versioned_paths;return S(i)||(S(t.strict_script_versioning)&&(s.strict_script_versioning=!!i),H(i)&&S(t.asset_host)&&(s.asset_host=i)),N(t.property_blacklist)&&(S(t.property_denylist)?s.property_denylist=t.property_blacklist:N(t.property_denylist)?s.property_denylist=[...t.property_blacklist,...t.property_denylist]:R.error(Cv+t.property_denylist)),s},ZA=class{constructor(){this.__forceAllowLocalhost=!1}get hu(){return this.__forceAllowLocalhost}set hu(t){R.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},fn=class rs{du(e){if(!e)return;let s=this.vu.indexOf(e);s!==-1&&this.vu.splice(s,1)}fu(e,s){var i;return this.du(e),this.vu.push(s),(i=s.initialize)===null||i===void 0||i.call(s),s}pu(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}gu(){if(this.mu||this.config.reuseAnonymousId||this.config.segment||this.pu())return;let e=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!e&&!this.config.disable_persistence||this.yu)return;let s,i,n;e?(s=`persistence is set to '${this.config.persistence}'`,i=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",n="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(s="persistence is disabled (disable_persistence is true)",i="on every page load",n="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.mu=!0,console.warn("[PostHog.js]",`${s} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${i}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${n}`)}bu(){let e=this.persistence;if(!e||this._u)return;if(this.pu())return void(this.config.cookieless_mode==="on_reject"&&this.get_distinct_id()!=="$posthog_cookieless"&&(this.wu(),this.ku()));if(this.get_distinct_id()!=="$posthog_cookieless")return;this.Su()||e.load(!0);let s=this.get_distinct_id();if(!s||s==="$posthog_cookieless"){let i=this.config.get_device_id(bt());this.register({distinct_id:i,$device_id:i}),e.set_property(Qe,qt)}this.wu()}get decideEndpointWasHit(){var e,s;return(e=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,s;return(e=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.xu=!1,this.$u=!1,this.webPerformance=new ZA,this.Cu=!1,this.version=it.LIB_VERSION,this.Tu=new Set,this.Iu="",this.lu=new no,this.vu=[],this.Mu=[],this.Eu=!1,this.yu=!1,this.mu=!1,this._u=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=ul(),this.SentryIntegration=uA,this.sentryIntegration=i=>(function(n,r){let o=Hp(n,r);return{name:Gp,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Pu=!1,this.Ru=null,this.Au=null,this.Fu=null,this.scrollManager=new DA(this),this.pageViewManager=new _f(this),this.rateLimiter=new bA(this),this.requestRouter=new UA(this),this.consent=new Zk(this),this.externalIntegrations=new HA(this);let s=(e=rs.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(i,n,r)=>{let o=H(i)?{[i]:n}:i;this.setPersonProperties(o),r?.({})},set_once:(i,n,r)=>{let o=H(i)?{[i]:n}:i;this.setPersonProperties(void 0,o),r?.({})}},this.on("eventCaptured",i=>R.info(`send "${i?.event}"`,i))}init(e,s,i){if(i&&i!==tn){var n;let r=(n=dn[i])!==null&&n!==void 0?n:new rs;return r._init(e,s,i),dn[i]=r,dn[tn][i]=r,r}return this._init(e,s,i)}_init(e,s={},i){var n,r,o;let a=H(e)?e.trim():"";if(!a)return R.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==((l=this.config)===null||l===void 0?void 0:l.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=ul(s.defaults),s.debug=this.Ou(s.debug),this.Du=s,this.Lu=[],s.person_profiles?this.Au=s.person_profiles:s.process_person&&(this.Au=s.process_person);let c=ul(s.defaults),u=Nf(s),h=ve({},c,u,{name:i,token:a});G(c.rageclick)&&G(u.rageclick)&&(h.rageclick=ve({},c.rageclick,u.rageclick)),G(c.session_recording)&&G(u.session_recording)&&(h.session_recording=ve({},c.session_recording,u.session_recording)),this.set_config(h),this.config.on_xhr_error&&R.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:ut.GZipJS;let d=this.Su(),g=!this.pu();if(this.persistence=new el(this.config,d,!0,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new el(_(_({},this.config),{},{persistence:"sessionStorage"}),d,!1,g),this.Iu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!d&&de.At()){let y=de.Dt(this.Iu);N(y)&&y.forEach(w=>{H(w)&&this.Tu.add(w)})}else de.Pt(this.Iu);let p=_({},this.persistence.props),m=_({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Nu=new PA((y,w)=>this.qu(y,w),this.config.request_queue_config),this.ju=new xA(this),this.__request_queue=[];let v=this.pu();v||(this.sessionManager=new Rf(this),this.sessionPropsManager=new Tf(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((y,w,A)=>{(A?.activityTimeout||A?.sessionPastMaximumLength||A?.crossTabAdoption)&&this.Bu()})),this.zu(),this.config.__preview_deferred_init_extensions?(R.info("Deferring extension initialization to improve startup performance"),this.Hu=setTimeout(()=>{this.Hu=void 0,this.Uu(v)},0)):(R.info("Initializing extensions synchronously"),this.Uu(v)),it.DEBUG=it.DEBUG||this.config.debug,it.DEBUG&&R.info("Starting in debug mode",{this:this,config:s,thisC:_({},this.config),p,s:m}),this.config.identity_distinct_id&&!(!((n=s.bootstrap)===null||n===void 0)&&n.distinctID)&&(s.bootstrap=_(_({},s.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));let b=(r=s.bootstrap)===null||r===void 0?void 0:r.distinctID;if(this.yu=!!b&&!sn(b),(o=s.bootstrap)===null||o===void 0?void 0:o.distinctID){let y=s.bootstrap.distinctID,w=this.get_distinct_id(),A=this.persistence.get_property(Qe);if(s.bootstrap.isIdentifiedID&&w!=null&&w!==y&&A==="anonymous")this.identify(y);else if(s.bootstrap.isIdentifiedID&&w!=null&&w!==y&&A==="identified")R.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{let I=this.config.get_device_id(bt()),k=s.bootstrap.isIdentifiedID?I:y;this.persistence.set_property(Qe,s.bootstrap.isIdentifiedID?Mr:qt),this.register({distinct_id:y,$device_id:k})}}if(v)this.register_once({distinct_id:za,$device_id:null},"");else if(!this.get_distinct_id()){let y=this.config.get_device_id(bt());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(Qe,qt)}return se(E,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),se(E,"pageshow",()=>{var y;this.xu=!1,this.$u||(y=this.ju)===null||y===void 0||y.resume()}),s.segment?vf(this,()=>this.Wu()):this.Wu(),Ce(this.config._onCapture)&&this.config._onCapture!==hn&&(R.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",y=>this.config._onCapture(y.event,y))),this.config.ip&&R.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.config.disableDeviceModel||(function(){return bv.apply(this,arguments)})().then(y=>{y&&this.register({[Ha]:y})}).catch(hn),this}Vu(e){let s=e;return H(s.name)&&Ce(s.setup)}Gu(e,s){var i=this;this.Vu(e)?s.push(he(function*(){try{yield e.setup(i.Qu())}catch(r){R.error(`Failed to set up extension "${e.name}"`,r);try{var n;yield(n=e.dispose)===null||n===void 0?void 0:n.call(e)}catch(o){R.error(`Failed to dispose extension "${e.name}"`,o)}}})):this.vu.push(e)}zu(){var e,s,i,n=this;let r=(e=(s=this.config.__extensionClasses)===null||s===void 0?void 0:s.featureFlags)!==null&&e!==void 0?e:(i=rs.__defaultExtensionClasses)===null||i===void 0?void 0:i.featureFlags;var o,a,l;if(r)if(this.featureFlags&&this.featureFlags instanceof r||((o=this.Zu)===null||o===void 0||o.call(this),this.Zu=void 0,this.featureFlags=new r(this)),Ce(this.featureFlags.onReloading)&&Ce(this.featureFlags.setup)){if(!this.Zu){this.Zu=this.featureFlags.onReloading(()=>{this.lu.emit("featureFlagsReloading",!0)});let c=this.featureFlags;he(function*(){try{yield c.setup(n.Qu())}catch(u){R.error("Failed to set up feature flags",u);let h=n.Zu;n.Zu=void 0;try{h?.()}catch(d){R.error("Failed to unsubscribe feature flag reloading",d)}try{yield c.dispose()}catch(d){R.error("Failed to dispose feature flags",d)}}})()}}else(a=(l=this.featureFlags).initialize)===null||a===void 0||a.call(l)}Uu(e){let s=performance.now(),i=_(_({},rs.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,a,l,c,u,h,d;i.exceptions&&this.vu.push(this.exceptions=(r=this.exceptions)!==null&&r!==void 0?r:new i.exceptions(this)),i.historyAutocapture&&this.vu.push(this.historyAutocapture=new i.historyAutocapture(this)),i.tracingHeaders&&this.vu.push(this.tracingHeaders=new i.tracingHeaders(this)),i.siteApps&&this.vu.push(this.siteApps=new i.siteApps(this)),i.sessionRecording&&!e&&this.vu.push(this.sessionRecording=new i.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.autocapture&&this.Gu(this.autocapture=new i.autocapture(this),n),i.surveys&&this.Gu(this.surveys=(o=this.surveys)!==null&&o!==void 0?o:new i.surveys(this),n),i.logs&&this.Gu(this.logs=(a=this.logs)!==null&&a!==void 0?a:new i.logs(this),n),i.metrics&&this.vu.push(this.metrics=(l=this.metrics)!==null&&l!==void 0?l:new i.metrics(this)),i.conversations&&this.vu.push(this.conversations=(c=this.conversations)!==null&&c!==void 0?c:new i.conversations(this)),i.productTours&&this.vu.push(this.productTours=new i.productTours(this)),i.heatmaps&&this.vu.push(this.heatmaps=new i.heatmaps(this)),i.webVitalsAutocapture&&this.vu.push(this.webVitalsAutocapture=new i.webVitalsAutocapture(this)),i.exceptionObserver&&this.vu.push(this.exceptionObserver=new i.exceptionObserver(this)),i.deadClicksAutocapture&&this.vu.push(this.deadClicksAutocapture=new i.deadClicksAutocapture(this,cA)),i.toolbar&&this.vu.push(this.toolbar=(u=this.toolbar)!==null&&u!==void 0?u:new i.toolbar(this)),i.experiments&&this.vu.push(this.experiments=(h=this.experiments)!==null&&h!==void 0?h:new i.experiments(this)),i.webMCP&&this.vu.push(this.webMCP=(d=this.webMCP)!==null&&d!==void 0?d:new i.webMCP(this)),this.vu.forEach(g=>{g.initialize&&n.push(()=>{var p;(p=g.initialize)===null||p===void 0||p.call(g)})}),n.push(()=>{if(this.Ju){let g=this.Ju;this.Ju=void 0,this.vu.forEach(p=>{var m;return(m=p.onRemoteConfig)===null||m===void 0?void 0:m.call(p,g)})}}),this.Ku(n,s)}Ku(e,s){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&e.length>0)return void(this.Hu=setTimeout(()=>{this.Hu=void 0,this.Ku(e,s)},0));let n=e.shift();if(n)try{n()}catch(r){R.error("Error initializing extension:",r)}}let i=Math.round(performance.now()-s);this.register_for_session({[Ep]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[wp]:i}),this.config.__preview_deferred_init_extensions&&R.info(`PostHog extensions initialized (${i}ms)`)}el(e){if(!T||!T.body)return R.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.el(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Ju=e),this.uu=e,this.compression=void 0,e.ok){var s;let i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=M(i.supportedCompression,ut.GZipJS)?ut.GZipJS:M(i.supportedCompression,ut.Base64)?ut.Base64:void 0),!((s=i.analytics)===null||s===void 0)&&s.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Au?this.Au:Op}),this.lu.emit("extensionsRemoteConfig",e),this.vu.forEach(i=>{var n;return(n=i.onRemoteConfig)===null||n===void 0?void 0:n.call(i,e)})}Wu(){try{this.config.loaded(this)}catch(e){R.critical("`loaded` function failed",e)}if(this.Xu(),this.config.internal_or_test_user_hostname&&pe?.hostname){let e=pe.hostname,s=this.config.internal_or_test_user_hostname;(typeof s=="string"?e===s:s.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.pu())&&this.Yu()},1),this.tc=new iv(this),this.tc.load()}Xu(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Nu)===null||e===void 0||e.enable())}_dom_loaded(){this.is_capturing()&&ai(this.__request_queue,e=>this.qu(e)),this.__request_queue=[],this.Xu()}_handle_unload(){var e,s,i,n,r,o;this.xu=!0,(e=this.surveys)===null||e===void 0||(s=e.handlePageUnload)===null||s===void 0||s.call(e),(i=this.metrics)===null||i===void 0||i.flush("sendBeacon"),this.config.request_batching?(this.ec()&&this.capture(Xh),(n=this.logs)===null||n===void 0||n.flushLogs("sendBeacon"),(r=this.Nu)===null||r===void 0||r.unload(),(o=this.ju)===null||o===void 0||o.unload()):this.ec()&&this.capture(Xh,null,{transport:"sendBeacon"})}_send_request(e){mv(this,e)}qu(e,s){this.ju?this.ju.retriableRequest(e,s):this._send_request(s?_(_({},e),{},{transport:s}):e)}_execute_array(e){cl++;try{let s,i=[],n=[],r=[];ai(e,a=>{if(a)if(s=a[0],N(s))r.push(a);else if(Ce(a))try{a.call(this)}catch(l){R.error("Error executing queued PostHog call",a,l)}else N(a)&&s==="alias"?i.push(a):N(a)&&s.indexOf("capture")!==-1&&Ce(this[s])?r.push(a):n.push(a)});let o=function(a,l){ai(a,function(c){try{if(N(c[0])){let u=l;re(c,function(h){u=u[h[0]].apply(u,h.slice(1))})}else l[c[0]].apply(l,c.slice(1))}catch(u){R.error("Error executing queued PostHog call",c,u)}})};o(i,this),o(n,this),o(r,this)}finally{cl--}}push(e){if(cl>0&&N(e)&&H(e[0])){let s=rs.prototype[e[0]];return void(Ce(s)&&s.apply(this,e.slice(1)))}this._execute_array([e])}get nc(){return{property:Qh,persistenceKey:ui,cookieName:"_fbc",pattern:xf,register:(e,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[ui]:{value:e,delivered:s}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(ui)}}}get sc(){return{property:Jh,persistenceKey:on,cookieName:"_fbp",pattern:Df,register:(e,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[on]:{value:e,delivered:s}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(on)}}}rc(e){var s;let i=(s=this.persistence)===null||s===void 0?void 0:s.get_property(e.persistenceKey);return H(i)&&e.pattern.test(i)?{value:i,delivered:!1}:G(i)&&H(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:i.delivered===!0}:void 0}oc(e,s,i){return s===i?.value?{value:s,pending:!i.delivered}:(e.register(s,!1),{value:s,pending:!0})}ac(e){if(!this.config.save_campaign_params||this.pu())return;let s=ln(e.cookieName);return H(s)&&e.pattern.test(s)?s:void 0}lc(e,s,i,n){if(!this.persistence)return;let r=this.nc;this.persistence.refreshKey(r.persistenceKey);let o=this.rc(r);if(n)return void r.unregister();if(i)return H(s)&&xf.test(s)?this.oc(r,s,o):void r.unregister();let a=H(e)&&YA.test(e)?e:void 0,l=this.ac(r);return l&&((c,u,h)=>{let d=c.split(".");if(u)return d[3]===u;if(!h)return!0;let g=h.value.split(".");return d[3]===g[3]||Number(d[2])>Number(g[2])})(l,a,o)?this.oc(r,l,o):a?o?.value.split(".")[3]===a?{value:o.value,pending:!o.delivered}:this.oc(r,`fb.1.${Date.now()}.${a}`,o):o?{value:o.value,pending:!o.delivered}:void 0}uc(e,s,i){if(!this.persistence)return;let n=this.sc;this.persistence.refreshKey(n.persistenceKey);let r=this.rc(n);if(i)return void n.unregister();if(s)return H(e)&&Df.test(e)?this.oc(n,e,r):void n.unregister();let o=this.ac(n);return o?this.oc(n,o,r):r?{value:r.value,pending:!r.delivered}:void 0}cc(e,s){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);let i=this.rc(e);i?.value!==s||i.delivered||e.register(s,!0)}capture(e,s,i){var n,r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Nu))return void R.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(S(e)||!H(e))return void R.error("No event name provided to posthog.capture");if(this.bu(),e==="$snapshot"&&this.pu())return;let o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return;let a=i?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a?.isRateLimited)return void R.critical("This capture call is ignored due to client rate limiting.");let l;s?.$current_url&&!H(s?.$current_url)&&(R.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),s==null||delete s.$current_url),e!=="$exception"||i?.hc||R.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&&(l=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();let c=new Date,u=i?.timestamp||c,h=Oh(i?.uuid,bt),d={uuid:h,event:e,properties:this.calculateEventProperties(e,s||{},u,h)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&o&&(d.event="$bot_pageview",d.properties.$browser_type="bot"),a&&(d.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);let g=e==="$feature_flag_called"&&d.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;i?.$set&&!g&&(d.$set=i?.$set);let p=G(s?.$set)?s.$set:void 0,m=N(s?.$unset)?s.$unset:[],v=i?.$unset||[],b=D=>{var K;let q=!!i?.$set&&D in i.$set;return{hasProvided:q||!!p&&D in p,provided:q?i==null||(K=i.$set)===null||K===void 0?void 0:K[D]:p?.[D],unset:m.indexOf(D)!==-1||v.indexOf(D)!==-1}},y=b(Qh),w=b(Jh),A=[{channel:this.nc,hasProvided:y.hasProvided,update:this.lc(l?.fbclid,y.provided,y.hasProvided,y.unset)},{channel:this.sc,hasProvided:w.hasProvided,update:this.uc(w.provided,w.hasProvided,w.unset)}];for(let{channel:D,hasProvided:K,update:q}of A)q&&d.properties.$process_person_profile===!0&&q.pending&&!K&&!g&&(d.$set=_({[D.property]:q.value},d.$set));let I=i?.$unset;I&&(d.$unset=I);let k=g?void 0:this.dc(i?.$set_once,e!==Zh,e===Pp);if(k&&(d.$set_once=k),i?._noTruncate||($=this.config.properties_string_max_length,d=(function(D,K){let q=new Set;return(function ie(Q,P){if(Q!==Object(Q))return K?K(Q):Q;if(q.has(Q))return;let U;if(q.add(Q),N(Q))U=[],ai(Q,V=>{U.push(ie(V))});else{let V={};re(bi(Q)?$p(Q):Q,(W,ee)=>{q.has(W)||(V[ee]=ie(W,ee))}),U=V}return U})(D)})(d,D=>H(D)?D.slice(0,$):D)),d.timestamp=u,S(i?.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=c),g&&(d.properties=((D,K=[])=>{let q={},ie=Q=>{D[Q]!==void 0&&(q[Q]=D[Q])};return BS.forEach(ie),K.forEach(ie),q})(d.properties,QA)),e===ct.DISMISSED||e===ct.SENT){let D=s?.[sl.SURVEY_ID],K=s?.[sl.SURVEY_ITERATION];kv({id:D,current_iteration:K}),d.$set=_(_({},d.$set),{},{[MA({id:D,current_iteration:K},e===ct.SENT?"responded":"dismissed")]:!0})}else e===ct.SHOWN&&(d.$set=_(_({},d.$set),{},{[sl.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var $;if(e===yA.SHOWN){let D=s?.[bf.TOUR_TYPE];D&&(d.$set=_(_({},d.$set),{},{[`${bf.TOUR_LAST_SEEN_DATE}/${D}`]:new Date().toISOString()}))}let O=_(_({},d.properties.$set),d.$set);if(nt(O)||this.setPersonPropertiesForFlags(O),!B(this.config.before_send)){let D=this.Os(d);if(!D)return;d=D,d.uuid=Oh(d.uuid,bt)}this.sessionRecording&&!this.Eu&&$f(e)&&(this.Eu=!0,setTimeout(()=>this.Eu=!1,3e4));let x=A.filter(({channel:D,update:K})=>{var q,ie,Q;let P=(q=(ie=d.$set)===null||ie===void 0?void 0:ie[D.property])!==null&&q!==void 0?q:G((Q=d.properties)===null||Q===void 0?void 0:Q.$set)?d.properties.$set[D.property]:void 0;return K?.pending&&P===K.value});this.lu.emit("eventCaptured",d);let Y=(n=i?._url)!==null&&n!==void 0?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),X=i?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(Y),Z=_(_(_({method:"POST",url:Y,data:d,compression:"best-available",preferSyncCompression:i?.send_instantly,timestampMode:X?"body":"capture-body",batchKey:i?._batchKey},X&&(!((r=d.properties)===null||r===void 0)&&r.$session_id)?{batchGroup:d.properties.$session_id+(d.properties.$window_id?`-${d.properties.$window_id}`:"")}:{}),i?.transport?{transport:i.transport}:{}),x.length?{fireCallbackOnDrop:!0,callback:D=>{if(D.statusCode>=200&&300>D.statusCode)for(let{channel:K,update:q}of x)this.cc(K,q.value)}}:{});if(!this.config.request_batching||i&&!i?._batchKey||i?.send_instantly){var ae;let D;!Z.transport&&!Z.callback&&nt((ae=this.config.request_headers)!==null&&ae!==void 0?ae:{})&&this.xu&&(D="sendBeacon"),this.qu(Z,D)}else this.Nu.enqueue(Z);return d}_addCaptureHook(e){return this.on("eventCaptured",s=>e(s.event,s))}getExtension(e){var s;return(s=this.vc)===null||s===void 0?void 0:s.getExtension(e)}Qu(){var e;return(e=this.vc)!==null&&e!==void 0?e:this.vc=new qA(this)}cu(e){this.Mu.push(e);let s=!0;return()=>{if(!s)return;s=!1;let i=this.Mu.indexOf(e);i!==-1&&this.Mu.splice(i,1)}}fc(e=!0){var s,i,n;return!!(!((s=this.persistence)===null||s===void 0)&&s.consumeCookieIdentityChange())&&(this.Fu=null,this.persistence.get_property("$user_state")==="anonymous"&&((n=this.sessionPersistence)===null||n===void 0||n.clear(),this.Tu.clear(),this.gc()),(i=this.featureFlags)===null||i===void 0||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,s,i,n,r){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return s;this.bu(),this.persistence.syncCookieProperties(),this.fc();let o=r?void 0:this.persistence.remove_event_timer(e),a=_({},s);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.pu()&&(a[bp]=!0),e==="$snapshot"){let y=_(_({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=y.distinct_id,(!H(a.distinct_id)&&!Te(a.distinct_id)||sn(a.distinct_id))&&R.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}let l=(function(y,w,A,I=!1){var k,$,O,x;if(!Ye)return{};let Y=y?[..._i,...w||[]]:[],[X,Z]=Mg(Ye),[ae,D]=(function(le){for(let _e=0;Ch.length>_e;_e++){let[Re,xe,Me]=Ch[_e],Be=le.match(Re);if(Be){let z=Me&&le.match(Me)||Be;return[xe,z?.[1]||""]}}return["",""]})(Ye),K=(function(){let le="u">typeof navigator?navigator:void 0;return le?.brave?{brave:!0}:{}})(),q={};S(A)||(q.detectGoogleSearchApp=A);let ie={},Q=(k=navigator)===null||k===void 0||(k=k.userAgentData)===null||k===void 0?void 0:k.platform,P=($=navigator)===null||$===void 0?void 0:$.maxTouchPoints,U=E==null||(O=E.screen)===null||O===void 0?void 0:O.width,V=E==null||(x=E.screen)===null||x===void 0?void 0:x.height,W=E?.devicePixelRatio;S(Q)||(ie.userAgentDataPlatform=Q),S(P)||(ie.maxTouchPoints=P),S(U)||(ie.screenWidth=U),S(V)||(ie.screenHeight=V),S(W)||(ie.devicePixelRatio=W);let ee=ve(fc({$os:X,$os_version:Z,$browser:Ng(Ye,navigator.vendor,K,q),$webview_app:ae,$webview_app_version:D,$device:Fg(Ye),$device_type:lS(Ye,ie),$timezone:zp(),$timezone_offset:vA()}),{$current_url:yn(I?ds(pe?.href):pe?.href,Y,bn),$host:pe?.host,$pathname:pe?.pathname,$raw_user_agent:Ye.length>1e3?Ye.substring(0,997)+"...":Ye,$browser_version:aS(Ye,navigator.vendor,K,q),$browser_language:Xp(),$browser_language_prefix:pA(),$screen_height:E?.screen.height,$screen_width:E?.screen.width,$viewport_height:E?.innerHeight,$viewport_width:E?.innerWidth,$lib:Wt.LIB_NAME,$lib_version:Wt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Wt.SDK_DIST_CHANNEL&&(ee.$sdk_dist_channel=Wt.SDK_DIST_CHANNEL),ee})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){let{sessionId:y,windowId:w}=this.sessionManager.checkAndGetSessionAndWindowId(r,i.getTime(),!0);a.$session_id=y,a.$window_id=w}this.sessionPropsManager&&ve(a,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){let y=this.sessionRecording.sdkDebugProperties,w=!this.Eu&&$f(e);for(let A in y)(w||M(WA,A))&&(a[A]=y[A])}a.$sdk_debug_retry_queue_size=(c=this.ju)===null||c===void 0?void 0:c.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}let u;if(this.requestRouter.region===Yl&&(a.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||r?e!=="$pageleave"||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,n),a=ve(a,u),e==="$pageview"&&T&&(a.title=T.title),!S(o)){let y=i.getTime()-o;a.$duration=parseFloat((y/1e3).toFixed(3))}Ye&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");let h=this.persistence.properties(),d=this.sessionPersistence.properties(),g=a.$groups,p=h.$groups;G(g)&&!nt(g)&&(a.$groups=_(_({},G(p)?p:{}),g)),re(["$referrer","$referring_domain"],y=>{y in h&&delete d[y]});let m={};if(this.Mu.length>0)for(let y of this.Mu.slice())try{ve(m,y())}catch(w){R.error("Failed to produce browser extension event properties",w)}a=ve({},l,h,d,_(_({},m),a)),a.$is_identified=this._isIdentified(),N(this.config.property_denylist)?re(this.config.property_denylist,function(y){delete a[y]}):R.error(Cv+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);let v=this.config.sanitize_properties;v&&(R.error(Pf),a=v(a,e));let b=this.mc();return a.$process_person_profile=b,b&&!r&&this.yc("_calculate_event_properties"),a}dc(e,s=!0,i=!1){var n;if(!this.persistence||!this.mc()||this.Cu&&!i)return e;let r=this.persistence.get_initial_props(),o=(n=this.sessionPropsManager)===null||n===void 0?void 0:n.getSetOnceProps(),a=ve({},r,o||{},e||{}),l=this.config.sanitize_properties;return l&&(R.error(Pf),a=l(a,"$set_once")),s&&(this.Cu=!0),nt(a)?void 0:a}register(e,s){var i;(i=this.persistence)===null||i===void 0||i.register(e,s)}register_once(e,s,i){var n;(n=this.persistence)===null||n===void 0||n.register_once(e,s,i)}register_for_session(e){var s,i;(s=this.persistence)===null||s===void 0||s.syncCookieProperties(),this.fc(),(i=this.sessionPersistence)===null||i===void 0||i.register(e),Object.keys(e).forEach(n=>this.Tu.add(n)),this.gc()}unregister(e){var s;(s=this.persistence)===null||s===void 0||s.unregister(e)}unregister_for_session(e){var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(e),this.Tu.delete(e),this.gc()}bc(e,s){this.register({[e]:s})}Bu(){this.Tu.forEach(e=>{var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(e)}),this.Tu.clear(),this.gc()}gc(){var e;if(!this.Iu)return;if(this.config.persistence==="memory"||!((e=this.sessionPersistence)===null||e===void 0)&&e.hi||!de.At())return void de.Pt(this.Iu);let s=[];this.Tu.forEach(i=>s.push(i)),s.length>0?de.$t(this.Iu,s):de.Pt(this.Iu)}getFeatureFlag(e,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlag(e,s)}getFeatureFlagPayload(e){var s;return(s=this.featureFlags)===null||s===void 0?void 0:s.getFeatureFlagPayload(e)}getFeatureFlagResult(e,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlagResult(e,s)}getAllFeatureFlags(){var e,s;return(e=(s=this.featureFlags)===null||s===void 0?void 0:s.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,s){var i,n;return(i=(n=this.featureFlags)===null||n===void 0?void 0:n.isFeatureEnabled(e,s))!==null&&i!==void 0?i:s?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)===null||e===void 0||e.reloadFeatureFlags()}updateFlags(e,s,i){var n;(n=this.featureFlags)===null||n===void 0||n.updateFlags(e,s,i)}updateEarlyAccessFeatureEnrollment(e,s,i){var n;(n=this.featureFlags)===null||n===void 0||n.updateEarlyAccessFeatureEnrollment(e,s,i)}getEarlyAccessFeatures(e,s=!1,i){var n;return(n=this.featureFlags)===null||n===void 0?void 0:n.getEarlyAccessFeatures(e,s,i)}on(e,s){return this.lu.on(e,s)}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:si}),()=>{})}onSessionId(e){var s,i;return(s=(i=this.sessionManager)===null||i===void 0?void 0:i.onSessionId(e))!==null&&s!==void 0?s:()=>{}}getSurveys(e,s=!1){this.surveys?this.surveys.getSurveys(e,s):e([],{isLoaded:!1,error:si})}getActiveMatchingSurveys(e,s=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,s):e([],{isLoaded:!1,error:si})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:si}),()=>{})}renderSurvey(e,s){var i;(i=this.surveys)===null||i===void 0||i.renderSurvey(e,s)}displaySurvey(e,s=VA){var i;(i=this.surveys)===null||i===void 0||i.displaySurvey(e,s)}cancelPendingSurvey(e){var s;(s=this.surveys)===null||s===void 0||s.cancelPendingSurvey(e)}canRenderSurvey(e){var s,i;return(s=(i=this.surveys)===null||i===void 0?void 0:i.canRenderSurvey(e))!==null&&s!==void 0?s:{visible:!1,disabledReason:si}}canRenderSurveyAsync(e,s=!1){var i,n;return(i=(n=this.surveys)===null||n===void 0?void 0:n.canRenderSurveyAsync(e,s))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:si})}_c(e){return!e||sn(e)?(R.critical("Unique user id has not been set in posthog.identify"),!1):e==="$posthog_cookieless"?(R.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())||(R.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,s,i){if(!this.__loaded||!this.persistence)return R.uninitializedWarning("posthog.identify");if(Te(e)&&(e=e.toString(),R.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this._c(e)||!this.yc("posthog.identify"))return;this.bu();let n=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==n,o=this.fc(!1),a=this.persistence.Oa(),l=!1;try{let u=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:u},""),e!==u&&e!==this.get_property("__alias")&&(this.unregister(Qr),this.register({distinct_id:e}));let h=(this.persistence.get_property("$user_state")||"anonymous")===qt,d=e!==u,g=!d&&h;if(d&&h){var c;let p=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:u};this.persistence.set_property(Qe,Mr),this.setPersonPropertiesForFlags({$set:s||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$identify",p,{$set:s||{},$set_once:i||{}})&&(this.Fu=ll(e,s,i)),(c=this.featureFlags)===null||c===void 0||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:u)}else if(g){this.persistence.set_property(Qe,Mr);let p=s||{},m=i||{};this.setPersonPropertiesForFlags({$set:p,$set_once:m},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$set",{$set:p,$set_once:m})&&(this.Fu=ll(e,s,i))}else(s||i)&&this.setPersonProperties(s,i);d||r||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ls)):g&&(s||i)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.qa(l)}}setPersonProperties(e,s){if(!e&&!s||!this.yc("posthog.setPersonProperties"))return;let i=ll(this.get_distinct_id(),e,s);this.Fu!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:s||{}},!0),this.capture("$set",{$set:e||{},$set_once:s||{}})&&(this.Fu=i)):R.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var s;let i=(N(e)?e:[e]).filter(n=>H(n)&&n.length>0);i.length!==0&&this.yc("posthog.unsetPersonProperties")&&((s=this.featureFlags)===null||s===void 0||s.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Fu=null)}group(e,s,i){var n;if(!e||!s)return void R.error("posthog.group requires a group type and group key");(n=this.persistence)===null||n===void 0||n.syncCookieProperties(),this.fc();let r=this.getGroups(),o=r[e]!==s;if(o&&this.resetGroupPropertiesForFlags(e),this.register({$groups:_(_({},r),{},{[e]:s})}),(o||i)&&this.mc()){let a={$group_type:e,$group_key:s};i&&(a.$group_set=i),this.capture(Zh,a)}i&&this.setGroupPropertiesForFlags({[e]:i}),o&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,s=!0){var i;(i=this.featureFlags)===null||i===void 0||i.setPersonPropertiesForFlags(e,s)}resetPersonPropertiesForFlags(e=!0){var s;(s=this.featureFlags)===null||s===void 0||s.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,s=!0){var i;this.yc("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)===null||i===void 0||i.setGroupPropertiesForFlags(e,s))}resetGroupPropertiesForFlags(e){var s;(s=this.featureFlags)===null||s===void 0||s.resetGroupPropertiesForFlags(e)}reset(e){let s=Je(e)?e:e?.resetDeviceID,i=Je(e)||e==null?void 0:e.bootstrap;this.wc(s,!1,i)}wc(e,s=!1,i){var n,r,o,a,l,c;if(R.info("reset"),!this.__loaded)return R.uninitializedWarning("posthog.reset");let u=i?.sessionID;this.config.bootstrap=i||((n=this.Du)===null||n===void 0?void 0:n.bootstrap)||{},(r=this.featureFlags)===null||r===void 0||(o=r.updateConfig)===null||o===void 0||o.call(r,this.config,this.il());let h=this.get_property(rc),d=this.get_property(Ha),g=this.get_property(an);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();let p=this.is_capturing();s||this.consent.reset(),s||!p||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");let m=(l=this.persistence)===null||l===void 0||(c=l.Oa)===null||c===void 0?void 0:c.call(l),v=this._u;this._u=v||s;let b=!1;try{var y,w,A,I,k,$,O,x,Y,X,Z,ae,D;if((y=this.persistence)===null||y===void 0||y.clear(),(w=this.sessionPersistence)===null||w===void 0||w.clear(),this.Tu.clear(),this.gc(),S(g)||(X=this.persistence)===null||X===void 0||X.register({$session_recording_remote_config:g}),(A=this.surveys)===null||A===void 0||A.reset(),(I=this.featureFlags)===null||I===void 0||I.reset(),(k=this.conversations)===null||k===void 0||k.reset(),($=this.logs)===null||$===void 0||$.reset(),(O=this.metrics)===null||O===void 0||O.reset(),(x=this.persistence)===null||x===void 0||x.set_property("$user_state","anonymous"),(Y=this.sessionManager)===null||Y===void 0||Y.resetSessionId(),this.Fu=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:za,$device_id:null},"");else{let ie=this.config.get_device_id(bt());this.register_once({distinct_id:ie,$device_id:e?ie:h},""),e||S(d)||this.register({[Ha]:d})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID&&!this.pu()&&((D=this.persistence)===null||D===void 0||D.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),(Z=this.featureFlags)===null||Z===void 0||Z.initialize(),!B(u)&&!(!((ae=this.sessionManager)===null||ae===void 0)&&ae.setBootstrapSessionId(u,!0)))){let ie=_({},i);delete ie.sessionID,this.config.bootstrap=ie}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,b=!0}finally{var K,q;this._u=v,m&&((K=this.persistence)===null||K===void 0||(q=K.qa)===null||q===void 0||q.call(K,b))}this.reloadFeatureFlags()}shutdown(e){var s=this;return he(function*(){if(!s.__loaded)return void R.uninitializedWarning("posthog.shutdown");s.$u=!0,clearTimeout(s.Hu),s.Hu=void 0;let i=s.Zu;s.Zu=void 0;for(let n of[()=>{var r;return(r=s.sessionRecording)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=s.logs)===null||r===void 0?void 0:r.flushLogs("sendBeacon")},()=>{var r;return(r=s.metrics)===null||r===void 0?void 0:r.flush("sendBeacon")},()=>{var r;return(r=s.metrics)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=s.logs)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=s.surveys)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=s.autocapture)===null||r===void 0?void 0:r.dispose()},()=>i?.(),()=>{var r;return(r=s.Nu)===null||r===void 0?void 0:r.unload()},()=>{var r;return(r=s.ju)===null||r===void 0?void 0:r.unload()},()=>{var r;return(r=s.featureFlags)===null||r===void 0?void 0:r.destroy()},()=>{var r;return(r=s.persistence)===null||r===void 0?void 0:r.destroy()},()=>{var r;return(r=s.sessionPersistence)===null||r===void 0?void 0:r.destroy()}])try{let r=n();r&&Ce(r.then)&&r.then(void 0,o=>{R.error("Error during shutdown",o)})}catch(r){R.error("Error during shutdown",r)}})()}setIdentity(e,s){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=s,this.alias(e),(i=this.conversations)===null||i===void 0||i.kc()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)===null||e===void 0||e.Sc()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,s;return(e=(s=this.sessionManager)===null||s===void 0?void 0:s.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";let{sessionId:s,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${s}`);if(e?.withTimestamp&&i){var r;let o=(r=e.timestampLookBack)!==null&&r!==void 0?r:10;if(!i)return n;n+=`?t=${Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}`}return n}alias(e,s){return e===this.get_property("$people_distinct_id")?(R.critical("Attempting to create alias for existing People user - aborting."),-2):this.yc("posthog.alias")?(S(s)&&(s=this.get_distinct_id()),e!==s?(this.bc(Qr,e),this.capture("$create_alias",{alias:e,distinct_id:s})):(R.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){let s=_({},this.config);if(G(e)){var i,n,r,o,a,l,c,u,h,d,g,p,m,v;ve(this.config,Nf(e));let I=this.Su();if(this.persistence){let $=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var b,y;if($&&this.sessionPersistence!==this.persistence&&((b=this.sessionPersistence)===null||b===void 0||b.remove(),(y=this.sessionPersistence)===null||y===void 0||y.destroy()),this.persistence.update_config(this.config,s,I),$)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new el(_(_({},this.config),{},{persistence:"sessionStorage"}),I,!1);else{var w;(w=this.sessionPersistence)===null||w===void 0||w.update_config(_(_({},this.config),{},{persistence:"sessionStorage"}),_(_({},s),{},{persistence:"sessionStorage"}),I)}}let k=this.Ou(this.config.debug);var A;Je(k)&&(this.config.debug=k),Je(this.config.debug)&&(this.config.debug?(it.DEBUG=!0,J.At()&&J.$t("ph_debug",!0),R.info("set_config",{config:e,oldConfig:s,newConfig:_({},this.config)})):(it.DEBUG=!1,J.At()&&J.Pt("ph_debug"))),(i=this.featureFlags)===null||i===void 0||(n=i.updateConfig)===null||n===void 0||n.call(i,this.config,this.il()),(r=this.exceptionObserver)===null||r===void 0||r.onConfigChange(),(o=this.exceptions)===null||o===void 0||o.onConfigChange(),(a=this.metrics)===null||a===void 0||a.onConfigChange(),(l=this.webMCP)===null||l===void 0||l.startIfEnabled(),(c=this.sessionRecording)===null||c===void 0||c.startIfEnabledOrStop(),(u=this.tracingHeaders)===null||u===void 0||u.startIfEnabledOrStop(),(h=this.autocapture)===null||h===void 0||h.startIfEnabled(),(d=this.heatmaps)===null||d===void 0||d.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&((A=this.historyAutocapture)===null||A===void 0||A.startIfEnabledOrStop()),(g=this.exceptionObserver)===null||g===void 0||g.startIfEnabledOrStop(),(p=this.deadClicksAutocapture)===null||p===void 0||p.startIfEnabledOrStop(),(m=this.surveys)===null||m===void 0||m.loadIfEnabled(),this.wu(),(v=this.externalIntegrations)===null||v===void 0||v.startIfEnabledOrStop(),!s.segment&&this.config.segment&&this.persistence&&vf(this,hn,!1)}}_overrideSDKInfo(e,s){it.LIB_NAME=e,it.LIB_VERSION=s}startSessionRecording(e){let s=e===!0,i={sampling:s||!!e?.sampling,linked_flag:s||!!e?.linked_flag,url_trigger:s||!!e?.url_trigger,event_trigger:s||!!e?.event_trigger};var n,r,o,a,l;Object.values(i).some(Boolean)&&((n=this.sessionManager)===null||n===void 0||n.checkAndGetSessionAndWindowId(),i.sampling&&((r=this.sessionRecording)===null||r===void 0||r.overrideSampling()),i.linked_flag&&((o=this.sessionRecording)===null||o===void 0||o.overrideLinkedFlag()),i.url_trigger&&((a=this.sessionRecording)===null||a===void 0||a.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.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===void 0)&&e.started)}captureException(e,s){try{if(!this.exceptions)return;let i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(_(_({},i),s))}catch{return}}addExceptionStep(e,s){var i;(i=this.exceptions)===null||i===void 0||i.addExceptionStep(e,s)}captureLog(e){var s;(s=this.logs)===null||s===void 0||s.captureLog(e)}get logger(){var e,s;return(e=(s=this.logs)===null||s===void 0?void 0:s.logger)!==null&&e!==void 0?e:rs.xc}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var s,i;return(s=(i=this.toolbar)===null||i===void 0?void 0:i.loadToolbar(e))!==null&&s!==void 0&&s}get_property(e){var s;return(s=this.persistence)===null||s===void 0?void 0:s.props[e]}getSessionProperty(e){var s;return(s=this.sessionPersistence)===null||s===void 0?void 0:s.props[e]}toString(){var e;let s=(e=this.config.name)!==null&&e!==void 0?e:tn;return s!==tn&&(s="posthog."+s),s}_isIdentified(){var e,s;return((e=this.persistence)===null||e===void 0?void 0:e.get_property("$user_state"))==="identified"||((s=this.sessionPersistence)===null||s===void 0?void 0:s.get_property("$user_state"))==="identified"}mc(){var e,s;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&nt(this.getGroups())&&!(!((e=this.persistence)===null||e===void 0||(e=e.props)===null||e===void 0)&&e.__alias)&&!(!((s=this.persistence)===null||s===void 0||(s=s.props)===null||s===void 0)&&s.$epp))}ec(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.mc()||this.yc("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.yc("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}yc(e){return this.config.person_profiles==="never"?(R.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gu(),this.bc(lc,!0),!0)}Su(){if(this.config.cookieless_mode==="always")return!0;let e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}wu(){var e,s;let i=this.Su();var n,r,o;return this.is_capturing()||(n=this.logs)===null||n===void 0||n.$c(),((e=this.persistence)===null||e===void 0?void 0:e.hi)!==i&&((r=this.persistence)===null||r===void 0||r.set_disabled(i)),((s=this.sessionPersistence)===null||s===void 0?void 0:s.hi)!==i&&((o=this.sessionPersistence)===null||o===void 0||o.set_disabled(i)),this.gc(),i}opt_in_capturing(e){var s;if(this.config.cookieless_mode!=="always"){if(this.pu()){var i,n,r,o,a,l;(i=this.sessionRecording)===null||i===void 0||i.dispose({discardBufferedEvents:!0}),this.wc(!0,!0),(n=this.sessionManager)===null||n===void 0||n.destroy(),(r=this.pageViewManager)===null||r===void 0||r.destroy(),this.sessionManager=new Rf(this),this.pageViewManager=new _f(this),this.persistence&&(this.sessionPropsManager=new Tf(this,this.sessionManager,this.persistence));let g=(o=(a=this.config.__extensionClasses)===null||a===void 0?void 0:a.sessionRecording)!==null&&o!==void 0?o:(l=rs.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var c,u;g&&(this.sessionRecording=this.fu(this.sessionRecording,new g(this)),this.uu&&((c=this.sessionRecording)===null||c===void 0||(u=c.onRemoteConfig)===null||u===void 0||u.call(c,this.uu)))}var h,d;this.consent.optInOut(!0),this.wu(),this.Xu(),(s=this.sessionRecording)===null||s===void 0||s.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((h=this.surveys)===null||h===void 0||h.loadIfEnabled()),(S(e?.captureEventName)||e?.captureEventName)&&this.capture((d=e?.captureEventName)!==null&&d!==void 0?d:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Yu()}else R.warn(Of)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.wu(),this.config.cookieless_mode==="on_reject"&&this.ku()):R.warn(Of)}ku(){var e,s;let i=this.sessionRecording;i?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.wc(!0,!0),this.register({distinct_id:za,$device_id:null}),this.du(i),this.sessionRecording=void 0,(e=this.sessionManager)===null||e===void 0||e.destroy(),(s=this.pageViewManager)===null||s===void 0||s.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Yu(),this.Xu()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){let e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return!this._u&&(this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing()))}clear_opt_in_out_capturing(){this.consent.reset(),this.wu()}_is_bot(){return Le?yv(Le,this.config.custom_blocked_useragents):void 0}Yu(){T&&(T.visibilityState==="visible"?this.Pu||(this.Pu=!0,this.capture(hc,{title:T.title},{send_instantly:!0}),this.Ru&&(T.removeEventListener(_n,this.Ru),this.Ru=null)):this.Ru||(this.Ru=this.Yu.bind(this),se(T,_n,this.Ru)))}debug(e){e===!1?(E?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(E?.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}))}il(){let e=this.Du||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(R.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):(function(s,i,n,r,o){let a=i in s&&!B(s[i]),l=n in s&&!B(s[n]);return a?s[i]:!!l&&(o&&o.warn(`Config field '${n}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),s[n])})(e,"advanced_disable_flags","advanced_disable_decide",0,R)}Os(e){var s;if(B(this.config.before_send))return e;let i=Object.keys((s=e.properties)!==null&&s!==void 0?s:{}).filter(Qw),n=N(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(let o of n)try{if(r=o(r),B(r)){let a=`Event '${e.event}' was rejected in beforeSend function`;return Yw(e.event)?R.warn(`${a}. This can cause unexpected behavior.`):R.info(a),null}r.properties&&!nt(r.properties)||R.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return R.error(`Error in beforeSend function for event '${e.event}':`,a),null}for(let o of i)if(r.properties&&B(r.properties[o]))return R.warn(`Event '${e.event}' had its '${o}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){var e;return(e=this.pageViewManager.Wo)===null||e===void 0?void 0:e.pageViewId}captureTraceFeedback(e,s){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:s})}captureTraceMetric(e,s,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:s,$ai_metric_value:String(i)})}Ou(e){let s=Je(e)&&!e,i=J.At()&&J.Ot("ph_debug")==="true";return!s&&(!!i||e)}};fn.__defaultExtensionClasses={},fn.xc=(()=>{let t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),(function(t,e){for(let s=0;e.length>s;s++)t.prototype[e[s]]=Hk(t.prototype[e[s]])})(fn,["identify"]);Ov=class{constructor(t){this.disabled=t===!1;let e=G(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,s){if(this.disabled)return!1;let i=this.clicks[this.clicks.length-1];if(i&&Math.abs(t-i.x)+Math.abs(e-i.y)<this.thresholdPx&&this.timeoutMs>s-i.timestamp){if(this.clicks.push({x:t,y:e,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:s}];return!1}},dl="$copy_autocapture",hl=ye("[AutoCapture]");sT=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(t){var e;if(!Ms(t))return!0;let s=(e=this.mo().css_selector_ignorelist)!==null&&e!==void 0?e:Ja,i=new Set,n=t;for(;n;){if(i.size>=1e3||i.has(n))return!0;i.add(n);let r=n,o=gi(r);if(M(o,"ph-no-capture")||M(o,"ph-sensitive")||pi(r)||s.some(l=>jl(r,l)))return!0;let a=n.parentNode;n=gc(a)?a.host:a&&Et(a)?a:null}return!1}yo(t){if(!this.isEnabled||t.type==="pointercancel")return void this.do();if(t.type==="pointerdown"){this.do();let i=cn(t);var e;return void(t.isPrimary&&t.button===0&&!t.ctrlKey&&i&&Et(i)&&(this.vo={target:i,excluded:this.po(i),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:(e=this.bo)===null||e===void 0?void 0:e.distinctId}))}let s=this.vo;s&&(t.pointerId!==s.id||Math.abs(t.clientX-s.x)>5||Math.abs(t.clientY-s.y)>5?this.do():t.type==="pointerup"&&(s.released=!0,this.fo=setTimeout(()=>this.do(),0)))}_o(t){var e;let s=this.vo;this.do();let i=cn(t);if(s?.released&&s.target.isConnected&&s.distinctId===((e=this.bo)===null||e===void 0?void 0:e.distinctId)&&t.pointerId===s.id&&(t.detail>0||t.pointerType==="touch"||t.pointerType==="pen")&&t.button===0&&5>=Math.abs(t.clientX-s.x)&&5>=Math.abs(t.clientY-s.y)&&i&&(Ue(i,"html")||Ue(i,"body"))){var n;if(s.excluded)return null;let r=(n=this.mo().css_selector_ignorelist)!==null&&n!==void 0?n:Ja;return[i,T?.documentElement,T?.body].some(o=>{if(!o)return!1;let a=gi(o);return M(a,"ph-no-capture")||M(a,"ph-sensitive")||!Ms(o)||pi(o)||r.some(l=>jl(o,l))})?null:s.target}}constructor(t){this.wo=t,this.name=Av,this.ko=!1,this.So=null,this.xo=!1,this.$o=new Map,this.Co=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.To=!1,this.wo.refresh(this.Mr),this.rageclicks=new Ov(this.Mr.rageclick),this.Io=null}setup(t){this.Mo(),this.bo=t;let e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.To?e.dispose():(this.Eo=e,this.startIfEnabled())}dispose(){var t;this.To||(this.To=!0,this.bo=void 0,(t=this.Eo)===null||t===void 0||t.dispose(),this.Eo=void 0,this.$o.clear(),this.Io=null,this.Po())}mo(){return this.wo.refresh(this.Mr),this.Mr}Mo(){var t,e;return this.mo(),this.Mr.url_allowlist=(t=this.Mr.url_allowlist)===null||t===void 0?void 0:t.map(s=>new RegExp(s)),this.Mr.url_ignorelist=(e=this.Mr.url_ignorelist)===null||e===void 0?void 0:e.map(s=>new RegExp(s)),this.Mr}Ro(){if(!this.isBrowserSupported())return void hl.info("Disabling Automatic Event Collection because this browser is not supported");if(!E||!T)return;let t=this.Ao=e=>{e=e||E?.event;try{if(e.type==="blur")return void this.do();if(e.type.indexOf("pointer")===0)return void this.yo(e);let s=e.type==="click"?this._o(e):void 0;if(we(s))return;this.Fo(e,"$autocapture",s)}catch(s){hl.error("Failed to capture event",s)}};if(se(E,"blur",t),se(T,"submit",t,{capture:!0}),se(T,"change",t,{capture:!0}),se(T,"click",t,{capture:!0}),re(["pointerdown","pointermove","pointerup","pointercancel"],e=>{se(T,e,t,{capture:!0})}),this.mo().capture_copied_text){let e=this.Oo=s=>{s=s||E?.event;try{this.Fo(s,dl)}catch(i){hl.error("Failed to capture clipboard event",i)}};se(T,"copy",e,{capture:!0}),se(T,"cut",e,{capture:!0}),se(T,"paste",e,{capture:!0})}}Po(){this.do(),this.Ao&&(E?.removeEventListener("blur",this.Ao),re(["pointerdown","pointermove","pointerup","pointercancel"],t=>{T?.removeEventListener(t,this.Ao,!0)}),T?.removeEventListener("submit",this.Ao,!0),T?.removeEventListener("change",this.Ao,!0),T?.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Oo&&(T?.removeEventListener("copy",this.Oo,!0),T?.removeEventListener("cut",this.Oo,!0),T?.removeEventListener("paste",this.Oo,!0),this.Oo=void 0),this.ko=!1}startIfEnabled(){this.isEnabled||this.do(),!this.To&&this.bo&&this.isEnabled&&!this.ko&&(this.Ro(),this.ko=!0)}onRemoteConfig(t){if(this.To)return;if(this.xo=!0,!t.ok)return void this.startIfEnabled();let e=t.config;e.elementsChainAsString&&(this.Co=e.elementsChainAsString);let s=e.autocapture_opt_out;var i;Je(s)&&((i=this.bo)===null||i===void 0||i.kv.set("$autocapture_disabled_server_side",s),this.So=s),this.startIfEnabled()}setElementSelectors(t,e=this){if(this.To)return;t.size?this.$o.set(e,new Set(t)):this.$o.delete(e);let s=new Set;this.$o.forEach(i=>{i.forEach(n=>s.add(n))}),this.Io=s}getElementSelectors(t,e){var s;let i=[];return(s=this.Io)===null||s===void 0||s.forEach(n=>{let r=T?.querySelectorAll(n);r?.forEach(o=>{t!==o&&e!==o||M(i,n)||i.push(n)})}),i}get isEnabled(){var t,e;if(this.To)return!1;let s=(t=this.bo)===null||t===void 0?void 0:t.kv.get(cp),i=this.So,n=this.mo();if(!n.remoteRequestsDisabled&&!this.xo)return!1;let r=n.remoteRequestsDisabled&&!this.xo;if(we(i)&&!Je(s)&&!r)return!1;let o=(e=this.So)!==null&&e!==void 0?e:!!s;return!!n.enabled&&!o}Fo(t,e="$autocapture",s){if(!this.isEnabled)return void this.do();let i=s||cn(t);Mp(i)&&(i=i.parentNode||null);let n=this.Mo();var r;e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&n.rageclick&&(!((r=this.rageclicks)===null||r===void 0)&&r.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime()))&&Bp(i,n.rageclick)&&this.Fo(t,"$rageclick",s);let o=e===dl,a=o?_(_({},n),{},{dom_event_allowlist:void 0}):n;if(i&&(function(h,d,g,p,m,v){var b;if(!E||mc(h)||g?.url_allowlist&&!rf(g.url_allowlist,v)||g?.url_ignorelist&&rf(g.url_ignorelist,v))return!1;if(g?.dom_event_allowlist){let I=g.dom_event_allowlist;if(I&&!I.some(k=>d.type===k))return!1}let{parentIsUsefulElement:y,targetElementList:w}=Vp(h,p);if(!(function(I,k){let $=k?.element_allowlist;if(S($))return!0;for(let O of I)if($.some(x=>O.tagName.toLowerCase()===x))return!0;return!1})(w,g)||!Gl(w,g?.css_selector_allowlist)||Gl(w,(b=g?.css_selector_ignorelist)!==null&&b!==void 0?b:Ja))return!1;try{let I=E.getComputedStyle(h);if(I&&I.getPropertyValue("cursor")==="pointer"&&d.type==="click")return!0}catch{}let A=h.tagName.toLowerCase();switch(A){case"html":return!1;case"form":return(m||["submit"]).indexOf(d.type)>=0;case"input":case"select":case"textarea":return(m||["change","click"]).indexOf(d.type)>=0;default:return y?(m||["click"]).indexOf(d.type)>=0:(m||["click"]).indexOf(d.type)>=0&&(vc.indexOf(A)>-1||h.getAttribute("contenteditable")==="true")}})(i,t,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l;let{props:h,explicitNoCapture:d,target:g}=tT(i,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:n.disableCaptureUrlHashes});if(d)return!1;let p=this.getElementSelectors(i,g);if(p&&p.length>0&&(h.$element_selectors=p),e===dl){let m=t.type||"clipboard";if(m!=="paste"){var c,u;let v=E==null||(c=E.getSelection())===null||c===void 0?void 0:c.toString(),b=Fp(v);if(!b)return!1;h.$selected_content=b,h.$clipboard_text_length=(u=v?.length)!==null&&u!==void 0?u:0}h.$copy_type=m}return(l=this.bo)===null||l===void 0||l.capture(e,h),!0}}isBrowserSupported(){return Ce(T?.querySelectorAll)}},iT=class{constructor(t){this._instance=t}refresh(t){let e=this._instance.config,s=G(e.autocapture)?e.autocapture:void 0;t.enabled=!!e.autocapture,t.rageclick=e.rageclick,t.maskAllElementAttributes=e.mask_all_element_attributes,t.maskAllText=e.mask_all_text,t.disableCaptureUrlHashes=e.disable_capture_url_hashes,t.getCurrentUrl=e.get_current_url,t.remoteRequestsDisabled=this._instance.il(),t.url_allowlist=s?.url_allowlist,t.url_ignorelist=s?.url_ignorelist,t.dom_event_allowlist=s?.dom_event_allowlist,t.element_allowlist=s?.element_allowlist,t.css_selector_allowlist=s?.css_selector_allowlist,t.css_selector_ignorelist=s?.css_selector_ignorelist,t.element_attribute_ignorelist=s?.element_attribute_ignorelist,t.capture_copied_text=s?.capture_copied_text}},Xi=ye("[ExceptionAutocapture]"),Mf=()=>{},Ff=t=>{var e;if(Ce(t))return(e=t.__posthog_layer__)!==null&&e!==void 0?e:t.__rrweb_layer__};nT=ye("[TracingHeaders]"),Rs=ye("[Web Vitals]"),Lf=9e5,Uf=["CLS","FCP","INP","LCP"],rT=["INP","LCP"],oT=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],gl="disabled",Bf="lazy_loading",jt=ye("[SessionRecording]"),aT=[cc,uc,Sp,kp,Ap,Tp,Ip,Rp,Cp],lT=ye("[Heatmaps]");Pr=ye("[Product Tours]"),vl=t=>{var e;return!t.config.disable_product_tours&&!!(!((e=t.persistence)===null||e===void 0)&&e.get_property(ac))},cT=["$set_once","$set"],At=ye("[SiteApps]"),Vf="Error while initializing PostHog app with config id ",Ec=(t,e)=>t?.then?t.then(e):e(t),ii="SDK is not enabled or survey functionality is not yet loaded",jf="Disabled. Not loading surveys.",uT=class{constructor(t,e){this.wo=t,this.Cc=e,this.name=Rv,this._surveyEventReceiver=null,this._surveyManager=null,this.Tc=!1,this.Ic=!1,this.Mc=[],this.Ec=[],this.Pc=null,this.Rc=null,this.To=!1,this.Ac=new Set,this.onRemoteConfig=s=>{if(this.To||this.Mr.disableSurveys)return;if(!s.ok)return this.Ic=!0,this.Fc({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),ne.warn("Remote config unavailable. Not loading surveys.");let i=s.config.surveys;if(B(i))return ne.warn("Flags not loaded yet. Not loading surveys.");this.Oc=Je(i)?i:i.length>0,ne.info(`flags response received, isSurveysEnabled: ${this.Oc}`),this.loadIfEnabled()},this.Fc=s=>{this.Ec.slice().forEach(i=>this.Dc(i,s))}}setup(t){if(!this.To)return this.Lc=t,Ec(t.kv.initialize(),()=>{if(this.Lc!==t||this.To)return;this.Lc=void 0,this.bo=t;let e=t.onRemoteConfig(this.onRemoteConfig);this.To?e.dispose():(this.Eo=e,this.loadIfEnabled())})}dispose(){var t,e,s,i,n;this.To||(this.To=!0,this.Lc=void 0,this.bo=void 0,(t=this.Eo)===null||t===void 0||t.dispose(),this.Eo=void 0,(e=this._surveyEventReceiver)===null||e===void 0||e.dispose(),this._surveyEventReceiver=null,(s=this._surveyManager)===null||s===void 0||(i=s.dispose)===null||i===void 0||i.call(s),this._surveyManager=null,this.Mc=[],this.Ec.forEach(r=>{r.active=!1}),this.Ec=[],(n=this.Nc)===null||n===void 0||n.call(this),this.Nc=void 0,this.Pc=null,this.Ac.forEach(r=>clearTimeout(r)),this.Ac.clear())}get Mr(){return this.wo.get()}initialize(){this.loadIfEnabled()}reset(){var t,e;(t=this._surveyManager)===null||t===void 0||(e=t.clearInMemoryInProgressSurveyState)===null||e===void 0||e.call(t);try{var s;(s=this._surveyEventReceiver)===null||s===void 0||s.reset(),localStorage.removeItem("lastSeenSurveyDate");let i=[];for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);(r?.startsWith("seenSurvey_")||r?.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach(n=>localStorage.removeItem(n))}catch{}this.Fc()}loadIfEnabled(){if(this.To||!this.bo)return;let t=this.Mr;if(this._surveyManager)return;if(this.Tc)return void ne.info("Already initializing surveys, skipping...");if(t.disableSurveys)return void ne.info(jf);if(t.cookielessMode&&this.wo.isOptedOut())return void ne.info("Not loading surveys in cookieless mode without consent.");let e=this.wo.getExtensions();if(!e)return void this.qc("PostHog Extensions not found.");if(S(this.Oc)&&!t.advancedEnableSurveys)return;let s=this.Oc||t.advancedEnableSurveys;this.Tc=!0,this.Ic=!1;try{let i=e.generateSurveys;if(i)return this.jc(i,s),void(this.Tc=!1);let n=e.loadExternalDependency;if(!n)return this.qc(dc),void(this.Tc=!1);n(r=>{try{if(this.To)return;let o=this.wo.getExtensions();r||!o?.generateSurveys?this.qc("Could not load surveys script",r):this.jc(o.generateSurveys,s)}finally{this.Tc=!1}})}catch(i){throw this.Tc=!1,this.qc("Error initializing surveys",i),i}}jc(t,e){var s,i;if(this.To)return;this._surveyManager=t(e),this._surveyEventReceiver=this.wo.createEventReceiver(this.Fc);let n=(s=(i=this.bo)!==null&&i!==void 0?i:this.Cc)===null||s===void 0?void 0:s.kv.get(en);n&&this.Bc(n),ne.info("Surveys loaded successfully"),this.zc(),this.Fc(),this.Hc({isLoaded:!0})}qc(t,e){this.Ic=!0,ne.error(t,e),this.Fc({isLoaded:!1,error:t}),this.Hc({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Mc.push(t),this._surveyManager&&this.Hc({isLoaded:!0}),()=>{this.Mc=this.Mc.filter(e=>e!==t)}}getSurveys(t,e=!1){var s;let i=(s=this.bo)!==null&&s!==void 0?s:this.Cc;if(!i||this.To)return;if(this.Mr.disableSurveys)return ne.info(jf),t([]);let n=i.kv.get(en);if(n&&!e)return t(n,{isLoaded:!0}),void(this.Uc()&&this.getSurveys(()=>{},!0));if(this.Pc)return void this.Pc.then(({surveys:a,context:l})=>{this.To||t(a,l)}).catch(a=>ne.error("Error in survey callback",a));let r=this.Wc("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(a=>{try{return this.Vc(i,a)}catch(l){return ne.error("Error processing surveys response",l),this.Vc(i,{statusCode:0,error:l})}},a=>this.Vc(i,{statusCode:0,error:a}));this.Pc=r;let o=()=>{this.Pc===r&&(this.Pc=null)};r.then(a=>{o(),this.To||(this.Fc(a.context),t(a.surveys,a.context))},o).catch(a=>ne.error("Error in survey callback",a))}Wc(t,e){let s=this.bo;return s?s.sendRequest(t,e):new Promise(i=>i({statusCode:0,error:new Error(ii)}))}Vc(t,e){if(this.To)return{surveys:[],context:{isLoaded:!1,error:ii}};let s=e.statusCode;if(s!==200||!e.json){let n=`Surveys API could not be loaded, status: ${s}`;return s!==0?ne.error(n):e.error||ne.warn(n),this.Rc=Date.now(),{surveys:[],context:{isLoaded:!1,error:n}}}this.Rc=null;let i=e.json.surveys||[];return t.kv.set({[en]:i,[Jr]:Date.now()}),this.Bc(i),{surveys:i,context:{isLoaded:!0}}}Bc(t){var e;let s=t.filter(i=>(function(n){return!(!n.start_date||n.end_date)})(i)&&(Ev(i)||(function(n){var r;return!!(!((r=n.conditions)===null||r===void 0||(r=r.actions)===null||r===void 0||(r=r.values)===null||r===void 0)&&r.length)})(i)));(e=this._surveyEventReceiver)===null||e===void 0||e.replace(s)}Uc(){return this.Gc()&&!this.Pc&&!this.Qc()}Gc(){var t,e;let s=(t=(e=this.bo)!==null&&e!==void 0?e:this.Cc)===null||t===void 0?void 0:t.kv.get(Jr);return Te(s)&&Date.now()-s>3e5}Qc(){return Te(this.Rc)&&3e5>Date.now()-this.Rc}markSurveyAsSeen(t,e){var s;let i={id:t,current_iteration:(s=e?.iteration)!==null&&s!==void 0?s:null};kv(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Fc()}Hc(t){for(let e of this.Mc)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(s){ne.error("Error in survey callback",s)}}getActiveMatchingSurveys(t,e=!1){if(!B(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ne.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e,s;if(this.To)return()=>{};let i={callback:t,active:!0,revision:0};this.Ec.push(i),this.zc();let n=(e=(s=this.bo)!==null&&s!==void 0?s:this.Cc)===null||e===void 0?void 0:e.kv.get(en);return this.Mr.disableSurveys||!this._surveyManager&&this.Ic&&!this.Tc||!n&&!B(this.Rc)&&!this.Pc?this.Dc(i,{isLoaded:!1}):this._surveyManager&&this.Dc(i),()=>{var r;i.active=!1,this.Ec=this.Ec.filter(o=>o!==i),this.Ec.length===0&&((r=this.Nc)===null||r===void 0||r.call(this),this.Nc=void 0)}}zc(){var t,e,s;this._surveyManager&&this.Ec.length>0&&((t=this.Nc)!==null&&t!==void 0||(this.Nc=(e=(s=this.wo).onMatchingConditionsChanged)===null||e===void 0?void 0:e.call(s,this.Fc)))}Dc(t,e){if(this.To||!t.active)return;let s=++t.revision,i=n=>{if(!this.To&&t.active&&s===t.revision)try{let r=e??{isLoaded:!0},o=JSON.stringify([n,r]);if(o===t.lastResult)return;t.lastResult=o,t.callback(n,r)}catch(r){ne.error("Error in active matching surveys callback",r)}};try{e&&!e.isLoaded?i([]):this.getActiveMatchingSurveys(i)}catch(n){ne.error("Error in active matching surveys callback",n)}}Zc(t){let e=null;return this.getSurveys(s=>{var i;e=(i=s.find(n=>n.id===t))!==null&&i!==void 0?i:null}),e}Jc(t){if(B(this._surveyManager))return{eligible:!1,reason:ii};let e=typeof t=="string"?this.Zc(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}Kc(t){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(B(this._surveyManager))return{eligible:!1,reason:ii};let e=typeof t=="string"?this.Zc(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(B(this._surveyManager))return ne.warn("init was not called"),{visible:!1,disabledReason:ii};let e=this.Kc(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return B(this._surveyManager)?(ne.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ii})):new Promise(s=>{this.getSurveys(i=>{var n;let r=(n=i.find(o=>o.id===t))!==null&&n!==void 0?n:null;if(r){let o=this.Kc(r);s({visible:o.eligible,disabledReason:o.reason})}else s({visible:!1,disabledReason:"Survey not found"})},e)})}renderSurvey(t,e,s){var i;if(!this.wo.isCapturing())return;if(B(this._surveyManager))return void ne.warn("init was not called");let n=typeof t=="string"?this.Zc(t):t;if(!n?.id)return void ne.warn("Survey not found");if(!BA.includes(n.type))return void ne.warn(`Surveys of type ${n.type} cannot be rendered in the app`);let r=T?.querySelector(e);if(r){if(!((i=n.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds){ne.info(`Rendering survey ${n.id} with delay of ${n.appearance.surveyPopupDelaySeconds} seconds`);let o=setTimeout(()=>{var a,l;this.Ac.delete(o),!this.To&&this.wo.isCapturing()&&(ne.info(`Rendering survey ${n.id} with delay of ${(a=n.appearance)===null||a===void 0?void 0:a.surveyPopupDelaySeconds} seconds`),(l=this._surveyManager)===null||l===void 0||l.renderSurvey(n,r,s),ne.info(`Survey ${n.id} rendered`))},1e3*n.appearance.surveyPopupDelaySeconds);return void this.Ac.add(o)}this._surveyManager.renderSurvey(n,r,s)}else ne.warn("Survey element not found")}displaySurvey(t,e){var s;if(!this.wo.isCapturing())return;if(B(this._surveyManager))return void ne.warn("init was not called");let i=this.Zc(t);if(!i)return void ne.warn("Survey not found");let n=i;if(!((s=i.appearance)===null||s===void 0)&&s.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=_(_({},i),{},{appearance:_(_({},i.appearance),{},{surveyPopupDelaySeconds:0})})),e.displayType!==Hl.Popover&&e.initialResponses&&ne.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){let r=this.Jc(i);if(!r.eligible)return void ne.warn("Survey is not eligible to be displayed: ",r.reason)}e.displayType!==Hl.Inline?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}cancelPendingSurvey(t){B(this._surveyManager)?ne.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t,e;(t=this._surveyManager)===null||t===void 0||(e=t.handlePageUnload)===null||e===void 0||e.call(t)}};dT=class{constructor(t){this._instance=t,this.Xc=new Set,this.Yc=new Set,this.th=new no,this.eh=(e,s)=>this.ih(e,s)&&this.nh(e,s)&&this.sh(e,s)&&this.rh(e,s),this.ih=(e,s)=>!s?.event||e?.event===s?.event}init(){var t,e;S((t=this._instance)===null||t===void 0?void 0:t._addCaptureHook)||(this.oh=(e=this._instance)===null||e===void 0?void 0:e._addCaptureHook((s,i)=>{this.on(s,i)}))}dispose(){var t,e;(t=this.oh)===null||t===void 0||t.call(this),this.oh=void 0,(e=this._instance)===null||e===void 0||(e=e.autocapture)===null||e===void 0||e.setElementSelectors(new Set,this),this.th=new no}register(t){var e,s;if(!S((e=this._instance)===null||e===void 0?void 0:e._addCaptureHook)&&(t.forEach(i=>{var n;this.Xc.add(i),(n=i.steps)===null||n===void 0||n.forEach(r=>{this.Yc.add(r?.event||"")})}),(s=this._instance)===null||s===void 0?void 0:s.autocapture)){let i=new Set;this.Xc.forEach(n=>{var r;(r=n.steps)===null||r===void 0||r.forEach(o=>{o?.selector&&i.add(o.selector)})}),this._instance.autocapture.setElementSelectors(i,this)}}replace(t){this.Xc.clear(),this.Yc.clear(),this.register(t)}on(t,e){e!=null&&t.length!=0&&(this.Yc.has(t)||this.Yc.has(e.event))&&this.Xc.forEach(s=>{this.ah(e,s)&&this.th.emit("actionCaptured",s.name)})}uh(t){this.onAction("actionCaptured",e=>t(e))}ah(t,e){if(e?.steps==null)return!1;for(let s of e.steps)if(this.eh(t,s))return!0;return!1}onAction(t,e){return this.th.on(t,e)}nh(t,e){if(e?.url){var s;let i=t==null||(s=t.properties)===null||s===void 0?void 0:s.$current_url;if(!i||typeof i!="string"||!ni(i,e.url,e.url_matching||"contains"))return!1}return!0}sh(t,e){return!!this.hh(t,e)&&!!this.dh(t,e)&&!!this.fh(t,e)}hh(t,e){var s;if(!e?.href)return!0;let i=this.ph(t);if(i.length>0)return i.some(r=>ni(r.href,e.href,e.href_matching||"exact"));let n=(t==null||(s=t.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!n&&ni((function(r){let o=r.match(/(?::|")href="(.*?)"/);return o?o[1]:""})(n),e.href,e.href_matching||"exact")}dh(t,e){var s;if(!e?.text)return!0;let i=this.ph(t);if(i.length>0)return i.some(l=>ni(l.text,e.text,e.text_matching||"exact")||ni(l.$el_text,e.text,e.text_matching||"exact"));let n=(t==null||(s=t.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!n&&(r=(function(l){let c=[],u=/(?::|")text="(.*?)"/g,h;for(;!B(h=u.exec(l));)c.includes(h[1])||c.push(h[1]);return c})(n),o=e.text,a=e.text_matching||"exact",r.some(l=>ni(l,o,a)));var r,o,a}fh(t,e){var s,i;if(!e?.selector)return!0;let n=t==null||(s=t.properties)===null||s===void 0?void 0:s.$element_selectors;if(n?.includes(e.selector))return!0;let r=(t==null||(i=t.properties)===null||i===void 0?void 0:i.$elements_chain)||"";if(e.selector_regex&&r)try{return new RegExp(e.selector_regex).test(r)}catch{return!1}return!1}ph(t){var e;return(t==null||(e=t.properties)===null||e===void 0?void 0:e.$elements)==null?[]:t?.properties.$elements}rh(t,e){return!e?.properties||e.properties.length===0||Sv(e.properties.reduce((s,i)=>{let n=N(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return s[i.key]={values:n,operator:i.operator||"exact"},s},{}),t?.properties)}},hT=class{constructor(t,e){var s,i;this.gh=[],this._instance=t,this.mh=e,this.yh=new Map,this.bh=new Map,this._h=new Map,this.wh=(s=this._instance)===null||s===void 0||(i=s.onSessionId)===null||i===void 0?void 0:i.call(s,n=>this.kh(n))}Sh(t){return!1}xh(){return null}$h(t){}Ch(){}Th(t,e){return!!t&&Sv(t.propertyFilters,e?.properties)}Ih(t,e){let s=new Map;return t.forEach(i=>{var n;(n=i.conditions)===null||n===void 0||(n=n[e])===null||n===void 0||(n=n.values)===null||n===void 0||n.forEach(r=>{if(r?.name){let o=s.get(r.name)||[];o.push(i.id),s.set(r.name,o)}})}),s}Mh(t,e,s){let i=(s===Yi.Activation?this.yh:this.bh).get(t),n=[];return this.Eh(r=>{n=r.filter(o=>i?.includes(o.id))}),n.filter(r=>{var o;let a=(o=r.conditions)===null||o===void 0||(o=o[s])===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.find(l=>l.name===t);return this.Th(a,e)})}register(t){this.Ph(t,!1)}replace(t){this.Ph(t,!0)}Ph(t,e){var s;S((s=this._instance)===null||s===void 0?void 0:s._addCaptureHook)||(this.Rh(t,e),this.Ah(t,e))}Ah(t,e){let s=t.filter(r=>{var o;return(o=r.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.length});var i;if(e&&this._h.clear(),s.length===0)return void(e&&((i=this.Fh)===null||i===void 0||i.replace([])));this.Fh||(this.Fh=new dT(this._instance),this.Fh.init(),this.Fh.uh(r=>this.onAction(r)));let n=[];s.forEach(r=>{var o;(o=r.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||o.values.forEach(a=>{if(n.push(a),a.name){var l;let c=(l=this._h.get(a.name))!==null&&l!==void 0?l:[];c.includes(r.id)||c.push(r.id),this._h.set(a.name,c)}})}),e?this.Fh.replace(n):this.Fh.register(n)}Oh(t,e){e.forEach((s,i)=>{var n;let r=(n=t.get(i))!==null&&n!==void 0?n:[];s.forEach(o=>{r.includes(o)||r.push(o)}),t.set(i,r)})}Rh(t,e){var s,i;let n=t.filter(l=>{var c,u;return((c=l.conditions)===null||c===void 0?void 0:c.events)&&((u=l.conditions)===null||u===void 0||(u=u.events)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),r=t.filter(l=>{var c,u;return((c=l.conditions)===null||c===void 0?void 0:c.cancelEvents)&&((u=l.conditions)===null||u===void 0||(u=u.cancelEvents)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),o=this.Ih(t,Yi.Activation),a=this.Ih(t,Yi.Cancellation);e?(this.yh=o,this.bh=a):(this.Oh(this.yh,o),this.Oh(this.bh,a)),(n.length!==0||r.length!==0||t.some(l=>{var c;return(c=l.conditions)===null||c===void 0||(c=c.actions)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length}))&&((s=this.oh)!==null&&s!==void 0||(this.oh=(i=this._instance)===null||i===void 0?void 0:i._addCaptureHook((l,c)=>{this.onEvent(l,c)})))}onEvent(t,e){var s,i;let n=this.Dh(),r=(e==null||(s=e.properties)===null||s===void 0?void 0:s.$survey_id)||(e==null||(i=e.properties)===null||i===void 0?void 0:i.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){let a=this.Lh(t,r,e);if(a==="consume")return n.info("event consumed activated item, removing it",{event:t,itemId:r}),void this.Nh([r]);if(a==="persist")return n.info("shown item promoted to persisted activation",{event:t,itemId:r}),this.qh(r),void this.jh([r])}if(this.bh.has(t)){let a=this.Mh(t,e,Yi.Cancellation);a.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map(l=>l.id)}),this.Nh(a.map(l=>l.id)),a.forEach(l=>this.Bh(l.id)))}if(!this.yh.has(t))return;n.info("event name matched",{event:t,eventPayload:e,items:this.yh.get(t)});let o=this.Mh(t,e,Yi.Activation);this.zh(o.map(a=>a.id))}onAction(t){this._h.has(t)&&this.zh(this._h.get(t)||[])}zh(t){var e,s;if(t.length===0)return;let i=!!(!((e=this._instance)===null||e===void 0||(s=e.get_session_id)===null||s===void 0)&&s.call(e)),n=[];for(let r of t)i&&this.Sh(r)?this.qh(r)&&this.Hh(r):n.push(r);n.length>0&&(this.gh=[...new Set([...this.gh,...n])]),this.Dh().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Uh()}qh(t){this.gh=this.gh.filter(s=>s!==t);let e=this.Wh();return!e.includes(t)&&(this.Vh([...e,t]),this.Gh(),!0)}Nh(t){let e=new Set(t);this.gh=this.gh.filter(n=>!e.has(n));let s=this.Qh(),i=s.filter(n=>!e.has(n));i.length!==s.length&&(this.Vh(i),i.length===0&&this.Zh()),this.jh(t),this.Uh()}Uh(){try{var t;(t=this.mh)===null||t===void 0||t.call(this)}catch(e){this.Dh().error("Error while handling activated items change",e)}}Jh(){var t;let e=this.xh();if(!e)return{};let s=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[e];return s&&typeof s=="object"?s:{}}Hh(t){if(!this.xh())return;let e=this.Jh();this.$h(_(_({},e),{},{[t]:Date.now()}))}jh(t){if(!this.xh())return;let e=this.Jh(),s={},i=!1;for(let[n,r]of Object.entries(e))t.includes(n)?i=!0:s[n]=r;i&&(nt(s)?this.Ch():this.$h(s))}Kh(){this.xh()&&this.Ch()}getActivationTimestamp(t){if(!this.Wh().includes(t))return;let e=this.Jh()[t];return Te(e)?e:void 0}Qh(){var t;let e=this.Xh();return((t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[e])||[]}Wh(){var t,e,s;let i=this.Qh();if(i.length===0)return[];let n=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[this.Yh()],r=(e=this._instance)===null||e===void 0||(s=e.get_session_id)===null||s===void 0?void 0:s.call(e);return r&&n===r?i:[]}Gh(){var t,e;let s=(t=this._instance)===null||t===void 0||(e=t.get_session_id)===null||e===void 0?void 0:e.call(t);s&&this.td(s)}Zh(){this.ed()}kh(t){var e;let s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[this.Yh()];if(s&&s!==t){let i=this.Qh(),n=this.Jh();i.length>0&&(this.Vh([]),i.filter(r=>Te(n[r])).forEach(r=>this.Bh(r))),this.Zh(),this.Kh(),i.length>0&&this.Uh()}}getActivatedIds(){return[...new Set([...this.Wh(),...this.gh])].filter(t=>!this.nd(t))}dispose(){var t,e,s;(t=this.wh)===null||t===void 0||t.call(this),this.wh=void 0,(e=this.oh)===null||e===void 0||e.call(this),this.oh=void 0,(s=this.Fh)===null||s===void 0||s.dispose(),this.Fh=void 0}reset(){this.gh=[],this.Qh().length>0&&this.Vh([]),this.Zh(),this.Kh(),this.Uh()}getEventToItemsMap(){return this.yh}sd(){return this.Fh}},fT=class extends hT{constructor(t,e){super(t,e)}Xh(){return pp}Yh(){return vp}xh(){return _p}$h(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated_timestamps:t})}Ch(){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.unregister("$surveys_activated_timestamps")}Sh(t){var e;let s;this.Eh(n=>{s=n.find(r=>r.id===t)});let i=s==null||(e=s.appearance)===null||e===void 0?void 0:e.surveyPopupDelaySeconds;return Te(i)&&i>0}rd(){return ct.SHOWN}Eh(t){var e;(e=this._instance)===null||e===void 0||e.getSurveys(t)}Bh(t){var e;(e=this._instance)===null||e===void 0||e.cancelPendingSurvey(t)}Dh(){return ne}Vh(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated:t})}td(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated_session:t})}ed(){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.unregister("$surveys_activated_session")}nd(){return!1}Lh(t,e,s){var i;if(t===ct.SENT&&(s==null||(i=s.properties)===null||i===void 0?void 0:i.$survey_completed)===!1)return"ignore";let n;return this.Eh(r=>{n=r.find(o=>o.id===e)}),!n||(function(r){var o;return Ev(r)&&!!(!((o=r.conditions)===null||o===void 0||(o=o.events)===null||o===void 0)&&o.repeatedActivation)||r.schedule==="always"})(n)?t===ct.SHOWN?"consume":"ignore":t===ct.SHOWN?"persist":t===ct.DISMISSED||t===ct.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},gT=class{constructor(t){this._instance=t}initialize(){}get(t){if(typeof t=="string")return this._instance.get_property(t);let e={};for(let s of t){let i=this._instance.get_property(s);S(i)||(e[s]=i)}return e}set(t,e){this._instance.register(typeof t=="string"?{[t]:e}:t)}remove(t){typeof t!="string"?t.forEach(e=>this._instance.unregister(e)):this._instance.unregister(t)}},pT=class{constructor(t){this._instance=t}get(){let t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){let t=L?.__PosthogExtensions__;if(!t)return;let{generateSurveys:e,loadExternalDependency:s}=t;return{generateSurveys:e?i=>e(this._instance,i):void 0,loadExternalDependency:s?i=>s(this._instance,"surveys",i):void 0}}createEventReceiver(t){return new fT(this._instance,t)}onMatchingConditionsChanged(t){let e=this._instance._addCaptureHook(r=>{r!=="$pageview"&&r!==ct.SHOWN&&r!==ct.DISMISSED&&r!==ct.SENT||t()}),s=()=>t();se(E,"PHSurveyShown",s);let i=!1,n=this._instance.onFeatureFlags(()=>{i&&t()});return i=!0,()=>{i=!1,e(),n(),E?.removeEventListener("PHSurveyShown",s)}}},vT=E?.location?eo(E.location.hash,"__posthog")||eo(location.hash,"state"):null,Gf="_postHogToolbarParams",Hf=ye("[Toolbar]"),zf=ye("[FeatureFlags]"),Cs=ye("[FeatureFlags]",{debugEnabled:!0}),_l=`" failed. Feature flags didn't load in time.`,_T=[502,504],qf=["click","keydown","wheel","touchstart","pointerdown"],Wf="connection_error",Kf=t=>{let e={};for(let s=0;t.length>s;s++)e[t[s]]=!0;return e},Yf=t=>{let e={};for(let[s,i]of Fr(t||{}))i&&(e[s]=i);return e},mT=class{constructor(t){this.name="featureFlags",this.od=!1,this.featureFlagEventHandlers=[],this.A=zf,this.ad={},this.ld={},this.ud=[],this.hd=new Set,this.dd=new Set,this.vd=!1,this.fd=!1,this.pd=0,this.gd=!1,this.md=!1,this.yd=!1,this.bd=!1,this._d=0,this.wd=!1,this.rn=()=>{let e=this.kd();this._d=0,e&&this.reloadFeatureFlags()},this.Sd=()=>{var e,s;let i=this.xd,n=(e=this.$d)!==null&&e!==void 0?e:i;S(i)||S(n)||this.Mr.remoteRequestsDisabled||!this.Cd||this.Cd.visibilityState==="hidden"||Date.now()-((s=this.Td)!==null&&s!==void 0?s:0)<n||(this.$d=this.wd||!this.Mr.idleRefreshBackoff?i:Math.min(2*n,36e5),this.wd=!1,this.reloadFeatureFlags(),this.Id())},this.Md=()=>{this.wd&&this.$d===this.xd||this.Ed()},this.sn=()=>{var e;((e=this.Cd)===null||e===void 0?void 0:e.visibilityState)==="visible"&&this.Ed()},this.wo=t}get Pd(){}Rd(){this.bo&&this.Ad()}setup(t){try{this.Fd=typeof window>"u"?void 0:window,this.Cd=typeof document>"u"?void 0:document}catch{this.Fd=void 0,this.Cd=void 0}return this.Lc=t,this.A=t.logger.createLogger("[FeatureFlags]"),Ec(t.kv.initialize(),()=>{this.Lc===t&&(this.Lc=void 0,this.bo=t,this.Od(t))})}Od(t){var e;if(this.bo===t)return this.Fd&&se(this.Fd,"online",this.rn),this.Ad(),this.Dd=t.registerDynamicEventProperties(()=>this.Ld()?this.ad:this.ld),this.Nd=(e=this.Pd)===null||e===void 0?void 0:e.onCrossTabFeatureFlagChange(()=>{this.qd(),this.jd(),this.Bd()}),this.jd(),this.initialize()}Ed(){this.wd=!0,this.$d=this.xd,this.Sd()}Ad(){var t;let e=this.Mr.refreshIntervalMs,s=!this.Mr.remoteRequestsDisabled&&this.Cd&&!S(e)&&e>0?e:void 0;this.Mr.idleRefreshBackoff||(this.$d=s),s!==this.xd&&(this.zd(),S(s)||(this.xd=s,this.$d=s,this.Id(),!((t=this.Cd)===null||t===void 0)&&t.addEventListener&&(se(this.Cd,_n,this.sn),ai(qf,i=>{se(this.Cd,i,this.Md,{capture:!0})}))))}Id(){S(this.xd)||(S(this.Hd)||clearInterval(this.Hd),this.Td=Date.now(),this.Hd=setInterval(this.Sd,this.xd))}zd(){var t,e;S(this.Hd)||(clearInterval(this.Hd),this.Hd=void 0,(t=this.Cd)===null||t===void 0||(e=t.removeEventListener)===null||e===void 0||e.call(t,"visibilitychange",this.sn),ai(qf,s=>{var i,n;(i=this.Cd)===null||i===void 0||(n=i.removeEventListener)===null||n===void 0||n.call(i,s,this.Md,{capture:!0})})),this.xd=void 0,this.$d=void 0,this.wd=!1,this.Td=void 0}destroy(){this.Ud()}dispose(){this.Ud()}Ud(){var t,e,s;this.zd(),this.pd++,this.md=!1,this.Lc=void 0,this.Wd(this.hd,"cancelled"),this.Wd(this.dd,"cancelled"),this.bo&&(this.Vd(),(t=this.Dd)===null||t===void 0||t.dispose(),this.Dd=void 0,(e=this.Nd)===null||e===void 0||e.call(this),this.Nd=void 0,this.ud=[],(s=this.Fd)===null||s===void 0||s.removeEventListener("online",this.rn),this.bo=void 0)}get Mr(){return this.wo.get()}Gd(t){var e;return this.Qd&&t in this.Qd?this.Qd[t]:(e=this.bo)===null||e===void 0?void 0:e.kv.get(t)}qd(){return!!this.Qd&&(this.Qd=void 0,!0)}Zd(){var t;return!S((t=this.bo)===null||t===void 0?void 0:t.kv.get("$enabled_feature_flags"))&&this.qd()}$t(t){this.Jd(()=>{var e;return(e=this.bo)===null||e===void 0?void 0:e.kv.set(t)})}Kd(t,e,s){if(!this.Pd||!t.$enabled_feature_flags)return;let i=this.Gd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},r=e.flags||e.featureFlags,o=e.flags?Object.entries(e.flags).filter(([,v])=>!v?.failed).map(([v])=>v):[],a=!!e.errorsWhileComputingFlags&&!!e.flags,l=a?o:s&&!N(r)?Object.keys(r||{}):Array.from(new Set([...Object.keys(i),...Object.keys(n)])),c=this.Gd("$feature_flag_payloads")||{},u=t.$feature_flag_payloads||{},h=a||s?l:Array.from(new Set([...Object.keys(c),...Object.keys(u)])),d=!a&&!s,g=!!d||l,p=!!d||h,m={[zt]:g,[yt]:g,[cs]:p};t.$feature_flag_details&&(m[Ds]=g);for(let v of[Ns,us,rn])S(t[v])||(m[v]=!0);this.Pd.markCrossTabFeatureFlagChanges(m)}Pt(t){this.Jd(()=>{var e;return(e=this.bo)===null||e===void 0?void 0:e.kv.remove(t)})}Jd(t){try{t()}catch(e){this.A.error("Failed to update feature flag persistence",e)}}jd(){let t={};for(let i of[zt,cs,Ns,Tt]){let n=this.Gd(i);S(n)||(t[i]=n)}this.ad=t;let e=_({},t),s=this.Gd(yt);if(s)for(let[i,n]of Object.entries(s))e[`$feature/${i}`]=n;this.ld=e}Ld(){let t=this.Mr.cacheTtlMs;if(!t||0>=t)return!1;let e=this.Gd(us);return typeof e!="number"||Date.now()-e>t}Xd(){return!!this.Ld()&&(this.bd||this.fd||(this.bd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Yd(){let t=this.Mr.evaluationContexts;return t?.length?t.filter(e=>{let s=e&&typeof e=="string"&&e.trim().length>0;return s||this.A.error("Invalid evaluation context found:",e,"Expected non-empty string"),s}):[]}tv(){let t=this.Mr.flagKeys;if(!S(t))return t.filter(e=>{let s=e&&typeof e=="string"&&e.trim().length>0;return s||this.A.error("Invalid flag key found:",e,"Expected non-empty string"),s})}initialize(){var t,e;let s=this.Mr,i=(t=(e=s.bootstrap)===null||e===void 0?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(i).length){var n,r;let o=(n=(r=s.bootstrap)===null||r===void 0?void 0:r.featureFlagPayloads)!==null&&n!==void 0?n:{},a=Object.keys(i).filter(c=>!S(i[c])).reduce((c,u)=>(c[u]=i[u],c),{}),l=Object.keys(o).filter(c=>a[c]).reduce((c,u)=>(c[u]=o[u],c),{});return this.ev({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,e,s){var i,n;let r=s?.merge&&(i=this.Gd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},o=s?.merge&&(n=this.Gd("$feature_flag_payloads"))!==null&&n!==void 0?n:{},a=_(_({},r),t),l=_(_({},o),e),c={};for(let[u,h]of Object.entries(a))c[u]={key:u,enabled:Uh(h),variant:Bh(h),reason:void 0,metadata:S(l?.[u])?void 0:{id:0,version:void 0,description:void 0,payload:l[u]}};this.ev({flags:c})}get hasLoadedFlags(){return this.vd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){let t=this.Gd(Ds),e=this.Gd(Tt),s=this.Gd($s);if(!s&&!e)return t||{};let i=ve({},t||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(e||{})])];for(let a of n){var r,o;let l=i[a],c=e?.[a],u=S(c)?(r=l?.enabled)!==null&&r!==void 0&&r:!!c,h=S(c)?l?.variant:typeof c=="string"?c:void 0,d=s?.[a],g=_(_({},l),{},{enabled:u,variant:u?h??l?.variant:void 0});u!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),d&&(g.metadata=_(_({},l?.metadata),{},{payload:d,original_payload:l==null||(o=l.metadata)===null||o===void 0?void 0:o.payload})),i[a]=g}return this.od||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:s,finalDetails:i}),this.od=!0),i}getAllFeatureFlags(){let t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(s=>{let i=t[s];return{key:s,enabled:Uh(i),variant:Bh(i),payload:Lh(e[s])}})}getFlagVariants(){let t=this.Gd(yt),e=this.Gd(Tt);if(!e)return t||{};let s=ve({},t||{}),i=Object.keys(e);for(let n=0;i.length>n;n++)s[i[n]]=e[i[n]];return this.od||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:s}),this.od=!0),s}getFlagPayloads(){let t=this.Gd(cs),e=this.Gd($s);if(!e)return t||{};let s=ve({},t||{}),i=Object.keys(e);for(let n=0;i.length>n;n++)s[i[n]]=e[i[n]];return this.od||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:s}),this.od=!0),s}reloadFeatureFlags(){this.gd||this.Mr.featureFlagsDisabled||this.kd()||(this.fd&&(this.md=!0),this.iv||(this.ud.slice().forEach(t=>{try{t()}catch(e){this.A.error("Error while running feature flags reloading callback",e)}}),this.iv=setTimeout(()=>{this.nv()},5)))}reloadFeatureFlagsAsync(){return!this.bo||this.gd||this.Mr.featureFlagsDisabled||this.Mr.remoteRequestsDisabled||this.kd()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.hd.add(t),this.reloadFeatureFlags()})}Wd(t,e){t.forEach(s=>s({status:e})),t.clear()}Vd(){clearTimeout(this.iv),this.iv=void 0}onReloading(t){return this.ud.push(t),()=>{this.ud=this.ud.filter(e=>e!==t)}}ensureFlagsLoaded(){this.vd||this.fd||this.iv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.gd=t}resetFlagCallReported(){this.Pt(ls)}nv(t){var e;this.Vd();let s=this.bo;if(!s||this.Mr.remoteRequestsDisabled||this.kd())return void this.Wd(this.hd,"skipped");if(this.fd)return void(this.md=!0);let i={token:s.projectToken,distinct_id:s.distinctId,groups:s.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:_(_(_({},s.initialPersonProperties),this.Gd("$stored_person_properties")||{}),{},{$lib:s.library.name,$lib_version:s.library.version}),group_properties:this.Gd(os),timezone:zp()};S(s.deviceId)||(i.$device_id=s.deviceId),(t?.disableFlags||this.Mr.featureFlagsDisabled)&&(i.disable_flags=!0);let n=this.Yd();n.length&&(i.evaluation_contexts=n);let r=this.tv();S(r)||(i.flag_keys=r);let o=this.Mr.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this.pd,c=this.hd;this.hd=new Set,this.dd=c,this.fd=!0;let u=()=>{this.md&&(this.md=!1,this.nv())},h=v=>{var b,y;let w=(b=v.json)!==null&&b!==void 0?b:{},A=v.statusCode!==200;if(this.fd=!1,l!==this.pd)return void u();if(this.sv(v.statusCode),A||this.md||(this.$anon_distinct_id=void 0),i.disable_flags&&!this.md)return void this.Wd(c,"skipped");this.yd=!A;let I=[];v.error?I.push(v.error instanceof Error&&v.error.name==="AbortError"?"timeout":v.error instanceof Error?Wf:"unknown_error"):v.statusCode!==200&&I.push(`api_error_${v.statusCode}`),w.errorsWhileComputingFlags&&I.push("errors_while_computing_flags");let k=!!(!((y=w.quotaLimited)===null||y===void 0)&&y.includes("feature_flags"));k&&I.push("quota_limited"),this.$t({[vn]:I}),k?this.A.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."):i.disable_flags||this.ev(w,A,{partialResponse:o}),this.Wd(c,i.disable_flags?"skipped":I.length||!w.flags&&!w.featureFlags?"error":"loaded"),u()},d=v=>{this.fd=!1,l===this.pd&&(this.$t({[vn]:[Wf]}),this.A.error("Feature flag request failed",v),this.Zd()&&this.Bd(!0),this.Wd(c,"error")),u()},g=(e=this.Mr.requestMaxRetries)!==null&&e!==void 0?e:1,p=()=>g>0&&l===this.pd,m=()=>{if(l!==this.pd||!this.bo||this.Mr.remoteRequestsDisabled)return this.fd=!1,this.Wd(c,"skipped"),void u();try{s.sendRequest(a,{target:"flags",method:"POST",body:i,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(v=>{if((b=>_T.includes(b.statusCode)||(y=>y.statusCode===0&&y.error instanceof Error&&y.error.name==="AbortError")(b))(v)&&p())return g--,void setTimeout(m,500);h(v)}).catch(d)}catch(v){d(v)}};m()}kd(){return Wp(this._d,3)}sv(t){this._d=Kp(t,this._d,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,e={}){var s;if(e.fresh&&!this.yd)return;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+t+_l);if(this.Xd())return;let i=this.getFeatureFlagResult(t,e);return(s=i?.variant)!==null&&s!==void 0?s:i?.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){let e=this.getFeatureFlagResult(t,{send_event:!1});return e?.payload}getFeatureFlagResult(t,e={}){if(e.fresh&&!this.yd)return;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+t+_l);if(this.Xd())return;let s=this.getFlagVariants(),i=t in s,n=s[t],r=this.getFlagPayloads()[t],o=String(n),a=this.Gd("$feature_flag_request_id")||void 0,l=this.Gd("$feature_flag_evaluated_at")||void 0,c,u=this.Gd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var h;let x=(h=this.bo)===null||h===void 0||(h=h.session)===null||h===void 0?void 0:h.sessionId,Y=this.Gd(Zi);x&&x!==Y&&(u={},c=x)}if(!e.send_event&&"send_event"in e)c&&this.$t({[ls]:u,[Zi]:c});else if(t in u&&u[t].includes(o))c&&this.$t({[ls]:u,[Zi]:c});else{var d,g,p,m,v,b,y,w,A,I,k,$,O;N(u[t])?u[t].push(o):u[t]=[o],this.$t(_({[ls]:u},c?{[Zi]:c}:{}));let x=this.getFeatureFlagDetails(t),Y=[...(d=this.Gd("$feature_flag_errors"))!==null&&d!==void 0?d:[]];S(n)&&Y.push("flag_missing");let X={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:r??null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(g=(p=this.Mr.bootstrap)===null||p===void 0||(p=p.featureFlags)===null||p===void 0?void 0:p[t])!==null&&g!==void 0?g:null,$feature_flag_bootstrapped_payload:(m=(v=this.Mr.bootstrap)===null||v===void 0||(v=v.featureFlagPayloads)===null||v===void 0?void 0:v[t])!==null&&m!==void 0?m:null,$used_bootstrap_value:!this.yd};S(x==null||(b=x.metadata)===null||b===void 0?void 0:b.has_experiment)||(X.$feature_flag_has_experiment=x.metadata.has_experiment),S(x==null||(y=x.metadata)===null||y===void 0?void 0:y.version)||(X.$feature_flag_version=x.metadata.version);let Z=(w=x==null||(A=x.reason)===null||A===void 0?void 0:A.description)!==null&&w!==void 0?w:x==null||(I=x.reason)===null||I===void 0?void 0:I.code;Z&&(X.$feature_flag_reason=Z),!(x==null||(k=x.metadata)===null||k===void 0)&&k.id&&(X.$feature_flag_id=x.metadata.id),S(x?.original_variant)&&S(x?.original_enabled)||(X.$feature_flag_original_response=S(x.original_variant)?x.original_enabled:x.original_variant),!(x==null||($=x.metadata)===null||$===void 0)&&$.original_payload&&(X.$feature_flag_original_payload=x==null||(O=x.metadata)===null||O===void 0?void 0:O.original_payload),Y.length&&(X.$feature_flag_error=Y.join(",")),this.rv(X)}return i?{key:t,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:Lh(r)}:void 0}rv(t){try{var e;(e=this.bo)===null||e===void 0||e.capture("$feature_flag_called",t)}catch(s){this.A.error("Failed to capture feature flag call",s)}}getRemoteConfigPayload(t,e){this.ov(t,e)}ov(t,e){var s=this;return he(function*(){let i=s.bo;if(!i)return;let n={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},r=s.Yd();r.length&&(n.evaluation_contexts=r);let o=s.tv(),a;S(o)||(n.flag_keys=o);try{var l;let c=(l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:s.Mr.compression,sentAt:"body",timeoutMs:s.Mr.requestTimeoutMs})).json)===null||l===void 0?void 0:l.featureFlagPayloads;a=c?.[t]||void 0}catch(c){return void s.A.error("Remote config feature flag request failed",c)}try{e(a)}catch(c){s.A.error("Remote config feature flag callback failed",c)}})()}isFeatureEnabled(t,e={}){if(e.fresh&&!this.yd)return e.defaultValue;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+_l),e.defaultValue;let s=this.getFeatureFlag(t,e);return S(s)?e.defaultValue:!!s}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(e=>e!==t)}receivedFeatureFlags(t,e,s){this.ev(t,e,s)}ev(t,e,s){if(!this.bo)return;this.vd=!0;let i=((n,r={},o={},a={},l,c=zf)=>{let u=((w,A)=>{let I=w.flags;if(I){let k=Object.fromEntries(Object.keys(I).map(O=>{var x;return[O,(x=I[O].variant)!==null&&x!==void 0?x:I[O].enabled]})),$=Object.fromEntries(Object.keys(I).filter(O=>I[O].enabled).filter(O=>{var x;return!S((x=I[O].metadata)===null||x===void 0?void 0:x.payload)}).map(O=>{var x;return[O,(x=I[O].metadata)===null||x===void 0?void 0:x.payload]}));return _(_({},w),{},{featureFlags:k,featureFlagPayloads:$})}return w.featureFlags&&A.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),w})(n,c),h=u.flags,d=u.featureFlags,g=u.featureFlagPayloads;if(!d)return;let p=n.requestId,m=n.evaluatedAt;if(N(d)){c.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");let w={};if(d)for(let A=0;d.length>A;A++)w[d[A]]=!0;return{[zt]:d,[yt]:w,[rn]:!1}}let v=d,b=g,y=h;if(l?.partialResponse){let w=Object.keys(v),A=b||{};v=_(_({},r),v),b=_(_({},o),A),w.forEach(I=>{I in A||b==null||delete b[I]}),y=_(_({},a),y)}else if(n.errorsWhileComputingFlags)if(h){let w=new Set(Object.keys(h).filter(I=>{var k;return!(!((k=h[I])===null||k===void 0)&&k.failed)}));v=_(_({},r),Object.fromEntries(Object.entries(v).filter(([I])=>w.has(I))));let A=Object.fromEntries(Object.entries(b||{}).filter(([I])=>w.has(I)));b=_(_({},o),A),w.forEach(I=>{I in A||b==null||delete b[I]}),y=_(_({},a),Object.fromEntries(Object.entries(y||{}).filter(([I])=>w.has(I))))}else v=_(_({},r),v),b=_(_({},o),b),y=_(_({},a),y);return _(_({[zt]:Object.keys(Yf(v)),[yt]:v||{},[cs]:b||{},[Ds]:y||{},[rn]:n.minimalFlagCalledEvents===!0},p?{[Ns]:p}:{}),m?{[us]:m}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),s,this.A);if(i)if(s?.persist===!1){let n=!S(this.bo.kv.get(yt));this.Qd=i,n||this.$t(i)}else this.qd(),this.Kd(i,t,!!s?.partialResponse),this.$t(i);else e&&this.Zd();e||(this.bd=!1),this.Bd(e)}override(t,e=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.av(t)}av(t){if(this.bo){if(t===!1)return this.Pt([Tt,$s]),this.Bd(),void Cs.info("All overrides cleared");if(N(t))return this.$t({[Tt]:Kf(t)}),this.Bd(),void Cs.info("Flag overrides set",{flags:t});if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var e;let s=t;this.od=!!((e=s.suppressWarning)!==null&&e!==void 0&&e);let i={},n=s.flags,r=s.payloads;return n&&(i[Tt]=N(n)?Kf(n):n),r&&(i[$s]=r),Object.keys(i).length&&this.$t(i),n===!1&&r===!1?this.Pt([Tt,$s]):n===!1?this.Pt(Tt):r===!1&&this.Pt($s),this.Bd(),n===!1?Cs.info("Flag overrides cleared"):n&&Cs.info("Flag overrides set",{flags:n}),void(r===!1?Cs.info("Payload overrides cleared"):r&&Cs.info("Payload overrides set",{payloads:r}))}if(t&&typeof t=="object")return this.$t({[Tt]:t}),this.Bd(),void Cs.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.vd){let{flags:e,flagVariants:s}=this.lv();try{t(e,s)}catch(i){this.A.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,s){var i;let n=(this.Gd("$early_access_features")||[]).find(c=>c.flagKey===t),r={[`$feature_enrollment/${t}`]:e},o={$feature_flag:t,$feature_enrollment:e,$set:r};n&&(o.$early_access_feature_name=n.name),s&&(o.$feature_enrollment_stage=s);let a=_(_({},this.getFlagVariants()),{},{[t]:e});(i=this.Pd)===null||i===void 0||i.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.$t({[zt]:Object.keys(Yf(a)),[yt]:a,[as]:_(_({},this.Gd("$stored_person_properties")||{}),r)}),this.Bd();try{var l;(l=this.bo)===null||l===void 0||l.capture("$feature_enrollment_update",o)}catch(c){this.A.error("Failed to capture early access feature enrollment",c)}}getEarlyAccessFeatures(t,e=!1,s){let i=this.Gd(Pl);!i||e?this.uv(t,s):t(i)}uv(t,e){var s=this;return he(function*(){let i=s.bo;if(!i)return;let n=e?`&${e.map(o=>`stage=${o}`).join("&")}`:"",r;try{let o=yield i.sendRequest(`/api/early_access_features/?token=${i.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;r=o.json.earlyAccessFeatures,s.$t({[Pl]:r})}catch(o){return void s.A.error("Early access feature request failed",o)}try{t(r)}catch(o){s.A.error("Early access feature callback failed",o)}})()}lv(){let t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter(s=>e[s]),flagVariants:Object.keys(e).filter(s=>e[s]).reduce((s,i)=>(s[i]=e[i],s),{})}}Bd(t){this.jd();let{flags:e,flagVariants:s}=this.lv();this.featureFlagEventHandlers.forEach(i=>{try{i(e,s,{errorsLoading:t})}catch(n){this.A.error("Error while running feature flags callback",n)}})}setPersonPropertiesForFlags(t,e=!0){this.hv(t,e)}hv(t,e=!0){let s=this.Gd("$stored_person_properties")||{},i=t?.$set||(t?.$set_once?{}:t),n=t?.$set_once,r={};if(n)for(let o in n)({}).hasOwnProperty.call(n,o)&&(o in s||(r[o]=n[o]));this.$t({[as]:_(_(_({},s),r),i)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e=!0){let s=_({},this.Gd("$stored_person_properties")||{});t.forEach(i=>{delete s[i]}),this.$t({[as]:s}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Pt(as),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e=!0){let s=this.Gd("$stored_group_properties")||{},i=_({},s);for(let n of Object.keys(t))i[n]=_(_({},s[n]),t[n]);this.$t({[os]:i}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){let e=this.Gd("$stored_group_properties")||{};this.$t({[os]:_(_({},e),{},{[t]:{}})})}else this.Pt(os)}reset(){this.pd++,this.Wd(this.hd,"cancelled"),this.Wd(this.dd,"cancelled"),this.md=!1,this.ad={},this.ld={},this.Qd=void 0,this.vd=!1,this.gd=!1,this.yd=!1,this.$anon_distinct_id=void 0,this.Vd(),this.od=!1,this._d=0}},Qf=ye("[FeatureFlags]"),yT=class{constructor(t,e=!1){this.dv=!1,this.update(t,e)}update(t,e){this.vv=((s,i)=>{var n,r,o,a,l,c,u,h;return{bootstrap:{featureFlags:(n=(r=s.bootstrap)===null||r===void 0?void 0:r.featureFlags)!==null&&n!==void 0?n:void 0,featureFlagPayloads:(o=(a=s.bootstrap)===null||a===void 0?void 0:a.featureFlagPayloads)!==null&&o!==void 0?o:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!s.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!s.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!s.advanced_feature_flags_dedup_per_session,cacheTtlMs:s.feature_flag_cache_ttl_ms,refreshIntervalMs:(l=s.remote_config_refresh_interval_ms)!==null&&l!==void 0?l:3e5,idleRefreshBackoff:S(s.remote_config_refresh_interval_ms),requestTimeoutMs:s.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,(c=s.feature_flag_request_max_retries)!==null&&c!==void 0?c:1),compression:s.disable_compression?void 0:"best-available",evaluationContexts:(u=(h=s.evaluation_contexts)!==null&&h!==void 0?h:s.evaluation_environments)!==null&&u!==void 0?u:[],flagKeys:N(s.flag_keys)?s.flag_keys:void 0}})(t,e),!t.evaluation_environments||t.evaluation_contexts||this.dv||(Qf.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.dv=!0),S(t.flag_keys)||N(t.flag_keys)||Qf.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.vv}},Jf=t=>bi(t)&&(t.name==="RangeError"&&t.message.indexOf("Maximum call stack size exceeded")===0||t.name==="InternalError"&&t.message==="too much recursion"),_t=ye("[Error tracking]"),Ql="webkit-masked-url:",bT=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],ET=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Ql],wT=["__firefox__","__gCrWeb"],Xf="Refusing to render web experiment since the viewer is a likely bot",ST={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>ro(e,t),not_regex:(t,e)=>!ro(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},gt=ye("[Conversations]"),Os="Conversations not available yet.";kT=["debug","log","warn","error","info"],AT=t=>{for(;t?.__rrweb_original__;)t=t.__rrweb_original__;return t},eg="console",Pv="__posthogHandledLogsRequestError",ml=(t,e)=>{let s=t instanceof Error?t:new Error(e);return s[Pv]=!0,s},tg=t=>!!t&&typeof t=="object"&&t[Pv]===!0,TT=class{get fv(){return _(_({},this.A),{},{error:(...t)=>{t.some(tg)||this.A.error(...t)}})}constructor(t,e){var s;this.wo=t,this.pv=e,this.name="logs",this.gv=!1,this.mv=!1,this.yv=!1,this.A=ye("[logs]"),this.ol=[],this.bv=[],this._d=0,this._v=!1,this.To=!1,this.wv=[],this.Sv=[],this.xv=!1,this.$v=!1,this.Cv=!1,this.Tv=()=>{var i,n;this.To||(this._d=0,(i=this.Iv)===null||i===void 0||i.onReconnect(),(n=this.Mv)===null||n===void 0||n.onReconnect())},this.gv=!!(!((s=t.get())===null||s===void 0)&&s.captureConsoleLogs)}get Ev(){return!0}Pv(){}Rv(){if(!this.Cv){try{this.Fd=typeof window>"u"?void 0:window}catch{this.Fd=void 0}this.Fd&&(se(this.Fd,"online",this.Tv),this.Cv=!0)}}Av(t,e,s,i){this.Rv();let n=Zf(this.wo.get(),s);return[new bk(this.Fv(t,e),n,this.fv,()=>this.pv(),r=>r(),void 0,i),n]}Ov(){let t=this.wo.get();var e;return this.Iv&&this.Dv===t||((e=this.Iv)===null||e===void 0||e.reset(),this.Dv=t,[this.Iv,this.Lv]=this.Av(()=>this.ol,s=>{this.ol=s})),this.Iv}Nv(){let t=this.wo.get();var e;return this.Mv&&this.qv===t||((e=this.Mv)===null||e===void 0||e.reset(),this.qv=t,[this.Mv,this.jv]=this.Av(()=>this.bv,s=>{this.bv=s},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},eg)),this.Mv}setup(t){if(!this.To&&!this._v)return this._v=!0,this.bo=t,this.A=t.logger.createLogger("[logs]"),Ec(t.kv.initialize(),()=>{this.To||this.Od(t)})}Od(t){var e;this.Rv(),!((e=this.wo.get())===null||e===void 0)&&e.captureConsoleLogs&&(this.gv=!0),(this.gv||this.wo.remoteConfigWillArrive&&t.kv.get(this.wo.captureHintKey))&&this.Bv();let s=!1,i=t.onRemoteConfig(n=>{var r;s=n.ok&&((r=n.config.logs)===null||r===void 0?void 0:r.captureConsoleLogs)===!0,this.onRemoteConfig(n)});this.To?i.dispose():(this.Eo=i,s||this.loadIfEnabled())}dispose(){var t,e,s,i,n,r,o;this.To||(this.To=!0,this.zv(),(t=this.Eo)===null||t===void 0||t.dispose(),this.Eo=void 0,this.bo=void 0,this.yv=!1,(e=this.Fd)===null||e===void 0||e.removeEventListener("online",this.Tv),(s=this.Hv)===null||s===void 0||s.call(this),this.Hv=void 0,(i=this.Iv)===null||i===void 0||i.clearQueue(),(n=this.Mv)===null||n===void 0||n.clearQueue(),(r=this.Iv)===null||r===void 0||r.reset(),(o=this.Mv)===null||o===void 0||o.reset())}onRemoteConfig(t){var e,s;if(this.To)return;let i=t.ok?(e=t.config.logs)===null||e===void 0?void 0:e.captureConsoleLogs:void 0;B(i)?this.Uv():((s=this.bo)===null||s===void 0||s.kv.set(this.wo.captureHintKey,!!i),i?(this.gv=!0,this.mv||this.Bv(),this.loadIfEnabled()):this.Uv())}reset(){var t,e,s,i;this.zv(),(t=this.Iv)===null||t===void 0||t.clearQueue(),this.ol=[],(e=this.Iv)===null||e===void 0||e.reset(),(s=this.Mv)===null||s===void 0||s.clearQueue(),this.bv=[],(i=this.Mv)===null||i===void 0||i.reset(),this._d=0}captureLog(t){!this.To&&this.bo&&this.Ov().captureLog(t)}captureConsoleLog(t){!this.To&&this.bo&&this.Nv().captureLog(t)}captureBufferedConsoleLog(t,e,s){!this.To&&this.bo&&this.Nv().captureLog(t,{context:e,occurredAtMs:s})}$c(){var t;this.zv(),(t=this.Mv)===null||t===void 0||t.clearQueue(),this.bv=[]}Uv(){this.gv||this.zv()}Bv(){var t;if(this.xv||!(!((t=this.Fd)===null||t===void 0)&&t.console))return;let e=Zf(this.wo.get()).maxBufferSize,s=!0;this.Sv.push(()=>{s=!1});for(let i of kT){let n;try{n=AT(this.Fd.console[i])}catch{continue}n&&this.Sv.push(yi(this.Fd.console,i,r=>{let o=(...a)=>{try{s&&this.Wv(i,a,e)}catch{}return r.apply(this.Fd.console,a)};return o.__rrweb_original__=n,o}))}this.xv=!0,this.Vv=setTimeout(()=>{this.zv()},3e4)}Wv(t,e,s){var i;if(this.xv&&!this.$v&&e.length!==0)if(!((i=this.bo)===null||i===void 0)&&i.canCapture){if(s>this.wv.length){this.$v=!0;try{this.wv.push({level:t,args:e,occurredAtMs:Date.now(),context:this.pv()})}finally{this.$v=!1}}}else this.zv()}zv(){if(this.wv=[],this.xv){this.xv=!1,this.Vv&&(clearTimeout(this.Vv),this.Vv=void 0);for(let t of this.Sv)t();this.Sv=[]}}Gv(){let t=this.wv;return this.zv(),t}get logger(){return this.Qv||(this.Qv={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Qv}flushLogs(t){this.bo&&(t?this.Zv(t):(this.Iv&&this.Iv.flush().catch(e=>this.Jv(e)),this.Mv&&this.Mv.flush().catch(e=>this.Jv(e))))}flush(){var t=this;return he(function*(){var e,s;let i=(e=t.Iv)===null||e===void 0?void 0:e.flush().catch(r=>t.Jv(r)),n=(s=t.Mv)===null||s===void 0?void 0:s.flush().catch(r=>t.Jv(r));yield i,yield n})()}Jv(t){tg(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.To||!this.gv||this.mv||this.yv)return;let t=this.Pv();if(t){this.yv=!0;try{t((e,s)=>{if(this.yv=!1,!this.To&&this.gv)if(e||!s)this.A.error("Could not load logs script",e),this.zv();else{let i=this.Gv();this.Hv=s.initialize(this.bo),this.mv=!0,i.length>0&&s.replay(this.bo,i)}})}catch(e){throw this.yv=!1,e}}else this.zv()}Fv(t,e){let s=this.bo;return{get isDisabled(){return!1},get optedOut(){return!s.canCapture},getPersistedProperty:i=>i===It.LogsQueue?t():void 0,setPersistedProperty(i,n){i===It.LogsQueue&&e(n??[])},js:i=>this.js(i),getLibraryId:()=>s.library.name,getLibraryVersion:()=>s.library.version}}js(t){return new Promise(e=>{if(Wp(this._d,3))return void e({kind:"fatal",error:ml(void 0,"logs endpoint is unreachable, dropping batch")});let s=!1,i=o=>{s||(s=!0,clearTimeout(n),e(o))},n=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:ml(void 0,"logs request timed out")})},9e4),r=this.Ev;this.bo.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.bo.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(o=>{var a;let l=o.statusCode;this.Kv(l,r),l>=200&&300>l?i({kind:"ok"}):l===413?i({kind:"too-large"}):l!==0&&l!==408&&l!==429&&500>l?i({kind:"fatal",error:new Error(`logs request failed with status ${l}`)}):l===0?(o.error||this.A.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:ml(o.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(a=o.error)!==null&&a!==void 0?a:new Error(`logs request failed with status ${l}`)})},o=>{i({kind:"retry-later",error:o})})})}Kv(t,e){(t!==0||e)&&(this._d=Kp(t,this._d,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Zv(t){this.ol.length>0&&this.Xv(t,this.ol,this.Lv,this.bo.library.name,e=>{this.ol=e}),this.bv.length>0&&this.Xv(t,this.bv,this.jv,eg,e=>{this.bv=e})}Xv(t,e,s,i,n){if(e.length===0)return;let r=e.map(a=>a.record);n([]);let o=np(r,ip(s,this.bo.library.name,this.bo.library.version),i,this.bo.library.version);this.bo.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.bo.projectToken},body:o,compression:"best-available",transport:t,timeoutMs:6e4}).catch(a=>this.Jv(a))}},oo=ye("[NetworkMetrics]"),wc=()=>{var t;return!(E==null||(t=E.performance)===null||t===void 0)&&t.now?E.performance.now():Date.now()},IT={"http:":80,"https:":443},RT=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),$v=(t,e)=>{var s;let i=String(e);return{method:String(t).toUpperCase(),url:((s=Kt(i))===null||s===void 0?void 0:s.href)||i}},Jl=(t,e,s,i,n,r,o=!1)=>{try{var a,l;let c=n();if(!c)return;let u=s||void 0,h=wc()-i,d=Kt(e.url);if(d&&d.protocol!=="http:"&&d.protocol!=="https:")return;let g={url:d?.href||e.url,method:e.method},p=Ce(c.name)?c.name(g):H(c.name)?c.name:"http.client.request.duration";if(!p)return;let m=o&&!u?void 0:((b,y)=>b?400>b?void 0:String(b):y?.name||"_OTHER")(u,r),v=_(_(_(_(_({},(b=>{let y=RT.has(b)?b:"_OTHER";return _({"http.request.method":y},y==="_OTHER"&&b!==y?{"http.request.method_original":b}:{})})(g.method)),d?(b=>{return{"server.address":b.hostname.startsWith("[")&&b.hostname.endsWith("]")?b.hostname.slice(1,-1):b.hostname,"server.port":Number(b.port)||IT[b.protocol],"url.scheme":b.protocol.slice(0,-1),"url.template":(y=b.pathname,y.split("/").map(w=>(A=>/^\d+$/.test(A)||A.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(A))(w)?":id":w).join("/"))};var y})(d):{}),u?{"http.response.status_code":u}:{}),m?{"error.type":m}:{}),(a=c.attributes)===null||a===void 0?void 0:a.call(c,g,{status:u,durationMs:h}));(l=t.metrics)===null||l===void 0||l.histogram(p,h,{unit:"ms",attributes:v})}catch(c){oo.error("Failed to record network metric",c)}},xv=()=>{},CT=(t,e)=>Ce(E?.fetch)?yi(E,"fetch",s=>function(...i){let n=wc(),r=s.apply(this,i);if(!e())return r;try{var o,a,l;let[c,u]=i,h=$v((o=(a=u?.method)!==null&&a!==void 0?a:c?.method)!==null&&o!==void 0?o:"GET",(l=c?.url)!==null&&l!==void 0?l:c);return r.then(d=>(Jl(t,h,d?.status,n,e,void 0,!0),d),d=>{throw Jl(t,h,void 0,n,e,d),d})}catch(c){return oo.error("Failed to observe fetch",c),r}}):xv,OT=(t,e)=>{var s;let i=E==null||(s=E.XMLHttpRequest)===null||s===void 0?void 0:s.prototype;if(!i)return xv;let n=new WeakMap,r=yi(i,"open",a=>function(...l){try{lv.has(this)||n.set(this,$v(l[0],l[1]))}catch(c){oo.error("Failed to observe XHR open",c)}return a.apply(this,l)}),o=yi(i,"send",a=>function(...l){let c;try{let u=n.get(this);if(u&&e()){let h=wc();c=()=>{this.removeEventListener("loadend",c),Jl(t,u,this.status,h,e)},se(this,"loadend",c)}}catch(u){oo.error("Failed to observe XHR send",u)}try{return a.apply(this,l)}catch(u){throw c&&this.removeEventListener("loadend",c),u}});return()=>{r(),o()}},sg=new WeakMap,PT=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),$T={maxStringLength:2048,truncationSuffix:"..."};uo={featureFlags:class extends mT{constructor(t){let e=new yT(t.config,t.il());super(e),this.name=Tv,this._instance=t,this.Yv=e}get Pd(){return this._instance.persistence}updateConfig(t,e){this.Yv.update(t,e),this.Rd()}}},xT={sessionRecording:class{get Mr(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var t;return!!(!((t=this.tf)===null||t===void 0)&&t.isStarted)}get status(){var t,e;return this.ef==="awaiting_config"||this.ef==="missing_config"?this.ef:(t=(e=this.tf)===null||e===void 0?void 0:e.status)!==null&&t!==void 0?t:this.ef}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.ef=gl,this.if=void 0,this.nf=!1,this.Je=(()=>{var e,s;if(!T?.visibilityState||T.visibilityState==="visible")return!0;let i=E==null||(e=E.performance)===null||e===void 0||(s=e.getEntriesByType)===null||s===void 0?void 0:s.call(e,"visibility-state");return!i?.length||i.some(n=>n.name==="visible")})(),this.sn=()=>{var e,s;T?.visibilityState==="visible"&&(this.Je=!0,(e=this.tf)===null||e===void 0||(s=e.setDocumentWasEverVisible)===null||s===void 0||s.call(e,!0))},!this._instance.sessionManager)throw jt.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Mr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');T?.addEventListener&&se(T,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var e;this.nf=!0,T==null||(e=T.removeEventListener)===null||e===void 0||e.call(T,"visibilitychange",this.sn),t?this.sf(!0):this.stopRecording()}get rf(){var t;let e=!!(!((t=this._instance.get_property("$session_recording_remote_config"))===null||t===void 0)&&t.enabled),s=!this.Mr.disable_session_recording,i=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return E&&e&&s&&!i}startIfEnabledOrStop(t){var e;if(this.nf||this.rf&&(!((e=this.tf)===null||e===void 0)&&e.isStarted))return;let s=!S(Object.assign)&&!S(Array.from);this.rf&&s?(this.af(t),jt.info("starting")):(this.ef=gl,this.stopRecording())}af(t){var e,s;if(this.rf)if(this.ef!=="awaiting_config"&&this.ef!=="missing_config"&&(this.ef=Bf),(L==null||(e=L.__PosthogExtensions__)===null||e===void 0||(e=e.rrweb)===null||e===void 0?void 0:e.record)&&((s=L.__PosthogExtensions__)===null||s===void 0?void 0:s.initSessionRecording))this.lf(t);else{var i,n;let r=this._instance.sessionManager;(i=L.__PosthogExtensions__)===null||i===void 0||(n=i.loadExternalDependency)===null||n===void 0||n.call(i,this._instance,this.uf,o=>{if(!this.nf&&this.rf&&this._instance.sessionManager===r)return o?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),jt.error("could not load recorder",o)):void this.lf(t);this.ef="disabled"})}}stopRecording(){var t,e;(t=this.if)===null||t===void 0||t.call(this),this.if=void 0,(e=this.tf)===null||e===void 0||e.stop()}sf(t=!1){var e,s;(e=this.if)===null||e===void 0||e.call(this),this.if=void 0,(s=this.tf)===null||s===void 0||s.discard({discardProducerEvents:t})}cf(){var t,e;(t=this.Il)===null||t===void 0||t.unregister("$session_is_sampled"),(e=this.Il)===null||e===void 0||e.unregister("$replay_sample_rate")}hf(t,e){if(B(t))return null;let s=Te(t)?t:parseFloat(t);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(jt.warn(`${e} must be between 0 and 1. Ignoring invalid value:`,t),null):s;var i}df(t){if(this.Il){var e,s;let i=this.Il,n=()=>{var r;let o=t.sessionRecording===!1?void 0:t.sessionRecording,a=this.hf((r=this.Mr.session_recording)===null||r===void 0?void 0:r.sampleRate,"session_recording.sampleRate"),l=this.hf(o?.sampleRate,"remote config sampleRate"),c=a??l;B(c)&&this.cf();let u=o?.minimumDurationMilliseconds;i.register({[an]:_(_({cache_timestamp:Date.now(),enabled:!!o},o),{},{networkPayloadCapture:_({capturePerformance:t.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:S(u)?null:u,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};n(),(e=this.if)===null||e===void 0||e.call(this),this.if=(s=this._instance.sessionManager)===null||s===void 0?void 0:s.onSessionId(n)}}onRemoteConfig(t){let e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.df(e),void this.sf()):(this.df(e),void this.startIfEnabledOrStop()):(this.ef==="awaiting_config"&&(this.ef="missing_config",this._instance.register_for_session({[uc]:!0}),jt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e="log"){var s;!((s=this.tf)===null||s===void 0)&&s.log?this.tf.log(t,e):jt.warn("log called before recorder was ready")}get uf(){var t,e;let s=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.get_property(an);return(s==null||(e=s.scriptConfig)===null||e===void 0?void 0:e.script)||"lazy-recorder"}vf(){let t=this._instance.get_property(an);if(!t)return!1;let e;try{e=typeof t=="object"?t:JSON.parse(t)}catch(s){return jt.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}return!B(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}lf(t){var e,s,i;if(!this.nf&&this.rf&&this._instance.sessionManager){if(!(!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.initSessionRecording))return jt.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[cc]:!0});var n;if(this.tf||(this.tf=(n=L.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording(this._instance,this.Je),this.tf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.vf())return this.ef==="missing_config"||this.ef==="awaiting_config"?void 0:(this.ef="awaiting_config",jt.info("persisted remote config is stale, requesting fresh config before starting"),void new iv(this._instance).load());this.ef=Bf,(s=(i=this.tf).setDocumentWasEverVisible)===null||s===void 0||s.call(i,this.Je),this.tf.start(t)}else this.ef=gl}onRRwebEmit(t){var e,s;(e=this.tf)===null||e===void 0||(s=e.onRRwebEmit)===null||s===void 0||s.call(e,t)}overrideLinkedFlag(){var t,e;this.tf||(e=this.Il)===null||e===void 0||e.register({$replay_override_linked_flag:!0}),(t=this.tf)===null||t===void 0||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.tf||(e=this.Il)===null||e===void 0||e.register({$replay_override_sampling:!0}),(t=this.tf)===null||t===void 0||t.overrideSampling()}overrideTrigger(t){var e,s;this.tf||(s=this.Il)===null||s===void 0||s.register({[t==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.tf)===null||e===void 0||e.overrideTrigger(t)}get sdkDebugProperties(){var t;let e={};for(let i of aT){var s;let n=(s=this._instance.sessionPersistence)===null||s===void 0?void 0:s.get_property(i);S(n)||(e[i]=n)}return _(_({},e),((t=this.tf)===null||t===void 0?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var s;return!!(!((s=this.tf)===null||s===void 0)&&s.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t,e;(t=this.tf)===null||t===void 0||(e=t.flushBeforeIdentityReset)===null||e===void 0||e.call(t)}}},DT={autocapture:class extends sT{constructor(t){super(new iT(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.ff=!1,this._instance=t,this.pf=this.gf()}initialize(){this.startIfEnabled()}get isEnabled(){let t=this.mf();return!!(t.path||t.search||this.yf(t))}startIfEnabled(){this.isEnabled&&(R.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.pf=this.gf(),this.startIfEnabled()}stop(){this.bf&&this.bf(),this.bf=void 0,this._f&&this._f(),this._f=void 0,R.info("History API monitoring stopped")}monitorHistoryChanges(){E&&E.history&&(this.wf("pushState"),this.wf("replaceState"),this.kf(),this.yf()&&this.Sf())}wf(t){var e;if(!E||!((e=E.history[t])===null||e===void 0)&&e.__posthog_wrapped__)return;let s=this;yi(E.history,t,i=>function(n,r,o){var a;s.xf(o)&&s.$f(),i.call(this,n,r,o),s.Cf(t,!s.ff&&(E==null||(a=E.event)===null||a===void 0?void 0:a.type)!=="popstate")})}gf(){let t=E?.location;if(t?.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}mf(){let t=this._instance.config.capture_pageview;return t==="history_change"?{path:!0}:G(t)?t:{}}yf(t=this.mf()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Tf(t){let e=this.mf(),s=this.pf;return!(!s||!(e.path&&t.pathname!==s.pathname||e.search&&t.search!==s.search||this.yf(e)&&t.hash!==s.hash))}Cf(t,e=!1){try{e||this.$f();let s=this.gf();if(!s)return;if(this.Tf(s)){let i=()=>this._instance.capture(hc,{navigation_type:t});e?(this.If=i,Promise.resolve().then(()=>this.$f())):i()}this.pf=s}catch(s){R.error(`Error capturing ${t} pageview`,s)}}xf(t){var e,s;return!(B(t)||!E)&&((e=Kt(String(t)))===null||e===void 0?void 0:e.href)!==((s=E.location)===null||s===void 0?void 0:s.href)}$f(){let t=this.If;if(t){this.If=void 0,this.ff=!0;try{t()}catch(e){R.error("Error capturing deferred pageview",e)}finally{this.ff=!1}this.pf=this.gf()}}kf(){if(this.bf)return;let t=()=>{this.Cf("popstate")};se(E,"popstate",t),this.bf=()=>{E&&E.removeEventListener("popstate",t)}}Sf(){if(this._f)return;let t=()=>{this.Cf("hashchange")};se(E,"hashchange",t),this._f=()=>{E&&E.removeEventListener("hashchange",t)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var e;this.Mf=!1,this.ko=!1,this.Ef=null,this.instance=t,this.Mf=!!(!((e=this.instance.persistence)===null||e===void 0)&&e.props[xl]),this.rageclicks=new Ov(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return G(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return B(this.Mr.capture_heatmaps)?B(this.Mr.enable_heatmaps)?this.Mf:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ko)return;lT.info("starting..."),this.Pf(),this.sn()}else{var t;clearInterval((t=this.Ef)!==null&&t!==void 0?t:void 0),this.Rf(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;let e=t.config;if(!("heatmaps"in e))return;let s=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[xl]:s}),this.Mf=s,this.startIfEnabled()}getAndClearBuffer(){let t=this.Rt;return this.Rt=void 0,t}Af(t){pl(t.originalEvent)&&this.Ir(t.originalEvent,"deadclick")}sn(){this.Ef&&clearInterval(this.Ef),this.Ef=T?.visibilityState==="visible"?setInterval(this.fl.bind(this),this.flushIntervalMilliseconds):null}Pf(){E&&T&&(this.Ff=this.fl.bind(this),se(E,Xr,this.Ff),this.Of=t=>this.Ir(t||E?.event),se(T,"click",this.Of,{capture:!0}),this.Df=t=>this.Lf(t||E?.event),se(T,"mousemove",this.Df,{capture:!0}),this.Nf=new pf(this.instance,lA,this.Af.bind(this)),this.Nf.startIfEnabledOrStop(),this.qf=this.sn.bind(this),se(T,_n,this.qf),this.ko=!0)}Rf(){var t;E&&T&&(this.Ff&&E.removeEventListener(Xr,this.Ff),this.Of&&T.removeEventListener("click",this.Of,{capture:!0}),this.Df&&T.removeEventListener("mousemove",this.Df,{capture:!0}),this.qf&&T.removeEventListener(_n,this.qf),clearTimeout(this.jf),(t=this.Nf)===null||t===void 0||t.stop(),this.ko=!1)}Bf(t,e){let s=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=(function(o,a,l){let c=o;for(;c&&Et(c)&&!Ue(c,"body");){if(c===l)return!1;let g;try{var u,h,d;g=(u=(h=(d=c.ownerDocument)===null||d===void 0?void 0:d.defaultView)!==null&&h!==void 0?h:E)===null||u===void 0?void 0:u.getComputedStyle(c).position}catch{return!1}if(M(a,g))return!0;c=Lp(c)}return!1})(cn(t),["fixed","sticky"],n);return{x:t.clientX+(r?0:i),y:t.clientY+(r?0:s),target_fixed:r,type:e}}Ir(t,e="click"){var s;if(nf(t.target)||!pl(t))return;let i=this.Bf(t,e);!((s=this.rageclicks)===null||s===void 0)&&s.isRageClick(t.clientX,t.clientY,new Date().getTime())&&Bp(cn(t),this.instance.config.rageclick)&&this.Qs(_(_({},i),{},{type:"rageclick"})),this.Qs(i)}Lf(t){!nf(t.target)&&pl(t)&&(clearTimeout(this.jf),this.jf=setTimeout(()=>{this.Qs(this.Bf(t,"mousemove"))},500))}Qs(t){if(!E)return;let e=this.Mr.disable_capture_url_hashes?ds(E.location.href):E.location.href,s=this.Mr.custom_personal_data_properties,i=this.Mr.mask_personal_data_properties?[..._i,...s||[]]:[],n=yn(e,i,bn);this.Rt=this.Rt||{},this.Rt[n]||(this.Rt[n]=[]),this.Rt[n].push(t)}fl(){this.Rt&&!nt(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:pf,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.Mf=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.zf=()=>{clearTimeout(this.Hf),this.Hf=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",_({$current_url:this.Rt.url},this.Rt.metrics.reduce((s,i)=>_(_({},s),{},{[`$web_vitals_${i.name}_event`]:_({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Uf=s=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},B(s?.name)||B(s?.value))return void Rs.error("Invalid metric received",s);let n=typeof s.navigationURL=="string"?s.navigationURL:void 0,r=this.Wf(n);if(S(r))return;let o=Te(s.navigationId)||typeof s.navigationId=="string"?`navigation:${s.navigationId}`:`url:${r}`;if(this.Vf&&s.value>=this.Vf)return void Rs.error("Ignoring metric with value >= "+this.Vf,s);this.Rt.navigationKey!==o&&(this.zf(),this.Hf=setTimeout(this.zf,this.flushToCaptureTimeoutMs)),S(this.Rt.navigationKey)&&(this.Rt.navigationKey=o,this.Rt.url=r),this.Rt.firstMetricTimestamp=S(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;let a=(i=this._instance.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0),l=_(_(_({},s),n?{navigationURL:r}:{}),{},{$current_url:r,timestamp:Date.now()});if(delete l.entries,G(s.attribution)&&this.attributionMetrics.indexOf(s.name)>-1){let c={};for(let u of oT){let h=u==="url"&&typeof s.attribution[u]=="string"?this.Wf(s.attribution[u]):s.attribution[u];S(h)||(c[u]=h)}l.attribution=c}else delete l.attribution;S(a)||(l.$session_id=a.sessionId,l.$window_id=a.windowId),this.Rt.metrics.push(l),this.Rt.metrics.length===this.allowedMetrics.length&&this.zf()},this.Gf=()=>{if(this.ko)return;let s,i,n,r,o=!1,a=L.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,c=l?.[this.Qf]||(this.Qf==="web-vitals"&&S(l)?a?.postHogWebVitalsCallbacks:void 0);if(!S(c)){let d=c.withoutAttribution,g=this.attributionMetrics;o=!S(d),s=g.indexOf("LCP")>-1?c.onLCP:d?.onLCP||c.onLCP,i=g.indexOf("CLS")>-1?c.onCLS:d?.onCLS||c.onCLS,n=g.indexOf("FCP")>-1?c.onFCP:d?.onFCP||c.onFCP,r=g.indexOf("INP")>-1?c.onINP:d?.onINP||c.onINP}if(!(s&&i&&n&&r))return void Rs.error("web vitals callbacks not loaded - not starting");let u={reportSoftNavs:this.useSoftNavs},h=o&&this.attributionMetrics.indexOf("INP")>-1?_(_({},u),{},{includeProcessedEventEntries:!1}):u;this.allowedMetrics.indexOf("LCP")>-1&&s(this.Uf.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Uf.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&n(this.Uf.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&r(this.Uf.bind(this),h),this.ko=!0},this.Mf=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[Ml]),this.startIfEnabled()}get Zf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e;let s=G(this.Zf)?(t=this.Zf)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return B(s)?((e=this._instance.persistence)===null||e===void 0?void 0:e.props.$web_vitals_allowed_metrics)||Uf:s}get flushToCaptureTimeoutMs(){return(G(this.Zf)?this.Zf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){let t=G(this.Zf)?this.Zf.web_vitals_attribution:void 0;return Je(t)?t?Uf:[]:N(t)?t:rT}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){let t=G(this.Zf)?this.Zf.__preview_web_vitals_soft_navs:void 0;return t!=null&&t}get Vf(){let t=G(this.Zf)&&Te(this.Zf.__web_vitals_max_value)?this.Zf.__web_vitals_max_value:Lf;return t>0&&6e4>=t?Lf:t}get isEnabled(){let t=pe?.protocol;if(t!=="http:"&&t!=="https:")return Rs.info("Web Vitals are disabled on non-http/https protocols"),!1;let e=G(this.Zf)?this.Zf.web_vitals:Je(this.Zf)?this.Zf:void 0;return Je(e)?e:this.Mf}startIfEnabled(){this.isEnabled&&!this.ko&&(Rs.info("enabled, starting..."),this.zo(this.Gf))}onRemoteConfig(t){if(!t.ok)return;let e=t.config;if(!("capturePerformance"in e))return;let s=G(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=G(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ml]:s}),this._instance.persistence.register({[hp]:i})),this.Mf=s,this.startIfEnabled()}get Qf(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}zo(t){var e;let s=L.__PosthogExtensions__,i=this.Qf,n=s?.postHogWebVitalsCallbacksByFlavor;n?.[i]||i==="web-vitals"&&S(n)&&s?.postHogWebVitalsCallbacks?t():s==null||(e=s.loadExternalDependency)===null||e===void 0||e.call(s,this._instance,i,r=>{r?Rs.error("failed to load script",r):t()})}Wf(t){let e=t||E?.location.href;if(!e)return void Rs.error("Could not determine current URL");let s=this._instance.config.disable_capture_url_hashes?ds(e):e,i=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[..._i,...i||[]]:[];return yn(s,n,bn)}}},NT={exceptionObserver:class{constructor(t){var e;this.Gf=()=>{var s;if(!E||!this.isEnabled||!(!((s=L.__PosthogExtensions__)===null||s===void 0)&&s.errorWrappingFunctions))return;let i=L.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=L.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=L.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Jf&&this.Mr.capture_unhandled_errors&&(this.Jf=i(this.captureException.bind(this))),!this.Kf&&this.Mr.capture_unhandled_rejections&&(this.Kf=n(this.captureException.bind(this))),!this.Xf&&this.Mr.capture_console_errors&&(this.Xf=r(this.captureException.bind(this)))}catch(o){Xi.error("failed to start",o),this.Yf()}},this._instance=t,this.tp=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[Dl]),this.wt=new eS(_(_({},(function(s={}){var i,n,r,o;return{refillRate:(i=(n=s.exceptionRateLimiterRefillRate)!==null&&n!==void 0?n:s.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(r=(o=s.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:s.__exceptionRateLimiterBucketSize)!==null&&r!==void 0?r:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,A:Xi})),this.Mr=this.ep(),this.startIfEnabledOrStop()}ep(){let t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return G(t)?e=_(_({},e),t):(S(t)?this.tp:t)&&(e=_(_({},e),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Xi.info("enabled"),this.Yf(),this.zo(this.Gf)):this.Yf()}zo(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.errorWrappingFunctions?t():(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"exception-autocapture",n=>{if(n)return Xi.error("failed to load script",n);t()})}Yf(){var t,e,s;(t=this.Jf)===null||t===void 0||t.call(this),this.Jf=void 0,(e=this.Kf)===null||e===void 0||e.call(this),this.Kf=void 0,(s=this.Xf)===null||s===void 0||s.call(this),this.Xf=void 0}onRemoteConfig(t){if(!t.ok)return;let e=t.config;"autocaptureExceptions"in e&&(this.tp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Dl]:this.tp}),this.Mr=this.ep(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.ep()}captureException(t){try{var e,s,i;let n=(e=t==null||(s=t.$exception_list)===null||s===void 0||(s=s[0])===null||s===void 0?void 0:s.type)!==null&&e!==void 0?e:"Exception";if(this.wt.consumeRateLimit(n))return void Xi.info("Skipping exception capture because of client rate limiting.",{exception:n});(i=this._instance.exceptions)===null||i===void 0||i.sendExceptionEvent(t)}catch{}}},exceptions:class{constructor(t){var e,s;this.np=[],this.sp=new hS([new IS,new MS,new CS,new RS,new DS,new xS,new PS,new NS],(function(i,...n){return(r,o=0)=>{let a=[],l=r.split(`
7
+ `),c=Math.min(l.length,o+1e3),u=[];for(let g=o;c>g;g++){let p=l[g];if(p.length>1024)continue;let m=Fh.test(p)?p.replace(Fh,"$1"):p;if(!m.match(/\S*Error: /)){for(let v of n){let b=v(m,i);if(b){a.push(b);let y=SS(a);if(y){for(let w=u.length-1;w>=0;w--){let A=u[w];if(y.start>=A.start+A.length)break;u.pop()}u.push(y)}break}}if(AS(a,u)>=50)break}}let h=[...u].sort((g,p)=>p.start-g.start),d=h[h.length-1];if(d){let g=Hg(a,d);a.splice(d.start-g,g);for(let p of h)p.start-=g}for(let g of h)kS(a,g);return u.some(g=>g.start===0&&a.length===g.length)&&(function(g){let p=g.map(v=>`${v.function}|${v.filename}|${v.lineno}|${v.colno}|${v.module}`),m=0;for(let v=1;p.length>v;v++)TS(p,v,m)&&(m=v);g.push(...g.splice(0,m))})(a),(function(g){if(!g.length)return[];let p=Array.from(g);return p.reverse(),p.slice(0,50).map(m=>{return _(_({},m),{},{filename:m.filename||(v=p,v[v.length-1]||{}).filename,function:m.function||"?"});var v})})(a)}})("web:javascript",yS,wS)),this._instance=t,this.np=(e=(s=this._instance.persistence)===null||s===void 0?void 0:s.get_property("$error_tracking_suppression_rules"))!==null&&e!==void 0?e:[],this.rp=qr(this.op()),this.ap=new LS(this.rp)}onConfigChange(){this.rp=qr(this.op()),this.ap.setConfig(this.rp)}onRemoteConfig(t){var e,s,i;if(!t.ok)return;let n=t.config;if(!("errorTracking"in n))return;let r=(e=(s=n.errorTracking)===null||s===void 0?void 0:s.suppressionRules)!==null&&e!==void 0?e:[],o=(i=n.errorTracking)===null||i===void 0?void 0:i.captureExtensionExceptions;this.np=r,this._instance.persistence&&this._instance.persistence.register({[up]:this.np,[Nl]:o})}get lp(){var t;let e=!!this._instance.get_property(Nl),s=this._instance.config.error_tracking.captureExtensionExceptions;return(t=s??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.sp.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this.rp.enabled)try{if(!H(t)||t.trim().length===0)return void _t.warn("Ignoring exception step because message must be a non-empty string");let{sanitizedProperties:s,droppedKeys:i}=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};let r=[];return{sanitizedProperties:Object.keys(n).reduce((o,a)=>FS.has(a)?(r.push(a),o):(o[a]=n[a],o),{}),droppedKeys:r}})(this.up(e));i.length>0&&_t.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.ap.add(_({[Hr]:t,[zr]:new Date().toISOString()},s))}catch(s){_t.error("Failed to add exception step. Ignoring breadcrumb.",s)}}sendExceptionEvent(t){try{let e=t.$exception_list;if(this.cp(e)){if(this.hp(e))return this.dp("Exception dropped: matched a suppression rule"),void _t.info("Skipping exception capture because a suppression rule matched");if(!this.lp&&this.vp(e))return this.dp("Exception dropped: thrown by a browser extension"),void _t.info("Skipping exception capture because it was thrown by an extension");if(!this.lp&&this.fp(e))return this.dp("Exception dropped: thrown by an injected browser script"),void _t.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.pp(e))return this.dp("Exception dropped: thrown by the PostHog SDK"),void _t.info("Skipping exception capture because it was thrown by the PostHog SDK")}let s=this.rp.enabled&&B(t.$exception_steps)?this.gp(t):t,i=(function(){if("u">typeof process){var n;let o=(n=process.env.POSTHOG_RELEASE_ID)===null||n===void 0?void 0:n.trim();if(o)return o}let r=globalThis._posthogReleaseId;return typeof r=="string"&&r.length>0?r:void 0})();i&&(s.$release_id=i);try{let n=this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",hc:!0});return n&&this.ap.clear(),n}catch(n){return Jf(n)||_t.error("Failed to capture exception event. Dropping this exception.",n),void this.ap.clear()}}catch(e){return void(Jf(e)||_t.error("Failed to process exception event. Ignoring this exception.",e))}}gp(t){try{let e=this.ap.getAttachable();return e.length===0?t:_(_({},t),{},{$exception_steps:e})}catch(e){return _t.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}dp(t){this.rp.enabled&&this.ap.add({[Hr]:t,[zr]:new Date().toISOString()})}up(t){return G(t)?_({},t):{}}op(){var t,e;return(t=(e=this._instance.config.error_tracking)===null||e===void 0?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}hp(t){if(t.length===0)return!1;try{let e=t.reduce((s,{type:i,value:n})=>(H(i)&&i.length>0&&s.$exception_types.push(i),H(n)&&n.length>0&&s.$exception_values.push(n),s),{$exception_types:[],$exception_values:[]});return this.np.some(s=>{let i=s.values.map(n=>{let r=wv[n.operator],o=e[n.key];if(!r||!o)return!1;let a=N(n.value)?n.value:[n.value];return a.length>0&&r(a,o)});return s.type==="OR"?i.some(Boolean):i.every(Boolean)})}catch(e){return _t.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}vp(t){let e=t.flatMap(i=>{var n,r;return(n=(r=i.stacktrace)===null||r===void 0?void 0:r.frames)!==null&&n!==void 0?n:[]}),s=e.filter(({filename:i})=>!!i&&ET.some(n=>i.startsWith(n)));return s.length!==0&&(!s.every(({filename:i})=>!!i&&i.startsWith(Ql))||t.some(({type:i,value:n})=>i==="NoResponse"||H(n)&&bT.some(({value:r,exact:o})=>o?n===r:n.includes(r)))&&!e.some(({in_app:i,filename:n})=>i&&!n?.startsWith(Ql)))}fp(t){return t.some(({value:e})=>H(e)&&wT.some(s=>e.includes(s)))}pp(t){if(t.length>0){var e,s,i,n;let r=(e=(s=t[0].stacktrace)===null||s===void 0?void 0:s.frames)!==null&&e!==void 0?e:[],o=r[r.length-1];return(i=o==null||(n=o.filename)===null||n===void 0?void 0:n.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}cp(t){return!B(t)&&N(t)}}},MT=_({productTours:class{get Il(){return this._instance.persistence}constructor(t){this.mp=null,this.yp=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!t.ok)return;let e=t.config;if("productTours"in e){var s,i;if(this.Il&&this.Il.register({[ac]:!!e.productTours}),!vl(this._instance))return!this.mp&&B((s=this.Il)===null||s===void 0?void 0:s.props.ph_product_tours)||Pr.info("product tours disabled; stopping and clearing cached tours"),(i=this.mp)===null||i===void 0||i.stop(),this.mp=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.mp&&vl(this._instance)&&this.zo(()=>this.bp())}zo(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours?t():(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"product-tours",n=>{n?Pr.error("Could not load product tours script",n):t()})}bp(){var t;!this.mp&&(!((t=L.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours)&&(this.mp=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e=!1){if(N(this.yp)&&!e)return void t(this.yp,{isLoaded:!0});let s=this.Il;if(s){let i=s.props[Fl];if(N(i)&&!e)return this.yp=i,void t(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:i=>{if(!vl(this._instance))return void t([],{isLoaded:!0});let n=i.statusCode;if(n!==200||!i.json){let o=`Product Tours API could not be loaded, status: ${n}`;return n===0?i.error||Pr.warn(o):Pr.error(o),void t([],{isLoaded:!1,error:o})}let r=N(i.json.product_tours)?i.json.product_tours:[];this.yp=r,s&&s.register({[Fl]:r}),t(r,{isLoaded:!0})}})}getActiveProductTours(t){B(this.mp)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.mp.getActiveProductTours(t)}showProductTour(t){var e;(e=this.mp)===null||e===void 0||e.showTourById(t)}previewTour(t){this.mp?this.mp.previewTour(t):this.zo(()=>{var e;this.bp(),(e=this.mp)===null||e===void 0||e.previewTour(t)})}dismissProductTour(){var t;(t=this.mp)===null||t===void 0||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.mp)===null||t===void 0||t.nextStep()}previousStep(){var t;(t=this.mp)===null||t===void 0||t.previousStep()}clearCache(){var t;this.yp=null,(t=this.Il)===null||t===void 0||t.unregister("ph_product_tours")}resetTour(t){var e;(e=this.mp)===null||e===void 0||e.resetTour(t)}resetAllTours(){var t;(t=this.mp)===null||t===void 0||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.mp)===null||e===void 0||e.cancelPendingTour(t)}}},uo),FT={siteApps:class{constructor(t){this._instance=t,this._p=0,this.wp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}kp(t,e){if(!e)return;let s=this.globalsForEvent(e);this.wp.push(s),this.wp.length>1e3&&(this.wp=this.wp.slice(10))}get siteAppLoaders(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(t=t[this._instance.config.token])===null||t===void 0?void 0:t.siteApps}initialize(){if(this.isEnabled){let t=this._instance._addCaptureHook(this.kp.bind(this));this.Sp=()=>{t(),this.wp=[],this.Sp=void 0}}}globalsForEvent(t){var e,s,i,n,r,o,a;if(!t)throw new Error("Event payload is required");let l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(let[g,p]of Object.entries(u))l[g]={id:c[g],type:g,properties:p};let{$set_once:h,$set:d}=t;return{event:_(_({},Kg(t,cT)),{},{properties:_(_(_({},t.properties),d?{$set:_(_({},(e=(s=t.properties)===null||s===void 0?void 0:s.$set)!==null&&e!==void 0?e:{}),d)}:{}),h?{$set_once:_(_({},(i=(n=t.properties)===null||n===void 0?void 0:n.$set_once)!==null&&i!==void 0?i:{}),h)}:{}),elements_chain:(r=(o=t.properties)===null||o===void 0?void 0:o.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(a=t.properties)===null||a===void 0?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}xp(t){var e;let s=(e=t.tagName)===null||e===void 0?void 0:e.toLowerCase();return s==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(At.error("prepare_external_dependency_stylesheet returned null"),null):s==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(At.error("prepare_external_dependency_script returned null"),null):t}$p(){var t,e,s,i,n,r,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};let l=T?.defaultView,c=l==null||(t=l.Node)===null||t===void 0?void 0:t.prototype;if(!l||!c)return()=>{};if(this._p++,this.Cp)return this.Tp();let u=[],h=this,d=new WeakSet,g=(v,b,y)=>{if(!v?.[b])return;let w=v[b];v[b]=y(w),u.push(()=>{v[b]=w})},p=v=>{if(d.has(v))return v;let b=h.xp(v);return b&&d.add(b),b},m=v=>v.map(b=>typeof b=="string"?b:p(b)).filter(b=>!we(b));return g(c,"appendChild",v=>function(b){let y=p(b);return y?v.call(this,y):b}),g(c,"insertBefore",v=>function(b,y){let w=p(b);return w?v.call(this,w,y):b}),g(c,"replaceChild",v=>function(b,y){let w=p(b);return w?v.call(this,w,y):y}),[(e=l.Element)===null||e===void 0?void 0:e.prototype,(s=l.Document)===null||s===void 0?void 0:s.prototype,(i=l.DocumentFragment)===null||i===void 0?void 0:i.prototype].forEach(v=>{g(v,"append",b=>function(...y){return b.apply(this,m(y))}),g(v,"prepend",b=>function(...y){return b.apply(this,m(y))})}),[(n=l.Element)===null||n===void 0?void 0:n.prototype,(r=l.CharacterData)===null||r===void 0?void 0:r.prototype,(o=l.DocumentType)===null||o===void 0?void 0:o.prototype].forEach(v=>{g(v,"before",b=>function(...y){return b.apply(this,m(y))}),g(v,"after",b=>function(...y){return b.apply(this,m(y))}),g(v,"replaceWith",b=>function(...y){let w=m(y);return y.length&&!w.length?void 0:b.apply(this,w)})}),g((a=l.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",v=>function(b,y){let w=p(y);return w?v.call(this,b,w):null}),this.Cp=()=>{u.forEach(v=>v()),this.Cp=void 0},this.Tp()}Tp(){let t=!1;return()=>{var e;t||(t=!0,this._p--,this._p===0&&((e=this.Cp)===null||e===void 0||e.call(this)))}}Ip(t,e=!0){let s=this.$p();try{let i=t(s);return e&&s(),i}catch(i){throw s(),i}}setupSiteApp(t){let e=this.apps[t.id],s=()=>{var r;!e.errored&&this.wp.length&&(At.info(`Processing ${this.wp.length} events for site app with id ${t.id}`),this.wp.forEach(o=>this.Ip(()=>{var a;return(a=e.processEvent)===null||a===void 0?void 0:a.call(e,o)})),e.processedBuffer=!0),Object.values(this.apps).every(o=>o.processedBuffer||o.errored)&&((r=this.Sp)===null||r===void 0||r.call(this))},i=!1,n=r=>{e.errored=!r,e.loaded=!0,At.info(`Site app with id ${t.id} ${r?"loaded":"errored"}`),i&&s()};try{let{processEvent:r}=this.Ip(o=>t.init({posthog:this._instance,callback(a){o(),n(a)}}),!1);r&&(e.processEvent=r),i=!0}catch(r){At.error(Vf+t.id,r),n(!1)}if(i&&e.loaded)try{s()}catch(r){At.error(`Error while processing buffered events PostHog app with config id ${t.id}`,r),e.errored=!0}}Mp(){let t=this.siteAppLoaders||[];for(let e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(let e of t)this.setupSiteApp(e)}Ep(t){if(Object.keys(this.apps).length===0)return;let e=this.globalsForEvent(t);for(let s of Object.values(this.apps))try{this.Ip(()=>{var i;return(i=s.processEvent)===null||i===void 0?void 0:i.call(s,e)})}catch(i){At.error(`Error while processing event ${t.event} for site app ${s.id}`,i)}}onRemoteConfig(t){var e,s,i;if(!((e=this.siteAppLoaders)===null||e===void 0)&&e.length)return this.isEnabled?(this.Mp(),void this._instance.on("eventCaptured",a=>this.Ep(a))):void At.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.Sp)===null||s===void 0||s.call(this),!t.ok)return;let n=t.config;if(!((i=n.siteApps)===null||i===void 0)&&i.length)if(this.isEnabled)for(let{id:a,url:l}of n.siteApps){var r,o;L[`__$$ph_site_app_${a}`]=this._instance,(r=L.__PosthogExtensions__)===null||r===void 0||(o=r.loadSiteApp)===null||o===void 0||o.call(r,this._instance,l,c=>{if(c)return At.error(Vf+a,c)})}else At.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},LT={tracingHeaders:class{constructor(t){this._instance=t,this.Pp=void 0,this.Rp=void 0,this.Ap=void 0,this.Gf=()=>{let e=this.Fp();var s,i;e?(S(this.Pp)&&(this.Pp=(s=L.__PosthogExtensions__)===null||s===void 0||(s=s.tracingHeadersPatchFns)===null||s===void 0?void 0:s._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),S(this.Rp)&&(this.Rp=(i=L.__PosthogExtensions__)===null||i===void 0||(i=i.tracingHeadersPatchFns)===null||i===void 0?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Yf()}}initialize(){this.startIfEnabledOrStop()}zo(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.tracingHeadersPatchFns?t():(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"tracing-headers",n=>{if(n)return nT.error("failed to load script",n);t()})}Op(){var t,e;return(t=(e=this._instance.config.tracing_headers)!==null&&e!==void 0?e:this._instance.config.addTracingHeaders)!==null&&t!==void 0?t:this._instance.config.__add_tracing_headers}Fp(){let t=this.Op();return N(t)?(N(this.Ap)?this.Ap.splice(0,this.Ap.length,...t):this.Ap=[...t],t.length>0?this.Ap:void 0):(N(this.Ap)&&this.Ap.splice(0),this.Ap=t||void 0,this.Ap)}Yf(){var t,e;(t=this.Pp)===null||t===void 0||t.call(this),(e=this.Rp)===null||e===void 0||e.call(this),this.Pp=void 0,this.Rp=void 0}startIfEnabledOrStop(){this.Fp()?this.zo(this.Gf):this.Yf()}}},UT=_({surveys:class extends uT{constructor(t){var e;super(new pT(t),(e=t,{get projectToken(){return e.config.token},kv:new gT(e)})),this._instance=t}Wc(t,e){let s=e.query?wn(t,e.query):t;return new Promise(i=>{var n;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor((n=e.target)!==null&&n!==void 0?n:"api",s),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:i})})}}},uo),BT={toolbar:class{constructor(t){this.instance=t}Dp(t){L.ph_toolbar_state=t}Lp(){var t;return(t=L.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,e=void 0,s=void 0){var i,n;if(Ul(this.instance.config)||!E||!T)return!1;t=(i=t)!==null&&i!==void 0?i:E.location,s=(n=s)!==null&&n!==void 0?n:E.history;try{if(!e){try{E.localStorage.setItem("test","test"),E.localStorage.removeItem("test")}catch{return!1}e=E?.localStorage}let r=vT||eo(t.hash,"__posthog")||eo(t.hash,"state"),o,a=r?Ph(()=>JSON.parse(atob(decodeURIComponent(r))))||Ph(()=>JSON.parse(decodeURIComponent(r))):null;return a&&a.action==="ph_authorize"?(o=a,o.source="url",o&&Object.keys(o).length>0&&(a.desiredHash?t.hash=a.desiredHash:s?s.replaceState(s.state,"",t.pathname+t.search):t.hash="")):(o=JSON.parse(e.getItem(Gf)||"{}"),o.source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token||(this.loadToolbar(o),0))}catch{return!1}}Np(t){let e=L.ph_load_toolbar||L.ph_load_editor;!B(e)&&Ce(e)?e(t,this.instance):Hf.warn("No toolbar load function found")}loadToolbar(t){let e=!!T?.getElementById("__POSTHOG_TOOLBAR__");if(!E||e)return!1;let s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=_(_({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(E.localStorage.setItem(Gf,JSON.stringify(_(_({},i),{},{source:void 0}))),this.Lp()===2)this.Np(i);else if(this.Lp()===0){var n,r;this.Dp(1),(n=L.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,"toolbar",o=>{if(o)return Hf.error("[Toolbar] Failed to load",o),void this.Dp(0);this.Dp(2),this.Np(i)}),se(E,"turbolinks:load",()=>{this.Dp(0),this.loadToolbar(i)})}return!0}qp(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,e=void 0,s=void 0){return this.maybeLoadToolbar(t,e,s)}}},VT=_({experiments:class Ke{get Mr(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(s=!1)=>{this.getWebExperiments(i=>{Ke.jp("retrieved web experiments from the server"),this.Bp=new Map,i.forEach(n=>{if(n.feature_flag_key){var r;this.Bp&&(Ke.jp("setting flag key ",n.feature_flag_key," to web experiment ",n),(r=this.Bp)===null||r===void 0||r.set(n.feature_flag_key,n));let o=this._instance.getFeatureFlag(n.feature_flag_key);H(o)&&n.variants[o]&&this.zp(n.name,o,n.variants[o].transforms)}else if(n.variants)for(let o in n.variants){let a=n.variants[o];Ke.Hp(a,this._instance)&&this.zp(n.name,o,a.transforms)}})},s)},this._instance.onFeatureFlags(s=>{this.onFeatureFlags(s)})}initialize(){}onFeatureFlags(e){if(this._is_bot())Ke.jp(Xf);else if(!this.Mr.disable_web_experiments){if(B(this.Bp))return this.Bp=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ke.jp("applying feature flags",e),e.forEach(s=>{var i;if(this.Bp&&(!((i=this.Bp)===null||i===void 0)&&i.has(s))){var n;let r=this._instance.getFeatureFlag(s),o=(n=this.Bp)===null||n===void 0?void 0:n.get(s);r&&o?.variants[r]&&this.zp(o.name,r,o.variants[r].transforms)}})}}previewWebExperiment(){let e=Ke.getWindowLocation();if(e?.search){let s=vi(e?.search,"__experiment_id"),i=vi(e?.search,"__experiment_variant");s&&i&&(Ke.jp(`previewing web experiments ${s} && ${i}`),this.getWebExperiments(n=>{this.Up(parseInt(s),i,n)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,s,i){if(this.Mr.disable_web_experiments&&!i)return e([]);let n=this._instance.get_property("$web_experiments");if(n&&!s)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Mr.token}`),method:"GET",timestampMode:"query",callback:r=>e(r.statusCode===200&&r.json&&r.json.experiments||[])})}Up(e,s,i){let n=i.filter(r=>r.id===e);n&&n.length>0&&(Ke.jp(`Previewing web experiment [${n[0].name}] with variant [${s}]`),this.zp(n[0].name,s,n[0].variants[s].transforms))}static Hp(e,s){return!B(e.conditions)&&Ke.Wp(e,s)&&Ke.Vp(e)}static Wp(e,s){var i;if(B(e.conditions)||B((i=e.conditions)===null||i===void 0?void 0:i.url))return!0;let n=Ke.getWindowLocation();if(n){var r,o,a;let l=Np(s,n.href);return!(!((r=e.conditions)===null||r===void 0)&&r.url)||ST[(o=(a=e.conditions)===null||a===void 0?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return E?.location}static Vp(e){var s;if(B(e.conditions)||B((s=e.conditions)===null||s===void 0?void 0:s.utm))return!0;let i=Yp();if(i.utm_source){var n,r,o,a,l,c,u,h;let d=!(!((n=e.conditions)===null||n===void 0||(n=n.utm)===null||n===void 0)&&n.utm_campaign)||((r=e.conditions)===null||r===void 0||(r=r.utm)===null||r===void 0?void 0:r.utm_campaign)==i.utm_campaign,g=!(!((o=e.conditions)===null||o===void 0||(o=o.utm)===null||o===void 0)&&o.utm_source)||((a=e.conditions)===null||a===void 0||(a=a.utm)===null||a===void 0?void 0:a.utm_source)==i.utm_source,p=!(!((l=e.conditions)===null||l===void 0||(l=l.utm)===null||l===void 0)&&l.utm_medium)||((c=e.conditions)===null||c===void 0||(c=c.utm)===null||c===void 0?void 0:c.utm_medium)==i.utm_medium,m=!(!((u=e.conditions)===null||u===void 0||(u=u.utm)===null||u===void 0)&&u.utm_term)||((h=e.conditions)===null||h===void 0||(h=h.utm)===null||h===void 0?void 0:h.utm_term)==i.utm_term;return d&&p&&m&&g}return!1}static jp(e,...s){R.info(`[WebExperiments] ${e}`,s)}zp(e,s,i){this._is_bot()?Ke.jp(Xf):s!=="control"?i.forEach(n=>{if(n.selector){var r;Ke.jp(`applying transform of variant ${s} for experiment ${e} `,n);let o=(r=document)===null||r===void 0?void 0:r.querySelectorAll(n.selector);o?.forEach(a=>{let l=a;n.html&&(l.innerHTML=n.html),n.css&&l.setAttribute("style",n.css)})}}):Ke.jp("Control variants leave the page unmodified.")}_is_bot(){return Le&&this._instance?yv(Le,this.Mr.custom_blocked_useragents):void 0}}},uo),jT={conversations:class{constructor(t){this._instance=t,this.Gp=void 0,this._conversationsManager=null,this.Qp=!1,this.ne=null,this.Zp=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations||(this.Jp=t.ok,!t.ok))return;let e=t.config.conversations;B(e)||(Je(e)?this.Gp=e:(this.Gp=e.enabled,this.ne=e),this.loadIfEnabled())}reset(){var t;(t=this._conversationsManager)===null||t===void 0||t.reset(),this._conversationsManager=null,this.Gp=void 0,this.ne=null,this.Jp=void 0,this.Zp=!1}loadIfEnabled(){if(this._conversationsManager||this.Qp||this._instance.config.disable_conversations||Ul(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;let t=L?.__PosthogExtensions__;if(t&&!S(this.Gp)&&this.Gp)if(this.ne&&this.ne.token){this.Qp=!0;try{let e=t.initConversations;if(e)return this.Kp(e),void(this.Qp=!1);let s=t.loadExternalDependency;if(!s)return void this.Xp(dc);s(this._instance,"conversations",i=>{i||!t.initConversations?this.Xp("Could not load conversations script",i):this.Kp(t.initConversations),this.Qp=!1})}catch(e){this.Xp("Error initializing conversations",e),this.Qp=!1}}else gt.error("Conversations enabled but missing token in remote config.")}Kp(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.Zp=!1,gt.info("Conversations loaded successfully")}catch(e){this.Xp("Error completing conversations initialization",e)}else gt.error("Cannot complete initialization: remote config is null")}Xp(t,e){gt.error(t,e),this._conversationsManager=null,this.Qp=!1,this.Zp=!0}show(){this._conversationsManager?this._conversationsManager.show():gt.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Gp===!0&&!we(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Ul(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Jp===!1?"remote_config_failed":S(this.Gp)?this.Jp?"disabled_in_project":"remote_config_pending":this.Gp?B(this.ne)||!this.ne.token?"missing_token":L?.__PosthogExtensions__?this.Qp?"initializing":this.Zp?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,e;return(t=(e=this._conversationsManager)===null||e===void 0?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,s){var i=this;return he(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(t,e,s):(gt.warn(Os),null)})()}getMessages(t,e){var s=this;return he(function*(){return s._conversationsManager?s._conversationsManager.getMessages(t,e):(gt.warn(Os),null)})()}markAsRead(t){var e=this;return he(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(gt.warn(Os),null)})()}getTickets(t){var e=this;return he(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(gt.warn(Os),null)})()}requestRestoreLink(t){var e=this;return he(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(gt.warn(Os),null)})()}restoreFromToken(t){var e=this;return he(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(gt.warn(Os),null)})()}restoreFromUrlToken(){var t=this;return he(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(gt.warn(Os),null)})()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)===null||e===void 0?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)===null||e===void 0?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}kc(){var t;(t=this._conversationsManager)===null||t===void 0||t.setIdentity()}Sc(){var t;(t=this._conversationsManager)===null||t===void 0||t.clearIdentity()}}},GT={logs:class extends TT{constructor(t){super({get(){var e;return t==null||(e=t.config)===null||e===void 0?void 0:e.logs},captureHintKey:dp,get remoteConfigWillArrive(){var e,s;return!(!((e=t.il)===null||e===void 0)&&e.call(t))||!!(!((s=L._POSTHOG_REMOTE_CONFIG)===null||s===void 0||(s=s[t.config.token])===null||s===void 0)&&s.config)}},()=>(function(e){var s;let i={};if(i.distinctId=e.get_distinct_id(),e.sessionManager){let{sessionId:n,windowId:r,sessionStartTimestamp:o,lastActivityTimestamp:a}=e.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=n,i.windowId=r,B(o)||(i.sessionStartTimestamp=o),B(a)||(i.lastActivityTimestamp=a)}if(!(L==null||(s=L.location)===null||s===void 0)&&s.href&&(i.currentUrl=e.config.disable_capture_url_hashes?ds(L.location.href):L.location.href),e.featureFlags){let n=e.featureFlags.getFlags();n&&n.length>0&&(i.activeFeatureFlags=n)}return i})(t)),this._instance=t,this.name=Iv,this.Rv()}get Ev(){return this._instance.__loaded}Pv(){let t=ye("[logs]"),e=L?.__PosthogExtensions__;if(!e)return void t.error("PostHog Extensions not found.");let s=e.loadExternalDependency;if(s)return i=>{s(this._instance,"logs",n=>{let r=e.logs;i(n,r?.initializeLogs?{initialize:o=>r.initializeLogs(o),replay(o,a){var l;return(l=r.replayConsoleBuffer)===null||l===void 0?void 0:l.call(r,o,a)}}:void 0)})};t.error(dc)}}},HT={metrics:class{constructor(t){this._instance=t,this.A=ye("[metrics]"),this.To=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(this.To)return;let e=!!(!((t=this._instance.config.metrics)===null||t===void 0)&&t.network);e&&!this.Yp?this.Yp=(s=>{let i=!0,n=()=>i?(a=>{var l;let c=(l=a.config.metrics)===null||l===void 0?void 0:l.network;return c===!0?{}:c||void 0})(s):void 0,r=CT(s,n),o=OT(s,n);return()=>{i=!1,r(),o()}})(this._instance):!e&&this.Yp&&(this.Yp(),this.Yp=void 0)}Ov(){var t;let e=(t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0?void 0:t.metrics;var s;return this.Iv&&this.Dv===e||((s=this.Iv)===null||s===void 0||s.reset(),this.Dv=e,this.Iv=new Ek(this.Fv(),(function(i){var n,r,o,a,l;let c=i?.resourceAttributes;return{serviceName:(n=c?.["service.name"])!==null&&n!==void 0?n:i?.serviceName,serviceVersion:(r=c?.["service.version"])!==null&&r!==void 0?r:i?.serviceVersion,environment:(o=c?.["deployment.environment"])!==null&&o!==void 0?o:i?.environment,resourceAttributes:c,beforeSend:i?.beforeSend,flushIntervalMs:(a=i?.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=i?.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(e),this.A)),this.Iv}count(t,e=1,s){this.Ov().count(t,e,s)}gauge(t,e,s){this.Ov().gauge(t,e,s)}histogram(t,e,s){this.Ov().histogram(t,e,s)}flush(t){if(!this.Iv)return Promise.resolve();if(t){let e=this.Iv.drainWindow();return e&&this.Ys(e,t),Promise.resolve()}return this.Iv.flush().catch(e=>this.A.error("PostHog metrics flush failed:",e))}reset(){var t;(t=this.Iv)===null||t===void 0||t.reset()}dispose(){var t,e;this.To=!0,(t=this.Yp)===null||t===void 0||t.call(this),this.Yp=void 0,(e=this.Iv)===null||e===void 0||e.reset()}Fv(){let t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ys:s=>e.Ys(s),getLibraryId:()=>it.LIB_NAME,getLibraryVersion:()=>it.LIB_VERSION}}Ys(t,e){return new Promise(s=>{let i=!1,n=o=>{i||(i=!0,clearTimeout(r),s(o))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(_(_({method:"POST",url:this.tg(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e}),{},{fireCallbackOnDrop:!0,callback(o){let a=o.statusCode;if(a>=200&&300>a)n({kind:"ok"});else if(a===413)n({kind:"too-large"});else if(a!==0&&a!==408&&a!==429&&500>a)n({kind:"fatal",error:new Error(`metrics request failed with status ${a}`)});else{var l;n({kind:"retry-later",error:(l=o.error)!==null&&l!==void 0?l:new Error(`metrics request failed with status ${a}`)})}}}))})}tg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},zT={webMCP:class{constructor(t){this._instance=t,this.eg=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this.eg)return;let t=T?.modelContext;if(!t||!Ce(t.registerTool))return;let e=sg.get(t);if(e)return e.instances.add(this._instance),void(this.eg=!0);let s={instances:new Set([this._instance])},i=t.registerTool,n=this;yi(t,"registerTool",r=>{let o=r;return function(a,...l){let c=a;try{c=n.ig(a,s)}catch{return o.call(this,a,...l)}return o.call(this,c,...l)}}),t.registerTool!==i&&(sg.set(t,s),this.eg=!0)}ig(t,e){if(!t||!Ce(t.execute))return t;let s=t.execute,i=this,{tool:n,injected:r}=(function(o,a){let l={intent:!1,model:!1},c=o.inputSchema;if(!(function(p){return!!S(p)||G(p)&&Object.keys(p).every(m=>PT.has(m)||m.startsWith("x-"))&&p.additionalProperties!==!0&&!G(p.additionalProperties)&&(!p.type||p.type==="object")&&(!p.properties||G(p.properties))&&(!p.required||N(p.required))})(c))return{tool:bl(o),injected:l};let u=c?.properties||{},h=p=>yl(u,p)||N(c?.required)&&c.required.includes(p);if(l.intent=a.intent&&!h("context"),l.model=a.model&&!h("llm_model"),!l.intent&&!l.model)return{tool:bl(o),injected:l};let d=_({},u),g=N(c?.required)?[...c.required]:[];return l.intent&&(d.context={type:"string",description:`Explain why this tool is called and how it supports the user's goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".`},g.includes("context")||g.push("context")),l.model&&(d.llm_model={type:"string",description:'The exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},g.includes("llm_model")||g.push("llm_model")),{tool:bl(o,_(_({},c),{},{type:c?.type||"object",properties:d,required:g})),injected:l}})(t,(function(o){let a={intent:!1,model:!1};for(let l of o.instances){let c=ig(l.config.capture_webmcp);a.intent||(a.intent=c?.intent===!0),a.model||(a.model=c?.model===!0)}return a})(e));return Object.defineProperty(n,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){let a=new Date,l=(function(d,g){if(!G(d))return{};try{let p=g.intent?ng(d.context,2048,!0):void 0,m=g.model?ng(d.llm_model,256):void 0;return _(_({},p&&p!=="{}"?{intent:p}:{}),m&&m.toLowerCase()!=="unknown"?{model:m}:{})}catch{return{}}})(o[0],r),c=(function(d,g){let p=d[0];if(!G(p))return d;try{let m=g.intent&&yl(p,"context"),v=g.model&&yl(p,"llm_model");if(!m&&!v)return d;let b=_({},p);return m&&delete b.context,v&&delete b.llm_model,[b,...d.slice(1)]}catch{return d}})(o,r),u;try{u=s.apply(this===n?t:this,c)}catch(d){throw i.ng(e,n,a,!0,l),d}return(h=u)&&typeof h.then=="function"?Promise.resolve(u).then(d=>(i.ng(e,n,a,rg(d),l),d),d=>{throw i.ng(e,n,a,!0,l),d}):(i.ng(e,n,a,rg(u),l),u);var h}}),n}ng(t,e,s,i,n){let r=Date.now()-s.getTime();for(let o of t.instances){let a=ig(o.config.capture_webmcp);if(a)try{o.capture("$mcp_tool_call",_(_({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:e.name,$mcp_resource_name:e.name,$mcp_tool_description:e.description,$mcp_server_name:pe?.hostname,$mcp_duration_ms:r,$mcp_is_error:i},a.intent&&n.intent?{$mcp_intent:n.intent,$mcp_intent_source:"context_parameter"}:{}),a.model&&n.model?{$mcp_llm_model:n.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:s})}catch{continue}}}}};fn.__defaultExtensionClasses=_({},_(_(_(_(_(_(_(_(_(_(_(_(_(_({},uo),xT),DT),NT),MT),FT),UT),LT),BT),VT),jT),GT),HT),zT));qT=(function(){it.SDK_DIST_CHANNEL="npm";let t=dn[tn]=new fn;return(function(){function e(){e.done||(e.done=!0,_v=!1,re(dn,function(s){s._dom_loaded()}))}T?.addEventListener?T.readyState==="complete"?e():se(T,"DOMContentLoaded",e,{capture:!1}):E&&R.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),t})(),Oe=qT});var Nv={};go(Nv,{Posthog:()=>Sc});var He,Sc,Mv=Ze(()=>{"use strict";Dv();Di();Mi();He=class He{constructor(e,s=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=es("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let s=`ph_${e}_posthog`,i=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==s);if(i.length===0)return;let n=window.location.hostname,r=n.split("."),o=r.length>=2?`.${r.slice(-2).join(".")}`:n;i.forEach(a=>{[o,n,""].forEach(c=>{let u=c?`; Domain=${c}`:"";document.cookie=`${a}=; path=/${u}; 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:s,config:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}if(He._hasLoaded||Oe.__loaded){this.log("init | PostHog already initialized, skipping re-init"),this.has_initialized=!0;return}this.cleanupStalePosthogCookies(e);let n=s||gd();this.log("init | loading PostHog SDK",{api_host:n});let r={api_host:n,ui_host:fd,autocapture:{dom_event_allowlist:["click"],element_allowlist:["button","a"]},rageclick:!0,capture_dead_clicks:!0,rate_limiting:{events_per_second:10,events_burst_limit:100},...i,person_profiles:"identified_only",capture_pageview:"history_change",capture_pageleave:!0,session_recording:{...i.session_recording,recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,maskAllInputs:!0},before_send:o=>{if(typeof window>"u"||!o)return null;if(o.timestamp){let c=o.timestamp.getTime(),u=Date.now();if(c<u-6048e5||c>u+6048e5)return this.log("init | before_send dropped event with bad timestamp",{event:o.event,timestamp:o.timestamp.toISOString()}),null}let a=window.location.hostname;if(a!=="localhost"&&a!=="127.0.0.1"&&!pd.some(c=>a.endsWith(`.${c}`)||a===c))return this.log("init | before_send blocked event from disallowed host",{currentHost:a}),null;if(i.before_send){let l=Array.isArray(i.before_send)?i.before_send:[i.before_send],c=o;for(let u of l)c=c?u(c):null;return c}return o}};Oe.init(e,r),this.options.app_version&&Oe.register({app_version:this.options.app_version}),He._hasLoaded=!0,this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.resetIfStaleId=(e,s,i)=>{He.isAnonymousId(e)||(this.log(`${i} | stale identified user, resetting`,{previous:e,next:s}),Oe.reset())};this.identifyEvent=(e,s={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{if(!e||!e.trim()||He.ILLEGAL_IDS.has(e.toLowerCase())){this.log("identifyEvent | skipped \u2014 invalid user_id",{user_id:e});return}let i=Oe.get_distinct_id();if(i===e){this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e});return}this.resetIfStaleId(i,e,"identifyEvent"),this.log("identifyEvent | identifying user",{user_id:e,traits:s}),Oe.identify(e,{...s,client_id:e}),this.has_identified=!0}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),Oe.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:s,language:i,country_of_residence:n})=>{if(!(!this.has_initialized||!e)){if(!e.trim()||He.ILLEGAL_IDS.has(e.toLowerCase())){this.log("backfillPersonProperties | skipped \u2014 invalid user_id",{user_id:e});return}try{let r=Oe.get_distinct_id(),o=r===e;o||this.resetIfStaleId(r,e,"backfillPersonProperties");let a={};if(Oe.get_property("client_id")||(a.client_id=e),s&&Oe.get_property("is_internal")==null&&(a.is_internal=sr(s)),i&&!Oe.get_property("language")&&(a.language=i),n&&!Oe.get_property("country_of_residence")&&(a.country_of_residence=n),o){if(Object.keys(a).length===0){this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e});return}this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:a}),Oe.setPersonProperties(a)}else a.client_id||(a.client_id=e),this.log("backfillPersonProperties | user not identified, identifying now",{user_id:e,updates:a}),Oe.identify(e,a),this.has_identified=!0}catch(r){console.error("Posthog: Failed to backfill person properties",r)}}};this.capture=(e,s)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:s}),Oe.capture(e,s)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let s=Oe.isFeatureEnabled(e);return this.log("isFeatureEnabled",{key:e,result:s}),s}catch(s){console.error("Posthog: Failed to check feature flag",s);return}};this.getFeatureFlag=e=>{if(this.has_initialized)try{let s=Oe.getFeatureFlag(e);return this.log("getFeatureFlag",{key:e,result:s}),s}catch(s){console.error("Posthog: Failed to get feature flag",s);return}};this.getFeatureFlagPayload=e=>{if(this.has_initialized)try{let s=Oe.getFeatureFlagResult(e)?.payload;return this.log("getFeatureFlagPayload",{key:e,result:s}),s}catch(s){console.error("Posthog: Failed to get feature flag payload",s);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let e=Oe.featureFlags?.getFlagVariants()??{},s=Object.fromEntries(Object.entries(e).filter(i=>i[1]!=null));return this.log("getAllFlags",{result:s}),s}catch(e){return console.error("Posthog: Failed to get all feature flags",e),{}}};this.onFeatureFlags=e=>{if(!this.has_initialized)return()=>{};try{this.log("onFeatureFlags | subscribing to feature flag changes");let s=Oe.onFeatureFlags(e);return typeof s=="function"?s:()=>{}}catch(s){return console.error("Posthog: Failed to subscribe to feature flags",s),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),Oe.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=s,this.init()}};He._hasLoaded=!1,He.ILLEGAL_IDS=new Set(["restored","null","undefined","anonymous","guest","distinctid","distinct_id","id","not_authenticated","email","true","false","0","none","nan"]),He.getPosthogInstance=(e,s=!1)=>(He._instance?e.apiKey&&e.apiKey!==He._instance.options.apiKey&&console.warn("Posthog: getPosthogInstance called with a different API key \u2014 returning existing instance"):He._instance=new He(e,s),He._instance),He.isAnonymousId=e=>e?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!0;Sc=He});var KT={};go(KT,{Analytics:()=>Fv});ca();Di();Mi();var VE=4320*60*60,ys=class ys{constructor(e,s,i=!1,n){this.analytics=new zs;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=es("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let s=window.location.hostname,r=["webflow.io"].some(c=>s.endsWith(c))?s:s.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 u=Array.from(c,h=>h.toString(16).padStart(2,"0")).join("");o=`${u.slice(0,8)}-${u.slice(8,12)}-${u.slice(12,16)}-${u.slice(16,20)}-${u.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=${r}; max-age=${VE}; SameSite=Lax${l}`}catch(s){console.warn("RudderStack: Failed to set anonymous ID cookie",s)}};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:ua});try{this.setCookieIfNotExists(),this.analytics.load(e,ua,{...this.app_version&&{context:{app_version:this.app_version}},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(s){console.error("RudderStack: Failed to initialize",s)}};this.identifyEvent=(e,s)=>{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:s}),this.analytics.identify(e,s||{}),this.has_identified=!0}catch(n){console.error("RudderStack: Failed to identify user",n)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,s="Deriv App",i,n)=>{if(!(!this.has_initialized||e===this.current_page))try{let r={...i&&{user_id:i},...n};this.log("pageView | tracking page view",{platform:s,current_page:e,properties:r}),this.analytics.page(s,e,r),this.current_page=e}catch(r){console.error("RudderStack: Failed to track page view",r)}};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,s)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:s}),this.analytics.track(e,s)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=s,this.debug=i,this.app_version=n,this.init(e)}};ys.getRudderStackInstance=(e,s,i=!1,n)=>(ys._instance||(ys._instance=new ys(e,s,i,n)),ys._instance);var ir=ys;var nr="cached_analytics_events",rr="cached_analytics_page_views",wd=(t,e)=>{try{let s=localStorage.getItem(nr),i=s?JSON.parse(s):[];i.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(nr,JSON.stringify(i))}catch(s){console.warn("Analytics: Failed to cache event",s)}},Sd=(t,e)=>{try{let s=localStorage.getItem(rr),i=s?JSON.parse(s):[];i.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(rr,JSON.stringify(i))}catch(s){console.warn("Analytics: Failed to cache page view",s)}},kd=()=>{try{let t=localStorage.getItem(nr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached events",t)}return[]},Ad=()=>{try{let t=localStorage.getItem(rr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached pages",t)}return[]},Td=()=>{try{localStorage.removeItem(nr)}catch(t){console.warn("Analytics: Failed to clear cached events",t)}},Id=()=>{try{localStorage.removeItem(rr)}catch(t){console.warn("Analytics: Failed to clear cached page views",t)}};Mi();function WT(t){let e=t?.debug??!1,s=es("",()=>e),i,n,r,o={},a={},l=[],c=[],u=!1,h=()=>{if(!u&&n?.has_initialized){u=!0;try{let P=kd();P.length>0&&(s(`processStorageCache | replaying ${P.length} cached event(s)`,P),P.forEach(V=>{let W=ms(V.properties);n?.track(V.name,W)}),Td());let U=Ad();U.length>0&&(s(`processStorageCache | replaying ${U.length} cached page view(s)`,U),U.forEach(V=>{n?.pageView(V.name,"Deriv App",A(),V.properties)}),Id())}catch(P){console.warn("Analytics: Failed to process storage cache",P)}}},d=()=>{s("onSdkLoaded | RudderStack SDK loaded"),h(),c.length>0&&s(`onSdkLoaded | flushing ${c.length} pending identify call(s)`),c.forEach(({userId:P,traits:U})=>{P&&n?.identifyEvent(P,U)}),c=[]},g=async({growthbookKey:P,growthbookDecryptionKey:U,rudderstackKey:V,app_version:W,growthbookOptions:ee,posthogOptions:le,debug:_e})=>{var Re,xe;_e!==void 0&&(e=_e),s("initialise | starting analytics initialization",{rudderstack:!!V,growthbook:!!P,posthog:!!le});try{let Me=ee?.attributes?.country||(P?await yd():void 0);if(V&&(s("initialise | initializing RudderStack"),n=ir.getRudderStackInstance(V,d,e,W)),ee?.attributes&&Object.keys(ee.attributes).length>0){let z=ee.attributes,Ct=n?.getAnonymousId();o={...o,country:Me,...z.user_language&&{user_language:z.user_language},...z.account_type&&{account_type:z.account_type},...z.app_id&&{app_id:z.app_id},...z.residence_country&&{residence_country:z.residence_country},...z.device_type&&{device_type:z.device_type},...z.url&&{url:z.url},...z.email_hash&&{email_hash:z.email_hash},...z.network_type&&{network_type:z.network_type},...z.network_rtt&&{network_rtt:z.network_rtt},...z.network_downlink&&{network_downlink:z.network_downlink},...z.account_currency&&{account_currency:z.account_currency},...z.account_mode&&{account_mode:z.account_mode},loggedIn:!!z.loggedIn,...z.user_id&&!Ni(z.user_id)&&{user_id:z.user_id},...Ct&&{anonymous_id:Ct}}}ee??(ee={}),ee.attributes??(ee.attributes={});let Be=n?.getAnonymousId();if((Re=ee.attributes).id??(Re.id=Be),(xe=ee.attributes).country??(xe.country=Me),P){s("initialise | initializing GrowthBook");let{Growthbook:z}=await Promise.resolve().then(()=>(wh(),Eh));i=z.getGrowthBookInstance(P,U,ee,e),s("initialise | GrowthBook initialized");let Ct=setInterval(()=>{Object.keys(a).length>0?clearInterval(Ct):a=v("tracking-buttons-config",{})},1e3)}if(le){s("initialise | initializing PostHog");let{Posthog:z}=await Promise.resolve().then(()=>(Mv(),Nv));r=z.getPosthogInstance({app_version:W,...le},e),s("initialise | PostHog initialized")}s("initialise | analytics initialization complete")}catch(Me){console.warn("Analytics: Failed to initialize",Me)}},p=P=>{s("setAttributes | received attributes",P);let{user_id:U,...V}=P,W=U??A();if(i){let ee={...V};U&&!Ni(U)&&(ee.user_id=U),W&&(ee.id=W,ee.user_id=W),s("setAttributes | called GrowthBook setAttributes",ee),i.setAttributes(ee)}o={...o,...Object.fromEntries(Object.entries(V).filter(([,ee])=>ee!==void 0)),...U!==void 0&&!Ni(U)&&{user_id:U}},s("setAttributes | updated core_data",o)},m=P=>i?.getFeatureState(P)?.experimentResult?.name,v=(P,U)=>i?.getFeatureValue(P,U),b=async()=>await i?.getStatus(),y=P=>i?.isOn(P),w=P=>i?.setUrl(P),A=()=>{let P=n?.getUserId()||"";return P&&!Ni(P)?P:""},Q={initialise:g,setAttributes:p,identifyEvent:(P,U)=>{let V=P||A();if(!V){s("identifyEvent | skipped \u2014 no user_id available");return}s("identifyEvent | called",{user_id:V,traits:U});let W=Re=>{if(!Re)return Re;let{email:xe,...Me}=Re;return{...Me,...xe&&{is_internal:sr(xe)}}},ee=U?.rudderstack!==void 0||U?.posthog!==void 0,le,_e;if(ee){let{rudderstack:Re,posthog:xe,...Me}=U;le=W({...Me,...Re}),_e=W({...Me,...xe})}else le=W(U),_e=W(U);n&&(n.has_initialized?(s("identifyEvent | calling RudderStack identify",{user_id:V,traits:le}),n.identifyEvent(V,le)):c.some(Re=>Re.userId===V)||(s("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:V}),c.push({userId:V,traits:le}))),r?.has_initialized&&(s("identifyEvent | calling PostHog identify",{user_id:V,traits:_e}),r.identifyEvent(V,_e))},backfillPersonProperties:({user_id:P,email:U,language:V,country_of_residence:W})=>{s("backfillPersonProperties | called",{user_id:P}),r?.has_initialized?(s("backfillPersonProperties | backfilling person properties in PostHog",{user_id:P}),r.backfillPersonProperties({user_id:P,email:U,language:V,country_of_residence:W})):s("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:m,getFeatureValue:v,getGrowthbookStatus:b,isFeatureOn:y,setUrl:w,getId:A,getAnonymousId:()=>n?.getAnonymousId()||"",trackEvent:(P,U)=>{let V=A();s("trackEvent | called",{event:P,analytics_data:U,userId:V,core_data:o});let W={...o,...U,...V&&!o.user_id&&{user_id:V}};if(s("trackEvent | built payload",{event:P,final_payload:W}),!(!(P in a)||a[P])){s("trackEvent | skipped \u2014 event disabled by tracking_config",{event:P});return}let le=n?.has_initialized;if(!navigator.onLine||!le)le?(s("trackEvent | offline \u2014 caching event to memory",{event:P}),l.push({event:P,payload:W})):(s("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:P}),wd(P,W));else{l.length>0&&(s(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(Re=>{let xe=ms(Re.payload);n?.track(Re.event,xe)}),l=[]);let _e=ms(W);s("trackEvent | sending event to RudderStack",{event:P,payload:_e}),n?.track(P,_e)}if(r?.has_initialized){let _e=ms(Ed(W));s("trackEvent | sending event to PostHog",{event:P,payload:_e}),r.capture(P,_e)}},getInstances:()=>({ab:i,tracking:n,posthog:r}),pageView:(P,U="Deriv App",V)=>{let W=A();s("pageView | called",{current_page:P,platform:U,properties:V,userId:W}),n?.has_initialized?(s("pageView | sending page view to RudderStack",{current_page:P,platform:U}),n.pageView(P,U,W,V)):(s("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:P}),Sd(P,{platform:U,...V}))},reset:()=>{s("reset | resetting all providers"),n?.has_initialized&&(s("reset | resetting RudderStack"),n.reset()),r?.has_initialized&&(s("reset | resetting PostHog"),r.reset())},isPosthogFeatureEnabled:P=>r?.isFeatureEnabled(P),getPosthogFeatureFlag:P=>r?.getFeatureFlag(P),getPosthogFeatureFlagPayload:P=>r?.getFeatureFlagPayload(P),getPosthogAllFlags:()=>r?.getAllFlags()??{},onPosthogFeatureFlags:P=>r?.onFeatureFlags(P)??(()=>{}),reloadPosthogFeatureFlags:()=>r?.reloadFeatureFlags()};return typeof window<"u"&&(window.AnalyticsInstance=Q),Q}var Fv=WT();return Kv(KT);})();
8
8
  /*! Bundled license information:
9
9
 
10
10
  js-cookie/dist/js.cookie.mjs: