@deriv-com/analytics 1.38.8 → 1.38.10
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.
- package/README.md +38 -8
- package/dist/browser/analytics.bundle.global.js +12 -12
- package/dist/browser/analytics.bundle.global.js.map +1 -1
- package/dist/browser/analytics.esm.mjs +1 -7
- package/dist/browser/analytics.esm.mjs.map +1 -1
- package/dist/chunk-7CT4XR74.mjs +3 -0
- package/dist/chunk-7CT4XR74.mjs.map +1 -0
- package/dist/chunk-BVGYK54Z.js +4 -0
- package/dist/chunk-BVGYK54Z.js.map +1 -0
- package/dist/chunk-D2MKQCJB.mjs +3 -0
- package/dist/chunk-D2MKQCJB.mjs.map +1 -0
- package/dist/chunk-FE5YWK6A.js +3 -0
- package/dist/chunk-FE5YWK6A.js.map +1 -0
- package/dist/chunk-ID2GN2PS.mjs +4 -0
- package/dist/chunk-ID2GN2PS.mjs.map +1 -0
- package/dist/chunk-ILN7DKKL.js +3 -0
- package/dist/chunk-ILN7DKKL.js.map +1 -0
- package/dist/chunk-OB6HH25Z.mjs +9 -0
- package/dist/chunk-OB6HH25Z.mjs.map +1 -0
- package/dist/chunk-YGU4ZMIH.mjs +14 -0
- package/dist/chunk-YGU4ZMIH.mjs.map +1 -0
- package/dist/growthbook-3K6VUME4.mjs +3 -0
- package/dist/growthbook-3K6VUME4.mjs.map +1 -0
- package/dist/index.d.mts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -3
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/metafile-iife.json +1 -1
- package/dist/posthog-ANAV4RFJ.mjs +6 -0
- package/dist/posthog-ANAV4RFJ.mjs.map +1 -0
- package/dist/{posthog-Df2P2mKj.d.mts → posthog-Ds4g1sJf.d.mts} +21 -7
- package/dist/{posthog-BXTVRi7y.d.ts → posthog-DvDj4azD.d.ts} +21 -7
- package/dist/providers/growthbook/index.d.mts +5 -3
- package/dist/providers/growthbook/index.d.ts +5 -3
- package/dist/providers/growthbook/index.js +2 -2
- package/dist/providers/growthbook/index.js.map +1 -1
- package/dist/providers/growthbook/index.mjs +2 -2
- package/dist/providers/growthbook/index.mjs.map +1 -1
- package/dist/providers/posthog/index.d.mts +1 -1
- package/dist/providers/posthog/index.d.ts +1 -1
- package/dist/providers/posthog/index.js +2 -2
- package/dist/providers/posthog/index.js.map +1 -1
- package/dist/providers/posthog/index.mjs +2 -2
- package/dist/providers/posthog/index.mjs.map +1 -1
- package/dist/providers/rudderstack/index.d.mts +5 -2
- package/dist/providers/rudderstack/index.d.ts +5 -2
- package/dist/providers/rudderstack/index.js +1 -1
- package/dist/providers/rudderstack/index.mjs +1 -1
- package/dist/utils/analytics-cache/index.d.mts +14 -5
- package/dist/utils/analytics-cache/index.d.ts +14 -5
- package/dist/utils/analytics-cache/index.js +1 -1
- package/dist/utils/analytics-cache/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-3LFZFQL4.mjs +0 -3
- package/dist/chunk-3LFZFQL4.mjs.map +0 -1
- package/dist/chunk-CAKVOFLO.js +0 -3
- package/dist/chunk-CAKVOFLO.js.map +0 -1
- package/dist/chunk-DNCZM4KN.mjs +0 -4
- package/dist/chunk-DNCZM4KN.mjs.map +0 -1
- package/dist/chunk-EMF3RT6E.mjs +0 -14
- package/dist/chunk-EMF3RT6E.mjs.map +0 -1
- package/dist/chunk-HQX3Z7PF.mjs +0 -3
- package/dist/chunk-HQX3Z7PF.mjs.map +0 -1
- package/dist/chunk-LKLVBL24.js +0 -3
- package/dist/chunk-LKLVBL24.js.map +0 -1
- package/dist/chunk-NOEKD4DT.js +0 -4
- package/dist/chunk-NOEKD4DT.js.map +0 -1
- package/dist/chunk-UDVSKE3Y.mjs +0 -3
- package/dist/chunk-UDVSKE3Y.mjs.map +0 -1
- package/dist/growthbook-NJGOOJH4.mjs +0 -3
- package/dist/growthbook-NJGOOJH4.mjs.map +0 -1
- package/dist/posthog-72HGN74H.mjs +0 -6
- package/dist/posthog-72HGN74H.mjs.map +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/* @deriv-com/analytics - Browser IIFE Bundle (RudderStack + PostHog) - Built with tsup */
|
|
2
|
-
"use strict";var DerivAnalytics=(()=>{var
|
|
3
|
-
`).filter(function(u){return!!u.match(
|
|
4
|
-
`).filter(function(u){return!u.match(o)},this);return c.map(function(u){if(u.indexOf(" > eval")>-1&&(u=u.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),u.indexOf("@")===-1&&u.indexOf(":")===-1)return new
|
|
2
|
+
"use strict";var DerivAnalytics=(()=>{var Lr=Object.defineProperty;var ff=Object.getOwnPropertyDescriptor;var gf=Object.getOwnPropertyNames;var pf=Object.prototype.hasOwnProperty;var vf=(i,e,t)=>e in i?Lr(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Re=(i,e)=>()=>(i&&(e=i(i=0)),e);var ds=(i,e)=>{for(var t in e)Lr(i,t,{get:e[t],enumerable:!0})},_f=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gf(e))!pf.call(i,n)&&n!==t&&Lr(i,n,{get:()=>e[n],enumerable:!(r=ff(e,n))||r.enumerable});return i};var mf=i=>_f(Lr({},"__esModule",{value:!0}),i);var ie=(i,e,t)=>vf(i,typeof e!="symbol"?e+"":e,t);function ne(i){return i!=null&&typeof i=="object"&&i["@@functional/placeholder"]===!0}function dt(i){return function e(t){return arguments.length===0||ne(t)?e:i.apply(this,arguments)}}function Tt(i){return function e(t,r){switch(arguments.length){case 0:return e;case 1:return ne(t)?e:dt(function(n){return i(t,n)});default:return ne(t)&&ne(r)?e:ne(t)?dt(function(n){return i(n,r)}):ne(r)?dt(function(n){return i(t,n)}):i(t,r)}}}function Xs(i){return function e(t,r,n){switch(arguments.length){case 0:return e;case 1:return ne(t)?e:Tt(function(s,o){return i(t,s,o)});case 2:return ne(t)&&ne(r)?e:ne(t)?Tt(function(s,o){return i(s,r,o)}):ne(r)?Tt(function(s,o){return i(t,s,o)}):dt(function(s){return i(t,r,s)});default:return ne(t)&&ne(r)&&ne(n)?e:ne(t)&&ne(r)?Tt(function(s,o){return i(s,o,n)}):ne(t)&&ne(n)?Tt(function(s,o){return i(s,r,o)}):ne(r)&&ne(n)?Tt(function(s,o){return i(t,s,o)}):ne(t)?dt(function(s){return i(s,r,n)}):ne(r)?dt(function(s){return i(t,s,n)}):ne(n)?dt(function(s){return i(t,r,s)}):i(t,r,n)}}}function Mr(i,e){return Object.prototype.hasOwnProperty.call(e,i)}function El(i){return Object.prototype.toString.call(i)==="[object Object]"}function Ef(i,e){var t=i<0?e.length+i:i;return e[t]}function kf(i){return new RegExp(i.source,i.flags?i.flags:(i.global?"g":"")+(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.sticky?"y":"")+(i.unicode?"u":"")+(i.dotAll?"s":""))}function nc(i,e,t){if(t||(t=new wf),Sf(i))return i;var r=function(s){var o=t.get(i);if(o)return o;t.set(i,s);for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(s[a]=nc(i[a],!0,t));return s};switch(yf(i)){case"Object":return r(Object.create(Object.getPrototypeOf(i)));case"Array":return r(Array(i.length));case"Date":return new Date(i.valueOf());case"RegExp":return kf(i);case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return i.slice();default:return i}}function Sf(i){var e=typeof i;return i==null||e!="object"&&e!="function"}function Af(i,e){for(var t=e,r=0;r<i.length;r+=1){if(t==null)return;var n=i[r];bf(n)?t=Ef(n,t):t=t[n]}return t}function Hf(i){return crypto.getRandomValues(new Uint8Array(i))}function qf(){(!gs||It+16>Sl)&&(gs=Hf(Sl),It=0);for(var i=0,e,t="";i<16;i++)e=gs[It+i],i==6?t+=Vr[e&15|64]:i==8?t+=Vr[e&63|128]:t+=Vr[e],i&1&&i>1&&i<11&&(t+="-");return It+=16,t}function zf(){var i=0,e,t="";if(!Ur||jt+16>256){for(Ur=Array(i=256);i--;)Ur[i]=256*Math.random()|0;i=jt=0}for(;i<16;i++)e=Ur[jt+i],i==6?t+=Gr[e&15|64]:i==8?t+=Gr[e&63|128]:t+=Gr[e],i&1&&i>1&&i<11&&(t+="-");return jt++,t}function yg(i,e,t=mg){let r;return(...n)=>{globalThis.clearTimeout(r),r=globalThis.setTimeout(()=>{i.apply(e,n)},t)}}function on(){if(Rt>1)Rt--;else{for(var i,e=!1;Ki!==void 0;){var t=Ki;for(Ki=void 0,ws++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&yc(t))try{t.c()}catch(n){e||(i=n,e=!0)}t=r}}if(ws=0,Rt--,e)throw i}}function ke(i){if(Rt>0)return i();Rt++;try{return i()}finally{on()}}function _c(i){var e=H;H=void 0;try{return i()}finally{H=e}}function mc(i){if(H!==void 0){var e=i.n;if(e===void 0||e.t!==H)return e={i:0,S:i,p:H.s,n:void 0,t:H,e:void 0,x:void 0,r:e},H.s!==void 0&&(H.s.n=e),H.s=e,i.n=e,32&H.f&&i.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=H.s,e.n=void 0,H.s.n=e,H.s=e),e}}function we(i,e){this.v=i,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function y(i,e){return new we(i,e)}function yc(i){for(var e=i.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 bc(i){for(var e=i.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){i.s=e;break}}}function Ec(i){for(var e=i.s,t=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}i.s=t}function hi(i,e){we.call(this,void 0),this.x=i,this.s=void 0,this.g=en-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function kc(i){var e=i.u;if(i.u=void 0,typeof e=="function"){Rt++;var t=H;H=void 0;try{e()}catch(r){throw i.f&=-2,i.f|=8,io(i),r}finally{H=t,on()}}}function io(i){for(var e=i.s;e!==void 0;e=e.n)e.S.U(e);i.x=void 0,i.s=void 0,kc(i)}function Pg(i){if(H!==this)throw new Error("Out-of-order effect");Ec(this),H=i,this.f&=-2,8&this.f&&io(this),on()}function fi(i,e){this.x=i,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}function it(i,e){var t=new fi(i,e);try{t.c()}catch(n){throw t.d(),n}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}function Pc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function sv(){return Ml||(Ml=1,(function(i,e){(function(t,r){i.exports=r()})(nv,function(){function t(v){return!isNaN(parseFloat(v))&&isFinite(v)}function r(v){return v.charAt(0).toUpperCase()+v.substring(1)}function n(v){return function(){return this[v]}}var s=["isConstructor","isEval","isNative","isToplevel"],o=["columnNumber","lineNumber"],a=["fileName","functionName","source"],l=["args"],c=["evalOrigin"],u=s.concat(o,a,l,c);function h(v){if(v)for(var _=0;_<u.length;_++)v[u[_]]!==void 0&&this["set"+r(u[_])](v[u[_]])}h.prototype={getArgs:function(){return this.args},setArgs:function(v){if(Object.prototype.toString.call(v)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=v},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(v){if(v instanceof h)this.evalOrigin=v;else if(v instanceof Object)this.evalOrigin=new h(v);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var v=this.getFileName()||"",_=this.getLineNumber()||"",b=this.getColumnNumber()||"",E=this.getFunctionName()||"";return this.getIsEval()?v?"[eval] ("+v+":"+_+":"+b+")":"[eval]:"+_+":"+b:E?E+" ("+v+":"+_+":"+b+")":v+":"+_+":"+b}},h.fromString=function(_){var b=_.indexOf("("),E=_.lastIndexOf(")"),D=_.substring(0,b),N=_.substring(b+1,E).split(","),R=_.substring(E+1);if(R.indexOf("@")===0)var K=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(R,""),B=K[1],C=K[2],pe=K[3];return new h({functionName:D,args:N||void 0,fileName:B,lineNumber:C||void 0,columnNumber:pe||void 0})};for(var g=0;g<s.length;g++)h.prototype["get"+r(s[g])]=n(s[g]),h.prototype["set"+r(s[g])]=(function(v){return function(_){this[v]=!!_}})(s[g]);for(var f=0;f<o.length;f++)h.prototype["get"+r(o[f])]=n(o[f]),h.prototype["set"+r(o[f])]=(function(v){return function(_){if(!t(_))throw new TypeError(v+" must be a Number");this[v]=Number(_)}})(o[f]);for(var p=0;p<a.length;p++)h.prototype["get"+r(a[p])]=n(a[p]),h.prototype["set"+r(a[p])]=(function(v){return function(_){this[v]=String(_)}})(a[p]);return h})})(zr)),zr.exports}function av(){return Fl||(Fl=1,(function(i,e){(function(t,r){i.exports=r(sv())})(ov,function(r){var n=/(^|@)\S+:\d+/,s=/^\s*at .*(\S+:\d+|\(native\))/m,o=/^(eval@)?(\[native code])?$/;return{parse:function(l){if(typeof l.stacktrace<"u"||typeof l["opera#sourceloc"]<"u")return this.parseOpera(l);if(l.stack&&l.stack.match(s))return this.parseV8OrIE(l);if(l.stack)return this.parseFFOrSafari(l);throw new Error("Cannot parse given Error object")},extractLocation:function(l){if(l.indexOf(":")===-1)return[l];var c=/(.+?)(?::(\d+))?(?::(\d+))?$/,u=c.exec(l.replace(/[()]/g,""));return[u[1],u[2]||void 0,u[3]||void 0]},parseV8OrIE:function(l){var c=l.stack.split(`
|
|
3
|
+
`).filter(function(u){return!!u.match(s)},this);return c.map(function(u){u.indexOf("(eval ")>-1&&(u=u.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var h=u.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),g=h.match(/ (\(.+\)$)/);h=g?h.replace(g[0],""):h;var f=this.extractLocation(g?g[1]:h),p=g&&h||void 0,v=["eval","<anonymous>"].indexOf(f[0])>-1?void 0:f[0];return new r({functionName:p,fileName:v,lineNumber:f[1],columnNumber:f[2],source:u})},this)},parseFFOrSafari:function(l){var c=l.stack.split(`
|
|
4
|
+
`).filter(function(u){return!u.match(o)},this);return c.map(function(u){if(u.indexOf(" > eval")>-1&&(u=u.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),u.indexOf("@")===-1&&u.indexOf(":")===-1)return new r({functionName:u});var h=/((.*".+"[^@]*)?[^@]*)(?:@)/,g=u.match(h),f=g&&g[1]?g[1]:void 0,p=this.extractLocation(u.replace(h,""));return new r({functionName:f,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:u})},this)},parseOpera:function(l){return!l.stacktrace||l.message.indexOf(`
|
|
5
5
|
`)>-1&&l.message.split(`
|
|
6
6
|
`).length>l.stacktrace.split(`
|
|
7
7
|
`).length?this.parseOpera9(l):l.stack?this.parseOpera11(l):this.parseOpera10(l)},parseOpera9:function(l){for(var c=/Line (\d+).*script (?:in )?(\S+)/i,u=l.message.split(`
|
|
8
|
-
`),h=[],g=2,f=u.length;g<f;g+=2){var p=c.exec(u[g]);p&&h.push(new
|
|
9
|
-
`),h=[],g=0,f=u.length;g<f;g+=2){var p=c.exec(u[g]);p&&h.push(new
|
|
10
|
-
`).filter(function(u){return!!u.match(s)&&!u.match(/^Error created at/)},this);return c.map(function(u){var h=u.split("@"),g=this.extractLocation(h.pop()),f=h.shift()||"",p=f.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,v;f.match(/\(([^)]*)\)/)&&(v=f.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var _=v===void 0||v==="[arguments not available]"?void 0:v.split(",");return new i({functionName:p,args:_,fileName:g[0],lineNumber:g[1],columnNumber:g[2],source:u})},this)}}})})(Bi)),Bi.exports}function xl(n,e,t,i){return{errorClass:Dl(n),message:`${t}${Dl(e)}`,type:"browserjs",stacktrace:i.reduce((s,r)=>{let o=ev(r);try{return JSON.stringify(o)==="{}"?s:s.concat(o)}catch{return s}},[])}}function xc(n,e){let t=Object.assign(n,e);for(let i of Object.keys(t))typeof t[i]=="object"&&typeof e[i]=="object"&&(t[i]=xc(t[i],e[i]));return t}async function Mv(n){let e=Lv[n];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((t,i)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(r=>{import(r).then(o=>{if(!e.inited){let a=Fv();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}t(e.lib)}).catch(i)})})}function Oe(n,e){if(!n?.default&&e){let t=Object.create(null);return t.default=n,t.__esModule=!0,t}return n}function Ce(n,e){return Mv(n).then(t=>t.get(e).then(i=>i()))}function p_(){return Vl||(Vl=1,(function(n,e){(function(t,i){n.exports=i()})(g_,function(){function t(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 s(f){if(typeof f=="string")try{return JSON.parse(f)}catch{return f}}function r(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",v="yes";try{f||(f=window.localStorage),f.setItem(p,v),f.removeItem(p)}catch{var _={};_._data={},_.setItem=function(b,C){return _._data[b]=String(C)},_.getItem=function(b){return _._data.hasOwnProperty(b)?_._data[b]:void 0},_.removeItem=function(b){return delete _._data[b]},_.clear=function(){return _._data={}},f=_}finally{f.getItem(p)===v&&f.removeItem(p)}return f}var l=a();function c(){if(!(this instanceof c))return new c}c.prototype={set:function(p,v){if(p&&!t(p))l.setItem(p,i(v));else if(t(p))for(var _ in p)this.set(_,p[_]);return this},get:function(p){if(p===void 0){var v={};return this.forEach(function(I,K){return v[I]=K}),v}if(p.charAt(0)==="?")return this.has(p.substr(1));var _=arguments;if(_.length>1){for(var E={},b=0,C=_.length;b<C;b++){var N=s(l.getItem(_[b]));this.has(_[b])&&(E[_[b]]=N)}return E}return s(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var v=this.get(p);return l.removeItem(p),v},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(v){p.push(v)}),p},forEach:function(p){for(var v=0,_=l.length;v<_;v++){var E=l.key(v);p(E,this.get(E))}return this},search:function(p){for(var v=this.keys(),_={},E=0,b=v.length;E<b;E++)v[E].indexOf(p)>-1&&(_[v[E]]=this.get(v[E]));return _},len:function(){return l.length}};var u=null;function h(f,p){var v=arguments,_=null;if(u||(u=c()),v.length===0)return u.get();if(v.length===1){if(typeof f=="string")return u.get(f);if(t(f))return u.set(f)}if(v.length===2&&typeof f=="string"){if(!p)return u.remove(f);if(p&&typeof p=="string")return u.set(f,p);p&&r(p)&&(_=null,_=p(f,u.get(f)),h.set(f,_))}if(v.length===2&&o(f)&&r(p))for(var E=0,b=f.length;E<b;E++)_=p(f[E],u.get(f[E])),h.set(f[E],_);return h}for(var g in c.prototype)h[g]=c.prototype[g];return h})})(ji)),ji.exports}var df,hf,vf,V,mf,yf,bf,Ef,Zl,T,J,Ne,_e,Ye,kf,z,nn,Sf,qr,wf,pr,Af,Tf,If,Q,Rf,ge,lt,$n,qi,st,Qe,Kr,Of,vl,Ki,Cf,Pf,zi,zr,ec,tc,nc,or,Wr,vr,Ve,ic,Ni,Lt,Ln,Qt,Nf,ar,Df,xf,$f,Di,_l,Li,kt,lr,Ut,Fi,xi,Uf,Qi,Bf,sc,Vf,rc,Gf,x,jf,ml,Hf,qf,Kf,zf,Wf,Yf,Xf,oc,Jf,We,Qf,ac,G,Mi,Zi,Yr,re,yl,Bn,Zf,lc,bl,eg,tg,Mn,ng,ig,sg,El,rg,kl,og,ag,Sl,_r,wl,lg,cg,cc,Vn,uc,Al,dg,hg,fg,gg,pg,vg,_g,mg,yg,bg,Wi,Eg,j,Un,St,mr,Yi,yr,$i,Tl,_c,Sg,wg,Ag,br,ct,rt,mc,Er,Il,Tg,Ig,Rg,Og,Cg,Pg,Ng,Dg,Rl,xg,$g,Lg,Fg,Mg,Ug,Bg,Ol,Vg,Gg,yc,jg,Hg,qg,Kg,zg,Wg,Yg,Cl,Xg,Jg,Qg,Zg,ep,tp,np,ip,sp,rp,op,ap,lp,cp,up,dp,hp,fp,gp,pp,vp,_p,mp,yp,bp,Ep,bc,ts,Ec,kp,Gn,ns,Jr,kc,Sc,wc,Ft,Sp,kr,Ui,wp,Ap,Tp,Ip,Rp,Op,q,cr,Cp,Pp,Np,Dp,xp,$p,Lp,Fp,Mp,Up,Bp,Vp,Gp,jp,Hp,qp,Kp,d,Bi,Vi,zp,Pl,Yp,Nl,Jp,Qp,Tc,Zp,ev,Dl,Ic,tv,$l,Gi,nv,iv,sv,rv,ov,av,lv,cv,Ll,Fl,Sr,Rc,uv,dv,hv,fv,gv,pv,vv,Oc,_v,mv,yv,bv,Ev,kv,Sv,wv,Av,Tv,Cc,Pc,Iv,Rv,Ov,Cv,wr,Nc,Ar,Pv,Nv,Dv,Ml,xv,Dc,$v,Lv,Fv,Uv,Bv,$c,Vv,Gv,ur,jv,Tr,Pe,$e,Be,Ze,Bt,Hv,qv,Kv,zv,Wv,Yv,Xv,Jv,Qv,Zv,e_,t_,Zt,n_,Lc,Fc,i_,Mc,Uc,en,Ul,Bl,s_,r_,Ir,o_,ot,a_,l_,c_,u_,d_,h_,f_,Rr,Xi,ji,g_,Vl,v_,$t,Bc,tn,Or,Qr,Cr,Zr,Pr,eo,ze,__,m_,y_,b_,E_,Nr,k_,Dr,S_,w_,Vc,A_,T_,I_,sn,xr,Gc,R_,O_,C_,rn,dr,hr,P_,N_,D_,Gl,x_,jc,$_,L_,F_,M_,U_,B_,V_,G_,j_,Hc,H_,q_,$r,K_,qc,z_,W_,Y_,Kc,X_,J_,Lr,Q_,Z_,em,tm,jl,nm,Hl,im,ql,Fr,sm,rm,Kl,fr,zc,om,Ji,zl,Wc,Wl,am,lm,cm,um,dm,Fn,Mr,hm,fm,gm,gr,pm,vm,_m,mm,ym,xn,Ur,Br,Vr,bm,Em,Yl,Xl,km,Sm,wm,Am,Hi,Gr,Jl,Tm,Im,jr,Mt,on,to=Ue(()=>{"use strict";df=at(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});hf=Number.isInteger||function(e){return e<<0===e};vf=(function(){function n(){this.map={},this.length=0}return n.prototype.set=function(e,t){var i=this.hash(e),s=this.map[i];s||(this.map[i]=s=[]),s.push([e,t]),this.length+=1},n.prototype.hash=function(e){var t=[];for(var i in e)t.push(Object.prototype.toString.call(e[i]));return t.join()},n.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var o=this.map[t],i=0;i<o.length;i+=1){var s=o[i];if(s[0]===e)return s[1]}return}var r=this.hash(e),o=this.map[r];if(o)for(var i=0;i<o.length;i+=1){var s=o[i];if(s[0]===e)return s[1]}},n})(),V=at(function(e){return e!=null&&typeof e.clone=="function"?e.clone():Ql(e)});mf=Hr(function(e,t,i){var s={},r;t=t||{},i=i||{};for(r in t)Pi(r,t)&&(s[r]=Pi(r,i)?e(r,t[r],i[r]):t[r]);for(r in i)Pi(r,i)&&!Pi(r,s)&&(s[r]=i[r]);return s}),yf=Hr(function n(e,t,i){return mf(function(s,r,o){return pl(r)&&pl(o)?n(e,r,o):e(s,r,o)},t,i)}),bf=Hr(function(e,t,i){return yf(function(s,r,o){return e(r,o)},t,i)}),Ef=Et(_f),Zl=Et(function(e,t){var i={};for(var s in t)e(t[s],s,t)&&(i[s]=t[s]);return i}),T=n=>typeof n=="function"&&!!(n.constructor&&n.call&&n.apply),J=n=>typeof n=="string",Ne=n=>n===null,_e=n=>typeof n>"u",Ye=n=>Ne(n)||_e(n),kf=n=>typeof n=="bigint",z=n=>!_e(n),nn=n=>!Ye(n),Sf=n=>nn(n)&&n!=="",qr=n=>{switch(Object.prototype.toString.call(n)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return n instanceof Error}},wf=n=>typeof n=="boolean",pr=(n,e)=>{let t=e.split(".");return Ef(t,n)},Af=(n,e)=>!!pr(n,e),Tf=n=>typeof n=="object",If=n=>!Ne(n)&&Tf(n)&&!Array.isArray(n),Q=n=>!Ne(n)&&Object.prototype.toString.call(n)==="[object Object]",Rf=(n,e)=>{if(!Array.isArray(n)||!Array.isArray(e))return V(e);let t=V(n);return e.forEach((i,s)=>{t[s]=Array.isArray(i)||If(i)?ge(t[s],i):i}),t},ge=(n,e)=>bf(Rf,n,e),lt=n=>Q(n)&&Object.keys(n).length>0,$n=n=>{let e=Zl(z,n);return Object.keys(e).forEach(t=>{let i=e[t];Q(i)&&(e[t]=$n(i))}),e},qi=n=>{let e=Zl(nn,n);return Object.keys(e).forEach(t=>{let i=e[t];Q(i)&&(e[t]=qi(i))}),e},st=n=>{if(lt(n))return qi(n)},Qe=(n,e)=>typeof n=="boolean"?n:e,Kr=n=>(Object.getOwnPropertyNames(n).forEach(function(e){n[e]&&typeof n[e]=="object"&&Kr(n[e])}),Object.freeze(n)),Of=n=>n.replace(/^\s+|\s+$/gm,""),vl=n=>n.replace(/^\.+/,""),Ki=n=>{let e=n;if(!J(n)&&!Ye(n))try{e=JSON.stringify(n)}catch{e=null}return e},Cf=n=>{let e=Array.from(n,t=>String.fromCodePoint(t)).join("");return globalThis.btoa(e)},Pf=n=>Cf(new TextEncoder().encode(n)),zi=(n,e,t,i,s)=>{let r={category:n,name:e,properties:t,options:i,callback:void 0};T(s)&&(r.callback=s),T(i)&&(r.category=n,r.name=e,r.properties=t,r.options=void 0,r.callback=i),T(t)&&(r.category=n,r.name=e,r.properties=void 0,r.options=void 0,r.callback=t),T(e)&&(r.category=n,r.name=void 0,r.properties=void 0,r.options=void 0,r.callback=e),T(n)&&(r.category=void 0,r.name=void 0,r.properties=void 0,r.options=void 0,r.callback=n),Q(n)?(r.name=void 0,r.category=void 0,r.properties=n,T(e)?r.options=void 0:r.options=e):Q(e)&&(r.name=void 0,r.properties=e,T(t)?r.options=void 0:r.options=t),J(n)&&!J(e)&&(r.category=void 0,r.name=n),z(r.category)||(r.category=void 0),z(r.name)||(r.name=void 0),r.properties=r.properties?V(r.properties):{},z(r.options)?r.options=V(r.options):r.options=void 0;let o=J(r.name)?r.name:r.properties.name,a=J(r.category)?r.category:r.properties.category;return r.properties=ge(Q(r.properties)?r.properties:{},{...o&&{name:o},...a&&{category:a}}),r},zr=(n,e,t,i)=>{let s={name:n,properties:e,options:t,callback:void 0};return T(i)&&(s.callback=i),T(t)&&(s.properties=e,s.options=void 0,s.callback=t),T(e)&&(s.properties=void 0,s.options=void 0,s.callback=e),s.properties=nn(s.properties)?V(s.properties):{},z(s.options)?s.options=V(s.options):s.options=void 0,s},ec=(n,e,t,i)=>{let s={userId:n,traits:e,options:t,callback:void 0};return T(i)&&(s.callback=i),T(t)&&(s.userId=n,s.traits=e,s.options=void 0,s.callback=t),T(e)&&(s.userId=n,s.traits=void 0,s.options=void 0,s.callback=e),(Q(n)||Ne(n))&&(s.userId=null,s.traits=n,T(e)?s.options=void 0:s.options=e),s.userId=Ki(s.userId),Q(s.traits)?s.traits=V(s.traits):s.traits=void 0,z(s.options)?s.options=V(s.options):s.options=void 0,s},tc=(n,e,t,i)=>{let s={to:n,from:e,options:t,callback:void 0};return T(i)&&(s.callback=i),T(t)&&(s.to=n,s.from=e,s.options=void 0,s.callback=t),T(e)?(s.to=n,s.from=void 0,s.options=void 0,s.callback=e):(Q(e)||Ne(e))&&(s.to=n,s.from=void 0,s.options=e),z(s.to)&&(s.to=Ki(s.to)),z(s.from)?s.from=Ki(s.from):s.from=void 0,z(s.options)?s.options=V(s.options):s.options=void 0,s},nc=(n,e,t,i)=>{let s={groupId:n,traits:e,options:t,callback:void 0};return T(i)&&(s.callback=i),T(t)&&(s.groupId=n,s.traits=e,s.options=void 0,s.callback=t),T(e)&&(s.groupId=n,s.traits=void 0,s.options=void 0,s.callback=e),(Q(n)||Ne(n))&&(s.groupId=null,s.traits=n,T(e)?s.options=void 0:s.options=e),s.groupId=Ki(s.groupId),Q(s.traits)?s.traits=V(s.traits):s.traits=void 0,z(s.options)?s.options=V(s.options):s.options=void 0,s},or=(function(n){return n.UNLOADED="Page Unloaded",n})({}),Wr="API",vr="CapabilitiesManager",Ve="ConfigManager",ic="EventManager",Ni="PluginsManager",Lt="UserSessionManager",Ln="ErrorHandler",Qt="PluginEngine",Nf="StoreManager",ar=`Ready${Wr}`,Df=`Load${Wr}`,xf="HttpClient",$f="RudderStackAnalytics",Di="AnalyticsCore";_l=4096,Li=[],kt=0;for(;kt<256;kt++)Li[kt]=(kt+256).toString(16).substring(1);Ut=256,Fi=[];for(;Ut--;)Fi[Ut]=(Ut+256).toString(16).substring(1);Uf=()=>!Ye(globalThis.crypto)&&T(globalThis.crypto.getRandomValues),Qi=()=>Uf()?Ff():Mf(),Bf=()=>!!window.chrome?.runtime?.id,sc=()=>J(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),Vf=(n,e=!1)=>{let t=!1,i=!1;function s(){t||(t=!0,n(i),setTimeout(()=>{t=!1},0))}(e||sc())&&globalThis.addEventListener("beforeunload",()=>{i=!1,s()}),globalThis.addEventListener("blur",()=>{i=!0,s()}),globalThis.addEventListener("focus",()=>{t=!1}),document.addEventListener("pagehide",()=>{i=document.visibilityState==="hidden",s()}),document.addEventListener("visibilitychange",()=>{i=!0,document.visibilityState==="hidden"?s():t=!1})},rc=n=>n.toISOString(),Gf=()=>rc(new Date),x=":: ",jf=n=>`A script with the id "${n}" is already loaded. Skipping the loading of this script to prevent conflicts`,ml=(n,e,t)=>`Unable to load (${J(t)?t:t.type}) the script with the id "${n}" from URL "${e}"`,Hf=(n,e,t)=>`A timeout of ${t} ms occurred while trying to load the script with id "${n}" from URL "${e}"`,qf=(n,e)=>`${n}${x}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,Kf="Failed to convert the value to a JSON string.",zf="Failed to encode the cookie data.",Wf=(n,e)=>`${n}${x}The "${e}" storage type is `,Yf="JSONStringify",Xf="[BigInt]",oc="[Circular Reference]",Jf=(n,e,t)=>{let i=[];return function(s,r){if(!e?.includes(s)&&!(n&&Ye(r))){if(typeof r!="object"||Ne(r))return r;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(r)?(t?.warn(qf(Yf,s)),oc):(i.push(r),r)}}},We=(n,e,t,i)=>{try{return JSON.stringify(n,Jf(e,t,i))}catch(s){return i?.warn(Kf,s),null}},Qf=n=>{let e=[];return function(i,s){if(kf(s))return Xf;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(s)?oc:(e.push(s),s)}},ac=(n,e)=>{let t=Array.isArray(n)?[]:{};for(let i in n)if(Object.hasOwnProperty.call(n,i)){let s=n[i],r=e.call(n,i,s);Q(r)||Array.isArray(r)?t[i]=ac(r,e):t[i]=r}return t},G=(n,e)=>{let t=Qf(),i=t.call(n,"",n);return Q(n)||Array.isArray(n)?ac(n,t):i},Mi="[SDK DISPATCHED ERROR]",Zi=n=>{let{stack:e,stacktrace:t,"opera#sourceloc":i}=n,s=e??t??i;if(s&&typeof s=="string")return s},Yr=(n,e)=>{if(!qr(n))return new Error(`${e}: ${We(n)}`);try{let t=n.constructor,i=new t(`${e}: ${n.message}`),s=Zi(n);return s&&(i.stack=s),Object.getOwnPropertyNames(n).forEach(r=>{if(r!=="message"&&r!=="stack"&&r!=="name")try{i[r]=n[r]}catch{}}),i}catch{return new Error(`${e}: ${We(n)}`)}},re=n=>{if(qr(n)){let e=Zi(n);if(e){let{stack:t,stacktrace:i,"opera#sourceloc":s}=n;switch(e){case t:n.stack=`${t}
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
${Mi}`;break}}}globalThis.dispatchEvent(new ErrorEvent("error",{error:n,bubbles:!0,cancelable:!0,composed:!0}))},yl="RudderLabs JavaScript SDK",Bn="3.28.1",Zf="com.rudderlabs.javascript",lc="npm",bl="RudderJS-Initiated",eg="ad-block page request",tg="/ad-blocked",Mn="preloadedEventsBuffer",ng="Consent Management Interaction",ig="ajs_trait_",sg="ajs_prop_",El="ajs_aid",rg="ajs_uid",kl="ajs_event",og=10*1e3,ag=31536e3*1e3,Sl=720*60*1e3,_r=1800*1e3,wl=10*1e3,lg=10*1e3,cg=250,cc=(n="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[n]||(globalThis.RudderStackGlobals[n]={})},Vn=(n,e,t="app")=>{cc(t),globalThis.RudderStackGlobals[t][n]=e},uc=(n,e="app")=>(cc(e),globalThis.RudderStackGlobals[e][n]);Al=(n,e)=>{let t={};return n.forEach((i,s)=>{if(s.startsWith(e)){let r=s.substring(e.length);t[r]=n.get(s)}}),t},dg=(n=[])=>{let e={trait:ig,properties:sg},t=new URLSearchParams(globalThis.location.search);t.get(kl)&&n.unshift(["track",t.get(kl),Al(t,e.properties)]);let i=t.get(rg),s=Al(t,e.trait);if(i||lt(s)){let r=[...i?[i]:[],s];n.unshift(["identify",...r])}t.get(El)&&n.unshift(["setAnonymousId",t.get(El)])},hg=n=>{let e="load",t=[],i=0;for(;i<n.length;){if(n[i]&&n[i][0]===e){t=V(n[i]),n.splice(i,1);break}i+=1}return t},fg=n=>{let e="consent",t=n.filter(s=>s[0]===e),i=n.filter(s=>s[0]!==e);n.splice(0,n.length,...t,...i)},gg=n=>{let e=uc(Mn)||[];dg(e),e.length>0&&(n.enqueuePreloadBufferEvents(e),Vn(Mn,[]))},pg=(n,e)=>{let t=n.shift(),i;if(T(e[t])){switch(t){case"page":i=zi(...n);break;case"track":i=zr(...n);break;case"identify":i=ec(...n);break;case"alias":i=tc(...n);break;case"group":i=nc(...n);break;default:e[t](...n);break}i&&e[t](i)}},vg=10*1e3,_g="RS_JS_SDK",mg=(n,e,t=!0,i=null,s=null,r={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=i,o.onerror=s,o.src=n,o.id=e,o.async=t,Object.keys(r).forEach(a=>{o.setAttribute(a,r[a])}),o.setAttribute("data-loader",_g),o},yg=n=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(n,e[0]?.firstChild);return}let t=document.getElementsByTagName("script");if(t.length>0&&t[0]?.parentNode){t[0]?.parentNode.insertBefore(n,t[0]);return}let i=document.createElement("head");i.appendChild(n);let s=document.getElementsByTagName("html")[0];s?.insertBefore(i,s.firstChild)},bg=(n,e,t,i=!0,s)=>new Promise((r,o)=>{document.getElementById(e)&&o(new Error(jf(e)));try{let l;yg(mg(n,e,i,()=>{globalThis.clearTimeout(l),r(e)},h=>{globalThis.clearTimeout(l),o(new Error(ml(e,n,h)))},s)),l=globalThis.setTimeout(()=>{o(new Error(Hf(e,n,t)))},t)}catch(l){o(Yr(l,ml(e,n,"unknown")))}}),Wi=class{constructor(e,t=vg){this.logger=e,this.timeout=t}loadJSFile(e){let{url:t,id:i,timeout:s,async:r,callback:o,extraAttributes:a}=e,l=!T(o);bg(t,i,s||this.timeout,r,a).then(c=>{l||o(c)}).catch(c=>{l||o(i,c)})}},Eg=Symbol.for("preact-signals");j=void 0;Un=void 0,St=0,mr=0,Yi=0;Te.prototype.brand=Eg;Te.prototype.h=function(){return!0};Te.prototype.S=function(n){var e=this,t=this.t;t!==n&&n.e===void 0&&(n.x=t,this.t=n,t!==void 0?t.e=n:dc(function(){var i;(i=e.W)==null||i.call(e)}))};Te.prototype.U=function(n){var e=this;if(this.t!==void 0){var t=n.e,i=n.x;t!==void 0&&(t.x=i,n.e=void 0),i!==void 0&&(i.e=t,n.x=void 0),n===this.t&&(this.t=i,i===void 0&&dc(function(){var s;(s=e.Z)==null||s.call(e)}))}};Te.prototype.subscribe=function(n){var e=this;return et(function(){var t=e.value,i=j;j=void 0;try{n(t)}finally{j=i}},{name:"sub"})};Te.prototype.valueOf=function(){return this.value};Te.prototype.toString=function(){return this.value+""};Te.prototype.toJSON=function(){return this.value};Te.prototype.peek=function(){var n=j;j=void 0;try{return this.value}finally{j=n}};Object.defineProperty(Te.prototype,"value",{get:function(){var n=hc(this);return n!==void 0&&(n.i=this.i),this.v},set:function(n){if(n!==this.v){if(mr>100)throw new Error("Cycle detected");this.v=n,this.i++,Yi++,St++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{es()}}}});an.prototype=new Te;an.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Yi))return!0;if(this.g=Yi,this.f|=1,this.i>0&&!fc(this))return this.f&=-2,!0;var n=j;try{gc(this),j=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return j=n,pc(this),this.f&=-2,!0};an.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}Te.prototype.S.call(this,n)};an.prototype.U=function(n){if(this.t!==void 0&&(Te.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};an.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var n=this.t;n!==void 0;n=n.x)n.t.N()}};Object.defineProperty(an.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var n=hc(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v}});ln.prototype.c=function(){var n=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{n()}};ln.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,vc(this),gc(this),St++;var n=j;return j=this,kg.bind(this,n)};ln.prototype.N=function(){2&this.f||(this.f|=2,this.o=Un,Un=this)};ln.prototype.d=function(){this.f|=8,1&this.f||Xr(this)};ln.prototype.dispose=function(){this.d()};yr=class{constructor(){this.items=[]}enqueue(e){this.items.push(e)}dequeue(){return this.items.length===0?null:this.items.shift()}isEmpty(){return this.items.length===0}size(){return this.items.length}clear(){this.items=[]}},$i={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Tl="LOG",_c="ERROR",Sg="RS SDK",wg="font-weight: bold; background: black; color: white;",Ag="font-weight: normal;",br=class{constructor(e=Tl,t="",i=console){this.minLogLevel=$i[e],this.scope=t,this.logProvider=i}log(...e){this.outputLog("LOG",e)}info(...e){this.outputLog("INFO",e)}debug(...e){this.outputLog("DEBUG",e)}warn(...e){this.outputLog("WARN",e)}error(...e){this.outputLog("ERROR",e)}outputLog(e,t){this.minLogLevel<=$i[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=$i[e],_e(this.minLogLevel)&&(this.minLogLevel=$i[Tl])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t=`%c ${Sg}`;this.scope&&(t=`${t} - ${this.scope}`);let i=J(e[0])?e[0].trim():"";t=`${t} %c ${i}`;let s=[t,wg,Ag];return J(e[0])||s.push(e[0]),s.push(...e.slice(1)),s}return e}},ct=new br,rt=(function(n){return n.HANDLEDEXCEPTION="handledException",n.UNHANDLEDEXCEPTION="unhandledException",n.UNHANDLEDREJECTION="unhandledPromiseRejection",n})({}),mc=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Er="cookieStorage",Il="Unable to process/parse source configuration response",Tg="The source is disabled. Please enable the source in the dashboard to send events.",Ig="Failed to prepare data for the request.",Rg="Failed to invoke plugin because the extension point name is missing.",Og="Failed to invoke plugin because the extension point name is invalid.",Cg=n=>`${n}${x}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,Pg=(n,e,t)=>`${n}${x}The base URL "${t}" for ${e} is not valid.`,Ng=(n,e,t)=>`${n}${x}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(t)}".`,Dg=(n,e)=>`${n}${x}Ignoring a non-error: ${e}.`,Rl="Failed to log breadcrumb",xg=n=>`${n}${x}Failed to handle the error.`,$g=n=>`${n}${x}Plugin name is missing.`,Lg=(n,e)=>`${n}${x}Plugin "${e}" already exists.`,Fg=(n,e)=>`${n}${x}Plugin "${e}" not found.`,Mg=(n,e)=>`${n}${x}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.`,Ug=(n,e,t)=>`${n}${x}Plugin "${e}" could not be loaded because some of its dependencies "${t}" do not exist.`,Bg=(n,e,t)=>`${n}${x}Failed to invoke the "${e}" extension point of plugin "${t}".`,Ol="Failed to fetch the source config",Vg=(n,e)=>`${n}${x}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,Gg=(n,e)=>`${n}${x}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.`,yc=n=>`${n}${x}The provided callback parameter is not a function.`,jg=(n,e,t,i,s)=>`${n} with status ${e} (${t}) for URL: ${i}. Response: ${s.trim()}`,Hg=(n,e,t)=>`${n} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${t}`,qg=(n,e)=>`${n} for URL: ${e}`,Kg=n=>`Failed to save the value for "${n}" to storage`,zg=n=>`Failed to retrieve or parse data for "${n}" from storage`,Wg=n=>`The server responded with status ${n} while setting the cookies. As a fallback, the cookies will be set client side.`,Yg=n=>`The server failed to set the ${n} cookie. As a fallback, the cookies will be set client side.`,Cl="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",Xg=(n,e,t)=>`${n}${x}The storage type "${e}" is not supported. Please choose one of the following supported types: "${mc}". The default type "${t}" will be used instead.`,Jg=(n,e,t,i)=>`${n}${x}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(t)}". The default version "${i}" will be used instead.`,Qg=(n,e,t)=>`${n}${x}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${t}). To enable storage data migration, please update the storage encryption version to the latest version.`,Zg=(n,e,t)=>`${n}${x}The provided cookie domain (${e}) does not match the current webpage's domain (${t}). Hence, the cookies will be set client-side.`,ep=(n,e,t,i)=>`${n}${x}The "${e}" property defined under "${t}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i}).`,tp=n=>`${n}${x}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,np=n=>`${n}${x}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,ip=(n,e,t)=>`${n}${x}The session timeout value "${e}" is not a number. The default timeout of ${t} ms will be used instead.`,sp=(n,e,t)=>`${n}${x}The session cut off duration value "${e}" is not a number. The default cut off duration of ${t} ms will be used instead.`,rp=(n,e,t)=>`${n}${x}The session cut off duration value "${e}" ms is less than the session timeout value "${t}" ms. The cut off functionality will be disabled.`,op=n=>`${n}${x}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.`,ap=(n,e,t)=>`${n}${x}The session timeout value ${e} ms is less than the recommended minimum of ${t} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,lp=(n,e,t)=>`${n}${x}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${t}" digits long. A new session ID will be auto-generated instead.`,cp=n=>`${n}${x}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,up=(n,e,t,i)=>`${n}${x}The storage type "${t}" is not available for entry "${e}". The SDK will initialize the entry with "${i}" storage type instead.`,dp=n=>`${n}${x}The callback threw an exception`,hp=(n,e)=>`${n}${x}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,fp=(n,e)=>`Failed to load the polyfill script with ID "${n}" from URL ${e}.`,gp=(n,e,t)=>`${n}${x}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${t}" will be used instead.`,pp=(n,e,t)=>`${n}${x}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${t}" will be used instead.`,vp=(n,e)=>`${n}${x}${e} plugin is deprecated. Please exclude it from the load API options.`,_p=(n,e,t,i)=>{let s=t.length===1,r=s?` '${t[0]}' plugin was`:` ['${t.join("', '")}'] plugins were`,o=`${n}${x}${e}, but${r} not configured to load.`;return i?`${o} So, ${s?"the plugin":"those plugins"} will be loaded automatically.`:`${o} Ignore if this was intentional. Otherwise, consider adding ${s?"it":"them"} to the 'plugins' load API option.`},mp=(n,e)=>`${n}${x}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,yp=n=>`${n}${x}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,bp=(n,e)=>`${n}${x}Ignoring unknown plugins: ${e.join(", ")}.`,Ep=(n,e)=>`${n}${x}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,bc={All:!0},ts="js-integrations",Ec="plugins",kp=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_]*)?$"),Gn="modern",ns="https://cdn.rudderlabs.com",Jr="v3",kc=`${ns}/${Jr}/${Gn}/${ts}`,Sc=`${ns}/${Jr}/${Gn}/${Ec}`,wc="https://api.rudderstack.com",Ft="v3",Sp="xhr",kr={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Ui={[Ft]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},wp={[Sp]:"XhrQueue",beacon:"BeaconQueue"},Ap="rsaRequest",Tp="rsaMetrics",Ip="Custom Device Mode",Rp={configUrl:wc,loadIntegration:!0,sessions:{autoTrack:!0,timeout:_r,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:bc,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:lg,storage:{encryption:{version:Ft},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},Op=y(V(Rp)),q=Kr({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),cr=Kr({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Cp=10,Pp={userId:y(q.userId),userTraits:y(q.userTraits),anonymousId:y(q.anonymousId),groupId:y(q.groupId),groupTraits:y(q.groupTraits),initialReferrer:y(q.initialReferrer),initialReferringDomain:y(q.initialReferringDomain),sessionInfo:y(q.sessionInfo),authToken:y(q.authToken)},Np={isOnline:y(!0),storage:{isLocalStorageAvailable:y(!1),isCookieStorageAvailable:y(!1),isSessionStorageAvailable:y(!1)},isBeaconAvailable:y(!1),isLegacyDOM:y(!1),isUaCHAvailable:y(!1),isCryptoAvailable:y(!1),isIE11:y(!1),isAdBlockerDetectionInProgress:y(!1),isAdBlocked:y(void 0),cspBlockedURLs:y([])},Dp={isErrorReportingEnabled:y(!1),isMetricsReportingEnabled:y(!1),breadcrumbs:y([])},xp=y(void 0),$p={activeDataplaneUrl:y(void 0),integrationsCDNPath:y(kc),pluginsCDNPath:y(Sc),sourceConfigUrl:y(void 0),status:y(void 0),initialized:y(!1),logLevel:y(_c),loaded:y(!1),readyCallbacks:y([]),writeKey:y(void 0),dataPlaneUrl:y(void 0),safeAnalyticsInstance:y(void 0)},Lp={enabled:y(!1),initialized:y(!1),data:y({}),activeConsentManagerPluginName:y(void 0),preConsent:y({enabled:!1}),postConsent:y({}),resolutionStrategy:y("and"),provider:y(void 0),metadata:y(void 0)},Fp={retries:y(0),dropped:y(0),sent:y(0),queued:y(0),triggered:y(0),metricsServiceUrl:y(void 0)},Mp={app:y({name:yl,namespace:Zf,version:Bn,installType:lc}),traits:y(null),library:y({name:yl,version:Bn,snippetVersion:globalThis.RudderSnippetVersion}),userAgent:y(null),device:y(null),network:y(null),os:y({name:"",version:""}),locale:y(null),screen:y({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":y(void 0),timezone:y(void 0)},Up={configuredDestinations:y([]),activeDestinations:y([]),loadOnlyIntegrations:y({}),failedDestinations:y([]),loadIntegration:y(!0),initializedDestinations:y([]),clientDestinationsReady:y(!1),integrationsConfig:y({})},Bp={toBeProcessedArray:y([]),readyCallbacksArray:y([])},Vp={ready:y(!1),loadedPlugins:y([]),failedPlugins:y([]),pluginsToLoadFromConfig:y([]),activePlugins:y([]),totalPluginsToLoad:y(0)},Gp={encryptionPluginName:y(void 0),migrate:y(!1),type:y(void 0),cookie:y(void 0),entries:y({}),trulyAnonymousTracking:y(!1)},jp={isEnabledServerSideCookies:y(!1),dataServiceUrl:y(void 0)},Hp={eventsQueuePluginName:y(void 0),deliveryEnabled:y(!0)},qp={enabled:y(!1),pageLifecycle:{enabled:y(!1),pageViewId:y(void 0),pageLoadedTimestamp:y(void 0)}},Kp={capabilities:Np,consents:Lp,context:Mp,eventBuffer:Bp,lifecycle:$p,loadOptions:Op,metrics:Fp,nativeDestinations:Up,plugins:Vp,reporting:Dp,session:Pp,source:xp,storage:Gp,serverCookies:jp,dataPlaneEvents:Hp,autoTrack:qp},d={...V(Kp)};Bi={exports:{}},Vi={exports:{}},zp=Vi.exports;Yp=Bi.exports;Jp=Xp(),Qp=Ac(Jp),Tc="global code",Zp=n=>z(n)&&/^global code$/i.test(n)?Tc:n,ev=n=>{let e={file:n.fileName,method:Zp(n.functionName),lineNumber:n.lineNumber,columnNumber:n.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Tc),e},Dl=n=>J(n)?n:"";Ic=(n,e)=>{let t;return qr(n)&&J(Zi(n))?t=n:(e.warn(Dg(Ln,We(n))),t=void 0),t},tv=(n,e)=>{try{let t=Qp.parse(n);return xl(n.name,n.message,e,t)}catch{return xl(n.name,n.message,e,[])}},$l=(n,e)=>{try{return JSON.parse(n||"")}catch(t){let i=Yr(t,"Failed to parse response data");e(i)}},Gi="The request failed",nv=[/Failed to fetch dynamically imported module: .*/],iv=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],sv=[new RegExp(`${Gi}.*`),/A script with the id .* is already loaded\./],rv=[...nv,...iv],ov="integrations",av="sdk",lv=av,cv={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Ll=(n,e,t)=>{let i=ge(cv,e||{});return t&&(i.headers=ge(i.headers,{Authorization:t})),i.url=n,i},Fl=(n,e=og,t)=>new Promise((i,s)=>{let r;if(n.sendRawData===!0)r=n.data;else if(r=We(n.data,!1,[],t),Ne(r)){s({error:new Error(Ig),undefined:void 0,options:n});return}let o=new XMLHttpRequest,a=c=>{s({error:new Error(jg(Gi,o.status,o.statusText,n.url,o.responseText)),xhr:o,options:n})},l=c=>{s({error:new Error(Hg(Gi,c,n.url)),xhr:o,options:n,...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:n}):a()},o.open(n.method,n.url,!0),n.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(n.headers).forEach(c=>{n.headers[c]&&o.setRequestHeader(c,n.headers[c])});try{o.send(r)}catch(c){s({error:Yr(c,qg(Gi,n.url)),xhr:o,options:n})}}),Sr=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:t,options:i,timeout:s,isRawResponse:r}=e;try{let o=await Fl(Ll(t,i,this.basicAuthHeader),s,this.logger);return{data:r?o.response:$l(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:t,url:i,options:s,timeout:r,isRawResponse:o}=e,a=!T(t);Fl(Ll(i,s,this.basicAuthHeader),r,this.logger).then(l=>{a||t(o?l.response:$l(l.response,this.onError),l)}).catch(l=>{a||t(void 0,l)})}onError(e,t){this.errorHandler?.onError({error:e,context:xf,groupingHash:t})}setAuthHeader(e,t=!1){let i=t?e:Pf(`${e}:`);this.basicAuthHeader=`Basic ${i}`}resetAuthHeader(){this.basicAuthHeader=void 0}},Rc=new Sr(ct),uv="1",dv=()=>["rsa"],hv=["www.test-host.com","localhost","127.0.0.1","[::1]"],fv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],gv="RudderStack JavaScript SDK",pv="git+https://github.com/rudderlabs/rudder-sdk-js.git",vv="js",Oc=n=>{d.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(d.lifecycle.sourceConfigUrl.value),t=`${e.origin}${e.pathname}?view=ad`;n.getAsyncData({url:t,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(i,s)=>{d.capabilities.isAdBlockerDetectionInProgress.value=!1,d.capabilities.isAdBlocked.value=s?.error!==void 0||s?.xhr?.responseURL!==t}})}catch(e){throw d.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},_v=(n,e)=>{switch(e){case rt.UNHANDLEDEXCEPTION:{let{error:t}=n;return t||n}case rt.UNHANDLEDREJECTION:return n.reason;case rt.HANDLEDEXCEPTION:default:return n}},mv=n=>({type:"manual",name:n,timestamp:new Date,metaData:{}}),yv=(n=()=>window.location.hostname)=>{let e=n();return!e||e&&hv.includes(e)?"development":"production"},bv=n=>{let e=We(n,!1,fv);return e!==null?JSON.parse(e):{}},Ev=()=>globalThis.location.href.split("?")[0],kv=(n,e,t,i)=>({id:`${n.value?.id??t.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${i.pageLifecycle.pageViewId.value??"NA"}`,name:n.value?.name??"NA"}),Sv=(n,e)=>({locale:n.value??"NA",userAgent:e.value??"NA",time:new Date}),wv=(n,e,t,i)=>{let{context:s,lifecycle:r,session:o,source:a,reporting:l,autoTrack:c}=t,{app:u,locale:h,userAgent:g,timezone:f,screen:p,library:v}=s;return{payloadVersion:"5",notifier:{name:gv,version:u.value.version,url:pv},events:[{exceptions:[V(n)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:u.value.version,releaseStage:yv(),type:u.value.installType},device:Sv(h,g),request:{url:Ev(),clientIp:"[NOT COLLECTED]"},breadcrumbs:V(l.breadcrumbs.value),context:n.message,groupingHash:i,metaData:{app:{snippetVersion:v.value.snippetVersion},device:{...p.value,timezone:f.value},...bv(t)},user:kv(a,o,r,c)}]}},Av=(n,e,t)=>{if(_e(n.capabilities.isAdBlocked.value)){n.capabilities.isAdBlockerDetectionInProgress.value===!1&&Oc(e);let i=et(()=>{z(n.capabilities.isAdBlocked.value)&&(t(n.capabilities.isAdBlocked.value===!1),i())})}else t(n.capabilities.isAdBlocked.value===!1)},Tv=(n,e,t)=>{let i=n.message;return new Promise(s=>{if(rv.some(r=>r.test(i))){let r=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(i)?.[0];J(r)?r.startsWith(ns)?e.capabilities.cspBlockedURLs.value.includes(r)?s(!1):Av(e,t,s):s(!1):s(!0)}else s(!sv.some(r=>r.test(i)))})},Cc=n=>n?n.split("/").at(-2):void 0,Pc=n=>{let e=n.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},Iv=n=>{let e=Pc(n);if(!e)return!1;let t=e.substring(e.lastIndexOf("/")+1);return Cc(e)===ts||dv().some(s=>t.startsWith(s)&&t.endsWith(".js"))},Rv=(n,e)=>{if(e)return e;let t=Pc(n);return Cc(t)===ts?ov:lv},Ov=(n,e,t)=>{let i={version:uv,message_id:Qi(),source:{name:vv,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:t},errors:n};return We(i)},Cv=(n,e,t)=>{let i;if(!z(n))i=e;else if(J(n))i=n;else{let s=Ic(n,t);z(s)?i=s.message:i=e}return i},wr=class{constructor(e,t){ee(this,"initialized",!1);this.httpClient=e,this.logger=t}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Ln,errorType:rt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Ln,errorType:rt.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let t=J(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&t.startsWith(ns)&&!d.capabilities.cspBlockedURLs.value.includes(t)&&(d.capabilities.cspBlockedURLs.value=[...d.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{let{error:t,context:i,customMessage:s,groupingHash:r,category:o}=e,a=e.errorType??rt.HANDLEDEXCEPTION,l=_v(t,a),c=Ic(l,this.logger);if(_e(c))return;let u=s?`${s} - `:"",h=`${i}${x}${u}`,g=tv(c,h),p=Zi(c).includes(Mi);if(!p&&!Iv(g)&&a!==rt.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await Tv(g,d,this.httpClient)){let _={severity:"error",unhandled:a!==rt.HANDLEDEXCEPTION,severityReason:{type:a}},E=Cv(r,g.message,this.logger),b=wv(g,_,d,E),C=Rv(g,o);this.httpClient.getAsyncData({url:d.metrics.metricsServiceUrl.value,options:{method:"POST",data:Ov(b,d,C),sendRawData:!0},isRawResponse:!0})}(a===rt.HANDLEDEXCEPTION||p)&&this.logger.error(g.message)}catch(t){this.logger.error(xg(Ln),t)}}leaveBreadcrumb(e){try{d.reporting.breadcrumbs.value=[...d.reporting.breadcrumbs.value,mv(e)]}catch(t){this.onError({error:t,context:Ln,customMessage:Rl,groupingHash:Rl})}}},Nc=new wr(Rc,ct),Ar=class{constructor(e,t={}){ee(this,"plugins",[]);ee(this,"byName",{});ee(this,"cache",{});ee(this,"config",{throws:!0});this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){let s=$g(Qt);if(this.config.throws)throw new Error(s);this.logger.error(s,e);return}if(this.byName[e.name]){let s=Lg(Qt,e.name);if(this.config.throws)throw new Error(s);this.logger.error(s);return}this.cache={},this.plugins=this.plugins.slice();let i=this.plugins.length;this.plugins.forEach((s,r)=>{s.deps?.includes(e.name)&&(i=Math.min(i,r))}),this.plugins.splice(i,0,e),this.byName[e.name]=e,T(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let s=Fg(Qt,e);if(this.config.throws)throw new Error(s);this.logger.error(s);return}let i=this.plugins.indexOf(t);if(i===-1){let s=Mg(Qt,e);if(this.config.throws)throw new Error(s);this.logger.error(s);return}this.cache={},delete this.byName[e],this.plugins=this.plugins.slice(),this.plugins.splice(i,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(i=>{if(i.deps?.some(s=>!this.byName[s])){let s=i.deps.filter(r=>!this.byName[r]);return this.logger.error(Ug(Qt,i.name,s)),!1}return t==="."?!0:Af(i,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...i){let s=e;if(!s)throw new Error(Rg);let r=s.startsWith("!"),o=this.config.throws??s.endsWith("!");if(s=s.replace(/(^!|!$)/g,""),!s)throw new Error(Og);let a=s.split(".");a.pop();let l=a.join(".");return(t?this.getPlugins(s):[this.getPlugins(s)[0]]).map(u=>{let h=pr(u,s);if(!T(h)||r)return h;try{return h.apply(pr(u,l),i)}catch(g){if(o)throw g;this.logger.error(Bg(Qt,s,u.name),g)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}},Pv=new Ar(ct,{throws:!0}),Nv=n=>n.config.connectionMode!=="cloud"||n.config.useNativeSDKToSend===!0||n.config.useNativeSDK===!0,Dv=n=>n.config.connectionMode==="hybrid"||n.config.useNativeSDKToSend===!0,Ml=n=>n.filter(Nv),xv=(n,e)=>`${n.replaceAll(" ","-")}___${e}`,Dc=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],$v=["Bugsnag","ErrorReporting"],Lv={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"}};Fv=n=>xc({},(globalThis.__federation_shared__||{}).default||{});Uv=n=>{switch(n){case"BeaconQueue":return()=>Ce("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>Oe(e,!0));case"CustomConsentManager":return()=>Ce("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>Oe(e,!0));case"DeviceModeDestinations":return()=>Ce("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>Oe(e,!0));case"DeviceModeTransformation":return()=>Ce("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>Oe(e,!0));case"ExternalAnonymousId":return()=>Ce("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>Oe(e,!0));case"GoogleLinker":return()=>Ce("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>Oe(e,!0));case"KetchConsentManager":return()=>Ce("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>Oe(e,!0));case"IubendaConsentManager":return()=>Ce("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>Oe(e,!0));case"NativeDestinationQueue":return()=>Ce("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>Oe(e,!0));case"OneTrustConsentManager":return()=>Ce("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>Oe(e,!0));case"StorageEncryption":return()=>Ce("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>Oe(e,!0));case"StorageEncryptionLegacy":return()=>Ce("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>Oe(e,!0));case"StorageMigrator":return()=>Ce("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>Oe(e,!0));case"XhrQueue":return()=>Ce("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>Oe(e,!0));default:return}},Bv=n=>{let e={};return n.forEach(t=>{if(Dc.includes(t)){let i=Uv(t);i&&(e[t]=i)}}),e},$c=()=>({}),Vv=()=>({}),Gv=n=>Bv?.(n)||{},ur={...$c(),...Vv()},jv=n=>({...Gv(n)}),Tr=class{constructor(e,t,i){this.engine=e,this.errorHandler=t,this.logger=i,this.onError=this.onError.bind(this)}init(){d.lifecycle.status.value="pluginsLoading",Vn("pluginsCDNPath",d.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){et(()=>{(d.plugins.activePlugins.value.length===0||d.plugins.loadedPlugins.value.length+d.plugins.failedPlugins.value.length===d.plugins.totalPluginsToLoad.value)&&we(()=>{d.plugins.ready.value=!0,d.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=d.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(s=>$v.includes(s)?(this.logger.warn(vp(Ni,s)),!1):!0);let t=[{configurationStatus:()=>z(d.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:d.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(wp),shouldAddMissingPlugins:!0},{configurationStatus:()=>Ml(d.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Ml(d.nativeDestinations.configuredDestinations.value).some(s=>s.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>z(d.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:d.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(kr)},{configurationStatus:()=>z(d.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:d.storage.encryptionPluginName.value,supportedPlugins:Object.values(Ui)},{configurationStatus:()=>d.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],i=!1;return t.forEach(s=>{s.configurationStatus()?(e=e.filter(s.activePluginName?r=>!(r!==s.activePluginName&&s.supportedPlugins.includes(r)):r=>z(r)),this.addMissingPlugins(s,i,e)):e=e.filter(s.basePlugins!==void 0?r=>!(s.basePlugins.includes(r)||s.supportedPlugins.includes(r)):r=>!s.supportedPlugins.includes(r))}),[...Object.keys($c()),...e]}addMissingPlugins(e,t,i){let s=e.shouldAddMissingPlugins||t,r;e.activePluginName?r=[...e.basePlugins||[],e.activePluginName]:r=[...e.supportedPlugins];let o=r.filter(a=>!i.includes(a));o.length>0&&(s&&i.push(...o),this.logger.warn(_p(Ni,e.configurationStatusStr,o,s)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(ur),...Dc],i=[],s=[];e.forEach(r=>{t.includes(r)?i.push(r):s.push(r)}),s.length>0&&this.logger.warn(bp(Ni,s)),we(()=>{d.plugins.totalPluginsToLoad.value=e.length,d.plugins.activePlugins.value=i,d.plugins.failedPlugins.value=s})}registerLocalPlugins(){Object.values(ur).forEach(e=>{T(e)&&d.plugins.activePlugins.value.includes(e().name)&&this.register([e()])})}registerRemotePlugins(){let e=jv(d.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async t=>{await e[t]().then(i=>this.register([i.default()])).catch(i=>{d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,t],this.onError(i,`Failed to load plugin "${t}"`,i)})})).catch(t=>{this.onError(t)})}invokeMultiple(e,...t){try{return this.engine.invokeMultiple(e,...t)}catch(i){return this.onError(i,e),[]}}invokeSingle(e,...t){try{return this.engine.invokeSingle(e,...t)}catch(i){return this.onError(i,e),null}}register(e){e.forEach(t=>{try{this.engine.register(t,d)}catch(i){d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,t.name],this.onError(i,`Failed to register plugin "${t.name}"`)}})}unregisterLocalPlugins(){Object.values(ur).forEach(e=>{try{this.engine.unregister(e().name)}catch(t){this.onError(t,`Failed to unregister plugin "${e().name}"`)}})}onError(e,t,i){this.errorHandler.onError({error:e,context:Ni,customMessage:t,groupingHash:i})}},Pe="cookieStorage",$e="localStorage",Be="sessionStorage",Ze="memoryStorage",Bt="none",Hv="test_rudder_cookie",qv="test_rudder_ls",Kv="test_rudder_ss",zv="rl_user_id",Wv="rl_trait",Yv="rl_anonymous_id",Xv="rl_group_id",Jv="rl_group_trait",Qv="rl_page_init_referrer",Zv="rl_page_init_referring_domain",e_="rl_session",t_="rl_auth_token",Zt={userId:zv,userTraits:Wv,anonymousId:Yv,groupId:Xv,groupTraits:Jv,initialReferrer:Qv,initialReferringDomain:Zv,sessionInfo:e_,authToken:t_},n_="__tld__",Lc="clientDataInCookie",Fc="clientDataInLocalStorage",i_="clientDataInMemory",Mc="clientDataInSessionStorage",Uc=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],en={[Pe]:Lc,[$e]:Fc,[Ze]:i_,[Be]:Mc},Ul=(n,e)=>{try{return encodeURIComponent(n)}catch(t){e?.error(zf,t);return}},Bl=n=>{try{return decodeURIComponent(n)}catch{return}},s_=n=>{let e={},t=n.split(/\s*;\s*/),i;return t[0]&&t.forEach(s=>{i=s.split("=");let r=i[0]?Bl(i[0]):void 0;r&&(e[r]=i[1]?Bl(i[1]):void 0)}),e},r_=(n,e,t,i)=>{let s={...t||{}},r=`${Ul(n,i)}=${Ul(e,i)}`;Ne(e)&&(s.maxage=-1),s.maxage&&(s.expires=new Date(+new Date+s.maxage)),s.path&&(r+=`; path=${s.path}`),s.domain&&(r+=`; domain=${s.domain}`),s.expires&&(r+=`; expires=${s.expires.toUTCString()}`),s.samesite&&(r+=`; samesite=${s.samesite}`),s.secure&&(r+="; secure"),globalThis.document.cookie=r},Ir=()=>{let n=globalThis.document.cookie;return s_(n)},o_=n=>Ir()[n],ot=function(n,e,t,i){switch(arguments.length){case 4:case 3:case 2:return r_(n,e,t,i);case 1:return n?o_(n):Ir();default:return Ir()}},a_=n=>{let e=document.createElement("a");return e.href=n,e.hostname},l_=n=>{let t=(typeof globalThis.URL!="function"?a_(n):new URL(n).hostname)?.split(".")??[],i=t[t.length-1],s=[];if(t.length===4&&i&&i===parseInt(i,10).toString())return s;if(t.length<=1)return t[0]&&t[0].indexOf("localhost")!==-1?["localhost"]:s;for(let r=t.length-2;r>=0;r-=1)s.push(t.slice(r).join("."));return s},c_=n=>{let e=l_(n);for(let t=0;t<e.length;t+=1){let i=e[t],s=n_,r={domain:`${i.indexOf("localhost")!==-1?"":"."}${i}`};try{if(ot(s,1,r),ot(s))return ot(s,null,r),i}catch{try{ot(s,null,r)}catch{}}}return""},u_=()=>{let n=`.${c_(globalThis.location.href)}`;return{maxage:ag,path:"/",domain:!n||n==="."?void 0:n,samesite:"Lax",enabled:!0}},d_=()=>({enabled:!0}),h_=()=>({enabled:!0}),f_=()=>({enabled:!0}),Rr=class{constructor(e){ee(this,"isEnabled",!0);ee(this,"length",0);ee(this,"data",{});this.options=f_(),this.logger=e}configure(e){return this.options=ge(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,t){return this.data[e]=t,this.length=Object.keys(this.data).length,t}getItem(e){return e in this.data?this.data[e]:null}removeItem(e){return e in this.data&&delete this.data[e],this.length=Object.keys(this.data).length,null}clear(){this.data={},this.length=0}key(e){return this.keys()[e]??null}keys(){return Object.keys(this.data)}},Xi=new Rr(ct),ji={exports:{}},g_=ji.exports;v_=p_(),$t=Ac(v_),Bc=n=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],t=[22,1014];return n instanceof DOMException?e.includes(n.name)||t.includes(n.code):!1},tn=(n=$e,e,t)=>{let i,s,r=Wf(vr,n),o="unavailable",a=!0,l;try{switch(n){case Ze:return!0;case Pe:i=e,s=Hv;break;case $e:i=e??globalThis.localStorage,s=qv;break;case Be:i=e??globalThis.sessionStorage,s=Kv;break;default:return!1}if(i&&(i.setItem(s,"true"),i.getItem(s)))return i.removeItem(s),!0;a=!1}catch(c){a=!1,l=c,Bc(c)&&(o="full")}return a||t?.warn(`${r}${o}.`,l),!1},Or=class{constructor(e){ee(this,"isSupportAvailable",!0);ee(this,"isEnabled",!0);ee(this,"length",0);this.options=d_(),this.logger=e}configure(e){return this.options=ge(this.options,e??{}),this.isSupportAvailable=tn($e),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){$t.set(e,t),this.length=$t.len()}getItem(e){let t=$t.get(e);return _e(t)?null:t}removeItem(e){$t.remove(e),this.length=$t.len()}clear(){$t.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return $t.keys()}},Qr=new Or(ct),Cr=class{constructor(e){ee(this,"isSupportAvailable",!0);ee(this,"isEnabled",!0);ee(this,"length",0);this.options=h_(),this.logger=e}configure(e){return this.options=ge(this.options,e??{}),this.isSupportAvailable=tn(Be),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){this.store&&(this.store.setItem(e,t),this.length=this.store.length)}getItem(e){if(!this.store)return null;let t=this.store.getItem(e);return _e(t)?null:t}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){this.store?.clear(),this.length=0}key(e){return this.store?.key(e)??null}keys(){let e=[];if(!this.store)return e;for(let t=0;t<this.store.length;t+=1){let i=this.store.key(t);i!==null&&e.push(i)}return e}},Zr=new Cr(ct),Pr=class{constructor(e){ee(this,"isSupportAvailable",!0);ee(this,"isEnabled",!0);ee(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=u_()),this.options=ge(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=tn(Pe,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){return ot(e,t,this.options,this.logger),this.length=Object.keys(ot()).length,!0}getItem(e){let t=ot(e);return _e(t)?null:t}removeItem(e){let t=this.setItem(e,null);return this.length=Object.keys(ot()).length,t}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(ot())}},eo=new Pr(ct),ze=n=>{switch(n){case $e:return Qr;case Be:return Zr;case Ze:return Xi;case Pe:return eo;default:return Xi}},__=n=>{let e=eo.configure(n);d.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},m_=n=>{Qr.configure(n)},y_=n=>{Xi.configure(n)},b_=n=>{Zr.configure(n)},E_=(n={},e={},t={},i={})=>{__(n),m_(e),y_(t),b_(i)},Nr=class{constructor(e,t,i){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=t,this.noKeyValidation=Object.keys(this.validKeys).length===0,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=i}createValidKey(e){let{name:t,id:i,validKeys:s,noKeyValidation:r,noCompoundKey:o}=this;if(r)return o?e:[t,i,e].join(".");let a;return Object.values(s).forEach(l=>{l===e&&(a=o?e:[t,i,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:i,noCompoundKey:s}=this,r=ze(Ze);Object.keys(i).forEach(o=>{let a=this.get(i[o]),l=s?o:[e,t,o].join(".");r.setItem(l,a),this.remove(o)}),this.engine=r}set(e,t){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(We(t,!1,[],this.logger)))}catch(s){if(Bc(s))this.logger.warn(cp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,t);else{let r=Kg(e);this.onError(s,r,r)}}}get(e){let t=this.createValidKey(e),i;try{return!t||(i=this.decrypt(this.engine.getItem(t)),Ye(i)||i==="")?null:JSON.parse(i)}catch(s){let r=d.storage.encryptionPluginName.value;if(!r||!d.plugins.failedPlugins.value.includes(r)){let a=zg(e);this.onError(s,a,a)}return null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return Ye(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||typeof e!="string"||Of(e)==="")return e;let s=`storage.${t}`,r=this.pluginsManager?this.pluginsManager.invokeSingle(s,e):e;return typeof r>"u"?e:r??""}onError(e,t,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:i})}},k_=(n,e)=>{let t;if(n.consents.preConsent.value.enabled)switch(n.consents.preConsent.value.storage?.strategy){case"none":t=Bt;break;case"session":e!=="sessionInfo"&&(t=Bt);break;case"anonymousId":e!=="anonymousId"&&(t=Bt);break}return t},Dr=class{constructor(e,t,i){ee(this,"stores",{});ee(this,"isInitialized",!1);this.errorHandler=t,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=d.loadOptions.value,t={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};E_($n(ge(t.cookieStorageOptions??{},d.storage.cookie?.value??{})),$n(t.localStorageOptions),$n(t.inMemoryStorageOptions),$n(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[Ze,$e,Pe,Be].forEach(t=>{ze(t)?.isEnabled&&this.setStore({id:en[t],name:en[t],isEncrypted:!0,noCompoundKey:!0,type:t,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=d.storage.type.value,t=d.loadOptions.value.storage?.entries,i=d.consents.postConsent.value.storage;(z(i?.type)||z(i?.entries))&&(e=i?.type,t=i?.entries);let s=!0,r={};Uc.forEach(o=>{let a=o,l=o,c=t?.[a]?.type,h=k_(d,o)??c??e??Er,g=this.getResolvedStorageTypeForEntry(h,o);g!==Bt&&(s=!1),r={...r,[o]:{type:g,key:Zt[l]}}}),we(()=>{d.storage.type.value=e,d.storage.entries.value=r,d.storage.trulyAnonymousTracking.value=s})}getResolvedStorageTypeForEntry(e,t){let i=e;switch(e){case $e:ze($e)?.isEnabled||(i=Ze);break;case Be:ze(Be)?.isEnabled||(i=Ze);break;case Ze:case Bt:break;case Pe:default:ze(Pe)?.isEnabled?i=Pe:ze($e)?.isEnabled?i=$e:ze(Be)?.isEnabled?i=Be:i=Ze;break}return i!==e&&this.logger.warn(up(Nf,t,e,i)),i}setStore(e){let t=ze(e.type);return this.stores[e.id]=new Nr(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},S_=n=>Q(n)&&Q(n.source)&&!Ye(n.source.id)&&Q(n.source.config)&&Array.isArray(n.source.destinations),w_=n=>typeof n=="string"&&mc.includes(n),Vc=n=>{let e=new URL(n),{host:t,protocol:i}=e,s=t.split("."),r;return s.length>2?r=`${s[s.length-2]}.${s[s.length-1]}`:r=t,{topDomain:r,protocol:i}},A_=n=>{let{topDomain:e,protocol:t}=Vc(n);return`${t}//${e}`},T_=(n,e)=>{let t=e?window.location.origin:A_(window.location.href),i=n.startsWith("/")?n.substring(1):n;return`${t}/${i}`},I_=n=>{let{topDomain:e}=Vc(window.location.href);return e===n},sn=n=>n?.endsWith("/")?sn(n.substring(0,n.length-1)):n,xr=n=>{try{return new URL(n).host}catch{return null}},Gc=n=>xr(n)??"",R_=n=>{let e={};try{let t=new URL(n),i="utm_";t.searchParams.forEach((s,r)=>{if(r.startsWith(i)){let o=r.substring(i.length);o==="campaign"&&(o="name"),e[o]=s}})}catch{}return e},O_=n=>{let e=n;try{let t=new URL(n);e=t.origin+t.pathname+t.search}catch{}return e},C_=n=>n.replace(/\/{2,}/g,"/"),rn=n=>{if(!J(n))return!1;try{return T(globalThis.URL)&&new URL(n),kp.test(n)}catch{return!1}},dr="none",hr="immediate",P_=n=>n?.statsCollection?.errors?.enabled===!0,N_=n=>n?.statsCollection?.metrics?.enabled===!0,D_=n=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(Q(n)){let t=V(n);e.storage=t.storage,lt(t.integrations)&&(e.integrations=t.integrations),e.discardPreConsentEvents=t.discardPreConsentEvents===!0,e.sendPageEvent=t.sendPageEvent===!0,e.trackConsent=t.trackConsent===!0,lt(t.consentManagement)&&(e.consentManagement=ge(t.consentManagement,{enabled:d.consents.enabled.value}))}return e},Gl=n=>lt(n)||Array.isArray(n),x_=(n,e)=>{let{provider:t}=n,i=t?kr[t]:void 0;return t&&!i&&(e.error(Ng(Ve,t,kr)),t=void 0),{provider:t,consentManagerPluginName:i}},jc=(n,e)=>{let t,i=[],s=[],r=!1,o,a=n?.enabled===!0;lt(n)&&a&&({provider:o,consentManagerPluginName:t}=x_(n,e),Gl(n.allowedConsentIds)&&(i=n.allowedConsentIds,r=!0),Gl(n.deniedConsentIds)&&(s=n.deniedConsentIds,r=!0));let l={allowedConsentIds:i,deniedConsentIds:s};return a=a&&!!t,{provider:o,consentManagerPluginName:t,initialized:r,enabled:a,consentsData:l}},$_=()=>{let n=document.querySelector("script[data-rsa-write-key]");if(n&&n.dataset.rsaWriteKey===d.lifecycle.writeKey.value)return n.src;let e=document.getElementsByTagName("script"),t=/(?:^|\/)rsa(\.min)?\.js$/;for(let i of e){let s=i.getAttribute("src");if(s&&t.test(s))return s}},L_=n=>{d.reporting.isErrorReportingEnabled.value=P_(n.source.config)&&!Bf(),d.reporting.isMetricsReportingEnabled.value=N_(n.source.config)},F_=n=>{let{useServerSideCookies:e,dataServiceEndpoint:t,storage:i,setCookieDomain:s,sameDomainCookiesOnly:r}=d.loadOptions.value,o=i?.cookie,a=!1,l;if(e){a=e;let c=o.domain??s,u=z(c)&&!I_(vl(c))||r,h=T_(t??Ap,u);if(rn(h)){l=sn(h);let g=xr(window.location.href),f=xr(h);g!==f&&(o={...o,samesite:"None",secure:!0}),!r&&u&&f!==vl(c)&&(a=!1,n.warn(Zg(Ve,c,f)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},M_=n=>{let{storage:e}=d.loadOptions.value,t=e?.type;z(t)&&!w_(t)&&(n.warn(Xg(Ve,t,Er)),t=Er);let i=e?.encryption?.version,s=i&&Ui[i];!_e(i)&&_e(s)?(n.warn(Jg(Ve,i,Ui,Ft)),i=Ft):_e(i)&&(i=Ft);let r=e?.migrate,o=r&&i===Ft;r===!0&&o!==r&&n.warn(Qg(Ve,i,Ft));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:c}=F_(n);we(()=>{d.storage.type.value=t,d.storage.cookie.value=c,d.serverCookies.isEnabledServerSideCookies.value=a,d.serverCookies.dataServiceUrl.value=l,d.storage.encryptionPluginName.value=Ui[i],d.storage.migrate.value=o})},U_=n=>{let{provider:e,consentManagerPluginName:t,initialized:i,enabled:s,consentsData:r}=jc(d.loadOptions.value.consentManagement,n),o=d.loadOptions.value.preConsent,a=o?.storage?.strategy??dr,l=["none","session","anonymousId"];z(a)&&!l.includes(a)&&(a=dr,n.warn(gp(Ve,o?.storage?.strategy,dr)));let c=o?.events?.delivery??hr,u=["immediate","buffer"];z(c)&&!u.includes(c)&&(c=hr,n.warn(pp(Ve,o?.events?.delivery,hr))),we(()=>{d.consents.activeConsentManagerPluginName.value=t,d.consents.initialized.value=i,d.consents.enabled.value=s,d.consents.data.value=r,d.consents.provider.value=e,d.consents.preConsent.value={enabled:d.loadOptions.value.preConsent?.enabled===!0&&i===!1&&s===!0,storage:{strategy:a},events:{delivery:c}}})},B_=n=>{let e=d.consents.resolutionStrategy.value,t;Q(n.consentManagementMetadata)&&(d.consents.provider.value&&(e=n.consentManagementMetadata.providers.find(i=>i.provider===d.consents.provider.value)?.resolutionStrategy??d.consents.resolutionStrategy.value),t=n.consentManagementMetadata),d.consents.provider.value==="custom"&&(e=void 0),we(()=>{d.consents.metadata.value=V(t),d.consents.resolutionStrategy.value=e})},V_=n=>{if(d.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",t=e;d.loadOptions.value.useBeacon&&(d.capabilities.isBeaconAvailable.value?t="BeaconQueue":(t=e,n.warn(np(Ve)))),we(()=>{d.dataPlaneEvents.eventsQueuePluginName.value=t})}},G_=(n,e,t,i,s)=>{let r=new URLSearchParams({p:lc,v:Bn,build:Gn,writeKey:e,lockIntegrationsVersion:t.toString(),lockPluginsVersion:i.toString()}),o=wc,a=r,l="/sourceConfig/",c="";if(rn(n)){let u=new URL(n);sn(u.pathname).endsWith("/sourceConfig")||(u.pathname=`${sn(u.pathname)}/sourceConfig/`),u.pathname=C_(u.pathname),r.forEach((h,g)=>{u.searchParams.get(g)===null&&u.searchParams.set(g,h)}),o=u.origin,l=u.pathname,a=u.searchParams,c=u.hash}else s.warn(hp(Ve,n));return`${o}${l}?${a}${c}`},j_=n=>n.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:xv(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===Ip})),Hc=(n,e,t,i,s,r,o)=>{let a;if(r){if(!rn(r))return o.error(Pg(Ve,n,r)),null;a=sn(r)}else if(a=t,d.context.app.value.installType==="cdn"){let l=$_();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return s&&(a=a.replace(new RegExp(`/${Jr}/${Gn}/${e}$`),`/${i}/${Gn}/${e}`)),a},H_=(n,e,t,i)=>Hc("integrations",ts,kc,n,e,t,i),q_=(n,e,t,i)=>Hc("plugins",Ec,Sc,n,e,t,i),$r=class{constructor(e,t,i){this.errorHandler=t,this.logger=i,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){et(()=>{this.logger.setMinLogLevel(d.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:t,lockIntegrationsVersion:i,lockPluginsVersion:s,destSDKBaseURL:r,pluginsSDKBaseURL:o,integrations:a}=d.loadOptions.value,l=H_(Bn,i,r,this.logger);if(Ne(l))return;let c;c=q_(Bn,s,o,this.logger),c!==null&&(this.attachEffects(),d.lifecycle.activeDataplaneUrl.value=sn(d.lifecycle.dataPlaneUrl.value),M_(this.logger),U_(this.logger),V_(this.logger),we(()=>{d.lifecycle.integrationsCDNPath.value=l,d.lifecycle.pluginsCDNPath.value=c,e&&(d.lifecycle.logLevel.value=e),d.lifecycle.sourceConfigUrl.value=G_(t,d.lifecycle.writeKey.value,i,s,this.logger),d.metrics.metricsServiceUrl.value=`${d.lifecycle.activeDataplaneUrl.value}/${Tp}`,d.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,t,i){this.errorHandler.onError({error:e,context:Ve,customMessage:t,groupingHash:i})}processConfig(e,t){if(!z(e)){z(t)?this.onError(t.error,Ol):this.onError(new Error(Ol));return}let i;try{J(e)?i=JSON.parse(e):i=e}catch(r){this.onError(r,Il);return}if(!S_(i)){this.onError(new Error(Il));return}if(i.source.enabled===!1){this.logger.error(Tg);return}L_(i);let s=i.source.destinations.length>0?j_(i.source.destinations):[];we(()=>{d.source.value={config:i.source.config,name:i.source.name,id:i.source.id,workspaceId:i.source.workspaceId},d.nativeDestinations.configuredDestinations.value=s,d.plugins.pluginsToLoadFromConfig.value=d.loadOptions.value.plugins??[],B_(i),d.lifecycle.status.value="configured"})}getConfig(){let e=d.loadOptions.value.getSourceConfig;if(e){if(!T(e)){this.logger.error(Cg(Ve));return}let t=e();t instanceof Promise?t.then(i=>this.processConfig(i)).catch(i=>{this.onError(i,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:d.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},K_=()=>{let n=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return n?.[1]?n[1]:"NA"},qc=(n=()=>document)=>n()?.referrer||"$direct",z_=(n=()=>document)=>{let t=n().getElementsByTagName("link"),i="";for(let s=0;t[s];s+=1){let r=t[s];if(r.getAttribute("rel")==="canonical"&&!i){i=r.getAttribute("href")??"";break}}return i},W_=(n=()=>globalThis.navigator)=>{let e=n();if(_e(e))return null;let{userAgent:t}=e,{brave:i}=e;if(i&&Object.getPrototypeOf(i).isBrave){let s=t.match(/(chrome)\/([\w.]+)/i);s&&(t=`${t} Brave/${s[2]}`)}return t},Y_=(n=()=>globalThis.navigator)=>{let e=n();return _e(e)?null:e.language??e.browserLanguage},Kc=(n=()=>globalThis.location,e=()=>document)=>{let t=n(),i=z_(e),s=t.pathname,{href:r}=t,o=r,{search:a}=t;if(i)try{let h=new URL(i);h.search===""?o=i+a:o=i,s=h.pathname}catch{}let l=O_(o),{title:c}=e(),u=qc(e);return{path:s,referrer:u,referring_domain:Gc(u),search:a,title:c,url:l,tab_url:r}},X_=(n,e="none")=>{e==="none"&&n(void 0),e==="default"&&n(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(t=>{n(t)}).catch(()=>{n()})},J_=()=>{let n=globalThis.document.createElement("div");return n.setAttribute("data-a-b","c"),n.dataset?n.dataset.aB==="c":!1},Lr={URL:()=>!T(globalThis.URL)||!T(globalThis.URLSearchParams),Promise:()=>!T(globalThis.Promise),"Number.isNaN":()=>!T(globalThis.Number.isNaN),"Number.isInteger":()=>!T(globalThis.Number.isInteger),"Array.from":()=>!T(globalThis.Array.from),"Array.prototype.find":()=>!T(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!T(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!T(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!T(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!T(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!T(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!T(globalThis.String.fromCodePoint),"Object.entries":()=>!T(globalThis.Object.entries),"Object.values":()=>!T(globalThis.Object.values),"Object.assign":()=>!T(globalThis.Object.assign),"Object.fromEntries":()=>!T(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!J_(),TextEncoder:()=>!T(globalThis.TextEncoder)||!T(globalThis.TextDecoder),requestAnimationFrame:()=>!T(globalThis.requestAnimationFrame)||!T(globalThis.cancelAnimationFrame),CustomEvent:()=>!T(globalThis.CustomEvent),"navigator.sendBeacon":()=>!T(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!T(globalThis.Uint8Array),Set:()=>!T(globalThis.Set),atob:()=>!T(globalThis.atob)},Q_=()=>{let n=Object.keys(Lr),e=!1;for(let t=0;t<n.length;t++){let i=Lr[n[t]];if(T(i)&&i()){e=!0;break}}return e},Z_="https://polyfill-fastly.io/v3/polyfill.min.js",em=`${Z_}?version=3.111.0&features=${Object.keys(Lr).join("%2C")}`,tm=10*1e3,jl="rudderstackPolyfill",nm=()=>!Ye(globalThis.crypto)&&T(globalThis.crypto.getRandomValues),Hl=()=>!Ye(globalThis.navigator.userAgentData),im=()=>!Ye(globalThis.navigator.sendBeacon)&&T(globalThis.navigator.sendBeacon),ql=()=>{let n={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return n={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},n},Fr=class{constructor(e,t,i){this.httpClient=e,this.errorHandler=t,this.logger=i,this.externalSrcLoader=new Wi(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){we(()=>{d.capabilities.storage.isCookieStorageAvailable.value=tn(Pe,ze(Pe),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=tn($e,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=tn(Be,void 0,this.logger),d.capabilities.isBeaconAvailable.value=im(),d.capabilities.isUaCHAvailable.value=Hl(),d.capabilities.isCryptoAvailable.value=nm(),d.capabilities.isIE11.value=sc(),d.capabilities.isOnline.value=globalThis.navigator.onLine,d.context.userAgent.value=W_(),d.context.locale.value=Y_(),d.context.screen.value=ql(),d.context.timezone.value=K_(),Hl()&&X_(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),et(()=>{d.loadOptions.value.sendAdblockPage===!0&&d.lifecycle.sourceConfigUrl.value!==void 0&&Oc(this.httpClient)})}prepareBrowserCapabilities(){d.capabilities.isLegacyDOM.value=Q_();let e=d.loadOptions.value.polyfillURL,t=em;if(nn(e)&&(rn(e)?t=e:this.logger.warn(mp(vr,e))),d.loadOptions.value.polyfillIfRequired&&d.capabilities.isLegacyDOM.value&&rn(t)){let s=t!==d.loadOptions.value.polyfillURL;if(s){let r=`RS_polyfillCallback_${d.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[r]};globalThis[r]=o,t=`${t}&callback=${r}`}this.externalSrcLoader.loadJSFile({url:t,id:jl,async:!0,timeout:tm,callback:r=>{r?s||this.onReady():this.onError(new Error(fp(jl,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{d.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{d.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",ug(()=>{d.context.screen.value=ql()},this))}onReady(){this.detectBrowserCapabilities(),d.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:vr,groupingHash:t})}},sm="web",rm=["integrations","anonymousId","originalTimestamp"],Kl=["library","consentManagement","userAgent","ua-ch","screen"],fr=["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"],zc=n=>typeof n=="number"&&!Number.isNaN(n),om=(n,e)=>e.toString().length>=n,Ji=n=>zc(n)&&n>=0&&Number.isInteger(n),zl=10,Wc=n=>{let{cutOff:e}=n,t=Date.now();return!!(e?.enabled&&e.expiresAt&&t>e.expiresAt)},Wl=n=>!n.expiresAt||Date.now()>n.expiresAt||Wc(n),am=()=>Date.now(),lm=(n,e)=>!n||!Ji(n)||!om(zl,n)?(e.warn(lp(Lt,n,zl)),!1):!0,cm=n=>{if(n?.enabled)return n.expiresAt??(Ji(n.duration)?Date.now()+n.duration:void 0)},um=n=>{let{timeout:e,cutOff:t}=n,i=Date.now();return{id:i,expiresAt:i+e,timeout:e,autoTrack:!0,...t&&{cutOff:t}}},dm=(n,e)=>({id:lm(n,e)?n:am(),sessionStart:void 0,manualTrack:!0}),Fn=n=>n===Pe||n===$e||n===Be||n===Ze,Mr=()=>Qi(),hm=n=>{if(wf(n)){let{entries:e,...t}=cr;return{...t,entries:{...e,anonymousId:n}}}return Q(n)&&Q(n.entries)?ge(cr,n):{...cr}},fm=n=>{let e=Kc(),t={};return Object.keys(e).forEach(i=>{t[i]=n?.[i]||e[i]}),t.initial_referrer=n?.initial_referrer||d.session.initialReferrer.value,t.initial_referring_domain=n?.initial_referring_domain||d.session.initialReferringDomain.value,t},gm=(n,e)=>{let t=e?.page||{},i=n,s=Kc();return Object.keys(s).forEach(r=>{_e(i[r])&&(i[r]=t[r]||s[r])}),_e(i.initial_referrer)&&(i.initial_referrer=t.initial_referrer||d.session.initialReferrer.value),_e(i.initial_referring_domain)&&(i.initial_referring_domain=t.initial_referring_domain||d.session.initialReferringDomain.value),i},gr=(n,e,t)=>{Q(n)&&Object.keys(n).forEach(i=>{(fr.includes(i)||fr.includes(i.toLowerCase()))&&t.warn(ep(ic,i,e,fr))})},pm=(n,e)=>{let{properties:t,traits:i,context:s}=n,{traits:r}=s;gr(t,"properties",e),gr(i,"traits",e),gr(r,"context.traits",e)},vm=(n,e)=>{e.anonymousId&&J(e.anonymousId)&&(n.anonymousId=e.anonymousId),lt(e.integrations)&&(n.integrations=e.integrations),e.originalTimestamp&&J(e.originalTimestamp)&&(n.originalTimestamp=e.originalTimestamp)},_m=(n,e,t)=>{let i=n;return Object.keys(e).forEach(s=>{if(!rm.includes(s)&&!Kl.includes(s))if(s!=="context")i=ge(i,{[s]:e[s]});else if(!_e(e[s])&&Q(e[s])){let r={};Object.keys(e[s]).forEach(o=>{Kl.includes(o)||(r[o]=e[s][o])}),i=ge(i,{...r})}else t.warn(tp(ic))}),i},mm=(n,e,t)=>{Q(e)&&(vm(n,e),n.context=_m(n.context,e,t))},ym=n=>{let e;return d.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=d.consents.postConsent.value.integrations??d.nativeDestinations.loadOnlyIntegrations.value:n?e=n:e=bc,V(e)},xn=(n,e,t,i)=>{let s={channel:sm,context:{traits:V(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:V(d.consents.data.value.deniedConsentIds),allowedConsentIds:V(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:R_(globalThis.location.href),page:fm(t),timezone:d.context.timezone.value,...d.autoTrack.enabled.value&&{autoTrack:{...d.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:d.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:Gf(),messageId:Qi(),userId:n.userId||d.session.userId.value};Fn(d.storage.entries.value.anonymousId?.type)?s.anonymousId=d.session.anonymousId.value:s.anonymousId=Mr(),d.storage.trulyAnonymousTracking.value&&(s.context.trulyAnonymousTracking=!0),n.type==="identify"&&(s.context.traits=d.storage.entries.value.userTraits?.type!==Bt?V(d.session.userTraits.value):n.context.traits),n.type==="group"&&((n.groupId||d.session.groupId.value)&&(s.groupId=n.groupId||d.session.groupId.value),(n.traits||d.session.groupTraits.value)&&(s.traits=d.storage.entries.value.groupTraits?.type!==Bt?V(d.session.groupTraits.value):n.traits));let r=ge(n,s);return r.event===void 0&&(r.event=null),r.properties===void 0&&(r.properties=null),mm(r,e,i),pm(r,i),r.integrations=ym(r.integrations),r},Ur=class{constructor(e){this.logger=e}generatePageEvent(e,t,i,s){let r=i??{};return r=gm(r,s),xn({properties:r,name:t,category:e,type:"page"},s,r,this.logger)}generateTrackEvent(e,t,i){return xn({properties:t,event:e,type:"track"},i,void 0,this.logger)}generateIdentifyEvent(e,t,i){return xn({userId:e,type:"identify",context:{traits:t}},i,void 0,this.logger)}generateAliasEvent(e,t,i){let r=xn({previousId:t,type:"alias"},i,void 0,this.logger);return r.userId=e??r.userId,r}generateGroupEvent(e,t,i){let s={type:"group"};return e&&(s.groupId=e),t&&(s.traits=t),xn(s,i,void 0,this.logger)}create(e){let t;switch(e.type){case"page":t=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":t=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":t=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":t=this.generateAliasEvent(e.to,e.from,e.options);break;default:t=this.generateGroupEvent(e.groupId,e.traits,e.options);break}return t}},Br=class{constructor(e,t,i,s){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=i,this.logger=s,this.eventFactory=new Ur(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let t=this.eventFactory.create(e);this.eventRepository.enqueue(t,e.callback)}},Vr=class{constructor(e,t,i,s,r){this.storeManager=t,this.pluginsManager=e,this.logger=r,this.errorHandler=s,this.httpClient=i,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:e,anonymousIdOptions:t}=d.loadOptions.value,i;nn(e)&&typeof e=="string"&&(i=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(i??this.getAnonymousId(t)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),i=this.getSessionInfo()??q.sessionInfo;e={autoTrack:t.autoTrack&&i.manualTrack!==!0,timeout:t.timeout,manualTrack:i.manualTrack,expiresAt:i.expiresAt,id:i.id,sessionStart:i.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=q.sessionInfo:t.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:i.cutOff?.expiresAt})}else e=q.sessionInfo;d.session.sessionInfo.value=e,d.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(d.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),t=this.getInitialReferringDomain();if(e&&t)this.setInitialReferrer(e),this.setInitialReferringDomain(t);else{let i=e||qc();this.setInitialReferrer(i),this.setInitialReferringDomain(Gc(i))}}isPersistenceEnabledForStorageEntry(e){return Fn(d.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=d.storage.entries.value,t=[Pe,$e,Be];Object.keys(e).forEach(i=>{let s=i,r=e[s]?.type,o=this.storeManager?.getStore(en[r]);o&&t.forEach(a=>{let l=this.storeManager?.getStore(en[a]);if(l&&a!==r){let c=l.get(Zt[s]);Sf(c)&&o.set(Zt[s],c),l.remove(Zt[s])}})})}migrateStorageIfNeeded(e,t){if(!d.storage.migrate.value)return;let i=e??[];i.length===0&&[Lc,Fc,Mc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&i.push(a)}),(t??Object.keys(Zt)).forEach(r=>{let o=Zt[r];i.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);Ye(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=d.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let t,i=d.loadOptions.value.sessions?.timeout;Ji(i)?t=i:(this.logger.warn(ip(Lt,i,_r)),t=_r),t===0&&(this.logger.warn(op(Lt)),e=!1),t>0&&t<wl&&this.logger.warn(ap(Lt,t,wl));let s=this.getCutOffInfo(t);return{timeout:t,autoTrack:e,cutOff:s}}getCutOffInfo(e){let t=d.loadOptions.value.sessions.cutOff,i,s=!1;return t.enabled===!0&&(i=t.duration,s=!0,Ji(i)?i<e&&(this.logger.warn(rp(Lt,i,e)),s=!1):(this.logger.warn(sp(Lt,i,Sl)),i=Sl)),{enabled:s,duration:i}}onError(e,t,i){this.errorHandler.onError({error:e,context:Lt,customMessage:t,groupingHash:i})}getEncryptedCookieData(e,t){let i=[];return e.forEach(s=>{let r=t?.encrypt(We(s.value,!1,[],this.logger));nn(r)&&i.push({name:s.name,value:r})}),i}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:d.serverCookies.dataServiceUrl.value,options:{method:"POST",data:We({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:t})}setServerSideCookies(e,t,i){let s=Object.keys(e),r=()=>s.map(c=>({name:e[c].name,value:d.session[c].value})),o={};s.forEach(c=>{o[e[c].name]=i?.get(e[c].name)});let a=()=>{s.forEach(c=>{this.serverSideCookiesRequestInProgress[c]=!1})},l=()=>{r().forEach(c=>{t&&t(c.name,c.value)})};try{let c={};s.forEach(h=>{c[e[h].name]=d.session[h].value});let u=this.getEncryptedCookieData(r(),i);u.length>0?this.makeRequestToSetCookie(u,(h,g)=>{a(),g?.xhr?.status===200?r().forEach(f=>{let p=o[f.name],v=i?.get(f.name);We(c[f.name],!1,[])!==We(v,!1,[])&&(Ne(p)&&Ne(v)&&this.logger.error(Yg(f.name)),t&&t(f.name,f.value))}):(this.logger.error(Wg(g?.xhr?.status)),l())}):(l(),a())}catch(c){this.onError(c,Cl,Cl),l(),a()}}syncValueToStorage(e){let t=d.storage.entries.value,i=t[e]?.type;if(Fn(i)){let s=this.storeManager.getStore(en[i]),r=t[e]?.key,o=d.session[e].value;o&&(J(o)||lt(o))?d.serverCookies.isEnabledServerSideCookies.value&&i===Pe?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{let a={[e]:{name:r}};this.setServerSideCookies(a,(l,c)=>{s?.set(l,c)},s)},Cp)):s?.set(r,o):s?.remove(r)}}registerEffects(){Uc.forEach(e=>{et(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let i=e;(!J(e)||!i)&&(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&t&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t)),i=i||Mr()):i=q.anonymousId,d.session.anonymousId.value=i}getAnonymousId(e){let t=d.storage.entries.value.anonymousId?.type;if(Fn(t)){let i=d.session.anonymousId.value;(!i||i===q.anonymousId)&&(i=this.getEntryValue("anonymousId")),!i&&e&&(i=this.pluginsManager?.invokeSingle("storage.getAnonymousId",ze,e)),d.session.anonymousId.value=i||Mr()}return d.session.anonymousId.value}getEntryValue(e){let t=d.storage.entries.value,i=t[e]?.type;if(Fn(i)){let s=this.storeManager?.getStore(en[i]);this.migrateStorageIfNeeded([s],[e]);let r=t[e]?.key;return s?.get(r)??null}return null}getExternalAnonymousIdByCookieName(e){let t=ze(Pe);return t?.isEnabled?t.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?d.session[e].value:this.getEntryValue(e)}getUserId(){return this.getUserSessionValue("userId")}getUserTraits(){return this.getUserSessionValue("userTraits")}getGroupId(){return this.getUserSessionValue("groupId")}getGroupTraits(){return this.getUserSessionValue("groupTraits")}getInitialReferrer(){return this.getUserSessionValue("initialReferrer")}getInitialReferringDomain(){return this.getUserSessionValue("initialReferringDomain")}getSessionInfo(){return this.getUserSessionValue("sessionInfo")}getAuthToken(){return this.getUserSessionValue("authToken")}getSessionId(){let e=this.getSessionInfo()??q.sessionInfo;return e.autoTrack&&!Wl(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??q.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=d.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),d.session.sessionInfo.value=e,d.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=d.session,{manualTrack:t,autoTrack:i,timeout:s,cutOff:r}=e.sessionInfo.value;if(i){let o={...q.sessionInfo,timeout:s};r&&(o.cutOff={enabled:r.enabled,duration:r.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){let{session:t}=d,i=hm(e);we(()=>{Object.keys(q).forEach(s=>{let r=s;if(i.entries[r]===!0)switch(s){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[r].value=q[r];break}})})}setUserId(e){d.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:q.userId}setUserTraits(e){d.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&Q(e)?ge(d.session.userTraits.value??q.userTraits,e):q.userTraits}setGroupId(e){d.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:q.groupId}setGroupTraits(e){d.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&Q(e)?ge(d.session.groupTraits.value??q.groupTraits,e):q.groupTraits}setInitialReferrer(e){d.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:q.initialReferrer}setInitialReferringDomain(e){d.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:q.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if(Wl(e))t=um(e);else{let i=Date.now(),s=e.timeout;t.expiresAt=i+s}if(Wc(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){let i=cm(t.cutOff);t.cutOff.expiresAt=i}d.session.sessionInfo.value=t}start(e){d.session.sessionInfo.value=dm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){d.session.sessionInfo.value=q.sessionInfo}setAuthToken(e){d.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:q.authToken}},bm=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],Em=(n,e)=>{let t=V(e);return J(t.setCookieDomain)||(t.setCookieDomain=void 0),["Strict","Lax","None"].includes(t.sameSiteCookie)||(t.sameSiteCookie=void 0),t.secureCookie=Qe(t.secureCookie,n.secureCookie),t.sameDomainCookiesOnly=Qe(t.sameDomainCookiesOnly,n.sameDomainCookiesOnly),["none","default","full"].includes(t.uaChTrackLevel)||(t.uaChTrackLevel=void 0),t.integrations=st(t.integrations),Array.isArray(t.plugins)||(t.plugins=bm),t.useGlobalIntegrationsConfigInEvents=Qe(t.useGlobalIntegrationsConfigInEvents,n.useGlobalIntegrationsConfigInEvents),t.bufferDataPlaneEventsUntilReady=Qe(t.bufferDataPlaneEventsUntilReady,n.bufferDataPlaneEventsUntilReady),t.sendAdblockPage=Qe(t.sendAdblockPage,n.sendAdblockPage),t.useServerSideCookies=Qe(t.useServerSideCookies,n.useServerSideCookies),J(t.dataServiceEndpoint)||(t.dataServiceEndpoint=void 0),t.sendAdblockPageOptions=st(t.sendAdblockPageOptions),t.loadIntegration=Qe(t.loadIntegration,n.loadIntegration),lt(t.storage)?(t.storage.migrate=Qe(t.storage.migrate,n.storage?.migrate),t.storage.cookie=st(t.storage.cookie),t.storage.encryption=st(t.storage.encryption),t.storage=qi(t.storage)):t.storage=void 0,t.destinationsQueueOptions=st(t.destinationsQueueOptions),t.queueOptions=st(t.queueOptions),t.lockIntegrationsVersion=Qe(t.lockIntegrationsVersion,n.lockIntegrationsVersion),t.lockPluginsVersion=Qe(t.lockPluginsVersion,n.lockPluginsVersion),zc(t.dataPlaneEventsBufferTimeout)||(t.dataPlaneEventsBufferTimeout=void 0),t.beaconQueueOptions=st(t.beaconQueueOptions),t.preConsent=st(t.preConsent),t.sourceConfigurationOverride=st(t.sourceConfigurationOverride),ge(n,qi(t))},Yl="dataplaneEventsQueue",Xl="destinationsEventsQueue",km="transformEvent",Sm=(n,e)=>Object.keys(n).filter(t=>n[t]!==!0||!e[t]).reduce((t,i)=>{let s=V(t);return s[i]=n[i],s},{}),wm=(n,e)=>{let t=V(n),i=e.nativeDestinations.integrationsConfig.value,s=Sm(n.integrations,i);return t.integrations=ge(i,s),t},Am=n=>n.consents.preConsent.value.enabled&&n.consents.preConsent.value.events?.delivery==="buffer",Hi=(n,e,t,i)=>{if(z(n))if(T(n))try{n(...e)}catch(s){i.error(dp(t),s)}else i.error(yc(t))},Gr=class{constructor(e,t,i,s,r){this.pluginsManager=e,this.errorHandler=s,this.httpClient=i,this.logger=r,this.storeManager=t}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${Yl}.init`,d,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${km}.init`,d,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${Xl}.init`,d,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),et(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=Am(d),t;et(()=>{let i=d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&d.nativeDestinations.clientDestinationsReady.value===!1;(d.nativeDestinations.activeDestinations.value.some(r=>Dv(r))===!1||i===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(t),this.dataplaneEventsQueue?.start())}),d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(t=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,t){let i=wm(e,d);this.pluginsManager.invokeSingle(`${Yl}.enqueue`,d,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let s=V(e);this.pluginsManager.invokeSingle(`${Xl}.enqueue`,d,this.destinationsEventsQueue,s,this.errorHandler,this.logger);let r=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${Wr}`;Hi(t,[i],r,this.logger)}},Jl=n=>{let e=new CustomEvent(n,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},Tm=n=>J(n)&&n.trim().length>0,Im=n=>rn(n),jr=class{constructor(){this.preloadBuffer=new yr,this.initialized=!1,this.errorHandler=Nc,this.logger=ct,this.externalSrcLoader=new Wi(this.logger),this.httpClient=Rc,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new Fr(this.httpClient,this.errorHandler,this.logger)}load(e,t,i={}){if(!d.lifecycle.status.value){if(!Tm(e)){this.logger.error(Vg(Di,e));return}if(!Im(t)){this.logger.error(Gg(Di,t));return}we(()=>{d.lifecycle.writeKey.value=V(e),d.lifecycle.dataPlaneUrl.value=V(t),d.loadOptions.value=Em(d.loadOptions.value,i),d.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(d.loadOptions.value.logLevel??_c),Vn("state",d,e),this.startLifecycle()}}startLifecycle(){et(()=>{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 t="Failed to load the SDK";this.errorHandler.onError({error:e,context:Di,customMessage:t,groupingHash:t})}})}onBrowserCapabilitiesReady(){gg(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(t=>this.preloadBuffer.enqueue(V(t)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&pg([...e],this)}}prepareInternalServices(){this.pluginsManager=new Tr(Pv,this.errorHandler,this.logger),this.storeManager=new Dr(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new $r(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Vr(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Gr(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Br(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(),we(()=>{d.lifecycle.loaded.value=!0,d.lifecycle.status.value="loaded"}),this.initialized=!0;let e=d.loadOptions.value.onLoaded;Hi(e,[globalThis.rudderanalytics],Df,this.logger),Jl("RSA_Initialised")}onReady(){d.lifecycle.status.value="readyExecuted",d.eventBuffer.readyCallbacksArray.value.forEach(e=>{Hi(e,[],ar,this.logger)}),Jl("RSA_Ready")}processBufferedEvents(){let e=d.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let t=e.shift();if(d.eventBuffer.toBeProcessedArray.value=e,t){let i=t[0];T(this[i])&&this[i](...t.slice(1),!0)}e=d.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if(d.lifecycle.status.value==="destinationsLoading"||d.lifecycle.status.value==="destinationsReady")return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",d,this.pluginsManager,this.errorHandler,this.logger);let e=d.nativeDestinations.activeDestinations.value.length;if(e===0){d.lifecycle.status.value="destinationsReady";return}d.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",d,this.externalSrcLoader,this.errorHandler,this.logger),et(()=>{(e===0||d.nativeDestinations.initializedDestinations.value.length+d.nativeDestinations.failedDestinations.value.length===e)&&we(()=>{d.lifecycle.status.value="destinationsReady",d.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){d.lifecycle.status.value!=="ready"&&we(()=>{d.lifecycle.status.value="ready"})}ready(e,t=!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`),!T(e)){this.logger.error(yc(ar));return}d.lifecycle.status.value==="readyExecuted"?Hi(e,[],ar,this.logger):d.eventBuffer.readyCallbacksArray.value=[...d.eventBuffer.readyCallbacksArray.value,e]}page(e,t=!1){let i="page";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),d.capabilities.isAdBlocked.value===!0&&e.category!==bl&&this.page(zi(bl,eg,{path:tg},d.loadOptions.value.sendAdblockPageOptions))}track(e,t=!1){let i="track";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event - ${e.name}`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:i,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,t=!1){let i="identify";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),d.metrics.triggered.value+=1,e.userId&&d.session.userId.value&&e.userId!==d.session.userId.value&&this.reset(),Ne(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:i,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,t=!1){let i="alias";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),d.metrics.triggered.value+=1;let s=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:i,to:e.to,from:s,options:e.options,callback:e.callback})}group(e,t=!1){let i="group";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),d.metrics.triggered.value+=1,Ne(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:i,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,t=!1){let i="reset";if(!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,t,i=!1){let s="setAnonymousId";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e,t]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.setAnonymousId(e,t)}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,t=!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 t="endSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[t]];return}this.errorHandler.leaveBreadcrumb(`New ${t} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,t=!1){let i="consent";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),we(()=>{d.consents.preConsent.value={...d.consents.preConsent.value,enabled:!1},d.consents.postConsent.value=D_(e);let{initialized:s,consentsData:r}=jc(d.consents.postConsent.value.consentManagement,this.logger);d.consents.initialized.value=s,d.consents.data.value=r}),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(t)}sendTrackingEvents(e){if(d.consents.postConsent.value.trackConsent){let t=zr(ng);e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(d.consents.postConsent.value.sendPageEvent){let t=zi();e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,i=!1){let s="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,d,this.logger);else{if(d.lifecycle.loaded.value){this.logger.error(Ep(Di,e));return}d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e,t]]}}},Mt=class Mt{constructor(){ee(this,"analyticsInstances",{});ee(this,"defaultAnalyticsKey","");ee(this,"logger",ct);try{if(Mt.globalSingleton)return Mt.globalSingleton;Mt.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.getSessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),Mt.globalSingleton=this,d.autoTrack.pageLifecycle.pageViewId.value=Qi(),d.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){re(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(){Nc.init(),eo.configure(),Qr.configure(),Zr.configure(),Xi.configure()}setDefaultInstanceKey(e){J(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;return(!J(t)||!t)&&(t=this.defaultAnalyticsKey),this.analyticsInstances[t]||(this.analyticsInstances[t]=new jr),this.analyticsInstances[t]}catch(t){re(t);return}}load(e,t,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let s=uc(Mn);fg(s),Vn(Mn,V(s)),this.getAnalyticsInstance(e)?.load(e,t,G(i))}catch(s){re(s)}}trackPageLifecycleEvents(e){let{autoTrack:t,useBeacon:i}=e??{},{enabled:s=!1,options:r={},pageLifecycle:o}=t??{},{events:a=[or.UNLOADED],enabled:l=s,options:c=r}=o??{};d.autoTrack.pageLifecycle.enabled.value=l,d.autoTrack.enabled.value=s||l,l&&this.setupPageUnloadTracking(a,i,c)}setupPageUnloadTracking(e,t,i){(e.length===0||e.includes(or.UNLOADED))&&(t===!0?Vf(s=>{if(s===!1&&d.lifecycle.loaded.value){let r=Date.now(),o=r-d.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(or.UNLOADED,{timeOnPage:o},{...i,originalTimestamp:rc(new Date(r))})}},!0):this.logger.warn(yp($f)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=hg(e);Vn(Mn,V([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(G(e))}catch(t){re(t)}}page(e,t,i,s,r){try{this.getAnalyticsInstance()?.page(zi(G(e),G(t),G(i),G(s),G(r)))}catch(o){re(o)}}track(e,t,i,s){try{this.getAnalyticsInstance()?.track(zr(G(e),G(t),G(i),G(s)))}catch(r){re(r)}}identify(e,t,i,s){try{this.getAnalyticsInstance()?.identify(ec(G(e),G(t),G(i),G(s)))}catch(r){re(r)}}alias(e,t,i,s){try{this.getAnalyticsInstance()?.alias(tc(G(e),G(t),G(i),G(s)))}catch(r){re(r)}}group(e,t,i,s){try{this.getAnalyticsInstance()?.group(nc(G(e),G(t),G(i),G(s)))}catch(r){re(r)}}reset(e){try{this.getAnalyticsInstance()?.reset(G(e))}catch(t){re(t)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(G(e))}catch(t){re(t);return}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(G(e),G(t))}catch(i){re(i)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){re(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){re(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){re(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){re(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(G(e))}catch(t){re(t)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){re(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){re(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(G(e))}catch(t){re(t)}}consent(e){try{this.getAnalyticsInstance()?.consent(G(e))}catch(t){re(t)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(G(e),G(t))}catch(i){re(i)}}};ee(Mt,"globalSingleton",null);on=Mt});var Yc,Xc,Jc,Qc,Zc,no,jn,cn=Ue(()=>{"use strict";Yc="https://deriv.com/cdn-cgi/trace",Xc="https://cdn.growthbook.io",Jc="https://deriv-dataplane.rudderstack.com",Qc="https://ph.deriv.com",Zc="https://us.posthog.com",no=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],jn=()=>{if(typeof window>"u")return".deriv.com";let n=window.location.hostname;if(n==="localhost")return"";let e=no.find(t=>n.includes(t));return e?`.${e}`:".deriv.com"}});function cu(){return lu}function ro(n){let e=2166136261,t=n.length;for(let i=0;i<t;i++)e^=n.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function qn(n,e,t){return t===2?ro(ro(n+e)+"")%1e4/1e4:t===1?ro(e+n)%1e3/1e3:null}function Cm(n){return n<=0?[]:new Array(n).fill(1/n)}function ls(n,e){return n>=e[0]&&n<e[1]}function uu(n,e){let t=qn("__"+e[0],n,1);return t===null?!1:t>=e[1]&&t<e[2]}function du(n,e){for(let t=0;t<e.length;t++)if(ls(n,e[t]))return t;return-1}function ao(n){try{let e=n.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function cs(n,e){if(!e.length)return!1;let t=!1,i=!1;for(let s=0;s<e.length;s++){let r=Dm(n,e[s].type,e[s].pattern);if(e[s].include===!1){if(r)return!1}else t=!0,r&&(i=!0)}return i||!t}function Pm(n,e,t){try{let i=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(i="\\/?"+i.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+i+"$","i").test(n)}catch{return!1}}function Nm(n,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),i=[[n.host,t.host,!1],[n.pathname,t.pathname,!0]];return t.hash&&i.push([n.hash,t.hash,!1]),t.searchParams.forEach((s,r)=>{i.push([n.searchParams.get(r)||"",s,!1])}),!i.some(s=>!Pm(s[0],s[1],s[2]))}catch{return!1}}function Dm(n,e,t){try{let i=new URL(n,"https://_");if(e==="regex"){let s=ao(t);return s?s.test(i.href)||s.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return Nm(i,t);return!1}catch{return!1}}function hu(n,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=Cm(n);t=t||i,t.length!==n&&(t=i);let s=t.reduce((o,a)=>a+o,0);(s<.99||s>1.01)&&(t=i);let r=0;return t.map(o=>{let a=r;return r+=o,[a,a+e*o]})}function fu(n,e,t){if(!e)return null;let i=e.split("?")[1];if(!i)return null;let s=i.replace(/#.*/,"").split("&").map(r=>r.split("=",2)).filter(([r])=>r===n).map(([,r])=>parseInt(r));return s.length>0&&s[0]>=0&&s[0]<t?s[0]:null}function gu(n){try{return n()}catch(e){return console.error(e),!1}}async function Gt(n,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||lu.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let i=await t.importKey("raw",oo(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[s,r]=n.split("."),o=await t.decrypt({name:"AES-CBC",iv:oo(s)},i,oo(r));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Kn(n){return typeof n=="string"?n:JSON.stringify(n)}function Le(n){typeof n=="number"&&(n=n+""),(!n||typeof n!="string")&&(n="0");let e=n.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}function pu(){let n;try{n="1.6.4"}catch{n=""}return n}function vu(n,e){let t,i;try{t=new URL(n),i=new URL(e)}catch(s){return console.error(`Unable to merge query strings: ${s}`),e}return t.searchParams.forEach((s,r)=>{i.searchParams.has(r)||i.searchParams.set(r,s)}),i.toString()}function au(n){return typeof n=="object"&&n!==null}function us(n){return n.urlPatterns&&n.variations.some(e=>au(e)&&"urlRedirect"in e)?"redirect":n.variations.some(e=>au(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function ds(n,e){return new Promise(t=>{let i=!1,s,r=o=>{i||(i=!0,s&&clearTimeout(s),t(o||null))};e&&(s=setTimeout(()=>r(),e)),n.then(o=>r(o)).catch(()=>r())})}var lu,oo,zn=Ue(()=>{"use strict";lu={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};oo=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0))});function yu(n){Object.assign(Ae,n),Ae.backgroundSync||go()}async function bu({instance:n,timeout:e,skipCache:t,allowStale:i,backgroundSync:s}){return s||(Ae.backgroundSync=!1),Fm({instance:n,allowStale:i,timeout:e,skipCache:t})}function xm(n){let e=Wn(n),t=hn.get(e)||new Set;t.add(n),hn.set(e,t)}function Eu(n){hn.forEach(e=>e.delete(n))}function $m(){fn.forEach(n=>{n&&(n.state="idle",ho(n))})}function Lm(){fn.forEach(n=>{n&&n.state==="idle"&&fo(n)})}async function mu(){try{if(!tt.localStorage)return;await tt.localStorage.setItem(Ae.cacheKey,JSON.stringify(Array.from(ut.entries())))}catch{}}async function Fm({instance:n,allowStale:e,timeout:t,skipCache:i}){let s=Wn(n),r=co(n),o=new Date,a=new Date(o.getTime()-Ae.maxAge+Ae.staleTTL);await Mm();let l=!Ae.disableCache&&!i?ut.get(r):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&gn.add(s),l.staleAt<o?lo(n):uo(n),{data:l.data,success:!0,source:"cache"}):await ds(lo(n),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function Wn(n){let[e,t]=n.getApiInfo();return`${e}||${t}`}function co(n){let e=Wn(n);if(!("isRemoteEval"in n)||!n.isRemoteEval())return e;let t=n.getAttributes(),i=n.getCacheKeyAttributes()||Object.keys(n.getAttributes()),s={};i.forEach(a=>{s[a]=t[a]});let r=n.getForcedVariations(),o=n.getUrl();return`${e}||${JSON.stringify({ca:s,fv:r,url:o})}`}async function Mm(){if(!_u){_u=!0;try{if(tt.localStorage){let n=await tt.localStorage.getItem(Ae.cacheKey);if(!Ae.disableCache&&n){let e=JSON.parse(n);e&&Array.isArray(e)&&e.forEach(([t,i])=>{ut.set(t,{...i,staleAt:new Date(i.staleAt)})}),ku()}}}catch{}if(!Ae.disableIdleStreams){let n=dn.startIdleListener();n&&(dn.stopIdleListener=n)}}}function ku(){let n=Array.from(ut.entries()).map(([t,i])=>({key:t,staleAt:i.staleAt.getTime()})).sort((t,i)=>t.staleAt-i.staleAt),e=Math.min(Math.max(0,ut.size-Ae.maxEntries),ut.size);for(let t=0;t<e;t++)ut.delete(n[t].key)}function Su(n,e,t){let i=t.dateUpdated||"",s=new Date(Date.now()+Ae.staleTTL),r=Ae.disableCache?void 0:ut.get(e);if(r&&i&&r.version===i){r.staleAt=s,mu();return}Ae.disableCache||(ut.set(e,{data:t,version:i,staleAt:s,sse:gn.has(n)}),ku()),mu();let o=hn.get(n);o&&o.forEach(a=>Um(a,t))}async function Um(n,e){await n.setPayload(e||n.getPayload())}async function lo(n){let{apiHost:e,apiRequestHeaders:t}=n.getApiHosts(),i=n.getClientKey(),s="isRemoteEval"in n&&n.isRemoteEval(),r=Wn(n),o=co(n),a=hs.get(o);return a||(a=(s?dn.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:n.getAttributes(),forcedVariations:n.getForcedVariations(),forcedFeatures:Array.from(n.getForcedFeatures().entries()),url:n.getUrl()},headers:t}):dn.fetchFeaturesCall({host:e,clientKey:i,headers:t})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&gn.add(r),c.json()}).then(c=>(Su(r,o,c),uo(n),hs.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(hs.delete(o),{data:null,source:"error",success:!1,error:c})),hs.set(o,a)),a}function uo(n,e=!1){let t=Wn(n),i=co(n),{streamingHost:s,streamingHostRequestHeaders:r}=n.getApiHosts(),o=n.getClientKey();if(e&&gn.add(t),Ae.backgroundSync&&gn.has(t)&&tt.EventSource){if(fn.has(t))return;let a={src:null,host:s,clientKey:o,headers:r,cb:l=>{try{if(l.type==="features-updated"){let c=hn.get(t);c&&c.forEach(u=>{lo(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);Su(t,i,c)}a.errors=0}catch{wu(a)}},errors:0,state:"active"};fn.set(t,a),fo(a)}}function wu(n){if(n.state!=="idle"&&(n.errors++,n.errors>3||n.src&&n.src.readyState===2)){let e=Math.pow(3,n.errors-3)*(1e3+Math.random()*1e3);ho(n),setTimeout(()=>{["idle","active"].includes(n.state)||fo(n)},Math.min(e,3e5))}}function ho(n){n.src&&(n.src.onopen=null,n.src.onerror=null,n.src.close(),n.src=null,n.state==="active"&&(n.state="disabled"))}function fo(n){n.src=dn.eventSourceCall({host:n.host,clientKey:n.clientKey,headers:n.headers}),n.state="active",n.src.addEventListener("features",n.cb),n.src.addEventListener("features-updated",n.cb),n.src.onerror=()=>wu(n),n.src.onopen=()=>{n.errors=0}}function Bm(n,e){ho(n),fn.delete(e)}function go(){gn.clear(),fn.forEach(Bm),hn.clear(),dn.stopIdleListener()}function fs(n,e){if(e.streaming){if(!n.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&uo(n,!0),xm(n)}}var Ae,tt,dn,hn,_u,ut,hs,fn,gn,Au=Ue(()=>{"use strict";zn();Ae={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},tt=cu(),dn={fetchFeaturesCall:({host:n,clientKey:e,headers:t})=>tt.fetch(`${n}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:n,clientKey:e,payload:t,headers:i})=>{let s={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(t)};return tt.fetch(`${n}/api/eval/${e}`,s)},eventSourceCall:({host:n,clientKey:e,headers:t})=>t?new tt.EventSource(`${n}/sub/${e}`,{headers:t}):new tt.EventSource(`${n}/sub/${e}`),startIdleListener:()=>{let n;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(n),Lm()):document.visibilityState==="hidden"&&(n=window.setTimeout($m,Ae.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(tt.localStorage=globalThis.localStorage)}catch{}hn=new Map,_u=!1,ut=new Map,hs=new Map,fn=new Map,gn=new Set});function Gm(n){return n==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[n]}}function ms(n){var e=_s.get(n);return e||(e={element:n,attributes:{}},_s.set(n,e)),e}function ys(n,e,t,i,s){var r=t(n),o={isDirty:!1,originalValue:r,virtualValue:r,mutations:[],el:n,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=t(n);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,s(o))}}),mutationRunner:s,setValue:i,getCurrentValue:t};return e==="position"&&n.parentNode?o.observer.observe(n.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(n,Gm(e)),o}function bs(n,e){var t=e.getCurrentValue(e.el);e.virtualValue=n,n&&typeof n!="string"?(!t||n.parentNode!==t.parentNode||n.insertBeforeNode!==t.insertBeforeNode)&&(e.isDirty=!0,Tu()):n!==t&&(e.isDirty=!0,Tu())}function jm(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),bs(iy(e),n)}function Hm(n){var e=new Set(n.originalValue.split(/\s+/).filter(Boolean));n.mutations.forEach(function(t){return t.mutate(e)}),bs(Array.from(e).filter(Boolean).join(" "),n)}function qm(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),bs(e,n)}function Km(n){var e=n.parentSelector,t=n.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var s=t?document.querySelector(t):null;return t&&!s?null:{parentNode:i,insertBeforeNode:s}}function zm(n){var e=n.originalValue;n.mutations.forEach(function(t){var i=t.mutate(),s=Km(i);e=s||e}),bs(e,n)}function Ru(n){var e=ms(n);return e.html||(e.html=ys(n,"html",Wm,Ym,jm)),e.html}function Ou(n){var e=ms(n);return e.position||(e.position=ys(n,"position",Xm,Jm,zm)),e.position}function Cu(n){var e=ms(n);return e.classes||(e.classes=ys(n,"class",Zm,Qm,Hm)),e.classes}function Pu(n,e){var t=ms(n);return t.attributes[e]||(t.attributes[e]=ys(n,e,ey(e),ty(e),qm)),t.attributes[e]}function ny(n,e){var t=_s.get(n);if(t)if(e==="html"){var i,s;(i=t.html)==null||(s=i.observer)==null||s.disconnect(),delete t.html}else if(e==="class"){var r,o;(r=t.classes)==null||(o=r.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var c,u,h;(c=t.attributes)==null||(u=c[e])==null||(h=u.observer)==null||h.disconnect(),delete t.attributes[e]}}function iy(n){return gs||(gs=document.createElement("div")),gs.innerHTML=n,gs.innerHTML}function ps(n,e,t){if(t.isDirty){t.isDirty=!1;var i=t.virtualValue;t.mutations.length||ny(n,e),t.setValue(n,i)}}function sy(n,e){n.html&&ps(e,"html",n.html),n.classes&&ps(e,"class",n.classes),n.position&&ps(e,"position",n.position),Object.keys(n.attributes).forEach(function(t){ps(e,t,n.attributes[t])})}function Tu(){_s.forEach(sy)}function ry(n,e){var t=null;n.kind==="html"?t=Ru(e):n.kind==="class"?t=Cu(e):n.kind==="attribute"?t=Pu(e,n.attribute):n.kind==="position"&&(t=Ou(e)),t&&(t.mutations.push(n),t.mutationRunner(t))}function oy(n,e){var t=null;if(n.kind==="html"?t=Ru(e):n.kind==="class"?t=Cu(e):n.kind==="attribute"?t=Pu(e,n.attribute):n.kind==="position"&&(t=Ou(e)),!!t){var i=t.mutations.indexOf(n);i!==-1&&t.mutations.splice(i,1),t.mutationRunner(t)}}function Nu(n){if(!(n.kind==="position"&&n.elements.size===1)){var e=new Set(n.elements),t=document.querySelectorAll(n.selector);t.forEach(function(i){e.has(i)||(n.elements.add(i),ry(n,i))})}}function ay(n){n.elements.forEach(function(e){return oy(n,e)}),n.elements.clear(),mo.delete(n)}function Iu(){mo.forEach(Nu)}function ly(){typeof document>"u"||(po||(po=new MutationObserver(function(){Iu()})),Iu(),po.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Es(n){return typeof document>"u"?_o:(mo.add(n),Nu(n),{revert:function(){ay(n)}})}function vo(n,e){return Es({kind:"html",elements:new Set,mutate:e,selector:n})}function Du(n,e){return Es({kind:"position",elements:new Set,mutate:e,selector:n})}function Yn(n,e){return Es({kind:"class",elements:new Set,mutate:e,selector:n})}function vs(n,e,t){return Vm.test(e)?e==="class"||e==="className"?Yn(n,function(i){var s=t(Array.from(i).join(" "));i.clear(),s&&s.split(/\s+/g).filter(Boolean).forEach(function(r){return i.add(r)})}):Es({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:n}):_o}function cy(n){var e=n.selector,t=n.action,i=n.value,s=n.attribute,r=n.parentSelector,o=n.insertBeforeSelector;if(s==="html"){if(t==="append")return vo(e,function(a){return a+(i??"")});if(t==="set")return vo(e,function(){return i??""})}else if(s==="class"){if(t==="append")return Yn(e,function(a){i&&a.add(i)});if(t==="remove")return Yn(e,function(a){i&&a.delete(i)});if(t==="set")return Yn(e,function(a){a.clear(),i&&a.add(i)})}else if(s==="position"){if(t==="set"&&r)return Du(e,function(){return{insertBeforeSelector:o,parentSelector:r}})}else{if(t==="append")return vs(e,s,function(a){return a!==null?a+(i??""):i??""});if(t==="set")return vs(e,s,function(){return i??""});if(t==="remove")return vs(e,s,function(){return null})}return _o}var Vm,_o,_s,mo,Wm,Ym,Xm,Jm,Qm,Zm,ey,ty,gs,po,uy,xu,$u=Ue(()=>{"use strict";Vm=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,_o={revert:function(){}},_s=new Map,mo=new Set;Wm=function(e){return e.innerHTML},Ym=function(e,t){return e.innerHTML=t};Xm=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Jm=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};Qm=function(e,t){return t?e.className=t:e.removeAttribute("class")},Zm=function(e){return e.className};ey=function(e){return function(t){var i;return(i=t.getAttribute(e))!=null?i:null}},ty=function(e){return function(t,i){return i!==null?t.setAttribute(e,i):t.removeAttribute(e)}};ly();uy={html:vo,classes:Yn,attribute:vs,position:Du,declarative:cy},xu=uy});function wt(n,e,t){t=t||{};for(let[i,s]of Object.entries(e))switch(i){case"$or":if(!Mu(n,s,t))return!1;break;case"$nor":if(Mu(n,s,t))return!1;break;case"$and":if(!py(n,s,t))return!1;break;case"$not":if(wt(n,s,t))return!1;break;default:if(!Xn(s,dy(n,i),t))return!1}return!0}function dy(n,e){let t=e.split("."),i=n;for(let s=0;s<t.length;s++)if(i&&typeof i=="object"&&t[s]in i)i=i[t[s]];else return null;return i}function Lu(n,e=!1){let t=`${n}${e?"/i":""}`;return yo[t]||(yo[t]=new RegExp(n.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),yo[t]}function Xn(n,e,t,i=!1){if(typeof n=="string")return i?String(e).toLowerCase()===n.toLowerCase():e+""===n;if(typeof n=="number")return e*1===n;if(typeof n=="boolean")return e!==null&&!!e===n;if(n===null)return e===null;if(Array.isArray(n)||!Uu(n))return JSON.stringify(e)===JSON.stringify(n);for(let s in n)if(!gy(s,e,n[s],t))return!1;return!0}function Uu(n){let e=Object.keys(n);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function hy(n){if(n===null)return"null";if(Array.isArray(n))return"array";let e=typeof n;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function fy(n,e,t){if(!Array.isArray(n))return!1;let i=Uu(e)?s=>Xn(e,s,t):s=>wt(s,e,t);for(let s=0;s<n.length;s++)if(n[s]&&i(n[s]))return!0;return!1}function pn(n,e,t=!1){if(t){let i=s=>typeof s=="string"?s.toLowerCase():s;return Array.isArray(n)?n.some(s=>e.some(r=>i(s)===i(r))):e.some(s=>i(n)===i(s))}return Array.isArray(n)?n.some(i=>e.includes(i)):e.includes(n)}function Fu(n,e,t,i=!1){if(!Array.isArray(n))return!1;for(let s=0;s<e.length;s++){let r=!1;for(let o=0;o<n.length;o++)if(Xn(e[s],n[o],t,i)){r=!0;break}if(!r)return!1}return!0}function gy(n,e,t,i){switch(n){case"$veq":return Le(e)===Le(t);case"$vne":return Le(e)!==Le(t);case"$vgt":return Le(e)>Le(t);case"$vgte":return Le(e)>=Le(t);case"$vlt":return Le(e)<Le(t);case"$vlte":return Le(e)<=Le(t);case"$eq":return e===t;case"$ne":return e!==t;case"$lt":return e<t;case"$lte":return e<=t;case"$gt":return e>t;case"$gte":return e>=t;case"$exists":return t?e!=null:e==null;case"$in":return Array.isArray(t)?pn(e,t):!1;case"$ini":return Array.isArray(t)?pn(e,t,!0):!1;case"$inGroup":return pn(e,i[t]||[]);case"$notInGroup":return!pn(e,i[t]||[]);case"$nin":return Array.isArray(t)?!pn(e,t):!1;case"$nini":return Array.isArray(t)?!pn(e,t,!0):!1;case"$not":return!Xn(t,e,i);case"$size":return Array.isArray(e)?Xn(t,e.length,i):!1;case"$elemMatch":return fy(e,t,i);case"$all":return Array.isArray(t)?Fu(e,t,i):!1;case"$alli":return Array.isArray(t)?Fu(e,t,i,!0):!1;case"$regex":try{return Lu(t).test(e)}catch{return!1}case"$regexi":try{return Lu(t,!0).test(e)}catch{return!1}case"$type":return hy(e)===t;default:return console.error("Unknown operator: "+n),!1}}function Mu(n,e,t){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(wt(n,e[i],t))return!0;return!1}function py(n,e,t){for(let i=0;i<e.length;i++)if(!wt(n,e[i],t))return!1;return!0}var yo,Bu=Ue(()=>{"use strict";zn();yo={}});function my(n){let e=new Map;return n.global.forcedFeatureValues&&n.global.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),n.user.forcedFeatureValues&&n.user.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),e}function yy(n){return n.global.forcedVariations&&n.user.forcedVariations?{...n.global.forcedVariations,...n.user.forcedVariations}:n.global.forcedVariations?n.global.forcedVariations:n.user.forcedVariations?n.user.forcedVariations:{}}async function vn(n){try{await n()}catch{}}function Vu(n,e,t){if(n.user.trackedExperiments){let s=ws(e,t);if(n.user.trackedExperiments.has(s))return[];n.user.trackedExperiments.add(s)}n.user.enableDevMode&&n.user.devLogs&&n.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let i=[];if(n.global.trackingCallback){let s=n.global.trackingCallback;i.push(vn(()=>s(e,t,n.user)))}if(n.user.trackingCallback){let s=n.user.trackingCallback;i.push(vn(()=>s(e,t)))}if(n.global.eventLogger){let s=n.global.eventLogger;i.push(vn(()=>s(_y,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},n.user)))}return i}function by(n,e,t){if(n.user.trackedFeatureUsage){let i=JSON.stringify(t.value);if(n.user.trackedFeatureUsage[e]===i)return;n.user.trackedFeatureUsage[e]=i,n.user.enableDevMode&&n.user.devLogs&&n.user.devLogs.push({featureKey:e,result:t,timestamp:Date.now().toString(),logType:"feature"})}if(n.global.onFeatureUsage){let i=n.global.onFeatureUsage;vn(()=>i(e,t,n.user))}if(n.user.onFeatureUsage){let i=n.user.onFeatureUsage;vn(()=>i(e,t))}if(n.global.eventLogger){let i=n.global.eventLogger;vn(()=>i(vy,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},n.user))}}function ks(n,e){if(e.stack.evaluatedFeatures.has(n))return At(e,n,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(n),e.stack.id=n;let t=my(e);if(t.has(n))return At(e,n,t.get(n),"override");if(!e.global.features||!e.global.features[n])return At(e,n,null,"unknownFeature");let i=e.global.features[n];if(i.rules){let s=new Set(e.stack.evaluatedFeatures);e:for(let r of i.rules){if(r.parentConditions)for(let l of r.parentConditions){e.stack.evaluatedFeatures=new Set(s);let c=ks(l.id,e);if(c.source==="cyclicPrerequisite")return At(e,n,null,"cyclicPrerequisite");let u={value:c.value};if(!wt(u,l.condition||{})){if(l.gate)return At(e,n,null,"prerequisite");continue e}}if(r.filters&&Hu(r.filters,e))continue;if("force"in r){if(r.condition&&!ju(r.condition,e)||!Ey(e,r.seed||n,r.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!r.disableStickyBucketing?r.fallbackAttribute:void 0,r.range,r.coverage,r.hashVersion))continue;return r.tracks&&r.tracks.forEach(l=>{!Vu(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),At(e,n,r.force,"force",r.id)}if(!r.variations)continue;let o={variations:r.variations,key:r.key||n};"coverage"in r&&(o.coverage=r.coverage),r.weights&&(o.weights=r.weights),r.hashAttribute&&(o.hashAttribute=r.hashAttribute),r.fallbackAttribute&&(o.fallbackAttribute=r.fallbackAttribute),r.disableStickyBucketing&&(o.disableStickyBucketing=r.disableStickyBucketing),r.bucketVersion!==void 0&&(o.bucketVersion=r.bucketVersion),r.minBucketVersion!==void 0&&(o.minBucketVersion=r.minBucketVersion),r.namespace&&(o.namespace=r.namespace),r.meta&&(o.meta=r.meta),r.ranges&&(o.ranges=r.ranges),r.name&&(o.name=r.name),r.phase&&(o.phase=r.phase),r.seed&&(o.seed=r.seed),r.hashVersion&&(o.hashVersion=r.hashVersion),r.filters&&(o.filters=r.filters),r.condition&&(o.condition=r.condition);let{result:a}=Ss(o,n,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return At(e,n,a.value,"experiment",r.id,o,a)}}return At(e,n,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function Ss(n,e,t){let i=n.key,s=n.variations.length;if(s<2)return{result:te(t,n,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:te(t,n,-1,!1,e)};if(n=ky(n,t),n.urlPatterns&&!cs(t.user.url||"",n.urlPatterns))return{result:te(t,n,-1,!1,e)};let r=fu(i,t.user.url||"",s);if(r!==null)return{result:te(t,n,r,!1,e)};let o=yy(t);if(i in o){let _=o[i];return{result:te(t,n,_,!1,e)}}if(n.status==="draft"||n.active===!1)return{result:te(t,n,-1,!1,e)};let{hashAttribute:a,hashValue:l}=jt(t,n.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0);if(!l)return{result:te(t,n,-1,!1,e)};let c=-1,u=!1,h=!1;if(t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing){let{variation:_,versionIsBlocked:E}=Ay({ctx:t,expKey:n.key,expBucketVersion:n.bucketVersion,expHashAttribute:n.hashAttribute,expFallbackAttribute:n.fallbackAttribute,expMinBucketVersion:n.minBucketVersion,expMeta:n.meta});u=_>=0,c=_,h=!!E}if(!u){if(n.filters){if(Hu(n.filters,t))return{result:te(t,n,-1,!1,e)}}else if(n.namespace&&!uu(l,n.namespace))return{result:te(t,n,-1,!1,e)};if(n.include&&!gu(n.include))return{result:te(t,n,-1,!1,e)};if(n.condition&&!ju(n.condition,t))return{result:te(t,n,-1,!1,e)};if(n.parentConditions){let _=new Set(t.stack.evaluatedFeatures);for(let E of n.parentConditions){t.stack.evaluatedFeatures=new Set(_);let b=ks(E.id,t);if(b.source==="cyclicPrerequisite")return{result:te(t,n,-1,!1,e)};let C={value:b.value};if(!wt(C,E.condition||{}))return{result:te(t,n,-1,!1,e)}}}if(n.groups&&!wy(n.groups,t))return{result:te(t,n,-1,!1,e)}}if(n.url&&!Sy(n.url,t))return{result:te(t,n,-1,!1,e)};let g=qn(n.seed||i,l,n.hashVersion||1);if(g===null)return{result:te(t,n,-1,!1,e)};if(!u){let _=n.ranges||hu(s,n.coverage===void 0?1:n.coverage,n.weights);c=du(g,_)}if(h)return{result:te(t,n,-1,!1,e,void 0,!0)};if(c<0)return{result:te(t,n,-1,!1,e)};if("force"in n)return{result:te(t,n,n.force===void 0?-1:n.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:te(t,n,-1,!1,e)};if(n.status==="stopped")return{result:te(t,n,-1,!1,e)};let f=te(t,n,c,!0,e,g,u);if(t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing){let{changed:_,key:E,doc:b}=Iy(t,a,Kn(l),{[bo(n.key,n.bucketVersion)]:f.key});_&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[E]=b,t.user.saveStickyBucketAssignmentDoc(b))}let p=Vu(t,n,f);p.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:n,result:f});let v=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in n&&n.changeId&&t.global.recordChangeId&&t.global.recordChangeId(n.changeId),{result:f,trackingCall:v}}function At(n,e,t,i,s,r,o){let a={value:t,on:!!t,off:!t,source:i,ruleId:s||""};return r&&(a.experiment=r),o&&(a.experimentResult=o),i!=="override"&&by(n,e,a),a}function Gu(n){return{...n.user.attributes,...n.user.attributeOverrides}}function ju(n,e){return wt(Gu(e),n,e.global.savedGroups||{})}function Hu(n,e){return n.some(t=>{let{hashValue:i}=jt(e,t.attribute);if(!i)return!0;let s=qn(t.seed,i,t.hashVersion||2);return s===null?!0:!t.ranges.some(r=>ls(s,r))})}function Ey(n,e,t,i,s,r,o){if(!s&&r===void 0)return!0;if(!s&&r===0)return!1;let{hashValue:a}=jt(n,t,i);if(!a)return!1;let l=qn(e,a,o||1);return l===null?!1:s?ls(l,s):r!==void 0?l<=r:!0}function te(n,e,t,i,s,r,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:c}=jt(n,e.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),u=e.meta?e.meta[t]:{},h={key:u.key||""+t,featureId:s,inExperiment:a,hashUsed:i,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};return u.name&&(h.name=u.name),r!==void 0&&(h.bucket=r),u.passthrough&&(h.passthrough=u.passthrough),h}function ky(n,e){let t=n.key,i=e.global.overrides;return i&&i[t]&&(n=Object.assign({},n,i[t]),typeof n.url=="string"&&(n.url=ao(n.url))),n}function jt(n,e,t){let i=e||"id",s="",r=Gu(n);return r[i]&&(s=r[i]),!s&&t&&(r[t]&&(s=r[t]),s&&(i=t)),{hashAttribute:i,hashValue:s}}function Sy(n,e){let t=e.user.url;if(!t)return!1;let i=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(n.test(t)||n.test(i))}function wy(n,e){let t=e.global.groups||{};for(let i=0;i<n.length;i++)if(t[n[i]])return!0;return!1}function Ay({ctx:n,expKey:e,expBucketVersion:t,expHashAttribute:i,expFallbackAttribute:s,expMinBucketVersion:r,expMeta:o}){t=t||0,r=r||0,i=i||"id",o=o||[];let a=bo(e,t),l=Ty(n,i,s);if(r>0)for(let h=0;h<r;h++){let g=bo(e,h);if(l[g]!==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 bo(n,e){return e=e||0,`${n}__${e}`}function Eo(n,e){return`${n}||${e}`}function Ty(n,e,t){if(!n.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:s}=jt(n,e),r=Eo(i,Kn(s)),{hashAttribute:o,hashValue:a}=jt(n,t),l=a?Eo(o,Kn(a)):null,c={};return l&&n.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,n.user.stickyBucketAssignmentDocs[l].assignments||{}),n.user.stickyBucketAssignmentDocs[r]&&Object.assign(c,n.user.stickyBucketAssignmentDocs[r].assignments||{}),c}function Iy(n,e,t,i){let s=Eo(e,t),r=n.user.stickyBucketAssignmentDocs&&n.user.stickyBucketAssignmentDocs[s]?n.user.stickyBucketAssignmentDocs[s].assignments||{}:{},o={...r,...i},a=JSON.stringify(r)!==JSON.stringify(o);return{key:s,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function Ry(n,e){let t=new Set,i=e&&e.features?e.features:n.global.features||{},s=e&&e.experiments?e.experiments:n.global.experiments||[];return Object.keys(i).forEach(r=>{let o=i[r];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),s.map(r=>{t.add(r.hashAttribute||"id"),r.fallbackAttribute&&t.add(r.fallbackAttribute)}),Array.from(t)}async function qu(n,e,t){let i=ko(n,t);return e.getAllAssignments(i)}function ko(n,e){let t={};return Ry(n,e).forEach(s=>{let{hashValue:r}=jt(n,s);t[s]=Kn(r)}),t}async function Ku(n,e,t){if(n={...n},n.encryptedFeatures){try{n.features=JSON.parse(await Gt(n.encryptedFeatures,e,t))}catch(i){console.error(i)}delete n.encryptedFeatures}if(n.encryptedExperiments){try{n.experiments=JSON.parse(await Gt(n.encryptedExperiments,e,t))}catch(i){console.error(i)}delete n.encryptedExperiments}if(n.encryptedSavedGroups){try{n.savedGroups=JSON.parse(await Gt(n.encryptedSavedGroups,e,t))}catch(i){console.error(i)}delete n.encryptedSavedGroups}return n}function zu(n){let e=n.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(n.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:n.apiHostRequestHeaders,streamingHostRequestHeaders:n.streamingHostRequestHeaders}}function ws(n,e){return e.hashAttribute+e.hashValue+n.key+e.variationId}var vy,_y,Wu=Ue(()=>{"use strict";Bu();zn();vy="Feature Evaluated",_y="Experiment Viewed"});var _n,Oy,Jn,Yu=Ue(()=>{"use strict";$u();zn();Au();Wu();_n=typeof window<"u"&&typeof document<"u",Oy=pu(),Jn=class{constructor(e){if(e=e||{},this.version=Oy,this._options=this.context=e,this._renderer=e.renderer||null,this._trackedExperiments=new Set,this._completedChangeIds=new Set,this._trackedFeatures={},this.debug=!!e.debug,this._subscriptions=new Set,this.ready=!1,this._assigned=new Map,this._activeAutoExperiments=new Map,this._triggeredExpKeys=new Set,this._initialized=!1,this._redirectedUrl="",this._deferredTrackingCalls=new Map,this._autoExperimentsAllowed=!e.disableExperimentsOnLoad,this._destroyCallbacks=[],this.logs=[],this.log=this.log.bind(this),this._saveDeferredTrack=this._saveDeferredTrack.bind(this),this._onExperimentEval=this._onExperimentEval.bind(this),this._fireSubscriptions=this._fireSubscriptions.bind(this),this._recordChangedId=this._recordChangedId.bind(this),e.remoteEval){if(e.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!e.clientKey)throw new Error("Missing clientKey");let t=!1;try{t=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(t)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(e.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(e.stickyBucketService){let t=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=i=>t.saveAssignments(i)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),_n&&e.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),e.experiments&&(this.ready=!0,this._updateAllAutoExperiments()),this._options.stickyBucketService&&this._options.stickyBucketAssignmentDocs)for(let t in this._options.stickyBucketAssignmentDocs){let i=this._options.stickyBucketAssignmentDocs[t];i&&this._options.stickyBucketService.saveAssignments(i).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await Ku(e,this._options.decryptionKey);this._decryptedPayload=t,await this.refreshStickyBuckets(t),t.features&&(this._options.features=t.features),t.savedGroups&&(this._options.savedGroups=t.savedGroups),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let t=e.payload;if(t.encryptedExperiments||t.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this._options.stickyBucketService&&!this._options.stickyBucketAssignmentDocs&&(this._options.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this._options.stickyBucketService,t)),this._payload=t,this._decryptedPayload=t,t.features&&(this._options.features=t.features),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,fs(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&yu(e.cacheSettings),e.payload)return await this.setPayload(e.payload),fs(this,e),{success:!0,source:"init"};{let{data:t,...i}=await this._refresh({...e,allowStale:!0});return fs(this,e),await this.setPayload(t||{}),i}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return zu(this._options)}getClientKey(){return this._options.clientKey||""}getPayload(){return this._payload||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this._decryptedPayload||this.getPayload()}isRemoteEval(){return this._options.remoteEval||!1}getCacheKeyAttributes(){return this._options.cacheKeyAttributes}async _refresh({timeout:e,skipCache:t,allowStale:i,streaming:s}){if(!this._options.clientKey)throw new Error("Missing clientKey");return bu({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:i,backgroundSync:s??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,t,i){let s=await Gt(e,t||this._options.decryptionKey,i);this.setFeatures(JSON.parse(s))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,i){let s=await Gt(e,t||this._options.decryptionKey,i);this.setExperiments(JSON.parse(s))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(t=>{try{t()}catch(i){console.error(i)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,Eu(this),e.destroyAllStreams&&go(),this.logs=[],_n&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(t=>{t.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,t){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=t,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:t}=Ss(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(i=>i.key===e).map(i=>this._runAutoExperiment(i)).filter(i=>i!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,t){let i=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!i)return null;let s=this._isAutoExperimentBlockedByContext(e),r,o;s?r=te(this._getEvalContext(),e,-1,!1,""):({result:r,trackingCall:o}=Ss(e,null,this._getEvalContext()),this._onExperimentEval(e,r));let a=JSON.stringify(r.value);if(!t&&r.inExperiment&&i&&i.valueHash===a)return r;if(i&&this._undoActiveAutoExperiment(e),r.inExperiment){let l=us(e);if(l==="redirect"&&r.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?vu(this._getContextUrl(),r.value.urlRedirect):r.value.urlRedirect;if(cs(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(_n)Promise.all([...o?[ds(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(g=>window.setTimeout(g,this._options.navigateDelay??h))]).then(()=>{try{u(c)}catch(g){console.error(g)}});else try{u(c)}catch(g){console.error(g)}}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 t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],i=new Set(t);this._activeAutoExperiments.forEach((s,r)=>{i.has(r)||(s.undo(),this._activeAutoExperiments.delete(r))});for(let s of t){let r=this._runAutoExperiment(s,e);if(r&&r.inExperiment&&us(s)==="redirect")break}}_onExperimentEval(e,t){let i=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,i)}_fireSubscriptions(e,t,i){(!i||i.result.inExperiment!==t.inExperiment||i.result.variationId!==t.variationId)&&this._subscriptions.forEach(s=>{try{s(e,t)}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,t){let i=this.evalFeature(e).value;return i===null?t:i}feature(e){return this.evalFeature(e)}evalFeature(e){return ks(e,this._getEvalContext())}log(e,t){this.debug&&(this._options.log?this._options.log(e,t):console.log(e,t))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(t=>t&&t.experiment&&t.result).map(t=>[ws(t.experiment,t.result),t]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(t=>{!t||!t.experiment||!t.result?console.error("Invalid deferred tracking call",{call:t}):e.push(this._options.trackingCallback(t.experiment,t.result))}),this._deferredTrackingCalls.clear(),await Promise.all(e)}setTrackingCallback(e){this._options.trackingCallback=e,this.fireDeferredTrackingCalls()}setEventLogger(e){this._options.eventLogger=e}async logEvent(e,t){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:t,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,t||{},this._getUserContext())}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(ws(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(_n?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=us(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(i=>i.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let i=new URL(this._getContextUrl());for(let s of e.variations){if(!s||!s.urlRedirect)continue;let r=new URL(s.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}:_n?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!_n)return;let t=[];if(e.css){let i=document.createElement("style");i.innerHTML=e.css,document.head.appendChild(i),t.push(()=>i.remove())}if(e.js){let i=document.createElement("script");i.innerHTML=e.js,this._options.jsInjectionNonce&&(i.nonce=this._options.jsInjectionNonce),document.head.appendChild(i),t.push(()=>i.remove())}return e.domMutations&&e.domMutations.forEach(i=>{t.push(xu.declarative(i).revert)}),()=>{t.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),i=await qu(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=i}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let i=this._getEvalContext(),s=ko(i,t);return e.getAllAssignmentsSync(s)}inDevMode(){return!!this._options.enableDevMode}}});var Xu=Ue(()=>{"use strict";Yu()});var Ju={};rr(Ju,{Growthbook:()=>So});var Ge,So,Qu=Ue(()=>{"use strict";Xu();to();cn();Ge=class Ge{constructor(e,t,i={}){this.analytics=new on;this.isLoaded=!1;this.status=void 0;this.setAttributes=({id:e,country:t,user_language:i,device_language:s,device_type:r,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:c,url:u,domain:h,utm_content:g,residence_country:f,loggedIn:p,network_type:v,network_downlink:_,user_id:E,anonymous_id:b,account_mode:C})=>{let N=this.GrowthBook.getAttributes();this.GrowthBook.setAttributes({...N,id:e,...E!==void 0&&{user_id:E},...b!==void 0&&{anonymous_id:b},...t!==void 0&&{country:t},...f!==void 0&&{residence_country:f},...i!==void 0&&{user_language:i},...s!==void 0&&{device_language:s},...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},...g!==void 0&&{utm_content:g},...p!==void 0&&{loggedIn:p},...v!==void 0&&{network_type:v},..._!==void 0&&{network_downlink:_},...C!==void 0&&{account_mode:C}})};this.getFeatureValue=(e,t)=>this.GrowthBook.getFeatureValue(e,t);this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>this.GrowthBook.evalFeature(e);this.setUrl=e=>this.GrowthBook.setURL(e);this.isOn=e=>this.GrowthBook.isOn(e);this.init=async()=>{let e=await this.GrowthBook.init({timeout:2e3,streaming:!0}).catch(()=>{});this.status=e,this.isLoaded=!0};this.destroy=()=>{this.GrowthBook.destroy(),this.isLoaded=!1,this.status=void 0};let s=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new Jn({apiHost:Xc,clientKey:e,decryptionKey:t,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:s,trackingCallback:(r,o)=>{typeof window<"u"&&window.dataLayer&&window.dataLayer.push({event:"experiment_viewed",event_category:"experiment",rudder_anonymous_id:this.analytics.getAnonymousId(),experiment_id:r.key,variation_id:o.variationId}),this.analytics.track("experiment_viewed",{experimentId:r.key,variationId:o.variationId})},...i}),this.init()}reapplyExperiment(e){let t=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(t)}waitForIsLoaded(e=1e4){return new Promise((t,i)=>{let s=Date.now(),r=setInterval(()=>{this.isLoaded?(clearInterval(r),t()):Date.now()-s>=e&&(clearInterval(r),i(new Error("GrowthBook initialization timeout")))},100)})}};Ge.getGrowthBookInstance=(e,t,i)=>Ge._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),Ge._instance):(Ge._instance=new Ge(e,t??"",i),Ge._instance),Ge.resetInstance=()=>{Ge._instance&&(Ge._instance.destroy(),Ge._instance=void 0)};So=Ge});function nd(n,e,t,i,s,r,o){try{var a=n[r](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(i,s)}function kn(n){return function(){var e=this,t=arguments;return new Promise((function(i,s){var r=n.apply(e,t);function o(l){nd(r,i,s,o,a,"next",l)}function a(l){nd(r,i,s,o,a,"throw",l)}o(void 0)}))}}function A(){return A=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},A.apply(null,arguments)}function Yd(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.indexOf(i)!==-1)continue;t[i]=n[i]}return t}function F(n,e){return n.indexOf(e)!==-1}function qo(n){return n===null||typeof n!="object"}function Ns(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function Qd(n){return!k(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(n,Event)}function it(n,e,t,i,s){return e>t&&(i.warn("min cannot be greater than max."),e=t),yt(n)?n>t?(i.warn(" cannot be greater than max: "+t+". Using max value instead."),t):n<e?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):n:(i.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+s),it(s||t,e,t,i))}function Wy(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return To&&t.length===rd||(rd=t.length,To=t.reduce(((i,s)=>{As||(As={});var r=As[s];if(r)i[r[0]]=r[1];else for(var o=n(s),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,u=e[s];if(c&&u){i[c]=u,As[s]=[c,u];break}}return i}),{})),To}}function Jo(n,e,t,i,s){var r={platform:n,filename:e,function:t==="<anonymous>"?Rn:t,in_app:!0};return k(i)||(r.lineno=i),k(s)||(r.colno=s),r}function nb(){return(function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return function(s,r){r===void 0&&(r=0);for(var o=[],a=s.split(`
|
|
14
|
-
`),l=r;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=ld.test(c)?c.replace(ld,"$1"):c;if(!u.match(/\S*Error: /)){for(var h of t){var g=h(u,n);if(g){o.push(g);break}}if(o.length>=cd)break}}}return(function(f){if(!f.length)return[];var p=Array.from(f);return p.reverse(),p.slice(0,cd).map((v=>{return A({},v,{filename:v.filename||(_=p,_[_.length-1]||{}).filename,function:v.function||Rn});var _}))})(o)}})("web:javascript",Qy,tb)}function vh(n,e){e===void 0&&(e=40);var t=Object.keys(n);if(t.sort(),!t.length)return"[object has no keys]";for(var i=t.length;i>0;i--){var s=t.slice(0,i).join(", ");if(!(s.length>e))return i===t.length||s.length<=e?s:s.slice(0,e)+"..."}return""}function Nt(n,e,t){if(H(n)){if(Zu&&n.forEach===Zu)n.forEach(e,t);else if("length"in n&&n.length===+n.length){for(var i=0,s=n.length;i<s;i++)if(i in n&&e.call(t,n[i],i)===xs)return}}}function Y(n,e,t){if(!M(n)){if(H(n))return Nt(n,e,t);if(Dy(n)){for(var i of n.entries())if(e.call(t,i[1],i[0])===xs)return}else for(var s in n)if(Jd.call(n,s)&&e.call(t,n[s],s)===xs)return}}function Cs(n){for(var e=Object.keys(n),t=e.length,i=new Array(t);t--;)i[t]=[e[t],n[e[t]]];return i}function ab(n,e){return t=n,i=r=>fe(r)&&!Je(e)?r.slice(0,e):r,s=new Set,(function r(o,a){return o!==Object(o)?i?i(o,a):o:s.has(o)?void 0:(s.add(o),H(o)?(l=[],Nt(o,(c=>{l.push(r(c))}))):(l={},Y(o,((c,u)=>{s.has(c)||(l[u]=r(c,u))}))),l);var l})(t);var t,i,s}function cb(n){var e=n?.hostname;if(!fe(e))return!1;var t=e.split(".").slice(-2).join(".");for(var i of lb)if(t===i)return!1;return!0}function mh(n,e){for(var t=0;t<n.length;t++)if(e(n[t]))return n[t]}function ue(n,e,t,i){var{capture:s=!1,passive:r=!0}=i??{};n?.addEventListener(e,t,{capture:s,passive:r})}function md(n){return n instanceof Element&&(n.id===kh||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function nr(n){return!!n&&n.nodeType===1}function Dt(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function Sh(n){return!!n&&n.nodeType===3}function wh(n){return!!n&&n.nodeType===11}function ol(n){return n?er(n).split(/\s+/):[]}function yd(n){var e=m?.location.href;return!!(e&&n&&n.some((t=>e.match(t))))}function Us(n){var e="";switch(typeof n.className){case"string":e=n.className;break;case"object":e=(n.className&&"baseVal"in n.className?n.className.baseVal:null)||n.getAttribute("class")||"";break;default:e=""}return ol(e)}function Ah(n){return M(n)?null:er(n).split(/(\s+)/).filter((e=>ki(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function wi(n){var e="";return pa(n)&&!Ch(n)&&n.childNodes&&n.childNodes.length&&Y(n.childNodes,(function(t){var i;Sh(t)&&t.textContent&&(e+=(i=Ah(t.textContent))!==null&&i!==void 0?i:"")})),er(e)}function Th(n){return k(n.target)?n.srcElement||null:(e=n.target)!=null&&e.shadowRoot?n.composedPath()[0]||null:n.target||null;var e}function Ih(n,e){if(k(e))return!0;var t,i=function(r){if(e.some((o=>r.matches(o))))return{v:!0}};for(var s of n)if(t=i(s))return t.v;return!1}function Rh(n){var e=n.parentNode;return!(!e||!nr(e))&&e}function hb(n,e){if(!m||ll(n))return!1;var t,i,s;if(mt(e)?(t=!!e&&Ed,i=void 0):(t=(s=e?.css_selector_ignorelist)!==null&&s!==void 0?s:Ed,i=e?.content_ignorelist),t===!1)return!1;var{targetElementList:r}=Oh(n,!1);return!(function(o,a){if(o===!1||k(o))return!1;var l;if(o===!0)l=db;else{if(!H(o))return!1;if(o.length>bd)return w.error("[PostHog] content_ignorelist array cannot exceed "+bd+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map((c=>c.toLowerCase()))}return a.some((c=>{var{safeText:u,ariaLabel:h}=c;return l.some((g=>u.includes(g)||h.includes(g)))}))})(i,r.map((o=>{var a;return{safeText:wi(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!Ih(r,t)}function fb(n,e,t,i,s){var r,o,a,l;if(t===void 0&&(t=void 0),!m||ll(n)||(r=t)!=null&&r.url_allowlist&&!yd(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&yd(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some((p=>e.type===p)))return!1}var{parentIsUsefulElement:u,targetElementList:h}=Oh(n,i);if(!(function(p,v){var _=v?.element_allowlist;if(k(_))return!0;var E,b=function(N){if(_.some((I=>N.tagName.toLowerCase()===I)))return{v:!0}};for(var C of p)if(E=b(C))return E.v;return!1})(h,t)||!Ih(h,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var g=m.getComputedStyle(n);if(g&&g.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var f=n.tagName.toLowerCase();switch(f){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return u?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(al.indexOf(f)>-1||n.getAttribute("contenteditable")==="true")}}function pa(n){for(var e=n;e.parentNode&&!Dt(e,"body");e=e.parentNode){var t=Us(e);if(F(t,"ph-sensitive")||F(t,"ph-no-capture"))return!1}if(F(Us(n),"ph-include"))return!0;var i=n.type||"";if(fe(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var s=n.name||n.id||"";return!(fe(s)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,"")))}function Ch(n){return!!(Dt(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||Dt(n,"select")||Dt(n,"textarea")||n.getAttribute("contenteditable")==="true")}function ki(n,e){return e===void 0&&(e=!0),!(M(n)||fe(n)&&(n=er(n),(e?gb:pb).test((n||"").replace(/[- ]/g,""))||(e?vb:_b).test(n)))}function Dh(n){var e=wi(n);return ki(e=(e+" "+xh(n)).trim())?e:""}function xh(n){var e="";return n&&n.childNodes&&n.childNodes.length&&Y(n.childNodes,(function(t){var i;if(t&&((i=t.tagName)==null?void 0:i.toLowerCase())==="span")try{var s=wi(t);e=(e+" "+s).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+xh(t)).trim())}catch(r){w.error("[AutoCapture]",r)}})),e}function mb(n){return(function(e){var t=e.map((i=>{var s,r,o="";if(i.tag_name&&(o+=i.tag_name),i.attr_class)for(var a of(i.attr_class.sort(),i.attr_class))o+="."+a.replace(/"/g,"");var l=A({},i.text?{text:i.text}:{},{"nth-child":(s=i.nth_child)!==null&&s!==void 0?s:0,"nth-of-type":(r=i.nth_of_type)!==null&&r!==void 0?r:0},i.href?{href:i.href}:{},i.attr_id?{attr_id:i.attr_id}:{},i.attributes),c={};return Cs(l).sort(((u,h)=>{var[g]=u,[f]=h;return g.localeCompare(f)})).forEach((u=>{var[h,g]=u;return c[kd(h.toString())]=kd(g.toString())})),o+=":",o+=Cs(c).map((u=>{var[h,g]=u;return h+'="'+g+'"'})).join("")}));return t.join(";")})((function(e){return e.map((t=>{var i,s,r={text:(i=t.$el_text)==null?void 0:i.slice(0,400),tag_name:t.tag_name,href:(s=t.attr__href)==null?void 0:s.slice(0,2048),attr_class:yb(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Cs(t).filter((o=>{var[a]=o;return a.indexOf("attr__")===0})).forEach((o=>{var[a,l]=o;return r.attributes[a]=l})),r}))})(n))}function kd(n){return n.replace(/"|\\"/g,'\\"')}function yb(n){var e=n.attr__class;return e?H(e)?e:ol(e):void 0}function Oo(n,e){return e.length>n?e.slice(0,n)+"...":e}function Eb(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!nr(e));return e}function kb(n,e,t,i){var s=n.tagName.toLowerCase(),r={tag_name:s};al.indexOf(s)>-1&&!t&&(s.toLowerCase()==="a"||s.toLowerCase()==="button"?r.$el_text=Oo(1024,Dh(n)):r.$el_text=Oo(1024,wi(n)));var o=Us(n);o.length>0&&(r.classes=o.filter((function(u){return u!==""}))),Y(n.attributes,(function(u){var h;if((!Ch(n)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(i==null||!i.includes(u.name))&&!e&&ki(u.value)&&(h=u.name,!fe(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var g=u.value;u.name==="class"&&(g=ol(g).join(" ")),r["attr__"+u.name]=Oo(1024,g)}}));for(var a=1,l=1,c=n;c=Eb(c);)a++,c.tagName===n.tagName&&l++;return r.nth_child=a,r.nth_of_type=l,r}function Sb(n,e){for(var t,i,{e:s,maskAllElementAttributes:r,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[n],u=n;u.parentNode&&!Dt(u,"body");)wh(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var h,g=[],f={},p=!1,v=!1;if(Y(c,(N=>{var I=pa(N);N.tagName.toLowerCase()==="a"&&(p=N.getAttribute("href"),p=I&&p&&ki(p)&&p),F(Us(N),"ph-no-capture")&&(v=!0),g.push(kb(N,r,o,a));var K=(function(B){if(!pa(B))return{};var P={};return Y(B.attributes,(function(Ee){if(Ee.name&&Ee.name.indexOf("data-ph-capture-attribute")===0){var de=Ee.name.replace("data-ph-capture-attribute-",""),R=Ee.value;de&&R&&ki(R)&&(P[de]=R)}})),P})(N);ae(f,K)})),v)return{props:{},explicitNoCapture:v};if(o||(n.tagName.toLowerCase()==="a"||n.tagName.toLowerCase()==="button"?g[0].$el_text=Dh(n):g[0].$el_text=wi(n)),p){var _,E;g[0].attr__href=p;var b=(_=Vs(p))==null?void 0:_.host,C=m==null||(E=m.location)==null?void 0:E.host;b&&C&&b!==C&&(h=p)}return{props:ae({$event_type:s.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:mb(g)},(t=g[0])!=null&&t.$el_text?{$el_text:(i=g[0])==null?void 0:i.$el_text}:{},h&&s.type==="click"?{$external_click_url:h}:{},f)}}function Tb(n,e){if(e){var t=(function(s,r){if(r===void 0&&(r=S),Zn)return Zn;if(!r||["localhost","127.0.0.1"].includes(s))return"";for(var o=s.split("."),a=Math.min(o.length,8),l="dmn_chk_"+Ct();!Zn&&a--;){var c=o.slice(a).join("."),u=l+"=1;domain=."+c+";path=/";r.cookie=u+";max-age=3",r.cookie.includes(l)&&(r.cookie=u+";max-age=0",Zn=c)}return Zn})(n);if(!t){var i=(s=>{var r=s.match(Ab);return r?r[0]:""})(n);i!==t&&w.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}function Td(n,e,t){try{if(!(e in n))return()=>{};var i=n[e],s=t(i);return Pt(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),n[e]=s,()=>{n[e]=i}}catch{return()=>{}}}function Pb(n,e){var t=n.config.segment;if(!t)return e();(function(i,s){var r=i.config.segment;if(!r)return s();var o=l=>{var c=()=>l.anonymousId()||Ct();i.config.get_device_id=c,l.id()&&(i.register({distinct_id:l.id(),$device_id:c()}),i.persistence.set_property(gt,"identified")),s()},a=r.user();"then"in a&&Pt(a.then)?a.then(o):o(a)})(n,(()=>{t.register((i=>{Promise&&Promise.resolve||Po.warn("This browser does not have Promise support, and can not use the segment integration");var s=(r,o)=>{if(!o)return r;r.event.userId||r.event.anonymousId===i.get_distinct_id()||(Po.info("No userId set, resetting PostHog"),i.reset()),r.event.userId&&r.event.userId!==i.get_distinct_id()&&(Po.info("UserId set, identifying with PostHog"),i.identify(r.event.userId));var a=i.calculateEventProperties(o,r.event.properties);return r.event.properties=Object.assign({},a,r.event.properties),r};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:r=>s(r,r.event.event),page:r=>s(r,"$pageview"),identify:r=>s(r,"$identify"),screen:r=>s(r,"$screen")}})(n)).then((()=>{e()}))}))}function Fh(n,e){var{organization:t,projectId:i,prefix:s,severityAllowList:r=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,h,g;if(!(r==="*"||r.includes(a.level))||!n.__loaded)return a;a.tags||(a.tags={});var f=n.requestRouter.endpointFor("ui","/project/"+n.config.token+"/person/"+n.get_distinct_id());a.tags["PostHog Person URL"]=f,n.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=n.get_session_replay_url({withTimestamp:!0}));var p=((l=a.exception)==null?void 0:l.values)||[],v=p.map((E=>A({},E,{stacktrace:E.stacktrace?A({},E.stacktrace,{type:"raw",frames:(E.stacktrace.frames||[]).map((b=>A({},b,{platform:"web:javascript"})))}):void 0}))),_={$exception_message:((c=p[0])==null?void 0:c.value)||a.message,$exception_type:(u=p[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:v,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=p[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(g=p[0])==null?void 0:g.type,$sentry_tags:a.tags};return t&&i&&(_.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+a.event_id),o&&n.exceptions.sendExceptionEvent(_),a}}function Mh(n,e,t){if(!S)return{};var i,s=e?Cn([],Pn,t||[]):[],r=Uh(Ai(S.URL,s,Ti),n),o=(i={},Y($b,(function(a){var l=nt.q(a);i[a]=l||null})),i);return ae(o,r)}function Uh(n,e){var t=xb.concat(e||[]),i={};return Y(t,(function(s){var r=Gs(n,s);i[s]=r||null})),i}function Bh(n){var e=(function(r){return r?r.search(Rs+"google.([^/?]*)")===0?"google":r.search(Rs+"bing.com")===0?"bing":r.search(Rs+"yahoo.com")===0?"yahoo":r.search(Rs+"duckduckgo.com")===0?"duckduckgo":null:null})(n),t=e!="yahoo"?"q":"p",i={};if(!Je(e)){i.$search_engine=e;var s=S?Gs(S.referrer,t):"";s.length&&(i.ph_keyword=s)}return i}function Od(){return navigator.language||navigator.userLanguage}function Vh(){return S?.referrer||"$direct"}function Gh(n,e){var t=n?Cn([],Pn,e||[]):[],i=ye?.href.substring(0,1e3);return{r:Vh().substring(0,1e3),u:i?Ai(i,t,Ti):void 0}}function jh(n){var e,{r:t,u:i}=n,s={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Vs(t))==null?void 0:e.host};if(i){s.$current_url=i;var r=Vs(i);s.$host=r?.host,s.$pathname=r?.pathname;var o=Uh(i);ae(s,o)}if(t){var a=Bh(t);ae(s,a)}return s}function Hh(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Lb(){try{return new Date().getTimezoneOffset()}catch{return}}function Fb(n,e){if(!De)return{};var t,i,s,r=n?Cn([],Pn,e||[]):[],[o,a]=(function(l){for(var c=0;c<od.length;c++){var[u,h]=od[c],g=u.exec(l),f=g&&(Pt(h)?h(g,l):h);if(f)return f}return["",""]})(De);return ae(rl({$os:o,$os_version:a,$browser:gh(De,navigator.vendor),$device:ad(De),$device_type:(i=De,s=ad(i),s===eh||s===Zd||s==="Kobo"||s==="Kindle Fire"||s===fh?mi:s===bi||s===Tn||s===Ei||s===Wo?"Console":s===nh?"Wearable":s?je:"Desktop"),$timezone:Hh(),$timezone_offset:Lb()}),{$current_url:Ai(ye?.href,r,Ti),$host:ye?.host,$pathname:ye?.pathname,$raw_user_agent:De.length>1e3?De.substring(0,997)+"...":De,$browser_version:Ky(De,navigator.vendor),$browser_language:Od(),$browser_language_prefix:(t=Od(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:m?.screen.height,$screen_width:m?.screen.width,$viewport_height:m?.innerHeight,$viewport_width:m?.innerWidth,$lib:"web",$lib_version:ft.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}function Pd(n){return he(n)&&"clientX"in n&&"clientY"in n&&yt(n.clientX)&&yt(n.clientY)}function qb(n,e){e===void 0&&(e={});var t=(function(){var a=4294967295;return{p:function(l){for(var c=a,u=0;u<l.length;++u)c=jb[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),i=n.length;t.p(n);var s,r=Hb(n,e,10+((s=e).filename&&s.filename.length+1||0),8),o=r.length;return(function(a,l){var c=l.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=l.level<2?4:l.level==9?2:0,a[9]=3,l.mtime!=0&&Do(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),c){a[3]=8;for(var u=0;u<=c.length;++u)a[u+10]=c.charCodeAt(u)}})(r,e),Do(r,o-8,t.d()),Do(r,o-4,i),r}function Ld(n,e,t){return hi({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}function Xh(n,e){return!n||Object.entries(n).every((t=>{var[i,s]=t,r=e?.[i];if(k(r)||Je(r))return!1;var o=[String(r)],a=Yh[s.operator];return!!a&&a(s.values,o)}))}function yn(n,e,t){if(M(n))return!1;switch(t){case"exact":return n===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(n);case"regex":try{return new RegExp(e).test(n)}catch{return!1}default:return!1}}var m,be,Wd,Zu,ed,Me,S,ye,Vo,Go,td,De,O,ft,Cy,Py,id,er,jo,Ny,Xd,Jd,tr,H,Pt,he,Sn,k,fe,Ho,Je,M,yt,bn,mt,Dy,xy,$y,wo,Ly,Ko,je,Ds,_t,mi,Zd,eh,th,nh,yi,In,ih,sh,rh,zt,Fy,oh,tl,ah,nl,My,il,lh,An,ch,bi,Ei,Tn,uh,dh,ai,zo,sd,Wo,hh,Uy,fh,Yo,Ie,Ao,By,Vy,Gy,sl,jy,As,rd,To,Hy,gh,qy,Ky,od,ad,zy,Xo,Rn,ph,Yy,Xy,Jy,Qy,Zy,eb,tb,ld,cd,Qo,Zo,ea,ib,ta,sb,na,ia,sa,ra,_h,w,oe,rb,ud,xs,ae,Cn,dd,ob,rl,lb,yh,li,ci,hd,oa,fd,aa,gd,pd,bh,vd,_d,Io,$s,Eh,wn,ui,la,di,Kt,ca,Ls,ua,gt,da,ha,fa,ga,Fs,Ms,kh,Qn,ub,al,db,bd,Ed,ll,Oh,Ph,gb,pb,Nh,vb,_b,Bs,Vs,bb,Gs,Ai,js,Ro,Sd,va,wd,_a,ma,Ad,$h,ya,Ct,wb,Zn,Ab,nt,Co,ie,Ib,Ts,Rb,Ht,me,pt,ba,Is,Ob,Cb,Hs,ei,Ea,ka,Po,Lh,Sa,Nb,Id,Rd,Ot,wa,Db,Aa,Rs,Pn,xb,Ti,$b,Tt,Cd,Ta,Mb,Ia,qs,vt,He,Re,On,cl,ul,Nd,qh,Kh,Ub,Ra,It,Oa,Ks,X,pi,Wt,zs,Bb,Vb,zh,Wh,dt,ti,No,Ca,Dd,ni,Pa,xd,Gb,jb,Hb,Do,Kb,zb,$d,Ws,hi,xo,Ps,Ys,Yh,Os,$o,Na,Fe,ii,Wb,Yb,Xb,Jb,Qb,Zb,eE,Lo,mn,Fd,si,Md,Ud,Bd,tE,nE,Da,iE,vi,Vd,Fo,xa,ri,XE,JE,QE,Mo,ZE,e0,t0,fi,Uo,$a,W,Jh,sE,Gd,rE,oE,Si,La,Fa,Ma,Ua,ht,Ba,Va,jd,Ga,qt,ja,Ha,qa,aE,Ka,za,lE,Xs,Bo,Js,cE,Rt,Wa,Qh,gi,Hd,Ya,uE,Xa,dE,hE,Ja,Qa,oi,Qs,_i,Za,En,Zh,qd,Kd,el,Zs,zd,Yt,ef=Ue(()=>{"use strict";m=typeof window<"u"?window:void 0,be=typeof globalThis<"u"?globalThis:m;typeof self>"u"&&(be.self=be),typeof File>"u"&&(be.File=function(){});Wd=Array.prototype,Zu=Wd.forEach,ed=Wd.indexOf,Me=be?.navigator,S=be?.document,ye=be?.location,Vo=be?.fetch,Go=be!=null&&be.XMLHttpRequest&&"withCredentials"in new be.XMLHttpRequest?be.XMLHttpRequest:void 0,td=be?.AbortController,De=Me?.userAgent,O=m??{},ft={DEBUG:!1,LIB_VERSION:"1.345.2"};Cy=["$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"],Py=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],id=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return Py.concat(e).some((i=>{var s=i.toLowerCase();return t.indexOf(s)!==-1}))};er=function(n){return n.trim()},jo=function(n){return n.replace(/^\$/,"")},Ny=Array.isArray,Xd=Object.prototype,Jd=Xd.hasOwnProperty,tr=Xd.toString,H=Ny||function(n){return tr.call(n)==="[object Array]"},Pt=n=>typeof n=="function",he=n=>n===Object(n)&&!H(n),Sn=n=>{if(he(n)){for(var e in n)if(Jd.call(n,e))return!1;return!0}return!1},k=n=>n===void 0,fe=n=>tr.call(n)=="[object String]",Ho=n=>fe(n)&&n.trim().length===0,Je=n=>n===null,M=n=>k(n)||Je(n),yt=n=>tr.call(n)=="[object Number]"&&n==n,bn=n=>yt(n)&&n>0,mt=n=>tr.call(n)==="[object Boolean]",Dy=n=>n instanceof FormData,xy=n=>F(Cy,n);$y=[!0,"true",1,"1","yes"],wo=n=>F($y,n),Ly=[!1,"false",0,"0","no"];Ko=class{constructor(e){this.t={},this.i=e.i,this.o=it(e.bucketSize,0,100,e.h),this.m=it(e.refillRate,0,this.o,e.h),this.$=it(e.refillInterval,0,864e5,e.h)}S(e,t){var i=t-e.lastAccess,s=Math.floor(i/this.$);if(s>0){var r=s*this.m;e.tokens=Math.min(e.tokens+r,this.o),e.lastAccess=e.lastAccess+s*this.$}}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this.t[s];return r?this.S(r,i):(r={tokens:this.o,lastAccess:i},this.t[s]=r),r.tokens===0||(r.tokens--,r.tokens===0&&((t=this.i)==null||t.call(this,e)),r.tokens===0)}stop(){this.t={}}},je="Mobile",Ds="iOS",_t="Android",mi="Tablet",Zd=_t+" "+mi,eh="iPad",th="Apple",nh=th+" Watch",yi="Safari",In="BlackBerry",ih="Samsung",sh=ih+"Browser",rh=ih+" Internet",zt="Chrome",Fy=zt+" OS",oh=zt+" "+Ds,tl="Internet Explorer",ah=tl+" "+je,nl="Opera",My=nl+" Mini",il="Edge",lh="Microsoft "+il,An="Firefox",ch=An+" "+Ds,bi="Nintendo",Ei="PlayStation",Tn="Xbox",uh=_t+" "+je,dh=je+" "+yi,ai="Windows",zo=ai+" Phone",sd="Nokia",Wo="Ouya",hh="Generic",Uy=hh+" "+je.toLowerCase(),fh=hh+" "+mi.toLowerCase(),Yo="Konqueror",Ie="(\\d+(\\.\\d+)?)",Ao=new RegExp("Version/"+Ie),By=new RegExp(Tn,"i"),Vy=new RegExp(Ei+" \\w+","i"),Gy=new RegExp(bi+" \\w+","i"),sl=new RegExp(In+"|PlayBook|BB10","i"),jy={"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"},Hy=(n,e)=>e&&F(e,th)||(function(t){return F(t,yi)&&!F(t,zt)&&!F(t,_t)})(n),gh=function(n,e){return e=e||"",F(n," OPR/")&&F(n,"Mini")?My:F(n," OPR/")?nl:sl.test(n)?In:F(n,"IE"+je)||F(n,"WPDesktop")?ah:F(n,sh)?rh:F(n,il)||F(n,"Edg/")?lh:F(n,"FBIOS")?"Facebook "+je:F(n,"UCWEB")||F(n,"UCBrowser")?"UC Browser":F(n,"CriOS")?oh:F(n,"CrMo")||F(n,zt)?zt:F(n,_t)&&F(n,yi)?uh:F(n,"FxiOS")?ch:F(n.toLowerCase(),Yo.toLowerCase())?Yo:Hy(n,e)?F(n,je)?dh:yi:F(n,An)?An:F(n,"MSIE")||F(n,"Trident/")?tl:F(n,"Gecko")?An:""},qy={[ah]:[new RegExp("rv:"+Ie)],[lh]:[new RegExp(il+"?\\/"+Ie)],[zt]:[new RegExp("("+zt+"|CrMo)\\/"+Ie)],[oh]:[new RegExp("CriOS\\/"+Ie)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ie)],[yi]:[Ao],[dh]:[Ao],[nl]:[new RegExp("(Opera|OPR)\\/"+Ie)],[An]:[new RegExp(An+"\\/"+Ie)],[ch]:[new RegExp("FxiOS\\/"+Ie)],[Yo]:[new RegExp("Konqueror[:/]?"+Ie,"i")],[In]:[new RegExp(In+" "+Ie),Ao],[uh]:[new RegExp("android\\s"+Ie,"i")],[rh]:[new RegExp(sh+"\\/"+Ie)],[tl]:[new RegExp("(rv:|MSIE )"+Ie)],Mozilla:[new RegExp("rv:"+Ie)]},Ky=function(n,e){var t=gh(n,e),i=qy[t];if(k(i))return null;for(var s=0;s<i.length;s++){var r=i[s],o=n.match(r);if(o)return parseFloat(o[o.length-2])}return null},od=[[new RegExp(Tn+"; "+Tn+" (.*?)[);]","i"),n=>[Tn,n&&n[1]||""]],[new RegExp(bi,"i"),[bi,""]],[new RegExp(Ei,"i"),[Ei,""]],[sl,[In,""]],[new RegExp(ai,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[zo,""];if(new RegExp(je).test(e)&&!/IEMobile\b/.test(e))return[ai+" "+je,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var i=t[1],s=jy[i]||"";return/arm/i.test(e)&&(s="RT"),[ai,s]}return[ai,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,n=>{if(n&&n[3]){var e=[n[3],n[4],n[5]||"0"];return[Ds,e.join(".")]}return[Ds,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,n=>{var e="";return n&&n.length>=3&&(e=k(n[2])?n[3]:n[2]),["watchOS",e]}],[new RegExp("("+_t+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+_t+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[_t,e.join(".")]}return[_t,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,n=>{var e=["Mac OS X",""];if(n&&n[1]){var t=[n[1],n[2],n[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Fy,""]],[/Linux|debian/i,["Linux",""]]],ad=function(n){return Gy.test(n)?bi:Vy.test(n)?Ei:By.test(n)?Tn:new RegExp(Wo,"i").test(n)?Wo:new RegExp("("+zo+"|WPDesktop)","i").test(n)?zo:/iPad/.test(n)?eh:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?nh:sl.test(n)?In:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(sd,"i").test(n)?sd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(n)||/(kf[a-z]+)( bui|\)).+silk\//i.test(n)?"Kindle Fire":/(Android|ZTE)/i.test(n)?new RegExp(je).test(n)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(n)||/pixel[\daxl ]{1,6}/i.test(n)&&!/pixel c/i.test(n)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(n)||/lmy47v/i.test(n)&&!/QTAQZ3/i.test(n)?_t:Zd:new RegExp("(pda|"+je+")","i").test(n)?Uy:new RegExp(mi,"i").test(n)&&!new RegExp(mi+" pc","i").test(n)?fh:""},zy=n=>n instanceof Error;Xo=class{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),r=this.buildParsingContext(t),o=this.parseStacktrace(s,r);return{$exception_list:this.convertToExceptionList(o,i),$exception_level:"error"}}modifyFrames(e){var t=this;return kn((function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&H(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,s;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),A({},e,{cause:i,stack:s})}applyChunkIds(e,t){return e.map((i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return kn((function*(){var i=e;for(var s of t.modifiers)i=yield s(i);return i}))()}convertToExceptionList(e,t){var i,s,r,o={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(s=t.handled)===null||s===void 0||s,synthetic:(r=e.synthetic)!==null&&r!==void 0&&r}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,A({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:Wy(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,i){i===void 0&&(i=0);var s=(r,o)=>{if(o<=4){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(r,a)}};return A({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:r=>s(r,i),next:r=>s(r,i+1)})}},Rn="?";ph=(n,e)=>{var t=n.indexOf("safari-extension")!==-1,i=n.indexOf("safari-web-extension")!==-1;return t||i?[n.indexOf("@")!==-1?n.split("@")[0]:Rn,t?"safari-extension:"+e:"safari-web-extension:"+e]:[n,e]},Yy=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Xy=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Jy=/\((\S*)(?::(\d+))(?::(\d+))\)/,Qy=(n,e)=>{var t=Yy.exec(n);if(t){var[,i,s,r]=t;return Jo(e,i,Rn,+s,+r)}var o=Xy.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Jy.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=ph(o[1]||Rn,o[2]);return Jo(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Zy=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,eb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,tb=(n,e)=>{var t=Zy.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=eb.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var s=t[3],r=t[1]||Rn;return[r,s]=ph(r,s),Jo(e,s,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},ld=/\(error: (.*)\)/,cd=50;Qo=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=fe(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Ns(e,"DOMException")}isDOMError(e){return Ns(e,"DOMError")}},Zo=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return i.error&&typeof i.error.message=="string"?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}},ea=class{constructor(){}match(e){return Ns(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var i,s=t.apply(e.error);return s||{type:"ErrorEvent",value:e.message,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},ib=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ta=class{match(e){return typeof e=="string"}coerce(e,t){var i,[s,r]=this.getInfos(e);return{type:s??"Error",value:r??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(ib);return s&&(t=s[1],i=s[2]),[t,i]}},sb=["fatal","error","warning","log","info","debug"];na=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:(i=t.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return Qd(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var i=this.getObjectClassName(e);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+vh(e)}isSeverityLevel(e){return fe(e)&&!Ho(e)&&sb.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(zy(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},ia=class{match(e){return Qd(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+vh(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},sa=class{match(e){return qo(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},ra=class{match(e){return Ns(e,"PromiseRejectionEvent")}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return qo(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){if(qo(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}},_h=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,i={k:function(s){if(m&&(ft.DEBUG||O.POSTHOG_DEBUG||t)&&!k(m.console)&&m.console){for(var r=("__rrweb_original__"in m.console[s])?m.console[s].__rrweb_original__:m.console[s],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];r(n,...a)}},info:function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];i.k("log",...r)},warn:function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];i.k("warn",...r)},error:function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];i.k("error",...r)},critical:function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];console.error(n,...r)},uninitializedWarning:s=>{i.error("You must initialize PostHog before calling "+s)},createLogger:(s,r)=>_h(n+" "+s,r)};return i},w=_h("[PostHog.js]"),oe=w.createLogger,rb=oe("[ExternalScriptsLoader]"),ud=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return rb.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var i=S?.querySelectorAll("script");if(i){for(var s,r=function(){if(i[o].src===e){var l=i[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)})),l.onerror=c=>t(c),{v:void 0})}},o=0;o<i.length;o++)if(s=r())return s.v}var a=()=>{if(!S)return t("document not found");var l=S.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,t(void 0,h)},l.onerror=h=>t(h),n.config.prepare_external_dependency_script&&(l=n.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(n.config.external_scripts_inject_target==="head")S.head.appendChild(l);else{var c,u=S.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):S.body.appendChild(l)}};S!=null&&S.body?a():S?.addEventListener("DOMContentLoaded",a)};O.__PosthogExtensions__=O.__PosthogExtensions__||{},O.__PosthogExtensions__.loadExternalDependency=(n,e,t)=>{var i="/static/"+e+".js?v="+n.version;if(e==="remote-config"&&(i="/array/"+n.config.token+"/config.js"),e==="toolbar"){var s=3e5;i=i+"&t="+Math.floor(Date.now()/s)*s}var r=n.requestRouter.endpointFor("assets",i);ud(n,r,t)},O.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var i=n.requestRouter.endpointFor("api",e);ud(n,i,t)};xs={};ae=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return Nt(t,(function(s){for(var r in s)s[r]!==void 0&&(n[r]=s[r])})),n},Cn=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return Nt(t,(function(s){Nt(s,(function(r){n.push(r)}))})),n};dd=function(n){try{return n()}catch{return}},ob=function(n){return function(){try{for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n.apply(this,t)}catch(s){w.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),w.critical(s)}}},rl=function(n){var e={};return Y(n,(function(t,i){(fe(t)&&t.length>0||yt(t))&&(e[i]=t)})),e};lb=["herokuapp.com","vercel.app","netlify.app"];yh="$people_distinct_id",li="__alias",ci="__timers",hd="$autocapture_disabled_server_side",oa="$heatmaps_enabled_server_side",fd="$exception_capture_enabled_server_side",aa="$error_tracking_suppression_rules",gd="$error_tracking_capture_extension_exceptions",pd="$web_vitals_enabled_server_side",bh="$dead_clicks_enabled_server_side",vd="$product_tours_enabled_server_side",_d="$web_vitals_allowed_metrics",Io="$session_recording_remote_config",$s="$sesid",Eh="$session_is_sampled",wn="$enabled_feature_flags",ui="$early_access_features",la="$feature_flag_details",di="$stored_person_properties",Kt="$stored_group_properties",ca="$surveys",Ls="$flag_call_reported",ua="$feature_flag_errors",gt="$user_state",da="$client_session_props",ha="$capture_rate_limit",fa="$initial_campaign_params",ga="$initial_referrer_info",Fs="$initial_person_info",Ms="$epp",kh="__POSTHOG_TOOLBAR__",Qn="$posthog_cookieless",ub=[yh,li,"__cmpns",ci,"$session_recording_enabled_server_side",oa,$s,wn,aa,gt,ui,la,Kt,di,ca,Ls,ua,da,ha,fa,ga,Ms,Fs,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];al=["a","button","form","input","select","textarea","label"];db=["next","previous","prev",">","<"],bd=10,Ed=[".ph-no-rageclick",".ph-no-capture"];ll=n=>!n||Dt(n,"html")||!nr(n),Oh=(n,e)=>{if(!m||ll(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[n],s=n;s.parentNode&&!Dt(s,"body");)if(wh(s.parentNode))i.push(s.parentNode.host),s=s.parentNode.host;else{var r=Rh(s);if(!r)break;if(e||al.indexOf(r.tagName.toLowerCase())>-1)t=!0;else{var o=m.getComputedStyle(r);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}i.push(r),s=r}return{parentIsUsefulElement:t,targetElementList:i}};Ph="(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})",gb=new RegExp("^(?:"+Ph+")$"),pb=new RegExp(Ph),Nh="\\d{3}-?\\d{2}-?\\d{4}",vb=new RegExp("^("+Nh+")$"),_b=new RegExp("("+Nh+")");Bs=class{constructor(e){this.disabled=e===!1;var t=he(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<this.thresholdPx&&i-s.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},Vs=n=>{var e=S?.createElement("a");return k(e)?null:(e.href=n,e)},bb=function(n,e){var t,i;e===void 0&&(e="&");var s=[];return Y(n,(function(r,o){k(r)||k(o)||o==="undefined"||(t=encodeURIComponent((a=>a instanceof File)(r)?r.name:r.toString()),i=encodeURIComponent(o),s[s.length]=i+"="+t)})),s.join(e)},Gs=function(n,e){for(var t,i=((n.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<i.length;s++){var r=i[s].split("=");if(r[0]===e){t=r;break}}if(!H(t)||t.length<2)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{w.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ai=function(n,e,t){if(!n||!e||!e.length)return n;for(var i=n.split("#"),s=i[0]||"",r=i[1],o=s.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],h=0;h<c.length;h++){var g=c[h].split("=");H(g)&&(e.includes(g[0])?u.push(g[0]+"="+t):u.push(c[h]))}var f=l;return a!=null&&(f+="?"+u.join("&")),r!=null&&(f+="#"+r),f},js=function(n,e){var t=n.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Ro="$copy_autocapture",Sd=oe("[AutoCapture]");va=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Bs(e.config.rageclick),this.C=null}get R(){var e,t,i=he(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=(e=i.url_allowlist)==null?void 0:e.map((s=>new RegExp(s))),i.url_ignorelist=(t=i.url_ignorelist)==null?void 0:t.map((s=>new RegExp(s))),i}F(){if(this.isBrowserSupported()){if(m&&S){var e=i=>{i=i||m?.event;try{this.O(i)}catch(s){Sd.error("Failed to capture event",s)}};if(ue(S,"submit",e,{capture:!0}),ue(S,"change",e,{capture:!0}),ue(S,"click",e,{capture:!0}),this.R.capture_copied_text){var t=i=>{i=i||m?.event,this.O(i,Ro)};ue(S,"copy",t,{capture:!0}),ue(S,"cut",t,{capture:!0})}}}else Sd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[hd]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,i=[];return(t=this.C)==null||t.forEach((s=>{var r=S?.querySelectorAll(s);r?.forEach((o=>{e===o&&i.push(s)}))})),i}get isEnabled(){var e,t,i=(e=this.instance.persistence)==null?void 0:e.props[hd],s=this.T;if(Je(s)&&!mt(i)&&!this.instance.M())return!1;var r=(t=this.T)!==null&&t!==void 0?t:!!i;return!!this.instance.config.autocapture&&!r}O(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var i,s=Th(e);Sh(s)&&(s=s.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(i=this.rageclicks)!=null&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&hb(s,this.instance.config.rageclick)&&this.O(e,"$rageclick");var r=t===Ro;if(s&&fb(s,e,this.R,r,r?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=Sb(s,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(o.$element_selectors=l),t===Ro){var c,u=Ah(m==null||(c=m.getSelection())==null?void 0:c.toString()),h=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=h}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return Pt(S?.querySelectorAll)}};Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Number.isInteger||(Number.isInteger=function(n){return yt(n)&&isFinite(n)&&Math.floor(n)===n});wd="0123456789abcdef",_a=class n{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,s){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||e<0||t<0||i<0||s<0||e>0xffffffffffff||t>4095||i>1073741823||s>4294967295)throw new RangeError("invalid field value");var 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/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=s>>>24,r[13]=s>>>16,r[14]=s>>>8,r[15]=s,new n(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+wd.charAt(this.bytes[t]>>>4)+wd.charAt(15&this.bytes[t]),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new n(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(i!==0)return Math.sign(i)}return 0}},ma=class{constructor(){this.A=0,this.j=0,this.D=new ya}generate(){var e=this.generateOrAbort();if(k(e)){this.A=0;var t=this.generateOrAbort();if(k(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return _a.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}},$h=n=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<n.length;e++)n[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return n};m&&!k(m.crypto)&&crypto.getRandomValues&&($h=n=>crypto.getRandomValues(n));ya=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&($h(this.N),this.U=0),this.N[this.U++]}},Ct=()=>wb().toString(),wb=()=>(Ad||(Ad=new ma)).generate(),Zn="",Ab=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;nt={H:()=>!!S,B:function(n){w.error("cookieStore error: "+n)},q:function(n){if(S){try{for(var e=n+"=",t=S.cookie.split(";").filter((r=>r.length)),i=0;i<t.length;i++){for(var s=t[i];s.charAt(0)==" ";)s=s.substring(1,s.length);if(s.indexOf(e)===0)return decodeURIComponent(s.substring(e.length,s.length))}}catch{}return null}},W:function(n){var e;try{e=JSON.parse(nt.q(n))||{}}catch{}return e},G:function(n,e,t,i,s){if(S)try{var r="",o="",a=Tb(S.location.hostname,i);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),r="; expires="+l.toUTCString()}s&&(o="; secure");var c=n+"="+encodeURIComponent(JSON.stringify(e))+r+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&w.warn("cookieStore warning: large cookie, len="+c.length),S.cookie=c,c}catch{return}},V:function(n,e){if(S!=null&&S.cookie)try{nt.G(n,"",-1,e)}catch{return}}},Co=null,ie={H:function(){if(!Je(Co))return Co;var n=!0;if(k(m))n=!1;else try{var e="__mplssupport__";ie.G(e,"xyz"),ie.q(e)!=='"xyz"'&&(n=!1),ie.V(e)}catch{n=!1}return n||w.error("localStorage unsupported; falling back to cookie store"),Co=n,n},B:function(n){w.error("localStorage error: "+n)},q:function(n){try{return m?.localStorage.getItem(n)}catch(e){ie.B(e)}return null},W:function(n){try{return JSON.parse(ie.q(n))||{}}catch{}return null},G:function(n,e){try{m?.localStorage.setItem(n,JSON.stringify(e))}catch(t){ie.B(t)}},V:function(n){try{m?.localStorage.removeItem(n)}catch(e){ie.B(e)}}},Ib=["$device_id","distinct_id",$s,Eh,Ms,Fs],Ts={},Rb={H:function(){return!0},B:function(n){w.error("memoryStorage error: "+n)},q:function(n){return Ts[n]||null},W:function(n){return Ts[n]||null},G:function(n,e){Ts[n]=e},V:function(n){delete Ts[n]}},Ht=null,me={H:function(){if(!Je(Ht))return Ht;if(Ht=!0,k(m))Ht=!1;else try{var n="__support__";me.G(n,"xyz"),me.q(n)!=='"xyz"'&&(Ht=!1),me.V(n)}catch{Ht=!1}return Ht},B:function(n){w.error("sessionStorage error: ",n)},q:function(n){try{return m?.sessionStorage.getItem(n)}catch(e){me.B(e)}return null},W:function(n){try{return JSON.parse(me.q(n))||null}catch{}return null},G:function(n,e){try{m?.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){me.B(t)}},V:function(n){try{m?.sessionStorage.removeItem(n)}catch(e){me.B(e)}}},pt=(function(n){return n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED",n})({}),ba=class{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?pt.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===pt.DENIED||this.consent===pt.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===pt.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return wo(e)?pt.GRANTED:F(Ly,e)?pt.DENIED:pt.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?ie:nt;var t=e==="localStorage"?nt:ie;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(wo(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!mh([Me?.doNotTrack,Me?.msDoNotTrack,O.doNotTrack],(e=>wo(e)))}},Is=oe("[Dead Clicks]"),Ob=()=>!0,Cb=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property(bh)),i=n.instance.config.capture_dead_clicks;return mt(i)?i:!!he(i)||t},Hs=class{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[bh]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it((()=>{this.et()}))}it(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(s=>{s?Is.error("failed to load script",s):e()}))}et(){var e;if(S){if(!this.tt&&(e=O.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=he(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=O.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(S),Is.info("starting...")}}else Is.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Is.info("stopping..."))}},ei=oe("[ExceptionAutocapture]"),Ea=class{constructor(e){var t,i,s;this.rt=()=>{var r;if(m&&this.isEnabled&&(r=O.__PosthogExtensions__)!=null&&r.errorWrappingFunctions){var o=O.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=O.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=O.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=o(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=a(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(c){ei.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[fd]),this.dt=new Ko({refillRate:(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,h:ei}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return he(e)?t=A({},t,e):(k(e)?this.ht:e)&&(t=A({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ei.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return ei.error("failed to load script",s);e()}))}ut(){var e,t,i;(e=this.st)==null||e.call(this),this.st=void 0,(t=this.nt)==null||t.call(this),this.nt=void 0,(i=this.ot)==null||i.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[fd]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,i,s=(t=e==null||(i=e.$exception_list)==null||(i=i[0])==null?void 0:i.type)!==null&&t!==void 0?t:"Exception";this.dt.consumeRateLimit(s)?ei.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}};ka=class{constructor(e){var t;this._instance=e,this.ct=(m==null||(t=m.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(w.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,w.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(m&&m.history){var i=this;(e=m.history.pushState)!=null&&e.__posthog_wrapped__||Td(m.history,"pushState",(s=>function(r,o,a){s.call(this,r,o,a),i._t("pushState")})),(t=m.history.replaceState)!=null&&t.__posthog_wrapped__||Td(m.history,"replaceState",(s=>function(r,o,a){s.call(this,r,o,a),i._t("replaceState")})),this.bt()}}_t(e){try{var t,i=m==null||(t=m.location)==null?void 0:t.pathname;if(!i)return;i!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=i}catch(s){w.error("Error capturing "+e+" pageview",s)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};ue(m,"popstate",e),this.ft=()=>{m&&m.removeEventListener("popstate",e)}}}},Po=oe("[SegmentIntegration]");Lh="posthog-js";Sa=class{constructor(e,t,i,s,r,o){this.name=Lh,this.setupOnce=function(a){a(Fh(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:o==null||o}))}}},Nb=m!=null&&m.location?js(m.location.hash,"__posthog")||js(location.hash,"state"):null,Id="_postHogToolbarParams",Rd=oe("[Toolbar]"),Ot=(function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n})(Ot||{}),wa=class{constructor(e){this.instance=e}yt(e){O.ph_toolbar_state=e}wt(){var e;return(e=O.ph_toolbar_state)!==null&&e!==void 0?e:Ot.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),this.instance.config.name&&this.instance.config.name==="ph_toolbar_internal"||!m||!S)return!1;e=e??m.location,i=i??m.history;try{if(!t){try{m.localStorage.setItem("test","test"),m.localStorage.removeItem("test")}catch{return!1}t=m?.localStorage}var s,r=Nb||js(e.hash,"__posthog")||js(e.hash,"state"),o=r?dd((()=>JSON.parse(atob(decodeURIComponent(r)))))||dd((()=>JSON.parse(decodeURIComponent(r)))):null;return o&&o.action==="ph_authorize"?((s=o).source="url",s&&Object.keys(s).length>0&&(o.desiredHash?e.hash=o.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(Id)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch{return!1}}xt(e){var t=O.ph_load_toolbar||O.ph_load_editor;!M(t)&&Pt(t)?t(e,this.instance):Rd.warn("No toolbar load function found")}loadToolbar(e){var t=!(S==null||!S.getElementById(kh));if(!m||t)return!1;var i=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=A({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(m.localStorage.setItem(Id,JSON.stringify(A({},s,{source:void 0}))),this.wt()===Ot.LOADED)this.xt(s);else if(this.wt()===Ot.UNINITIALIZED){var r;this.yt(Ot.LOADING),(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(o=>{if(o)return Rd.error("[Toolbar] Failed to load",o),void this.yt(Ot.UNINITIALIZED);this.yt(Ot.LOADED),this.xt(s)})),ue(m,"turbolinks:load",(()=>{this.yt(Ot.UNINITIALIZED),this.loadToolbar(s)}))}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),this.maybeLoadToolbar(e,t,i)}},Db=oe("[TracingHeaders]"),Aa=class{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,i;k(this.$t)&&((t=O.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),k(this.St)&&((i=O.__PosthogExtensions__)==null||(i=i.tracingHeadersPatchFns)==null||i._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return Db.error("failed to load script",s);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.$t)==null||e.call(this),(t=this.St)==null||t.call(this),this.$t=void 0,this.St=void 0)}},Rs="https?://(.*)",Pn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],xb=Cn(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Pn),Ti="<masked>",$b=["li_fat_id"];Tt=oe("[Web Vitals]"),Cd=9e5,Ta=class{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce(((i,s)=>A({},i,{["$web_vitals_"+s.name+"_event"]:A({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=i=>{var s,r=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(k(r))Tt.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.Ct();k(o)||(M(i?.name)||M(i?.value)?Tt.error("Invalid metric received",i):this.Rt&&i.value>=this.Rt?Tt.error("Ignoring metric with value >= "+this.Rt,i):(this.N.url!==o&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),k(this.N.url)&&(this.N.url=o),this.N.firstMetricTimestamp=k(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,i.attribution&&i.attribution.interactionTargetElement&&(i.attribution.interactionTargetElement=void 0),this.N.metrics.push(A({},i,{$current_url:o,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var i,s,r,o,a=O.__PosthogExtensions__;k(a)||k(a.postHogWebVitalsCallbacks)||({onLCP:i,onCLS:s,onFCP:r,onINP:o}=a.postHogWebVitalsCallbacks),i&&s&&r&&o?(this.allowedMetrics.indexOf("LCP")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&o(this.It.bind(this)),this.P=!0):Tt.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[pd]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=he(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return M(i)?((t=this._instance.persistence)==null?void 0:t.props[_d])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(he(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=he(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return e!=null&&e}get Rt(){var e=he(this._instance.config.capture_performance)&&yt(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Cd;return 0<e&&e<=6e4?Cd:e}get isEnabled(){var e=ye?.protocol;if(e!=="http:"&&e!=="https:")return Tt.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=he(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:mt(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return mt(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(Tt.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=he(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=he(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[pd]:t}),this._instance.persistence.register({[_d]:i})),this.kt=t,this.startIfEnabled()}it(e){var t,i;if((t=O.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var s=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,s,(r=>{r?Tt.error("failed to load script",r):e()}))}}Ct(){var e=m?m.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,i=this._instance.config.custom_personal_data_properties,s=t?Cn([],Pn,i||[]):[];return Ai(e,s,Ti)}Tt.error("Could not determine current URL")}},Mb=oe("[Heatmaps]");Ia=class{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!((t=this.instance.persistence)==null||!t.props[oa]),this.rageclicks=new Bs(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return he(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return M(this.instance.config.capture_heatmaps)?M(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;Mb.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval((e=this.Ft)!==null&&e!==void 0?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[oa]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}jt(e){this.Dt(e.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft=(function(e){return e?.visibilityState==="visible"})(S)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){m&&S&&(this.Nt=this.Lt.bind(this),ue(m,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||m?.event),ue(S,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||m?.event),ue(S,"mousemove",this.zt,{capture:!0}),this.Bt=new Hs(this.instance,Ob,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),ue(S,"visibilitychange",this.qt),this.P=!0)}At(){var e;m&&S&&(this.Nt&&m.removeEventListener("beforeunload",this.Nt),this.Ut&&S.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&S.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&S.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(e=this.Bt)==null||e.stop(),this.P=!1)}Gt(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=(function(a,l,c){for(var u=a;u&&nr(u)&&!Dt(u,"body");){if(u===c)return!1;if(F(l,m?.getComputedStyle(u).position))return!0;u=Rh(u)}return!1})(Th(e),["fixed","sticky"],r);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:i),target_fixed:o,type:t}}Dt(e,t){var i;if(t===void 0&&(t="click"),!md(e.target)&&Pd(e)){var s=this.Gt(e,t);(i=this.rageclicks)!=null&&i.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(A({},s,{type:"rageclick"})),this.Vt(s)}}Ht(e){!md(e.target)&&Pd(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout((()=>{this.Vt(this.Gt(e,"mousemove"))}),500))}Vt(e){if(m){var t=m.location.href,i=this.instance.config.mask_personal_data_properties,s=this.instance.config.custom_personal_data_properties,r=i?Cn([],Pn,s||[]):[],o=Ai(t,r,Ti);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!Sn(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},qs=class{constructor(e){this.Jt=(t,i,s)=>{s&&(s.noSessionId||s.activityTimeout||s.sessionPastMaximumLength)&&(w.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:s}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Jt)}destroy(){var e;(e=this.Xt)==null||e.call(this),this.Xt=void 0}doPageView(e,t){var i,s=this.Qt(e,t);return this.Kt={pathname:(i=m?.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this.Qt(e,(t=this.Kt)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Kt)==null?void 0:e.pageViewId}}Qt(e,t){var i=this.Kt;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:h}=r;if(!(k(o)||k(a)||k(l)||k(c)||k(u)||k(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),h=Math.ceil(h);var g=o<=1?1:it(a/o,0,1,w),f=o<=1?1:it(l/o,0,1,w),p=c<=1?1:it(u/c,0,1,w),v=c<=1?1:it(h/c,0,1,w);s=ae(s,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:g,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}},vt=(function(n){return n.GZipJS="gzip-js",n.Base64="base64",n})({}),He=Uint8Array,Re=Uint16Array,On=Uint32Array,cl=new He([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ul=new He([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]),Nd=new He([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qh=function(n,e){for(var t=new Re(31),i=0;i<31;++i)t[i]=e+=1<<n[i-1];var s=new On(t[30]);for(i=1;i<30;++i)for(var r=t[i];r<t[i+1];++r)s[r]=r-t[i]<<5|i;return[t,s]},Kh=qh(cl,2),Ub=Kh[0],Ra=Kh[1];Ub[28]=258,Ra[258]=28;for(Oa=qh(ul,0)[1],Ks=new Re(32768),X=0;X<32768;++X)It=(43690&X)>>>1|(21845&X)<<1,It=(61680&(It=(52428&It)>>>2|(13107&It)<<2))>>>4|(3855&It)<<4,Ks[X]=((65280&It)>>>8|(255&It)<<8)>>>1;pi=function(n,e,t){for(var i=n.length,s=0,r=new Re(e);s<i;++s)++r[n[s]-1];var o,a=new Re(e);for(s=0;s<e;++s)a[s]=a[s-1]+r[s-1]<<1;if(t){o=new Re(1<<e);var l=15-e;for(s=0;s<i;++s)if(n[s])for(var c=s<<4|n[s],u=e-n[s],h=a[n[s]-1]++<<u,g=h|(1<<u)-1;h<=g;++h)o[Ks[h]>>>l]=c}else for(o=new Re(i),s=0;s<i;++s)o[s]=Ks[a[n[s]-1]++]>>>15-n[s];return o},Wt=new He(288);for(X=0;X<144;++X)Wt[X]=8;for(X=144;X<256;++X)Wt[X]=9;for(X=256;X<280;++X)Wt[X]=7;for(X=280;X<288;++X)Wt[X]=8;zs=new He(32);for(X=0;X<32;++X)zs[X]=5;Bb=pi(Wt,9,0),Vb=pi(zs,5,0),zh=function(n){return(n/8>>0)+(7&n&&1)},Wh=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var i=new(n instanceof Re?Re:n instanceof On?On:He)(t-e);return i.set(n.subarray(e,t)),i},dt=function(n,e,t){t<<=7&e;var i=e/8>>0;n[i]|=t,n[i+1]|=t>>>8},ti=function(n,e,t){t<<=7&e;var i=e/8>>0;n[i]|=t,n[i+1]|=t>>>8,n[i+2]|=t>>>16},No=function(n,e){for(var t=[],i=0;i<n.length;++i)n[i]&&t.push({s:i,f:n[i]});var s=t.length,r=t.slice();if(!s)return[new He(0),0];if(s==1){var o=new He(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(I,K){return I.f-K.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,u=1,h=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=t[t[c].f<t[h].f?c++:h++],l=t[c!=u&&t[c].f<t[h].f?c++:h++],t[u++]={s:-1,f:a.f+l.f,l:a,r:l};var g=r[0].s;for(i=1;i<s;++i)r[i].s>g&&(g=r[i].s);var f=new Re(g+1),p=Ca(t[u-1],f,0);if(p>e){i=0;var v=0,_=p-e,E=1<<_;for(r.sort((function(I,K){return f[K.s]-f[I.s]||I.f-K.f}));i<s;++i){var b=r[i].s;if(!(f[b]>e))break;v+=E-(1<<p-f[b]),f[b]=e}for(v>>>=_;v>0;){var C=r[i].s;f[C]<e?v-=1<<e-f[C]++-1:++i}for(;i>=0&&v;--i){var N=r[i].s;f[N]==e&&(--f[N],++v)}p=e}return[new He(f),p]},Ca=function(n,e,t){return n.s==-1?Math.max(Ca(n.l,e,t+1),Ca(n.r,e,t+1)):e[n.s]=t},Dd=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new Re(++e),i=0,s=n[0],r=1,o=function(l){t[i++]=l},a=1;a<=e;++a)if(n[a]==s&&a!=e)++r;else{if(!s&&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(s),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(s);r=1,s=n[a]}return[t.subarray(0,i),e]},ni=function(n,e){for(var t=0,i=0;i<e.length;++i)t+=n[i]*e[i];return t},Pa=function(n,e,t){var i=t.length,s=zh(e+2);n[s]=255&i,n[s+1]=i>>>8,n[s+2]=255^n[s],n[s+3]=255^n[s+1];for(var r=0;r<i;++r)n[s+r+4]=t[r];return 8*(s+4+i)},xd=function(n,e,t,i,s,r,o,a,l,c,u){dt(e,u++,t),++s[256];for(var h=No(s,15),g=h[0],f=h[1],p=No(r,15),v=p[0],_=p[1],E=Dd(g),b=E[0],C=E[1],N=Dd(v),I=N[0],K=N[1],B=new Re(19),P=0;P<b.length;++P)B[31&b[P]]++;for(P=0;P<I.length;++P)B[31&I[P]]++;for(var Ee=No(B,7),de=Ee[0],R=Ee[1],$=19;$>4&&!de[Nd[$-1]];--$);var U,L,le,se,Z=c+5<<3,ce=ni(s,Wt)+ni(r,zs)+o,ke=ni(s,g)+ni(r,v)+o+14+3*$+ni(B,de)+(2*B[16]+3*B[17]+7*B[18]);if(Z<=ce&&Z<=ke)return Pa(e,u,n.subarray(l,l+c));if(dt(e,u,1+(ke<ce)),u+=2,ke<ce){U=pi(g,f,0),L=g,le=pi(v,_,0),se=v;var D=pi(de,R,0);for(dt(e,u,C-257),dt(e,u+5,K-1),dt(e,u+10,$-4),u+=14,P=0;P<$;++P)dt(e,u+3*P,de[Nd[P]]);u+=3*$;for(var xe=[b,I],pe=0;pe<2;++pe){var Se=xe[pe];for(P=0;P<Se.length;++P){var ve=31&Se[P];dt(e,u,D[ve]),u+=de[ve],ve>15&&(dt(e,u,Se[P]>>>5&127),u+=Se[P]>>>12)}}}else U=Bb,L=Wt,le=Vb,se=zs;for(P=0;P<a;++P)if(i[P]>255){ve=i[P]>>>18&31,ti(e,u,U[ve+257]),u+=L[ve+257],ve>7&&(dt(e,u,i[P]>>>23&31),u+=cl[ve]);var bt=31&i[P];ti(e,u,le[bt]),u+=se[bt],bt>3&&(ti(e,u,i[P]>>>5&8191),u+=ul[bt])}else ti(e,u,U[i[P]]),u+=L[i[P]];return ti(e,u,U[256]),u+L[256]},Gb=new On([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),jb=(function(){for(var n=new On(256),e=0;e<256;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n})(),Hb=function(n,e,t,i,s){return(function(r,o,a,l,c,u){var h=r.length,g=new He(l+h+5*(1+Math.floor(h/7e3))+c),f=g.subarray(l,g.length-c),p=0;if(!o||h<8)for(var v=0;v<=h;v+=65535){var _=v+65535;_<h?p=Pa(f,p,r.subarray(v,_)):(f[v]=u,p=Pa(f,p,r.subarray(v,h)))}else{for(var E=Gb[o-1],b=E>>>13,C=8191&E,N=(1<<a)-1,I=new Re(32768),K=new Re(N+1),B=Math.ceil(a/3),P=2*B,Ee=function(sr){return(r[sr]^r[sr+1]<<B^r[sr+2]<<P)&N},de=new On(25e3),R=new Re(288),$=new Re(32),U=0,L=0,le=(v=0,0),se=0,Z=0;v<h;++v){var ce=Ee(v),ke=32767&v,D=K[ce];if(I[ke]=D,K[ce]=ke,se<=v){var xe=h-v;if((U>7e3||le>24576)&&xe>423){p=xd(r,f,0,de,R,$,L,le,Z,v-Z,p),le=U=L=0,Z=v;for(var pe=0;pe<286;++pe)R[pe]=0;for(pe=0;pe<30;++pe)$[pe]=0}var Se=2,ve=0,bt=C,qe=ke-D&32767;if(xe>2&&ce==Ee(v-qe))for(var Nn=Math.min(b,xe)-1,Ii=Math.min(32767,v),Ri=Math.min(258,xe);qe<=Ii&&--bt&&ke!=D;){if(r[v+Se]==r[v+Se-qe]){for(var Ke=0;Ke<Ri&&r[v+Ke]==r[v+Ke-qe];++Ke);if(Ke>Se){if(Se=Ke,ve=qe,Ke>Nn)break;var Oi=Math.min(qe,Ke-2),Dn=0;for(pe=0;pe<Oi;++pe){var xt=v-qe+pe+32768&32767,Jt=xt-I[xt]+32768&32767;Jt>Dn&&(Dn=Jt,D=xt)}}}qe+=(ke=D)-(D=I[ke])+32768&32767}if(ve){de[le++]=268435456|Ra[Se]<<18|Oa[ve];var fl=31&Ra[Se],gl=31&Oa[ve];L+=cl[fl]+ul[gl],++R[257+fl],++$[gl],se=v+Se,++U}else de[le++]=r[v],++R[r[v]]}}p=xd(r,f,u,de,R,$,L,le,Z,v-Z,p)}return Wh(g,0,l+zh(p)+c)})(n,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+e.mem,t,i,!0)},Do=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};Kb=function(n){var e,t,i,s,r="";for(e=t=0,i=(n=(n+"").replace(/\r\n/g,`
|
|
8
|
+
`),h=[],g=2,f=u.length;g<f;g+=2){var p=c.exec(u[g]);p&&h.push(new r({fileName:p[2],lineNumber:p[1],source:u[g]}))}return h},parseOpera10:function(l){for(var c=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,u=l.stacktrace.split(`
|
|
9
|
+
`),h=[],g=0,f=u.length;g<f;g+=2){var p=c.exec(u[g]);p&&h.push(new r({functionName:p[3]||void 0,fileName:p[2],lineNumber:p[1],source:u[g]}))}return h},parseOpera11:function(l){var c=l.stack.split(`
|
|
10
|
+
`).filter(function(u){return!!u.match(n)&&!u.match(/^Error created at/)},this);return c.map(function(u){var h=u.split("@"),g=this.extractLocation(h.pop()),f=h.shift()||"",p=f.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,v;f.match(/\(([^)]*)\)/)&&(v=f.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var _=v===void 0||v==="[arguments not available]"?void 0:v.split(",");return new r({functionName:p,args:_,fileName:g[0],lineNumber:g[1],columnNumber:g[2],source:u})},this)}}})})(qr)),qr.exports}function Bl(i,e,t,r){return{errorClass:Ul(i),message:`${t}${Ul(e)}`,type:"browserjs",stacktrace:r.reduce((n,s)=>{let o=dv(s);try{return JSON.stringify(o)==="{}"?n:n.concat(o)}catch{return n}},[])}}function Bc(i,e){let t=Object.assign(i,e);for(let r of Object.keys(t))typeof t[r]=="object"&&typeof e[r]=="object"&&(t[r]=Bc(t[r],e[r]));return t}async function Yv(i){let e=Kv[i];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((t,r)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(s=>{import(s).then(o=>{if(!e.inited){let a=Wv();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}t(e.lib)}).catch(r)})})}function Oe(i,e){if(!i?.default&&e){let t=Object.create(null);return t.default=i,t.__esModule=!0,t}return i}function Ce(i,e){return Yv(i).then(t=>t.get(e).then(r=>r()))}function T_(){return Kl||(Kl=1,(function(i,e){(function(t,r){i.exports=r()})(A_,function(){function t(f){return f=JSON.stringify(f),!!/^\{[\s\S]*\}$/.test(f)}function r(f){return f===void 0||typeof f=="function"?f+"":JSON.stringify(f)}function n(f){if(typeof f=="string")try{return JSON.parse(f)}catch{return f}}function s(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",v="yes";try{f||(f=window.localStorage),f.setItem(p,v),f.removeItem(p)}catch{var _={};_._data={},_.setItem=function(E,D){return _._data[E]=String(D)},_.getItem=function(E){return _._data.hasOwnProperty(E)?_._data[E]:void 0},_.removeItem=function(E){return delete _._data[E]},_.clear=function(){return _._data={}},f=_}finally{f.getItem(p)===v&&f.removeItem(p)}return f}var l=a();function c(){if(!(this instanceof c))return new c}c.prototype={set:function(p,v){if(p&&!t(p))l.setItem(p,r(v));else if(t(p))for(var _ in p)this.set(_,p[_]);return this},get:function(p){if(p===void 0){var v={};return this.forEach(function(R,K){return v[R]=K}),v}if(p.charAt(0)==="?")return this.has(p.substr(1));var _=arguments;if(_.length>1){for(var b={},E=0,D=_.length;E<D;E++){var N=n(l.getItem(_[E]));this.has(_[E])&&(b[_[E]]=N)}return b}return n(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var v=this.get(p);return l.removeItem(p),v},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(v){p.push(v)}),p},forEach:function(p){for(var v=0,_=l.length;v<_;v++){var b=l.key(v);p(b,this.get(b))}return this},search:function(p){for(var v=this.keys(),_={},b=0,E=v.length;b<E;b++)v[b].indexOf(p)>-1&&(_[v[b]]=this.get(v[b]));return _},len:function(){return l.length}};var u=null;function h(f,p){var v=arguments,_=null;if(u||(u=c()),v.length===0)return u.get();if(v.length===1){if(typeof f=="string")return u.get(f);if(t(f))return u.set(f)}if(v.length===2&&typeof f=="string"){if(!p)return u.remove(f);if(p&&typeof p=="string")return u.set(f,p);p&&s(p)&&(_=null,_=p(f,u.get(f)),h.set(f,_))}if(v.length===2&&o(f)&&s(p))for(var b=0,E=f.length;b<E;b++)_=p(f[b],u.get(f[b])),h.set(f[b],_);return h}for(var g in c.prototype)h[g]=c.prototype[g];return h})})(Wr)),Wr.exports}var yf,bf,wf,V,Tf,If,Rf,Of,sc,I,ee,De,me,Je,Cf,W,li,Pf,Js,Df,Es,Nf,xf,$f,te,Lf,ge,ht,ji,Xr,lt,et,Qs,Mf,kl,Jr,Ff,Uf,Qr,Zs,oc,ac,lc,hs,eo,ks,He,cc,Vi,Bt,Hi,ni,Bf,fs,Vf,Gf,jf,Fr,Sl,Vr,It,gs,jt,Gr,Ur,Kf,nn,Wf,uc,Yf,dc,Xf,$,Jf,wl,Qf,Zf,eg,tg,ig,rg,ng,hc,sg,Xe,og,fc,G,jr,sn,to,ae,Al,Wi,ag,gc,lg,Tl,cg,ug,zi,dg,hg,fg,Il,gg,Rl,pg,vg,Ol,Ss,Cl,_g,mg,pc,Yi,vc,Pl,bg,Eg,kg,Sg,wg,Ag,Tg,Ig,Rg,Og,Zr,Cg,H,Ki,Rt,ws,en,As,Br,Dl,Sc,Dg,Ng,xg,Ts,ft,ct,wc,Is,Nl,$g,Lg,Mg,Fg,Ug,Bg,Vg,Gg,xl,jg,Hg,qg,zg,Kg,Wg,Yg,$l,Xg,Jg,Ac,Qg,Zg,ep,tp,ip,rp,np,Ll,sp,op,ap,lp,cp,up,dp,hp,fp,gp,pp,vp,_p,mp,yp,bp,Ep,kp,Sp,wp,Ap,Tp,Ip,Rp,Op,Cp,Pp,Tc,an,Ic,Dp,Xi,ln,ro,Rc,Oc,Cc,Vt,Np,Rs,Hr,xp,$p,Lp,Mp,Fp,Up,z,ps,Bp,Vp,Gp,jp,Hp,qp,zp,Kp,Wp,Yp,Xp,Jp,Qp,Zp,ev,tv,iv,rv,d,qr,zr,nv,Ml,ov,Fl,lv,cv,Dc,uv,dv,Ul,Nc,hv,Vl,Kr,fv,gv,pv,vv,_v,mv,yv,bv,Gl,jl,Os,xc,Ev,kv,Sv,wv,Av,Tv,Iv,$c,Rv,Ov,Cv,Pv,Dv,Nv,xv,$v,Lv,Mv,Lc,Mc,Fv,Uv,Bv,Vv,Cs,Fc,Ps,Gv,jv,Hv,Hl,qv,Uc,zv,Kv,Wv,Xv,Jv,Vc,Qv,Zv,vs,e_,Ds,Pe,Fe,je,tt,Ht,t_,i_,r_,n_,s_,o_,a_,l_,c_,u_,d_,h_,si,f_,Gc,jc,g_,Hc,qc,oi,ql,zl,p_,v_,Ns,__,ut,m_,y_,b_,E_,k_,S_,w_,xs,tn,Wr,A_,Kl,I_,Ut,zc,ai,$s,no,Ls,so,Ms,oo,Ye,R_,O_,C_,P_,D_,Fs,N_,Us,x_,$_,Kc,L_,M_,F_,ci,Bs,Wc,U_,B_,V_,ui,_s,ms,G_,j_,H_,Wl,q_,Yc,z_,K_,W_,Y_,X_,J_,Q_,Z_,em,Xc,tm,im,Vs,rm,Jc,nm,sm,om,Qc,am,lm,Gs,cm,um,dm,hm,Yl,fm,Xl,gm,Jl,js,pm,vm,Ql,ys,Zc,_m,rn,Zl,eu,ec,mm,ym,bm,Em,km,qi,Hs,Sm,wm,Am,bs,Tm,Im,Rm,Om,Cm,Gi,qs,zs,Ks,Pm,Dm,Nm,tc,ic,xm,$m,Lm,Mm,Yr,Ws,rc,Fm,Um,Ys,Gt,di,ao=Re(()=>{"use strict";yf=dt(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});bf=Number.isInteger||function(e){return e<<0===e};wf=(function(){function i(){this.map={},this.length=0}return i.prototype.set=function(e,t){var r=this.hash(e),n=this.map[r];n||(this.map[r]=n=[]),n.push([e,t]),this.length+=1},i.prototype.hash=function(e){var t=[];for(var r in e)t.push(Object.prototype.toString.call(e[r]));return t.join()},i.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var o=this.map[t],r=0;r<o.length;r+=1){var n=o[r];if(n[0]===e)return n[1]}return}var s=this.hash(e),o=this.map[s];if(o)for(var r=0;r<o.length;r+=1){var n=o[r];if(n[0]===e)return n[1]}},i})(),V=dt(function(e){return e!=null&&typeof e.clone=="function"?e.clone():nc(e)});Tf=Xs(function(e,t,r){var n={},s;t=t||{},r=r||{};for(s in t)Mr(s,t)&&(n[s]=Mr(s,r)?e(s,t[s],r[s]):t[s]);for(s in r)Mr(s,r)&&!Mr(s,n)&&(n[s]=r[s]);return n}),If=Xs(function i(e,t,r){return Tf(function(n,s,o){return El(s)&&El(o)?i(e,s,o):e(n,s,o)},t,r)}),Rf=Xs(function(e,t,r){return If(function(n,s,o){return e(s,o)},t,r)}),Of=Tt(Af),sc=Tt(function(e,t){var r={};for(var n in t)e(t[n],n,t)&&(r[n]=t[n]);return r}),I=i=>typeof i=="function"&&!!(i.constructor&&i.call&&i.apply),ee=i=>typeof i=="string",De=i=>i===null,me=i=>typeof i>"u",Je=i=>De(i)||me(i),Cf=i=>typeof i=="bigint",W=i=>!me(i),li=i=>!Je(i),Pf=i=>li(i)&&i!=="",Js=i=>{switch(Object.prototype.toString.call(i)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return i instanceof Error}},Df=i=>typeof i=="boolean",Es=(i,e)=>{let t=e.split(".");return Of(t,i)},Nf=(i,e)=>!!Es(i,e),xf=i=>typeof i=="object",$f=i=>!De(i)&&xf(i)&&!Array.isArray(i),te=i=>!De(i)&&Object.prototype.toString.call(i)==="[object Object]",Lf=(i,e)=>{if(!Array.isArray(i)||!Array.isArray(e))return V(e);let t=V(i);return e.forEach((r,n)=>{t[n]=Array.isArray(r)||$f(r)?ge(t[n],r):r}),t},ge=(i,e)=>Rf(Lf,i,e),ht=i=>te(i)&&Object.keys(i).length>0,ji=i=>{let e=sc(W,i);return Object.keys(e).forEach(t=>{let r=e[t];te(r)&&(e[t]=ji(r))}),e},Xr=i=>{let e=sc(li,i);return Object.keys(e).forEach(t=>{let r=e[t];te(r)&&(e[t]=Xr(r))}),e},lt=i=>{if(ht(i))return Xr(i)},et=(i,e)=>typeof i=="boolean"?i:e,Qs=i=>(Object.getOwnPropertyNames(i).forEach(function(e){i[e]&&typeof i[e]=="object"&&Qs(i[e])}),Object.freeze(i)),Mf=i=>i.replace(/^\s+|\s+$/gm,""),kl=i=>i.replace(/^\.+/,""),Jr=i=>{let e=i;if(!ee(i)&&!Je(i))try{e=JSON.stringify(i)}catch{e=null}return e},Ff=i=>{let e=Array.from(i,t=>String.fromCodePoint(t)).join("");return globalThis.btoa(e)},Uf=i=>Ff(new TextEncoder().encode(i)),Qr=(i,e,t,r,n)=>{let s={category:i,name:e,properties:t,options:r,callback:void 0};I(n)&&(s.callback=n),I(r)&&(s.category=i,s.name=e,s.properties=t,s.options=void 0,s.callback=r),I(t)&&(s.category=i,s.name=e,s.properties=void 0,s.options=void 0,s.callback=t),I(e)&&(s.category=i,s.name=void 0,s.properties=void 0,s.options=void 0,s.callback=e),I(i)&&(s.category=void 0,s.name=void 0,s.properties=void 0,s.options=void 0,s.callback=i),te(i)?(s.name=void 0,s.category=void 0,s.properties=i,I(e)?s.options=void 0:s.options=e):te(e)&&(s.name=void 0,s.properties=e,I(t)?s.options=void 0:s.options=t),ee(i)&&!ee(e)&&(s.category=void 0,s.name=i),W(s.category)||(s.category=void 0),W(s.name)||(s.name=void 0),s.properties=s.properties?V(s.properties):{},W(s.options)?s.options=V(s.options):s.options=void 0;let o=ee(s.name)?s.name:s.properties.name,a=ee(s.category)?s.category:s.properties.category;return s.properties=ge(te(s.properties)?s.properties:{},{...o&&{name:o},...a&&{category:a}}),s},Zs=(i,e,t,r)=>{let n={name:i,properties:e,options:t,callback:void 0};return I(r)&&(n.callback=r),I(t)&&(n.properties=e,n.options=void 0,n.callback=t),I(e)&&(n.properties=void 0,n.options=void 0,n.callback=e),n.properties=li(n.properties)?V(n.properties):{},W(n.options)?n.options=V(n.options):n.options=void 0,n},oc=(i,e,t,r)=>{let n={userId:i,traits:e,options:t,callback:void 0};return I(r)&&(n.callback=r),I(t)&&(n.userId=i,n.traits=e,n.options=void 0,n.callback=t),I(e)&&(n.userId=i,n.traits=void 0,n.options=void 0,n.callback=e),(te(i)||De(i))&&(n.userId=null,n.traits=i,I(e)?n.options=void 0:n.options=e),n.userId=Jr(n.userId),te(n.traits)?n.traits=V(n.traits):n.traits=void 0,W(n.options)?n.options=V(n.options):n.options=void 0,n},ac=(i,e,t,r)=>{let n={to:i,from:e,options:t,callback:void 0};return I(r)&&(n.callback=r),I(t)&&(n.to=i,n.from=e,n.options=void 0,n.callback=t),I(e)?(n.to=i,n.from=void 0,n.options=void 0,n.callback=e):(te(e)||De(e))&&(n.to=i,n.from=void 0,n.options=e),W(n.to)&&(n.to=Jr(n.to)),W(n.from)?n.from=Jr(n.from):n.from=void 0,W(n.options)?n.options=V(n.options):n.options=void 0,n},lc=(i,e,t,r)=>{let n={groupId:i,traits:e,options:t,callback:void 0};return I(r)&&(n.callback=r),I(t)&&(n.groupId=i,n.traits=e,n.options=void 0,n.callback=t),I(e)&&(n.groupId=i,n.traits=void 0,n.options=void 0,n.callback=e),(te(i)||De(i))&&(n.groupId=null,n.traits=i,I(e)?n.options=void 0:n.options=e),n.groupId=Jr(n.groupId),te(n.traits)?n.traits=V(n.traits):n.traits=void 0,W(n.options)?n.options=V(n.options):n.options=void 0,n},hs=(function(i){return i.UNLOADED="Page Unloaded",i})({}),eo="API",ks="CapabilitiesManager",He="ConfigManager",cc="EventManager",Vi="PluginsManager",Bt="UserSessionManager",Hi="ErrorHandler",ni="PluginEngine",Bf="StoreManager",fs=`Ready${eo}`,Vf=`Load${eo}`,Gf="HttpClient",jf="RudderStackAnalytics",Fr="AnalyticsCore";Sl=4096,Vr=[],It=0;for(;It<256;It++)Vr[It]=(It+256).toString(16).substring(1);jt=256,Gr=[];for(;jt--;)Gr[jt]=(jt+256).toString(16).substring(1);Kf=()=>!Je(globalThis.crypto)&&I(globalThis.crypto.getRandomValues),nn=()=>Kf()?qf():zf(),Wf=()=>!!window.chrome?.runtime?.id,uc=()=>ee(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),Yf=(i,e=!1)=>{let t=!1,r=!1;function n(){t||(t=!0,i(r),setTimeout(()=>{t=!1},0))}(e||uc())&&globalThis.addEventListener("beforeunload",()=>{r=!1,n()}),globalThis.addEventListener("blur",()=>{r=!0,n()}),globalThis.addEventListener("focus",()=>{t=!1}),document.addEventListener("pagehide",()=>{r=document.visibilityState==="hidden",n()}),document.addEventListener("visibilitychange",()=>{r=!0,document.visibilityState==="hidden"?n():t=!1})},dc=i=>i.toISOString(),Xf=()=>dc(new Date),$=":: ",Jf=i=>`A script with the id "${i}" is already loaded. Skipping the loading of this script to prevent conflicts`,wl=(i,e,t)=>`Unable to load (${ee(t)?t:t.type}) the script with the id "${i}" from URL "${e}"`,Qf=(i,e,t)=>`A timeout of ${t} ms occurred while trying to load the script with id "${i}" from URL "${e}"`,Zf=(i,e)=>`${i}${$}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,eg="Failed to convert the value to a JSON string.",tg="Failed to encode the cookie data.",ig=(i,e)=>`${i}${$}The "${e}" storage type is `,rg="JSONStringify",ng="[BigInt]",hc="[Circular Reference]",sg=(i,e,t)=>{let r=[];return function(n,s){if(!e?.includes(n)&&!(i&&Je(s))){if(typeof s!="object"||De(s))return s;for(;r.length>0&&r[r.length-1]!==this;)r.pop();return r.includes(s)?(t?.warn(Zf(rg,n)),hc):(r.push(s),s)}}},Xe=(i,e,t,r)=>{try{return JSON.stringify(i,sg(e,t,r))}catch(n){return r?.warn(eg,n),null}},og=i=>{let e=[];return function(r,n){if(Cf(n))return ng;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(n)?hc:(e.push(n),n)}},fc=(i,e)=>{let t=Array.isArray(i)?[]:{};for(let r in i)if(Object.hasOwnProperty.call(i,r)){let n=i[r],s=e.call(i,r,n);te(s)||Array.isArray(s)?t[r]=fc(s,e):t[r]=s}return t},G=(i,e)=>{let t=og(),r=t.call(i,"",i);return te(i)||Array.isArray(i)?fc(i,t):r},jr="[SDK DISPATCHED ERROR]",sn=i=>{let{stack:e,stacktrace:t,"opera#sourceloc":r}=i,n=e??t??r;if(n&&typeof n=="string")return n},to=(i,e)=>{if(!Js(i))return new Error(`${e}: ${Xe(i)}`);try{let t=i.constructor,r=new t(`${e}: ${i.message}`),n=sn(i);return n&&(r.stack=n),Object.getOwnPropertyNames(i).forEach(s=>{if(s!=="message"&&s!=="stack"&&s!=="name")try{r[s]=i[s]}catch{}}),r}catch{return new Error(`${e}: ${Xe(i)}`)}},ae=i=>{if(Js(i)){let e=sn(i);if(e){let{stack:t,stacktrace:r,"opera#sourceloc":n}=i;switch(e){case t:i.stack=`${t}
|
|
11
|
+
${jr}`;break;case r:i.stacktrace=`${r}
|
|
12
|
+
${jr}`;break;case n:default:i["opera#sourceloc"]=`${n}
|
|
13
|
+
${jr}`;break}}}globalThis.dispatchEvent(new ErrorEvent("error",{error:i,bubbles:!0,cancelable:!0,composed:!0}))},Al="RudderLabs JavaScript SDK",Wi="3.29.0",ag="com.rudderlabs.javascript",gc="npm",lg="modern",Tl="RudderJS-Initiated",cg="ad-block page request",ug="/ad-blocked",zi="preloadedEventsBuffer",dg="Consent Management Interaction",hg="ajs_trait_",fg="ajs_prop_",Il="ajs_aid",gg="ajs_uid",Rl="ajs_event",pg=10*1e3,vg=31536e3*1e3,Ol=720*60*1e3,Ss=1800*1e3,Cl=10*1e3,_g=10*1e3,mg=250,pc=(i="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[i]||(globalThis.RudderStackGlobals[i]={})},Yi=(i,e,t="app")=>{pc(t),globalThis.RudderStackGlobals[t][i]=e},vc=(i,e="app")=>(pc(e),globalThis.RudderStackGlobals[e][i]);Pl=(i,e)=>{let t={};return i.forEach((r,n)=>{if(n.startsWith(e)){let s=n.substring(e.length);t[s]=i.get(n)}}),t},bg=(i=[])=>{let e={trait:hg,properties:fg},t=new URLSearchParams(globalThis.location.search);t.get(Rl)&&i.unshift(["track",t.get(Rl),Pl(t,e.properties)]);let r=t.get(gg),n=Pl(t,e.trait);if(r||ht(n)){let s=[...r?[r]:[],n];i.unshift(["identify",...s])}t.get(Il)&&i.unshift(["setAnonymousId",t.get(Il)])},Eg=i=>{let e="load",t=[],r=0;for(;r<i.length;){if(i[r]&&i[r][0]===e){t=V(i[r]),i.splice(r,1);break}r+=1}return t},kg=i=>{let e="consent",t=i.filter(n=>n[0]===e),r=i.filter(n=>n[0]!==e);i.splice(0,i.length,...t,...r)},Sg=i=>{let e=vc(zi)||[];bg(e),e.length>0&&(i.enqueuePreloadBufferEvents(e),Yi(zi,[]))},wg=(i,e)=>{let t=i.shift(),r;if(I(e[t])){switch(t){case"page":r=Qr(...i);break;case"track":r=Zs(...i);break;case"identify":r=oc(...i);break;case"alias":r=ac(...i);break;case"group":r=lc(...i);break;default:e[t](...i);break}r&&e[t](r)}},Ag=10*1e3,Tg="RS_JS_SDK",Ig=(i,e,t=!0,r=null,n=null,s={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=r,o.onerror=n,o.src=i,o.id=e,o.async=t,Object.keys(s).forEach(a=>{o.setAttribute(a,s[a])}),o.setAttribute("data-loader",Tg),o},Rg=i=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(i,e[0]?.firstChild);return}let t=document.getElementsByTagName("script");if(t.length>0&&t[0]?.parentNode){t[0]?.parentNode.insertBefore(i,t[0]);return}let r=document.createElement("head");r.appendChild(i);let n=document.getElementsByTagName("html")[0];n?.insertBefore(r,n.firstChild)},Og=(i,e,t,r=!0,n)=>new Promise((s,o)=>{document.getElementById(e)&&o(new Error(Jf(e)));try{let l;Rg(Ig(i,e,r,()=>{globalThis.clearTimeout(l),s(e)},h=>{globalThis.clearTimeout(l),o(new Error(wl(e,i,h)))},n)),l=globalThis.setTimeout(()=>{o(new Error(Qf(e,i,t)))},t)}catch(l){o(to(l,wl(e,i,"unknown")))}}),Zr=class{constructor(e,t=Ag){this.logger=e,this.timeout=t}loadJSFile(e){let{url:t,id:r,timeout:n,async:s,callback:o,extraAttributes:a}=e,l=!I(o);Og(t,r,n||this.timeout,s,a).then(c=>{l||o(c)}).catch(c=>{l||o(r,c)})}},Cg=Symbol.for("preact-signals");H=void 0;Ki=void 0,Rt=0,ws=0,en=0;we.prototype.brand=Cg;we.prototype.h=function(){return!0};we.prototype.S=function(i){var e=this,t=this.t;t!==i&&i.e===void 0&&(i.x=t,this.t=i,t!==void 0?t.e=i:_c(function(){var r;(r=e.W)==null||r.call(e)}))};we.prototype.U=function(i){var e=this;if(this.t!==void 0){var t=i.e,r=i.x;t!==void 0&&(t.x=r,i.e=void 0),r!==void 0&&(r.e=t,i.x=void 0),i===this.t&&(this.t=r,r===void 0&&_c(function(){var n;(n=e.Z)==null||n.call(e)}))}};we.prototype.subscribe=function(i){var e=this;return it(function(){var t=e.value,r=H;H=void 0;try{i(t)}finally{H=r}},{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 i=H;H=void 0;try{return this.value}finally{H=i}};Object.defineProperty(we.prototype,"value",{get:function(){var i=mc(this);return i!==void 0&&(i.i=this.i),this.v},set:function(i){if(i!==this.v){if(ws>100)throw new Error("Cycle detected");this.v=i,this.i++,en++,Rt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{on()}}}});hi.prototype=new we;hi.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===en))return!0;if(this.g=en,this.f|=1,this.i>0&&!yc(this))return this.f&=-2,!0;var i=H;try{bc(this),H=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return H=i,Ec(this),this.f&=-2,!0};hi.prototype.S=function(i){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,i)};hi.prototype.U=function(i){if(this.t!==void 0&&(we.prototype.U.call(this,i),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};hi.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;i!==void 0;i=i.x)i.t.N()}};Object.defineProperty(hi.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=mc(this);if(this.h(),i!==void 0&&(i.i=this.i),16&this.f)throw this.v;return this.v}});fi.prototype.c=function(){var i=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{i()}};fi.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,kc(this),bc(this),Rt++;var i=H;return H=this,Pg.bind(this,i)};fi.prototype.N=function(){2&this.f||(this.f|=2,this.o=Ki,Ki=this)};fi.prototype.d=function(){this.f|=8,1&this.f||io(this)};fi.prototype.dispose=function(){this.d()};As=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=[]}},Br={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Dl="LOG",Sc="ERROR",Dg="RS SDK",Ng="font-weight: bold; background: black; color: white;",xg="font-weight: normal;",Ts=class{constructor(e=Dl,t="",r=console){this.minLogLevel=Br[e],this.scope=t,this.logProvider=r}log(...e){this.outputLog("LOG",e)}info(...e){this.outputLog("INFO",e)}debug(...e){this.outputLog("DEBUG",e)}warn(...e){this.outputLog("WARN",e)}error(...e){this.outputLog("ERROR",e)}outputLog(e,t){this.minLogLevel<=Br[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=Br[e],me(this.minLogLevel)&&(this.minLogLevel=Br[Dl])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t=`%c ${Dg}`;this.scope&&(t=`${t} - ${this.scope}`);let r=ee(e[0])?e[0].trim():"";t=`${t} %c ${r}`;let n=[t,Ng,xg];return ee(e[0])||n.push(e[0]),n.push(...e.slice(1)),n}return e}},ft=new Ts,ct=(function(i){return i.HANDLEDEXCEPTION="handledException",i.UNHANDLEDEXCEPTION="unhandledException",i.UNHANDLEDREJECTION="unhandledPromiseRejection",i})({}),wc=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Is="cookieStorage",Nl="Unable to process/parse source configuration response",$g="The source is disabled. Please enable the source in the dashboard to send events.",Lg="Failed to prepare data for the request.",Mg="Failed to invoke plugin because the extension point name is missing.",Fg="Failed to invoke plugin because the extension point name is invalid.",Ug=i=>`${i}${$}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,Bg=(i,e,t)=>`${i}${$}The base URL "${t}" for ${e} is not valid.`,Vg=(i,e,t)=>`${i}${$}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(t)}".`,Gg=(i,e)=>`${i}${$}Ignoring a non-error: ${e}.`,xl="Failed to log breadcrumb",jg=i=>`${i}${$}Failed to handle the error.`,Hg=i=>`${i}${$}Plugin name is missing.`,qg=(i,e)=>`${i}${$}Plugin "${e}" already exists.`,zg=(i,e)=>`${i}${$}Plugin "${e}" not found.`,Kg=(i,e)=>`${i}${$}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.`,Wg=(i,e,t)=>`${i}${$}Plugin "${e}" could not be loaded because some of its dependencies "${t}" do not exist.`,Yg=(i,e,t)=>`${i}${$}Failed to invoke the "${e}" extension point of plugin "${t}".`,$l="Failed to fetch the source config",Xg=(i,e)=>`${i}${$}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,Jg=(i,e)=>`${i}${$}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.`,Ac=i=>`${i}${$}The provided callback parameter is not a function.`,Qg=(i,e,t,r,n)=>`${i} with status ${e} (${t}) for URL: ${r}. Response: ${n.trim()}`,Zg=(i,e,t)=>`${i} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${t}`,ep=(i,e)=>`${i} for URL: ${e}`,tp=i=>`Failed to save the value for "${i}" to storage`,ip=i=>`Failed to retrieve or parse data for "${i}" from storage`,rp=i=>`The server responded with status ${i} while setting the cookies. As a fallback, the cookies will be set client side.`,np=i=>`The server failed to set the ${i} cookie. As a fallback, the cookies will be set client side.`,Ll="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",sp=(i,e,t)=>`${i}${$}The storage type "${e}" is not supported. Please choose one of the following supported types: "${wc}". The default type "${t}" will be used instead.`,op=(i,e,t,r)=>`${i}${$}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(t)}". The default version "${r}" will be used instead.`,ap=(i,e,t)=>`${i}${$}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${t}). To enable storage data migration, please update the storage encryption version to the latest version.`,lp=(i,e,t)=>`${i}${$}The provided cookie domain (${e}) does not match the current webpage's domain (${t}). Hence, the cookies will be set client-side.`,cp=(i,e,t,r)=>`${i}${$}The "${e}" property defined under "${t}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${r}).`,up=i=>`${i}${$}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,dp=i=>`${i}${$}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,hp=(i,e,t)=>`${i}${$}The session timeout value "${e}" is not a number. The default timeout of ${t} ms will be used instead.`,fp=(i,e,t)=>`${i}${$}The session cut off duration value "${e}" is not a number. The default cut off duration of ${t} ms will be used instead.`,gp=(i,e,t)=>`${i}${$}The session cut off duration value "${e}" ms is less than the session timeout value "${t}" ms. The cut off functionality will be disabled.`,pp=i=>`${i}${$}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.`,vp=(i,e,t)=>`${i}${$}The session timeout value ${e} ms is less than the recommended minimum of ${t} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,_p=(i,e,t)=>`${i}${$}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${t}" digits long. A new session ID will be auto-generated instead.`,mp=i=>`${i}${$}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,yp=(i,e,t,r)=>`${i}${$}The storage type "${t}" is not available for entry "${e}". The SDK will initialize the entry with "${r}" storage type instead.`,bp=i=>`${i}${$}The callback threw an exception`,Ep=(i,e)=>`${i}${$}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,kp=(i,e)=>`Failed to load the polyfill script with ID "${i}" from URL ${e}.`,Sp=(i,e,t)=>`${i}${$}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${t}" will be used instead.`,wp=(i,e,t)=>`${i}${$}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${t}" will be used instead.`,Ap=(i,e)=>`${i}${$}${e} plugin is deprecated. Please exclude it from the load API options.`,Tp=(i,e,t,r)=>{let n=t.length===1,s=n?` '${t[0]}' plugin was`:` ['${t.join("', '")}'] plugins were`,o=`${i}${$}${e}, but${s} not configured to load.`;return r?`${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.`},Ip=(i,e)=>`${i}${$}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,Rp=i=>`${i}${$}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,Op=(i,e)=>`${i}${$}Ignoring unknown plugins: ${e.join(", ")}.`,Cp=(i,e)=>`${i}${$}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.`,Pp=(i,e)=>`${i}${$}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,Tc={All:!0},an="js-integrations",Ic="plugins",Dp=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_]*)?$"),Xi="modern",ln="https://cdn.rudderlabs.com",ro="v3",Rc=`${ln}/${ro}/${Xi}/${an}`,Oc=`${ln}/${ro}/${Xi}/${Ic}`,Cc="https://api.rudderstack.com",Vt="v3",Np="xhr",Rs={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Hr={[Vt]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},xp={[Np]:"XhrQueue",beacon:"BeaconQueue"},$p="rsaRequest",Lp="rsaMetrics",Mp="Custom Device Mode",Fp={configUrl:Cc,loadIntegration:!0,sessions:{autoTrack:!0,timeout:Ss,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:Tc,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:_g,storage:{encryption:{version:Vt},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},Up=y(V(Fp)),z=Qs({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),ps=Qs({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Bp=10,Vp={userId:y(z.userId),userTraits:y(z.userTraits),anonymousId:y(z.anonymousId),groupId:y(z.groupId),groupTraits:y(z.groupTraits),initialReferrer:y(z.initialReferrer),initialReferringDomain:y(z.initialReferringDomain),sessionInfo:y(z.sessionInfo),authToken:y(z.authToken)},Gp={isOnline:y(!0),storage:{isLocalStorageAvailable:y(!1),isCookieStorageAvailable:y(!1),isSessionStorageAvailable:y(!1)},isBeaconAvailable:y(!1),isLegacyDOM:y(!1),isUaCHAvailable:y(!1),isCryptoAvailable:y(!1),isIE11:y(!1),isAdBlockerDetectionInProgress:y(!1),isAdBlocked:y(void 0),cspBlockedURLs:y([])},jp={isErrorReportingEnabled:y(!1),isMetricsReportingEnabled:y(!1),breadcrumbs:y([])},Hp=y(void 0),qp={activeDataplaneUrl:y(void 0),integrationsCDNPath:y(Rc),pluginsCDNPath:y(Oc),sourceConfigUrl:y(void 0),status:y(void 0),initialized:y(!1),logLevel:y(Sc),loaded:y(!1),readyCallbacks:y([]),writeKey:y(void 0),dataPlaneUrl:y(void 0),safeAnalyticsInstance:y(void 0)},zp={enabled:y(!1),initialized:y(!1),data:y({}),activeConsentManagerPluginName:y(void 0),preConsent:y({enabled:!1}),postConsent:y({}),resolutionStrategy:y("and"),provider:y(void 0),metadata:y(void 0)},Kp={retries:y(0),dropped:y(0),sent:y(0),queued:y(0),triggered:y(0),metricsServiceUrl:y(void 0)},Wp=()=>lg,Yp={app:y({name:Al,namespace:ag,version:Wi,installType:gc}),traits:y(null),library:y({name:Al,version:Wi,snippetVersion:globalThis.RudderSnippetVersion,variant:Wp()}),userAgent:y(null),device:y(null),network:y(null),os:y({name:"",version:""}),locale:y(null),screen:y({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":y(void 0),timezone:y(void 0)},Xp={configuredDestinations:y([]),activeDestinations:y([]),loadOnlyIntegrations:y({}),failedDestinations:y([]),loadIntegration:y(!0),initializedDestinations:y([]),clientDestinationsReady:y(!1),integrationsConfig:y({})},Jp={toBeProcessedArray:y([]),readyCallbacksArray:y([])},Qp={ready:y(!1),loadedPlugins:y([]),failedPlugins:y([]),pluginsToLoadFromConfig:y([]),activePlugins:y([]),totalPluginsToLoad:y(0)},Zp={encryptionPluginName:y(void 0),migrate:y(!1),type:y(void 0),cookie:y(void 0),entries:y({}),trulyAnonymousTracking:y(!1)},ev={isEnabledServerSideCookies:y(!1),dataServiceUrl:y(void 0)},tv={eventsQueuePluginName:y(void 0),deliveryEnabled:y(!0)},iv={enabled:y(!1),pageLifecycle:{enabled:y(!1),pageViewId:y(void 0),pageLoadedTimestamp:y(void 0)}},rv={capabilities:Gp,consents:zp,context:Yp,eventBuffer:Jp,lifecycle:qp,loadOptions:Up,metrics:Kp,nativeDestinations:Xp,plugins:Qp,reporting:jp,session:Vp,source:Hp,storage:Zp,serverCookies:ev,dataPlaneEvents:tv,autoTrack:iv},d={...V(rv)};qr={exports:{}},zr={exports:{}},nv=zr.exports;ov=qr.exports;lv=av(),cv=Pc(lv),Dc="global code",uv=i=>W(i)&&/^global code$/i.test(i)?Dc:i,dv=i=>{let e={file:i.fileName,method:uv(i.functionName),lineNumber:i.lineNumber,columnNumber:i.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Dc),e},Ul=i=>ee(i)?i:"";Nc=(i,e)=>{let t;return Js(i)&&ee(sn(i))?t=i:(e.warn(Gg(Hi,Xe(i))),t=void 0),t},hv=(i,e)=>{try{let t=cv.parse(i);return Bl(i.name,i.message,e,t)}catch{return Bl(i.name,i.message,e,[])}},Vl=(i,e)=>{try{return JSON.parse(i||"")}catch(t){let r=to(t,"Failed to parse response data");e(r)}},Kr="The request failed",fv=[/Failed to fetch dynamically imported module: .*/],gv=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],pv=[new RegExp(`${Kr}.*`),/A script with the id .* is already loaded\./],vv=[...fv,...gv],_v="integrations",mv="sdk",yv=mv,bv={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Gl=(i,e,t)=>{let r=ge(bv,e||{});return t&&(r.headers=ge(r.headers,{Authorization:t})),r.url=i,r},jl=(i,e=pg,t)=>new Promise((r,n)=>{let s;if(i.sendRawData===!0)s=i.data;else if(s=Xe(i.data,!1,[],t),De(s)){n({error:new Error(Lg),undefined:void 0,options:i});return}let o=new XMLHttpRequest,a=c=>{n({error:new Error(Qg(Kr,o.status,o.statusText,i.url,o.responseText)),xhr:o,options:i})},l=c=>{n({error:new Error(Zg(Kr,c,i.url)),xhr:o,options:i,...c?.type==="timeout"?{timedOut:!0}:{}})};o.ontimeout=l,o.onerror=l,o.onload=()=>{o.status>=200&&o.status<400?r({response:o.responseText,xhr:o,options:i}):a()},o.open(i.method,i.url,!0),i.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(i.headers).forEach(c=>{i.headers[c]&&o.setRequestHeader(c,i.headers[c])});try{o.send(s)}catch(c){n({error:to(c,ep(Kr,i.url)),xhr:o,options:i})}}),Os=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:t,options:r,timeout:n,isRawResponse:s}=e;try{let o=await jl(Gl(t,r,this.basicAuthHeader),n,this.logger);return{data:s?o.response:Vl(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:t,url:r,options:n,timeout:s,isRawResponse:o}=e,a=!I(t);jl(Gl(r,n,this.basicAuthHeader),s,this.logger).then(l=>{a||t(o?l.response:Vl(l.response,this.onError),l)}).catch(l=>{a||t(void 0,l)})}onError(e,t){this.errorHandler?.onError({error:e,context:Gf,groupingHash:t})}setAuthHeader(e,t=!1){let r=t?e:Uf(`${e}:`);this.basicAuthHeader=`Basic ${r}`}resetAuthHeader(){this.basicAuthHeader=void 0}},xc=new Os(ft),Ev="1",kv=()=>["rsa"],Sv=["www.test-host.com","localhost","127.0.0.1","[::1]"],wv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],Av="RudderStack JavaScript SDK",Tv="git+https://github.com/rudderlabs/rudder-sdk-js.git",Iv="js",$c=i=>{d.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(d.lifecycle.sourceConfigUrl.value),t=`${e.origin}${e.pathname}?view=ad`;i.getAsyncData({url:t,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(r,n)=>{d.capabilities.isAdBlockerDetectionInProgress.value=!1,d.capabilities.isAdBlocked.value=n?.error!==void 0||n?.xhr?.responseURL!==t}})}catch(e){throw d.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},Rv=(i,e)=>{switch(e){case ct.UNHANDLEDEXCEPTION:{let{error:t}=i;return t||i}case ct.UNHANDLEDREJECTION:return i.reason;case ct.HANDLEDEXCEPTION:default:return i}},Ov=i=>({type:"manual",name:i,timestamp:new Date,metaData:{}}),Cv=(i=()=>window.location.hostname)=>{let e=i();return!e||e&&Sv.includes(e)?"development":"production"},Pv=i=>{let e=Xe(i,!1,wv);return e!==null?JSON.parse(e):{}},Dv=()=>globalThis.location.href.split("?")[0],Nv=(i,e,t,r)=>({id:`${i.value?.id??t.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${r.pageLifecycle.pageViewId.value??"NA"}`,name:i.value?.name??"NA"}),xv=(i,e)=>({locale:i.value??"NA",userAgent:e.value??"NA",time:new Date}),$v=(i,e,t,r)=>{let{context:n,lifecycle:s,session:o,source:a,reporting:l,autoTrack:c}=t,{app:u,locale:h,userAgent:g,timezone:f,screen:p,library:v}=n;return{payloadVersion:"5",notifier:{name:Av,version:u.value.version,url:Tv},events:[{exceptions:[V(i)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:u.value.version,releaseStage:Cv(),type:u.value.installType},device:xv(h,g),request:{url:Dv(),clientIp:"[NOT COLLECTED]"},breadcrumbs:V(l.breadcrumbs.value),context:i.message,groupingHash:r,metaData:{app:{snippetVersion:v.value.snippetVersion},device:{...p.value,timezone:f.value},...Pv(t)},user:Nv(a,o,s,c)}]}},Lv=(i,e,t)=>{if(me(i.capabilities.isAdBlocked.value)){i.capabilities.isAdBlockerDetectionInProgress.value===!1&&$c(e);let r=it(()=>{W(i.capabilities.isAdBlocked.value)&&(t(i.capabilities.isAdBlocked.value===!1),r())})}else t(i.capabilities.isAdBlocked.value===!1)},Mv=(i,e,t)=>{let r=i.message;return new Promise(n=>{if(vv.some(s=>s.test(r))){let s=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(r)?.[0];ee(s)?s.startsWith(ln)?e.capabilities.cspBlockedURLs.value.includes(s)?n(!1):Lv(e,t,n):n(!1):n(!0)}else n(!pv.some(s=>s.test(r)))})},Lc=i=>i?i.split("/").at(-2):void 0,Mc=i=>{let e=i.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},Fv=i=>{let e=Mc(i);if(!e)return!1;let t=e.substring(e.lastIndexOf("/")+1);return Lc(e)===an||kv().some(n=>t.startsWith(n)&&t.endsWith(".js"))},Uv=(i,e)=>{if(e)return e;let t=Mc(i);return Lc(t)===an?_v:yv},Bv=(i,e,t)=>{let r={version:Ev,message_id:nn(),source:{name:Iv,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:t},errors:i};return Xe(r)},Vv=(i,e,t)=>{let r;if(!W(i))r=e;else if(ee(i))r=i;else{let n=Nc(i,t);W(n)?r=n.message:r=e}return r},Cs=class{constructor(e,t){ie(this,"initialized",!1);this.httpClient=e,this.logger=t}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Hi,errorType:ct.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Hi,errorType:ct.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let t=ee(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&t.startsWith(ln)&&!d.capabilities.cspBlockedURLs.value.includes(t)&&(d.capabilities.cspBlockedURLs.value=[...d.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{let{error:t,context:r,customMessage:n,groupingHash:s,category:o}=e,a=e.errorType??ct.HANDLEDEXCEPTION,l=Rv(t,a),c=Nc(l,this.logger);if(me(c))return;let u=n?`${n} - `:"",h=`${r}${$}${u}`,g=hv(c,h),p=sn(c).includes(jr);if(!p&&!Fv(g)&&a!==ct.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await Mv(g,d,this.httpClient)){let _={severity:"error",unhandled:a!==ct.HANDLEDEXCEPTION,severityReason:{type:a}},b=Vv(s,g.message,this.logger),E=$v(g,_,d,b),D=Uv(g,o);this.httpClient.getAsyncData({url:d.metrics.metricsServiceUrl.value,options:{method:"POST",data:Bv(E,d,D),sendRawData:!0},isRawResponse:!0})}(a===ct.HANDLEDEXCEPTION||p)&&this.logger.error(g.message)}catch(t){this.logger.error(jg(Hi),t)}}leaveBreadcrumb(e){try{d.reporting.breadcrumbs.value=[...d.reporting.breadcrumbs.value,Ov(e)]}catch(t){this.onError({error:t,context:Hi,customMessage:xl,groupingHash:xl})}}},Fc=new Cs(xc,ft),Ps=class{constructor(e,t={}){ie(this,"plugins",[]);ie(this,"byName",{});ie(this,"cache",{});ie(this,"config",{throws:!0});this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){let n=Hg(ni);if(this.config.throws)throw new Error(n);this.logger.error(n,e);return}if(this.byName[e.name]){let n=qg(ni,e.name);if(this.config.throws)throw new Error(n);this.logger.error(n);return}this.cache={},this.plugins=this.plugins.slice();let r=this.plugins.length;this.plugins.forEach((n,s)=>{n.deps?.includes(e.name)&&(r=Math.min(r,s))}),this.plugins.splice(r,0,e),this.byName[e.name]=e,I(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let n=zg(ni,e);if(this.config.throws)throw new Error(n);this.logger.error(n);return}let r=this.plugins.indexOf(t);if(r===-1){let n=Kg(ni,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(r,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(r=>{if(r.deps?.some(n=>!this.byName[n])){let n=r.deps.filter(s=>!this.byName[s]);return this.logger.error(Wg(ni,r.name,n)),!1}return t==="."?!0:Nf(r,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...r){let n=e;if(!n)throw new Error(Mg);let s=n.startsWith("!"),o=this.config.throws??n.endsWith("!");if(n=n.replace(/(^!|!$)/g,""),!n)throw new Error(Fg);let a=n.split(".");a.pop();let l=a.join(".");return(t?this.getPlugins(n):[this.getPlugins(n)[0]]).map(u=>{let h=Es(u,n);if(!I(h)||s)return h;try{return h.apply(Es(u,l),r)}catch(g){if(o)throw g;this.logger.error(Yg(ni,n,u.name),g)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}},Gv=new Ps(ft,{throws:!0}),jv=i=>i.config.connectionMode!=="cloud"||i.config.useNativeSDKToSend===!0||i.config.useNativeSDK===!0,Hv=i=>i.config.connectionMode==="hybrid"||i.config.useNativeSDKToSend===!0,Hl=i=>i.filter(jv),qv=(i,e)=>`${i.replaceAll(" ","-")}___${e}`,Uc=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],zv=["Bugsnag","ErrorReporting"],Kv={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"}};Wv=i=>Bc({},(globalThis.__federation_shared__||{}).default||{});Xv=i=>{switch(i){case"BeaconQueue":return()=>Ce("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>Oe(e,!0));case"CustomConsentManager":return()=>Ce("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>Oe(e,!0));case"DeviceModeDestinations":return()=>Ce("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>Oe(e,!0));case"DeviceModeTransformation":return()=>Ce("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>Oe(e,!0));case"ExternalAnonymousId":return()=>Ce("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>Oe(e,!0));case"GoogleLinker":return()=>Ce("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>Oe(e,!0));case"KetchConsentManager":return()=>Ce("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>Oe(e,!0));case"IubendaConsentManager":return()=>Ce("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>Oe(e,!0));case"NativeDestinationQueue":return()=>Ce("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>Oe(e,!0));case"OneTrustConsentManager":return()=>Ce("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>Oe(e,!0));case"StorageEncryption":return()=>Ce("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>Oe(e,!0));case"StorageEncryptionLegacy":return()=>Ce("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>Oe(e,!0));case"StorageMigrator":return()=>Ce("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>Oe(e,!0));case"XhrQueue":return()=>Ce("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>Oe(e,!0));default:return}},Jv=i=>{let e={};return i.forEach(t=>{if(Uc.includes(t)){let r=Xv(t);r&&(e[t]=r)}}),e},Vc=()=>({}),Qv=()=>({}),Zv=i=>Jv?.(i)||{},vs={...Vc(),...Qv()},e_=i=>({...Zv(i)}),Ds=class{constructor(e,t,r){this.engine=e,this.errorHandler=t,this.logger=r,this.onError=this.onError.bind(this)}init(){d.lifecycle.status.value="pluginsLoading",Yi("pluginsCDNPath",d.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){it(()=>{(d.plugins.activePlugins.value.length===0||d.plugins.loadedPlugins.value.length+d.plugins.failedPlugins.value.length===d.plugins.totalPluginsToLoad.value)&&ke(()=>{d.plugins.ready.value=!0,d.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=d.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(n=>zv.includes(n)?(this.logger.warn(Ap(Vi,n)),!1):!0);let t=[{configurationStatus:()=>W(d.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:d.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(xp),shouldAddMissingPlugins:!0},{configurationStatus:()=>Hl(d.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Hl(d.nativeDestinations.configuredDestinations.value).some(n=>n.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>W(d.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:d.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Rs)},{configurationStatus:()=>W(d.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:d.storage.encryptionPluginName.value,supportedPlugins:Object.values(Hr)},{configurationStatus:()=>d.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],r=!1;return t.forEach(n=>{n.configurationStatus()?(e=e.filter(n.activePluginName?s=>!(s!==n.activePluginName&&n.supportedPlugins.includes(s)):s=>W(s)),this.addMissingPlugins(n,r,e)):e=e.filter(n.basePlugins!==void 0?s=>!(n.basePlugins.includes(s)||n.supportedPlugins.includes(s)):s=>!n.supportedPlugins.includes(s))}),[...Object.keys(Vc()),...e]}addMissingPlugins(e,t,r){let n=e.shouldAddMissingPlugins||t,s;e.activePluginName?s=[...e.basePlugins||[],e.activePluginName]:s=[...e.supportedPlugins];let o=s.filter(a=>!r.includes(a));o.length>0&&(n&&r.push(...o),this.logger.warn(Tp(Vi,e.configurationStatusStr,o,n)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(vs),...Uc],r=[],n=[];e.forEach(s=>{t.includes(s)?r.push(s):n.push(s)}),n.length>0&&this.logger.warn(Op(Vi,n)),ke(()=>{d.plugins.totalPluginsToLoad.value=e.length,d.plugins.activePlugins.value=r,d.plugins.failedPlugins.value=n})}registerLocalPlugins(){let e=[];Object.entries(vs).forEach(([t,r])=>{d.plugins.activePlugins.value.includes(t)&&(I(r)?this.register([r()]):e.push(t))}),e.length>0&&(d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,...e],this.logger.error(Cp(Vi,e)))}registerRemotePlugins(){let e=e_(d.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async t=>{await e[t]().then(r=>this.register([r.default()])).catch(r=>{d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,t],this.onError(r,`Failed to load plugin "${t}"`,r)})})).catch(t=>{this.onError(t)})}invokeMultiple(e,...t){try{return this.engine.invokeMultiple(e,...t)}catch(r){return this.onError(r,e),[]}}invokeSingle(e,...t){try{return this.engine.invokeSingle(e,...t)}catch(r){return this.onError(r,e),null}}register(e){e.forEach(t=>{try{this.engine.register(t,d)}catch(r){d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,t.name],this.onError(r,`Failed to register plugin "${t.name}"`)}})}unregisterLocalPlugins(){Object.keys(vs).forEach(e=>{try{this.engine.unregister(e)}catch(t){this.onError(t,`Failed to unregister plugin "${e}"`)}})}onError(e,t,r){this.errorHandler.onError({error:e,context:Vi,customMessage:t,groupingHash:r})}},Pe="cookieStorage",Fe="localStorage",je="sessionStorage",tt="memoryStorage",Ht="none",t_="test_rudder_cookie",i_="test_rudder_ls",r_="test_rudder_ss",n_="rl_user_id",s_="rl_trait",o_="rl_anonymous_id",a_="rl_group_id",l_="rl_group_trait",c_="rl_page_init_referrer",u_="rl_page_init_referring_domain",d_="rl_session",h_="rl_auth_token",si={userId:n_,userTraits:s_,anonymousId:o_,groupId:a_,groupTraits:l_,initialReferrer:c_,initialReferringDomain:u_,sessionInfo:d_,authToken:h_},f_="__tld__",Gc="clientDataInCookie",jc="clientDataInLocalStorage",g_="clientDataInMemory",Hc="clientDataInSessionStorage",qc=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],oi={[Pe]:Gc,[Fe]:jc,[tt]:g_,[je]:Hc},ql=(i,e)=>{try{return encodeURIComponent(i)}catch(t){e?.error(tg,t);return}},zl=i=>{try{return decodeURIComponent(i)}catch{return}},p_=i=>{let e={},t=i.split(/\s*;\s*/),r;return t[0]&&t.forEach(n=>{r=n.split("=");let s=r[0]?zl(r[0]):void 0;s&&(e[s]=r[1]?zl(r[1]):void 0)}),e},v_=(i,e,t,r)=>{let n={...t||{}},s=`${ql(i,r)}=${ql(e,r)}`;De(e)&&(n.maxage=-1),n.maxage&&(n.expires=new Date(+new Date+n.maxage)),n.path&&(s+=`; path=${n.path}`),n.domain&&(s+=`; domain=${n.domain}`),n.expires&&(s+=`; expires=${n.expires.toUTCString()}`),n.samesite&&(s+=`; samesite=${n.samesite}`),n.secure&&(s+="; secure"),globalThis.document.cookie=s},Ns=()=>{let i=globalThis.document.cookie;return p_(i)},__=i=>Ns()[i],ut=function(i,e,t,r){switch(arguments.length){case 4:case 3:case 2:return v_(i,e,t,r);case 1:return i?__(i):Ns();default:return Ns()}},m_=i=>{let e=document.createElement("a");return e.href=i,e.hostname},y_=i=>{let t=(typeof globalThis.URL!="function"?m_(i):new URL(i).hostname)?.split(".")??[],r=t[t.length-1],n=[];if(t.length===4&&r&&r===parseInt(r,10).toString())return n;if(t.length<=1)return t[0]&&t[0].indexOf("localhost")!==-1?["localhost"]:n;for(let s=t.length-2;s>=0;s-=1)n.push(t.slice(s).join("."));return n},b_=i=>{let e=y_(i);for(let t=0;t<e.length;t+=1){let r=e[t],n=f_,s={domain:`${r.indexOf("localhost")!==-1?"":"."}${r}`};try{if(ut(n,1,s),ut(n))return ut(n,null,s),r}catch{try{ut(n,null,s)}catch{}}}return""},E_=()=>{let i=`.${b_(globalThis.location.href)}`;return{maxage:vg,path:"/",domain:!i||i==="."?void 0:i,samesite:"Lax",enabled:!0}},k_=()=>({enabled:!0}),S_=()=>({enabled:!0}),w_=()=>({enabled:!0}),xs=class{constructor(e){ie(this,"isEnabled",!0);ie(this,"length",0);ie(this,"data",{});this.options=w_(),this.logger=e}configure(e){return this.options=ge(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,t){return this.data[e]=t,this.length=Object.keys(this.data).length,t}getItem(e){return e in this.data?this.data[e]:null}removeItem(e){return e in this.data&&delete this.data[e],this.length=Object.keys(this.data).length,null}clear(){this.data={},this.length=0}key(e){return this.keys()[e]??null}keys(){return Object.keys(this.data)}},tn=new xs(ft),Wr={exports:{}},A_=Wr.exports;I_=T_(),Ut=Pc(I_),zc=i=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],t=[22,1014];return i instanceof DOMException?e.includes(i.name)||t.includes(i.code):!1},ai=(i=Fe,e,t)=>{let r,n,s=ig(ks,i),o="unavailable",a=!0,l;try{switch(i){case tt:return!0;case Pe:r=e,n=t_;break;case Fe:r=e??globalThis.localStorage,n=i_;break;case je:r=e??globalThis.sessionStorage,n=r_;break;default:return!1}if(r&&(r.setItem(n,"true"),r.getItem(n)))return r.removeItem(n),!0;a=!1}catch(c){a=!1,l=c,zc(c)&&(o="full")}return a||t?.warn(`${s}${o}.`,l),!1},$s=class{constructor(e){ie(this,"isSupportAvailable",!0);ie(this,"isEnabled",!0);ie(this,"length",0);this.options=k_(),this.logger=e}configure(e){return this.options=ge(this.options,e??{}),this.isSupportAvailable=ai(Fe),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){Ut.set(e,t),this.length=Ut.len()}getItem(e){let t=Ut.get(e);return me(t)?null:t}removeItem(e){Ut.remove(e),this.length=Ut.len()}clear(){Ut.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Ut.keys()}},no=new $s(ft),Ls=class{constructor(e){ie(this,"isSupportAvailable",!0);ie(this,"isEnabled",!0);ie(this,"length",0);this.options=S_(),this.logger=e}configure(e){return this.options=ge(this.options,e??{}),this.isSupportAvailable=ai(je),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){this.store&&(this.store.setItem(e,t),this.length=this.store.length)}getItem(e){if(!this.store)return null;let t=this.store.getItem(e);return me(t)?null:t}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){this.store?.clear(),this.length=0}key(e){return this.store?.key(e)??null}keys(){let e=[];if(!this.store)return e;for(let t=0;t<this.store.length;t+=1){let r=this.store.key(t);r!==null&&e.push(r)}return e}},so=new Ls(ft),Ms=class{constructor(e){ie(this,"isSupportAvailable",!0);ie(this,"isEnabled",!0);ie(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=E_()),this.options=ge(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=ai(Pe,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){return ut(e,t,this.options,this.logger),this.length=Object.keys(ut()).length,!0}getItem(e){let t=ut(e);return me(t)?null:t}removeItem(e){let t=this.setItem(e,null);return this.length=Object.keys(ut()).length,t}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(ut())}},oo=new Ms(ft),Ye=i=>{switch(i){case Fe:return no;case je:return so;case tt:return tn;case Pe:return oo;default:return tn}},R_=i=>{let e=oo.configure(i);d.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},O_=i=>{no.configure(i)},C_=i=>{tn.configure(i)},P_=i=>{so.configure(i)},D_=(i={},e={},t={},r={})=>{R_(i),O_(e),C_(t),P_(r)},Fs=class{constructor(e,t,r){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=t,this.noKeyValidation=Object.keys(this.validKeys).length===0,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=r}createValidKey(e){let{name:t,id:r,validKeys:n,noKeyValidation:s,noCompoundKey:o}=this;if(s)return o?e:[t,r,e].join(".");let a;return Object.values(n).forEach(l=>{l===e&&(a=o?e:[t,r,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:r,noCompoundKey:n}=this,s=Ye(tt);Object.keys(r).forEach(o=>{let a=this.get(r[o]),l=n?o:[e,t,o].join(".");s.setItem(l,a),this.remove(o)}),this.engine=s}set(e,t){let r=this.createValidKey(e);if(r)try{this.engine.setItem(r,this.encrypt(Xe(t,!1,[],this.logger)))}catch(n){if(zc(n))this.logger.warn(mp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,t);else{let s=tp(e);this.onError(n,s,s)}}}get(e){let t=this.createValidKey(e),r;try{return!t||(r=this.decrypt(this.engine.getItem(t)),Je(r)||r==="")?null:JSON.parse(r)}catch(n){let s=d.storage.encryptionPluginName.value;if(!s||!d.plugins.failedPlugins.value.includes(s)){let a=ip(e);this.onError(n,a,a)}return null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return Je(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||typeof e!="string"||Mf(e)==="")return e;let n=`storage.${t}`,s=this.pluginsManager?this.pluginsManager.invokeSingle(n,e):e;return typeof s>"u"?e:s??""}onError(e,t,r){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:r})}},N_=(i,e)=>{let t;if(i.consents.preConsent.value.enabled)switch(i.consents.preConsent.value.storage?.strategy){case"none":t=Ht;break;case"session":e!=="sessionInfo"&&(t=Ht);break;case"anonymousId":e!=="anonymousId"&&(t=Ht);break}return t},Us=class{constructor(e,t,r){ie(this,"stores",{});ie(this,"isInitialized",!1);this.errorHandler=t,this.logger=r,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=d.loadOptions.value,t={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};D_(ji(ge(t.cookieStorageOptions??{},d.storage.cookie?.value??{})),ji(t.localStorageOptions),ji(t.inMemoryStorageOptions),ji(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[tt,Fe,Pe,je].forEach(t=>{Ye(t)?.isEnabled&&this.setStore({id:oi[t],name:oi[t],isEncrypted:!0,noCompoundKey:!0,type:t,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=d.storage.type.value,t=d.loadOptions.value.storage?.entries,r=d.consents.postConsent.value.storage;(W(r?.type)||W(r?.entries))&&(e=r?.type,t=r?.entries);let n=!0,s={};qc.forEach(o=>{let a=o,l=o,c=t?.[a]?.type,h=N_(d,o)??c??e??Is,g=this.getResolvedStorageTypeForEntry(h,o);g!==Ht&&(n=!1),s={...s,[o]:{type:g,key:si[l]}}}),ke(()=>{d.storage.type.value=e,d.storage.entries.value=s,d.storage.trulyAnonymousTracking.value=n})}getResolvedStorageTypeForEntry(e,t){let r=e;switch(e){case Fe:Ye(Fe)?.isEnabled||(r=tt);break;case je:Ye(je)?.isEnabled||(r=tt);break;case tt:case Ht:break;case Pe:default:Ye(Pe)?.isEnabled?r=Pe:Ye(Fe)?.isEnabled?r=Fe:Ye(je)?.isEnabled?r=je:r=tt;break}return r!==e&&this.logger.warn(yp(Bf,t,e,r)),r}setStore(e){let t=Ye(e.type);return this.stores[e.id]=new Fs(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},x_=i=>te(i)&&te(i.source)&&!Je(i.source.id)&&te(i.source.config)&&Array.isArray(i.source.destinations),$_=i=>typeof i=="string"&&wc.includes(i),Kc=i=>{let e=new URL(i),{host:t,protocol:r}=e,n=t.split("."),s;return n.length>2?s=`${n[n.length-2]}.${n[n.length-1]}`:s=t,{topDomain:s,protocol:r}},L_=i=>{let{topDomain:e,protocol:t}=Kc(i);return`${t}//${e}`},M_=(i,e)=>{let t=e?window.location.origin:L_(window.location.href),r=i.startsWith("/")?i.substring(1):i;return`${t}/${r}`},F_=i=>{let{topDomain:e}=Kc(window.location.href);return e===i},ci=i=>i?.endsWith("/")?ci(i.substring(0,i.length-1)):i,Bs=i=>{try{return new URL(i).host}catch{return null}},Wc=i=>Bs(i)??"",U_=i=>{let e={};try{let t=new URL(i),r="utm_";t.searchParams.forEach((n,s)=>{if(s.startsWith(r)){let o=s.substring(r.length);o==="campaign"&&(o="name"),e[o]=n}})}catch{}return e},B_=i=>{let e=i;try{let t=new URL(i);e=t.origin+t.pathname+t.search}catch{}return e},V_=i=>i.replace(/\/{2,}/g,"/"),ui=i=>{if(!ee(i))return!1;try{return I(globalThis.URL)&&new URL(i),Dp.test(i)}catch{return!1}},_s="none",ms="immediate",G_=i=>i?.statsCollection?.errors?.enabled===!0,j_=i=>i?.statsCollection?.metrics?.enabled===!0,H_=i=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(te(i)){let t=V(i);e.storage=t.storage,ht(t.integrations)&&(e.integrations=t.integrations),e.discardPreConsentEvents=t.discardPreConsentEvents===!0,e.sendPageEvent=t.sendPageEvent===!0,e.trackConsent=t.trackConsent===!0,ht(t.consentManagement)&&(e.consentManagement=ge(t.consentManagement,{enabled:d.consents.enabled.value}))}return e},Wl=i=>ht(i)||Array.isArray(i),q_=(i,e)=>{let{provider:t}=i,r=t?Rs[t]:void 0;return t&&!r&&(e.error(Vg(He,t,Rs)),t=void 0),{provider:t,consentManagerPluginName:r}},Yc=(i,e)=>{let t,r=[],n=[],s=!1,o,a=i?.enabled===!0;ht(i)&&a&&({provider:o,consentManagerPluginName:t}=q_(i,e),Wl(i.allowedConsentIds)&&(r=i.allowedConsentIds,s=!0),Wl(i.deniedConsentIds)&&(n=i.deniedConsentIds,s=!0));let l={allowedConsentIds:r,deniedConsentIds:n};return a=a&&!!t,{provider:o,consentManagerPluginName:t,initialized:s,enabled:a,consentsData:l}},z_=()=>{let i=document.querySelector("script[data-rsa-write-key]");if(i&&i.dataset.rsaWriteKey===d.lifecycle.writeKey.value)return i.src;let e=document.getElementsByTagName("script"),t=/(?:^|\/)rsa(\.min)?\.js$/;for(let r of e){let n=r.getAttribute("src");if(n&&t.test(n))return n}},K_=i=>{d.reporting.isErrorReportingEnabled.value=G_(i.source.config)&&!Wf(),d.reporting.isMetricsReportingEnabled.value=j_(i.source.config)},W_=i=>{let{useServerSideCookies:e,dataServiceEndpoint:t,storage:r,setCookieDomain:n,sameDomainCookiesOnly:s}=d.loadOptions.value,o=r?.cookie,a=!1,l;if(e){a=e;let c=o.domain??n,u=W(c)&&!F_(kl(c))||s,h=M_(t??$p,u);if(ui(h)){l=ci(h);let g=Bs(window.location.href),f=Bs(h);g!==f&&(o={...o,samesite:"None",secure:!0}),!s&&u&&f!==kl(c)&&(a=!1,i.warn(lp(He,c,f)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},Y_=i=>{let{storage:e}=d.loadOptions.value,t=e?.type;W(t)&&!$_(t)&&(i.warn(sp(He,t,Is)),t=Is);let r=e?.encryption?.version,n=r&&Hr[r];!me(r)&&me(n)?(i.warn(op(He,r,Hr,Vt)),r=Vt):me(r)&&(r=Vt);let s=e?.migrate,o=s&&r===Vt;s===!0&&o!==s&&i.warn(ap(He,r,Vt));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:c}=W_(i);ke(()=>{d.storage.type.value=t,d.storage.cookie.value=c,d.serverCookies.isEnabledServerSideCookies.value=a,d.serverCookies.dataServiceUrl.value=l,d.storage.encryptionPluginName.value=Hr[r],d.storage.migrate.value=o})},X_=i=>{let{provider:e,consentManagerPluginName:t,initialized:r,enabled:n,consentsData:s}=Yc(d.loadOptions.value.consentManagement,i),o=d.loadOptions.value.preConsent,a=o?.storage?.strategy??_s,l=["none","session","anonymousId"];W(a)&&!l.includes(a)&&(a=_s,i.warn(Sp(He,o?.storage?.strategy,_s)));let c=o?.events?.delivery??ms,u=["immediate","buffer"];W(c)&&!u.includes(c)&&(c=ms,i.warn(wp(He,o?.events?.delivery,ms))),ke(()=>{d.consents.activeConsentManagerPluginName.value=t,d.consents.initialized.value=r,d.consents.enabled.value=n,d.consents.data.value=s,d.consents.provider.value=e,d.consents.preConsent.value={enabled:d.loadOptions.value.preConsent?.enabled===!0&&r===!1&&n===!0,storage:{strategy:a},events:{delivery:c}}})},J_=i=>{let e=d.consents.resolutionStrategy.value,t;te(i.consentManagementMetadata)&&(d.consents.provider.value&&(e=i.consentManagementMetadata.providers.find(r=>r.provider===d.consents.provider.value)?.resolutionStrategy??d.consents.resolutionStrategy.value),t=i.consentManagementMetadata),d.consents.provider.value==="custom"&&(e=void 0),ke(()=>{d.consents.metadata.value=V(t),d.consents.resolutionStrategy.value=e})},Q_=i=>{if(d.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",t=e;d.loadOptions.value.useBeacon&&(d.capabilities.isBeaconAvailable.value?t="BeaconQueue":(t=e,i.warn(dp(He)))),ke(()=>{d.dataPlaneEvents.eventsQueuePluginName.value=t})}},Z_=(i,e,t,r,n)=>{let s=new URLSearchParams({p:gc,v:Wi,build:Xi,writeKey:e,lockIntegrationsVersion:t.toString(),lockPluginsVersion:r.toString()}),o=Cc,a=s,l="/sourceConfig/",c="";if(ui(i)){let u=new URL(i);ci(u.pathname).endsWith("/sourceConfig")||(u.pathname=`${ci(u.pathname)}/sourceConfig/`),u.pathname=V_(u.pathname),s.forEach((h,g)=>{u.searchParams.get(g)===null&&u.searchParams.set(g,h)}),o=u.origin,l=u.pathname,a=u.searchParams,c=u.hash}else n.warn(Ep(He,i));return`${o}${l}?${a}${c}`},em=i=>i.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:qv(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===Mp})),Xc=(i,e,t,r,n,s,o)=>{let a;if(s){if(!ui(s))return o.error(Bg(He,i,s)),null;a=ci(s)}else if(a=t,d.context.app.value.installType==="cdn"){let l=z_();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return n&&(a=a.replace(new RegExp(`/${ro}/${Xi}/${e}$`),`/${r}/${Xi}/${e}`)),a},tm=(i,e,t,r)=>Xc("integrations",an,Rc,i,e,t,r),im=(i,e,t,r)=>Xc("plugins",Ic,Oc,i,e,t,r),Vs=class{constructor(e,t,r){this.errorHandler=t,this.logger=r,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){it(()=>{this.logger.setMinLogLevel(d.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:t,lockIntegrationsVersion:r,lockPluginsVersion:n,destSDKBaseURL:s,pluginsSDKBaseURL:o,integrations:a}=d.loadOptions.value,l=tm(Wi,r,s,this.logger);if(De(l))return;let c;c=im(Wi,n,o,this.logger),c!==null&&(this.attachEffects(),d.lifecycle.activeDataplaneUrl.value=ci(d.lifecycle.dataPlaneUrl.value),Y_(this.logger),X_(this.logger),Q_(this.logger),ke(()=>{d.lifecycle.integrationsCDNPath.value=l,d.lifecycle.pluginsCDNPath.value=c,e&&(d.lifecycle.logLevel.value=e),d.lifecycle.sourceConfigUrl.value=Z_(t,d.lifecycle.writeKey.value,r,n,this.logger),d.metrics.metricsServiceUrl.value=`${d.lifecycle.activeDataplaneUrl.value}/${Lp}`,d.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,t,r){this.errorHandler.onError({error:e,context:He,customMessage:t,groupingHash:r})}processConfig(e,t){if(!W(e)){W(t)?this.onError(t.error,$l):this.onError(new Error($l));return}let r;try{ee(e)?r=JSON.parse(e):r=e}catch(s){this.onError(s,Nl);return}if(!x_(r)){this.onError(new Error(Nl));return}if(r.source.enabled===!1){this.logger.error($g);return}K_(r);let n=r.source.destinations.length>0?em(r.source.destinations):[];ke(()=>{d.source.value={config:r.source.config,name:r.source.name,id:r.source.id,workspaceId:r.source.workspaceId},d.nativeDestinations.configuredDestinations.value=n,d.plugins.pluginsToLoadFromConfig.value=d.loadOptions.value.plugins??[],J_(r),d.lifecycle.status.value="configured"})}getConfig(){let e=d.loadOptions.value.getSourceConfig;if(e){if(!I(e)){this.logger.error(Ug(He));return}let t=e();t instanceof Promise?t.then(r=>this.processConfig(r)).catch(r=>{this.onError(r,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:d.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},rm=()=>{let i=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return i?.[1]?i[1]:"NA"},Jc=(i=()=>document)=>i()?.referrer||"$direct",nm=(i=()=>document)=>{let t=i().getElementsByTagName("link"),r="";for(let n=0;t[n];n+=1){let s=t[n];if(s.getAttribute("rel")==="canonical"&&!r){r=s.getAttribute("href")??"";break}}return r},sm=(i=()=>globalThis.navigator)=>{let e=i();if(me(e))return null;let{userAgent:t}=e,{brave:r}=e;if(r&&Object.getPrototypeOf(r).isBrave){let n=t.match(/(chrome)\/([\w.]+)/i);n&&(t=`${t} Brave/${n[2]}`)}return t},om=(i=()=>globalThis.navigator)=>{let e=i();return me(e)?null:e.language??e.browserLanguage},Qc=(i=()=>globalThis.location,e=()=>document)=>{let t=i(),r=nm(e),n=t.pathname,{href:s}=t,o=s,{search:a}=t;if(r)try{let h=new URL(r);h.search===""?o=r+a:o=r,n=h.pathname}catch{}let l=B_(o),{title:c}=e(),u=Jc(e);return{path:n,referrer:u,referring_domain:Wc(u),search:a,title:c,url:l,tab_url:s}},am=(i,e="none")=>{e==="none"&&i(void 0),e==="default"&&i(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(t=>{i(t)}).catch(()=>{i()})},lm=()=>{let i=globalThis.document.createElement("div");return i.setAttribute("data-a-b","c"),i.dataset?i.dataset.aB==="c":!1},Gs={URL:()=>!I(globalThis.URL)||!I(globalThis.URLSearchParams),Promise:()=>!I(globalThis.Promise),"Number.isNaN":()=>!I(globalThis.Number.isNaN),"Number.isInteger":()=>!I(globalThis.Number.isInteger),"Array.from":()=>!I(globalThis.Array.from),"Array.prototype.find":()=>!I(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!I(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!I(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!I(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!I(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!I(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!I(globalThis.String.fromCodePoint),"Object.entries":()=>!I(globalThis.Object.entries),"Object.values":()=>!I(globalThis.Object.values),"Object.assign":()=>!I(globalThis.Object.assign),"Object.fromEntries":()=>!I(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!lm(),TextEncoder:()=>!I(globalThis.TextEncoder)||!I(globalThis.TextDecoder),requestAnimationFrame:()=>!I(globalThis.requestAnimationFrame)||!I(globalThis.cancelAnimationFrame),CustomEvent:()=>!I(globalThis.CustomEvent),"navigator.sendBeacon":()=>!I(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!I(globalThis.Uint8Array),Set:()=>!I(globalThis.Set),atob:()=>!I(globalThis.atob)},cm=()=>{let i=Object.keys(Gs),e=!1;for(let t=0;t<i.length;t++){let r=Gs[i[t]];if(I(r)&&r()){e=!0;break}}return e},um="https://polyfill-fastly.io/v3/polyfill.min.js",dm=`${um}?version=3.111.0&features=${Object.keys(Gs).join("%2C")}`,hm=10*1e3,Yl="rudderstackPolyfill",fm=()=>!Je(globalThis.crypto)&&I(globalThis.crypto.getRandomValues),Xl=()=>!Je(globalThis.navigator.userAgentData),gm=()=>!Je(globalThis.navigator.sendBeacon)&&I(globalThis.navigator.sendBeacon),Jl=()=>{let i={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return i={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},i},js=class{constructor(e,t,r){this.httpClient=e,this.errorHandler=t,this.logger=r,this.externalSrcLoader=new Zr(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){ke(()=>{d.capabilities.storage.isCookieStorageAvailable.value=ai(Pe,Ye(Pe),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=ai(Fe,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=ai(je,void 0,this.logger),d.capabilities.isBeaconAvailable.value=gm(),d.capabilities.isUaCHAvailable.value=Xl(),d.capabilities.isCryptoAvailable.value=fm(),d.capabilities.isIE11.value=uc(),d.capabilities.isOnline.value=globalThis.navigator.onLine,d.context.userAgent.value=sm(),d.context.locale.value=om(),d.context.screen.value=Jl(),d.context.timezone.value=rm(),Xl()&&am(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),it(()=>{d.loadOptions.value.sendAdblockPage===!0&&d.lifecycle.sourceConfigUrl.value!==void 0&&$c(this.httpClient)})}prepareBrowserCapabilities(){d.capabilities.isLegacyDOM.value=cm();let e=d.loadOptions.value.polyfillURL,t=dm;if(li(e)&&(ui(e)?t=e:this.logger.warn(Ip(ks,e))),d.loadOptions.value.polyfillIfRequired&&d.capabilities.isLegacyDOM.value&&ui(t)){let n=t!==d.loadOptions.value.polyfillURL;if(n){let s=`RS_polyfillCallback_${d.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[s]};globalThis[s]=o,t=`${t}&callback=${s}`}this.externalSrcLoader.loadJSFile({url:t,id:Yl,async:!0,timeout:hm,callback:s=>{s?n||this.onReady():this.onError(new Error(kp(Yl,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{d.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{d.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",yg(()=>{d.context.screen.value=Jl()},this))}onReady(){this.detectBrowserCapabilities(),d.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:ks,groupingHash:t})}},pm="web",vm=["integrations","anonymousId","originalTimestamp"],Ql=["library","consentManagement","userAgent","ua-ch","screen"],ys=["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"],Zc=i=>typeof i=="number"&&!Number.isNaN(i),_m=(i,e)=>e.toString().length>=i,rn=i=>Zc(i)&&i>=0&&Number.isInteger(i),Zl=10,eu=i=>{let{cutOff:e}=i,t=Date.now();return!!(e?.enabled&&e.expiresAt&&t>e.expiresAt)},ec=i=>!i.expiresAt||Date.now()>i.expiresAt||eu(i),mm=()=>Date.now(),ym=(i,e)=>!i||!rn(i)||!_m(Zl,i)?(e.warn(_p(Bt,i,Zl)),!1):!0,bm=i=>{if(i?.enabled)return i.expiresAt??(rn(i.duration)?Date.now()+i.duration:void 0)},Em=i=>{let{timeout:e,cutOff:t}=i,r=Date.now();return{id:r,expiresAt:r+e,timeout:e,autoTrack:!0,...t&&{cutOff:t}}},km=(i,e)=>({id:ym(i,e)?i:mm(),sessionStart:void 0,manualTrack:!0}),qi=i=>i===Pe||i===Fe||i===je||i===tt,Hs=()=>nn(),Sm=i=>{if(Df(i)){let{entries:e,...t}=ps;return{...t,entries:{...e,anonymousId:i}}}return te(i)&&te(i.entries)?ge(ps,i):{...ps}},wm=i=>{let e=Qc(),t={};return Object.keys(e).forEach(r=>{t[r]=i?.[r]||e[r]}),t.initial_referrer=i?.initial_referrer||d.session.initialReferrer.value,t.initial_referring_domain=i?.initial_referring_domain||d.session.initialReferringDomain.value,t},Am=(i,e)=>{let t=e?.page||{},r=i,n=Qc();return Object.keys(n).forEach(s=>{me(r[s])&&(r[s]=t[s]||n[s])}),me(r.initial_referrer)&&(r.initial_referrer=t.initial_referrer||d.session.initialReferrer.value),me(r.initial_referring_domain)&&(r.initial_referring_domain=t.initial_referring_domain||d.session.initialReferringDomain.value),r},bs=(i,e,t)=>{te(i)&&Object.keys(i).forEach(r=>{(ys.includes(r)||ys.includes(r.toLowerCase()))&&t.warn(cp(cc,r,e,ys))})},Tm=(i,e)=>{let{properties:t,traits:r,context:n}=i,{traits:s}=n;bs(t,"properties",e),bs(r,"traits",e),bs(s,"context.traits",e)},Im=(i,e)=>{e.anonymousId&&ee(e.anonymousId)&&(i.anonymousId=e.anonymousId),ht(e.integrations)&&(i.integrations=e.integrations),e.originalTimestamp&&ee(e.originalTimestamp)&&(i.originalTimestamp=e.originalTimestamp)},Rm=(i,e,t)=>{let r=i;return Object.keys(e).forEach(n=>{if(!vm.includes(n)&&!Ql.includes(n))if(n!=="context")r=ge(r,{[n]:e[n]});else if(!me(e[n])&&te(e[n])){let s={};Object.keys(e[n]).forEach(o=>{Ql.includes(o)||(s[o]=e[n][o])}),r=ge(r,{...s})}else t.warn(up(cc))}),r},Om=(i,e,t)=>{te(e)&&(Im(i,e),i.context=Rm(i.context,e,t))},Cm=i=>{let e;return d.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=d.consents.postConsent.value.integrations??d.nativeDestinations.loadOnlyIntegrations.value:i?e=i:e=Tc,V(e)},Gi=(i,e,t,r)=>{let n={channel:pm,context:{traits:V(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:V(d.consents.data.value.deniedConsentIds),allowedConsentIds:V(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:U_(globalThis.location.href),page:wm(t),timezone:d.context.timezone.value,...d.autoTrack.enabled.value&&{autoTrack:{...d.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:d.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:Xf(),messageId:nn(),userId:i.userId||d.session.userId.value};qi(d.storage.entries.value.anonymousId?.type)?n.anonymousId=d.session.anonymousId.value:n.anonymousId=Hs(),d.storage.trulyAnonymousTracking.value&&(n.context.trulyAnonymousTracking=!0),i.type==="identify"&&(n.context.traits=d.storage.entries.value.userTraits?.type!==Ht?V(d.session.userTraits.value):i.context.traits),i.type==="group"&&((i.groupId||d.session.groupId.value)&&(n.groupId=i.groupId||d.session.groupId.value),(i.traits||d.session.groupTraits.value)&&(n.traits=d.storage.entries.value.groupTraits?.type!==Ht?V(d.session.groupTraits.value):i.traits));let s=ge(i,n);return s.event===void 0&&(s.event=null),s.properties===void 0&&(s.properties=null),Om(s,e,r),Tm(s,r),s.integrations=Cm(s.integrations),s},qs=class{constructor(e){this.logger=e}generatePageEvent(e,t,r,n){let s=r??{};return s=Am(s,n),Gi({properties:s,name:t,category:e,type:"page"},n,s,this.logger)}generateTrackEvent(e,t,r){return Gi({properties:t,event:e,type:"track"},r,void 0,this.logger)}generateIdentifyEvent(e,t,r){return Gi({userId:e,type:"identify",context:{traits:t}},r,void 0,this.logger)}generateAliasEvent(e,t,r){let s=Gi({previousId:t,type:"alias"},r,void 0,this.logger);return s.userId=e??s.userId,s}generateGroupEvent(e,t,r){let n={type:"group"};return e&&(n.groupId=e),t&&(n.traits=t),Gi(n,r,void 0,this.logger)}create(e){let t;switch(e.type){case"page":t=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":t=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":t=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":t=this.generateAliasEvent(e.to,e.from,e.options);break;default:t=this.generateGroupEvent(e.groupId,e.traits,e.options);break}return t}},zs=class{constructor(e,t,r,n){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=r,this.logger=n,this.eventFactory=new qs(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let t=this.eventFactory.create(e);this.eventRepository.enqueue(t,e.callback)}},Ks=class{constructor(e,t,r,n,s){this.storeManager=t,this.pluginsManager=e,this.logger=s,this.errorHandler=n,this.httpClient=r,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:e,anonymousIdOptions:t}=d.loadOptions.value,r;li(e)&&typeof e=="string"&&(r=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(r??this.getAnonymousId(t)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),r=this.getSessionInfo()??z.sessionInfo;e={autoTrack:t.autoTrack&&r.manualTrack!==!0,timeout:t.timeout,manualTrack:r.manualTrack,expiresAt:r.expiresAt,id:r.id,sessionStart:r.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=z.sessionInfo:t.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:r.cutOff?.expiresAt})}else e=z.sessionInfo;d.session.sessionInfo.value=e,d.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(d.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),t=this.getInitialReferringDomain();if(e&&t)this.setInitialReferrer(e),this.setInitialReferringDomain(t);else{let r=e||Jc();this.setInitialReferrer(r),this.setInitialReferringDomain(Wc(r))}}isPersistenceEnabledForStorageEntry(e){return qi(d.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=d.storage.entries.value,t=[Pe,Fe,je];Object.keys(e).forEach(r=>{let n=r,s=e[n]?.type,o=this.storeManager?.getStore(oi[s]);o&&t.forEach(a=>{let l=this.storeManager?.getStore(oi[a]);if(l&&a!==s){let c=l.get(si[n]);Pf(c)&&o.set(si[n],c),l.remove(si[n])}})})}migrateStorageIfNeeded(e,t){if(!d.storage.migrate.value)return;let r=e??[];r.length===0&&[Gc,jc,Hc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&r.push(a)}),(t??Object.keys(si)).forEach(s=>{let o=si[s];r.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);Je(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=d.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let t,r=d.loadOptions.value.sessions?.timeout;rn(r)?t=r:(this.logger.warn(hp(Bt,r,Ss)),t=Ss),t===0&&(this.logger.warn(pp(Bt)),e=!1),t>0&&t<Cl&&this.logger.warn(vp(Bt,t,Cl));let n=this.getCutOffInfo(t);return{timeout:t,autoTrack:e,cutOff:n}}getCutOffInfo(e){let t=d.loadOptions.value.sessions.cutOff,r,n=!1;return t.enabled===!0&&(r=t.duration,n=!0,rn(r)?r<e&&(this.logger.warn(gp(Bt,r,e)),n=!1):(this.logger.warn(fp(Bt,r,Ol)),r=Ol)),{enabled:n,duration:r}}onError(e,t,r){this.errorHandler.onError({error:e,context:Bt,customMessage:t,groupingHash:r})}getEncryptedCookieData(e,t){let r=[];return e.forEach(n=>{let s=t?.encrypt(Xe(n.value,!1,[],this.logger));li(s)&&r.push({name:n.name,value:s})}),r}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:d.serverCookies.dataServiceUrl.value,options:{method:"POST",data:Xe({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:t})}setServerSideCookies(e,t,r){let n=Object.keys(e),s=()=>n.map(c=>({name:e[c].name,value:d.session[c].value})),o={};n.forEach(c=>{o[e[c].name]=r?.get(e[c].name)});let a=()=>{n.forEach(c=>{this.serverSideCookiesRequestInProgress[c]=!1})},l=()=>{s().forEach(c=>{t&&t(c.name,c.value)})};try{let c={};n.forEach(h=>{c[e[h].name]=d.session[h].value});let u=this.getEncryptedCookieData(s(),r);u.length>0?this.makeRequestToSetCookie(u,(h,g)=>{a(),g?.xhr?.status===200?s().forEach(f=>{let p=o[f.name],v=r?.get(f.name);Xe(c[f.name],!1,[])!==Xe(v,!1,[])&&(De(p)&&De(v)&&this.logger.error(np(f.name)),t&&t(f.name,f.value))}):(this.logger.error(rp(g?.xhr?.status)),l())}):(l(),a())}catch(c){this.onError(c,Ll,Ll),l(),a()}}syncValueToStorage(e){let t=d.storage.entries.value,r=t[e]?.type;if(qi(r)){let n=this.storeManager.getStore(oi[r]),s=t[e]?.key,o=d.session[e].value;o&&(ee(o)||ht(o))?d.serverCookies.isEnabledServerSideCookies.value&&r===Pe?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{let a={[e]:{name:s}};this.setServerSideCookies(a,(l,c)=>{n?.set(l,c)},n)},Bp)):n?.set(s,o):n?.remove(s)}}registerEffects(){qc.forEach(e=>{it(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let r=e;(!ee(e)||!r)&&(r=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!r&&t&&(r=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t)),r=r||Hs()):r=z.anonymousId,d.session.anonymousId.value=r}getAnonymousId(e){let t=d.storage.entries.value.anonymousId?.type;if(qi(t)){let r=d.session.anonymousId.value;(!r||r===z.anonymousId)&&(r=this.getEntryValue("anonymousId")),!r&&e&&(r=this.pluginsManager?.invokeSingle("storage.getAnonymousId",Ye,e)),d.session.anonymousId.value=r||Hs()}return d.session.anonymousId.value}getEntryValue(e){let t=d.storage.entries.value,r=t[e]?.type;if(qi(r)){let n=this.storeManager?.getStore(oi[r]);this.migrateStorageIfNeeded([n],[e]);let s=t[e]?.key;return n?.get(s)??null}return null}getExternalAnonymousIdByCookieName(e){let t=Ye(Pe);return t?.isEnabled?t.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()??z.sessionInfo;return e.autoTrack&&!ec(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??z.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:t,autoTrack:r,timeout:n,cutOff:s}=e.sessionInfo.value;if(r){let o={...z.sessionInfo,timeout:n};s&&(o.cutOff={enabled:s.enabled,duration:s.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){let{session:t}=d,r=Sm(e);ke(()=>{Object.keys(z).forEach(n=>{let s=n;if(r.entries[s]===!0)switch(n){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[s].value=z[s];break}})})}setUserId(e){d.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:z.userId}setUserTraits(e){d.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&te(e)?ge(d.session.userTraits.value??z.userTraits,e):z.userTraits}setGroupId(e){d.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:z.groupId}setGroupTraits(e){d.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&te(e)?ge(d.session.groupTraits.value??z.groupTraits,e):z.groupTraits}setInitialReferrer(e){d.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:z.initialReferrer}setInitialReferringDomain(e){d.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:z.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if(ec(e))t=Em(e);else{let r=Date.now(),n=e.timeout;t.expiresAt=r+n}if(eu(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){let r=bm(t.cutOff);t.cutOff.expiresAt=r}d.session.sessionInfo.value=t}start(e){d.session.sessionInfo.value=km(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){d.session.sessionInfo.value=z.sessionInfo}setAuthToken(e){d.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:z.authToken}},Pm=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],Dm=Pm,Nm=(i,e)=>{let t=V(e);return ee(t.setCookieDomain)||(t.setCookieDomain=void 0),["Strict","Lax","None"].includes(t.sameSiteCookie)||(t.sameSiteCookie=void 0),t.secureCookie=et(t.secureCookie,i.secureCookie),t.sameDomainCookiesOnly=et(t.sameDomainCookiesOnly,i.sameDomainCookiesOnly),["none","default","full"].includes(t.uaChTrackLevel)||(t.uaChTrackLevel=void 0),t.integrations=lt(t.integrations),Array.isArray(t.plugins)||(t.plugins=Dm),t.useGlobalIntegrationsConfigInEvents=et(t.useGlobalIntegrationsConfigInEvents,i.useGlobalIntegrationsConfigInEvents),t.bufferDataPlaneEventsUntilReady=et(t.bufferDataPlaneEventsUntilReady,i.bufferDataPlaneEventsUntilReady),t.sendAdblockPage=et(t.sendAdblockPage,i.sendAdblockPage),t.useServerSideCookies=et(t.useServerSideCookies,i.useServerSideCookies),ee(t.dataServiceEndpoint)||(t.dataServiceEndpoint=void 0),t.sendAdblockPageOptions=lt(t.sendAdblockPageOptions),t.loadIntegration=et(t.loadIntegration,i.loadIntegration),ht(t.storage)?(t.storage.migrate=et(t.storage.migrate,i.storage?.migrate),t.storage.cookie=lt(t.storage.cookie),t.storage.encryption=lt(t.storage.encryption),t.storage=Xr(t.storage)):t.storage=void 0,t.destinationsQueueOptions=lt(t.destinationsQueueOptions),t.queueOptions=lt(t.queueOptions),t.lockIntegrationsVersion=et(t.lockIntegrationsVersion,i.lockIntegrationsVersion),t.lockPluginsVersion=et(t.lockPluginsVersion,i.lockPluginsVersion),Zc(t.dataPlaneEventsBufferTimeout)||(t.dataPlaneEventsBufferTimeout=void 0),t.beaconQueueOptions=lt(t.beaconQueueOptions),t.preConsent=lt(t.preConsent),t.sourceConfigurationOverride=lt(t.sourceConfigurationOverride),ge(i,Xr(t))},tc="dataplaneEventsQueue",ic="destinationsEventsQueue",xm="transformEvent",$m=(i,e)=>Object.keys(i).filter(t=>i[t]!==!0||!e[t]).reduce((t,r)=>{let n=V(t);return n[r]=i[r],n},{}),Lm=(i,e)=>{let t=V(i),r=e.nativeDestinations.integrationsConfig.value,n=$m(i.integrations,r);return t.integrations=ge(r,n),t},Mm=i=>i.consents.preConsent.value.enabled&&i.consents.preConsent.value.events?.delivery==="buffer",Yr=(i,e,t,r)=>{if(W(i))if(I(i))try{i(...e)}catch(n){r.error(bp(t),n)}else r.error(Ac(t))},Ws=class{constructor(e,t,r,n,s){this.pluginsManager=e,this.errorHandler=n,this.httpClient=r,this.logger=s,this.storeManager=t}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${tc}.init`,d,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${xm}.init`,d,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${ic}.init`,d,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),it(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=Mm(d),t;it(()=>{let r=d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&d.nativeDestinations.clientDestinationsReady.value===!1;(d.nativeDestinations.activeDestinations.value.some(s=>Hv(s))===!1||r===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(t),this.dataplaneEventsQueue?.start())}),d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(t=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,t){let r=Lm(e,d);this.pluginsManager.invokeSingle(`${tc}.enqueue`,d,this.dataplaneEventsQueue,r,this.errorHandler,this.logger);let n=V(e);this.pluginsManager.invokeSingle(`${ic}.enqueue`,d,this.destinationsEventsQueue,n,this.errorHandler,this.logger);let s=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${eo}`;Yr(t,[r],s,this.logger)}},rc=i=>{let e=new CustomEvent(i,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},Fm=i=>ee(i)&&i.trim().length>0,Um=i=>ui(i),Ys=class{constructor(){this.preloadBuffer=new As,this.initialized=!1,this.errorHandler=Fc,this.logger=ft,this.externalSrcLoader=new Zr(this.logger),this.httpClient=xc,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new js(this.httpClient,this.errorHandler,this.logger)}load(e,t,r={}){if(!d.lifecycle.status.value){if(!Fm(e)){this.logger.error(Xg(Fr,e));return}if(!Um(t)){this.logger.error(Jg(Fr,t));return}ke(()=>{d.lifecycle.writeKey.value=V(e),d.lifecycle.dataPlaneUrl.value=V(t),d.loadOptions.value=Nm(d.loadOptions.value,r),d.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(d.loadOptions.value.logLevel??Sc),Yi("state",d,e),this.startLifecycle()}}startLifecycle(){it(()=>{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 t="Failed to load the SDK";this.errorHandler.onError({error:e,context:Fr,customMessage:t,groupingHash:t})}})}onBrowserCapabilitiesReady(){Sg(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(t=>this.preloadBuffer.enqueue(V(t)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&wg([...e],this)}}prepareInternalServices(){this.pluginsManager=new Ds(Gv,this.errorHandler,this.logger),this.storeManager=new Us(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Vs(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Ks(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Ws(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new zs(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(),ke(()=>{d.lifecycle.loaded.value=!0,d.lifecycle.status.value="loaded"}),this.initialized=!0;let e=d.loadOptions.value.onLoaded;Yr(e,[globalThis.rudderanalytics],Vf,this.logger),rc("RSA_Initialised")}onReady(){d.lifecycle.status.value="readyExecuted",d.eventBuffer.readyCallbacksArray.value.forEach(e=>{Yr(e,[],fs,this.logger)}),rc("RSA_Ready")}processBufferedEvents(){let e=d.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let t=e.shift();if(d.eventBuffer.toBeProcessedArray.value=e,t){let r=t[0];I(this[r])&&this[r](...t.slice(1),!0)}e=d.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if(d.lifecycle.status.value==="destinationsLoading"||d.lifecycle.status.value==="destinationsReady")return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",d,this.pluginsManager,this.errorHandler,this.logger);let e=d.nativeDestinations.activeDestinations.value.length;if(e===0){d.lifecycle.status.value="destinationsReady";return}d.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",d,this.externalSrcLoader,this.errorHandler,this.logger),it(()=>{(e===0||d.nativeDestinations.initializedDestinations.value.length+d.nativeDestinations.failedDestinations.value.length===e)&&ke(()=>{d.lifecycle.status.value="destinationsReady",d.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){d.lifecycle.status.value!=="ready"&&ke(()=>{d.lifecycle.status.value="ready"})}ready(e,t=!1){let r="ready";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),!I(e)){this.logger.error(Ac(fs));return}d.lifecycle.status.value==="readyExecuted"?Yr(e,[],fs,this.logger):d.eventBuffer.readyCallbacksArray.value=[...d.eventBuffer.readyCallbacksArray.value,e]}page(e,t=!1){let r="page";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}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}),d.capabilities.isAdBlocked.value===!0&&e.category!==Tl&&this.page(Qr(Tl,cg,{path:ug},d.loadOptions.value.sendAdblockPageOptions))}track(e,t=!1){let r="track";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}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})}identify(e,t=!1){let r="identify";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}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(),De(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})}alias(e,t=!1){let r="alias";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1;let n=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:r,to:e.to,from:n,options:e.options,callback:e.callback})}group(e,t=!1){let r="group";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1,De(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})}reset(e,t=!1){let r="reset";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,t,r=!1){let n="setAnonymousId";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[n,e,t]];return}this.errorHandler.leaveBreadcrumb(`New ${n} invocation`),this.userSessionManager?.setAnonymousId(e,t)}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,t=!1){let r="startSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let t="endSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[t]];return}this.errorHandler.leaveBreadcrumb(`New ${t} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,t=!1){let r="consent";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),ke(()=>{d.consents.preConsent.value={...d.consents.preConsent.value,enabled:!1},d.consents.postConsent.value=H_(e);let{initialized:n,consentsData:s}=Yc(d.consents.postConsent.value.consentManagement,this.logger);d.consents.initialized.value=n,d.consents.data.value=s}),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(t)}sendTrackingEvents(e){if(d.consents.postConsent.value.trackConsent){let t=Zs(dg);e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(d.consents.postConsent.value.sendPageEvent){let t=Qr();e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,r=!1){let n="addCustomIntegration";if(r)this.errorHandler.leaveBreadcrumb(`New ${n} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,d,this.logger);else{if(d.lifecycle.loaded.value){this.logger.error(Pp(Fr,e));return}d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[n,e,t]]}}},Gt=class Gt{constructor(){ie(this,"analyticsInstances",{});ie(this,"defaultAnalyticsKey","");ie(this,"logger",ft);try{if(Gt.globalSingleton)return Gt.globalSingleton;Gt.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.getSessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),Gt.globalSingleton=this,d.autoTrack.pageLifecycle.pageViewId.value=nn(),d.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){ae(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(){Fc.init(),oo.configure(),no.configure(),so.configure(),tn.configure()}setDefaultInstanceKey(e){ee(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;return(!ee(t)||!t)&&(t=this.defaultAnalyticsKey),this.analyticsInstances[t]||(this.analyticsInstances[t]=new Ys),this.analyticsInstances[t]}catch(t){ae(t);return}}load(e,t,r){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(r);let n=vc(zi);kg(n),Yi(zi,V(n)),this.getAnalyticsInstance(e)?.load(e,t,G(r))}catch(n){ae(n)}}trackPageLifecycleEvents(e){let{autoTrack:t,useBeacon:r}=e??{},{enabled:n=!1,options:s={},pageLifecycle:o}=t??{},{events:a=[hs.UNLOADED],enabled:l=n,options:c=s}=o??{};d.autoTrack.pageLifecycle.enabled.value=l,d.autoTrack.enabled.value=n||l,l&&this.setupPageUnloadTracking(a,r,c)}setupPageUnloadTracking(e,t,r){(e.length===0||e.includes(hs.UNLOADED))&&(t===!0?Yf(n=>{if(n===!1&&d.lifecycle.loaded.value){let s=Date.now(),o=s-d.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(hs.UNLOADED,{timeOnPage:o},{...r,originalTimestamp:dc(new Date(s))})}},!0):this.logger.warn(Rp(jf)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=Eg(e);Yi(zi,V([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(G(e))}catch(t){ae(t)}}page(e,t,r,n,s){try{this.getAnalyticsInstance()?.page(Qr(G(e),G(t),G(r),G(n),G(s)))}catch(o){ae(o)}}track(e,t,r,n){try{this.getAnalyticsInstance()?.track(Zs(G(e),G(t),G(r),G(n)))}catch(s){ae(s)}}identify(e,t,r,n){try{this.getAnalyticsInstance()?.identify(oc(G(e),G(t),G(r),G(n)))}catch(s){ae(s)}}alias(e,t,r,n){try{this.getAnalyticsInstance()?.alias(ac(G(e),G(t),G(r),G(n)))}catch(s){ae(s)}}group(e,t,r,n){try{this.getAnalyticsInstance()?.group(lc(G(e),G(t),G(r),G(n)))}catch(s){ae(s)}}reset(e){try{this.getAnalyticsInstance()?.reset(G(e))}catch(t){ae(t)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(G(e))}catch(t){ae(t);return}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(G(e),G(t))}catch(r){ae(r)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){ae(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){ae(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){ae(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){ae(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(G(e))}catch(t){ae(t)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){ae(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){ae(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(G(e))}catch(t){ae(t)}}consent(e){try{this.getAnalyticsInstance()?.consent(G(e))}catch(t){ae(t)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(G(e),G(t))}catch(r){ae(r)}}};ie(Gt,"globalSingleton",null);di=Gt});var tu,iu,lo,co,ru,uo,nu,Ji,gi=Re(()=>{"use strict";tu="https://deriv.com/cdn-cgi/trace",iu="https://cdn.growthbook.io",lo="https://deriv-dataplane.rudderstack.com",co="https://ph.deriv.com",ru="https://us.posthog.com",uo=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],nu=["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"],Ji=()=>{if(typeof window>"u")return".deriv.com";let i=window.location.hostname;if(i==="localhost")return"";let e=uo.find(t=>i.includes(t));return e?`.${e}`:".deriv.com"}});function cn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)i[r]=t[r]}return i}function ho(i,e){function t(n,s,o){if(!(typeof document>"u")){o=cn({},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+"="+i.write(s,n)+a}}function r(n){if(!(typeof document>"u"||arguments.length&&!n)){for(var s=document.cookie?document.cookie.split("; "):[],o={},a=0;a<s.length;a++){var l=s[a].split("="),c=l.slice(1).join("=");try{var u=decodeURIComponent(l[0]);if(o[u]=i.read(c,u),n===u)break}catch{}}return n?o[n]:o}}return Object.create({set:t,get:r,remove:function(n,s){t(n,"",cn({},s,{expires:-1}))},withAttributes:function(n){return ho(this.converter,cn({},this.attributes,n))},withConverter:function(n){return ho(cn({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(i)}})}var Bm,Qe,fo=Re(()=>{"use strict";Bm={read:function(i){return i[0]==='"'&&(i=i.slice(1,-1)),i.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(i){return encodeURIComponent(i).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};Qe=ho(Bm,{path:"/"})});var rt,go,Qi,un,su,pi,ou,au,vi=Re(()=>{"use strict";fo();gi();rt=(i,e)=>(...t)=>{e()&&console.log(`[ANALYTIC]${i}`,...t)},go=i=>{let e=i.split("@")[1]?.toLowerCase();return e?nu.includes(e):!1},Qi=i=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i),un=null,su=async()=>{if(un)return un;let i=JSON.parse(Qe.get("website_status")||"{}")?.clients_country;return un=(async()=>{try{let e=await fetch(tu).catch(()=>null);if(!e)return i||"";let t=await e.text().catch(()=>"");return t?Object.fromEntries(t.split(`
|
|
14
|
+
`).map(n=>n.split("=",2))).loc?.toLowerCase()||i||"":i||""}catch{return i||""}})(),un},pi=i=>{if(i==null||typeof i!="object")return i;if(Array.isArray(i)){let r=[];for(let n=0;n<i.length;n++){let s=pi(i[n]);s!=null&&r.push(s)}return r.length?r:void 0}let e={},t=!1;for(let r in i){if(!Object.prototype.hasOwnProperty.call(i,r))continue;let n=pi(i[r]);n==null||n===""||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0||Array.isArray(n)&&n.length===0||(e[r]=n,t=!0)}return t?e:void 0},ou=(i,e)=>{for(let t in i){if(!Object.prototype.hasOwnProperty.call(i,t))continue;let r=i[t];r&&typeof r=="object"&&!Array.isArray(r)?ou(r,e):e[t]=r}},au=i=>{if(i==null||typeof i!="object"||Array.isArray(i))return i;let e={};return ou(i,e),e}});function vu(){return pu}function vo(i){let e=2166136261,t=i.length;for(let r=0;r<t;r++)e^=i.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Zi(i,e,t){return t===2?vo(vo(i+e)+"")%1e4/1e4:t===1?vo(e+i)%1e3/1e3:null}function Gm(i){return i<=0?[]:new Array(i).fill(1/i)}function gn(i,e){return i>=e[0]&&i<e[1]}function _u(i,e){let t=Zi("__"+e[0],i,1);return t===null?!1:t>=e[1]&&t<e[2]}function mu(i,e){for(let t=0;t<e.length;t++)if(gn(i,e[t]))return t;return-1}function mo(i){try{let e=i.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function pn(i,e){if(!e.length)return!1;let t=!1,r=!1;for(let n=0;n<e.length;n++){let s=qm(i,e[n].type,e[n].pattern);if(e[n].include===!1){if(s)return!1}else t=!0,s&&(r=!0)}return r||!t}function jm(i,e,t){try{let r=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(i)}catch{return!1}}function Hm(i,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[i.host,t.host,!1],[i.pathname,t.pathname,!0]];return t.hash&&r.push([i.hash,t.hash,!1]),t.searchParams.forEach((n,s)=>{r.push([i.searchParams.get(s)||"",n,!1])}),!r.some(n=>!jm(n[0],n[1],n[2]))}catch{return!1}}function qm(i,e,t){try{let r=new URL(i,"https://_");if(e==="regex"){let n=mo(t);return n?n.test(r.href)||n.test(r.href.substring(r.origin.length)):!1}else if(e==="simple")return Hm(r,t);return!1}catch{return!1}}function yu(i,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let r=Gm(i);t=t||r,t.length!==i&&(t=r);let n=t.reduce((o,a)=>a+o,0);(n<.99||n>1.01)&&(t=r);let s=0;return t.map(o=>{let a=s;return s+=o,[a,a+e*o]})}function bu(i,e,t){if(!e)return null;let r=e.split("?")[1];if(!r)return null;let n=r.replace(/#.*/,"").split("&").map(s=>s.split("=",2)).filter(([s])=>s===i).map(([,s])=>parseInt(s));return n.length>0&&n[0]>=0&&n[0]<t?n[0]:null}function Eu(i){try{return i()}catch(e){return console.error(e),!1}}async function zt(i,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||pu.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let r=await t.importKey("raw",_o(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[n,s]=i.split("."),o=await t.decrypt({name:"AES-CBC",iv:_o(n)},r,_o(s));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function er(i){return typeof i=="string"?i:JSON.stringify(i)}function Ue(i){typeof i=="number"&&(i=i+""),(!i||typeof i!="string")&&(i="0");let e=i.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}function ku(){let i;try{i="1.6.5"}catch{i=""}return i}function Su(i,e){let t,r;try{t=new URL(i),r=new URL(e)}catch(n){return console.error(`Unable to merge query strings: ${n}`),e}return t.searchParams.forEach((n,s)=>{r.searchParams.has(s)||r.searchParams.set(s,n)}),r.toString()}function gu(i){return typeof i=="object"&&i!==null}function vn(i){return i.urlPatterns&&i.variations.some(e=>gu(e)&&"urlRedirect"in e)?"redirect":i.variations.some(e=>gu(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function _n(i,e){return new Promise(t=>{let r=!1,n,s=o=>{r||(r=!0,n&&clearTimeout(n),t(o||null))};e&&(n=setTimeout(()=>s(),e)),i.then(o=>s(o)).catch(()=>s())})}var pu,_o,tr=Re(()=>{"use strict";pu={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};_o=i=>Uint8Array.from(atob(i),e=>e.charCodeAt(0))});function Tu(i){Object.assign(Se,i),Se.backgroundSync||wo()}async function Iu({instance:i,timeout:e,skipCache:t,allowStale:r,backgroundSync:n}){return n||(Se.backgroundSync=!1),Ym({instance:i,allowStale:r,timeout:e,skipCache:t})}function zm(i){let e=ir(i),t=yi.get(e)||new Set;t.add(i),yi.set(e,t)}function Ru(i){yi.forEach(e=>e.delete(i))}function Km(){bi.forEach(i=>{i&&(i.state="idle",ko(i))})}function Wm(){bi.forEach(i=>{i&&i.state==="idle"&&So(i)})}async function Au(){try{if(!nt.localStorage)return;await nt.localStorage.setItem(Se.cacheKey,JSON.stringify(Array.from(gt.entries())))}catch{}}async function Ym({instance:i,allowStale:e,timeout:t,skipCache:r}){let n=ir(i),s=bo(i),o=new Date,a=new Date(o.getTime()-Se.maxAge+Se.staleTTL);await Xm();let l=!Se.disableCache&&!r?gt.get(s):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&Ei.add(n),l.staleAt<o?yo(i):Eo(i),{data:l.data,success:!0,source:"cache"}):await _n(yo(i),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function ir(i){let[e,t]=i.getApiInfo();return`${e}||${t}`}function bo(i){let e=ir(i);if(!("isRemoteEval"in i)||!i.isRemoteEval())return e;let t=i.getAttributes(),r=i.getCacheKeyAttributes()||Object.keys(i.getAttributes()),n={};r.forEach(a=>{n[a]=t[a]});let s=i.getForcedVariations(),o=i.getUrl();return`${e}||${JSON.stringify({ca:n,fv:s,url:o})}`}async function Xm(){if(!wu){wu=!0;try{if(nt.localStorage){let i=await nt.localStorage.getItem(Se.cacheKey);if(!Se.disableCache&&i){let e=JSON.parse(i);e&&Array.isArray(e)&&e.forEach(([t,r])=>{gt.set(t,{...r,staleAt:new Date(r.staleAt)})}),Ou()}}}catch{}if(!Se.disableIdleStreams){let i=mi.startIdleListener();i&&(mi.stopIdleListener=i)}}}function Ou(){let i=Array.from(gt.entries()).map(([t,r])=>({key:t,staleAt:r.staleAt.getTime()})).sort((t,r)=>t.staleAt-r.staleAt),e=Math.min(Math.max(0,gt.size-Se.maxEntries),gt.size);for(let t=0;t<e;t++)gt.delete(i[t].key)}function Cu(i,e,t){let r=t.dateUpdated||"",n=new Date(Date.now()+Se.staleTTL),s=Se.disableCache?void 0:gt.get(e);if(s&&r&&s.version===r){s.staleAt=n,Au();return}Se.disableCache||(gt.set(e,{data:t,version:r,staleAt:n,sse:Ei.has(i)}),Ou()),Au();let o=yi.get(i);o&&o.forEach(a=>Jm(a,t))}async function Jm(i,e){await i.setPayload(e||i.getPayload())}async function yo(i){let{apiHost:e,apiRequestHeaders:t}=i.getApiHosts(),r=i.getClientKey(),n="isRemoteEval"in i&&i.isRemoteEval(),s=ir(i),o=bo(i),a=mn.get(o);return a||(a=(n?mi.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:i.getAttributes(),forcedVariations:i.getForcedVariations(),forcedFeatures:Array.from(i.getForcedFeatures().entries()),url:i.getUrl()},headers:t}):mi.fetchFeaturesCall({host:e,clientKey:r,headers:t})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&Ei.add(s),c.json()}).then(c=>(Cu(s,o,c),Eo(i),mn.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(mn.delete(o),{data:null,source:"error",success:!1,error:c})),mn.set(o,a)),a}function Eo(i,e=!1){let t=ir(i),r=bo(i),{streamingHost:n,streamingHostRequestHeaders:s}=i.getApiHosts(),o=i.getClientKey();if(e&&Ei.add(t),Se.backgroundSync&&Ei.has(t)&&nt.EventSource){if(bi.has(t))return;let a={src:null,host:n,clientKey:o,headers:s,cb:l=>{try{if(l.type==="features-updated"){let c=yi.get(t);c&&c.forEach(u=>{yo(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);Cu(t,r,c)}a.errors=0}catch{Pu(a)}},errors:0,state:"active"};bi.set(t,a),So(a)}}function Pu(i){if(i.state!=="idle"&&(i.errors++,i.errors>3||i.src&&i.src.readyState===2)){let e=Math.pow(3,i.errors-3)*(1e3+Math.random()*1e3);ko(i),setTimeout(()=>{["idle","active"].includes(i.state)||So(i)},Math.min(e,3e5))}}function ko(i){i.src&&(i.src.onopen=null,i.src.onerror=null,i.src.close(),i.src=null,i.state==="active"&&(i.state="disabled"))}function So(i){i.src=mi.eventSourceCall({host:i.host,clientKey:i.clientKey,headers:i.headers}),i.state="active",i.src.addEventListener("features",i.cb),i.src.addEventListener("features-updated",i.cb),i.src.onerror=()=>Pu(i),i.src.onopen=()=>{i.errors=0}}function Qm(i,e){ko(i),bi.delete(e)}function wo(){Ei.clear(),bi.forEach(Qm),yi.clear(),mi.stopIdleListener()}function yn(i,e){if(e.streaming){if(!i.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&Eo(i,!0),zm(i)}}var Se,nt,mi,yi,wu,gt,mn,bi,Ei,Du=Re(()=>{"use strict";tr();Se={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},nt=vu(),mi={fetchFeaturesCall:({host:i,clientKey:e,headers:t})=>nt.fetch(`${i}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:i,clientKey:e,payload:t,headers:r})=>{let n={method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(t)};return nt.fetch(`${i}/api/eval/${e}`,n)},eventSourceCall:({host:i,clientKey:e,headers:t})=>t?new nt.EventSource(`${i}/sub/${e}`,{headers:t}):new nt.EventSource(`${i}/sub/${e}`),startIdleListener:()=>{let i;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(i),Wm()):document.visibilityState==="hidden"&&(i=window.setTimeout(Km,Se.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(nt.localStorage=globalThis.localStorage)}catch{}yi=new Map,wu=!1,gt=new Map,mn=new Map,bi=new Map,Ei=new Set});function ey(i){return i==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[i]}}function wn(i){var e=Sn.get(i);return e||(e={element:i,attributes:{}},Sn.set(i,e)),e}function An(i,e,t,r,n){var s=t(i),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:i,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=t(i);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,n(o))}}),mutationRunner:n,setValue:r,getCurrentValue:t};return e==="position"&&i.parentNode?o.observer.observe(i.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(i,ey(e)),o}function Tn(i,e){var t=e.getCurrentValue(e.el);e.virtualValue=i,i&&typeof i!="string"?(!t||i.parentNode!==t.parentNode||i.insertBeforeNode!==t.insertBeforeNode)&&(e.isDirty=!0,Nu()):i!==t&&(e.isDirty=!0,Nu())}function ty(i){var e=i.originalValue;i.mutations.forEach(function(t){return e=t.mutate(e)}),Tn(py(e),i)}function iy(i){var e=new Set(i.originalValue.split(/\s+/).filter(Boolean));i.mutations.forEach(function(t){return t.mutate(e)}),Tn(Array.from(e).filter(Boolean).join(" "),i)}function ry(i){var e=i.originalValue;i.mutations.forEach(function(t){return e=t.mutate(e)}),Tn(e,i)}function ny(i){var e=i.parentSelector,t=i.insertBeforeSelector,r=document.querySelector(e);if(!r)return null;var n=t?document.querySelector(t):null;return t&&!n?null:{parentNode:r,insertBeforeNode:n}}function sy(i){var e=i.originalValue;i.mutations.forEach(function(t){var r=t.mutate(),n=ny(r);e=n||e}),Tn(e,i)}function $u(i){var e=wn(i);return e.html||(e.html=An(i,"html",oy,ay,ty)),e.html}function Lu(i){var e=wn(i);return e.position||(e.position=An(i,"position",ly,cy,sy)),e.position}function Mu(i){var e=wn(i);return e.classes||(e.classes=An(i,"class",dy,uy,iy)),e.classes}function Fu(i,e){var t=wn(i);return t.attributes[e]||(t.attributes[e]=An(i,e,hy(e),fy(e),ry)),t.attributes[e]}function gy(i,e){var t=Sn.get(i);if(t)if(e==="html"){var r,n;(r=t.html)==null||(n=r.observer)==null||n.disconnect(),delete t.html}else if(e==="class"){var s,o;(s=t.classes)==null||(o=s.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var c,u,h;(c=t.attributes)==null||(u=c[e])==null||(h=u.observer)==null||h.disconnect(),delete t.attributes[e]}}function py(i){return bn||(bn=document.createElement("div")),bn.innerHTML=i,bn.innerHTML}function En(i,e,t){if(t.isDirty){t.isDirty=!1;var r=t.virtualValue;t.mutations.length||gy(i,e),t.setValue(i,r)}}function vy(i,e){i.html&&En(e,"html",i.html),i.classes&&En(e,"class",i.classes),i.position&&En(e,"position",i.position),Object.keys(i.attributes).forEach(function(t){En(e,t,i.attributes[t])})}function Nu(){Sn.forEach(vy)}function _y(i,e){var t=null;i.kind==="html"?t=$u(e):i.kind==="class"?t=Mu(e):i.kind==="attribute"?t=Fu(e,i.attribute):i.kind==="position"&&(t=Lu(e)),t&&(t.mutations.push(i),t.mutationRunner(t))}function my(i,e){var t=null;if(i.kind==="html"?t=$u(e):i.kind==="class"?t=Mu(e):i.kind==="attribute"?t=Fu(e,i.attribute):i.kind==="position"&&(t=Lu(e)),!!t){var r=t.mutations.indexOf(i);r!==-1&&t.mutations.splice(r,1),t.mutationRunner(t)}}function Uu(i){if(!(i.kind==="position"&&i.elements.size===1)){var e=new Set(i.elements),t=document.querySelectorAll(i.selector);t.forEach(function(r){e.has(r)||(i.elements.add(r),_y(i,r))})}}function yy(i){i.elements.forEach(function(e){return my(i,e)}),i.elements.clear(),Ro.delete(i)}function xu(){Ro.forEach(Uu)}function by(){typeof document>"u"||(Ao||(Ao=new MutationObserver(function(){xu()})),xu(),Ao.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function In(i){return typeof document>"u"?Io:(Ro.add(i),Uu(i),{revert:function(){yy(i)}})}function To(i,e){return In({kind:"html",elements:new Set,mutate:e,selector:i})}function Bu(i,e){return In({kind:"position",elements:new Set,mutate:e,selector:i})}function rr(i,e){return In({kind:"class",elements:new Set,mutate:e,selector:i})}function kn(i,e,t){return Zm.test(e)?e==="class"||e==="className"?rr(i,function(r){var n=t(Array.from(r).join(" "));r.clear(),n&&n.split(/\s+/g).filter(Boolean).forEach(function(s){return r.add(s)})}):In({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:i}):Io}function Ey(i){var e=i.selector,t=i.action,r=i.value,n=i.attribute,s=i.parentSelector,o=i.insertBeforeSelector;if(n==="html"){if(t==="append")return To(e,function(a){return a+(r??"")});if(t==="set")return To(e,function(){return r??""})}else if(n==="class"){if(t==="append")return rr(e,function(a){r&&a.add(r)});if(t==="remove")return rr(e,function(a){r&&a.delete(r)});if(t==="set")return rr(e,function(a){a.clear(),r&&a.add(r)})}else if(n==="position"){if(t==="set"&&s)return Bu(e,function(){return{insertBeforeSelector:o,parentSelector:s}})}else{if(t==="append")return kn(e,n,function(a){return a!==null?a+(r??""):r??""});if(t==="set")return kn(e,n,function(){return r??""});if(t==="remove")return kn(e,n,function(){return null})}return Io}var Zm,Io,Sn,Ro,oy,ay,ly,cy,uy,dy,hy,fy,bn,Ao,ky,Vu,Gu=Re(()=>{"use strict";Zm=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Io={revert:function(){}},Sn=new Map,Ro=new Set;oy=function(e){return e.innerHTML},ay=function(e,t){return e.innerHTML=t};ly=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},cy=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};uy=function(e,t){return t?e.className=t:e.removeAttribute("class")},dy=function(e){return e.className};hy=function(e){return function(t){var r;return(r=t.getAttribute(e))!=null?r:null}},fy=function(e){return function(t,r){return r!==null?t.setAttribute(e,r):t.removeAttribute(e)}};by();ky={html:To,classes:rr,attribute:kn,position:Bu,declarative:Ey},Vu=ky});function Ot(i,e,t){t=t||{};for(let[r,n]of Object.entries(e))switch(r){case"$or":if(!qu(i,n,t))return!1;break;case"$nor":if(qu(i,n,t))return!1;break;case"$and":if(!Iy(i,n,t))return!1;break;case"$not":if(Ot(i,n,t))return!1;break;default:if(!nr(n,Sy(i,r),t))return!1}return!0}function Sy(i,e){let t=e.split("."),r=i;for(let n=0;n<t.length;n++)if(r&&typeof r=="object"&&t[n]in r)r=r[t[n]];else return null;return r}function ju(i,e=!1){let t=`${i}${e?"/i":""}`;return Oo[t]||(Oo[t]=new RegExp(i.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Oo[t]}function nr(i,e,t,r=!1){if(typeof i=="string")return r?String(e).toLowerCase()===i.toLowerCase():e+""===i;if(typeof i=="number")return e*1===i;if(typeof i=="boolean")return e!==null&&!!e===i;if(i===null)return e===null;if(Array.isArray(i)||!zu(i))return JSON.stringify(e)===JSON.stringify(i);for(let n in i)if(!Ty(n,e,i[n],t))return!1;return!0}function zu(i){let e=Object.keys(i);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function wy(i){if(i===null)return"null";if(Array.isArray(i))return"array";let e=typeof i;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function Ay(i,e,t){if(!Array.isArray(i))return!1;let r=zu(e)?n=>nr(e,n,t):n=>Ot(n,e,t);for(let n=0;n<i.length;n++)if(i[n]&&r(i[n]))return!0;return!1}function ki(i,e,t=!1){if(t){let r=n=>typeof n=="string"?n.toLowerCase():n;return Array.isArray(i)?i.some(n=>e.some(s=>r(n)===r(s))):e.some(n=>r(i)===r(n))}return Array.isArray(i)?i.some(r=>e.includes(r)):e.includes(i)}function Hu(i,e,t,r=!1){if(!Array.isArray(i))return!1;for(let n=0;n<e.length;n++){let s=!1;for(let o=0;o<i.length;o++)if(nr(e[n],i[o],t,r)){s=!0;break}if(!s)return!1}return!0}function Ty(i,e,t,r){switch(i){case"$veq":return Ue(e)===Ue(t);case"$vne":return Ue(e)!==Ue(t);case"$vgt":return Ue(e)>Ue(t);case"$vgte":return Ue(e)>=Ue(t);case"$vlt":return Ue(e)<Ue(t);case"$vlte":return Ue(e)<=Ue(t);case"$eq":return e===t;case"$ne":return e!==t;case"$lt":return e<t;case"$lte":return e<=t;case"$gt":return e>t;case"$gte":return e>=t;case"$exists":return t?e!=null:e==null;case"$in":return Array.isArray(t)?ki(e,t):!1;case"$ini":return Array.isArray(t)?ki(e,t,!0):!1;case"$inGroup":return ki(e,r[t]||[]);case"$notInGroup":return!ki(e,r[t]||[]);case"$nin":return Array.isArray(t)?!ki(e,t):!1;case"$nini":return Array.isArray(t)?!ki(e,t,!0):!1;case"$not":return!nr(t,e,r);case"$size":return Array.isArray(e)?nr(t,e.length,r):!1;case"$elemMatch":return Ay(e,t,r);case"$all":return Array.isArray(t)?Hu(e,t,r):!1;case"$alli":return Array.isArray(t)?Hu(e,t,r,!0):!1;case"$regex":try{return ju(t).test(e)}catch{return!1}case"$regexi":try{return ju(t,!0).test(e)}catch{return!1}case"$type":return wy(e)===t;default:return console.error("Unknown operator: "+i),!1}}function qu(i,e,t){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(Ot(i,e[r],t))return!0;return!1}function Iy(i,e,t){for(let r=0;r<e.length;r++)if(!Ot(i,e[r],t))return!1;return!0}var Oo,Ku=Re(()=>{"use strict";tr();Oo={}});function Cy(i){let e=new Map;return i.global.forcedFeatureValues&&i.global.forcedFeatureValues.forEach((t,r)=>e.set(r,t)),i.user.forcedFeatureValues&&i.user.forcedFeatureValues.forEach((t,r)=>e.set(r,t)),e}function Py(i){return i.global.forcedVariations&&i.user.forcedVariations?{...i.global.forcedVariations,...i.user.forcedVariations}:i.global.forcedVariations?i.global.forcedVariations:i.user.forcedVariations?i.user.forcedVariations:{}}async function Si(i){try{await i()}catch{}}function Wu(i,e,t){if(i.user.trackedExperiments){let n=Cn(e,t);if(i.user.trackedExperiments.has(n))return[];i.user.trackedExperiments.add(n)}i.user.enableDevMode&&i.user.devLogs&&i.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let r=[];if(i.global.trackingCallback){let n=i.global.trackingCallback;r.push(Si(()=>n(e,t,i.user)))}if(i.user.trackingCallback){let n=i.user.trackingCallback;r.push(Si(()=>n(e,t)))}if(i.global.eventLogger){let n=i.global.eventLogger;r.push(Si(()=>n(Oy,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},i.user)))}return r}function Dy(i,e,t){if(i.user.trackedFeatureUsage){let r=JSON.stringify(t.value);if(i.user.trackedFeatureUsage[e]===r)return;i.user.trackedFeatureUsage[e]=r,i.user.enableDevMode&&i.user.devLogs&&i.user.devLogs.push({featureKey:e,result:t,timestamp:Date.now().toString(),logType:"feature"})}if(i.global.onFeatureUsage){let r=i.global.onFeatureUsage;Si(()=>r(e,t,i.user))}if(i.user.onFeatureUsage){let r=i.user.onFeatureUsage;Si(()=>r(e,t))}if(i.global.eventLogger){let r=i.global.eventLogger;Si(()=>r(Ry,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},i.user))}}function Rn(i,e){if(e.stack.evaluatedFeatures.has(i))return Ct(e,i,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(i),e.stack.id=i;let t=Cy(e);if(t.has(i))return Ct(e,i,t.get(i),"override");if(!e.global.features||!e.global.features[i])return Ct(e,i,null,"unknownFeature");let r=e.global.features[i];if(r.rules){let n=new Set(e.stack.evaluatedFeatures);e:for(let s of r.rules){if(s.parentConditions)for(let l of s.parentConditions){e.stack.evaluatedFeatures=new Set(n);let c=Rn(l.id,e);if(c.source==="cyclicPrerequisite")return Ct(e,i,null,"cyclicPrerequisite");let u={value:c.value};if(!Ot(u,l.condition||{})){if(l.gate)return Ct(e,i,null,"prerequisite");continue e}}if(s.filters&&Ju(s.filters,e))continue;if("force"in s){if(s.condition&&!Xu(s.condition,e)||!Ny(e,s.seed||i,s.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing?s.fallbackAttribute:void 0,s.range,s.coverage,s.hashVersion))continue;return s.tracks&&s.tracks.forEach(l=>{!Wu(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),Ct(e,i,s.force,"force",s.id)}if(!s.variations)continue;let o={variations:s.variations,key:s.key||i};"coverage"in s&&(o.coverage=s.coverage),s.weights&&(o.weights=s.weights),s.hashAttribute&&(o.hashAttribute=s.hashAttribute),s.fallbackAttribute&&(o.fallbackAttribute=s.fallbackAttribute),s.disableStickyBucketing&&(o.disableStickyBucketing=s.disableStickyBucketing),s.bucketVersion!==void 0&&(o.bucketVersion=s.bucketVersion),s.minBucketVersion!==void 0&&(o.minBucketVersion=s.minBucketVersion),s.namespace&&(o.namespace=s.namespace),s.meta&&(o.meta=s.meta),s.ranges&&(o.ranges=s.ranges),s.name&&(o.name=s.name),s.phase&&(o.phase=s.phase),s.seed&&(o.seed=s.seed),s.hashVersion&&(o.hashVersion=s.hashVersion),s.filters&&(o.filters=s.filters),s.condition&&(o.condition=s.condition);let{result:a}=On(o,i,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return Ct(e,i,a.value,"experiment",s.id,o,a)}}return Ct(e,i,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function On(i,e,t){let r=i.key,n=i.variations.length;if(n<2)return{result:re(t,i,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:re(t,i,-1,!1,e)};if(i=xy(i,t),i.urlPatterns&&!pn(t.user.url||"",i.urlPatterns))return{result:re(t,i,-1,!1,e)};let s=bu(r,t.user.url||"",n);if(s!==null)return{result:re(t,i,s,!1,e)};let o=Py(t);if(r in o){let _=o[r];return{result:re(t,i,_,!1,e)}}if(i.status==="draft"||i.active===!1)return{result:re(t,i,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Kt(t,i.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0);if(!l)return{result:re(t,i,-1,!1,e)};let c=-1,u=!1,h=!1;if(t.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing){let{variation:_,versionIsBlocked:b}=My({ctx:t,expKey:i.key,expBucketVersion:i.bucketVersion,expHashAttribute:i.hashAttribute,expFallbackAttribute:i.fallbackAttribute,expMinBucketVersion:i.minBucketVersion,expMeta:i.meta});u=_>=0,c=_,h=!!b}if(!u){if(i.filters){if(Ju(i.filters,t))return{result:re(t,i,-1,!1,e)}}else if(i.namespace&&!_u(l,i.namespace))return{result:re(t,i,-1,!1,e)};if(i.include&&!Eu(i.include))return{result:re(t,i,-1,!1,e)};if(i.condition&&!Xu(i.condition,t))return{result:re(t,i,-1,!1,e)};if(i.parentConditions){let _=new Set(t.stack.evaluatedFeatures);for(let b of i.parentConditions){t.stack.evaluatedFeatures=new Set(_);let E=Rn(b.id,t);if(E.source==="cyclicPrerequisite")return{result:re(t,i,-1,!1,e)};let D={value:E.value};if(!Ot(D,b.condition||{}))return{result:re(t,i,-1,!1,e)}}}if(i.groups&&!Ly(i.groups,t))return{result:re(t,i,-1,!1,e)}}if(i.url&&!$y(i.url,t))return{result:re(t,i,-1,!1,e)};let g=Zi(i.seed||r,l,i.hashVersion||1);if(g===null)return{result:re(t,i,-1,!1,e)};if(!u){let _=i.ranges||yu(n,i.coverage===void 0?1:i.coverage,i.weights);c=mu(g,_)}if(h)return{result:re(t,i,-1,!1,e,void 0,!0)};if(c<0)return{result:re(t,i,-1,!1,e)};if("force"in i)return{result:re(t,i,i.force===void 0?-1:i.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:re(t,i,-1,!1,e)};if(i.status==="stopped")return{result:re(t,i,-1,!1,e)};let f=re(t,i,c,!0,e,g,u);if(t.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing){let{changed:_,key:b,doc:E}=Uy(t,a,er(l),{[Co(i.key,i.bucketVersion)]:f.key});_&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[b]=E,t.user.saveStickyBucketAssignmentDoc(E))}let p=Wu(t,i,f);p.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:i,result:f});let v=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in i&&i.changeId&&t.global.recordChangeId&&t.global.recordChangeId(i.changeId),{result:f,trackingCall:v}}function Ct(i,e,t,r,n,s,o){let a={value:t,on:!!t,off:!t,source:r,ruleId:n||""};return s&&(a.experiment=s),o&&(a.experimentResult=o),r!=="override"&&Dy(i,e,a),a}function Yu(i){return{...i.user.attributes,...i.user.attributeOverrides}}function Xu(i,e){return Ot(Yu(e),i,e.global.savedGroups||{})}function Ju(i,e){return i.some(t=>{let{hashValue:r}=Kt(e,t.attribute);if(!r)return!0;let n=Zi(t.seed,r,t.hashVersion||2);return n===null?!0:!t.ranges.some(s=>gn(n,s))})}function Ny(i,e,t,r,n,s,o){if(!n&&s===void 0)return!0;if(!n&&s===0)return!1;let{hashValue:a}=Kt(i,t,r);if(!a)return!1;let l=Zi(e,a,o||1);return l===null?!1:n?gn(l,n):s!==void 0?l<=s:!0}function re(i,e,t,r,n,s,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:c}=Kt(i,e.hashAttribute,i.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),u=e.meta?e.meta[t]:{},h={key:u.key||""+t,featureId:n,inExperiment:a,hashUsed:r,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};return u.name&&(h.name=u.name),s!==void 0&&(h.bucket=s),u.passthrough&&(h.passthrough=u.passthrough),h}function xy(i,e){let t=i.key,r=e.global.overrides;return r&&r[t]&&(i=Object.assign({},i,r[t]),typeof i.url=="string"&&(i.url=mo(i.url))),i}function Kt(i,e,t){let r=e||"id",n="",s=Yu(i);return s[r]&&(n=s[r]),!n&&t&&(s[t]&&(n=s[t]),n&&(r=t)),{hashAttribute:r,hashValue:n}}function $y(i,e){let t=e.user.url;if(!t)return!1;let r=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(i.test(t)||i.test(r))}function Ly(i,e){let t=e.global.groups||{};for(let r=0;r<i.length;r++)if(t[i[r]])return!0;return!1}function My({ctx:i,expKey:e,expBucketVersion:t,expHashAttribute:r,expFallbackAttribute:n,expMinBucketVersion:s,expMeta:o}){t=t||0,s=s||0,r=r||"id",o=o||[];let a=Co(e,t),l=Fy(i,r,n);if(s>0)for(let h=0;h<s;h++){let g=Co(e,h);if(l[g]!==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 Co(i,e){return e=e||0,`${i}__${e}`}function Po(i,e){return`${i}||${e}`}function Fy(i,e,t){if(!i.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:r,hashValue:n}=Kt(i,e),s=Po(r,er(n)),{hashAttribute:o,hashValue:a}=Kt(i,t),l=a?Po(o,er(a)):null,c={};return l&&i.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,i.user.stickyBucketAssignmentDocs[l].assignments||{}),i.user.stickyBucketAssignmentDocs[s]&&Object.assign(c,i.user.stickyBucketAssignmentDocs[s].assignments||{}),c}function Uy(i,e,t,r){let n=Po(e,t),s=i.user.stickyBucketAssignmentDocs&&i.user.stickyBucketAssignmentDocs[n]?i.user.stickyBucketAssignmentDocs[n].assignments||{}:{},o={...s,...r},a=JSON.stringify(s)!==JSON.stringify(o);return{key:n,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function By(i,e){let t=new Set,r=e&&e.features?e.features:i.global.features||{},n=e&&e.experiments?e.experiments:i.global.experiments||[];return Object.keys(r).forEach(s=>{let o=r[s];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),n.map(s=>{t.add(s.hashAttribute||"id"),s.fallbackAttribute&&t.add(s.fallbackAttribute)}),Array.from(t)}async function Qu(i,e,t){let r=Do(i,t);return e.getAllAssignments(r)}function Do(i,e){let t={};return By(i,e).forEach(n=>{let{hashValue:s}=Kt(i,n);t[n]=er(s)}),t}async function Zu(i,e,t){if(i={...i},i.encryptedFeatures){try{i.features=JSON.parse(await zt(i.encryptedFeatures,e,t))}catch(r){console.error(r)}delete i.encryptedFeatures}if(i.encryptedExperiments){try{i.experiments=JSON.parse(await zt(i.encryptedExperiments,e,t))}catch(r){console.error(r)}delete i.encryptedExperiments}if(i.encryptedSavedGroups){try{i.savedGroups=JSON.parse(await zt(i.encryptedSavedGroups,e,t))}catch(r){console.error(r)}delete i.encryptedSavedGroups}return i}function ed(i){let e=i.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(i.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:i.apiHostRequestHeaders,streamingHostRequestHeaders:i.streamingHostRequestHeaders}}function Cn(i,e){return e.hashAttribute+e.hashValue+i.key+e.variationId}var Ry,Oy,td=Re(()=>{"use strict";Ku();tr();Ry="Feature Evaluated",Oy="Experiment Viewed"});var wi,Vy,sr,id=Re(()=>{"use strict";Gu();tr();Du();td();wi=typeof window<"u"&&typeof document<"u",Vy=ku(),sr=class{constructor(e){if(e=e||{},this.version=Vy,this._options=this.context=e,this._renderer=e.renderer||null,this._trackedExperiments=new Set,this._completedChangeIds=new Set,this._trackedFeatures={},this.debug=!!e.debug,this._subscriptions=new Set,this.ready=!1,this._assigned=new Map,this._activeAutoExperiments=new Map,this._triggeredExpKeys=new Set,this._initialized=!1,this._redirectedUrl="",this._deferredTrackingCalls=new Map,this._autoExperimentsAllowed=!e.disableExperimentsOnLoad,this._destroyCallbacks=[],this.logs=[],this.log=this.log.bind(this),this._saveDeferredTrack=this._saveDeferredTrack.bind(this),this._onExperimentEval=this._onExperimentEval.bind(this),this._fireSubscriptions=this._fireSubscriptions.bind(this),this._recordChangedId=this._recordChangedId.bind(this),e.remoteEval){if(e.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!e.clientKey)throw new Error("Missing clientKey");let t=!1;try{t=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(t)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(e.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(e.stickyBucketService){let t=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=r=>t.saveAssignments(r)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),wi&&e.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),e.experiments&&(this.ready=!0,this._updateAllAutoExperiments()),this._options.stickyBucketService&&this._options.stickyBucketAssignmentDocs)for(let t in this._options.stickyBucketAssignmentDocs){let r=this._options.stickyBucketAssignmentDocs[t];r&&this._options.stickyBucketService.saveAssignments(r).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await Zu(e,this._options.decryptionKey);this._decryptedPayload=t,await this.refreshStickyBuckets(t),t.features&&(this._options.features=t.features),t.savedGroups&&(this._options.savedGroups=t.savedGroups),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let t=e.payload;if(t.encryptedExperiments||t.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this._options.stickyBucketService&&!this._options.stickyBucketAssignmentDocs&&(this._options.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this._options.stickyBucketService,t)),this._payload=t,this._decryptedPayload=t,t.features&&(this._options.features=t.features),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,yn(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Tu(e.cacheSettings),e.payload)return await this.setPayload(e.payload),yn(this,e),{success:!0,source:"init"};{let{data:t,...r}=await this._refresh({...e,allowStale:!0});return yn(this,e),await this.setPayload(t||{}),r}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return ed(this._options)}getClientKey(){return this._options.clientKey||""}getPayload(){return this._payload||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this._decryptedPayload||this.getPayload()}isRemoteEval(){return this._options.remoteEval||!1}getCacheKeyAttributes(){return this._options.cacheKeyAttributes}async _refresh({timeout:e,skipCache:t,allowStale:r,streaming:n}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Iu({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:r,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,t,r){let n=await zt(e,t||this._options.decryptionKey,r);this.setFeatures(JSON.parse(n))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,r){let n=await zt(e,t||this._options.decryptionKey,r);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)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(t=>{try{t()}catch(r){console.error(r)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,Ru(this),e.destroyAllStreams&&wo(),this.logs=[],wi&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(t=>{t.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,t){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=t,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:t}=On(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(r=>r.key===e).map(r=>this._runAutoExperiment(r)).filter(r=>r!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,t){let r=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!r)return null;let n=this._isAutoExperimentBlockedByContext(e),s,o;n?s=re(this._getEvalContext(),e,-1,!1,""):({result:s,trackingCall:o}=On(e,null,this._getEvalContext()),this._onExperimentEval(e,s));let a=JSON.stringify(s.value);if(!t&&s.inExperiment&&r&&r.valueHash===a)return s;if(r&&this._undoActiveAutoExperiment(e),s.inExperiment){let l=vn(e);if(l==="redirect"&&s.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?Su(this._getContextUrl(),s.value.urlRedirect):s.value.urlRedirect;if(pn(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),s;this._redirectedUrl=c;let{navigate:u,delay:h}=this._getNavigateFunction();if(u)if(wi)Promise.all([...o?[_n(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(g=>window.setTimeout(g,this._options.navigateDelay??h))]).then(()=>{try{u(c)}catch(g){console.error(g)}});else try{u(c)}catch(g){console.error(g)}}else if(l==="visual"){let c=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(s.value):this._applyDOMChanges(s.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return s}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],r=new Set(t);this._activeAutoExperiments.forEach((n,s)=>{r.has(s)||(n.undo(),this._activeAutoExperiments.delete(s))});for(let n of t){let s=this._runAutoExperiment(n,e);if(s&&s.inExperiment&&vn(n)==="redirect")break}}_onExperimentEval(e,t){let r=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,r)}_fireSubscriptions(e,t,r){(!r||r.result.inExperiment!==t.inExperiment||r.result.variationId!==t.variationId)&&this._subscriptions.forEach(n=>{try{n(e,t)}catch(s){console.error(s)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,t){let r=this.evalFeature(e).value;return r===null?t:r}feature(e){return this.evalFeature(e)}evalFeature(e){return Rn(e,this._getEvalContext())}log(e,t){this.debug&&(this._options.log?this._options.log(e,t):console.log(e,t))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(t=>t&&t.experiment&&t.result).map(t=>[Cn(t.experiment,t.result),t]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(t=>{!t||!t.experiment||!t.result?console.error("Invalid deferred tracking call",{call:t}):e.push(this._options.trackingCallback(t.experiment,t.result))}),this._deferredTrackingCalls.clear(),await Promise.all(e)}setTrackingCallback(e){this._options.trackingCallback=e,this.fireDeferredTrackingCalls()}setFeatureUsageCallback(e){this._options.onFeatureUsage=e}setEventLogger(e){this._options.eventLogger=e}async logEvent(e,t){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:t,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,t||{},this._getUserContext())}catch(r){console.error(r)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Cn(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(wi?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=vn(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(r=>r.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let r=new URL(this._getContextUrl());for(let n of e.variations){if(!n||!n.urlRedirect)continue;let s=new URL(n.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(s.protocol!==r.protocol||s.host!==r.host))return!0}}catch(r){return this.log("Error parsing current or redirect URL",{id:e.key,error:r}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:wi?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!wi)return;let t=[];if(e.css){let r=document.createElement("style");r.innerHTML=e.css,document.head.appendChild(r),t.push(()=>r.remove())}if(e.js){let r=document.createElement("script");r.innerHTML=e.js,this._options.jsInjectionNonce&&(r.nonce=this._options.jsInjectionNonce),document.head.appendChild(r),t.push(()=>r.remove())}return e.domMutations&&e.domMutations.forEach(r=>{t.push(Vu.declarative(r).revert)}),()=>{t.forEach(r=>r())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),r=await Qu(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=r}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let r=this._getEvalContext(),n=Do(r,t);return e.getAllAssignmentsSync(n)}inDevMode(){return!!this._options.enableDevMode}}});var rd=Re(()=>{"use strict";id()});var nd={};ds(nd,{Growthbook:()=>No});var qe,No,sd=Re(()=>{"use strict";rd();ao();gi();vi();qe=class qe{constructor(e,t,r={},n=!1){this.analytics=new di;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=rt("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:t,user_language:r,device_language:n,device_type:s,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:c,url:u,domain:h,utm_content:g,residence_country:f,loggedIn:p,network_type:v,network_downlink:_,user_id:b,anonymous_id:E,account_mode:D})=>{let R={...this.GrowthBook.getAttributes(),id:e,...b!==void 0&&{user_id:b},...E!==void 0&&{anonymous_id:E},...t!==void 0&&{country:t},...f!==void 0&&{residence_country:f},...r!==void 0&&{user_language:r},...n!==void 0&&{device_language:n},...s!==void 0&&{device_type:s},...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},...g!==void 0&&{utm_content:g},...p!==void 0&&{loggedIn:p},...v!==void 0&&{network_type:v},..._!==void 0&&{network_downlink:_},...D!==void 0&&{account_mode:D}};this.log("setAttributes | updating GrowthBook attributes",R),this.GrowthBook.setAttributes(R)};this.getFeatureValue=(e,t)=>{let r=this.GrowthBook.getFeatureValue(e,t);return this.log("getFeatureValue",{key:e,value:r,defaultValue:t}),r};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let t=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:t}),t};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let t=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:t}),t};this.init=async()=>{this.log("init | initializing GrowthBook SDK");let e=await this.GrowthBook.init({timeout:2e3,streaming:!0}).catch(()=>{});this.status=e,this.isLoaded=!0,this.log("init | GrowthBook SDK loaded",{status:e})};this.destroy=()=>{this.GrowthBook.destroy(),this.isLoaded=!1,this.status=void 0};this.debug=n;let s=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new sr({apiHost:iu,clientKey:e,decryptionKey:t,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:s,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})},...r}),this.init()}reapplyExperiment(e){let t=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(t)}waitForIsLoaded(e=1e4){return new Promise((t,r)=>{let n=Date.now(),s=setInterval(()=>{this.isLoaded?(clearInterval(s),t()):Date.now()-n>=e&&(clearInterval(s),r(new Error("GrowthBook initialization timeout")))},100)})}};qe.getGrowthBookInstance=(e,t,r,n=!1)=>qe._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),qe._instance):(qe._instance=new qe(e,t??"",r,n),qe._instance),qe.resetInstance=()=>{qe._instance&&(qe._instance.destroy(),qe._instance=void 0)};No=qe});function cd(i,e,t,r,n,s,o){try{var a=i[s](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(r,n)}function _t(i){return function(){var e=this,t=arguments;return new Promise((function(r,n){var s=i.apply(e,t);function o(l){cd(s,r,n,o,a,"next",l)}function a(l){cd(s,r,n,o,a,"throw",l)}o(void 0)}))}}function T(){return T=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},T.apply(null,arguments)}function ih(i,e){if(i==null)return{};var t={};for(var r in i)if({}.hasOwnProperty.call(i,r)){if(e.indexOf(r)!==-1)continue;t[r]=i[r]}return t}function F(i,e){return i.indexOf(e)!==-1}function ta(i){return i===null||typeof i!="object"}function Un(i,e){return Object.prototype.toString.call(i)==="[object "+e+"]"}function sh(i){return!S(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(i,Event)}function at(i,e,t,r,n){return e>t&&(r.warn("min cannot be greater than max."),e=t),St(i)?i>t?(r.warn(" cannot be greater than max: "+t+". Using max value instead."),t):i<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):i:(r.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+n),at(n||t,e,t,r))}function ob(i){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return Lo&&t.length===hd||(hd=t.length,Lo=t.reduce(((r,n)=>{Pn||(Pn={});var s=Pn[n];if(s)r[s[0]]=s[1];else for(var o=i(n),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,u=e[n];if(c&&u){r[c]=u,Pn[n]=[c,u];break}}return r}),{})),Lo}}function aa(i,e,t,r,n){var s={platform:i,filename:e,function:t==="<anonymous>"?$i:t,in_app:!0};return S(r)||(s.lineno=r),S(n)||(s.colno=n),s}function gb(){return(function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return function(n,s){s===void 0&&(s=0);for(var o=[],a=n.split(`
|
|
15
|
+
`),l=s;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=pd.test(c)?c.replace(pd,"$1"):c;if(!u.match(/\S*Error: /)){for(var h of t){var g=h(u,i);if(g){o.push(g);break}}if(o.length>=vd)break}}}return(function(f){if(!f.length)return[];var p=Array.from(f);return p.reverse(),p.slice(0,vd).map((v=>{return T({},v,{filename:v.filename||(_=p,_[_.length-1]||{}).filename,function:v.function||$i});var _}))})(o)}})("web:javascript",ub,fb)}function Sh(i,e){e===void 0&&(e=40);var t=Object.keys(i);if(t.sort(),!t.length)return"[object has no keys]";for(var r=t.length;r>0;r--){var n=t.slice(0,r).join(", ");if(!(n.length>e))return r===t.length||n.length<=e?n:n.slice(0,e)+"..."}return""}function Lt(i,e,t){if(j(i)){if(od&&i.forEach===od)i.forEach(e,t);else if("length"in i&&i.length===+i.length){for(var r=0,n=i.length;r<n;r++)if(r in i&&e.call(t,i[r],r)===Vn)return}}}function J(i,e,t){if(!U(i)){if(j(i))return Lt(i,e,t);if(qy(i)){for(var r of i.entries())if(e.call(t,r[1],r[0])===Vn)return}else for(var n in i)if(nh.call(i,n)&&e.call(t,i[n],n)===Vn)return}}function Mn(i){for(var e=Object.keys(i),t=e.length,r=new Array(t);t--;)r[t]=[e[t],i[e[t]]];return r}function yb(i,e){return t=i,r=s=>ue(s)&&!Ze(e)?s.slice(0,e):s,n=new Set,(function s(o,a){return o!==Object(o)?r?r(o,a):o:n.has(o)?void 0:(n.add(o),j(o)?(l=[],Lt(o,(c=>{l.push(s(c))}))):(l={},J(o,((c,u)=>{n.has(c)||(l[u]=s(c,u))}))),l);var l})(t);var t,r,n}function Eb(i){var e=i?.hostname;if(!ue(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of bb)if(t===r)return!1;return!0}function Ah(i,e){for(var t=0;t<i.length;t++)if(e(i[t]))return i[t]}function de(i,e,t,r){var{capture:n=!1,passive:s=!0}=r??{};i?.addEventListener(e,t,{capture:n,passive:s})}function Th(i){return i.name==="ph_toolbar_internal"}function Ad(i){return i instanceof Element&&(i.id===Ch||!(i.closest==null||!i.closest(".toolbar-global-fade-container")))}function us(i){return!!i&&i.nodeType===1}function Mt(i,e){return!!i&&!!i.tagName&&i.tagName.toLowerCase()===e.toLowerCase()}function Ph(i){return!!i&&i.nodeType===3}function Dh(i){return!!i&&i.nodeType===11}function pl(i){return i?ls(i).split(/\s+/):[]}function Td(i){var e=m?.location.href;return!!(e&&i&&i.some((t=>e.match(t))))}function zn(i){var e="";switch(typeof i.className){case"string":e=i.className;break;case"object":e=(i.className&&"baseVal"in i.className?i.className.baseVal:null)||i.getAttribute("class")||"";break;default:e=""}return pl(e)}function Nh(i){return U(i)?null:ls(i).split(/(\s+)/).filter((e=>Cr(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Dr(i){var e="";return Aa(i)&&!Fh(i)&&i.childNodes&&i.childNodes.length&&J(i.childNodes,(function(t){var r;Ph(t)&&t.textContent&&(e+=(r=Nh(t.textContent))!==null&&r!==void 0?r:"")})),ls(e)}function xh(i){return S(i.target)?i.srcElement||null:(e=i.target)!=null&&e.shadowRoot?i.composedPath()[0]||null:i.target||null;var e}function $h(i,e){if(S(e))return!0;var t,r=function(s){if(e.some((o=>s.matches(o))))return{v:!0}};for(var n of i)if(t=r(n))return t.v;return!1}function Lh(i){var e=i.parentNode;return!(!e||!us(e))&&e}function wb(i,e){if(!m||_l(i))return!1;var t,r,n;if(kt(e)?(t=!!e&&Rd,r=void 0):(t=(n=e?.css_selector_ignorelist)!==null&&n!==void 0?n:Rd,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=Mh(i,!1);return!(function(o,a){if(o===!1||S(o))return!1;var l;if(o===!0)l=Sb;else{if(!j(o))return!1;if(o.length>Id)return w.error("[PostHog] content_ignorelist array cannot exceed "+Id+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map((c=>c.toLowerCase()))}return a.some((c=>{var{safeText:u,ariaLabel:h}=c;return l.some((g=>u.includes(g)||h.includes(g)))}))})(r,s.map((o=>{var a;return{safeText:Dr(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!$h(s,t)}function Ab(i,e,t,r,n){var s,o,a,l;if(t===void 0&&(t=void 0),!m||_l(i)||(s=t)!=null&&s.url_allowlist&&!Td(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&Td(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some((p=>e.type===p)))return!1}var{parentIsUsefulElement:u,targetElementList:h}=Mh(i,r);if(!(function(p,v){var _=v?.element_allowlist;if(S(_))return!0;var b,E=function(N){if(_.some((R=>N.tagName.toLowerCase()===R)))return{v:!0}};for(var D of p)if(b=E(D))return b.v;return!1})(h,t)||!$h(h,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var g=m.getComputedStyle(i);if(g&&g.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var f=i.tagName.toLowerCase();switch(f){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return u?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(vl.indexOf(f)>-1||i.getAttribute("contenteditable")==="true")}}function Aa(i){for(var e=i;e.parentNode&&!Mt(e,"body");e=e.parentNode){var t=zn(e);if(F(t,"ph-sensitive")||F(t,"ph-no-capture"))return!1}if(F(zn(i),"ph-include"))return!0;var r=i.type||"";if(ue(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var n=i.name||i.id||"";return!(ue(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 Fh(i){return!!(Mt(i,"input")&&!["button","checkbox","submit","reset"].includes(i.type)||Mt(i,"select")||Mt(i,"textarea")||i.getAttribute("contenteditable")==="true")}function Cr(i,e){return e===void 0&&(e=!0),!(U(i)||ue(i)&&(i=ls(i),(e?Tb:Ib).test((i||"").replace(/[- ]/g,""))||(e?Rb:Ob).test(i)))}function Vh(i){var e=Dr(i);return Cr(e=(e+" "+Gh(i)).trim())?e:""}function Gh(i){var e="";return i&&i.childNodes&&i.childNodes.length&&J(i.childNodes,(function(t){var r;if(t&&((r=t.tagName)==null?void 0:r.toLowerCase())==="span")try{var n=Dr(t);e=(e+" "+n).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Gh(t)).trim())}catch(s){w.error("[AutoCapture]",s)}})),e}function Cb(i){return(function(e){var t=e.map((r=>{var n,s,o="";if(r.tag_name&&(o+=r.tag_name),r.attr_class)for(var a of(r.attr_class.sort(),r.attr_class))o+="."+a.replace(/"/g,"");var l=T({},r.text?{text:r.text}:{},{"nth-child":(n=r.nth_child)!==null&&n!==void 0?n:0,"nth-of-type":(s=r.nth_of_type)!==null&&s!==void 0?s:0},r.href?{href:r.href}:{},r.attr_id?{attr_id:r.attr_id}:{},r.attributes),c={};return Mn(l).sort(((u,h)=>{var[g]=u,[f]=h;return g.localeCompare(f)})).forEach((u=>{var[h,g]=u;return c[Od(h.toString())]=Od(g.toString())})),o+=":",o+=Mn(c).map((u=>{var[h,g]=u;return h+'="'+g+'"'})).join("")}));return t.join(";")})((function(e){return e.map((t=>{var r,n,s={text:(r=t.$el_text)==null?void 0:r.slice(0,400),tag_name:t.tag_name,href:(n=t.attr__href)==null?void 0:n.slice(0,2048),attr_class:Pb(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Mn(t).filter((o=>{var[a]=o;return a.indexOf("attr__")===0})).forEach((o=>{var[a,l]=o;return s.attributes[a]=l})),s}))})(i))}function Od(i){return i.replace(/"|\\"/g,'\\"')}function Pb(i){var e=i.attr__class;return e?j(e)?e:pl(e):void 0}function Fo(i,e){return e.length>i?e.slice(0,i)+"...":e}function Nb(i){if(i.previousElementSibling)return i.previousElementSibling;var e=i;do e=e.previousSibling;while(e&&!us(e));return e}function xb(i,e,t,r){var n=i.tagName.toLowerCase(),s={tag_name:n};vl.indexOf(n)>-1&&!t&&(n.toLowerCase()==="a"||n.toLowerCase()==="button"?s.$el_text=Fo(1024,Vh(i)):s.$el_text=Fo(1024,Dr(i)));var o=zn(i);o.length>0&&(s.classes=o.filter((function(u){return u!==""}))),J(i.attributes,(function(u){var h;if((!Fh(i)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!e&&Cr(u.value)&&(h=u.name,!ue(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var g=u.value;u.name==="class"&&(g=pl(g).join(" ")),s["attr__"+u.name]=Fo(1024,g)}}));for(var a=1,l=1,c=i;c=Nb(c);)a++,c.tagName===i.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function $b(i,e){for(var t,r,{e:n,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[i],u=i;u.parentNode&&!Mt(u,"body");)Dh(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var h,g=[],f={},p=!1,v=!1;if(J(c,(N=>{var R=Aa(N);N.tagName.toLowerCase()==="a"&&(p=N.getAttribute("href"),p=R&&p&&Cr(p)&&p),F(zn(N),"ph-no-capture")&&(v=!0),g.push(xb(N,s,o,a));var K=(function(B){if(!Aa(B))return{};var C={};return J(B.attributes,(function(pe){if(pe.name&&pe.name.indexOf("data-ph-capture-attribute")===0){var ve=pe.name.replace("data-ph-capture-attribute-",""),xe=pe.value;ve&&xe&&Cr(xe)&&(C[ve]=xe)}})),C})(N);le(f,K)})),v)return{props:{},explicitNoCapture:v};if(o||(i.tagName.toLowerCase()==="a"||i.tagName.toLowerCase()==="button"?g[0].$el_text=Vh(i):g[0].$el_text=Dr(i)),p){var _,b;g[0].attr__href=p;var E=(_=Wn(p))==null?void 0:_.host,D=m==null||(b=m.location)==null?void 0:b.host;E&&D&&E!==D&&(h=p)}return{props:le({$event_type:n.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:Cb(g)},(t=g[0])!=null&&t.$el_text?{$el_text:(r=g[0])==null?void 0:r.$el_text}:{},h&&n.type==="click"?{$external_click_url:h}:{},f)}}function Fb(i,e){if(e){var t=(function(n,s){if(s===void 0&&(s=k),ar)return ar;if(!s||["localhost","127.0.0.1"].includes(n))return"";for(var o=n.split("."),a=Math.min(o.length,8),l="dmn_chk_"+$t();!ar&&a--;){var c=o.slice(a).join("."),u=l+"=1;domain=."+c+";path=/";s.cookie=u+";max-age=3",s.cookie.includes(l)&&(s.cookie=u+";max-age=0",ar=c)}return ar})(i);if(!t){var r=(n=>{var s=n.match(Mb);return s?s[0]:""})(i);r!==t&&w.info("Warning: cookie subdomain discovery mismatch",r,t),t=r}return t?"; domain=."+t:""}return""}function Nd(i,e,t){try{if(!(e in i))return()=>{};var r=i[e],n=t(r);return bt(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0}})),i[e]=n,()=>{i[e]=r}}catch{return()=>{}}}function jb(i,e){var t=i.config.segment;if(!t)return e();(function(r,n){var s=r.config.segment;if(!s)return n();var o=l=>{var c=()=>l.anonymousId()||$t();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(st,"identified")),n()},a=s.user();"then"in a&&bt(a.then)?a.then(o):o(a)})(i,(()=>{t.register((r=>{Promise&&Promise.resolve||Bo.warn("This browser does not have Promise support, and can not use the segment integration");var n=(s,o)=>{if(!o)return s;s.event.userId||s.event.anonymousId===r.get_distinct_id()||(Bo.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(Bo.info("UserId set, identifying with PostHog"),r.identify(s.event.userId));var a=r.calculateEventProperties(o,s.event.properties);return s.event.properties=Object.assign({},a,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:s=>n(s,s.event.event),page:s=>n(s,"$pageview"),identify:s=>n(s,"$identify"),screen:s=>n(s,"$screen")}})(i)).then((()=>{e()}))}))}function qh(i,e){var{organization:t,projectId:r,prefix:n,severityAllowList:s=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,h,g;if(!(s==="*"||s.includes(a.level))||!i.__loaded)return a;a.tags||(a.tags={});var f=i.requestRouter.endpointFor("ui","/project/"+i.config.token+"/person/"+i.get_distinct_id());a.tags["PostHog Person URL"]=f,i.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=i.get_session_replay_url({withTimestamp:!0}));var p=((l=a.exception)==null?void 0:l.values)||[],v=p.map((b=>T({},b,{stacktrace:b.stacktrace?T({},b.stacktrace,{type:"raw",frames:(b.stacktrace.frames||[]).map((E=>T({},E,{platform:"web:javascript"})))}):void 0}))),_={$exception_message:((c=p[0])==null?void 0:c.value)||a.message,$exception_type:(u=p[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:v,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=p[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(g=p[0])==null?void 0:g.type,$sentry_tags:a.tags};return t&&r&&(_.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),o&&i.exceptions.sendExceptionEvent(_),a}}function zh(i,e,t){if(!k)return{};var r,n=e?Mi([],Fi,t||[]):[],s=Kh(Nr(k.URL,n,xr),i),o=(r={},J(Kb,(function(a){var l=ot.q(a);r[a]=l||null})),r);return le(o,s)}function Kh(i,e){var t=zb.concat(e||[]),r={};return J(t,(function(n){var s=Yn(i,n);r[n]=s||null})),r}function Wh(i){var e=(function(s){return s?s.search($n+"google.([^/?]*)")===0?"google":s.search($n+"bing.com")===0?"bing":s.search($n+"yahoo.com")===0?"yahoo":s.search($n+"duckduckgo.com")===0?"duckduckgo":null:null})(i),t=e!="yahoo"?"q":"p",r={};if(!Ze(e)){r.$search_engine=e;var n=k?Yn(k.referrer,t):"";n.length&&(r.ph_keyword=n)}return r}function Ld(){return navigator.language||navigator.userLanguage}function Yh(){return k?.referrer||"$direct"}function Xh(i,e){var t=i?Mi([],Fi,e||[]):[],r=be?.href.substring(0,1e3);return{r:Yh().substring(0,1e3),u:r?Nr(r,t,xr):void 0}}function Jh(i){var e,{r:t,u:r}=i,n={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Wn(t))==null?void 0:e.host};if(r){n.$current_url=r;var s=Wn(r);n.$host=s?.host,n.$pathname=s?.pathname;var o=Kh(r);le(n,o)}if(t){var a=Wh(t);le(n,a)}return n}function Qh(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Wb(){try{return new Date().getTimezoneOffset()}catch{return}}function Yb(i,e){if(!Ne)return{};var t,r,n,s=i?Mi([],Fi,e||[]):[],[o,a]=(function(l){for(var c=0;c<fd.length;c++){var[u,h]=fd[c],g=u.exec(l),f=g&&(bt(h)?h(g,l):h);if(f)return f}return["",""]})(Ne);return le(gl({$os:o,$os_version:a,$browser:Eh(Ne,navigator.vendor),$device:gd(Ne),$device_type:(r=Ne,n=gd(r),n===ah||n===oh||n==="Kobo"||n==="Kindle Fire"||n===bh?Tr:n===Rr||n===Ni||n===Or||n===na?"Console":n===ch?"Wearable":n?Ke:"Desktop"),$timezone:Qh(),$timezone_offset:Wb()}),{$current_url:Nr(be?.href,s,xr),$host:be?.host,$pathname:be?.pathname,$raw_user_agent:Ne.length>1e3?Ne.substring(0,997)+"...":Ne,$browser_version:nb(Ne,navigator.vendor),$browser_language:Ld(),$browser_language_prefix:(t=Ld(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:m?.screen.height,$screen_width:m?.screen.width,$viewport_height:m?.innerHeight,$viewport_width:m?.innerWidth,$lib:"web",$lib_version:vt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}function Fd(i){return fe(i)&&"clientX"in i&&"clientY"in i&&St(i.clientX)&&St(i.clientY)}function rE(i,e){e===void 0&&(e={});var t=(function(){var a=4294967295;return{p:function(l){for(var c=a,u=0;u<l.length;++u)c=tE[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),r=i.length;t.p(i);var n,s=iE(i,e,10+((n=e).filename&&n.filename.length+1||0),8),o=s.length;return(function(a,l){var c=l.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=l.level<2?4:l.level==9?2:0,a[9]=3,l.mtime!=0&&Go(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),c){a[3]=8;for(var u=0;u<=c.length;++u)a[u+10]=c.charCodeAt(u)}})(s,e),Go(s,o-8,t.d()),Go(s,o-4,r),s}function jd(i,e,t){return br({distinct_id:i,userPropertiesToSet:e,userPropertiesToSetOnce:t})}function sf(i,e){return!i||Object.entries(i).every((t=>{var[r,n]=t,s=e?.[r];if(S(s)||Ze(s))return!1;var o=[String(s)],a=nf[n.operator];return!!a&&a(n.values,o)}))}function Ti(i,e,t){if(U(i))return!1;switch(t){case"exact":return i===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(i);case"regex":try{return new RegExp(e).test(i)}catch{return!1}default:return!1}}var m,Ee,th,od,ad,Ve,k,be,Jo,Qo,ld,Ne,O,vt,Gy,jy,ud,ls,Zo,Hy,rh,nh,cs,j,bt,fe,Ci,S,ue,ea,Ze,U,St,Ri,kt,qy,zy,Ky,xo,Wy,ia,Ke,Bn,Et,Tr,oh,ah,lh,ch,Ir,xi,uh,dh,hh,Xt,Yy,fh,ul,gh,dl,Xy,hl,ph,Di,vh,Rr,Or,Ni,_h,mh,pr,ra,dd,na,yh,Jy,bh,sa,Ae,$o,Qy,Zy,eb,fl,tb,Pn,hd,Lo,ib,Eh,rb,nb,fd,gd,sb,oa,$i,kh,ab,lb,cb,ub,db,hb,fb,pd,vd,la,ca,ua,pb,da,vb,ha,fa,ga,pa,wh,w,oe,_b,_d,Vn,le,Mi,md,mb,gl,bb,Ih,vr,_r,yd,va,bd,_a,Ed,kd,Rh,Sd,wd,Dn,Gn,Oh,Pi,mr,ma,yr,Yt,ya,jn,ba,st,Ea,ka,Sa,wa,Hn,qn,Ch,or,kb,vl,Sb,Id,Rd,_l,Mh,Uh,Tb,Ib,Bh,Rb,Ob,Kn,Wn,Db,Yn,Nr,Xn,Mo,Cd,Ta,Pd,Ia,Ra,Dd,jh,Oa,$t,Lb,ar,Mb,ot,Uo,se,Ub,Nn,Bb,Wt,ye,mt,Ca,xn,Vb,Gb,Jn,lr,Pa,Da,Bo,Hh,Na,Hb,xd,$d,xt,xa,qb,$a,$n,Fi,zb,xr,Kb,Pt,Md,La,Xb,Ma,Qn,yt,We,Te,Li,ml,yl,Ud,Zh,ef,Jb,Fa,Dt,Ua,Zn,Q,Sr,Jt,es,Qb,Zb,tf,rf,pt,cr,Vo,Ba,Bd,ur,Va,Vd,eE,tE,iE,Go,nE,sE,Gd,ts,br,jo,Fn,is,nf,Ln,Ho,Ga,Be,dr,oE,aE,lE,cE,uE,dE,hE,qo,Ai,Hd,hr,qd,zd,Kd,fE,gE,ja,pE,wr,Wd,zo,Ha,fr,hk,fk,gk,Ko,pk,vk,_k,Er,Wo,qa,Y,of,vE,Yd,_E,mE,Pr,za,Ka,Wa,Ya,ze,Xa,Ja,Xd,Qa,gr,rs,Za,el,yE,tl,il,bE,ns,Yo,ss,EE,Nt,rl,af,kr,Jd,nl,kE,sl,SE,wE,ol,al,Ii,os,Ar,Xo,ll,Oi,lf,Qd,Zd,cl,as,eh,mk,yk,wt,cf=Re(()=>{"use strict";m=typeof window<"u"?window:void 0,Ee=typeof globalThis<"u"?globalThis:m;typeof self>"u"&&(Ee.self=Ee),typeof File>"u"&&(Ee.File=function(){});th=Array.prototype,od=th.forEach,ad=th.indexOf,Ve=Ee?.navigator,k=Ee?.document,be=Ee?.location,Jo=Ee?.fetch,Qo=Ee!=null&&Ee.XMLHttpRequest&&"withCredentials"in new Ee.XMLHttpRequest?Ee.XMLHttpRequest:void 0,ld=Ee?.AbortController,Ne=Ve?.userAgent,O=m??{},vt={DEBUG:!1,LIB_VERSION:"1.353.1"};Gy=["$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"],jy=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],ud=function(i,e){if(e===void 0&&(e=[]),!i)return!1;var t=i.toLowerCase();return jy.concat(e).some((r=>{var n=r.toLowerCase();return t.indexOf(n)!==-1}))};ls=function(i){return i.trim()},Zo=function(i){return i.replace(/^\$/,"")},Hy=Array.isArray,rh=Object.prototype,nh=rh.hasOwnProperty,cs=rh.toString,j=Hy||function(i){return cs.call(i)==="[object Array]"},bt=i=>typeof i=="function",fe=i=>i===Object(i)&&!j(i),Ci=i=>{if(fe(i)){for(var e in i)if(nh.call(i,e))return!1;return!0}return!1},S=i=>i===void 0,ue=i=>cs.call(i)=="[object String]",ea=i=>ue(i)&&i.trim().length===0,Ze=i=>i===null,U=i=>S(i)||Ze(i),St=i=>cs.call(i)=="[object Number]"&&i==i,Ri=i=>St(i)&&i>0,kt=i=>cs.call(i)==="[object Boolean]",qy=i=>i instanceof FormData,zy=i=>F(Gy,i);Ky=[!0,"true",1,"1","yes"],xo=i=>F(Ky,i),Wy=[!1,"false",0,"0","no"];ia=class{constructor(e){this.t={},this.i=e.i,this.o=at(e.bucketSize,0,100,e.h),this.m=at(e.refillRate,0,this.o,e.h),this.$=at(e.refillInterval,0,864e5,e.h)}S(e,t){var r=t-e.lastAccess,n=Math.floor(r/this.$);if(n>0){var s=n*this.m;e.tokens=Math.min(e.tokens+s,this.o),e.lastAccess=e.lastAccess+n*this.$}}consumeRateLimit(e){var t,r=Date.now(),n=String(e),s=this.t[n];return s?this.S(s,r):(s={tokens:this.o,lastAccess:r},this.t[n]=s),s.tokens===0||(s.tokens--,s.tokens===0&&((t=this.i)==null||t.call(this,e)),s.tokens===0)}stop(){this.t={}}},Ke="Mobile",Bn="iOS",Et="Android",Tr="Tablet",oh=Et+" "+Tr,ah="iPad",lh="Apple",ch=lh+" Watch",Ir="Safari",xi="BlackBerry",uh="Samsung",dh=uh+"Browser",hh=uh+" Internet",Xt="Chrome",Yy=Xt+" OS",fh=Xt+" "+Bn,ul="Internet Explorer",gh=ul+" "+Ke,dl="Opera",Xy=dl+" Mini",hl="Edge",ph="Microsoft "+hl,Di="Firefox",vh=Di+" "+Bn,Rr="Nintendo",Or="PlayStation",Ni="Xbox",_h=Et+" "+Ke,mh=Ke+" "+Ir,pr="Windows",ra=pr+" Phone",dd="Nokia",na="Ouya",yh="Generic",Jy=yh+" "+Ke.toLowerCase(),bh=yh+" "+Tr.toLowerCase(),sa="Konqueror",Ae="(\\d+(\\.\\d+)?)",$o=new RegExp("Version/"+Ae),Qy=new RegExp(Ni,"i"),Zy=new RegExp(Or+" \\w+","i"),eb=new RegExp(Rr+" \\w+","i"),fl=new RegExp(xi+"|PlayBook|BB10","i"),tb={"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"},ib=(i,e)=>e&&F(e,lh)||(function(t){return F(t,Ir)&&!F(t,Xt)&&!F(t,Et)})(i),Eh=function(i,e){return e=e||"",F(i," OPR/")&&F(i,"Mini")?Xy:F(i," OPR/")?dl:fl.test(i)?xi:F(i,"IE"+Ke)||F(i,"WPDesktop")?gh:F(i,dh)?hh:F(i,hl)||F(i,"Edg/")?ph:F(i,"FBIOS")?"Facebook "+Ke:F(i,"UCWEB")||F(i,"UCBrowser")?"UC Browser":F(i,"CriOS")?fh:F(i,"CrMo")||F(i,Xt)?Xt:F(i,Et)&&F(i,Ir)?_h:F(i,"FxiOS")?vh:F(i.toLowerCase(),sa.toLowerCase())?sa:ib(i,e)?F(i,Ke)?mh:Ir:F(i,Di)?Di:F(i,"MSIE")||F(i,"Trident/")?ul:F(i,"Gecko")?Di:""},rb={[gh]:[new RegExp("rv:"+Ae)],[ph]:[new RegExp(hl+"?\\/"+Ae)],[Xt]:[new RegExp("("+Xt+"|CrMo)\\/"+Ae)],[fh]:[new RegExp("CriOS\\/"+Ae)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ae)],[Ir]:[$o],[mh]:[$o],[dl]:[new RegExp("(Opera|OPR)\\/"+Ae)],[Di]:[new RegExp(Di+"\\/"+Ae)],[vh]:[new RegExp("FxiOS\\/"+Ae)],[sa]:[new RegExp("Konqueror[:/]?"+Ae,"i")],[xi]:[new RegExp(xi+" "+Ae),$o],[_h]:[new RegExp("android\\s"+Ae,"i")],[hh]:[new RegExp(dh+"\\/"+Ae)],[ul]:[new RegExp("(rv:|MSIE )"+Ae)],Mozilla:[new RegExp("rv:"+Ae)]},nb=function(i,e){var t=Eh(i,e),r=rb[t];if(S(r))return null;for(var n=0;n<r.length;n++){var s=r[n],o=i.match(s);if(o)return parseFloat(o[o.length-2])}return null},fd=[[new RegExp(Ni+"; "+Ni+" (.*?)[);]","i"),i=>[Ni,i&&i[1]||""]],[new RegExp(Rr,"i"),[Rr,""]],[new RegExp(Or,"i"),[Or,""]],[fl,[xi,""]],[new RegExp(pr,"i"),(i,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[ra,""];if(new RegExp(Ke).test(e)&&!/IEMobile\b/.test(e))return[pr+" "+Ke,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],n=tb[r]||"";return/arm/i.test(e)&&(n="RT"),[pr,n]}return[pr,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,i=>{if(i&&i[3]){var e=[i[3],i[4],i[5]||"0"];return[Bn,e.join(".")]}return[Bn,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,i=>{var e="";return i&&i.length>=3&&(e=S(i[2])?i[3]:i[2]),["watchOS",e]}],[new RegExp("("+Et+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Et+")","i"),i=>{if(i&&i[2]){var e=[i[2],i[3],i[4]||"0"];return[Et,e.join(".")]}return[Et,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,i=>{var e=["Mac OS X",""];if(i&&i[1]){var t=[i[1],i[2],i[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Yy,""]],[/Linux|debian/i,["Linux",""]]],gd=function(i){return eb.test(i)?Rr:Zy.test(i)?Or:Qy.test(i)?Ni:new RegExp(na,"i").test(i)?na:new RegExp("("+ra+"|WPDesktop)","i").test(i)?ra:/iPad/.test(i)?ah:/iPod/.test(i)?"iPod Touch":/iPhone/.test(i)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(i)?ch:fl.test(i)?xi:/(kobo)\s(ereader|touch)/i.test(i)?"Kobo":new RegExp(dd,"i").test(i)?dd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(i)||/(kf[a-z]+)( bui|\)).+silk\//i.test(i)?"Kindle Fire":/(Android|ZTE)/i.test(i)?new RegExp(Ke).test(i)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(i)||/pixel[\daxl ]{1,6}/i.test(i)&&!/pixel c/i.test(i)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(i)||/lmy47v/i.test(i)&&!/QTAQZ3/i.test(i)?Et:oh:new RegExp("(pda|"+Ke+")","i").test(i)?Jy:new RegExp(Tr,"i").test(i)&&!new RegExp(Tr+" pc","i").test(i)?bh:""},sb=i=>i instanceof Error;oa=class{constructor(e,t,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=t,this.modifiers=r}buildFromUnknown(e,t){t===void 0&&(t={});var r=t&&t.mechanism||{handled:!0,type:"generic"},n=this.buildCoercingContext(r,t,0).apply(e),s=this.buildParsingContext(t),o=this.parseStacktrace(n,s);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(e){var t=this;return _t((function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&j(r.stacktrace.frames)&&(r.stacktrace.frames=yield t.applyModifiers(r.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,n;return e.cause!=null&&(r=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(n=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),T({},e,{cause:r,stack:n})}applyChunkIds(e,t){return e.map((r=>(r.filename&&t&&(r.chunk_id=t[r.filename]),r)))}applyCoercers(e,t){for(var r of this.coercers)if(r.match(e))return r.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return _t((function*(){var r=e;for(var n of t.modifiers)r=yield n(r);return r}))()}convertToExceptionList(e,t){var r,n,s,o={type:e.type,value:e.value,mechanism:{type:(r=t.type)!==null&&r!==void 0?r:"generic",handled:(n=t.handled)===null||n===void 0||n,synthetic:(s=e.synthetic)!==null&&s!==void 0&&s}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,T({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:ob(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,r){r===void 0&&(r=0);var n=(s,o)=>{if(o<=4){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(s,a)}};return T({},t,{syntheticException:r==0?t.syntheticException:void 0,mechanism:e,apply:s=>n(s,r),next:s=>n(s,r+1)})}},$i="?";kh=(i,e)=>{var t=i.indexOf("safari-extension")!==-1,r=i.indexOf("safari-web-extension")!==-1;return t||r?[i.indexOf("@")!==-1?i.split("@")[0]:$i,t?"safari-extension:"+e:"safari-web-extension:"+e]:[i,e]},ab=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,lb=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,cb=/\((\S*)(?::(\d+))(?::(\d+))\)/,ub=(i,e)=>{var t=ab.exec(i);if(t){var[,r,n,s]=t;return aa(e,r,$i,+n,+s)}var o=lb.exec(i);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=cb.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=kh(o[1]||$i,o[2]);return aa(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},db=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,hb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,fb=(i,e)=>{var t=db.exec(i);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=hb.exec(t[3]);r&&(t[1]=t[1]||"eval",t[3]=r[1],t[4]=r[2],t[5]="")}var n=t[3],s=t[1]||$i;return[s,n]=kh(s,n),aa(e,n,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},pd=/\(error: (.*)\)/,vd=50;la=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var r=ue(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Un(e,"DOMException")}isDOMError(e){return Un(e,"DOMError")}},ca=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var r=e.message;return r.error&&typeof r.error.message=="string"?String(r.error.message):String(r)}getStack(e){return e.stacktrace||e.stack||void 0}},ua=class{constructor(){}match(e){return Un(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var r,n=t.apply(e.error);return n||{type:"ErrorEvent",value:e.message,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},pb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,da=class{match(e){return typeof e=="string"}coerce(e,t){var r,[n,s]=this.getInfos(e);return{type:n??"Error",value:s??e,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var t="Error",r=e,n=e.match(pb);return n&&(t=n[1],r=n[2]),[t,r]}},vb=["fatal","error","warning","log","info","debug"];ha=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var r,n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:(r=t.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return sh(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var r=this.getObjectClassName(e);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+Sh(e)}isSeverityLevel(e){return ue(e)&&!ea(e)&&vb.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(sb(r))return r}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},fa=class{match(e){return sh(e)}coerce(e,t){var r,n=e.constructor.name;return{type:n,value:n+" captured as exception with keys: "+Sh(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},ga=class{match(e){return ta(e)}coerce(e,t){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},pa=class{match(e){return Un(e,"PromiseRejectionEvent")}coerce(e,t){var r,n=this.getUnhandledRejectionReason(e);return ta(n)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(n),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){if(ta(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}},wh=function(i,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(n){if(m&&(vt.DEBUG||O.POSTHOG_DEBUG||t)&&!S(m.console)&&m.console){for(var s=("__rrweb_original__"in m.console[n])?m.console[n].__rrweb_original__:m.console[n],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];s(i,...a)}},info:function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];r.k("log",...s)},warn:function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];r.k("warn",...s)},error:function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];r.k("error",...s)},critical:function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];console.error(i,...s)},uninitializedWarning:n=>{r.error("You must initialize PostHog before calling "+n)},createLogger:(n,s)=>wh(i+" "+n,s)};return r},w=wh("[PostHog.js]"),oe=w.createLogger,_b=oe("[ExternalScriptsLoader]"),_d=(i,e,t)=>{if(i.config.disable_external_dependency_loading)return _b.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var r=k?.querySelectorAll("script");if(r){for(var n,s=function(){if(r[o].src===e){var l=r[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)})),l.onerror=c=>t(c),{v:void 0})}},o=0;o<r.length;o++)if(n=s())return n.v}var a=()=>{if(!k)return t("document not found");var l=k.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,t(void 0,h)},l.onerror=h=>t(h),i.config.prepare_external_dependency_script&&(l=i.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(i.config.external_scripts_inject_target==="head")k.head.appendChild(l);else{var c,u=k.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):k.body.appendChild(l)}};k!=null&&k.body?a():k?.addEventListener("DOMContentLoaded",a)};O.__PosthogExtensions__=O.__PosthogExtensions__||{},O.__PosthogExtensions__.loadExternalDependency=(i,e,t)=>{var r="/static/"+e+".js?v="+i.version;if(e==="remote-config"&&(r="/array/"+i.config.token+"/config.js"),e==="toolbar"){var n=3e5;r=r+"&t="+Math.floor(Date.now()/n)*n}var s=i.requestRouter.endpointFor("assets",r);_d(i,s,t)},O.__PosthogExtensions__.loadSiteApp=(i,e,t)=>{var r=i.requestRouter.endpointFor("api",e);_d(i,r,t)};Vn={};le=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return Lt(t,(function(n){for(var s in n)n[s]!==void 0&&(i[s]=n[s])})),i},Mi=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return Lt(t,(function(n){Lt(n,(function(s){i.push(s)}))})),i};md=function(i){try{return i()}catch{return}},mb=function(i){return function(){try{for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return i.apply(this,t)}catch(n){w.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),w.critical(n)}}},gl=function(i){var e={};return J(i,(function(t,r){(ue(t)&&t.length>0||St(t))&&(e[r]=t)})),e};bb=["herokuapp.com","vercel.app","netlify.app"];Ih="$people_distinct_id",vr="__alias",_r="__timers",yd="$autocapture_disabled_server_side",va="$heatmaps_enabled_server_side",bd="$exception_capture_enabled_server_side",_a="$error_tracking_suppression_rules",Ed="$error_tracking_capture_extension_exceptions",kd="$web_vitals_enabled_server_side",Rh="$dead_clicks_enabled_server_side",Sd="$product_tours_enabled_server_side",wd="$web_vitals_allowed_metrics",Dn="$session_recording_remote_config",Gn="$sesid",Oh="$session_is_sampled",Pi="$enabled_feature_flags",mr="$early_access_features",ma="$feature_flag_details",yr="$stored_person_properties",Yt="$stored_group_properties",ya="$surveys",jn="$flag_call_reported",ba="$feature_flag_errors",st="$user_state",Ea="$client_session_props",ka="$capture_rate_limit",Sa="$initial_campaign_params",wa="$initial_referrer_info",Hn="$initial_person_info",qn="$epp",Ch="__POSTHOG_TOOLBAR__",or="$posthog_cookieless",kb=[Ih,vr,"__cmpns",_r,"$session_recording_enabled_server_side",va,Gn,Pi,_a,st,mr,ma,Yt,yr,ya,jn,ba,Ea,ka,Sa,wa,qn,Hn];vl=["a","button","form","input","select","textarea","label"];Sb=["next","previous","prev",">","<"],Id=10,Rd=[".ph-no-rageclick",".ph-no-capture"];_l=i=>!i||Mt(i,"html")||!us(i),Mh=(i,e)=>{if(!m||_l(i))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[i],n=i;n.parentNode&&!Mt(n,"body");)if(Dh(n.parentNode))r.push(n.parentNode.host),n=n.parentNode.host;else{var s=Lh(n);if(!s)break;if(e||vl.indexOf(s.tagName.toLowerCase())>-1)t=!0;else{var o=m.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}r.push(s),n=s}return{parentIsUsefulElement:t,targetElementList:r}};Uh="(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})",Tb=new RegExp("^(?:"+Uh+")$"),Ib=new RegExp(Uh),Bh="\\d{3}-?\\d{2}-?\\d{4}",Rb=new RegExp("^("+Bh+")$"),Ob=new RegExp("("+Bh+")");Kn=class{constructor(e){this.disabled=e===!1;var t=fe(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,r){if(this.disabled)return!1;var n=this.clicks[this.clicks.length-1];if(n&&Math.abs(e-n.x)+Math.abs(t-n.y)<this.thresholdPx&&r-n.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:r}];return!1}},Wn=i=>{var e=k?.createElement("a");return S(e)?null:(e.href=i,e)},Db=function(i,e){var t,r;e===void 0&&(e="&");var n=[];return J(i,(function(s,o){S(s)||S(o)||o==="undefined"||(t=encodeURIComponent((a=>a instanceof File)(s)?s.name:s.toString()),r=encodeURIComponent(o),n[n.length]=r+"="+t)})),n.join(e)},Yn=function(i,e){for(var t,r=((i.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;n<r.length;n++){var s=r[n].split("=");if(s[0]===e){t=s;break}}if(!j(t)||t.length<2)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{w.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Nr=function(i,e,t){if(!i||!e||!e.length)return i;for(var r=i.split("#"),n=r[0]||"",s=r[1],o=n.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],h=0;h<c.length;h++){var g=c[h].split("=");j(g)&&(e.includes(g[0])?u.push(g[0]+"="+t):u.push(c[h]))}var f=l;return a!=null&&(f+="?"+u.join("&")),s!=null&&(f+="#"+s),f},Xn=function(i,e){var t=i.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Mo="$copy_autocapture",Cd=oe("[AutoCapture]");Ta=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Kn(e.config.rageclick),this.C=null}get R(){var e,t,r=fe(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(e=r.url_allowlist)==null?void 0:e.map((n=>new RegExp(n))),r.url_ignorelist=(t=r.url_ignorelist)==null?void 0:t.map((n=>new RegExp(n))),r}F(){if(this.isBrowserSupported()){if(m&&k){var e=r=>{r=r||m?.event;try{this.O(r)}catch(n){Cd.error("Failed to capture event",n)}};if(de(k,"submit",e,{capture:!0}),de(k,"change",e,{capture:!0}),de(k,"click",e,{capture:!0}),this.R.capture_copied_text){var t=r=>{r=r||m?.event,this.O(r,Mo)};de(k,"copy",t,{capture:!0}),de(k,"cut",t,{capture:!0})}}}else Cd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[yd]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,r=[];return(t=this.C)==null||t.forEach((n=>{var s=k?.querySelectorAll(n);s?.forEach((o=>{e===o&&r.push(n)}))})),r}get isEnabled(){var e,t,r=(e=this.instance.persistence)==null?void 0:e.props[yd],n=this.T;if(Ze(n)&&!kt(r)&&!this.instance.M())return!1;var s=(t=this.T)!==null&&t!==void 0?t:!!r;return!!this.instance.config.autocapture&&!s}O(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var r,n=xh(e);Ph(n)&&(n=n.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&wb(n,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===Mo;if(n&&Ab(n,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=$b(n,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(n);if(l&&l.length>0&&(o.$element_selectors=l),t===Mo){var c,u=Nh(m==null||(c=m.getSelection())==null?void 0:c.toString()),h=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=h}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return bt(k?.querySelectorAll)}};Math.trunc||(Math.trunc=function(i){return i<0?Math.ceil(i):Math.floor(i)}),Number.isInteger||(Number.isInteger=function(i){return St(i)&&isFinite(i)&&Math.floor(i)===i});Pd="0123456789abcdef",Ia=class i{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,r,n){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||e<0||t<0||r<0||n<0||e>0xffffffffffff||t>4095||r>1073741823||n>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=n>>>24,s[13]=n>>>16,s[14]=n>>>8,s[15]=n,new i(s)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Pd.charAt(this.bytes[t]>>>4)+Pd.charAt(15&this.bytes[t]),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new i(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;t<16;t++){var r=this.bytes[t]-e.bytes[t];if(r!==0)return Math.sign(r)}return 0}},Ra=class{constructor(){this.A=0,this.j=0,this.D=new Oa}generate(){var e=this.generateOrAbort();if(S(e)){this.A=0;var t=this.generateOrAbort();if(S(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return Ia.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}},jh=i=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<i.length;e++)i[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return i};m&&!S(m.crypto)&&crypto.getRandomValues&&(jh=i=>crypto.getRandomValues(i));Oa=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(jh(this.N),this.U=0),this.N[this.U++]}},$t=()=>Lb().toString(),Lb=()=>(Dd||(Dd=new Ra)).generate(),ar="",Mb=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;ot={H:()=>!!k,B:function(i){w.error("cookieStore error: "+i)},q:function(i){if(k){try{for(var e=i+"=",t=k.cookie.split(";").filter((s=>s.length)),r=0;r<t.length;r++){for(var n=t[r];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}},W:function(i){var e;try{e=JSON.parse(ot.q(i))||{}}catch{}return e},G:function(i,e,t,r,n){if(k)try{var s="",o="",a=Fb(k.location.hostname,r);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),s="; expires="+l.toUTCString()}n&&(o="; secure");var c=i+"="+encodeURIComponent(JSON.stringify(e))+s+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&w.warn("cookieStore warning: large cookie, len="+c.length),k.cookie=c,c}catch{return}},V:function(i,e){if(k!=null&&k.cookie)try{ot.G(i,"",-1,e)}catch{return}}},Uo=null,se={H:function(){if(!Ze(Uo))return Uo;var i=!0;if(S(m))i=!1;else try{var e="__mplssupport__";se.G(e,"xyz"),se.q(e)!=='"xyz"'&&(i=!1),se.V(e)}catch{i=!1}return i||w.error("localStorage unsupported; falling back to cookie store"),Uo=i,i},B:function(i){w.error("localStorage error: "+i)},q:function(i){try{return m?.localStorage.getItem(i)}catch(e){se.B(e)}return null},W:function(i){try{return JSON.parse(se.q(i))||{}}catch{}return null},G:function(i,e){try{m?.localStorage.setItem(i,JSON.stringify(e))}catch(t){se.B(t)}},V:function(i){try{m?.localStorage.removeItem(i)}catch(e){se.B(e)}}},Ub=["$device_id","distinct_id",Gn,Oh,qn,Hn,st],Nn={},Bb={H:function(){return!0},B:function(i){w.error("memoryStorage error: "+i)},q:function(i){return Nn[i]||null},W:function(i){return Nn[i]||null},G:function(i,e){Nn[i]=e},V:function(i){delete Nn[i]}},Wt=null,ye={H:function(){if(!Ze(Wt))return Wt;if(Wt=!0,S(m))Wt=!1;else try{var i="__support__";ye.G(i,"xyz"),ye.q(i)!=='"xyz"'&&(Wt=!1),ye.V(i)}catch{Wt=!1}return Wt},B:function(i){w.error("sessionStorage error: ",i)},q:function(i){try{return m?.sessionStorage.getItem(i)}catch(e){ye.B(e)}return null},W:function(i){try{return JSON.parse(ye.q(i))||null}catch{}return null},G:function(i,e){try{m?.sessionStorage.setItem(i,JSON.stringify(e))}catch(t){ye.B(t)}},V:function(i){try{m?.sessionStorage.removeItem(i)}catch(e){ye.B(e)}}},mt=(function(i){return i[i.PENDING=-1]="PENDING",i[i.DENIED=0]="DENIED",i[i.GRANTED=1]="GRANTED",i})({}),Ca=class{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?mt.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===mt.DENIED||this.consent===mt.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===mt.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:r}=this._instance.config;return r||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return xo(e)?mt.GRANTED:F(Wy,e)?mt.DENIED:mt.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?se:ot;var t=e==="localStorage"?ot:se;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(xo(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!Ah([Ve?.doNotTrack,Ve?.msDoNotTrack,O.doNotTrack],(e=>xo(e)))}},xn=oe("[Dead Clicks]"),Vb=()=>!0,Gb=i=>{var e,t=!((e=i.instance.persistence)==null||!e.get_property(Rh)),r=i.instance.config.capture_dead_clicks;return kt(r)?r:!!fe(r)||t},Jn=class{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,r){this.instance=e,this.isEnabled=t,this.onCapture=r,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Rh]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.it((()=>{this.et()})):this.stop()}it(e){var t,r;(t=O.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",(n=>{n?xn.error("failed to load script",n):e()}))}et(){var e;if(k){if(!this.tt&&(e=O.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=fe(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=O.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(k),xn.info("starting...")}}else xn.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,xn.info("stopping..."))}},lr=oe("[ExceptionAutocapture]"),Pa=class{constructor(e){var t,r,n;this.rt=()=>{var s;if(m&&this.isEnabled&&(s=O.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=O.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=O.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=O.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=o(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=a(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(c){lr.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[bd]),this.dt=new ia({refillRate:(r=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(n=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&n!==void 0?n:10,refillInterval:1e4,h:lr}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return fe(e)?t=T({},t,e):(S(e)?this.ht:e)&&(t=T({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(lr.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,r;(t=O.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",(n=>{if(n)return lr.error("failed to load script",n);e()}))}ut(){var e,t,r;(e=this.st)==null||e.call(this),this.st=void 0,(t=this.nt)==null||t.call(this),this.nt=void 0,(r=this.ot)==null||r.call(this),this.ot=void 0}onRemoteConfig(e){if("autocaptureExceptions"in e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[bd]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}}onConfigChange(){this.R=this.vt()}captureException(e){var t,r,n=(t=e==null||(r=e.$exception_list)==null||(r=r[0])==null?void 0:r.type)!==null&&t!==void 0?t:"Exception";this.dt.consumeRateLimit(n)?lr.info("Skipping exception capture because of client rate limiting.",{exception:n}):this._instance.exceptions.sendExceptionEvent(e)}};Da=class{constructor(e){var t;this._instance=e,this.ct=(m==null||(t=m.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(w.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,w.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(m&&m.history){var r=this;(e=m.history.pushState)!=null&&e.__posthog_wrapped__||Nd(m.history,"pushState",(n=>function(s,o,a){n.call(this,s,o,a),r._t("pushState")})),(t=m.history.replaceState)!=null&&t.__posthog_wrapped__||Nd(m.history,"replaceState",(n=>function(s,o,a){n.call(this,s,o,a),r._t("replaceState")})),this.bt()}}_t(e){try{var t,r=m==null||(t=m.location)==null?void 0:t.pathname;if(!r)return;r!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=r}catch(n){w.error("Error capturing "+e+" pageview",n)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};de(m,"popstate",e),this.ft=()=>{m&&m.removeEventListener("popstate",e)}}}},Bo=oe("[SegmentIntegration]");Hh="posthog-js";Na=class{constructor(e,t,r,n,s,o){this.name=Hh,this.setupOnce=function(a){a(qh(e,{organization:t,projectId:r,prefix:n,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},Hb=m!=null&&m.location?Xn(m.location.hash,"__posthog")||Xn(location.hash,"state"):null,xd="_postHogToolbarParams",$d=oe("[Toolbar]"),xt=(function(i){return i[i.UNINITIALIZED=0]="UNINITIALIZED",i[i.LOADING=1]="LOADING",i[i.LOADED=2]="LOADED",i})(xt||{}),xa=class{constructor(e){this.instance=e}yt(e){O.ph_toolbar_state=e}wt(){var e;return(e=O.ph_toolbar_state)!==null&&e!==void 0?e:xt.UNINITIALIZED}maybeLoadToolbar(e,t,r){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),Th(this.instance.config)||!m||!k)return!1;e=e??m.location,r=r??m.history;try{if(!t){try{m.localStorage.setItem("test","test"),m.localStorage.removeItem("test")}catch{return!1}t=m?.localStorage}var n,s=Hb||Xn(e.hash,"__posthog")||Xn(e.hash,"state"),o=s?md((()=>JSON.parse(atob(decodeURIComponent(s)))))||md((()=>JSON.parse(decodeURIComponent(s)))):null;return o&&o.action==="ph_authorize"?((n=o).source="url",n&&Object.keys(n).length>0&&(o.desiredHash?e.hash=o.desiredHash:r?r.replaceState(r.state,"",e.pathname+e.search):e.hash="")):((n=JSON.parse(t.getItem(xd)||"{}")).source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token)&&(this.loadToolbar(n),!0)}catch{return!1}}xt(e){var t=O.ph_load_toolbar||O.ph_load_editor;!U(t)&&bt(t)?t(e,this.instance):$d.warn("No toolbar load function found")}loadToolbar(e){var t=!(k==null||!k.getElementById(Ch));if(!m||t)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,n=T({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(m.localStorage.setItem(xd,JSON.stringify(T({},n,{source:void 0}))),this.wt()===xt.LOADED)this.xt(n);else if(this.wt()===xt.UNINITIALIZED){var s;this.yt(xt.LOADING),(s=O.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",(o=>{if(o)return $d.error("[Toolbar] Failed to load",o),void this.yt(xt.UNINITIALIZED);this.yt(xt.LOADED),this.xt(n)})),de(m,"turbolinks:load",(()=>{this.yt(xt.UNINITIALIZED),this.loadToolbar(n)}))}return!0}$t(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,r){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),this.maybeLoadToolbar(e,t,r)}},qb=oe("[TracingHeaders]"),$a=class{constructor(e){this.Et=void 0,this.St=void 0,this.rt=()=>{var t,r;S(this.Et)&&((t=O.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),S(this.St)&&((r=O.__PosthogExtensions__)==null||(r=r.tracingHeadersPatchFns)==null||r._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,r;(t=O.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",(n=>{if(n)return qb.error("failed to load script",n);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.Et)==null||e.call(this),(t=this.St)==null||t.call(this),this.Et=void 0,this.St=void 0)}},$n="https?://(.*)",Fi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],zb=Mi(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Fi),xr="<masked>",Kb=["li_fat_id"];Pt=oe("[Web Vitals]"),Md=9e5,La=class{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce(((r,n)=>T({},r,{["$web_vitals_"+n.name+"_event"]:T({},n),["$web_vitals_"+n.name+"_value"]:n.value})),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=r=>{var n,s=(n=this._instance.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0);if(S(s))Pt.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.Ct();S(o)||(U(r?.name)||U(r?.value)?Pt.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?Pt.error("Ignoring metric with value >= "+this.Rt,r):(this.N.url!==o&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),S(this.N.url)&&(this.N.url=o),this.N.firstMetricTimestamp=S(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.N.metrics.push(T({},r,{$current_url:o,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var r,n,s,o,a=O.__PosthogExtensions__;S(a)||S(a.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:n,onFCP:s,onINP:o}=a.postHogWebVitalsCallbacks),r&&n&&s&&o?(this.allowedMetrics.indexOf("LCP")>-1&&r(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&n(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&o(this.It.bind(this)),this.P=!0):Pt.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[kd]),this.startIfEnabled()}get allowedMetrics(){var e,t,r=fe(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return U(r)?((t=this._instance.persistence)==null?void 0:t.props[wd])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(fe(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=fe(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return e!=null&&e}get Rt(){var e=fe(this._instance.config.capture_performance)&&St(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Md;return 0<e&&e<=6e4?Md:e}get isEnabled(){var e=be?.protocol;if(e!=="http:"&&e!=="https:")return Pt.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=fe(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:kt(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return kt(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(Pt.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){if("capturePerformance"in e){var t=fe(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=fe(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[kd]:t}),this._instance.persistence.register({[wd]:r})),this.kt=t,this.startIfEnabled()}}it(e){var t,r;if((t=O.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var n=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,n,(s=>{s?Pt.error("failed to load script",s):e()}))}}Ct(){var e=m?m.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,r=this._instance.config.custom_personal_data_properties,n=t?Mi([],Fi,r||[]):[];return Nr(e,n,xr)}Pt.error("Could not determine current URL")}},Xb=oe("[Heatmaps]");Ma=class{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!((t=this.instance.persistence)==null||!t.props[va]),this.rageclicks=new Kn(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return fe(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return U(this.instance.config.capture_heatmaps)?U(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;Xb.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval((e=this.Ft)!==null&&e!==void 0?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){if("heatmaps"in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[va]:t}),this.kt=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}jt(e){this.Dt(e.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft=(function(e){return e?.visibilityState==="visible"})(k)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){m&&k&&(this.Nt=this.Lt.bind(this),de(m,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||m?.event),de(k,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||m?.event),de(k,"mousemove",this.zt,{capture:!0}),this.Bt=new Jn(this.instance,Vb,this.jt.bind(this)),this.Bt.startIfEnabledOrStop(),this.qt=this.Mt.bind(this),de(k,"visibilitychange",this.qt),this.P=!0)}At(){var e;m&&k&&(this.Nt&&m.removeEventListener("beforeunload",this.Nt),this.Ut&&k.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&k.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&k.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(e=this.Bt)==null||e.stop(),this.P=!1)}Gt(e,t){var r=this.instance.scrollManager.scrollY(),n=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=(function(a,l,c){for(var u=a;u&&us(u)&&!Mt(u,"body");){if(u===c)return!1;if(F(l,m?.getComputedStyle(u).position))return!0;u=Lh(u)}return!1})(xh(e),["fixed","sticky"],s);return{x:e.clientX+(o?0:n),y:e.clientY+(o?0:r),target_fixed:o,type:t}}Dt(e,t){var r;if(t===void 0&&(t="click"),!Ad(e.target)&&Fd(e)){var n=this.Gt(e,t);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(T({},n,{type:"rageclick"})),this.Vt(n)}}Ht(e){!Ad(e.target)&&Fd(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout((()=>{this.Vt(this.Gt(e,"mousemove"))}),500))}Vt(e){if(m){var t=m.location.href,r=this.instance.config.mask_personal_data_properties,n=this.instance.config.custom_personal_data_properties,s=r?Mi([],Fi,n||[]):[],o=Nr(t,s,xr);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!Ci(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},Qn=class{constructor(e){this.Jt=(t,r,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength)&&(w.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:n}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Jt)}destroy(){var e;(e=this.Xt)==null||e.call(this),this.Xt=void 0}doPageView(e,t){var r,n=this.Qt(e,t);return this.Kt={pathname:(r=m?.location.pathname)!==null&&r!==void 0?r:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){var t;return this.Qt(e,(t=this.Kt)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Kt)==null?void 0:e.pageViewId}}Qt(e,t){var r=this.Kt;if(!r)return{$pageview_id:t};var n={$pageview_id:t,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:h}=s;if(!(S(o)||S(a)||S(l)||S(c)||S(u)||S(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),h=Math.ceil(h);var g=o<=1?1:at(a/o,0,1,w),f=o<=1?1:at(l/o,0,1,w),p=c<=1?1:at(u/c,0,1,w),v=c<=1?1:at(h/c,0,1,w);n=le(n,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:g,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return r.pathname&&(n.$prev_pageview_pathname=r.pathname),r.timestamp&&(n.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),n}},yt=(function(i){return i.GZipJS="gzip-js",i.Base64="base64",i})({}),We=Uint8Array,Te=Uint16Array,Li=Uint32Array,ml=new We([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),yl=new We([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ud=new We([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zh=function(i,e){for(var t=new Te(31),r=0;r<31;++r)t[r]=e+=1<<i[r-1];var n=new Li(t[30]);for(r=1;r<30;++r)for(var s=t[r];s<t[r+1];++s)n[s]=s-t[r]<<5|r;return[t,n]},ef=Zh(ml,2),Jb=ef[0],Fa=ef[1];Jb[28]=258,Fa[258]=28;for(Ua=Zh(yl,0)[1],Zn=new Te(32768),Q=0;Q<32768;++Q)Dt=(43690&Q)>>>1|(21845&Q)<<1,Dt=(61680&(Dt=(52428&Dt)>>>2|(13107&Dt)<<2))>>>4|(3855&Dt)<<4,Zn[Q]=((65280&Dt)>>>8|(255&Dt)<<8)>>>1;Sr=function(i,e,t){for(var r=i.length,n=0,s=new Te(e);n<r;++n)++s[i[n]-1];var o,a=new Te(e);for(n=0;n<e;++n)a[n]=a[n-1]+s[n-1]<<1;if(t){o=new Te(1<<e);var l=15-e;for(n=0;n<r;++n)if(i[n])for(var c=n<<4|i[n],u=e-i[n],h=a[i[n]-1]++<<u,g=h|(1<<u)-1;h<=g;++h)o[Zn[h]>>>l]=c}else for(o=new Te(r),n=0;n<r;++n)o[n]=Zn[a[i[n]-1]++]>>>15-i[n];return o},Jt=new We(288);for(Q=0;Q<144;++Q)Jt[Q]=8;for(Q=144;Q<256;++Q)Jt[Q]=9;for(Q=256;Q<280;++Q)Jt[Q]=7;for(Q=280;Q<288;++Q)Jt[Q]=8;es=new We(32);for(Q=0;Q<32;++Q)es[Q]=5;Qb=Sr(Jt,9,0),Zb=Sr(es,5,0),tf=function(i){return(i/8>>0)+(7&i&&1)},rf=function(i,e,t){(t==null||t>i.length)&&(t=i.length);var r=new(i instanceof Te?Te:i instanceof Li?Li:We)(t-e);return r.set(i.subarray(e,t)),r},pt=function(i,e,t){t<<=7&e;var r=e/8>>0;i[r]|=t,i[r+1]|=t>>>8},cr=function(i,e,t){t<<=7&e;var r=e/8>>0;i[r]|=t,i[r+1]|=t>>>8,i[r+2]|=t>>>16},Vo=function(i,e){for(var t=[],r=0;r<i.length;++r)i[r]&&t.push({s:r,f:i[r]});var n=t.length,s=t.slice();if(!n)return[new We(0),0];if(n==1){var o=new We(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(R,K){return R.f-K.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,u=1,h=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=t[t[c].f<t[h].f?c++:h++],l=t[c!=u&&t[c].f<t[h].f?c++:h++],t[u++]={s:-1,f:a.f+l.f,l:a,r:l};var g=s[0].s;for(r=1;r<n;++r)s[r].s>g&&(g=s[r].s);var f=new Te(g+1),p=Ba(t[u-1],f,0);if(p>e){r=0;var v=0,_=p-e,b=1<<_;for(s.sort((function(R,K){return f[K.s]-f[R.s]||R.f-K.f}));r<n;++r){var E=s[r].s;if(!(f[E]>e))break;v+=b-(1<<p-f[E]),f[E]=e}for(v>>>=_;v>0;){var D=s[r].s;f[D]<e?v-=1<<e-f[D]++-1:++r}for(;r>=0&&v;--r){var N=s[r].s;f[N]==e&&(--f[N],++v)}p=e}return[new We(f),p]},Ba=function(i,e,t){return i.s==-1?Math.max(Ba(i.l,e,t+1),Ba(i.r,e,t+1)):e[i.s]=t},Bd=function(i){for(var e=i.length;e&&!i[--e];);for(var t=new Te(++e),r=0,n=i[0],s=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(i[a]==n&&a!=e)++s;else{if(!n&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=i[a]}return[t.subarray(0,r),e]},ur=function(i,e){for(var t=0,r=0;r<e.length;++r)t+=i[r]*e[r];return t},Va=function(i,e,t){var r=t.length,n=tf(e+2);i[n]=255&r,i[n+1]=r>>>8,i[n+2]=255^i[n],i[n+3]=255^i[n+1];for(var s=0;s<r;++s)i[n+s+4]=t[s];return 8*(n+4+r)},Vd=function(i,e,t,r,n,s,o,a,l,c,u){pt(e,u++,t),++n[256];for(var h=Vo(n,15),g=h[0],f=h[1],p=Vo(s,15),v=p[0],_=p[1],b=Bd(g),E=b[0],D=b[1],N=Bd(v),R=N[0],K=N[1],B=new Te(19),C=0;C<E.length;++C)B[31&E[C]]++;for(C=0;C<R.length;++C)B[31&R[C]]++;for(var pe=Vo(B,7),ve=pe[0],xe=pe[1],$e=19;$e>4&&!ve[Ud[$e-1]];--$e);var Ge,A,x,M,L=c+5<<3,ce=ur(n,Jt)+ur(s,es)+o,q=ur(n,g)+ur(s,v)+o+14+3*$e+ur(B,ve)+(2*B[16]+3*B[17]+7*B[18]);if(L<=ce&&L<=q)return Va(e,u,i.subarray(l,l+c));if(pt(e,u,1+(q<ce)),u+=2,q<ce){Ge=Sr(g,f,0),A=g,x=Sr(v,_,0),M=v;var X=Sr(ve,xe,0);for(pt(e,u,D-257),pt(e,u+5,K-1),pt(e,u+10,$e-4),u+=14,C=0;C<$e;++C)pt(e,u+3*C,ve[Ud[C]]);u+=3*$e;for(var he=[E,R],Z=0;Z<2;++Z){var _e=he[Z];for(C=0;C<_e.length;++C){var P=31&_e[C];pt(e,u,X[P]),u+=ve[P],P>15&&(pt(e,u,_e[C]>>>5&127),u+=_e[C]>>>12)}}}else Ge=Qb,A=Jt,x=Zb,M=es;for(C=0;C<a;++C)if(r[C]>255){P=r[C]>>>18&31,cr(e,u,Ge[P+257]),u+=A[P+257],P>7&&(pt(e,u,r[C]>>>23&31),u+=ml[P]);var Ie=31&r[C];cr(e,u,x[Ie]),u+=M[Ie],Ie>3&&(cr(e,u,r[C]>>>5&8191),u+=yl[Ie])}else cr(e,u,Ge[r[C]]),u+=A[r[C]];return cr(e,u,Ge[256]),u+A[256]},eE=new Li([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),tE=(function(){for(var i=new Li(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(1&t&&3988292384)^t>>>1;i[e]=t}return i})(),iE=function(i,e,t,r,n){return(function(s,o,a,l,c,u){var h=s.length,g=new We(l+h+5*(1+Math.floor(h/7e3))+c),f=g.subarray(l,g.length-c),p=0;if(!o||h<8)for(var v=0;v<=h;v+=65535){var _=v+65535;_<h?p=Va(f,p,s.subarray(v,_)):(f[v]=u,p=Va(f,p,s.subarray(v,h)))}else{for(var b=eE[o-1],E=b>>>13,D=8191&b,N=(1<<a)-1,R=new Te(32768),K=new Te(N+1),B=Math.ceil(a/3),C=2*B,pe=function(At){return(s[At]^s[At+1]<<B^s[At+2]<<C)&N},ve=new Li(25e3),xe=new Te(288),$e=new Te(32),Ge=0,A=0,x=(v=0,0),M=0,L=0;v<h;++v){var ce=pe(v),q=32767&v,X=K[ce];if(R[q]=X,K[ce]=q,M<=v){var he=h-v;if((Ge>7e3||x>24576)&&he>423){p=Vd(s,f,0,ve,xe,$e,A,x,L,v-L,p),x=Ge=A=0,L=v;for(var Z=0;Z<286;++Z)xe[Z]=0;for(Z=0;Z<30;++Z)$e[Z]=0}var _e=2,P=0,Ie=D,Le=q-X&32767;if(he>2&&ce==pe(v-Le))for(var Zt=Math.min(E,he)-1,$r=Math.min(32767,v),Ui=Math.min(258,he);Le<=$r&&--Ie&&q!=X;){if(s[v+_e]==s[v+_e-Le]){for(var Me=0;Me<Ui&&s[v+Me]==s[v+Me-Le];++Me);if(Me>_e){if(_e=Me,P=Le,Me>Zt)break;var Bi=Math.min(Le,Me-2),ei=0;for(Z=0;Z<Bi;++Z){var Ft=v-Le+Z+32768&32767,ti=Ft-R[Ft]+32768&32767;ti>ei&&(ei=ti,X=Ft)}}}Le+=(q=X)-(X=R[q])+32768&32767}if(P){ve[x++]=268435456|Fa[_e]<<18|Ua[P];var ii=31&Fa[_e],ri=31&Ua[P];A+=ml[ii]+yl[ri],++xe[257+ii],++$e[ri],M=v+_e,++Ge}else ve[x++]=s[v],++xe[s[v]]}}p=Vd(s,f,u,ve,xe,$e,A,x,L,v-L,p)}return rf(g,0,l+tf(p)+c)})(i,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(i.length)))):12+e.mem,t,r,!0)},Go=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};nE=function(i){var e,t,r,n,s="";for(e=t=0,r=(i=(i+"").replace(/\r\n/g,`
|
|
15
16
|
`).replace(/\r/g,`
|
|
16
|
-
`)).length,s=0;s<i;s++){var o=n.charCodeAt(s),a=null;o<128?t++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Je(a)||(t>e&&(r+=n.substring(e,t)),r+=a,e=t=s+1)}return t>e&&(r+=n.substring(e,n.length)),r},zb=!!Go||!!Vo,$d="text/plain",Ws=function(n,e,t){var i;t===void 0&&(t=!0);var[s,r]=n.split("?"),o=A({},e),a=(i=r?.split("&").map((c=>{var u,[h,g]=c.split("="),f=t&&(u=o[h])!==null&&u!==void 0?u:g;return delete o[h],h+"="+f})))!==null&&i!==void 0?i:[],l=bb(o);return l&&a.push(l),s+"?"+a.join("&")},hi=(n,e)=>JSON.stringify(n,((t,i)=>typeof i=="bigint"?i.toString():i),e),xo=n=>{var{data:e,compression:t}=n;if(e){if(t===vt.GZipJS){var i=qb((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var h=new He(l.length+(l.length>>>1)),g=0,f=function(E){h[g++]=E},p=0;p<u;++p){if(g+5>h.length){var v=new He(g+8+(u-p<<1));v.set(h),h=v}var _=l.charCodeAt(p);_<128||c?f(_):_<2048?(f(192|_>>>6),f(128|63&_)):_>55295&&_<57344?(f(240|(_=65536+(1047552&_)|1023&l.charCodeAt(++p))>>>18),f(128|_>>>12&63),f(128|_>>>6&63),f(128|63&_)):(f(224|_>>>12),f(128|_>>>6&63),f(128|63&_))}return Wh(h,0,g)})(hi(e)),{mtime:0}),s=new Blob([i],{type:$d});return{contentType:$d,body:s,estimatedSize:s.size}}if(t===vt.Base64){var r=(function(l){var c,u,h,g,f,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,_=0,E="",b=[];if(!l)return l;l=Kb(l);do c=(f=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=f>>12&63,h=f>>6&63,g=63&f,b[_++]=p.charAt(c)+p.charAt(u)+p.charAt(h)+p.charAt(g);while(v<l.length);switch(E=b.join(""),l.length%3){case 1:E=E.slice(0,-2)+"==";break;case 2:E=E.slice(0,-1)+"="}return E})(hi(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:hi(l)))(r);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=hi(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Ps=[];Vo&&Ps.push({transport:"fetch",method:n=>{var e,t,{contentType:i,body:s,estimatedSize:r}=(e=xo(n))!==null&&e!==void 0?e:{},o=new Headers;Y(n.headers,(function(u,h){o.append(h,u)})),i&&o.append("Content-Type",i);var a=n.url,l=null;if(td){var c=new td;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}Vo(a,A({method:n?.method||"GET",headers:o,keepalive:n.method==="POST"&&(r||0)<52428.8,body:s,signal:(t=l)==null?void 0:t.signal},n.fetchOptions)).then((u=>u.text().then((h=>{var g={statusCode:u.status,text:h};if(u.status===200)try{g.json=JSON.parse(h)}catch(f){w.error(f)}n.callback==null||n.callback(g)})))).catch((u=>{w.error(u),n.callback==null||n.callback({statusCode:0,error:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Go&&Ps.push({transport:"XHR",method:n=>{var e,t=new Go;t.open(n.method||"GET",n.url,!0);var{contentType:i,body:s}=(e=xo(n))!==null&&e!==void 0?e:{};Y(n.headers,(function(r,o){t.setRequestHeader(o,r)})),i&&t.setRequestHeader("Content-Type",i),n.timeout&&(t.timeout=n.timeout),n.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var r={statusCode:t.status,text:t.responseText};if(t.status===200)try{r.json=JSON.parse(t.responseText)}catch{}n.callback==null||n.callback(r)}},t.send(s)}}),Me!=null&&Me.sendBeacon&&Ps.push({transport:"sendBeacon",method:n=>{var e=Ws(n.url,{beacon:"1"});try{var t,{contentType:i,body:s}=(t=xo(n))!==null&&t!==void 0?t:{},r=typeof s=="string"?new Blob([s],{type:i}):s;Me.sendBeacon(e,r)}catch{}}});Ys=function(n,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(n)}catch{return!1}};Yh={exact:(n,e)=>e.some((t=>n.some((i=>t===i)))),is_not:(n,e)=>e.every((t=>n.every((i=>t!==i)))),regex:(n,e)=>e.some((t=>n.some((i=>Ys(t,i))))),not_regex:(n,e)=>e.every((t=>n.every((i=>!Ys(t,i))))),icontains:(n,e)=>e.map(Os).some((t=>n.map(Os).some((i=>t.includes(i))))),not_icontains:(n,e)=>e.map(Os).every((t=>n.map(Os).every((i=>!t.includes(i))))),gt:(n,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&n.some((s=>i>parseFloat(s)))})),lt:(n,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&n.some((s=>i<parseFloat(s)))}))},Os=n=>n.toLowerCase();$o=oe("[Error tracking]"),Na=class{constructor(e){var t,i;this.Zt=[],this.ti=new Xo([new Qo,new ra,new ea,new Zo,new ia,new na,new ta,new sa],nb()),this._instance=e,this.Zt=(t=(i=this._instance.persistence)==null?void 0:i.get_property(aa))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,i,s,r=(t=(i=e.errorTracking)==null?void 0:i.suppressionRules)!==null&&t!==void 0?t:[],o=(s=e.errorTracking)==null?void 0:s.captureExtensionExceptions;this.Zt=r,this._instance.persistence&&this._instance.persistence.register({[aa]:this.Zt,[gd]:o})}get ii(){var e,t=!!this._instance.get_property(gd),i=this._instance.config.error_tracking.captureExtensionExceptions;return(e=i??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void $o.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void $o.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void $o.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(e.length===0)return!1;var t=e.reduce(((i,s)=>{var{type:r,value:o}=s;return fe(r)&&r.length>0&&i.$exception_types.push(r),fe(o)&&o.length>0&&i.$exception_values.push(o),i}),{$exception_types:[],$exception_values:[]});return this.Zt.some((i=>{var s=i.values.map((r=>{var o,a=Yh[r.operator],l=H(r.value)?r.value:[r.value],c=(o=t[r.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)}));return i.type==="OR"?s.some(Boolean):s.every(Boolean)}))}si(e){return e.flatMap((t=>{var i,s;return(i=(s=t.stacktrace)==null?void 0:s.frames)!==null&&i!==void 0?i:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ni(e){if(e.length>0){var t,i,s,r,o=(t=(i=e[0].stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(s=a==null||(r=a.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}ei(e){return!M(e)&&H(e)}},Fe=oe("[FeatureFlags]"),ii=oe("[FeatureFlags]",{debugEnabled:!0}),Wb="errors_while_computing_flags",Yb="flag_missing",Xb="quota_limited",Jb="timeout",Qb="connection_error",Zb="unknown_error",eE=n=>"api_error_"+n,Lo="$active_feature_flags",mn="$override_feature_flags",Fd="$feature_flag_payloads",si="$override_feature_flag_payloads",Md="$feature_flag_request_id",Ud="$feature_flag_evaluated_at",Bd=n=>{var e={};for(var[t,i]of Cs(n||{}))i&&(e[t]=i);return e},tE=n=>{var e=n.flags;return e?(n.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,(i=e[t].variant)!==null&&i!==void 0?i:e[t].enabled]}))),n.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return(i=e[t].metadata)==null?void 0:i.payload})).map((t=>{var i;return[t,(i=e[t].metadata)==null?void 0:i.payload]})))):Fe.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},nE=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),Da=class{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(Fe.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter((i=>{var s=i&&typeof i=="string"&&i.trim().length>0;return s||Fe.error("Invalid evaluation context found:",i,"Expected non-empty string"),s})):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(la),t=this._instance.get_property(mn),i=this._instance.get_property(si);if(!i&&!t)return e||{};var s=ae({},e||{}),r=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var o of r){var a,l,c=s[o],u=t?.[o],h=k(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,g=k(u)?c.variant:typeof u=="string"?u:void 0,f=i?.[o],p=A({},c,{enabled:h,variant:h?g??c?.variant:void 0});h!==c?.enabled&&(p.original_enabled=c?.enabled),g!==c?.variant&&(p.original_variant=c?.variant),f&&(p.metadata=A({},c?.metadata,{payload:f,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),s[o]=p}return this.oi||(Fe.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this.oi=!0),s}getFlagVariants(){var e=this._instance.get_property(wn),t=this._instance.get_property(mn);if(!t)return e||{};for(var i=ae({},e),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this.oi||(Fe.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this.oi=!0),i}getFlagPayloads(){var e=this._instance.get_property(Fd),t=this._instance.get_property(si);if(!t)return e||{};for(var i=ae({},e||{}),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this.oi||(Fe.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this.oi=!0),i}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this._instance.bi.emit("featureFlagsReloading",!0),this.gi=setTimeout((()=>{this.mi()}),5))}yi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.yi(),!this._instance.M())if(this.li)this.hi=!0;else{var i=this._instance.config.token,s=this._instance.get_property("$device_id"),r={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:A({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(di)||{}),group_properties:this._instance.get_property(Kt)};Je(s)||k(s)||(r.$device_id=s),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.pi()&&(r.evaluation_contexts=this.fi());var o=this._instance.config.__preview_remote_config,a=o?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);o&&(r.timezone=Hh()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:r,compression:this._instance.config.disable_compression?void 0:vt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var h,g,f,p,v=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),v=!1),this.li=!1,this.di||(this.di=!0,this._instance.wi((p=u.json)!==null&&p!==void 0?p:{})),!r.disable_flags||this.hi){this.vi=!v;var _=[];u.error?u.error instanceof Error?_.push(u.error.name==="AbortError"?Jb:Qb):_.push(Zb):u.statusCode!==200&&_.push(eE(u.statusCode)),(h=u.json)!=null&&h.errorsWhileComputingFlags&&_.push(Wb);var E=!((g=u.json)==null||(g=g.quotaLimited)==null||!g.includes(nE.FeatureFlags));if(E&&_.push(Xb),(f=this._instance.persistence)==null||f.register({[ua]:_}),E)Fe.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.");else{var b;r.disable_flags||this.receivedFeatureFlags((b=u.json)!==null&&b!==void 0?b:{},v),this.hi&&(this.hi=!1,this.mi())}}}})}}getFeatureFlag(e,t){var i;if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var s=this.getFeatureFlagResult(e,t);return(i=s?.variant)!==null&&i!==void 0?i:s?.enabled}Fe.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants(),s=e in i,r=i[e],o=this.getFlagPayloads()[e],a=String(r),l=this._instance.get_property(Md)||void 0,c=this._instance.get_property(Ud)||void 0,u=this._instance.get_property(Ls)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var h,g,f,p,v,_,E,b,C,N;H(u[e])?u[e].push(a):u[e]=[a],(h=this._instance.persistence)==null||h.register({[Ls]:u});var I=this.getFeatureFlagDetails(e),K=[...(g=this._instance.get_property(ua))!==null&&g!==void 0?g:[]];k(r)&&K.push(Yb);var B={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((f=this._instance.config.bootstrap)==null||(f=f.featureFlags)==null?void 0:f[e])||null,$feature_flag_bootstrapped_payload:((p=this._instance.config.bootstrap)==null||(p=p.featureFlagPayloads)==null?void 0:p[e])||null,$used_bootstrap_value:!this.vi};k(I==null||(v=I.metadata)==null?void 0:v.version)||(B.$feature_flag_version=I.metadata.version);var P,Ee=(_=I==null||(E=I.reason)==null?void 0:E.description)!==null&&_!==void 0?_:I==null||(b=I.reason)==null?void 0:b.code;Ee&&(B.$feature_flag_reason=Ee),I!=null&&(C=I.metadata)!=null&&C.id&&(B.$feature_flag_id=I.metadata.id),k(I?.original_variant)&&k(I?.original_enabled)||(B.$feature_flag_original_response=k(I.original_variant)?I.original_enabled:I.original_variant),I!=null&&(N=I.metadata)!=null&&N.original_payload&&(B.$feature_flag_original_payload=I==null||(P=I.metadata)==null?void 0:P.original_payload),K.length&&(B.$feature_flag_error=K.join(",")),this._instance.capture("$feature_flag_called",B)}if(s){var de=o;if(!k(o))try{de=JSON.parse(o)}catch{}return{key:e,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:de}}}else Fe.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var i=this._instance.config.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this.pi()&&(s.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:s,compression:this._instance.config.disable_compression?void 0:vt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:r=>{var o,a=(o=r.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return k(i)?void 0:!!i}Fe.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var i=this.getFlagVariants(),s=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var h=tE(o),g=h.flags,f=h.featureFlags,p=h.featureFlagPayloads;if(f){var v=o.requestId,_=o.evaluatedAt;if(H(f)){Fe.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var E={};if(f)for(var b=0;b<f.length;b++)E[f[b]]=!0;a&&a.register({[Lo]:f,[wn]:E})}else{var C=f,N=p,I=g;if(o.errorsWhileComputingFlags)if(g){var K=new Set(Object.keys(g).filter((B=>{var P;return!((P=g[B])!=null&&P.failed)})));C=A({},l,Object.fromEntries(Object.entries(C).filter((B=>{var[P]=B;return K.has(P)})))),N=A({},c,Object.fromEntries(Object.entries(N||{}).filter((B=>{var[P]=B;return K.has(P)})))),I=A({},u,Object.fromEntries(Object.entries(I||{}).filter((B=>{var[P]=B;return K.has(P)}))))}else C=A({},l,C),N=A({},c,N),I=A({},u,I);a&&a.register(A({[Lo]:Object.keys(Bd(C)),[wn]:C||{},[Fd]:N||{},[la]:I||{}},v?{[Md]:v}:{},_?{[Ud]:_}:{}))}}})(e,this._instance.persistence,i,s,r),this.xi(t)}}override(e,t){t===void 0&&(t=!1),Fe.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return Fe.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(mn),this._instance.persistence.unregister(si),this.xi(),ii.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,i=e;if(this.oi=!!((t=i.suppressWarning)!==null&&t!==void 0&&t),"flags"in i){if(i.flags===!1)this._instance.persistence.unregister(mn),ii.info("Flag overrides cleared");else if(i.flags){if(H(i.flags)){for(var s={},r=0;r<i.flags.length;r++)s[i.flags[r]]=!0;this._instance.persistence.register({[mn]:s})}else this._instance.persistence.register({[mn]:i.flags});ii.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this._instance.persistence.unregister(si),ii.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[si]:i.payloads}),ii.info("Payload overrides set",{payloads:i.payloads}))),void this.xi()}this.xi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:i}=this.Ei();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s,r=(this._instance.get_property(ui)||[]).find((c=>c.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};r&&(a.$early_access_feature_name=r.name),i&&(a.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=A({},this.getFlagVariants(),{[e]:t});(s=this._instance.persistence)==null||s.register({[Lo]:Object.keys(Bd(l)),[wn]:l}),this.xi()}getEarlyAccessFeatures(e,t,i){t===void 0&&(t=!1);var s=this._instance.get_property(ui),r=i?"&"+i.map((o=>"stage="+o)).join("&"):"";if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+r),method:"GET",callback:o=>{var a,l;if(o.json){var c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(ui),(l=this._instance.persistence)==null||l.register({[ui]:c}),e(c)}}})}Ei(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((i=>t[i])),flagVariants:Object.keys(t).filter((i=>t[i])).reduce(((i,s)=>(i[s]=t[s],i)),{})}}xi(e){var{flags:t,flagVariants:i}=this.Ei();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(di)||{};this._instance.register({[di]:A({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(di)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(Kt)||{};Object.keys(i).length!==0&&Object.keys(i).forEach((s=>{i[s]=A({},i[s],e[s]),delete e[s]})),this._instance.register({[Kt]:A({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Kt)||{};this._instance.register({[Kt]:A({},t,{[e]:{}})})}else this._instance.unregister(Kt)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.yi(),this.oi=!1}},iE=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],vi=class{constructor(e,t){this.R=e,this.props={},this.$i=!1,this.Si=(i=>{var s="";return i.token&&(s=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+s+"_posthog"})(e),this.Y=this.ki(e),this.load(),e.debug&&w.info("Persistence loaded",e.persistence,A({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Pi}ki(e){iE.indexOf(e.persistence.toLowerCase())===-1&&(w.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(s){s===void 0&&(s=[]);var r=[...Ib,...s];return A({},ie,{W:function(o){try{var a={};try{a=nt.W(o)||{}}catch{}var l=ae(a,JSON.parse(ie.q(o)||"{}"));return ie.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,h){try{ie.G(o,a,void 0,void 0,h);var g={};r.forEach((f=>{a[f]&&(g[f]=a[f])})),Object.keys(g).length&&nt.G(o,g,l,c,u,h)}catch(f){ie.B(f)}},V:function(o,a){try{m?.localStorage.removeItem(o),nt.V(o,a)}catch(l){ie.B(l)}}})})(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return i==="localstorage"&&ie.H()?ie:i==="localstorage+cookie"&&t.H()?t:i==="sessionstorage"&&me.H()?me:i==="memory"?Rb:i==="cookie"?nt:t.H()?t:nt}properties(){var e={};return Y(this.props,(function(t,i){if(i===wn&&he(t))for(var s=Object.keys(t),r=0;r<s.length;r++)e["$feature/"+s[r]]=t[s[r]];else a=i,l=!1,(Je(o=ub)?l:ed&&o.indexOf===ed?o.indexOf(a)!=-1:(Y(o,(function(c){if(l||(l=c===a))return xs})),l))||(e[i]=t);var o,a,l})),e}load(){if(!this.Pi){var e=this.Y.W(this.Si);e&&(this.props=ae({},e))}}save(){this.Pi||this.Y.G(this.Si,this.props,this.Ti,this.Ii,this.Ci,this.R.debug)}remove(){this.Y.V(this.Si,!1),this.Y.V(this.Si,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(he(e)){k(t)&&(t="None"),this.Ti=k(i)?this.Ri:i;var s=!1;if(Y(e,((r,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=r,s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(he(e)){this.Ti=k(t)?this.Ri:t;var i=!1;if(Y(e,((s,r)=>{e.hasOwnProperty(r)&&this.props[r]!==s&&(this.props[r]=s,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.$i){var e=Mh(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);Sn(rl(e))||this.register(e),this.$i=!0}}update_search_keyword(){var e;this.register((e=S?.referrer)?Bh(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Vh(),$referring_domain:S!=null&&S.referrer&&((e=Vs(S.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[fa]||this.props[ga]||this.register_once({[Fs]:Gh(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Y([ga,fa],(o=>{var a=this.props[o];a&&Y(a,(function(l,c){e["$initial_"+jo(c)]=l}))}));var t,i,s=this.props[Fs];if(s){var r=(t=jh(s),i={},Y(t,(function(o,a){i["$initial_"+jo(a)]=o})),i);ae(e,r)}return e}safe_merge(e){return Y(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this.Ri=this.Ti=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((u,h)=>u===c[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var s=this.ki(e),r=this.props;this.clear(),this.Y=s,this.props=r,this.save()}}set_disabled(e){this.Pi=e,this.Pi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_secure(e){e!==this.Ci&&(this.Ci=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[ci]||{};i[e]=t,this.props[ci]=i,this.save()}remove_event_timer(e){var t=(this.props[ci]||{})[e];return k(t)||(delete this.props[ci][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},Vd=oe("[Product Tours]"),Fo="ph_product_tours",xa=class{constructor(e){this.Fi=null,this.Oi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[vd]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Fi||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(vd)||this.it((()=>this.Mi()))}it(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.generateProductTours?e():(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"product-tours",(s=>{s?Vd.error("Could not load product tours script",s):e()}))}Mi(){var e;!this.Fi&&(e=O.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Fi=O.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!H(this.Oi)||t){var i=this._instance.persistence;if(i){var s=i.props[Fo];if(H(s)&&!t)return this.Oi=s,void e(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:r=>{var o=r.statusCode;if(o!==200||!r.json){var a="Product Tours API could not be loaded, status: "+o;return Vd.error(a),void e([],{isLoaded:!1,error:a})}var l=H(r.json.product_tours)?r.json.product_tours:[];this.Oi=l,i&&i.register({[Fo]:l}),e(l,{isLoaded:!0})}})}else e(this.Oi,{isLoaded:!0})}getActiveProductTours(e){M(this.Fi)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fi.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Fi)==null||t.showTourById(e)}previewTour(e){this.Fi?this.Fi.previewTour(e):this.it((()=>{var t;this.Mi(),(t=this.Fi)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Fi)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Fi)==null||e.nextStep()}previousStep(){var e;(e=this.Fi)==null||e.previousStep()}clearCache(){var e;this.Oi=null,(e=this._instance.persistence)==null||e.unregister(Fo)}resetTour(e){var t;(t=this.Fi)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Fi)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Fi)==null||t.cancelPendingTour(e)}},ri=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),XE=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),JE=(function(n){return n.TopLeft="top_left",n.TopRight="top_right",n.TopCenter="top_center",n.MiddleLeft="middle_left",n.MiddleRight="middle_right",n.MiddleCenter="middle_center",n.Left="left",n.Center="center",n.Right="right",n.NextToTrigger="next_to_trigger",n})({}),QE=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),Mo=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),ZE=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),e0=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),t0=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),fi=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),Uo=(function(n){return n.SURVEY_ID="$survey_id",n.SURVEY_NAME="$survey_name",n.SURVEY_RESPONSE="$survey_response",n.SURVEY_ITERATION="$survey_iteration",n.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",n.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",n.SURVEY_SUBMISSION_ID="$survey_submission_id",n.SURVEY_QUESTIONS="$survey_questions",n.SURVEY_COMPLETED="$survey_completed",n.PRODUCT_TOUR_ID="$product_tour_id",n.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",n})({}),$a=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),W=oe("[Surveys]"),Jh="seenSurvey_",sE=(n,e)=>{var t="$survey_"+e+"/"+n.id;return n.current_iteration&&n.current_iteration>0&&(t="$survey_"+e+"/"+n.id+"/"+n.current_iteration),t},Gd=n=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(Jh,n),rE=[Mo.Popover,Mo.Widget,Mo.API],oE={ignoreConditions:!1,ignoreDelay:!1,displayType:$a.Popover},Si=class{constructor(){this.Ai={},this.Ai={}}on(e,t){return this.Ai[e]||(this.Ai[e]=[]),this.Ai[e].push(t),()=>{this.Ai[e]=this.Ai[e].filter((i=>i!==t))}}emit(e,t){for(var i of this.Ai[e]||[])i(t);for(var s of this.Ai["*"]||[])s(e,t)}};La=class{constructor(e){this.ji=new Si,this.Di=(t,i)=>this.Li(t,i)&&this.Ni(t,i)&&this.Ui(t,i)&&this.zi(t,i),this.Li=(t,i)=>i==null||!i.event||t?.event===i?.event,this._instance=e,this.Hi=new Set,this.Bi=new Set}init(){var e;if(!k((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((i,s)=>{this.on(i,s)}))}}register(e){var t,i;if(!k((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.Bi)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.Hi)==null||u.add(c?.event||"")}))})),(i=this._instance)!=null&&i.autocapture)){var s,r=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&r.add(l?.selector)}))})),(s=this._instance)==null||s.autocapture.setElementSelectors(r)}}on(e,t){var i;t!=null&&e.length!=0&&(this.Hi.has(e)||this.Hi.has(t?.event))&&this.Bi&&((i=this.Bi)==null?void 0:i.size)>0&&this.Bi.forEach((s=>{this.qi(t,s)&&this.ji.emit("actionCaptured",s.name)}))}Wi(e){this.onAction("actionCaptured",(t=>e(t)))}qi(e,t){if(t?.steps==null)return!1;for(var i of t.steps)if(this.Di(e,i))return!0;return!1}onAction(e,t){return this.ji.on(e,t)}Ni(e,t){if(t!=null&&t.url){var i,s=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!s||typeof s!="string"||!yn(s,t.url,t.url_matching||"contains"))return!1}return!0}Ui(e,t){return!!this.Gi(e,t)&&!!this.Vi(e,t)&&!!this.Ji(e,t)}Gi(e,t){var i;if(t==null||!t.href)return!0;var s=this.Ki(e);if(s.length>0)return s.some((a=>yn(a.href,t.href,t.href_matching||"exact")));var r,o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!o&&yn((r=o.match(/(?::|")href="(.*?)"/))?r[1]:"",t.href,t.href_matching||"exact")}Vi(e,t){var i;if(t==null||!t.text)return!0;var s=this.Ki(e);if(s.length>0)return s.some((c=>yn(c.text,t.text,t.text_matching||"exact")||yn(c.$el_text,t.text,t.text_matching||"exact")));var r,o,a,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(r=(function(c){for(var u,h=[],g=/(?::|")text="(.*?)"/g;!M(u=g.exec(c));)h.includes(u[1])||h.push(u[1]);return h})(l),o=t.text,a=t.text_matching||"exact",r.some((c=>yn(c,o,a))))}Ji(e,t){var i,s;if(t==null||!t.selector)return!0;var r=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(r!=null&&r.includes(t.selector))return!0;var o=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}Ki(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}zi(e,t){return t==null||!t.properties||t.properties.length===0||Xh(t.properties.reduce(((i,s)=>{var r=H(s.value)?s.value.map(String):s.value!=null?[String(s.value)]:[];return i[s.key]={values:r,operator:s.operator||"exact"},i}),{}),e?.properties)}},Fa=class{constructor(e){this._instance=e,this.Yi=new Map,this.Xi=new Map,this.Qi=new Map}Zi(e,t){return!!e&&Xh(e.propertyFilters,t?.properties)}te(e,t){var i=new Map;return e.forEach((s=>{var r;(r=s.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((o=>{if(o!=null&&o.name){var a=i.get(o.name)||[];a.push(s.id),i.set(o.name,a)}}))})),i}ie(e,t,i){var s=(i===ri.Activation?this.Yi:this.Xi).get(e),r=[];return this.ee((o=>{r=o.filter((a=>s?.includes(a.id)))})),r.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[i])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.Zi(l,t)}))}register(e){var t;k((t=this._instance)==null?void 0:t._addCaptureHook)||(this.re(e),this.se(e))}se(e){var t=e.filter((i=>{var s,r;return((s=i.conditions)==null?void 0:s.actions)&&((r=i.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0}));t.length!==0&&(this.ne==null&&(this.ne=new La(this._instance),this.ne.init(),this.ne.Wi((i=>{this.onAction(i)}))),t.forEach((i=>{var s,r,o,a,l;i.conditions&&(s=i.conditions)!=null&&s.actions&&(r=i.conditions)!=null&&(r=r.actions)!=null&&r.values&&((o=i.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.ne)==null||a.register(i.conditions.actions.values),(l=i.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.Qi.get(c.name);u&&u.push(i.id),this.Qi.set(c.name,u||[i.id])}})))})))}re(e){var t,i=e.filter((r=>{var o,a;return((o=r.conditions)==null?void 0:o.events)&&((a=r.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),s=e.filter((r=>{var o,a;return((o=r.conditions)==null?void 0:o.cancelEvents)&&((a=r.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(i.length!==0||s.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((r,o)=>{this.onEvent(r,o)})),this.Yi=this.te(e,ri.Activation),this.Xi=this.te(e,ri.Cancellation))}onEvent(e,t){var i,s=this.oe(),r=this.ae(),o=this.le(),a=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[r])||[];if(o===e&&t&&a.length>0){var l,c;s.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var h=a.indexOf(u);h>=0&&(a.splice(h,1),this.ue(a))}}else{if(this.Xi.has(e)){var g=this.ie(e,t,ri.Cancellation);g.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:g.map((p=>p.id))}),g.forEach((p=>{var v=a.indexOf(p.id);v>=0&&a.splice(v,1),this.he(p.id)})),this.ue(a))}if(this.Yi.has(e)){s.info("event name matched",{event:e,eventPayload:t,items:this.Yi.get(e)});var f=this.ie(e,t,ri.Activation);this.ue(a.concat(f.map((p=>p.id))||[]))}}}onAction(e){var t,i=this.ae(),s=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[i])||[];this.Qi.has(e)&&this.ue(s.concat(this.Qi.get(e)||[]))}ue(e){var t,i=this.oe(),s=this.ae(),r=[...new Set(e)].filter((o=>!this.de(o)));i.info("updating activated items",{activatedItems:r}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[s]:r})}getActivatedIds(){var e,t=this.ae(),i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return i||[]}getEventToItemsMap(){return this.Yi}ve(){return this.ne}},Ma=class extends Fa{constructor(e){super(e)}ae(){return"$surveys_activated"}le(){return fi.SHOWN}ee(e){var t;(t=this._instance)==null||t.getSurveys(e)}he(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}oe(){return W}de(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ua=class{constructor(e){this.ce=void 0,this._surveyManager=null,this.fe=!1,this.pe=[],this.ge=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(M(t))return W.warn("Flags not loaded yet. Not loading surveys.");var i=H(t);this.ce=i?t.length>0:t,W.info("flags response received, isSurveysEnabled: "+this.ce),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(i!=null&&i.startsWith(Jh)||i!=null&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((s=>localStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.fe)W.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)W.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())W.info("Not loading surveys in cookieless mode without consent.");else{var e=O?.__PosthogExtensions__;if(e){if(!k(this.ce)||this._instance.config.advanced_enable_surveys){var t=this.ce||this._instance.config.advanced_enable_surveys;this.fe=!0;try{var i=e.generateSurveys;if(i)return void this._e(i,t);var s=e.loadExternalDependency;if(!s)return void this.me("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",(r=>{r||!e.generateSurveys?this.me("Could not load surveys script",r):this._e(e.generateSurveys,t)}))}catch(r){throw this.me("Error initializing surveys",r),r}finally{this.fe=!1}}}else W.error("PostHog Extensions not found.")}}_e(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ma(this._instance),W.info("Surveys loaded successfully"),this.be({isLoaded:!0})}me(e,t){W.error(e,t),this.be({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.pe.push(e),this._surveyManager&&this.be({isLoaded:!0}),()=>{this.pe=this.pe.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return W.info("Disabled. Not loading surveys."),e([]);var i,s=this._instance.get_property(ca);if(s&&!t)return e(s,{isLoaded:!0});typeof Promise<"u"&&this.ge?this.ge.then((r=>{var{surveys:o,context:a}=r;return e(o,a)})):(typeof Promise<"u"&&(this.ge=new Promise((r=>{i=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:r=>{var o;this.ge=null;var a=r.statusCode;if(a!==200||!r.json){var l="Surveys API could not be loaded, status: "+a;W.error(l);var c={isLoaded:!1,error:l};return e([],c),void(i==null||i({surveys:[],context:c}))}var u,h=r.json.surveys||[],g=h.filter((p=>(function(v){return!(!v.start_date||v.end_date)})(p)&&((function(v){var _;return!((_=v.conditions)==null||(_=_.events)==null||(_=_.values)==null||!_.length)})(p)||(function(v){var _;return!((_=v.conditions)==null||(_=_.actions)==null||(_=_.values)==null||!_.length)})(p))));g.length>0&&((u=this._surveyEventReceiver)==null||u.register(g)),(o=this._instance.persistence)==null||o.register({[ca]:h});var f={isLoaded:!0};e(h,f),i?.({surveys:h,context:f})}}))}be(e){for(var t of this.pe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){W.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!M(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);W.warn("init was not called")}ye(e){var t=null;return this.getSurveys((i=>{var s;t=(s=i.find((r=>r.id===e)))!==null&&s!==void 0?s:null})),t}we(e){if(M(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.ye(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(M(this._surveyManager))return W.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.we(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return M(this._surveyManager)?(W.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((i=>{this.getSurveys((s=>{var r,o=(r=s.find((l=>l.id===e)))!==null&&r!==void 0?r:null;if(o){var a=this.we(o);i({visible:a.eligible,disabledReason:a.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var s;if(M(this._surveyManager))W.warn("init was not called");else{var r=typeof e=="string"?this.ye(e):e;if(r!=null&&r.id)if(rE.includes(r.type)){var o=S?.querySelector(t);if(o)return(s=r.appearance)!=null&&s.surveyPopupDelaySeconds?(W.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,l;W.info("Rendering survey "+r.id+" with delay of "+((a=r.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(r,o,i),W.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,o,i);W.warn("Survey element not found")}else W.warn("Surveys of type "+r.type+" cannot be rendered in the app");else W.warn("Survey not found")}}displaySurvey(e,t){var i;if(M(this._surveyManager))W.warn("init was not called");else{var s=this.ye(e);if(s){var r=s;if((i=s.appearance)!=null&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(r=A({},s,{appearance:A({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==$a.Popover&&t.initialResponses&&W.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(s);if(!o.visible)return void W.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==$a.Inline?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}else W.warn("Survey not found")}}cancelPendingSurvey(e){M(this._surveyManager)?W.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},ht=oe("[Conversations]"),Ba=class{constructor(e){this.xe=void 0,this._conversationsManager=null,this.Ee=!1,this.$e=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;M(t)||(mt(t)?this.xe=t:(this.xe=t.enabled,this.$e=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.xe=void 0,this.$e=null}loadIfEnabled(){if(!this._conversationsManager&&!this.Ee&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=O?.__PosthogExtensions__;if(e&&!k(this.xe)&&this.xe)if(this.$e&&this.$e.token){this.Ee=!0;try{var t=e.initConversations;if(t)return this.Se(t),void(this.Ee=!1);var i=e.loadExternalDependency;if(!i)return void this.ke("PostHog loadExternalDependency extension not found.");i(this._instance,"conversations",(s=>{s||!e.initConversations?this.ke("Could not load conversations script",s):this.Se(e.initConversations),this.Ee=!1}))}catch(s){this.ke("Error initializing conversations",s),this.Ee=!1}}else ht.error("Conversations enabled but missing token in remote config.")}}Se(e){if(this.$e)try{this._conversationsManager=e(this.$e,this._instance),ht.info("Conversations loaded successfully")}catch(t){this.ke("Error completing conversations initialization",t)}else ht.error("Cannot complete initialization: remote config is null")}ke(e,t){ht.error(e,t),this._conversationsManager=null,this.Ee=!1}show(){this._conversationsManager?this._conversationsManager.show():ht.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.xe===!0&&!Je(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,i){var s=this;return kn((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(ht.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var i=this;return kn((function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(ht.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return kn((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(ht.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return kn((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(ht.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},Va=class{constructor(e){var t;this.Pe=!1,this.Te=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Pe=!0)}onRemoteConfig(e){var t,i=(t=e.logs)==null?void 0:t.captureConsoleLogs;!M(i)&&i&&(this.Pe=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Pe&&!this.Te){var e=oe("[logs]"),t=O?.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",(s=>{var r;s||(r=t.logs)==null||!r.initializeLogs?e.error("Could not load logs script",s):(t.logs.initializeLogs(this._instance),this.Te=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},jd=oe("[RateLimiter]"),Ga=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((s=>{jd.info((s||"events")+" is quota limited."),this.serverLimits[s]=new Date().getTime()+6e4}))}catch(s){return void jd.warn('could not rate limit - continuing. Error: "'+s?.message+'"',{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;e===void 0&&(e=!1);var{captureEventsBurstLimit:r,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(ha))!==null&&t!==void 0?t:{tokens:r,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>r&&(l.tokens=r);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(s=this.instance.persistence)==null||s.set_property(ha,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},qt=oe("[RemoteConfig]"),ja=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=O._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Ie(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(qt.error("PostHog Extensions not found. Cannot load remote config."),e())}Ce(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return qt.info("Using preloaded remote config",this.remoteConfig),void this.wi(this.remoteConfig);if(this._instance.M())return void qt.warn("Remote config is disabled. Falling back to local config.");this.Ie((e=>{if(!e)return qt.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ce((t=>{this.wi(t)}));this.wi(e)}))}catch(e){qt.error("Error loading remote config",e)}}wi(e){e?this._instance.config.__preview_remote_config?(this._instance.wi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):qt.info("__preview_remote_config is disabled. Logging config instead",e):qt.error("Failed to fetch remote config from PostHog.")}},Ha=3e3,qa=class{constructor(e,t){this.Re=!0,this.Fe=[],this.Oe=it(t?.flush_interval_ms||Ha,250,5e3,w.createLogger("flush interval"),Ha),this.Me=e}enqueue(e){this.Fe.push(e),this.Ae||this.je()}unload(){this.De();var e=this.Fe.length>0?this.Le():{},t=Object.values(e);[...t.filter((i=>i.url.indexOf("/e")===0)),...t.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.Me(A({},i,{transport:"sendBeacon"}))}))}enable(){this.Re=!1,this.je()}je(){var e=this;this.Re||(this.Ae=setTimeout((()=>{if(this.De(),this.Fe.length>0){var t=this.Le(),i=function(){var r=t[s],o=new Date().getTime();r.data&&H(r.data)&&Y(r.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Me(r)};for(var s in t)i()}}),this.Oe))}De(){clearTimeout(this.Ae),this.Ae=void 0}Le(){var e={};return Y(this.Fe,(t=>{var i,s=t,r=(s?s.batchKey:null)||s.url;k(e[r])&&(e[r]=A({},s,{data:[]})),(i=e[r].data)==null||i.push(s.data)})),this.Fe=[],e}},aE=["retriesPerformedSoFar"],Ka=class{constructor(e){this.Ne=!1,this.Ue=3e3,this.Fe=[],this._instance=e,this.Fe=[],this.ze=!0,!k(m)&&"onLine"in m.navigator&&(this.ze=m.navigator.onLine,this.He=()=>{this.ze=!0,this.Lt()},this.Be=()=>{this.ze=!1},ue(m,"online",this.He),ue(m,"offline",this.Be))}get length(){return this.Fe.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=Yd(e,aE);bn(t)&&(i.url=Ws(i.url,{retry_count:t})),this._instance._send_request(A({},i,{callback:s=>{s.statusCode!==200&&(s.statusCode<400||s.statusCode>=500)&&(t??0)<10?this.qe(A({retriesPerformedSoFar:t},i)):i.callback==null||i.callback(s)}}))}qe(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(t),s=Date.now()+i;this.Fe.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),w.warn(r),this.Ne||(this.Ne=!0,this.We())}We(){if(this.Ge&&clearTimeout(this.Ge),this.Fe.length===0)return this.Ne=!1,void(this.Ge=void 0);this.Ge=setTimeout((()=>{this.ze&&this.Fe.length>0&&this.Lt(),this.We()}),this.Ue)}Lt(){var e=Date.now(),t=[],i=this.Fe.filter((r=>r.retryAt<e||(t.push(r),!1)));if(this.Fe=t,i.length>0)for(var{requestOptions:s}of i)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this.Ge&&(clearTimeout(this.Ge),this.Ge=void 0),this.Ne=!1,k(m)||(this.He&&(m.removeEventListener("online",this.He),this.He=void 0),this.Be&&(m.removeEventListener("offline",this.Be),this.Be=void 0)),this.Fe))try{this._instance._send_request(A({},e,{transport:"sendBeacon"}))}catch(t){w.error(t)}this.Fe=[]}},za=class{constructor(e){this.Ve=()=>{var t,i,s,r;this.Je||(this.Je={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),u=o?.scrollHeight||0;this.Je.lastScrollY=Math.ceil(a),this.Je.maxScrollY=Math.max(a,(t=this.Je.maxScrollY)!==null&&t!==void 0?t:0),this.Je.maxScrollHeight=Math.max(l,(i=this.Je.maxScrollHeight)!==null&&i!==void 0?i:0),this.Je.lastContentY=c,this.Je.maxContentY=Math.max(c,(s=this.Je.maxContentY)!==null&&s!==void 0?s:0),this.Je.maxContentHeight=Math.max(u,(r=this.Je.maxContentHeight)!==null&&r!==void 0?r:0)},this._instance=e}getContext(){return this.Je}resetContext(){var e=this.Je;return setTimeout(this.Ve,0),e}startMeasuringScrollPosition(){ue(m,"scroll",this.Ve,{capture:!0}),ue(m,"scrollend",this.Ve,{capture:!0}),ue(m,"resize",this.Ve)}scrollElement(){if(!this._instance.config.scroll_root_selector)return m?.document.documentElement;var e=H(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var i=m?.document.querySelector(t);if(i)return i}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return m&&(m.scrollY||m.pageYOffset||m.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return m&&(m.scrollX||m.pageXOffset||m.document.documentElement.scrollLeft)||0}},lE=n=>Gh(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),Xs=class{constructor(e,t,i,s){this.Ke=r=>{var o=this.Ye();if(!o||o.sessionId!==r){var a={sessionId:r,props:this.Xe(this._instance)};this.Qe.register({[da]:a})}},this._instance=e,this.Ze=t,this.Qe=i,this.Xe=s||lE,this.Ze.onSessionId(this.Ke)}Ye(){return this.Qe.props[da]}getSetOnceProps(){var e,t=(e=this.Ye())==null?void 0:e.props;return t?"r"in t?jh(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return Y(rl(this.getSetOnceProps()),((t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+jo(i)]=t})),e}},Bo=oe("[SessionId]"),Js=class{on(e,t){return this.tr.on(e,t)}constructor(e,t,i){var s;if(this.ir=[],this.er=void 0,this.tr=new Si,this.rr=(u,h)=>!(!bn(u)||!bn(h))&&Math.abs(u-h)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Qe=e.persistence,this.sr=void 0,this.nr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ar=t||Ct,this.lr=i||Ct;var r=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*it(o,60,36e3,Bo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ur(),this.hr="ph_"+r+"_window_id",this.dr="ph_"+r+"_primary_window_exists",this.vr()){var a=me.W(this.hr),l=me.W(this.dr);a&&!l?this.sr=a:me.V(this.hr),me.G(this.dr,!0)}if((s=this.R.bootstrap)!=null&&s.sessionID)try{var c=(u=>{var h=u.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})(this.R.bootstrap.sessionID);this.cr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){Bo.error("Invalid sessionID in bootstrap",u)}this.pr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return k(this.ir)&&(this.ir=[]),this.ir.push(e),this.nr&&e(this.nr,this.sr),()=>{this.ir=this.ir.filter((t=>t!==e))}}vr(){return this.R.persistence!=="memory"&&!this.Qe.Pi&&me.H()}gr(e){e!==this.sr&&(this.sr=e,this.vr()&&me.G(this.hr,e))}_r(){return this.sr?this.sr:this.vr()?me.W(this.hr):null}cr(e,t,i){e===this.nr&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.nr=e,this.Qe.register({[$s]:[t,e,i]}))}mr(){var e=this.Qe.props[$s];return H(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.cr(null,null,null)}destroy(){clearTimeout(this.br),this.br=void 0,this.er&&m&&(m.removeEventListener("beforeunload",this.er,{capture:!1}),this.er=void 0),this.ir=[]}pr(){this.er=()=>{this.vr()&&me.V(this.dr)},ue(m,"beforeunload",this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||new Date().getTime(),[s,r,o]=this.mr(),a=this._r(),l=bn(o)&&Math.abs(i-o)>864e5,c=!1,u=!r,h=!u&&!e&&this.rr(i,s);u||h||l?(r=this.ar(),a=this.lr(),Bo.info("new session ID generated",{sessionId:r,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}}),o=i,c=!0):a||(a=this.lr(),c=!0);var g=bn(s)&&e&&!l?s:i,f=bn(o)?o:new Date().getTime();return this.gr(a),this.cr(r,g,f),e||this.ur(),c&&this.ir.forEach((p=>p(r,a,c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:r,windowId:a,sessionStartTimestamp:f,changeReason:c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:s}}ur(){clearTimeout(this.br),this.br=setTimeout((()=>{var[e]=this.mr();if(this.rr(new Date().getTime(),e)){var t=this.nr;this.resetSessionId(),this.tr.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},cE=["$set_once","$set"],Rt=oe("[SiteApps]"),Wa=class{constructor(e){this._instance=e,this.yr=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}wr(e,t){if(t){var i=this.globalsForEvent(t);this.yr.push(i),this.yr.length>1e3&&(this.yr=this.yr.slice(10))}}get siteAppLoaders(){var e;return(e=O._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.wr.bind(this));this.Er=()=>{e(),this.yr=[],this.Er=void 0}}}globalsForEvent(e){var t,i,s,r,o,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var[g,f]of Object.entries(h))c[g]={id:u[g],type:g,properties:f};var{$set_once:p,$set:v}=e;return{event:A({},Yd(e,cE),{properties:A({},e.properties,v?{$set:A({},(t=(i=e.properties)==null?void 0:i.$set)!==null&&t!==void 0?t:{},v)}:{},p?{$set_once:A({},(s=(r=e.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},p)}:{}),elements_chain:(o=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var a;!t.errored&&this.yr.length&&(Rt.info("Processing "+this.yr.length+" events for site app with id "+e.id),this.yr.forEach((l=>t.processEvent==null?void 0:t.processEvent(l))),t.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.Er)==null||a.call(this))},s=!1,r=a=>{t.errored=!a,t.loaded=!0,Rt.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),s&&i()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:a=>{r(a)}});o&&(t.processEvent=o),s=!0}catch(a){Rt.error("Error while initializing PostHog app with config id "+e.id,a),r(!1)}if(s&&t.loaded)try{i()}catch(a){Rt.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}$r(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}Sr(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{i.processEvent==null||i.processEvent(t)}catch(s){Rt.error("Error while processing event "+e.event+" for site app "+i.id,s)}}}onRemoteConfig(e){var t,i,s,r=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.$r(),void this._instance.on("eventCaptured",(c=>this.Sr(c)))):void Rt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((i=this.Er)==null||i.call(this),(s=e.siteApps)!=null&&s.length)if(this.isEnabled){var o=function(c){var u;O["__$$ph_site_app_"+c]=r._instance,(u=O.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(r._instance,l,(h=>{if(h)return Rt.error("Error while initializing PostHog app with config id "+c,h)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else Rt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},Qh=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&id(t,e))return!0;try{var i=n?.userAgentData;if(i!=null&&i.brands&&i.brands.some((s=>id(s?.brand,e))))return!0}catch{}return!!n.webdriver},gi=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),Hd="i.posthog.com",Ya=class{constructor(e){this.kr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+Hd,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.kr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=gi.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=gi.EU:this.kr[this.apiHost]=gi.CUSTOM),this.kr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===gi.CUSTOM)return this.apiHost+t;var i=Hd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}},uE={icontains:(n,e)=>!!m&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!m&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!m&&Ys(e.href,n),not_regex:(n,e)=>!!m&&!Ys(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Xa=class n{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments((s=>{n.Pr("retrieved web experiments from the server"),t.Tr=new Map,s.forEach((r=>{if(r.feature_flag_key){var o;t.Tr&&(n.Pr("setting flag key ",r.feature_flag_key," to web experiment ",r),(o=t.Tr)==null||o.set(r.feature_flag_key,r));var a=t._instance.getFeatureFlag(r.feature_flag_key);fe(a)&&r.variants[a]&&t.Ir(r.name,a,r.variants[a].transforms)}else if(r.variants)for(var l in r.variants){var c=r.variants[l];n.Cr(c)&&t.Ir(r.name,l,c.transforms)}}))}),i)},this._instance=e,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}onFeatureFlags(e){if(this._is_bot())n.Pr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(M(this.Tr))return this.Tr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();n.Pr("applying feature flags",e),e.forEach((t=>{var i;if(this.Tr&&(i=this.Tr)!=null&&i.has(t)){var s,r=this._instance.getFeatureFlag(t),o=(s=this.Tr)==null?void 0:s.get(t);r&&o!=null&&o.variants[r]&&this.Ir(o.name,r,o.variants[r].transforms)}}))}}previewWebExperiment(){var e=n.getWindowLocation();if(e!=null&&e.search){var t=Gs(e?.search,"__experiment_id"),i=Gs(e?.search,"__experiment_variant");t&&i&&(n.Pr("previewing web experiments "+t+" && "+i),this.getWebExperiments((s=>{this.Rr(parseInt(t),i,s)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._instance.config.disable_web_experiments&&!i)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:r=>{if(r.statusCode!==200||!r.json)return e([]);var o=r.json.experiments||[];return e(o)}})}Rr(e,t,i){var s=i.filter((r=>r.id===e));s&&s.length>0&&(n.Pr("Previewing web experiment ["+s[0].name+"] with variant ["+t+"]"),this.Ir(s[0].name,t,s[0].variants[t].transforms))}static Cr(e){return!M(e.conditions)&&n.Fr(e)&&n.Or(e)}static Fr(e){var t;if(M(e.conditions)||M((t=e.conditions)==null?void 0:t.url))return!0;var i,s,r,o=n.getWindowLocation();return!!o&&((i=e.conditions)==null||!i.url||uE[(s=(r=e.conditions)==null?void 0:r.urlMatchType)!==null&&s!==void 0?s:"icontains"](e.conditions.url,o))}static getWindowLocation(){return m?.location}static Or(e){var t;if(M(e.conditions)||M((t=e.conditions)==null?void 0:t.utm))return!0;var i=Mh();if(i.utm_source){var s,r,o,a,l,c,u,h,g=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.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||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==i.utm_medium,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return g&&p&&v&&f}return!1}static Pr(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];w.info("[WebExperiments] "+e,i)}Ir(e,t,i){this._is_bot()?n.Pr("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?i.forEach((s=>{if(s.selector){var r;n.Pr("applying transform of variant "+t+" for experiment "+e+" ",s);var o=(r=document)==null?void 0:r.querySelectorAll(s.selector);o?.forEach((a=>{var l=a;s.html&&(l.innerHTML=s.html),s.css&&l.setAttribute("style",s.css)}))}})):n.Pr("Control variants leave the page unmodified.")}_is_bot(){return Me&&this._instance?Qh(Me,this._instance.config.custom_blocked_useragents):void 0}},dE=oe("[PostHog ExternalIntegrations]"),hE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ja=class{constructor(e){this._instance=e}it(e,t){var i;(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,(s=>{if(s)return dE.error("failed to load script",s);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!s||(a=O.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(hE[o],(()=>{var u;(u=O.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!s&&(l=O.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=O.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[i,s]of Object.entries((r=this._instance.config.integrations)!==null&&r!==void 0?r:{})){var r;t(i)}}},Qa="[SessionRecording]",oi=oe(Qa),Qs=class{get started(){var e;return!((e=this.Mr)==null||!e.isStarted)}get status(){return this.Mr?this.Mr.status:this.Ar&&!this.jr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ar=!1,this.Dr=void 0,this._instance=e,!this._instance.sessionManager)throw oi.error("started without valid sessionManager"),new Error(Qa+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Qa+' cannot be used with cookieless_mode="always"')}get jr(){var e,t=!((e=this._instance.get_property(Io))==null||!e.enabled),i=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return m&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!this.jr||(t=this.Mr)==null||!t.isStarted){var i=!k(Object.assign)&&!k(Array.from);this.jr&&i?(this.Lr(e),oi.info("starting")):this.stopRecording()}}Lr(e){var t,i,s;this.jr&&(O!=null&&(t=O.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(i=O.__PosthogExtensions__)!=null&&i.initSessionRecording?this.Nr(e):(s=O.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.Ur,(r=>{if(r)return oi.error("could not load recorder",r);this.Nr(e)})))}stopRecording(){var e,t;(e=this.Dr)==null||e.call(this),this.Dr=void 0,(t=this.Mr)==null||t.stop()}zr(){var e;(e=this._instance.persistence)==null||e.unregister(Eh)}Hr(e){if(this._instance.persistence){var t,i,s=this._instance.persistence,r=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=M(a)?null:parseFloat(a);M(l)&&this.zr();var c=o?.minimumDurationMilliseconds;s.register({[Io]:A({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:A({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:k(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};r(),(t=this.Dr)==null||t.call(this),this.Dr=(i=this._instance.sessionManager)==null?void 0:i.onSessionId(r)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.Hr(e),this.Ar=!0,this.startIfEnabledOrStop()):this.Ar=!0:oi.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;t===void 0&&(t="log"),(i=this.Mr)!=null&&i.log?this.Mr.log(e,t):oi.warn("log called before recorder was ready")}get Ur(){var e,t,i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Io);return(i==null||(t=i.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Nr(e){var t,i;if((t=O.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Mr||(this.Mr=(i=O.__PosthogExtensions__)==null?void 0:i.initSessionRecording(this._instance),this.Mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Mr.start(e)}onRRwebEmit(e){var t;(t=this.Mr)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Mr||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Mr)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Mr||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Mr)==null||e.overrideSampling()}overrideTrigger(e){var t,i;this.Mr||(i=this._instance.persistence)==null||i.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Mr)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Mr)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!((i=this.Mr)==null||!i.tryAddCustomEvent(e,t))}},_i={},Za=()=>{},En="posthog",Zh=!zb&&De?.indexOf("MSIE")===-1&&De?.indexOf("Mozilla")===-1,qd=n=>{var e;return A({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:cb(S?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Za,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:n??"unset",__preview_deferred_init_extensions:!1,debug:ye&&fe(ye?.search)&&ye.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:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(m==null||(e=m.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_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var i="Bad HTTP status: "+t.statusCode+" "+t.text;w.error(i)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Ha},error_tracking:{},_onCapture:Za,__preview_eager_load_replay:!1},(t=>({rageclick:!(t&&t>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(t&&t>="2025-05-24")||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(n))},Kd=n=>{var e={};k(n.process_person)||(e.person_profiles=n.process_person),k(n.xhr_headers)||(e.request_headers=n.xhr_headers),k(n.cookie_name)||(e.persistence_name=n.cookie_name),k(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),k(n.store_google)||(e.save_campaign_params=n.store_google),k(n.verbose)||(e.debug=n.verbose);var t=ae({},e,n);return H(n.property_blacklist)&&(k(n.property_denylist)?t.property_denylist=n.property_blacklist:H(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:w.error("Invalid value for property_denylist config: "+n.property_denylist)),t},el=class{constructor(){this.__forceAllowLocalhost=!1}get Br(){return this.__forceAllowLocalhost}set Br(e){w.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Zs=class n{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new el,this.qr=!1,this.version=ft.LIB_VERSION,this.bi=new Si,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=qd(),this.SentryIntegration=Sa,this.sentryIntegration=e=>(function(t,i){var s=Fh(t,i);return{name:Lh,processEvent:r=>s(r)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new Da(this),this.toolbar=new wa(this),this.scrollManager=new za(this),this.pageViewManager=new qs(this),this.surveys=new Ua(this),this.conversations=new Ba(this),this.logs=new Va(this),this.experiments=new Xa(this),this.exceptions=new Na(this),this.rateLimiter=new Ga(this),this.requestRouter=new Ya(this),this.consent=new ba(this),this.externalIntegrations=new Ja(this),this.people={set:(e,t,i)=>{var s=fe(e)?{[e]:t}:e;this.setPersonProperties(s),i?.({})},set_once:(e,t,i)=>{var s=fe(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),i?.({})}},this.on("eventCaptured",(e=>w.info('send "'+e?.event+'"',e)))}init(e,t,i){if(i&&i!==En){var s,r=(s=_i[i])!==null&&s!==void 0?s:new n;return r._init(e,t,i),_i[i]=r,_i[En][i]=r,r}return this._init(e,t,i)}_init(e,t,i){var s;if(t===void 0&&(t={}),k(e)||Ho(e))return w.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(ae({},qd(t.defaults),Kd(t),{name:i,token:e})),this.config.on_xhr_error&&w.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:vt.GZipJS;var r=this.Qr();this.persistence=new vi(this.config,r),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new vi(A({},this.config,{persistence:"sessionStorage"}),r);var o=A({},this.persistence.props),a=A({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new qa((b=>this.ts(b)),this.config.request_queue_config),this.es=new Ka(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new Js(this),this.sessionPropsManager=new Xs(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(w.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.rs(l)}),0)):(w.info("Initializing extensions synchronously"),this.rs(l)),ft.DEBUG=ft.DEBUG||this.config.debug,ft.DEBUG&&w.info("Starting in debug mode",{this:this,config:t,thisC:A({},this.config),p:o,s:a}),((s=t.bootstrap)==null?void 0:s.distinctID)!==void 0){var c,u,h=this.config.get_device_id(Ct()),g=(c=t.bootstrap)!=null&&c.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(gt,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:g})}if(this.ss()){var f,p,v=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlags)||{}).filter((b=>{var C;return!((C=t.bootstrap)==null||(C=C.featureFlags)==null||!C[b])})).reduce(((b,C)=>{var N;return b[C]=((N=t.bootstrap)==null||(N=N.featureFlags)==null?void 0:N[C])||!1,b}),{}),_=Object.keys(((p=t.bootstrap)==null?void 0:p.featureFlagPayloads)||{}).filter((b=>v[b])).reduce(((b,C)=>{var N,I;return(N=t.bootstrap)!=null&&(N=N.featureFlagPayloads)!=null&&N[C]&&(b[C]=(I=t.bootstrap)==null||(I=I.featureFlagPayloads)==null?void 0:I[C]),b}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:_})}if(l)this.register_once({distinct_id:Qn,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id(Ct());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(gt,"anonymous")}return ue(m,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Pb(this,(()=>this.ns())):this.ns(),Pt(this.config._onCapture)&&this.config._onCapture!==Za&&(w.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(b=>this.config._onCapture(b.event,b)))),this.config.ip&&w.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}rs(e){var t=performance.now();this.historyAutocapture=new ka(this),this.historyAutocapture.startIfEnabled();var i=[];i.push((()=>{new Aa(this).startIfEnabledOrStop()})),i.push((()=>{var s;this.siteApps=new Wa(this),(s=this.siteApps)==null||s.init()})),e||i.push((()=>{this.sessionRecording=new Qs(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),i.push((()=>{this.autocapture=new va(this),this.autocapture.startIfEnabled()})),i.push((()=>{this.surveys.loadIfEnabled()})),i.push((()=>{this.logs.loadIfEnabled()})),i.push((()=>{this.conversations.loadIfEnabled()})),i.push((()=>{this.productTours=new xa(this),this.productTours.loadIfEnabled()})),i.push((()=>{this.heatmaps=new Ia(this),this.heatmaps.startIfEnabled()})),i.push((()=>{this.webVitalsAutocapture=new Ta(this)})),i.push((()=>{this.exceptionObserver=new Ea(this),this.exceptionObserver.startIfEnabledOrStop()})),i.push((()=>{this.deadClicksAutocapture=new Hs(this,Cb),this.deadClicksAutocapture.startIfEnabled()})),i.push((()=>{if(this.os){var s=this.os;this.os=void 0,this.wi(s)}})),this.ls(i,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.ls(e,t)}),0);var i=e.shift();if(i)try{i()}catch(r){w.error("Error initializing extension:",r)}}var s=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:s}),this.config.__preview_deferred_init_extensions&&w.info("PostHog extensions initialized ("+s+"ms)")}wi(e){var t,i,s,r,o,a,l,c,u;if(!S||!S.body)return w.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.wi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=F(e.supportedCompression,vt.GZipJS)?vt.GZipJS:F(e.supportedCompression,vt.Base64)?vt.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),(i=this.siteApps)==null||i.onRemoteConfig(e),(s=this.sessionRecording)==null||s.onRemoteConfig(e),(r=this.autocapture)==null||r.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(i){w.critical("`loaded` function failed",i)}if(this.us(),this.config.internal_or_test_user_hostname&&ye!=null&&ye.hostname){var e=ye.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.hs()}),1),new ja(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Nt(this.__request_queue,(e=>this.ts(e))),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),(e=this.Zr)==null||e.unload(),(t=this.es)==null||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Zh?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Ws(e.url,{ip:this.config.ip?1:0}),e.headers=A({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var i,s,r,o=A({},t);o.timeout=o.timeout||6e4,o.url=Ws(o.url,{_:new Date().getTime().toString(),ver:ft.LIB_VERSION,compression:o.compression});var a=(i=o.transport)!==null&&i!==void 0?i:"fetch",l=Ps.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(s=(r=mh(l,(u=>u.transport===a)))==null?void 0:r.method)!==null&&s!==void 0?s:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(A({},e,{callback:t=>{var i,s;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((i=(s=this.config).on_request_error)==null||i.call(s,t)),e.callback==null||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],s=[],r=[];Nt(e,(a=>{a&&(t=a[0],H(t)?r.push(a):Pt(a)?a.call(this):H(a)&&t==="alias"?i.push(a):H(a)&&t.indexOf("capture")!==-1&&Pt(this[t])?r.push(a):s.push(a))}));var o=function(a,l){Nt(a,(function(c){if(H(c[0])){var u=l;Y(c,(function(h){u=u[h[0]].apply(u,h.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};o(i,this),o(s,this),o(r,this)}ss(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,i){var s;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!k(e)&&fe(e)){var r=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(r&&!this.config.__preview_capture_bot_pageviews)){var o=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!fe(t?.$current_url)&&(w.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=i?.timestamp||a,c=Ct(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&r&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),i?.$set&&(u.$set=i?.$set);var h,g=e!=="$groupidentify",f=this.vs(i?.$set_once,g);if(f&&(u.$set_once=f),(u=ab(u,i!=null&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,k(i?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===fi.DISMISSED||e===fi.SENT){var p=t?.[Uo.SURVEY_ID],v=t?.[Uo.SURVEY_ITERATION];h={id:p,current_iteration:v},localStorage.getItem(Gd(h))||localStorage.setItem(Gd(h),"true"),u.$set=A({},u.$set,{[sE({id:p,current_iteration:v},e===fi.SENT?"responded":"dismissed")]:!0})}else e===fi.SHOWN&&(u.$set=A({},u.$set,{[Uo.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var _=A({},u.properties.$set,u.$set);if(Sn(_)||this.setPersonPropertiesForFlags(_),!M(this.config.before_send)){var E=this.cs(u);if(!E)return;u=E}this.bi.emit("eventCaptured",u);var b={method:"POST",url:(s=i?._url)!==null&&s!==void 0?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:i?._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.ts(b):this.Zr.enqueue(b),u}w.critical("This capture call is ignored due to client rate limiting.")}}else w.error("No event name provided to posthog.capture")}else w.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,i,s,r){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var o=r?void 0:this.persistence.remove_event_timer(e),a=A({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=A({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!fe(a.distinct_id)&&!yt(a.distinct_id)||Ho(a.distinct_id))&&w.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=Fb(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(r,i.getTime());a.$session_id=h,a.$window_id=g}this.sessionPropsManager&&ae(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&ae(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this.es)==null?void 0:f.length}catch(E){a.$sdk_debug_error_capturing_properties=String(E)}if(this.requestRouter.region===gi.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||r?e!=="$pageleave"||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,s),a=ae(a,c),e==="$pageview"&&S&&(a.title=S.title),!k(o)){var p=i.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}De&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=ae({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),H(this.config.property_denylist)?Y(this.config.property_denylist,(function(E){delete a[E]})):w.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(w.error("sanitize_properties is deprecated. Use before_send instead"),a=v(a,e));var _=this.fs();return a.$process_person_profile=_,_&&!r&&this.ps("_calculate_event_properties"),a}vs(e,t){var i;if(t===void 0&&(t=!0),!this.persistence||!this.fs()||this.qr)return e;var s=this.persistence.get_initial_props(),r=(i=this.sessionPropsManager)==null?void 0:i.getSetOnceProps(),o=ae({},s,r||{},e||{}),a=this.config.sanitize_properties;return a&&(w.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.qr=!0),Sn(o)?void 0:o}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var s;(s=this.persistence)==null||s.register_once(e,t,i)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,i){var s=i!=null&&i.merge?this.featureFlags.getFlagVariants():{},r=i!=null&&i.merge?this.featureFlags.getFlagPayloads():{},o=A({},s,e),a=A({},r,t),l={};for(var[c,u]of Object.entries(o)){var h=typeof u=="string";l[c]={key:c,enabled:!!h||!!u,variant:h?u:void 0,reason:void 0,metadata:k(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.bi.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=oE),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,i){if(!this.__loaded||!this.persistence)return w.uninitializedWarning("posthog.identify");if(yt(e)&&(e=e.toString(),w.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))w.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.');else if(e!==Qn){if(this.ps("posthog.identify")){var s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var r=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:r},"")}e!==s&&e!==this.get_property(li)&&(this.unregister(li),this.register({distinct_id:e}));var o=(this.persistence.get_property(gt)||"anonymous")==="anonymous";e!==s&&o?(this.persistence.set_property(gt,"identified"),this.setPersonPropertiesForFlags(A({},i||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:i||{}}),this.Jr=Ld(e,t,i),this.featureFlags.setAnonymousDistinctId(s)):(t||i)&&this.setPersonProperties(t,i),e!==s&&(this.reloadFeatureFlags(),this.unregister(Ls))}}else w.critical('The string "'+Qn+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else w.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var i=Ld(this.get_distinct_id(),e,t);this.Jr!==i?(this.setPersonPropertiesForFlags(A({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=i):w.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var s=this.getGroups();s[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:A({},s,{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),s[e]===t||i||this.reloadFeatureFlags()}else w.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,r;if(w.info("reset"),!this.__loaded)return w.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(i=this.sessionPersistence)==null||i.clear(),this.surveys.reset(),this.featureFlags.reset(),(s=this.persistence)==null||s.set_property(gt,"anonymous"),(r=this.sessionManager)==null||r.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Qn,$device_id:null},"");else{var a=this.config.get_device_id(Ct());this.register_once({distinct_id:a,$device_id:e?a:o},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&i){var r,o=(r=e.timestampLookBack)!==null&&r!==void 0?r:10;if(!i)return s;s+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}return s}alias(e,t){return e===this.get_property(yh)?(w.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(k(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(li,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(w.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=A({},this.config);if(he(e)){var i,s,r,o,a,l,c;ae(this.config,Kd(e));var u=this.Qr();(i=this.persistence)==null||i.update_config(this.config,t,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new vi(A({},this.config,{persistence:"sessionStorage"}),u);var h=this.Kr(this.config.debug);mt(h)&&(this.config.debug=h),mt(this.config.debug)&&(this.config.debug?(ft.DEBUG=!0,ie.H()&&ie.G("ph_debug","true"),w.info("set_config",{config:e,oldConfig:t,newConfig:A({},this.config)})):(ft.DEBUG=!1,ie.H()&&ie.V("ph_debug"))),(s=this.exceptionObserver)==null||s.onConfigChange(),(r=this.sessionRecording)==null||r.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,i={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(i).some(Boolean)){var s,r,o,a,l;(s=this.sessionManager)==null||s.checkAndGetSessionAndWindowId(),i.sampling&&((r=this.sessionRecording)==null||r.overrideSampling()),i.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),i.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)==null||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.started)}captureException(e,t){var i=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(A({},s,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:En;return t!==En&&(t=En+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(gt))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(gt))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Sn(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[li])&&((t=this.persistence)==null||(t=t.props)==null||!t[Ms]))}ds(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return this.config.person_profiles==="never"?(w.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(Ms,!0),!0)}Qr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!t}_s(){var e,t,i,s,r=this.Qr();return((e=this.persistence)==null?void 0:e.Pi)!==r&&((i=this.persistence)==null||i.set_disabled(r)),((t=this.sessionPersistence)==null?void 0:t.Pi)!==r&&((s=this.sessionPersistence)==null||s.set_disabled(r)),r}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var i,s,r;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(i=this.sessionManager)==null||i.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=new Js(this),this.pageViewManager=new qs(this),this.persistence&&(this.sessionPropsManager=new Xs(this,this.sessionManager,this.persistence)),this.sessionRecording=new Qs(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(k(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.hs()}else w.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:Qn,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(i=this.sessionRecording)==null||i.stopRecording(),this.sessionRecording=void 0,this.hs())):w.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}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===pt.GRANTED?"granted":e===pt.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return Me?Qh(Me,this.config.custom_blocked_useragents):void 0}hs(){S&&(S.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:S.title},{send_instantly:!0}),this.Gr&&(S.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),ue(S,"visibilitychange",this.Gr)))}debug(e){e===!1?(m?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(m?.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}))}M(){var e,t,i,s,r,o,a,l=this.Yr||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(w.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",s=!1,r=w,o=(t="advanced_disable_flags")in(e=l)&&!M(e[t]),a=i in e&&!M(e[i]),o?e[t]:a?(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):s)}cs(e){if(M(this.config.before_send))return e;var t=H(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),M(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return xy(e.event)?w.warn(r+". This can cause unexpected behavior."):w.info(r),null}i.properties&&!Sn(i.properties)||w.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Kr(e){var t=mt(e)&&!e,i=ie.H()&&ie.q("ph_debug")==="true";return!t&&(!!i||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=ob(n.prototype[e[t]])})(Zs,["identify"]);Yt=(zd=_i[En]=new Zs,(function(){function n(){n.done||(n.done=!0,Zh=!1,Y(_i,(function(e){e._dom_loaded()})))}S!=null&&S.addEventListener?S.readyState==="complete"?n():ue(S,"DOMContentLoaded",n,{capture:!1}):m&&w.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),zd)});var tf={};rr(tf,{Posthog:()=>dl});var Xt,dl,nf=Ue(()=>{"use strict";ef();cn();Xt=class Xt{constructor(e){this.has_initialized=!1;this.has_identified=!1;this.init=()=>{try{let{apiKey:e,api_host:t,config:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}let s={api_host:t||Qc,ui_host:Zc,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...i.session_recording},before_send:r=>{if(typeof window>"u")return null;let o=window.location.hostname;return o==="localhost"||o==="127.0.0.1"||no.some(l=>o.endsWith(`.${l}`)||o===l)?r:null},...i};Yt.init(e,s),this.has_initialized=!0}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let i=typeof Yt._isIdentified=="function"?Yt._isIdentified():this.has_identified;e&&!i&&(Yt.identify(e,{...t,client_id:e}),this.has_identified=!0)}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{Yt.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.capture=(e,t)=>{if(this.has_initialized)try{Yt.capture(e,t)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.options=e,this.init()}};Xt.getPosthogInstance=e=>(Xt._instance||(Xt._instance=new Xt(e)),Xt._instance);dl=Xt});var gE={};rr(gE,{Analytics:()=>sf,cacheTrackEvents:()=>ir});to();cn();var Rm=2*365*24*60*60,Vt=class Vt{constructor(e,t){this.analytics=new on;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let t=window.location.hostname,r=["webflow.io"].some(c=>t.endsWith(c))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let c=new Uint8Array(16);crypto.getRandomValues(c),c[6]=c[6]&15|64,c[8]=c[8]&63|128;let 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=${Rm}; SameSite=Lax${l}`}catch(t){console.warn("RudderStack: Failed to set anonymous ID cookie",t)}};this.getUserId=()=>this.analytics.getUserId();this.init=e=>{if(!e){console.warn("RudderStack: Initialization skipped - no key provided");return}try{this.setCookieIfNotExists(),this.analytics.load(e,Jc,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.onLoadedCallback?.()}})}catch(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let i=this.getUserId();if(!i||i!==e)try{this.analytics.identify(e,t||{}),this.has_identified=!0}catch(s){console.error("RudderStack: Failed to identify user",s)}else this.has_identified=!0};this.pageView=(e,t="Deriv App",i,s)=>{if(!(!this.has_initialized||e===this.current_page))try{let r={...i&&{user_id:i},...s};this.analytics.page(t,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.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,t)=>{if(this.has_initialized)try{this.analytics.track(e,t)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=t,this.init(e)}};Vt.getRudderStackInstance=(e,t)=>(Vt._instance||(Vt._instance=new Vt(e,t)),Vt._instance);var is=Vt;function ss(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)n[i]=t[i]}return n}var Om={read:function(n){return n[0]==='"'&&(n=n.slice(1,-1)),n.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(n){return encodeURIComponent(n).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function io(n,e){function t(s,r,o){if(!(typeof document>"u")){o=ss({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),s=encodeURIComponent(s).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=s+"="+n.write(r,s)+a}}function i(s){if(!(typeof document>"u"||arguments.length&&!s)){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(o[u]=n.read(c,u),s===u)break}catch{}}return s?o[s]:o}}return Object.create({set:t,get:i,remove:function(s,r){t(s,"",ss({},r,{expires:-1}))},withAttributes:function(s){return io(this.converter,ss({},this.attributes,s))},withConverter:function(s){return io(ss({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(n)}})}var Xe=io(Om,{path:"/"});cn();var rs="cached_analytics_events",os="cached_analytics_page_views",eu=(n,e)=>{try{let t=jn(),i=Xe.get(rs),s=i?JSON.parse(i):[];s.push({name:n,properties:e,timestamp:Date.now()});let r={expires:1};t&&(r.domain=t),Xe.set(rs,JSON.stringify(s),r)}catch(t){console.warn("Analytics: Failed to cache event",t)}},tu=(n,e)=>{try{let t=jn(),i=Xe.get(os),s=i?JSON.parse(i):[];s.push({name:n,properties:e,timestamp:Date.now()});let r={expires:1};t&&(r.domain=t),Xe.set(os,JSON.stringify(s),r)}catch(t){console.warn("Analytics: Failed to cache page view",t)}},nu=()=>{try{let n=Xe.get(rs);if(n){let e=JSON.parse(n);return Array.isArray(e)?e:[]}}catch(n){console.warn("Analytics: Failed to get cached events",n)}return[]},iu=()=>{try{let n=Xe.get(os);if(n){let e=JSON.parse(n);return Array.isArray(e)?e:[]}}catch(n){console.warn("Analytics: Failed to get cached pages",n)}return[]},su=()=>{let n=jn(),e=n?{domain:n}:{};Xe.remove(rs,e)},ru=()=>{let n=jn(),e=n?{domain:n}:{};Xe.remove(os,e)};cn();var Hn=n=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n),as=null,ou=async()=>{if(as)return as;let n=JSON.parse(Xe.get("website_status")||"{}")?.clients_country;return as=(async()=>{try{let e=await fetch(Yc).catch(()=>null);if(!e)return n||"";let t=await e.text().catch(()=>"");return t?Object.fromEntries(t.split(`
|
|
17
|
-
`).map(s=>s.split("=",2))).loc?.toLowerCase()||n||"":n||""}catch{return n||""}})(),as},un=n=>{if(n==null||typeof n!="object")return n;if(Array.isArray(n)){let t=n.map(un).filter(i=>i!=null);return t.length?t:void 0}let e={};return Object.entries(n).forEach(([t,i])=>{let s=un(i);s==null||s===""||typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length===0||Array.isArray(s)&&s.length===0||(e[t]=s)}),Object.keys(e).length?e:void 0},so=n=>{if(n==null||typeof n!="object"||Array.isArray(n))return n;let e={};return Object.entries(n).forEach(([t,i])=>{i&&typeof i=="object"&&!Array.isArray(i)?Object.assign(e,so(i)):e[t]=i}),e};function fE(n){let e,t,i,s={},r={},o=[],a=[],l=!1,c=()=>{if(!l&&t?.has_initialized){l=!0;try{let R=nu();R.length>0&&(R.forEach(U=>{t?.track(U.name,U.properties)}),su());let $=iu();$.length>0&&($.forEach(U=>{t?.pageView(U.name,"Deriv App",b(),U.properties)}),ru())}catch(R){console.warn("Analytics: Failed to process cookie cache",R)}}},u=()=>{c(),a.forEach(({userId:R,traits:$})=>{R&&t?.identifyEvent(R,$)}),a=[]},h=async({growthbookKey:R,growthbookDecryptionKey:$,rudderstackKey:U,growthbookOptions:L,posthogOptions:le})=>{var se,Z;try{let ce=L?.attributes?.country||(R?await ou():void 0);if(U&&(t=is.getRudderStackInstance(U,u)),L?.attributes&&Object.keys(L.attributes).length>0){let D=L.attributes,xe=t?.getAnonymousId();s={...s,country:ce,...D.user_language&&{user_language:D.user_language},...D.account_type&&{account_type:D.account_type},...D.app_id&&{app_id:D.app_id},...D.residence_country&&{residence_country:D.residence_country},...D.device_type&&{device_type:D.device_type},...D.url&&{url:D.url},...D.email_hash&&{email_hash:D.email_hash},...D.network_type&&{network_type:D.network_type},...D.network_rtt&&{network_rtt:D.network_rtt},...D.network_downlink&&{network_downlink:D.network_downlink},...D.account_currency&&{account_currency:D.account_currency},...D.account_mode&&{account_mode:D.account_mode},loggedIn:!!D.loggedIn,...D.user_id&&!Hn(D.user_id)&&{user_id:D.user_id},...xe&&{anonymous_id:xe}}}L??(L={}),L.attributes??(L.attributes={});let ke=t?.getAnonymousId();if((se=L.attributes).id??(se.id=ke),(Z=L.attributes).country??(Z.country=ce),R){let{Growthbook:D}=await Promise.resolve().then(()=>(Qu(),Ju));e=D.getGrowthBookInstance(R,$,L);let xe=setInterval(()=>{Object.keys(r).length>0?clearInterval(xe):r=p("tracking-buttons-config",{})},1e3)}if(le){let{Posthog:D}=await Promise.resolve().then(()=>(nf(),tf));i=D.getPosthogInstance(le)}}catch(ce){console.warn("Analytics: Failed to initialize",ce)}},g=({country:R,user_language:$,device_language:U,device_type:L,account_type:le,user_id:se,anonymous_id:Z,app_id:ce,utm_source:ke,utm_medium:D,utm_campaign:xe,is_authorised:pe,residence_country:Se,url:ve,domain:bt,geo_location:qe,loggedIn:Nn,network_downlink:Ii,network_rtt:Ri,network_type:Ke,account_currency:Oi,account_mode:Dn})=>{let xt=se??b();if(e){let Jt={country:R,residence_country:Se,user_language:$,device_language:U,device_type:L,utm_source:ke,utm_medium:D,utm_campaign:xe,is_authorised:pe,url:ve,domain:bt,loggedIn:Nn,...se&&!Hn(se)&&{user_id:se},anonymous_id:Z};xt&&(Jt.id=xt,Jt.user_id=xt),e.setAttributes(Jt)}s={...s,...R!==void 0&&{country:R},...qe!==void 0&&{geo_location:qe},...$!==void 0&&{user_language:$},...le!==void 0&&{account_type:le},...ce!==void 0&&{app_id:ce},...Se!==void 0&&{residence_country:Se},...L!==void 0&&{device_type:L},...ve!==void 0&&{url:ve},...Nn!==void 0&&{loggedIn:Nn},...Ii!==void 0&&{network_downlink:Ii},...Ri!==void 0&&{network_rtt:Ri},...Ke!==void 0&&{network_type:Ke},...se!==void 0&&!Hn(se)&&{user_id:se},...Z!==void 0&&{anonymous_id:Z},...Oi!==void 0&&{account_currency:Oi},...Dn!==void 0&&{account_mode:Dn}}},f=R=>e?.getFeatureState(R)?.experimentResult?.name,p=(R,$)=>e?.getFeatureValue(R,$),v=async()=>await e?.getStatus(),_=R=>e?.isOn(R),E=R=>e?.setUrl(R),b=()=>{let R=t?.getUserId()||"";return R&&!Hn(R)?R:""},C=()=>t?.getAnonymousId()||"",N=(R,$="Deriv App",U)=>{let L=b();t&&(t.has_initialized?t.pageView(R,$,L,U):tu(R,{platform:$,...U}))},I=(R,$)=>{let U=R||b();if(!U)return;let L=$?.rudderstack!==void 0||$?.posthog!==void 0,le=L?$?.rudderstack:$,se=L?$?.posthog:$;t&&(t.has_initialized?t.identifyEvent(U,le):a.some(Z=>Z.userId===U)||a.push({userId:U,traits:le})),i?.has_initialized&&i.identifyEvent(U,se)},K=()=>{t?.has_initialized&&t.reset(),i?.has_initialized&&i.reset()},B=R=>"event_metadata"in R||"cta_information"in R||"error"in R,de={initialise:h,setAttributes:g,identifyEvent:I,getFeatureState:f,getFeatureValue:p,getGrowthbookStatus:v,isFeatureOn:_,setUrl:E,getId:b,getAnonymousId:C,trackEvent:(R,$)=>{let U=b(),L={};if(B($)){let Z=$;L={...Z,event_metadata:{...s,...U&&!s.user_id&&{user_id:U},...Z.event_metadata}}}else L={...s,...$,...U&&!s.user_id&&{user_id:U}};if(!(!(R in r)||r[R]))return;let se=t?.has_initialized;if(!navigator.onLine||!se)se?o.push({event:R,payload:L}):eu(R,L);else{o.length>0&&(o.forEach(ce=>{let ke=un(ce.payload);t?.track(ce.event,ke)}),o=[]);let Z=un(L);t?.track(R,Z)}if(i?.has_initialized){let Z=so(L),ce=un(Z);i.capture(R,ce)}},getInstances:()=>({ab:e,tracking:t,posthog:i}),pageView:N,reset:K};return typeof window<"u"&&(window.AnalyticsInstance=de),de}var sf=fE();var hl=class{constructor(){this.interval=null;this.responses=[];this.isTrackingResponses=!1;this.delegatedSelectors=new Set;this.addEventhandler=this.addEventHandler.bind(this)}hash(e,t=32){let i=a=>{let l=2166136261;for(let c=0;c<a.length;c++)l^=a.charCodeAt(c),l=l*16777619>>>0;return l.toString(16)},s=a=>btoa(a),r=i(e),o=s(r);for(;o.length<t;)o+=s(i(o));return o.substring(0,t)}getCookies(e){let i=`; ${document.cookie}`.split(`; ${e}=`);if(i.length===2){let s=decodeURIComponent(i.pop().split(";").shift());try{return JSON.parse(s)}catch{return s}}return null}trackPageUnload(){typeof window>"u"||window.addEventListener("beforeunload",()=>{this.isPageViewSent()||this.push("cached_analytics_page_views",{name:window.location.href,properties:{url:window.location.href}})})}trackResponses(){if(typeof window>"u"||typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(i,s){return this._url=s,this._method=i,e.apply(this,arguments)},XMLHttpRequest.prototype.send=function(i){return this.addEventListener("load",function(){let s=null;if(typeof i=="string")try{s=JSON.parse(i)}catch{s=i}let r={url:this._url,method:this._method,status:this.status,headers:this.getAllResponseHeaders(),data:this.responseText,payload:s};ir.responses.push(r)}),t.apply(this,arguments)},this.isTrackingResponses=!0}isReady(){if(typeof window>"u")return!1;let e=window.Analytics;return typeof e>"u"||e===null?!1:!!e.Analytics?.getInstances?.()?.tracking}parseCookies(e){if(typeof document>"u")return null;let t=document.cookie.split("; ").reduce((i,s)=>{let[r,o]=s.split("=");return r&&o&&(i[decodeURIComponent(r)]=decodeURIComponent(o)),i},{});try{return t[e]?JSON.parse(t[e]):null}catch{return null}}isPageViewSent(){return!!this.responses.find(e=>e.payload?.type==="page"&&e.payload?.anonymousId)}set(e){this.push("cached_analytics_events",e)}push(e,t){if(typeof document>"u")return;let i=[],s=this.parseCookies(e);s&&Array.isArray(s)&&(i=s),i.push(t);let r=this.getAllowedDomain(),o=365*24*60*60,a=`${e}=${encodeURIComponent(JSON.stringify(i))}; path=/; Domain=${r}; max-age=${o}; SameSite=Lax`;document.cookie=a}getAllowedDomain(){if(typeof window>"u")return"";let e=window.location.hostname;if(e==="localhost"||/^\d+\.\d+\.\d+\.\d+$/.test(e))return e;let t=e.split(".");return t.length===1?e:`.${t.slice(-2).join(".")}`}processEvent(e){let t=this.getCookies("client_information");if(t){let{email:i=null}=t;i&&(e.properties.email_hash=this.hash(i))}if(e?.properties?.email){let i=e.properties.email;delete e.properties.email,e.properties.email_hash=this.hash(i)}return e}track(e,t=!1){if(typeof window>"u")return;let i=this.processEvent(e),s=window.Analytics;this.isReady()&&!t?s.Analytics.trackEvent(i.name,i.properties):this.set(i)}pageView(){typeof window>"u"||(this.isTrackingResponses||(this.trackResponses(),this.trackPageUnload()),this.interval=setInterval(()=>{let e=window.Analytics;typeof e<"u"&&typeof e.Analytics?.pageView=="function"&&this.isReady()&&e.Analytics.pageView(window.location.href,"Trader's hub"),this.isPageViewSent()&&this.interval&&clearInterval(this.interval)},1e3))}listen(e,{name:t="",properties:i={}},s=!1,r=null){let o=l=>{l.dataset?.clickEventTracking||(l.addEventListener("click",c=>{let u={name:t,properties:i,cache:s};if(typeof r=="function"){let h=r(c);u={...h,cache:h.cache??s}}this.track(u,u.cache??!1)}),l.dataset.clickEventTracking="true")};(e instanceof NodeList?Array.from(e):[e]).forEach(o)}addEventHandler(e){return typeof window>"u"?this:(e.forEach(({element:t,event:i={name:"",properties:{}},cache:s=!1,callback:r=null})=>{if(typeof t=="string"){let o=t;if(!this.delegatedSelectors.has(o)){let a=l=>{let c=l.target;if(!c)return;let u=c.closest(o);if(u&&!u.dataset?.clickEventTracking){let h={name:i.name,properties:i.properties,cache:s};if(typeof r=="function"){let g=r(l);h={...g,cache:g.cache??s}}u.dataset.clickEventTracking="true",this.track(h,h.cache??!1)}};document.addEventListener("click",a),this.delegatedSelectors.add(o)}}else(t instanceof NodeList?Array.from(t):[t]).forEach(a=>{a&&!a.dataset?.clickEventTracking&&this.listen(a,i,s,r)})}),this)}loadEvent(e){return e.forEach(({event:t})=>{let{name:i,properties:s}=t;this.track({name:i,properties:s})}),this}pageLoadEvent(e){if(typeof window>"u")return this;let t=window.location.pathname.slice(1);return e.forEach(({pages:i=[],excludedPages:s=[],event:r,callback:o=null})=>{let a=!1;if(i.length?i.includes(t)&&(a=!0):s.length&&s.includes(t)||(a=!0),a){let l=o?o():r;this.loadEvent([{event:l}])}}),this}clearInterval(){this.interval&&(clearInterval(this.interval),this.interval=null)}cleanup(){this.clearInterval(),this.responses=[],this.isTrackingResponses=!1}},ir=new hl;typeof window<"u"&&(window.cacheTrackEvents=ir);return uf(gE);})();
|
|
17
|
+
`)).length,n=0;n<r;n++){var o=i.charCodeAt(n),a=null;o<128?t++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Ze(a)||(t>e&&(s+=i.substring(e,t)),s+=a,e=t=n+1)}return t>e&&(s+=i.substring(e,i.length)),s},sE=!!Qo||!!Jo,Gd="text/plain",ts=function(i,e,t){var r;t===void 0&&(t=!0);var[n,s]=i.split("?"),o=T({},e),a=(r=s?.split("&").map((c=>{var u,[h,g]=c.split("="),f=t&&(u=o[h])!==null&&u!==void 0?u:g;return delete o[h],h+"="+f})))!==null&&r!==void 0?r:[],l=Db(o);return l&&a.push(l),n+"?"+a.join("&")},br=(i,e)=>JSON.stringify(i,((t,r)=>typeof r=="bigint"?r.toString():r),e),jo=i=>{var{data:e,compression:t}=i;if(e){if(t===yt.GZipJS){var r=rE((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var h=new We(l.length+(l.length>>>1)),g=0,f=function(b){h[g++]=b},p=0;p<u;++p){if(g+5>h.length){var v=new We(g+8+(u-p<<1));v.set(h),h=v}var _=l.charCodeAt(p);_<128||c?f(_):_<2048?(f(192|_>>>6),f(128|63&_)):_>55295&&_<57344?(f(240|(_=65536+(1047552&_)|1023&l.charCodeAt(++p))>>>18),f(128|_>>>12&63),f(128|_>>>6&63),f(128|63&_)):(f(224|_>>>12),f(128|_>>>6&63),f(128|63&_))}return rf(h,0,g)})(br(e)),{mtime:0}),n=new Blob([r],{type:Gd});return{contentType:Gd,body:n,estimatedSize:n.size}}if(t===yt.Base64){var s=(function(l){var c,u,h,g,f,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,_=0,b="",E=[];if(!l)return l;l=nE(l);do c=(f=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=f>>12&63,h=f>>6&63,g=63&f,E[_++]=p.charAt(c)+p.charAt(u)+p.charAt(h)+p.charAt(g);while(v<l.length);switch(b=E.join(""),l.length%3){case 1:b=b.slice(0,-2)+"==";break;case 2:b=b.slice(0,-1)+"="}return b})(br(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:br(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=br(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Fn=[];Jo&&Fn.push({transport:"fetch",method:i=>{var e,t,{contentType:r,body:n,estimatedSize:s}=(e=jo(i))!==null&&e!==void 0?e:{},o=new Headers;J(i.headers,(function(u,h){o.append(h,u)})),r&&o.append("Content-Type",r);var a=i.url,l=null;if(ld){var c=new ld;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),i.timeout)}}Jo(a,T({method:i?.method||"GET",headers:o,keepalive:i.method==="POST"&&(s||0)<52428.8,body:n,signal:(t=l)==null?void 0:t.signal},i.fetchOptions)).then((u=>u.text().then((h=>{var g={statusCode:u.status,text:h};if(u.status===200)try{g.json=JSON.parse(h)}catch(f){w.error(f)}i.callback==null||i.callback(g)})))).catch((u=>{w.error(u),i.callback==null||i.callback({statusCode:0,error:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Qo&&Fn.push({transport:"XHR",method:i=>{var e,t=new Qo;t.open(i.method||"GET",i.url,!0);var{contentType:r,body:n}=(e=jo(i))!==null&&e!==void 0?e:{};J(i.headers,(function(s,o){t.setRequestHeader(o,s)})),r&&t.setRequestHeader("Content-Type",r),i.timeout&&(t.timeout=i.timeout),i.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var s={statusCode:t.status,text:t.responseText};if(t.status===200)try{s.json=JSON.parse(t.responseText)}catch{}i.callback==null||i.callback(s)}},t.send(n)}}),Ve!=null&&Ve.sendBeacon&&Fn.push({transport:"sendBeacon",method:i=>{var e=ts(i.url,{beacon:"1"});try{var t,{contentType:r,body:n}=(t=jo(i))!==null&&t!==void 0?t:{},s=typeof n=="string"?new Blob([n],{type:r}):n;Ve.sendBeacon(e,s)}catch{}}});is=function(i,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(i)}catch{return!1}};nf={exact:(i,e)=>e.some((t=>i.some((r=>t===r)))),is_not:(i,e)=>e.every((t=>i.every((r=>t!==r)))),regex:(i,e)=>e.some((t=>i.some((r=>is(t,r))))),not_regex:(i,e)=>e.every((t=>i.every((r=>!is(t,r))))),icontains:(i,e)=>e.map(Ln).some((t=>i.map(Ln).some((r=>t.includes(r))))),not_icontains:(i,e)=>e.map(Ln).every((t=>i.map(Ln).every((r=>!t.includes(r))))),gt:(i,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&i.some((n=>r>parseFloat(n)))})),lt:(i,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&i.some((n=>r<parseFloat(n)))}))},Ln=i=>i.toLowerCase();Ho=oe("[Error tracking]"),Ga=class{constructor(e){var t,r;this.Zt=[],this.ti=new oa([new la,new pa,new ua,new ca,new fa,new ha,new da,new ga],gb()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(_a))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,r,n;if("errorTracking"in e){var s=(t=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&t!==void 0?t:[],o=(n=e.errorTracking)==null?void 0:n.captureExtensionExceptions;this.Zt=s,this._instance.persistence&&this._instance.persistence.register({[_a]:this.Zt,[Ed]:o})}}get ii(){var e,t=!!this._instance.get_property(Ed),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void Ho.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void Ho.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void Ho.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",oi:!0})}ri(e){if(e.length===0)return!1;var t=e.reduce(((r,n)=>{var{type:s,value:o}=n;return ue(s)&&s.length>0&&r.$exception_types.push(s),ue(o)&&o.length>0&&r.$exception_values.push(o),r}),{$exception_types:[],$exception_values:[]});return this.Zt.some((r=>{var n=r.values.map((s=>{var o,a=nf[s.operator],l=j(s.value)?s.value:[s.value],c=(o=t[s.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)}));return r.type==="OR"?n.some(Boolean):n.every(Boolean)}))}si(e){return e.flatMap((t=>{var r,n;return(r=(n=t.stacktrace)==null?void 0:n.frames)!==null&&r!==void 0?r:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ni(e){if(e.length>0){var t,r,n,s,o=(t=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(n=a==null||(s=a.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&n!==void 0&&n}return!1}ei(e){return!U(e)&&j(e)}},Be=oe("[FeatureFlags]"),dr=oe("[FeatureFlags]",{debugEnabled:!0}),oE="errors_while_computing_flags",aE="flag_missing",lE="quota_limited",cE="timeout",uE="connection_error",dE="unknown_error",hE=i=>"api_error_"+i,qo="$active_feature_flags",Ai="$override_feature_flags",Hd="$feature_flag_payloads",hr="$override_feature_flag_payloads",qd="$feature_flag_request_id",zd="$feature_flag_evaluated_at",Kd=i=>{var e={};for(var[t,r]of Mn(i||{}))r&&(e[t]=r);return e},fE=i=>{var e=i.flags;return e?(i.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var r;return[t,(r=e[t].variant)!==null&&r!==void 0?r:e[t].enabled]}))),i.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var r;return(r=e[t].metadata)==null?void 0:r.payload})).map((t=>{var r;return[t,(r=e[t].metadata)==null?void 0:r.payload]})))):Be.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),i},gE=(function(i){return i.FeatureFlags="feature_flags",i.Recordings="recordings",i})({}),ja=class{constructor(e){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(Be.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter((r=>{var n=r&&typeof r=="string"&&r.trim().length>0;return n||Be.error("Invalid evaluation context found:",r,"Expected non-empty string"),n})):[]}pi(){return this.fi().length>0}get hasLoadedFlags(){return this.li}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(ma),t=this._instance.get_property(Ai),r=this._instance.get_property(hr);if(!r&&!t)return e||{};var n=le({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of s){var a,l,c=n[o],u=t?.[o],h=S(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,g=S(u)?c.variant:typeof u=="string"?u:void 0,f=r?.[o],p=T({},c,{enabled:h,variant:h?g??c?.variant:void 0});h!==c?.enabled&&(p.original_enabled=c?.enabled),g!==c?.variant&&(p.original_variant=c?.variant),f&&(p.metadata=T({},c?.metadata,{payload:f,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),n[o]=p}return this.ai||(Be.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:n}),this.ai=!0),n}getFlagVariants(){var e=this._instance.get_property(Pi),t=this._instance.get_property(Ai);if(!t)return e||{};for(var r=le({},e),n=Object.keys(t),s=0;s<n.length;s++)r[n[s]]=t[n[s]];return this.ai||(Be.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.ai=!0),r}getFlagPayloads(){var e=this._instance.get_property(Hd),t=this._instance.get_property(hr);if(!t)return e||{};for(var r=le({},e||{}),n=Object.keys(t),s=0;s<n.length;s++)r[n[s]]=t[n[s]];return this.ai||(Be.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:r}),this.ai=!0),r}reloadFeatureFlags(){this.hi||this._instance.config.advanced_disable_feature_flags||this.gi||(this._instance.mi.emit("featureFlagsReloading",!0),this.gi=setTimeout((()=>{this.bi()}),5))}yi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.li||this.ui||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.hi=e}bi(e){var t;if(this.yi(),!this._instance.M())if(this.ui)this.di=!0;else{var r=this._instance.config.token,n=this._instance.get_property("$device_id"),s={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:T({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(yr)||{}),group_properties:this._instance.get_property(Yt),timezone:Qh()};Ze(n)||S(n)||(s.$device_id=n),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.pi()&&(s.evaluation_contexts=this.fi());var o=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",a=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+o);this.ui=!0,this._instance._send_request({method:"POST",url:a,data:s,compression:this._instance.config.disable_compression?void 0:yt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:l=>{var c,u,h,g=!0;if(l.statusCode===200&&(this.di||(this.$anon_distinct_id=void 0),g=!1),this.ui=!1,!s.disable_flags||this.di){this.vi=!g;var f=[];l.error?l.error instanceof Error?f.push(l.error.name==="AbortError"?cE:uE):f.push(dE):l.statusCode!==200&&f.push(hE(l.statusCode)),(c=l.json)!=null&&c.errorsWhileComputingFlags&&f.push(oE);var p=!((u=l.json)==null||(u=u.quotaLimited)==null||!u.includes(gE.FeatureFlags));if(p&&f.push(lE),(h=this._instance.persistence)==null||h.register({[ba]:f}),p)Be.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.");else{var v;s.disable_flags||this.receivedFeatureFlags((v=l.json)!==null&&v!==void 0?v:{},g),this.di&&(this.di=!1,this.bi())}}}})}}getFeatureFlag(e,t){var r;if(t===void 0&&(t={}),!t.fresh||this.vi){if(this.li||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlagResult(e,t);return(r=n?.variant)!==null&&r!==void 0?r:n?.enabled}Be.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.vi)if(this.li||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants(),n=e in r,s=r[e],o=this.getFlagPayloads()[e],a=String(s),l=this._instance.get_property(qd)||void 0,c=this._instance.get_property(zd)||void 0,u=this._instance.get_property(jn)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var h,g,f,p,v,_,b,E,D,N;j(u[e])?u[e].push(a):u[e]=[a],(h=this._instance.persistence)==null||h.register({[jn]:u});var R=this.getFeatureFlagDetails(e),K=[...(g=this._instance.get_property(ba))!==null&&g!==void 0?g:[]];S(s)&&K.push(aE);var B={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((f=this._instance.config.bootstrap)==null||(f=f.featureFlags)==null?void 0:f[e])||null,$feature_flag_bootstrapped_payload:((p=this._instance.config.bootstrap)==null||(p=p.featureFlagPayloads)==null?void 0:p[e])||null,$used_bootstrap_value:!this.vi};S(R==null||(v=R.metadata)==null?void 0:v.version)||(B.$feature_flag_version=R.metadata.version);var C,pe=(_=R==null||(b=R.reason)==null?void 0:b.description)!==null&&_!==void 0?_:R==null||(E=R.reason)==null?void 0:E.code;pe&&(B.$feature_flag_reason=pe),R!=null&&(D=R.metadata)!=null&&D.id&&(B.$feature_flag_id=R.metadata.id),S(R?.original_variant)&&S(R?.original_enabled)||(B.$feature_flag_original_response=S(R.original_variant)?R.original_enabled:R.original_variant),R!=null&&(N=R.metadata)!=null&&N.original_payload&&(B.$feature_flag_original_payload=R==null||(C=R.metadata)==null?void 0:C.original_payload),K.length&&(B.$feature_flag_error=K.join(",")),this._instance.capture("$feature_flag_called",B)}if(n){var ve=o;if(!S(o))try{ve=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:ve}}}else Be.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var r=this._instance.config.token,n={distinct_id:this._instance.get_distinct_id(),token:r};this.pi()&&(n.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:n,compression:this._instance.config.disable_compression?void 0:yt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.vi){if(this.li||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,t);return S(r)?void 0:!!r}Be.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this.li=!0;var r=this.getFlagVariants(),n=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var h=fE(o),g=h.flags,f=h.featureFlags,p=h.featureFlagPayloads;if(f){var v=o.requestId,_=o.evaluatedAt;if(j(f)){Be.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var b={};if(f)for(var E=0;E<f.length;E++)b[f[E]]=!0;a&&a.register({[qo]:f,[Pi]:b})}else{var D=f,N=p,R=g;if(o.errorsWhileComputingFlags)if(g){var K=new Set(Object.keys(g).filter((B=>{var C;return!((C=g[B])!=null&&C.failed)})));D=T({},l,Object.fromEntries(Object.entries(D).filter((B=>{var[C]=B;return K.has(C)})))),N=T({},c,Object.fromEntries(Object.entries(N||{}).filter((B=>{var[C]=B;return K.has(C)})))),R=T({},u,Object.fromEntries(Object.entries(R||{}).filter((B=>{var[C]=B;return K.has(C)}))))}else D=T({},l,D),N=T({},c,N),R=T({},u,R);a&&a.register(T({[qo]:Object.keys(Kd(D)),[Pi]:D||{},[Hd]:N||{},[ma]:R||{}},v?{[qd]:v}:{},_?{[zd]:_}:{}))}}})(e,this._instance.persistence,r,n,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),Be.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return Be.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Ai),this._instance.persistence.unregister(hr),this.wi(),dr.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,r=e;if(this.ai=!!((t=r.suppressWarning)!==null&&t!==void 0&&t),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(Ai),dr.info("Flag overrides cleared");else if(r.flags){if(j(r.flags)){for(var n={},s=0;s<r.flags.length;s++)n[r.flags[s]]=!0;this._instance.persistence.register({[Ai]:n})}else this._instance.persistence.register({[Ai]:r.flags});dr.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(hr),dr.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[hr]:r.payloads}),dr.info("Payload overrides set",{payloads:r.payloads}))),void this.wi()}this.wi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.li){var{flags:t,flagVariants:r}=this.xi();e(t,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var n,s=(this._instance.get_property(mr)||[]).find((c=>c.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};s&&(a.$early_access_feature_name=s.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=T({},this.getFlagVariants(),{[e]:t});(n=this._instance.persistence)==null||n.register({[qo]:Object.keys(Kd(l)),[Pi]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var n=this._instance.get_property(mr),s=r?"&"+r.map((o=>"stage="+o)).join("&"):"";if(n&&!t)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:o=>{var a,l;if(o.json){var c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(mr),(l=this._instance.persistence)==null||l.register({[mr]:c}),e(c)}}})}xi(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((r=>t[r])),flagVariants:Object.keys(t).filter((r=>t[r])).reduce(((r,n)=>(r[n]=t[n],r)),{})}}wi(e){var{flags:t,flagVariants:r}=this.xi();this.featureFlagEventHandlers.forEach((n=>n(t,r,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(yr)||{};this._instance.register({[yr]:T({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(yr)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(Yt)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((n=>{r[n]=T({},r[n],e[n]),delete e[n]})),this._instance.register({[Yt]:T({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Yt)||{};this._instance.register({[Yt]:T({},t,{[e]:{}})})}else this._instance.unregister(Yt)}reset(){this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.yi(),this.ai=!1}},pE=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],wr=class{constructor(e,t){this.R=e,this.props={},this.$i=!1,this.Ei=(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"})(e),this.Y=this.Si(e),this.load(),e.debug&&w.info("Persistence loaded",e.persistence,T({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){pE.indexOf(e.persistence.toLowerCase())===-1&&(w.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(n){n===void 0&&(n=[]);var s=[...Ub,...n];return T({},se,{W:function(o){try{var a={};try{a=ot.W(o)||{}}catch{}var l=le(a,JSON.parse(se.q(o)||"{}"));return se.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,h){try{se.G(o,a,void 0,void 0,h);var g={};s.forEach((f=>{a[f]&&(g[f]=a[f])})),Object.keys(g).length&&ot.G(o,g,l,c,u,h)}catch(f){se.B(f)}},V:function(o,a){try{m?.localStorage.removeItem(o),ot.V(o,a)}catch(l){se.B(l)}}})})(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&se.H()?se:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&ye.H()?ye:r==="memory"?Bb:r==="cookie"?ot:t.H()?t:ot}properties(){var e={};return J(this.props,(function(t,r){if(r===Pi&&fe(t))for(var n=Object.keys(t),s=0;s<n.length;s++)e["$feature/"+n[s]]=t[n[s]];else a=r,l=!1,(Ze(o=kb)?l:ad&&o.indexOf===ad?o.indexOf(a)!=-1:(J(o,(function(c){if(l||(l=c===a))return Vn})),l))||(e[r]=t);var o,a,l})),e}load(){if(!this.ki){var e=this.Y.W(this.Ei);e&&(this.props=le({},e))}}save(){this.ki||this.Y.G(this.Ei,this.props,this.Pi,this.Ti,this.Ii,this.R.debug)}remove(){this.Y.V(this.Ei,!1),this.Y.V(this.Ei,!0)}clear(){this.remove(),this.props={}}register_once(e,t,r){if(fe(e)){S(t)&&(t="None"),this.Pi=S(r)?this.Ci:r;var n=!1;if(J(e,((s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=s,n=!0)})),n)return this.save(),!0}return!1}register(e,t){if(fe(e)){this.Pi=S(t)?this.Ci:t;var r=!1;if(J(e,((n,s)=>{e.hasOwnProperty(s)&&this.props[s]!==n&&(this.props[s]=n,r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.$i){var e=zh(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);Ci(gl(e))||this.register(e),this.$i=!0}}update_search_keyword(){var e;this.register((e=k?.referrer)?Wh(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Yh(),$referring_domain:k!=null&&k.referrer&&((e=Wn(k.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Sa]||this.props[wa]||this.register_once({[Hn]:Xh(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};J([wa,Sa],(o=>{var a=this.props[o];a&&J(a,(function(l,c){e["$initial_"+Zo(c)]=l}))}));var t,r,n=this.props[Hn];if(n){var s=(t=Jh(n),r={},J(t,(function(o,a){r["$initial_"+Zo(a)]=o})),r);le(e,s)}return e}safe_merge(e){return J(this.props,(function(t,r){r in e||(e[r]=t)})),e}update_config(e,t,r){if(this.Ci=this.Pi=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((u,h)=>u===c[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var n=this.Si(e),s=this.props;this.clear(),this.Y=n,this.props=s,this.save()}}set_disabled(e){this.ki=e,this.ki?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ti&&(this.Ti=e,this.remove(),this.save())}set_secure(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_event_timer(e,t){var r=this.props[_r]||{};r[e]=t,this.props[_r]=r,this.save()}remove_event_timer(e){var t=(this.props[_r]||{})[e];return S(t)||(delete this.props[_r][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},Wd=oe("[Product Tours]"),zo="ph_product_tours",Ha=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){"productTours"in e&&(this._instance.persistence&&this._instance.persistence.register({[Sd]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this.Ri||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Sd)||this.it((()=>this.Oi()))}it(e){var t,r;(t=O.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",(n=>{n?Wd.error("Could not load product tours script",n):e()}))}Oi(){var e;!this.Ri&&(e=O.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=O.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!j(this.Fi)||t){var r=this._instance.persistence;if(r){var n=r.props[zo];if(j(n)&&!t)return this.Fi=n,void e(n,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:s=>{var o=s.statusCode;if(o!==200||!s.json){var a="Product Tours API could not be loaded, status: "+o;return Wd.error(a),void e([],{isLoaded:!1,error:a})}var l=j(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[zo]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){U(this.Ri)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ri.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ri)==null||t.showTourById(e)}previewTour(e){this.Ri?this.Ri.previewTour(e):this.it((()=>{var t;this.Oi(),(t=this.Ri)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Ri)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Ri)==null||e.nextStep()}previousStep(){var e;(e=this.Ri)==null||e.previousStep()}clearCache(){var e;this.Fi=null,(e=this._instance.persistence)==null||e.unregister(zo)}resetTour(e){var t;(t=this.Ri)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ri)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ri)==null||t.cancelPendingTour(e)}},fr=(function(i){return i.Activation="events",i.Cancellation="cancelEvents",i})({}),hk=(function(i){return i.Button="button",i.Tab="tab",i.Selector="selector",i})({}),fk=(function(i){return i.TopLeft="top_left",i.TopRight="top_right",i.TopCenter="top_center",i.MiddleLeft="middle_left",i.MiddleRight="middle_right",i.MiddleCenter="middle_center",i.Left="left",i.Center="center",i.Right="right",i.NextToTrigger="next_to_trigger",i})({}),gk=(function(i){return i.Top="top",i.Left="left",i.Right="right",i.Bottom="bottom",i})({}),Ko=(function(i){return i.Popover="popover",i.API="api",i.Widget="widget",i.ExternalSurvey="external_survey",i})({}),pk=(function(i){return i.Open="open",i.MultipleChoice="multiple_choice",i.SingleChoice="single_choice",i.Rating="rating",i.Link="link",i})({}),vk=(function(i){return i.NextQuestion="next_question",i.End="end",i.ResponseBased="response_based",i.SpecificQuestion="specific_question",i})({}),_k=(function(i){return i.Once="once",i.Recurring="recurring",i.Always="always",i})({}),Er=(function(i){return i.SHOWN="survey shown",i.DISMISSED="survey dismissed",i.SENT="survey sent",i.ABANDONED="survey abandoned",i})({}),Wo=(function(i){return i.SURVEY_ID="$survey_id",i.SURVEY_NAME="$survey_name",i.SURVEY_RESPONSE="$survey_response",i.SURVEY_ITERATION="$survey_iteration",i.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",i.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",i.SURVEY_SUBMISSION_ID="$survey_submission_id",i.SURVEY_QUESTIONS="$survey_questions",i.SURVEY_COMPLETED="$survey_completed",i.PRODUCT_TOUR_ID="$product_tour_id",i.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",i})({}),qa=(function(i){return i.Popover="popover",i.Inline="inline",i})({}),Y=oe("[Surveys]"),of="seenSurvey_",vE=(i,e)=>{var t="$survey_"+e+"/"+i.id;return i.current_iteration&&i.current_iteration>0&&(t="$survey_"+e+"/"+i.id+"/"+i.current_iteration),t},Yd=i=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(of,i),_E=[Ko.Popover,Ko.Widget,Ko.API],mE={ignoreConditions:!1,ignoreDelay:!1,displayType:qa.Popover},Pr=class{constructor(){this.Mi={},this.Mi={}}on(e,t){return this.Mi[e]||(this.Mi[e]=[]),this.Mi[e].push(t),()=>{this.Mi[e]=this.Mi[e].filter((r=>r!==t))}}emit(e,t){for(var r of this.Mi[e]||[])r(t);for(var n of this.Mi["*"]||[])n(e,t)}};za=class{constructor(e){this.Ai=new Pr,this.ji=(t,r)=>this.Di(t,r)&&this.Li(t,r)&&this.Ni(t,r)&&this.Ui(t,r),this.Di=(t,r)=>r==null||!r.event||t?.event===r?.event,this._instance=e,this.zi=new Set,this.Hi=new Set}init(){var e;if(!S((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((r,n)=>{this.on(r,n)}))}}register(e){var t,r;if(!S((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.Hi)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.zi)==null||u.add(c?.event||"")}))})),(r=this._instance)!=null&&r.autocapture)){var n,s=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&s.add(l?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(s)}}on(e,t){var r;t!=null&&e.length!=0&&(this.zi.has(e)||this.zi.has(t?.event))&&this.Hi&&((r=this.Hi)==null?void 0:r.size)>0&&this.Hi.forEach((n=>{this.Bi(t,n)&&this.Ai.emit("actionCaptured",n.name)}))}qi(e){this.onAction("actionCaptured",(t=>e(t)))}Bi(e,t){if(t?.steps==null)return!1;for(var r of t.steps)if(this.ji(e,r))return!0;return!1}onAction(e,t){return this.Ai.on(e,t)}Li(e,t){if(t!=null&&t.url){var r,n=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!n||typeof n!="string"||!Ti(n,t.url,t.url_matching||"contains"))return!1}return!0}Ni(e,t){return!!this.Wi(e,t)&&!!this.Gi(e,t)&&!!this.Vi(e,t)}Wi(e,t){var r;if(t==null||!t.href)return!0;var n=this.Ji(e);if(n.length>0)return n.some((a=>Ti(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&Ti((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}Gi(e,t){var r;if(t==null||!t.text)return!0;var n=this.Ji(e);if(n.length>0)return n.some((c=>Ti(c.text,t.text,t.text_matching||"exact")||Ti(c.$el_text,t.text,t.text_matching||"exact")));var s,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=(function(c){for(var u,h=[],g=/(?::|")text="(.*?)"/g;!U(u=g.exec(c));)h.includes(u[1])||h.push(u[1]);return h})(l),o=t.text,a=t.text_matching||"exact",s.some((c=>Ti(c,o,a))))}Vi(e,t){var r,n;if(t==null||!t.selector)return!0;var s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(t.selector))return!0;var o=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}Ji(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Ui(e,t){return t==null||!t.properties||t.properties.length===0||sf(t.properties.reduce(((r,n)=>{var s=j(n.value)?n.value.map(String):n.value!=null?[String(n.value)]:[];return r[n.key]={values:s,operator:n.operator||"exact"},r}),{}),e?.properties)}},Ka=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&sf(e.propertyFilters,t?.properties)}Zi(e,t){var r=new Map;return e.forEach((n=>{var s;(s=n.conditions)==null||(s=s[t])==null||(s=s.values)==null||s.forEach((o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(n.id),r.set(o.name,a)}}))})),r}te(e,t,r){var n=(r===fr.Activation?this.Ki:this.Yi).get(e),s=[];return this.ie((o=>{s=o.filter((a=>n?.includes(a.id)))})),s.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.Qi(l,t)}))}register(e){var t;S((t=this._instance)==null?void 0:t._addCaptureHook)||(this.ee(e),this.re(e))}re(e){var t=e.filter((r=>{var n,s;return((n=r.conditions)==null?void 0:n.actions)&&((s=r.conditions)==null||(s=s.actions)==null||(s=s.values)==null?void 0:s.length)>0}));t.length!==0&&(this.se==null&&(this.se=new za(this._instance),this.se.init(),this.se.qi((r=>{this.onAction(r)}))),t.forEach((r=>{var n,s,o,a,l;r.conditions&&(n=r.conditions)!=null&&n.actions&&(s=r.conditions)!=null&&(s=s.actions)!=null&&s.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.se)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.Xi.get(c.name);u&&u.push(r.id),this.Xi.set(c.name,u||[r.id])}})))})))}ee(e){var t,r=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.events)&&((a=s.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),n=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.cancelEvents)&&((a=s.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(r.length!==0||n.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((s,o)=>{this.onEvent(s,o)})),this.Ki=this.Zi(e,fr.Activation),this.Yi=this.Zi(e,fr.Cancellation))}onEvent(e,t){var r,n=this.ne(),s=this.oe(),o=this.ae(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[s])||[];if(o===e&&t&&a.length>0){var l,c;n.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var h=a.indexOf(u);h>=0&&(a.splice(h,1),this.le(a))}}else{if(this.Yi.has(e)){var g=this.te(e,t,fr.Cancellation);g.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:g.map((p=>p.id))}),g.forEach((p=>{var v=a.indexOf(p.id);v>=0&&a.splice(v,1),this.ue(p.id)})),this.le(a))}if(this.Ki.has(e)){n.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var f=this.te(e,t,fr.Activation);this.le(a.concat(f.map((p=>p.id))||[]))}}}onAction(e){var t,r=this.oe(),n=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[r])||[];this.Xi.has(e)&&this.le(n.concat(this.Xi.get(e)||[]))}le(e){var t,r=this.ne(),n=this.oe(),s=[...new Set(e)].filter((o=>!this.he(o)));r.info("updating activated items",{activatedItems:s}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[n]:s})}getActivatedIds(){var e,t=this.oe(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return r||[]}getEventToItemsMap(){return this.Ki}de(){return this.se}},Wa=class extends Ka{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return Er.SHOWN}ie(e){var t;(t=this._instance)==null||t.getSurveys(e)}ue(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}ne(){return Y}he(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ya=class{constructor(e){this.ve=void 0,this._surveyManager=null,this.ce=!1,this.fe=[],this.pe=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(U(t))return Y.warn("Flags not loaded yet. Not loading surveys.");var r=j(t);this.ve=r?t.length>0:t,Y.info("flags response received, isSurveysEnabled: "+this.ve),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var r=localStorage.key(t);(r!=null&&r.startsWith(of)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((n=>localStorage.removeItem(n)))}loadIfEnabled(){if(!this._surveyManager)if(this.ce)Y.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Y.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Y.info("Not loading surveys in cookieless mode without consent.");else{var e=O?.__PosthogExtensions__;if(e){if(!S(this.ve)||this._instance.config.advanced_enable_surveys){var t=this.ve||this._instance.config.advanced_enable_surveys;this.ce=!0;try{var r=e.generateSurveys;if(r)return void this._e(r,t);var n=e.loadExternalDependency;if(!n)return void this.ge("PostHog loadExternalDependency extension not found.");n(this._instance,"surveys",(s=>{s||!e.generateSurveys?this.ge("Could not load surveys script",s):this._e(e.generateSurveys,t)}))}catch(s){throw this.ge("Error initializing surveys",s),s}finally{this.ce=!1}}}else Y.error("PostHog Extensions not found.")}}_e(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Wa(this._instance),Y.info("Surveys loaded successfully"),this.me({isLoaded:!0})}ge(e,t){Y.error(e,t),this.me({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.fe.push(e),this._surveyManager&&this.me({isLoaded:!0}),()=>{this.fe=this.fe.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return Y.info("Disabled. Not loading surveys."),e([]);var r,n=this._instance.get_property(ya);if(n&&!t)return e(n,{isLoaded:!0});typeof Promise<"u"&&this.pe?this.pe.then((s=>{var{surveys:o,context:a}=s;return e(o,a)})):(typeof Promise<"u"&&(this.pe=new Promise((s=>{r=s}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:s=>{var o;this.pe=null;var a=s.statusCode;if(a!==200||!s.json){var l="Surveys API could not be loaded, status: "+a;Y.error(l);var c={isLoaded:!1,error:l};return e([],c),void(r==null||r({surveys:[],context:c}))}var u,h=s.json.surveys||[],g=h.filter((p=>(function(v){return!(!v.start_date||v.end_date)})(p)&&((function(v){var _;return!((_=v.conditions)==null||(_=_.events)==null||(_=_.values)==null||!_.length)})(p)||(function(v){var _;return!((_=v.conditions)==null||(_=_.actions)==null||(_=_.values)==null||!_.length)})(p))));g.length>0&&((u=this._surveyEventReceiver)==null||u.register(g)),(o=this._instance.persistence)==null||o.register({[ya]:h});var f={isLoaded:!0};e(h,f),r?.({surveys:h,context:f})}}))}me(e){for(var t of this.fe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(r){Y.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!U(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Y.warn("init was not called")}be(e){var t=null;return this.getSurveys((r=>{var n;t=(n=r.find((s=>s.id===e)))!==null&&n!==void 0?n:null})),t}ye(e){if(U(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.be(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(U(this._surveyManager))return Y.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.ye(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return U(this._surveyManager)?(Y.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((r=>{this.getSurveys((n=>{var s,o=(s=n.find((l=>l.id===e)))!==null&&s!==void 0?s:null;if(o){var a=this.ye(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,r){var n;if(U(this._surveyManager))Y.warn("init was not called");else{var s=typeof e=="string"?this.be(e):e;if(s!=null&&s.id)if(_E.includes(s.type)){var o=k?.querySelector(t);if(o)return(n=s.appearance)!=null&&n.surveyPopupDelaySeconds?(Y.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,l;Y.info("Rendering survey "+s.id+" with delay of "+((a=s.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(s,o,r),Y.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,o,r);Y.warn("Survey element not found")}else Y.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Y.warn("Survey not found")}}displaySurvey(e,t){var r;if(U(this._surveyManager))Y.warn("init was not called");else{var n=this.be(e);if(n){var s=n;if((r=n.appearance)!=null&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=T({},n,{appearance:T({},n.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==qa.Popover&&t.initialResponses&&Y.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(n);if(!o.visible)return void Y.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==qa.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else Y.warn("Survey not found")}}cancelPendingSurvey(e){U(this._surveyManager)?Y.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},ze=oe("[Conversations]"),Xa=class{constructor(e){this.we=void 0,this._conversationsManager=null,this.xe=!1,this.$e=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;U(t)||(kt(t)?this.we=t:(this.we=t.enabled,this.$e=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.we=void 0,this.$e=null}loadIfEnabled(){if(!(this._conversationsManager||this.xe||this._instance.config.disable_conversations||Th(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=O?.__PosthogExtensions__;if(e&&!S(this.we)&&this.we)if(this.$e&&this.$e.token){this.xe=!0;try{var t=e.initConversations;if(t)return this.Ee(t),void(this.xe=!1);var r=e.loadExternalDependency;if(!r)return void this.Se("PostHog loadExternalDependency extension not found.");r(this._instance,"conversations",(n=>{n||!e.initConversations?this.Se("Could not load conversations script",n):this.Ee(e.initConversations),this.xe=!1}))}catch(n){this.Se("Error initializing conversations",n),this.xe=!1}}else ze.error("Conversations enabled but missing token in remote config.")}}Ee(e){if(this.$e)try{this._conversationsManager=e(this.$e,this._instance),ze.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else ze.error("Cannot complete initialization: remote config is null")}Se(e,t){ze.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():ze.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Ze(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,r){var n=this;return _t((function*(){return n._conversationsManager?n._conversationsManager.sendMessage(e,t,r):(ze.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return _t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(ze.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(ze.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(ze.warn("Conversations not available yet."),null)}))()}requestRestoreLink(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(ze.warn("Conversations not available yet."),null)}))()}restoreFromToken(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(ze.warn("Conversations not available yet."),null)}))()}restoreFromUrlToken(){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(ze.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},Ja=class{constructor(e){var t;this.ke=!1,this.Pe=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.ke=!0)}onRemoteConfig(e){var t,r=(t=e.logs)==null?void 0:t.captureConsoleLogs;!U(r)&&r&&(this.ke=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.ke&&!this.Pe){var e=oe("[logs]"),t=O?.__PosthogExtensions__;if(t){var r=t.loadExternalDependency;r?r(this._instance,"logs",(n=>{var s;n||(s=t.logs)==null||!s.initializeLogs?e.error("Could not load logs script",n):(t.logs.initializeLogs(this._instance),this.Pe=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},Xd=oe("[RateLimiter]"),Qa=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var r=t.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach((n=>{Xd.info((n||"events")+" is quota limited."),this.serverLimits[n]=new Date().getTime()+6e4}))}catch(n){return void Xd.warn('could not rate limit - continuing. Error: "'+n?.message+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,r,n;e===void 0&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(r=this.instance.persistence)==null?void 0:r.get_property(ka))!==null&&t!==void 0?t:{tokens:s,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>s&&(l.tokens=s);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(n=this.instance.persistence)==null||n.set_property(ka,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},gr=oe("[RemoteConfig]"),rs=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=O._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=O.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Ie(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return gr.info("Using preloaded remote config",this.remoteConfig),this.Ce(this.remoteConfig),void this.Re();if(this._instance.M())return void gr.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return gr.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ie((t=>{this.Ce(t),this.Re()}));this.Ce(e),this.Re()}))}catch(e){gr.error("Error loading remote config",e)}}stop(){this.Fe&&(clearInterval(this.Fe),this.Fe=void 0)}refresh(){this._instance.M()||k?.visibilityState==="hidden"||this._instance.featureFlags.reloadFeatureFlags()}Re(){this.Fe||(this.Fe=setInterval((()=>{this.refresh()}),3e5))}Ce(e){e||gr.error("Failed to fetch remote config from PostHog."),this._instance.Ce(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||this._instance.featureFlags.ensureFlagsLoaded())}},Za=3e3,el=class{constructor(e,t){this.Oe=!0,this.Me=[],this.Ae=at(t?.flush_interval_ms||Za,250,5e3,w.createLogger("flush interval"),Za),this.je=e}enqueue(e){this.Me.push(e),this.De||this.Le()}unload(){this.Ne();var e=this.Me.length>0?this.Ue():{},t=Object.values(e);[...t.filter((r=>r.url.indexOf("/e")===0)),...t.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.je(T({},r,{transport:"sendBeacon"}))}))}enable(){this.Oe=!1,this.Le()}Le(){var e=this;this.Oe||(this.De=setTimeout((()=>{if(this.Ne(),this.Me.length>0){var t=this.Ue(),r=function(){var s=t[n],o=new Date().getTime();s.data&&j(s.data)&&J(s.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.je(s)};for(var n in t)r()}}),this.Ae))}Ne(){clearTimeout(this.De),this.De=void 0}Ue(){var e={};return J(this.Me,(t=>{var r,n=t,s=(n?n.batchKey:null)||n.url;S(e[s])&&(e[s]=T({},n,{data:[]})),(r=e[s].data)==null||r.push(n.data)})),this.Me=[],e}},yE=["retriesPerformedSoFar"],tl=class{constructor(e){this.ze=!1,this.He=3e3,this.Me=[],this._instance=e,this.Me=[],this.Be=!0,!S(m)&&"onLine"in m.navigator&&(this.Be=m.navigator.onLine,this.qe=()=>{this.Be=!0,this.Lt()},this.We=()=>{this.Be=!1},de(m,"online",this.qe),de(m,"offline",this.We))}get length(){return this.Me.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=ih(e,yE);Ri(t)&&(r.url=ts(r.url,{retry_count:t})),this._instance._send_request(T({},r,{callback:n=>{n.statusCode!==200&&(n.statusCode<400||n.statusCode>=500)&&(t??0)<10?this.Ge(T({retriesPerformedSoFar:t},r)):r.callback==null||r.callback(n)}}))}Ge(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var r=(function(o){var 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)})(t),n=Date.now()+r;this.Me.push({retryAt:n,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),w.warn(s),this.ze||(this.ze=!0,this.Ve())}Ve(){if(this.Je&&clearTimeout(this.Je),this.Me.length===0)return this.ze=!1,void(this.Je=void 0);this.Je=setTimeout((()=>{this.Be&&this.Me.length>0&&this.Lt(),this.Ve()}),this.He)}Lt(){var e=Date.now(),t=[],r=this.Me.filter((s=>s.retryAt<e||(t.push(s),!1)));if(this.Me=t,r.length>0)for(var{requestOptions:n}of r)this.retriableRequest(n)}unload(){for(var{requestOptions:e}of(this.Je&&(clearTimeout(this.Je),this.Je=void 0),this.ze=!1,S(m)||(this.qe&&(m.removeEventListener("online",this.qe),this.qe=void 0),this.We&&(m.removeEventListener("offline",this.We),this.We=void 0)),this.Me))try{this._instance._send_request(T({},e,{transport:"sendBeacon"}))}catch(t){w.error(t)}this.Me=[]}},il=class{constructor(e){this.Ke=()=>{var t,r,n,s;this.Ye||(this.Ye={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),u=o?.scrollHeight||0;this.Ye.lastScrollY=Math.ceil(a),this.Ye.maxScrollY=Math.max(a,(t=this.Ye.maxScrollY)!==null&&t!==void 0?t:0),this.Ye.maxScrollHeight=Math.max(l,(r=this.Ye.maxScrollHeight)!==null&&r!==void 0?r:0),this.Ye.lastContentY=c,this.Ye.maxContentY=Math.max(c,(n=this.Ye.maxContentY)!==null&&n!==void 0?n:0),this.Ye.maxContentHeight=Math.max(u,(s=this.Ye.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.Ye}resetContext(){var e=this.Ye;return setTimeout(this.Ke,0),e}startMeasuringScrollPosition(){de(m,"scroll",this.Ke,{capture:!0}),de(m,"scrollend",this.Ke,{capture:!0}),de(m,"resize",this.Ke)}scrollElement(){if(!this._instance.config.scroll_root_selector)return m?.document.documentElement;var e=j(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var r=m?.document.querySelector(t);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return m&&(m.scrollY||m.pageYOffset||m.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return m&&(m.scrollX||m.pageXOffset||m.document.documentElement.scrollLeft)||0}},bE=i=>Xh(i?.config.mask_personal_data_properties,i?.config.custom_personal_data_properties),ns=class{constructor(e,t,r,n){this.Xe=s=>{var o=this.Qe();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ze(this._instance)};this.tr.register({[Ea]:a})}},this._instance=e,this.ir=t,this.tr=r,this.Ze=n||bE,this.ir.onSessionId(this.Xe)}Qe(){return this.tr.props[Ea]}getSetOnceProps(){var e,t=(e=this.Qe())==null?void 0:e.props;return t?"r"in t?Jh(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return J(gl(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+Zo(r)]=t})),e}},Yo=oe("[SessionId]"),ss=class{on(e,t){return this.er.on(e,t)}constructor(e,t,r){var n;if(this.rr=[],this.sr=void 0,this.er=new Pr,this.nr=(u,h)=>!(!Ri(u)||!Ri(h))&&Math.abs(u-h)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.tr=e.persistence,this.ar=void 0,this.lr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ur=t||$t,this.hr=r||$t;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*at(o,60,36e3,Yo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.dr(),this.vr="ph_"+s+"_window_id",this.cr="ph_"+s+"_primary_window_exists",this.pr()){var a=ye.W(this.vr),l=ye.W(this.cr);a&&!l?this.ar=a:ye.V(this.vr),ye.G(this.cr,!0)}if((n=this.R.bootstrap)!=null&&n.sessionID)try{var c=(u=>{var h=u.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})(this.R.bootstrap.sessionID);this._r(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){Yo.error("Invalid sessionID in bootstrap",u)}this.gr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return S(this.rr)&&(this.rr=[]),this.rr.push(e),this.lr&&e(this.lr,this.ar),()=>{this.rr=this.rr.filter((t=>t!==e))}}pr(){return this.R.persistence!=="memory"&&!this.tr.ki&&ye.H()}mr(e){e!==this.ar&&(this.ar=e,this.pr()&&ye.G(this.vr,e))}br(){return this.ar?this.ar:this.pr()?ye.W(this.vr):null}_r(e,t,r){e===this.lr&&t===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=t,this.lr=e,this.tr.register({[Gn]:[t,e,r]}))}yr(){var e=this.tr.props[Gn];return j(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._r(null,null,null)}destroy(){clearTimeout(this.wr),this.wr=void 0,this.sr&&m&&(m.removeEventListener("beforeunload",this.sr,{capture:!1}),this.sr=void 0),this.rr=[]}gr(){this.sr=()=>{this.pr()&&ye.V(this.cr)},de(m,"beforeunload",this.sr,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||new Date().getTime(),[n,s,o]=this.yr(),a=this.br(),l=Ri(o)&&Math.abs(r-o)>864e5,c=!1,u=!s,h=!u&&!e&&this.nr(r,n);u||h||l?(s=this.ur(),a=this.hr(),Yo.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.hr(),c=!0);var g=Ri(n)&&e&&!l?n:r,f=Ri(o)?o:new Date().getTime();return this.mr(a),this._r(s,g,f),e||this.dr(),c&&this.rr.forEach((p=>p(s,a,c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:f,changeReason:c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:n}}dr(){clearTimeout(this.wr),this.wr=setTimeout((()=>{var[e]=this.yr();if(this.nr(new Date().getTime(),e)){var t=this.lr;this.resetSessionId(),this.er.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},EE=["$set_once","$set"],Nt=oe("[SiteApps]"),rl=class{constructor(e){this._instance=e,this.$r=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Er(e,t){if(t){var r=this.globalsForEvent(t);this.$r.push(r),this.$r.length>1e3&&(this.$r=this.$r.slice(10))}}get siteAppLoaders(){var e;return(e=O._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.Er.bind(this));this.Sr=()=>{e(),this.$r=[],this.Sr=void 0}}}globalsForEvent(e){var t,r,n,s,o,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var[g,f]of Object.entries(h))c[g]={id:u[g],type:g,properties:f};var{$set_once:p,$set:v}=e;return{event:T({},ih(e,EE),{properties:T({},e.properties,v?{$set:T({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},v)}:{},p?{$set_once:T({},(n=(s=e.properties)==null?void 0:s.$set_once)!==null&&n!==void 0?n:{},p)}:{}),elements_chain:(o=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],r=()=>{var a;!t.errored&&this.$r.length&&(Nt.info("Processing "+this.$r.length+" events for site app with id "+e.id),this.$r.forEach((l=>t.processEvent==null?void 0:t.processEvent(l))),t.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.Sr)==null||a.call(this))},n=!1,s=a=>{t.errored=!a,t.loaded=!0,Nt.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),n&&r()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:a=>{s(a)}});o&&(t.processEvent=o),n=!0}catch(a){Nt.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(n&&t.loaded)try{r()}catch(a){Nt.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}kr(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}Pr(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(t)}catch(n){Nt.error("Error while processing event "+e.event+" for site app "+r.id,n)}}}onRemoteConfig(e){var t,r,n,s=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.kr(),void this._instance.on("eventCaptured",(c=>this.Pr(c)))):void Nt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.Sr)==null||r.call(this),(n=e.siteApps)!=null&&n.length)if(this.isEnabled){var o=function(c){var u;O["__$$ph_site_app_"+c]=s._instance,(u=O.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,(h=>{if(h)return Nt.error("Error while initializing PostHog app with config id "+c,h)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else Nt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},af=function(i,e){if(!i)return!1;var t=i.userAgent;if(t&&ud(t,e))return!0;try{var r=i?.userAgentData;if(r!=null&&r.brands&&r.brands.some((n=>ud(n?.brand,e))))return!0}catch{}return!!i.webdriver},kr=(function(i){return i.US="us",i.EU="eu",i.CUSTOM="custom",i})({}),Jd="i.posthog.com",nl=class{constructor(e){this.Tr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+Jd,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Tr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Tr[this.apiHost]=kr.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Tr[this.apiHost]=kr.EU:this.Tr[this.apiHost]=kr.CUSTOM),this.Tr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===kr.CUSTOM)return this.apiHost+t;var r=Jd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},kE={icontains:(i,e)=>!!m&&e.href.toLowerCase().indexOf(i.toLowerCase())>-1,not_icontains:(i,e)=>!!m&&e.href.toLowerCase().indexOf(i.toLowerCase())===-1,regex:(i,e)=>!!m&&is(e.href,i),not_regex:(i,e)=>!!m&&!is(e.href,i),exact:(i,e)=>e.href===i,is_not:(i,e)=>e.href!==i},sl=class i{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),t.getWebExperiments((n=>{i.Ir("retrieved web experiments from the server"),t.Cr=new Map,n.forEach((s=>{if(s.feature_flag_key){var o;t.Cr&&(i.Ir("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=t.Cr)==null||o.set(s.feature_flag_key,s));var a=t._instance.getFeatureFlag(s.feature_flag_key);ue(a)&&s.variants[a]&&t.Rr(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var c=s.variants[l];i.Fr(c)&&t.Rr(s.name,l,c.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}onFeatureFlags(e){if(this._is_bot())i.Ir("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(U(this.Cr))return this.Cr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();i.Ir("applying feature flags",e),e.forEach((t=>{var r;if(this.Cr&&(r=this.Cr)!=null&&r.has(t)){var n,s=this._instance.getFeatureFlag(t),o=(n=this.Cr)==null?void 0:n.get(t);s&&o!=null&&o.variants[s]&&this.Rr(o.name,s,o.variants[s].transforms)}}))}}previewWebExperiment(){var e=i.getWindowLocation();if(e!=null&&e.search){var t=Yn(e?.search,"__experiment_id"),r=Yn(e?.search,"__experiment_variant");t&&r&&(i.Ir("previewing web experiments "+t+" && "+r),this.getWebExperiments((n=>{this.Or(parseInt(t),r,n)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var n=this._instance.get_property("$web_experiments");if(n&&!t)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return e([]);var o=s.json.experiments||[];return e(o)}})}Or(e,t,r){var n=r.filter((s=>s.id===e));n&&n.length>0&&(i.Ir("Previewing web experiment ["+n[0].name+"] with variant ["+t+"]"),this.Rr(n[0].name,t,n[0].variants[t].transforms))}static Fr(e){return!U(e.conditions)&&i.Mr(e)&&i.Ar(e)}static Mr(e){var t;if(U(e.conditions)||U((t=e.conditions)==null?void 0:t.url))return!0;var r,n,s,o=i.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||kE[(n=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&n!==void 0?n:"icontains"](e.conditions.url,o))}static getWindowLocation(){return m?.location}static Ar(e){var t;if(U(e.conditions)||U((t=e.conditions)==null?void 0:t.utm))return!0;var r=zh();if(r.utm_source){var n,s,o,a,l,c,u,h,g=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.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)==r.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==r.utm_term;return g&&p&&v&&f}return!1}static Ir(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];w.info("[WebExperiments] "+e,r)}Rr(e,t,r){this._is_bot()?i.Ir("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?r.forEach((n=>{if(n.selector){var s;i.Ir("applying transform of variant "+t+" for experiment "+e+" ",n);var o=(s=document)==null?void 0:s.querySelectorAll(n.selector);o?.forEach((a=>{var l=a;n.html&&(l.innerHTML=n.html),n.css&&l.setAttribute("style",n.css)}))}})):i.Ir("Control variants leave the page unmodified.")}_is_bot(){return Ve&&this._instance?af(Ve,this._instance.config.custom_blocked_useragents):void 0}},SE=oe("[PostHog ExternalIntegrations]"),wE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},ol=class{constructor(e){this._instance=e}it(e,t){var r;(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(n=>{if(n)return SE.error("failed to load script",n);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!n||(a=O.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(wE[o],(()=>{var u;(u=O.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!n&&(l=O.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=O.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[r,n]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;t(r)}}};oe("[SessionRecording]");al="[SessionRecording]",Ii=oe(al),os=class{get started(){var e;return!((e=this.jr)==null||!e.isStarted)}get status(){return this.jr?this.jr.status:this.Dr&&!this.Lr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Dr=!1,this.Nr=!1,this.Ur=void 0,this._instance=e,!this._instance.sessionManager)throw Ii.error("started without valid sessionManager"),new Error(al+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(al+' cannot be used with cookieless_mode="always"')}get Lr(){var e,t=!((e=this._instance.get_property(Dn))==null||!e.enabled),r=!this._instance.config.disable_session_recording,n=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return m&&t&&r&&!n}startIfEnabledOrStop(e){var t;if(!this.Lr||(t=this.jr)==null||!t.isStarted){var r=!S(Object.assign)&&!S(Array.from);this.Lr&&r?(this.zr(e),Ii.info("starting")):this.stopRecording()}}zr(e){var t,r,n;this.Lr&&(O!=null&&(t=O.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=O.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Hr(e):(n=O.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.Br,(s=>{if(s)return Ii.error("could not load recorder",s);this.Hr(e)})))}stopRecording(){var e,t;(e=this.Ur)==null||e.call(this),this.Ur=void 0,(t=this.jr)==null||t.stop()}qr(){var e;(e=this._instance.persistence)==null||e.unregister(Oh)}Wr(e){if(this._instance.persistence){var t,r,n=this._instance.persistence,s=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=U(a)?null:parseFloat(a);U(l)&&this.qr();var c=o?.minimumDurationMilliseconds;n.register({[Dn]:T({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:T({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:S(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(t=this.Ur)==null||t.call(this),this.Ur=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.Nr=!1,this.Wr(e),this.Dr=!0,this.startIfEnabledOrStop()):this.Dr=!0:Ii.info("skipping remote config with no sessionRecording",e)}log(e,t){var r;t===void 0&&(t="log"),(r=this.jr)!=null&&r.log?this.jr.log(e,t):Ii.warn("log called before recorder was ready")}get Br(){var e,t,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Dn);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Gr(){var e,t=this._instance.get_property(Dn);if(!t)return!1;var r=(e=(typeof t=="object"?t:JSON.parse(t)).cache_timestamp)!==null&&e!==void 0?e:Date.now();return Date.now()-r<=3e5}Hr(e){var t,r;if((t=O.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.jr||(this.jr=(r=O.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.jr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Gr()?this.jr.start(e):this.Nr||(this.Nr=!0,Ii.info("persisted remote config is stale, requesting fresh config before starting"),new rs(this._instance).load())}onRRwebEmit(e){var t;(t=this.jr)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.jr||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.jr)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.jr||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.jr)==null||e.overrideSampling()}overrideTrigger(e){var t,r;this.jr||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.jr)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.jr)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var r;return!((r=this.jr)==null||!r.tryAddCustomEvent(e,t))}},Ar={},Xo=0,ll=()=>{},Oi="posthog",lf=!sE&&Ne?.indexOf("MSIE")===-1&&Ne?.indexOf("Mozilla")===-1,Qd=i=>{var e;return T({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Eb(k?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:ll,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:i??"unset",__preview_deferred_init_extensions:!1,debug:be&&ue(be?.search)&&be.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(m==null||(e=m.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_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var r="Bad HTTP status: "+t.statusCode+" "+t.text;w.error(r)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Za},error_tracking:{},_onCapture:ll,__preview_eager_load_replay:!1},(t=>({rageclick:!(t&&t>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(t&&t>="2025-05-24")||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(i))},Zd=i=>{var e={};S(i.process_person)||(e.person_profiles=i.process_person),S(i.xhr_headers)||(e.request_headers=i.xhr_headers),S(i.cookie_name)||(e.persistence_name=i.cookie_name),S(i.disable_cookie)||(e.disable_persistence=i.disable_cookie),S(i.store_google)||(e.save_campaign_params=i.store_google),S(i.verbose)||(e.debug=i.verbose);var t=le({},e,i);return j(i.property_blacklist)&&(S(i.property_denylist)?t.property_denylist=i.property_blacklist:j(i.property_denylist)?t.property_denylist=[...i.property_blacklist,...i.property_denylist]:w.error("Invalid value for property_denylist config: "+i.property_denylist)),t},cl=class{constructor(){this.__forceAllowLocalhost=!1}get Vr(){return this.__forceAllowLocalhost}set Vr(e){w.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},as=class i{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new cl,this.Jr=!1,this.version=vt.LIB_VERSION,this.mi=new Pr,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Qd(),this.SentryIntegration=Na,this.sentryIntegration=e=>(function(t,r){var n=qh(t,r);return{name:Hh,processEvent:s=>n(s)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Kr=!1,this.Yr=null,this.Xr=null,this.Qr=null,this.featureFlags=new ja(this),this.toolbar=new xa(this),this.scrollManager=new il(this),this.pageViewManager=new Qn(this),this.surveys=new Ya(this),this.conversations=new Xa(this),this.logs=new Ja(this),this.experiments=new sl(this),this.exceptions=new Ga(this),this.rateLimiter=new Qa(this),this.requestRouter=new nl(this),this.consent=new Ca(this),this.externalIntegrations=new ol(this),this.people={set:(e,t,r)=>{var n=ue(e)?{[e]:t}:e;this.setPersonProperties(n),r?.({})},set_once:(e,t,r)=>{var n=ue(e)?{[e]:t}:e;this.setPersonProperties(void 0,n),r?.({})}},this.on("eventCaptured",(e=>w.info('send "'+e?.event+'"',e)))}init(e,t,r){if(r&&r!==Oi){var n,s=(n=Ar[r])!==null&&n!==void 0?n:new i;return s._init(e,t,r),Ar[r]=s,Ar[Oi][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var n;if(t===void 0&&(t={}),S(e)||ea(e))return w.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Zr(t.debug),this.ts=t,this.es=[],t.person_profiles?this.Xr=t.person_profiles:t.process_person&&(this.Xr=t.process_person),this.set_config(le({},Qd(t.defaults),Zd(t),{name:r,token:e})),this.config.on_xhr_error&&w.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:yt.GZipJS;var s=this.rs();this.persistence=new wr(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wr(T({},this.config,{persistence:"sessionStorage"}),s);var o=T({},this.persistence.props),a=T({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.ss=new el((E=>this.ns(E)),this.config.request_queue_config),this.os=new tl(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new ss(this),this.sessionPropsManager=new ns(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(w.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.ls(l)}),0)):(w.info("Initializing extensions synchronously"),this.ls(l)),vt.DEBUG=vt.DEBUG||this.config.debug,vt.DEBUG&&w.info("Starting in debug mode",{this:this,config:t,thisC:T({},this.config),p:o,s:a}),((n=t.bootstrap)==null?void 0:n.distinctID)!==void 0){var c,u,h=this.config.get_device_id($t()),g=(c=t.bootstrap)!=null&&c.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(st,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:g})}if(this.us()){var f,p,v=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlags)||{}).filter((E=>{var D;return!((D=t.bootstrap)==null||(D=D.featureFlags)==null||!D[E])})).reduce(((E,D)=>{var N;return E[D]=((N=t.bootstrap)==null||(N=N.featureFlags)==null?void 0:N[D])||!1,E}),{}),_=Object.keys(((p=t.bootstrap)==null?void 0:p.featureFlagPayloads)||{}).filter((E=>v[E])).reduce(((E,D)=>{var N,R;return(N=t.bootstrap)!=null&&(N=N.featureFlagPayloads)!=null&&N[D]&&(E[D]=(R=t.bootstrap)==null||(R=R.featureFlagPayloads)==null?void 0:R[D]),E}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:_})}if(l)this.register_once({distinct_id:or,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id($t());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(st,"anonymous")}return de(m,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?jb(this,(()=>this.hs())):this.hs(),bt(this.config._onCapture)&&this.config._onCapture!==ll&&(w.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(E=>this.config._onCapture(E.event,E)))),this.config.ip&&w.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}ls(e){var t=performance.now();this.historyAutocapture=new Da(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new $a(this).startIfEnabledOrStop()})),r.push((()=>{var n;this.siteApps=new rl(this),(n=this.siteApps)==null||n.init()})),e||r.push((()=>{this.sessionRecording=new os(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new Ta(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new Ha(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new Ma(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new La(this)})),r.push((()=>{this.exceptionObserver=new Pa(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new Jn(this,Gb),this.deadClicksAutocapture.startIfEnabledOrStop()})),r.push((()=>{if(this.ds){var n=this.ds;this.ds=void 0,this.Ce(n)}})),this.vs(r,t)}vs(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.vs(e,t)}),0);var r=e.shift();if(r)try{r()}catch(s){w.error("Error initializing extension:",s)}}var n=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:n}),this.config.__preview_deferred_init_extensions&&w.info("PostHog extensions initialized ("+n+"ms)")}Ce(e){var t,r,n,s,o,a,l,c,u;if(!k||!k.body)return w.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Ce(e)}),500);this.config.__preview_deferred_init_extensions&&(this.ds=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=F(e.supportedCompression,yt.GZipJS)?yt.GZipJS:F(e.supportedCompression,yt.Base64)?yt.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Xr?this.Xr:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(n=this.sessionRecording)==null||n.onRemoteConfig(e),(s=this.autocapture)==null||s.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}hs(){try{this.config.loaded(this)}catch(r){w.critical("`loaded` function failed",r)}if(this.cs(),this.config.internal_or_test_user_hostname&&be!=null&&be.hostname){var e=be.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.fs()}),1),this.ps=new rs(this),this.ps.load()}cs(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.ss)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Lt(this.__request_queue,(e=>this.ns(e))),this.__request_queue=[],this.cs()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this._s()&&this.capture("$pageleave"),(e=this.ss)==null||e.unload(),(t=this.os)==null||t.unload()):this._s()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(lf?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=ts(e.url,{ip:this.config.ip?1:0}),e.headers=T({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var r,n,s,o=T({},t);o.timeout=o.timeout||6e4,o.url=ts(o.url,{_:new Date().getTime().toString(),ver:vt.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=Fn.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(n=(s=Ah(l,(u=>u.transport===a)))==null?void 0:s.method)!==null&&n!==void 0?n:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(T({},e,{callback:t=>{var r,n;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((r=(n=this.config).on_request_error)==null||r.call(n,t)),e.callback==null||e.callback(t)}}))))}ns(e){this.os?this.os.retriableRequest(e):this._send_request(e)}_execute_array(e){Xo++;try{var t,r=[],n=[],s=[];Lt(e,(a=>{a&&(t=a[0],j(t)?s.push(a):bt(a)?a.call(this):j(a)&&t==="alias"?r.push(a):j(a)&&t.indexOf("capture")!==-1&&bt(this[t])?s.push(a):n.push(a))}));var o=function(a,l){Lt(a,(function(c){if(j(c[0])){var u=l;J(c,(function(h){u=u[h[0]].apply(u,h.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};o(r,this),o(n,this),o(s,this)}finally{Xo--}}us(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){if(Xo>0&&j(e)&&ue(e[0])){var t=i.prototype[e[0]];bt(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,r){var n;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.ss){if(this.is_capturing())if(!S(e)&&ue(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(s&&!this.config.__preview_capture_bot_pageviews)){var o=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!ue(t?.$current_url)&&(w.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!=="$exception"||r!=null&&r.oi||w.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=r?.timestamp||a,c=$t(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),r?.$set&&(u.$set=r?.$set);var h,g=e!=="$groupidentify",f=this.gs(r?.$set_once,g);if(f&&(u.$set_once=f),(u=yb(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,S(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===Er.DISMISSED||e===Er.SENT){var p=t?.[Wo.SURVEY_ID],v=t?.[Wo.SURVEY_ITERATION];h={id:p,current_iteration:v},localStorage.getItem(Yd(h))||localStorage.setItem(Yd(h),"true"),u.$set=T({},u.$set,{[vE({id:p,current_iteration:v},e===Er.SENT?"responded":"dismissed")]:!0})}else e===Er.SHOWN&&(u.$set=T({},u.$set,{[Wo.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var _=T({},u.properties.$set,u.$set);if(Ci(_)||this.setPersonPropertiesForFlags(_),!U(this.config.before_send)){var b=this.bs(u);if(!b)return;u=b}this.mi.emit("eventCaptured",u);var E={method:"POST",url:(n=r?._url)!==null&&n!==void 0?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.ns(E):this.ss.enqueue(E),u}w.critical("This capture call is ignored due to client rate limiting.")}}else w.error("No event name provided to posthog.capture")}else w.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,n,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var o=s?void 0:this.persistence.remove_event_timer(e),a=T({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=T({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ue(a.distinct_id)&&!St(a.distinct_id)||ea(a.distinct_id))&&w.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=Yb(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=h,a.$window_id=g}this.sessionPropsManager&&le(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&le(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this.os)==null?void 0:f.length}catch(b){a.$sdk_debug_error_capturing_properties=String(b)}if(this.requestRouter.region===kr.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,n),a=le(a,c),e==="$pageview"&&k&&(a.title=k.title),!S(o)){var p=r.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}Ne&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=le({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),j(this.config.property_denylist)?J(this.config.property_denylist,(function(b){delete a[b]})):w.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(w.error("sanitize_properties is deprecated. Use before_send instead"),a=v(a,e));var _=this.ys();return a.$process_person_profile=_,_&&!s&&this.ws("_calculate_event_properties"),a}gs(e,t){var r;if(t===void 0&&(t=!0),!this.persistence||!this.ys()||this.Jr)return e;var n=this.persistence.get_initial_props(),s=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),o=le({},n,s||{},e||{}),a=this.config.sanitize_properties;return a&&(w.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Jr=!0),Ci(o)?void 0:o}register(e,t){var r;(r=this.persistence)==null||r.register(e,t)}register_once(e,t,r){var n;(n=this.persistence)==null||n.register_once(e,t,r)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}xs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,r){var n=r!=null&&r.merge?this.featureFlags.getFlagVariants():{},s=r!=null&&r.merge?this.featureFlags.getFlagPayloads():{},o=T({},n,e),a=T({},s,t),l={};for(var[c,u]of Object.entries(o)){var h=typeof u=="string";l[c]={key:c,enabled:!!h||!!u,variant:h?u:void 0,reason:void 0,metadata:S(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,r)}getEarlyAccessFeatures(e,t,r){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,r)}on(e,t){return this.mi.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,r;return(t=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=mE),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,r){if(!this.__loaded||!this.persistence)return w.uninitializedWarning("posthog.identify");if(St(e)&&(e=e.toString(),w.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))w.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.');else if(e!==or){if(this.ws("posthog.identify")){var n=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=n;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==n&&e!==this.get_property(vr)&&(this.unregister(vr),this.register({distinct_id:e}));var o=(this.persistence.get_property(st)||"anonymous")==="anonymous";e!==n&&o?(this.persistence.set_property(st,"identified"),this.setPersonPropertiesForFlags(T({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n},{$set:t||{},$set_once:r||{}}),this.Qr=jd(e,t,r),this.featureFlags.setAnonymousDistinctId(n)):(t||r)&&this.setPersonProperties(t,r),e!==n&&(this.reloadFeatureFlags(),this.unregister(jn))}}else w.critical('The string "'+or+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else w.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ws("posthog.setPersonProperties")){var r=jd(this.get_distinct_id(),e,t);this.Qr!==r?(this.setPersonPropertiesForFlags(T({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Qr=r):w.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){var n=this.getGroups();n[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:T({},n,{[e]:t})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),n[e]===t||r||this.reloadFeatureFlags()}else w.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.ws("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,r,n,s,o;if(w.info("reset"),!this.__loaded)return w.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),(n=this.ps)==null||n.stop(),this.featureFlags.reset(),(s=this.persistence)==null||s.set_property(st,"anonymous"),(o=this.sessionManager)==null||o.resetSessionId(),this.Qr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:or,$device_id:null},"");else{var l=this.config.get_device_id($t());this.register_once({distinct_id:l,$device_id:e?l:a},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&r){var s,o=(s=e.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return n;n+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return n}alias(e,t){return e===this.get_property(Ih)?(w.critical("Attempting to create alias for existing People user - aborting."),-2):this.ws("posthog.alias")?(S(t)&&(t=this.get_distinct_id()),e!==t?(this.xs(vr,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(w.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=T({},this.config);if(fe(e)){var r,n,s,o,a,l,c,u;le(this.config,Zd(e));var h=this.rs();(r=this.persistence)==null||r.update_config(this.config,t,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wr(T({},this.config,{persistence:"sessionStorage"}),h);var g=this.Zr(this.config.debug);kt(g)&&(this.config.debug=g),kt(this.config.debug)&&(this.config.debug?(vt.DEBUG=!0,se.H()&&se.G("ph_debug","true"),w.info("set_config",{config:e,oldConfig:t,newConfig:T({},this.config)})):(vt.DEBUG=!1,se.H()&&se.V("ph_debug"))),(n=this.exceptionObserver)==null||n.onConfigChange(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this.$s(),(u=this.externalIntegrations)==null||u.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,r={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var n,s,o,a,l;(n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),r.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),r.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),r.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)==null||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.started)}captureException(e,t){var r=new Error("PostHog syntheticException"),n=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(T({},n,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Oi;return t!==Oi&&(t=Oi+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(st))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(st))==="identified"}ys(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Ci(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[vr])&&((t=this.persistence)==null||(t=t.props)==null||!t[qn]))}_s(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.ys()||this.ws("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ws("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ws(e){return this.config.person_profiles==="never"?(w.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.xs(qn,!0),!0)}rs(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!t}$s(){var e,t,r,n,s=this.rs();return((e=this.persistence)==null?void 0:e.ki)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((t=this.sessionPersistence)==null?void 0:t.ki)!==s&&((n=this.sessionPersistence)==null||n.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var r,n,s;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=new ss(this),this.pageViewManager=new Qn(this),this.persistence&&(this.sessionPropsManager=new ns(this,this.sessionManager,this.persistence)),this.sessionRecording=new os(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.$s(),this.cs(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(S(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((s=e?.captureEventName)!==null&&s!==void 0?s:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.fs()}else w.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,r;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.$s(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:or,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(r=this.sessionRecording)==null||r.stopRecording(),this.sessionRecording=void 0,this.fs())):w.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}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===mt.GRANTED?"granted":e===mt.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.$s()}_is_bot(){return Ve?af(Ve,this.config.custom_blocked_useragents):void 0}fs(){k&&(k.visibilityState==="visible"?this.Kr||(this.Kr=!0,this.capture("$pageview",{title:k.title},{send_instantly:!0}),this.Yr&&(k.removeEventListener("visibilitychange",this.Yr),this.Yr=null)):this.Yr||(this.Yr=this.fs.bind(this),de(k,"visibilitychange",this.Yr)))}debug(e){e===!1?(m?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(m?.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}))}M(){var e,t,r,n,s,o,a,l=this.ts||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(w.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):(r="advanced_disable_decide",n=!1,s=w,o=(t="advanced_disable_flags")in(e=l)&&!U(e[t]),a=r in e&&!U(e[r]),o?e[t]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[r]):n)}bs(e){if(U(this.config.before_send))return e;var t=j(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var n of t){if(r=n(r),U(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return zy(e.event)?w.warn(s+". This can cause unexpected behavior."):w.info(s),null}r.properties&&!Ci(r.properties)||w.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(r)})}Zr(e){var t=kt(e)&&!e,r=se.H()&&se.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(i,e){for(var t=0;t<e.length;t++)i.prototype[e[t]]=mb(i.prototype[e[t]])})(as,["identify"]);mk=(function(i){return i.SHOWN="product tour shown",i.DISMISSED="product tour dismissed",i.COMPLETED="product tour completed",i.STEP_SHOWN="product tour step shown",i.STEP_COMPLETED="product tour step completed",i.BUTTON_CLICKED="product tour button clicked",i.STEP_SELECTOR_FAILED="product tour step selector failed",i.BANNER_CONTAINER_SELECTOR_FAILED="product tour banner container selector failed",i.BANNER_ACTION_CLICKED="product tour banner action clicked",i})({}),yk=(function(i){return i.TOUR_ID="$product_tour_id",i.TOUR_NAME="$product_tour_name",i.TOUR_ITERATION="$product_tour_iteration",i.TOUR_RENDER_REASON="$product_tour_render_reason",i.TOUR_STEP_ID="$product_tour_step_id",i.TOUR_STEP_ORDER="$product_tour_step_order",i.TOUR_STEP_TYPE="$product_tour_step_type",i.TOUR_DISMISS_REASON="$product_tour_dismiss_reason",i.TOUR_BUTTON_TEXT="$product_tour_button_text",i.TOUR_BUTTON_ACTION="$product_tour_button_action",i.TOUR_BUTTON_LINK="$product_tour_button_link",i.TOUR_BUTTON_TOUR_ID="$product_tour_button_tour_id",i.TOUR_STEPS_COUNT="$product_tour_steps_count",i.TOUR_STEP_SELECTOR="$product_tour_step_selector",i.TOUR_STEP_SELECTOR_FOUND="$product_tour_step_selector_found",i.TOUR_STEP_ELEMENT_TAG="$product_tour_step_element_tag",i.TOUR_STEP_ELEMENT_ID="$product_tour_step_element_id",i.TOUR_STEP_ELEMENT_CLASSES="$product_tour_step_element_classes",i.TOUR_STEP_ELEMENT_TEXT="$product_tour_step_element_text",i.TOUR_ERROR="$product_tour_error",i.TOUR_MATCHES_COUNT="$product_tour_matches_count",i.TOUR_FAILURE_PHASE="$product_tour_failure_phase",i.TOUR_WAITED_FOR_ELEMENT="$product_tour_waited_for_element",i.TOUR_WAIT_DURATION_MS="$product_tour_wait_duration_ms",i.TOUR_BANNER_SELECTOR="$product_tour_banner_selector",i.TOUR_LINKED_SURVEY_ID="$product_tour_linked_survey_id",i.USE_MANUAL_SELECTOR="$use_manual_selector",i.INFERENCE_DATA_PRESENT="$inference_data_present",i})({}),wt=(eh=Ar[Oi]=new as,(function(){function i(){i.done||(i.done=!0,lf=!1,J(Ar,(function(e){e._dom_loaded()})))}k!=null&&k.addEventListener?k.readyState==="complete"?i():de(k,"DOMContentLoaded",i,{capture:!1}):m&&w.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),eh)});var uf={};ds(uf,{Posthog:()=>bl});var Qt,bl,df=Re(()=>{"use strict";cf();gi();vi();Qt=class Qt{constructor(e,t=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=rt("[PostHog]",()=>this.debug);this.init=()=>{try{let{apiKey:e,api_host:t,config:r={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.log("init | loading PostHog SDK",{api_host:t||co});let n={api_host:t||co,ui_host:ru,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...r.session_recording},before_send:s=>{if(typeof window>"u")return null;let o=window.location.hostname;if(o==="localhost"||o==="127.0.0.1")return s;let a=uo.some(l=>o.endsWith(`.${l}`)||o===l);return a||this.log("init | before_send blocked event from disallowed host",{currentHost:o}),a?s:null},...r};wt.init(e,n),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let r=typeof wt._isIdentified=="function"?wt._isIdentified():this.has_identified;if(e&&!r){let{email:n,...s}=t;this.log("identifyEvent | identifying user",{user_id:e,safeTraits:s}),wt.identify(e,{...s,client_id:e,...n&&{is_internal:go(n)}}),this.has_identified=!0}else this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(r){console.error("Posthog: Failed to identify user",r)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),wt.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=(e,t)=>{if(!(!this.has_initialized||!e))try{let r=wt.get_property("$stored_person_properties"),n={};r?.client_id||(n.client_id=e),t&&r?.is_internal===void 0&&(n.is_internal=go(t)),Object.keys(n).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:n}),wt.setPersonProperties(n)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e})}catch(r){console.error("Posthog: Failed to backfill person properties",r)}};this.capture=(e,t)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:t}),wt.capture(e,t)}catch(r){console.error("Posthog: Failed to capture event",r)}};this.options=e,this.debug=t,this.init()}};Qt.getPosthogInstance=(e,t=!1)=>(Qt._instance||(Qt._instance=new Qt(e,t)),Qt._instance);bl=Qt});var TE={};ds(TE,{Analytics:()=>hf,cacheTrackEvents:()=>_i});ao();gi();vi();var Vm=2*365*24*60*60,qt=class qt{constructor(e,t,r=!1){this.analytics=new di;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=rt("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let t=window.location.hostname,s=["webflow.io"].some(c=>t.endsWith(c))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let c=new Uint8Array(16);crypto.getRandomValues(c),c[6]=c[6]&15|64,c[8]=c[8]&63|128;let 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=${s}; max-age=${Vm}; SameSite=Lax${l}`}catch(t){console.warn("RudderStack: Failed to set anonymous ID cookie",t)}};this.getUserId=()=>this.analytics.getUserId();this.init=e=>{if(!e){console.warn("RudderStack: Initialization skipped - no key provided");return}this.log("init | loading SDK",{dataplane:lo});try{this.setCookieIfNotExists(),this.analytics.load(e,lo,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.log("init | SDK loaded successfully",{userId:this.getUserId(),anonymousId:this.getAnonymousId()}),this.onLoadedCallback?.()}})}catch(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let r=this.getUserId();if(!r||r!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:t}),this.analytics.identify(e,t||{}),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,t="Deriv App",r,n)=>{if(!(!this.has_initialized||e===this.current_page))try{let s={...r&&{user_id:r},...n};this.log("pageView | tracking page view",{platform:t,current_page:e,properties:s}),this.analytics.page(t,e,s),this.current_page=e}catch(s){console.error("RudderStack: Failed to track page view",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting RudderStack session"),this.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,t)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:t}),this.analytics.track(e,t)}catch(r){console.warn("RudderStack: Failed to track event",r)}};this.onLoadedCallback=t,this.debug=r,this.init(e)}};qt.getRudderStackInstance=(e,t,r=!1)=>(qt._instance||(qt._instance=new qt(e,t,r)),qt._instance);var dn=qt;fo();gi();var hn="cached_analytics_events",fn="cached_analytics_page_views",lu=(i,e)=>{try{let t=Ji(),r=Qe.get(hn),n=r?JSON.parse(r):[];n.push({name:i,properties:e,timestamp:Date.now()});let s={expires:1};t&&(s.domain=t),Qe.set(hn,JSON.stringify(n),s)}catch(t){console.warn("Analytics: Failed to cache event",t)}},cu=(i,e)=>{try{let t=Ji(),r=Qe.get(fn),n=r?JSON.parse(r):[];n.push({name:i,properties:e,timestamp:Date.now()});let s={expires:1};t&&(s.domain=t),Qe.set(fn,JSON.stringify(n),s)}catch(t){console.warn("Analytics: Failed to cache page view",t)}},uu=()=>{try{let i=Qe.get(hn);if(i){let e=JSON.parse(i);return Array.isArray(e)?e:[]}}catch(i){console.warn("Analytics: Failed to get cached events",i)}return[]},du=()=>{try{let i=Qe.get(fn);if(i){let e=JSON.parse(i);return Array.isArray(e)?e:[]}}catch(i){console.warn("Analytics: Failed to get cached pages",i)}return[]},hu=()=>{let i=Ji(),e=i?{domain:i}:{};Qe.remove(hn,e)},fu=()=>{let i=Ji(),e=i?{domain:i}:{};Qe.remove(fn,e)};vi();vi();var po=class{constructor(){this.interval=null;this.responses=[];this.isTrackingResponses=!1;this.delegatedSelectors=new Set;this.debug=!1;this.log=rt("[CacheManager]",()=>this.debug);this.addEventhandler=this.addEventHandler.bind(this)}setDebug(e){this.debug=e}hash(e,t=32){let r=a=>{let l=2166136261;for(let c=0;c<a.length;c++)l^=a.charCodeAt(c),l=l*16777619>>>0;return l.toString(16)},n=a=>btoa(a),s=r(e),o=n(s);for(;o.length<t;)o+=n(r(o));return o.substring(0,t)}getCookies(e){let r=`; ${document.cookie}`.split(`; ${e}=`);if(r.length===2){let n=decodeURIComponent(r.pop().split(";").shift());try{return JSON.parse(n)}catch{return n}}return null}trackPageUnload(){typeof window>"u"||window.addEventListener("beforeunload",()=>{this.isPageViewSent()||this.push("cached_analytics_page_views",{name:window.location.href,properties:{url:window.location.href}})})}trackResponses(){if(typeof window>"u"||typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(r,n){return this._url=n,this._method=r,e.apply(this,arguments)},XMLHttpRequest.prototype.send=function(r){return this.addEventListener("load",function(){let n=null;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}let s={url:this._url,method:this._method,status:this.status,headers:this.getAllResponseHeaders(),data:this.responseText,payload:n};_i.responses.push(s)}),t.apply(this,arguments)},this.isTrackingResponses=!0}getAnalyticsInstance(){return typeof window>"u"?null:window.AnalyticsInstance??window.DerivAnalytics?.Analytics??window.Analytics?.Analytics}isReady(){if(typeof window>"u")return!1;let e=this.getAnalyticsInstance();return e?!!e.getInstances?.()?.tracking:!1}parseCookies(e){if(typeof document>"u")return null;let t=document.cookie.split("; ");for(let r of t){let n=r.indexOf("=");if(n!==-1&&decodeURIComponent(r.slice(0,n))===e){let s=r.slice(n+1);try{return JSON.parse(decodeURIComponent(s))}catch{return decodeURIComponent(s)}}}return null}isPageViewSent(){return!!this.responses.find(e=>e.payload?.type==="page"&&e.payload?.anonymousId)}set(e){this.log("set | caching event to cookie",e),this.push("cached_analytics_events",e)}push(e,t){if(typeof document>"u")return;let r=[],n=this.parseCookies(e);n&&Array.isArray(n)&&(r=n),r.push(t);let s=this.getAllowedDomain(),o=365*24*60*60,a=`${e}=${encodeURIComponent(JSON.stringify(r))}; path=/; Domain=${s}; max-age=${o}; SameSite=Lax`;document.cookie=a}getAllowedDomain(){if(typeof window>"u")return"";let e=window.location.hostname;if(e==="localhost"||/^\d+\.\d+\.\d+\.\d+$/.test(e))return e;let t=e.split(".");return t.length===1?e:`.${t.slice(-2).join(".")}`}processEvent(e){let t=this.getCookies("client_information");if(t){let{email:r=null}=t;r&&(e.properties.email_hash=this.hash(r))}if(e?.properties?.email){let r=e.properties.email;delete e.properties.email,e.properties.email_hash=this.hash(r)}return e}track(e,t=!1){if(typeof window>"u")return;let r=this.processEvent(e),n=this.getAnalyticsInstance();this.isReady()&&!t?(this.log("track | analytics ready \u2014 calling trackEvent",{event:r.name,properties:r.properties}),n.trackEvent(r.name,r.properties)):(this.log("track | analytics not ready or cache=true \u2014 storing event",{event:r.name,cache:t}),this.set(r))}pageView(){typeof window>"u"||(this.log("pageView | starting page view polling"),this.isTrackingResponses||(this.trackResponses(),this.trackPageUnload()),this.interval=setInterval(()=>{let e=window.Analytics;typeof e<"u"&&typeof e.Analytics?.pageView=="function"&&this.isReady()&&(this.log("pageView | analytics ready \u2014 sending page view",{href:window.location.href}),e.Analytics.pageView(window.location.href,"Trader's hub")),this.isPageViewSent()&&(this.log("pageView | page view confirmed sent \u2014 clearing interval"),this.interval&&clearInterval(this.interval))},1e3))}listen(e,{name:t="",properties:r={}},n=!1,s=null){let o=l=>{l.dataset?.clickEventTracking||(l.addEventListener("click",c=>{let u={name:t,properties:r,cache:n};if(typeof s=="function"){let h=s(c);u={...h,cache:h.cache??n}}this.track(u,u.cache??!1)}),l.dataset.clickEventTracking="true")};(e instanceof NodeList?Array.from(e):[e]).forEach(o)}addEventHandler(e){return typeof window>"u"?this:(e.forEach(({element:t,event:r={name:"",properties:{}},cache:n=!1,callback:s=null})=>{if(typeof t=="string"){let o=t;if(!this.delegatedSelectors.has(o)){let a=l=>{let c=l.target;if(!c)return;let u=c.closest(o);if(u&&!u.dataset?.clickEventTracking){let h={name:r.name,properties:r.properties,cache:n};if(typeof s=="function"){let g=s(l);h={...g,cache:g.cache??n}}u.dataset.clickEventTracking="true",this.track(h,h.cache??!1)}};document.addEventListener("click",a),this.delegatedSelectors.add(o)}}else(t instanceof NodeList?Array.from(t):[t]).forEach(a=>{a&&!a.dataset?.clickEventTracking&&this.listen(a,r,n,s)})}),this)}loadEvent(e){return this.log("loadEvent | firing load events",e.map(t=>t.event.name)),e.forEach(({event:t})=>{let{name:r,properties:n}=t;this.track({name:r,properties:n})}),this}pageLoadEvent(e){if(typeof window>"u")return this;let t=window.location.pathname.slice(1);return this.log("pageLoadEvent | checking page load events",{pathname:t}),e.forEach(({pages:r=[],excludedPages:n=[],event:s,callback:o=null})=>{let a=!1;if(r.length?r.includes(t)&&(a=!0):n.length&&n.includes(t)||(a=!0),a){let l=o?o():s;this.log("pageLoadEvent | dispatching event for page",{pathname:t,event:l.name}),this.loadEvent([{event:l}])}else this.log("pageLoadEvent | skipped event for page",{pathname:t,event:s.name,pages:r,excludedPages:n})}),this}clearInterval(){this.interval&&(clearInterval(this.interval),this.interval=null)}cleanup(){this.clearInterval(),this.responses=[],this.isTrackingResponses=!1}},_i=new po;typeof window<"u"&&(window.cacheTrackEvents=_i);function AE(i){let e=i?.debug??!1,t=rt("",()=>e),r,n,s,o={},a={},l=[],c=[],u=!1,h=()=>{if(!u&&n?.has_initialized){u=!0;try{let A=uu();A.length>0&&(t(`processCookieCache | replaying ${A.length} cached event(s)`,A),A.forEach(M=>{n?.track(M.name,M.properties)}),hu());let x=du();x.length>0&&(t(`processCookieCache | replaying ${x.length} cached page view(s)`,x),x.forEach(M=>{n?.pageView(M.name,"Deriv App",N(),M.properties)}),fu())}catch(A){console.warn("Analytics: Failed to process cookie cache",A)}}},g=()=>{t("onSdkLoaded | RudderStack SDK loaded"),h(),c.length>0&&t(`onSdkLoaded | flushing ${c.length} pending identify call(s)`),c.forEach(({userId:A,traits:x})=>{A&&n?.identifyEvent(A,x)}),c=[]},f=async({growthbookKey:A,growthbookDecryptionKey:x,rudderstackKey:M,growthbookOptions:L,posthogOptions:ce,debug:q})=>{var X,he;q!==void 0&&(e=q),_i.setDebug(e),t("initialise | starting analytics initialization",{rudderstack:!!M,growthbook:!!A,posthog:!!ce});try{let Z=L?.attributes?.country||(A?await su():void 0);if(M&&(t("initialise | initializing RudderStack"),n=dn.getRudderStackInstance(M,g,e)),L?.attributes&&Object.keys(L.attributes).length>0){let P=L.attributes,Ie=n?.getAnonymousId();o={...o,country:Z,...P.user_language&&{user_language:P.user_language},...P.account_type&&{account_type:P.account_type},...P.app_id&&{app_id:P.app_id},...P.residence_country&&{residence_country:P.residence_country},...P.device_type&&{device_type:P.device_type},...P.url&&{url:P.url},...P.email_hash&&{email_hash:P.email_hash},...P.network_type&&{network_type:P.network_type},...P.network_rtt&&{network_rtt:P.network_rtt},...P.network_downlink&&{network_downlink:P.network_downlink},...P.account_currency&&{account_currency:P.account_currency},...P.account_mode&&{account_mode:P.account_mode},loggedIn:!!P.loggedIn,...P.user_id&&!Qi(P.user_id)&&{user_id:P.user_id},...Ie&&{anonymous_id:Ie}}}L??(L={}),L.attributes??(L.attributes={});let _e=n?.getAnonymousId();if((X=L.attributes).id??(X.id=_e),(he=L.attributes).country??(he.country=Z),A){t("initialise | initializing GrowthBook");let{Growthbook:P}=await Promise.resolve().then(()=>(sd(),nd));r=P.getGrowthBookInstance(A,x,L,e),t("initialise | GrowthBook initialized");let Ie=setInterval(()=>{Object.keys(a).length>0?clearInterval(Ie):a=_("tracking-buttons-config",{})},1e3)}if(ce){t("initialise | initializing PostHog");let{Posthog:P}=await Promise.resolve().then(()=>(df(),uf));s=P.getPosthogInstance(ce,e),t("initialise | PostHog initialized")}t("initialise | analytics initialization complete")}catch(Z){console.warn("Analytics: Failed to initialize",Z)}},p=({country:A,user_language:x,device_language:M,device_type:L,account_type:ce,user_id:q,anonymous_id:X,app_id:he,utm_source:Z,utm_medium:_e,utm_campaign:P,is_authorised:Ie,residence_country:Le,url:Zt,domain:$r,geo_location:Ui,loggedIn:Me,network_downlink:Bi,network_rtt:ei,network_type:Ft,account_currency:ti,account_mode:ii})=>{let ri=q??N();if(t("setAttributes | received attributes",{country:A,user_language:x,device_language:M,device_type:L,account_type:ce,user_id:q,anonymous_id:X,app_id:he,utm_source:Z,utm_medium:_e,utm_campaign:P,is_authorised:Ie,residence_country:Le,url:Zt,domain:$r,geo_location:Ui,loggedIn:Me,network_downlink:Bi,network_rtt:ei,network_type:Ft,account_currency:ti,account_mode:ii}),r){let At={country:A,residence_country:Le,user_language:x,device_language:M,device_type:L,utm_source:Z,utm_medium:_e,utm_campaign:P,is_authorised:Ie,url:Zt,domain:$r,loggedIn:Me,...q&&!Qi(q)&&{user_id:q},anonymous_id:X};ri&&(At.id=ri,At.user_id=ri),t("setAttributes | called GrowthBook setAttributes",At),r.setAttributes(At)}o={...o,...A!==void 0&&{country:A},...Ui!==void 0&&{geo_location:Ui},...x!==void 0&&{user_language:x},...ce!==void 0&&{account_type:ce},...he!==void 0&&{app_id:he},...Le!==void 0&&{residence_country:Le},...L!==void 0&&{device_type:L},...Zt!==void 0&&{url:Zt},...Me!==void 0&&{loggedIn:Me},...Bi!==void 0&&{network_downlink:Bi},...ei!==void 0&&{network_rtt:ei},...Ft!==void 0&&{network_type:Ft},...q!==void 0&&!Qi(q)&&{user_id:q},...X!==void 0&&{anonymous_id:X},...ti!==void 0&&{account_currency:ti},...ii!==void 0&&{account_mode:ii}},t("setAttributes | updated core_data",o)},v=A=>r?.getFeatureState(A)?.experimentResult?.name,_=(A,x)=>r?.getFeatureValue(A,x),b=async()=>await r?.getStatus(),E=A=>r?.isOn(A),D=A=>r?.setUrl(A),N=()=>{let A=n?.getUserId()||"";return A&&!Qi(A)?A:""},R=()=>n?.getAnonymousId()||"",K=(A,x="Deriv App",M)=>{let L=N();t("pageView | called",{current_page:A,platform:x,properties:M,userId:L}),n&&(n.has_initialized?(t("pageView | sending page view to RudderStack",{current_page:A,platform:x}),n.pageView(A,x,L,M)):(t("pageView | RudderStack not initialized \u2014 caching page view to cookie",{current_page:A}),cu(A,{platform:x,...M})))},B=(A,x)=>{let M=A||N();if(!M){t("identifyEvent | skipped \u2014 no user_id available");return}t("identifyEvent | called",{user_id:M,traits:x});let L=x?.rudderstack!==void 0||x?.posthog!==void 0,ce=L?x?.rudderstack:x,q=L?x?.posthog:x;n&&(n.has_initialized?(t("identifyEvent | calling RudderStack identify",{user_id:M,traits:ce}),n.identifyEvent(M,ce)):c.some(X=>X.userId===M)||(t("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:M}),c.push({userId:M,traits:ce}))),s?.has_initialized&&q&&(t("identifyEvent | calling PostHog identify",{user_id:M,traits:q}),s.identifyEvent(M,q))},C=()=>{t("reset | resetting all providers"),n?.has_initialized&&(t("reset | resetting RudderStack"),n.reset()),s?.has_initialized&&(t("reset | resetting PostHog"),s.reset())},pe=A=>"event_metadata"in A||"cta_information"in A||"error"in A,Ge={initialise:f,setAttributes:p,identifyEvent:B,backfillPersonProperties:(A,x)=>{t("backfillPersonProperties | called",{user_id:A}),s?.has_initialized?(t("backfillPersonProperties | backfilling person properties in PostHog",{user_id:A}),s.backfillPersonProperties(A,x)):t("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:v,getFeatureValue:_,getGrowthbookStatus:b,isFeatureOn:E,setUrl:D,getId:N,getAnonymousId:R,trackEvent:(A,x)=>{let M=N(),L={};if(t("trackEvent | called",{event:A,analytics_data:x,userId:M,core_data:o}),pe(x)){let X=x;L={...X,event_metadata:{...o,...M&&!o.user_id&&{user_id:M},...X.event_metadata}},t("trackEvent | built V2 payload",{event:A,final_payload:L})}else L={...o,...x,...M&&!o.user_id&&{user_id:M}},t("trackEvent | built V1 payload",{event:A,final_payload:L});if(!(!(A in a)||a[A])){t("trackEvent | skipped \u2014 event disabled by tracking_config",{event:A});return}let q=n?.has_initialized;if(!navigator.onLine||!q)q?(t("trackEvent | offline \u2014 caching event to memory",{event:A}),l.push({event:A,payload:L})):(t("trackEvent | RudderStack not initialized \u2014 caching event to cookie",{event:A}),lu(A,L));else{l.length>0&&(t(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(he=>{let Z=pi(he.payload);n?.track(he.event,Z)}),l=[]);let X=pi(L);t("trackEvent | sending event to RudderStack",{event:A,payload:X}),n?.track(A,X)}if(s?.has_initialized){let X=au(L),he=pi(X);t("trackEvent | sending event to PostHog",{event:A,payload:he}),s.capture(A,he)}},getInstances:()=>({ab:r,tracking:n,posthog:s}),pageView:K,reset:C};return typeof window<"u"&&(window.AnalyticsInstance=Ge),Ge}var hf=AE();return mf(TE);})();
|
|
18
18
|
/*! Bundled license information:
|
|
19
19
|
|
|
20
20
|
js-cookie/dist/js.cookie.mjs:
|