@deriv-com/analytics 1.39.5 → 1.39.6

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.
Files changed (36) hide show
  1. package/dist/browser/analytics.bundle.global.js +13 -13
  2. package/dist/browser/analytics.bundle.global.js.map +1 -1
  3. package/dist/browser/analytics.esm.mjs +1 -1
  4. package/dist/browser/analytics.esm.mjs.map +1 -1
  5. package/dist/chunk-GTT7DF4Y.mjs +3 -0
  6. package/dist/chunk-GTT7DF4Y.mjs.map +1 -0
  7. package/dist/chunk-YZ34YKBW.js +3 -0
  8. package/dist/chunk-YZ34YKBW.js.map +1 -0
  9. package/dist/index.d.mts +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +2 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +2 -2
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/metafile-cjs.json +1 -1
  16. package/dist/metafile-esm.json +1 -1
  17. package/dist/metafile-iife.json +1 -1
  18. package/dist/{posthog-CZnsy0at.d.ts → posthog-DUxm7AzZ.d.ts} +6 -0
  19. package/dist/{posthog-CRa194Jm.d.mts → posthog-DfHTd53-.d.mts} +6 -0
  20. package/dist/posthog-WH6LGSSW.mjs +6 -0
  21. package/dist/posthog-WH6LGSSW.mjs.map +1 -0
  22. package/dist/providers/posthog/index.d.mts +1 -1
  23. package/dist/providers/posthog/index.d.ts +1 -1
  24. package/dist/providers/posthog/index.js +1 -1
  25. package/dist/providers/posthog/index.js.map +1 -1
  26. package/dist/providers/posthog/index.mjs +1 -1
  27. package/dist/providers/posthog/index.mjs.map +1 -1
  28. package/dist/providers/rudderstack/index.js +1 -1
  29. package/dist/providers/rudderstack/index.mjs +1 -1
  30. package/package.json +2 -2
  31. package/dist/chunk-BGCEXYPC.mjs +0 -3
  32. package/dist/chunk-BGCEXYPC.mjs.map +0 -1
  33. package/dist/chunk-GVFVS6VE.js +0 -3
  34. package/dist/chunk-GVFVS6VE.js.map +0 -1
  35. package/dist/posthog-ZW7SFGPQ.mjs +0 -6
  36. package/dist/posthog-ZW7SFGPQ.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 Ls=Object.defineProperty;var Jh=Object.getOwnPropertyDescriptor;var Zh=Object.getOwnPropertyNames;var ef=Object.prototype.hasOwnProperty;var tf=(i,e,t)=>e in i?Ls(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Re=(i,e)=>()=>(i&&(e=i(i=0)),e);var un=(i,e)=>{for(var t in e)Ls(i,t,{get:e[t],enumerable:!0})},sf=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Zh(e))!ef.call(i,r)&&r!==t&&Ls(i,r,{get:()=>e[r],enumerable:!(s=Jh(e,r))||s.enumerable});return i};var rf=i=>sf(Ls({},"__esModule",{value:!0}),i);var re=(i,e,t)=>tf(i,typeof e!="symbol"?e+"":e,t);function oe(i){return i!=null&&typeof i=="object"&&i["@@functional/placeholder"]===!0}function dt(i){return function e(t){return arguments.length===0||oe(t)?e:i.apply(this,arguments)}}function At(i){return function e(t,s){switch(arguments.length){case 0:return e;case 1:return oe(t)?e:dt(function(r){return i(t,r)});default:return oe(t)&&oe(s)?e:oe(t)?dt(function(r){return i(r,s)}):oe(s)?dt(function(r){return i(t,r)}):i(t,s)}}}function Xn(i){return function e(t,s,r){switch(arguments.length){case 0:return e;case 1:return oe(t)?e:At(function(n,o){return i(t,n,o)});case 2:return oe(t)&&oe(s)?e:oe(t)?At(function(n,o){return i(n,s,o)}):oe(s)?At(function(n,o){return i(t,n,o)}):dt(function(n){return i(t,s,n)});default:return oe(t)&&oe(s)&&oe(r)?e:oe(t)&&oe(s)?At(function(n,o){return i(n,o,r)}):oe(t)&&oe(r)?At(function(n,o){return i(n,s,o)}):oe(s)&&oe(r)?At(function(n,o){return i(t,n,o)}):oe(t)?dt(function(n){return i(n,s,r)}):oe(s)?dt(function(n){return i(t,n,r)}):oe(r)?dt(function(n){return i(t,s,n)}):i(t,s,r)}}}function $s(i,e){return Object.prototype.hasOwnProperty.call(e,i)}function sl(i){return Object.prototype.toString.call(i)==="[object Object]"}function af(i,e){var t=i<0?e.length+i:i;return e[t]}function lf(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 Bl(i,e,t){if(t||(t=new uf),cf(i))return i;var s=function(n){var o=t.get(i);if(o)return o;t.set(i,n);for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=Bl(i[a],!0,t));return n};switch(nf(i)){case"Object":return s(Object.create(Object.getPrototypeOf(i)));case"Array":return s(Array(i.length));case"Date":return new Date(i.valueOf());case"RegExp":return lf(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 cf(i){var e=typeof i;return i==null||e!="object"&&e!="function"}function df(i,e){for(var t=e,s=0;s<i.length;s+=1){if(t==null)return;var r=i[s];of(r)?t=af(r,t):t=t[r]}return t}function Cf(i){return crypto.getRandomValues(new Uint8Array(i))}function Pf(){(!fn||Tt+16>nl)&&(fn=Cf(nl),Tt=0);for(var i=0,e,t="";i<16;i++)e=fn[Tt+i],i==6?t+=Bs[e&15|64]:i==8?t+=Bs[e&63|128]:t+=Bs[e],i&1&&i>1&&i<11&&(t+="-");return Tt+=16,t}function Nf(){var i=0,e,t="";if(!Ms||Gt+16>256){for(Ms=Array(i=256);i--;)Ms[i]=256*Math.random()|0;i=Gt=0}for(;i<16;i++)e=Ms[Gt+i],i==6?t+=Vs[e&15|64]:i==8?t+=Vs[e&63|128]:t+=Vs[e],i&1&&i>1&&i<11&&(t+="-");return Gt++,t}function ng(i,e,t=rg){let s;return(...r)=>{globalThis.clearTimeout(s),s=globalThis.setTimeout(()=>{i.apply(e,r)},t)}}function rr(){if(It>1)It--;else{for(var i,e=!1;Ki!==void 0;){var t=Ki;for(Ki=void 0,Sn++;t!==void 0;){var s=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&tc(t))try{t.c()}catch(r){e||(i=r,e=!0)}t=s}}if(Sn=0,It--,e)throw i}}function ke(i){if(It>0)return i();It++;try{return i()}finally{rr()}}function Zl(i){var e=W;W=void 0;try{return i()}finally{W=e}}function ec(i){if(W!==void 0){var e=i.n;if(e===void 0||e.t!==W)return e={i:0,S:i,p:W.s,n:void 0,t:W,e:void 0,x:void 0,r:e},W.s!==void 0&&(W.s.n=e),W.s=e,i.n=e,32&W.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=W.s,e.n=void 0,W.s.n=e,W.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 tc(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 ic(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 sc(i){for(var e=i.s,t=void 0;e!==void 0;){var s=e.p;e.i===-1?(e.S.U(e),s!==void 0&&(s.n=e.n),e.n!==void 0&&(e.n.p=s)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=s}i.s=t}function fi(i,e){we.call(this,void 0),this.x=i,this.s=void 0,this.g=Zs-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function rc(i){var e=i.u;if(i.u=void 0,typeof e=="function"){It++;var t=W;W=void 0;try{e()}catch(s){throw i.f&=-2,i.f|=8,to(i),s}finally{W=t,rr()}}}function to(i){for(var e=i.s;e!==void 0;e=e.n)e.S.U(e);i.x=void 0,i.s=void 0,rc(i)}function _g(i){if(W!==this)throw new Error("Out-of-order effect");sc(this),W=i,this.f&=-2,8&this.f&&to(this),rr()}function gi(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 tt(i,e){var t=new gi(i,e);try{t.c()}catch(r){throw t.d(),r}var s=t.d.bind(t);return s[Symbol.dispose]=s,s}function fc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function qp(){return yl||(yl=1,(function(i,e){(function(t,s){i.exports=s()})(Hp,function(){function t(p){return!isNaN(parseFloat(p))&&isFinite(p)}function s(p){return p.charAt(0).toUpperCase()+p.substring(1)}function r(p){return function(){return this[p]}}var n=["isConstructor","isEval","isNative","isToplevel"],o=["columnNumber","lineNumber"],a=["fileName","functionName","source"],l=["args"],c=["evalOrigin"],u=n.concat(o,a,l,c);function h(p){if(p)for(var m=0;m<u.length;m++)p[u[m]]!==void 0&&this["set"+s(u[m])](p[u[m]])}h.prototype={getArgs:function(){return this.args},setArgs:function(p){if(Object.prototype.toString.call(p)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=p},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(p){if(p instanceof h)this.evalOrigin=p;else if(p instanceof Object)this.evalOrigin=new h(p);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var p=this.getFileName()||"",m=this.getLineNumber()||"",E=this.getColumnNumber()||"",b=this.getFunctionName()||"";return this.getIsEval()?p?"[eval] ("+p+":"+m+":"+E+")":"[eval]:"+m+":"+E:b?b+" ("+p+":"+m+":"+E+")":p+":"+m+":"+E}},h.fromString=function(m){var E=m.indexOf("("),b=m.lastIndexOf(")"),O=m.substring(0,E),P=m.substring(E+1,b).split(","),I=m.substring(b+1);if(I.indexOf("@")===0)var z=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(I,""),B=z[1],N=z[2],ve=z[3];return new h({functionName:O,args:P||void 0,fileName:B,lineNumber:N||void 0,columnNumber:ve||void 0})};for(var g=0;g<n.length;g++)h.prototype["get"+s(n[g])]=r(n[g]),h.prototype["set"+s(n[g])]=(function(p){return function(m){this[p]=!!m}})(n[g]);for(var f=0;f<o.length;f++)h.prototype["get"+s(o[f])]=r(o[f]),h.prototype["set"+s(o[f])]=(function(p){return function(m){if(!t(m))throw new TypeError(p+" must be a Number");this[p]=Number(m)}})(o[f]);for(var v=0;v<a.length;v++)h.prototype["get"+s(a[v])]=r(a[v]),h.prototype["set"+s(a[v])]=(function(p){return function(m){this[p]=String(m)}})(a[v]);return h})})(qs)),qs.exports}function Kp(){return bl||(bl=1,(function(i,e){(function(t,s){i.exports=s(qp())})(zp,function(s){var r=/(^|@)\S+:\d+/,n=/^\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(n))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(n)},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),v=g&&h||void 0,p=["eval","<anonymous>"].indexOf(f[0])>-1?void 0:f[0];return new s({functionName:v,fileName:p,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 s({functionName:u});var h=/((.*".+"[^@]*)?[^@]*)(?:@)/,g=u.match(h),f=g&&g[1]?g[1]:void 0,v=this.extractLocation(u.replace(h,""));return new s({functionName:f,fileName:v[0],lineNumber:v[1],columnNumber:v[2],source:u})},this)},parseOpera:function(l){return!l.stacktrace||l.message.indexOf(`
2
+ "use strict";var DerivAnalytics=(()=>{var $s=Object.defineProperty;var ig=Object.getOwnPropertyDescriptor;var sg=Object.getOwnPropertyNames;var rg=Object.prototype.hasOwnProperty;var ng=(i,e,t)=>e in i?$s(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Re=(i,e)=>()=>(i&&(e=i(i=0)),e);var gn=(i,e)=>{for(var t in e)$s(i,t,{get:e[t],enumerable:!0})},og=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of sg(e))!rg.call(i,r)&&r!==t&&$s(i,r,{get:()=>e[r],enumerable:!(s=ig(e,r))||s.enumerable});return i};var ag=i=>og($s({},"__esModule",{value:!0}),i);var re=(i,e,t)=>ng(i,typeof e!="symbol"?e+"":e,t);function oe(i){return i!=null&&typeof i=="object"&&i["@@functional/placeholder"]===!0}function dt(i){return function e(t){return arguments.length===0||oe(t)?e:i.apply(this,arguments)}}function At(i){return function e(t,s){switch(arguments.length){case 0:return e;case 1:return oe(t)?e:dt(function(r){return i(t,r)});default:return oe(t)&&oe(s)?e:oe(t)?dt(function(r){return i(r,s)}):oe(s)?dt(function(r){return i(t,r)}):i(t,s)}}}function Qn(i){return function e(t,s,r){switch(arguments.length){case 0:return e;case 1:return oe(t)?e:At(function(n,o){return i(t,n,o)});case 2:return oe(t)&&oe(s)?e:oe(t)?At(function(n,o){return i(n,s,o)}):oe(s)?At(function(n,o){return i(t,n,o)}):dt(function(n){return i(t,s,n)});default:return oe(t)&&oe(s)&&oe(r)?e:oe(t)&&oe(s)?At(function(n,o){return i(n,o,r)}):oe(t)&&oe(r)?At(function(n,o){return i(n,s,o)}):oe(s)&&oe(r)?At(function(n,o){return i(t,n,o)}):oe(t)?dt(function(n){return i(n,s,r)}):oe(s)?dt(function(n){return i(t,n,r)}):oe(r)?dt(function(n){return i(t,s,n)}):i(t,s,r)}}}function Fs(i,e){return Object.prototype.hasOwnProperty.call(e,i)}function nl(i){return Object.prototype.toString.call(i)==="[object Object]"}function ug(i,e){var t=i<0?e.length+i:i;return e[t]}function dg(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 Gl(i,e,t){if(t||(t=new gg),hg(i))return i;var s=function(n){var o=t.get(i);if(o)return o;t.set(i,n);for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=Gl(i[a],!0,t));return n};switch(lg(i)){case"Object":return s(Object.create(Object.getPrototypeOf(i)));case"Array":return s(Array(i.length));case"Date":return new Date(i.valueOf());case"RegExp":return dg(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 hg(i){var e=typeof i;return i==null||e!="object"&&e!="function"}function fg(i,e){for(var t=e,s=0;s<i.length;s+=1){if(t==null)return;var r=i[s];cg(r)?t=ug(r,t):t=t[r]}return t}function Dg(i){return crypto.getRandomValues(new Uint8Array(i))}function xg(){(!vn||Tt+16>al)&&(vn=Dg(al),Tt=0);for(var i=0,e,t="";i<16;i++)e=vn[Tt+i],i==6?t+=Vs[e&15|64]:i==8?t+=Vs[e&63|128]:t+=Vs[e],i&1&&i>1&&i<11&&(t+="-");return Tt+=16,t}function Lg(){var i=0,e,t="";if(!Us||Gt+16>256){for(Us=Array(i=256);i--;)Us[i]=256*Math.random()|0;i=Gt=0}for(;i<16;i++)e=Us[Gt+i],i==6?t+=Gs[e&15|64]:i==8?t+=Gs[e&63|128]:t+=Gs[e],i&1&&i>1&&i<11&&(t+="-");return Gt++,t}function cf(i,e,t=lf){let s;return(...r)=>{globalThis.clearTimeout(s),s=globalThis.setTimeout(()=>{i.apply(e,r)},t)}}function nr(){if(It>1)It--;else{for(var i,e=!1;Ki!==void 0;){var t=Ki;for(Ki=void 0,Tn++;t!==void 0;){var s=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&sc(t))try{t.c()}catch(r){e||(i=r,e=!0)}t=s}}if(Tn=0,It--,e)throw i}}function Ee(i){if(It>0)return i();It++;try{return i()}finally{nr()}}function tc(i){var e=K;K=void 0;try{return i()}finally{K=e}}function ic(i){if(K!==void 0){var e=i.n;if(e===void 0||e.t!==K)return e={i:0,S:i,p:K.s,n:void 0,t:K,e:void 0,x:void 0,r:e},K.s!==void 0&&(K.s.n=e),K.s=e,i.n=e,32&K.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=K.s,e.n=void 0,K.s.n=e,K.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 sc(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 rc(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 nc(i){for(var e=i.s,t=void 0;e!==void 0;){var s=e.p;e.i===-1?(e.S.U(e),s!==void 0&&(s.n=e.n),e.n!==void 0&&(e.n.p=s)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=s}i.s=t}function gi(i,e){we.call(this,void 0),this.x=i,this.s=void 0,this.g=er-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function oc(i){var e=i.u;if(i.u=void 0,typeof e=="function"){It++;var t=K;K=void 0;try{e()}catch(s){throw i.f&=-2,i.f|=8,ro(i),s}finally{K=t,nr()}}}function ro(i){for(var e=i.s;e!==void 0;e=e.n)e.S.U(e);i.x=void 0,i.s=void 0,oc(i)}function Ef(i){if(K!==this)throw new Error("Out-of-order effect");nc(this),K=i,this.f&=-2,8&this.f&&ro(this),nr()}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 tt(i,e){var t=new fi(i,e);try{t.c()}catch(r){throw t.d(),r}var s=t.d.bind(t);return s[Symbol.dispose]=s,s}function pc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Xp(){return El||(El=1,(function(i,e){(function(t,s){i.exports=s()})(Wp,function(){function t(p){return!isNaN(parseFloat(p))&&isFinite(p)}function s(p){return p.charAt(0).toUpperCase()+p.substring(1)}function r(p){return function(){return this[p]}}var n=["isConstructor","isEval","isNative","isToplevel"],o=["columnNumber","lineNumber"],a=["fileName","functionName","source"],l=["args"],u=["evalOrigin"],c=n.concat(o,a,l,u);function h(p){if(p)for(var m=0;m<c.length;m++)p[c[m]]!==void 0&&this["set"+s(c[m])](p[c[m]])}h.prototype={getArgs:function(){return this.args},setArgs:function(p){if(Object.prototype.toString.call(p)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=p},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(p){if(p instanceof h)this.evalOrigin=p;else if(p instanceof Object)this.evalOrigin=new h(p);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var p=this.getFileName()||"",m=this.getLineNumber()||"",E=this.getColumnNumber()||"",T=this.getFunctionName()||"";return this.getIsEval()?p?"[eval] ("+p+":"+m+":"+E+")":"[eval]:"+m+":"+E:T?T+" ("+p+":"+m+":"+E+")":p+":"+m+":"+E}},h.fromString=function(m){var E=m.indexOf("("),T=m.lastIndexOf(")"),x=m.substring(0,E),R=m.substring(E+1,T).split(","),M=m.substring(T+1);if(M.indexOf("@")===0)var F=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(M,""),W=F[1],$=F[2],ve=F[3];return new h({functionName:x,args:R||void 0,fileName:W,lineNumber:$||void 0,columnNumber:ve||void 0})};for(var g=0;g<n.length;g++)h.prototype["get"+s(n[g])]=r(n[g]),h.prototype["set"+s(n[g])]=(function(p){return function(m){this[p]=!!m}})(n[g]);for(var f=0;f<o.length;f++)h.prototype["get"+s(o[f])]=r(o[f]),h.prototype["set"+s(o[f])]=(function(p){return function(m){if(!t(m))throw new TypeError(p+" must be a Number");this[p]=Number(m)}})(o[f]);for(var v=0;v<a.length;v++)h.prototype["get"+s(a[v])]=r(a[v]),h.prototype["set"+s(a[v])]=(function(p){return function(m){this[p]=String(m)}})(a[v]);return h})})(zs)),zs.exports}function Jp(){return kl||(kl=1,(function(i,e){(function(t,s){i.exports=s(Xp())})(Yp,function(s){var r=/(^|@)\S+:\d+/,n=/^\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(n))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 u=/(.+?)(?::(\d+))?(?::(\d+))?$/,c=u.exec(l.replace(/[()]/g,""));return[c[1],c[2]||void 0,c[3]||void 0]},parseV8OrIE:function(l){var u=l.stack.split(`
3
+ `).filter(function(c){return!!c.match(n)},this);return u.map(function(c){c.indexOf("(eval ")>-1&&(c=c.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var h=c.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),v=g&&h||void 0,p=["eval","<anonymous>"].indexOf(f[0])>-1?void 0:f[0];return new s({functionName:v,fileName:p,lineNumber:f[1],columnNumber:f[2],source:c})},this)},parseFFOrSafari:function(l){var u=l.stack.split(`
4
+ `).filter(function(c){return!c.match(o)},this);return u.map(function(c){if(c.indexOf(" > eval")>-1&&(c=c.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),c.indexOf("@")===-1&&c.indexOf(":")===-1)return new s({functionName:c});var h=/((.*".+"[^@]*)?[^@]*)(?:@)/,g=c.match(h),f=g&&g[1]?g[1]:void 0,v=this.extractLocation(c.replace(h,""));return new s({functionName:f,fileName:v[0],lineNumber:v[1],columnNumber:v[2],source:c})},this)},parseOpera:function(l){return!l.stacktrace||l.message.indexOf(`
5
5
  `)>-1&&l.message.split(`
6
6
  `).length>l.stacktrace.split(`
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 v=c.exec(u[g]);v&&h.push(new s({fileName:v[2],lineNumber:v[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 v=c.exec(u[g]);v&&h.push(new s({functionName:v[3]||void 0,fileName:v[2],lineNumber:v[1],source:u[g]}))}return h},parseOpera11:function(l){var c=l.stack.split(`
10
- `).filter(function(u){return!!u.match(r)&&!u.match(/^Error created at/)},this);return c.map(function(u){var h=u.split("@"),g=this.extractLocation(h.pop()),f=h.shift()||"",v=f.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,p;f.match(/\(([^)]*)\)/)&&(p=f.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var m=p===void 0||p==="[arguments not available]"?void 0:p.split(",");return new s({functionName:v,args:m,fileName:g[0],lineNumber:g[1],columnNumber:g[2],source:u})},this)}}})})(Hs)),Hs.exports}function kl(i,e,t,s){return{errorClass:El(i),message:`${t}${El(e)}`,type:"browserjs",stacktrace:s.reduce((r,n)=>{let o=Qp(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function kc(i,e){let t=Object.assign(i,e);for(let s of Object.keys(t))typeof t[s]=="object"&&typeof e[s]=="object"&&(t[s]=kc(t[s],e[s]));return t}async function Lv(i){let e=Dv[i];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((t,s)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=xv();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}t(e.lib)}).catch(s)})})}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 Lv(i).then(t=>t.get(e).then(s=>s()))}function h_(){return Ol||(Ol=1,(function(i,e){(function(t,s){i.exports=s()})(d_,function(){function t(f){return f=JSON.stringify(f),!!/^\{[\s\S]*\}$/.test(f)}function s(f){return f===void 0||typeof f=="function"?f+"":JSON.stringify(f)}function r(f){if(typeof f=="string")try{return JSON.parse(f)}catch{return f}}function n(f){return{}.toString.call(f)==="[object Function]"}function o(f){return Object.prototype.toString.call(f)==="[object Array]"}function a(f){var v="_Is_Incognit",p="yes";try{f||(f=window.localStorage),f.setItem(v,p),f.removeItem(v)}catch{var m={};m._data={},m.setItem=function(b,O){return m._data[b]=String(O)},m.getItem=function(b){return m._data.hasOwnProperty(b)?m._data[b]:void 0},m.removeItem=function(b){return delete m._data[b]},m.clear=function(){return m._data={}},f=m}finally{f.getItem(v)===p&&f.removeItem(v)}return f}var l=a();function c(){if(!(this instanceof c))return new c}c.prototype={set:function(v,p){if(v&&!t(v))l.setItem(v,s(p));else if(t(v))for(var m in v)this.set(m,v[m]);return this},get:function(v){if(v===void 0){var p={};return this.forEach(function(I,z){return p[I]=z}),p}if(v.charAt(0)==="?")return this.has(v.substr(1));var m=arguments;if(m.length>1){for(var E={},b=0,O=m.length;b<O;b++){var P=r(l.getItem(m[b]));this.has(m[b])&&(E[m[b]]=P)}return E}return r(l.getItem(v))},clear:function(){return l.clear(),this},remove:function(v){var p=this.get(v);return l.removeItem(v),p},has:function(v){return{}.hasOwnProperty.call(this.get(),v)},keys:function(){var v=[];return this.forEach(function(p){v.push(p)}),v},forEach:function(v){for(var p=0,m=l.length;p<m;p++){var E=l.key(p);v(E,this.get(E))}return this},search:function(v){for(var p=this.keys(),m={},E=0,b=p.length;E<b;E++)p[E].indexOf(v)>-1&&(m[p[E]]=this.get(p[E]));return m},len:function(){return l.length}};var u=null;function h(f,v){var p=arguments,m=null;if(u||(u=c()),p.length===0)return u.get();if(p.length===1){if(typeof f=="string")return u.get(f);if(t(f))return u.set(f)}if(p.length===2&&typeof f=="string"){if(!v)return u.remove(f);if(v&&typeof v=="string")return u.set(f,v);v&&n(v)&&(m=null,m=v(f,u.get(f)),h.set(f,m))}if(p.length===2&&o(f)&&n(v))for(var E=0,b=f.length;E<b;E++)m=v(f[E],u.get(f[E])),h.set(f[E],m);return h}for(var g in c.prototype)h[g]=c.prototype[g];return h})})(Ks)),Ks.exports}var nf,of,uf,G,hf,ff,gf,pf,Vl,R,te,Ne,me,Qe,vf,Y,ci,_f,Yn,mf,bn,yf,bf,Ef,ie,kf,pe,ht,ji,Xs,lt,Ze,Qn,Sf,rl,Ys,wf,Af,Qs,Jn,Gl,jl,Hl,dn,Zn,En,qe,ql,Vi,Ut,Hi,ni,Tf,hn,If,Rf,Of,Fs,nl,Bs,Tt,fn,Gt,Vs,Ms,Df,ir,xf,zl,Lf,Kl,$f,$,Ff,ol,Mf,Uf,Bf,Vf,Gf,jf,Hf,Wl,qf,Ye,zf,Xl,j,Gs,sr,eo,ce,al,Wi,Kf,Yl,Wf,ll,Xf,Yf,zi,Qf,Jf,Zf,cl,eg,ul,tg,ig,dl,kn,hl,sg,rg,Ql,Xi,Jl,fl,og,ag,lg,cg,ug,dg,hg,fg,gg,pg,Js,vg,W,Ki,It,Sn,Zs,wn,Us,gl,nc,mg,yg,bg,An,ft,ct,oc,Tn,pl,Eg,kg,Sg,wg,Ag,Tg,Ig,Rg,vl,Og,Cg,Pg,Ng,Dg,xg,Lg,_l,$g,Fg,ac,Mg,Ug,Bg,Vg,Gg,jg,Hg,ml,qg,zg,Kg,Wg,Xg,Yg,Qg,Jg,Zg,ep,tp,ip,sp,rp,np,op,ap,lp,cp,up,dp,hp,fp,gp,pp,vp,_p,lc,nr,cc,mp,Yi,or,io,uc,dc,hc,Bt,yp,In,js,bp,Ep,kp,Sp,wp,Ap,X,gn,Tp,Ip,Rp,Op,Cp,Pp,Np,Dp,xp,Lp,$p,Fp,Mp,Up,Bp,Vp,Gp,jp,d,Hs,qs,Hp,yl,zp,bl,Wp,Xp,gc,Yp,Qp,El,pc,Jp,Sl,zs,Zp,ev,tv,iv,sv,rv,nv,ov,wl,Al,Rn,vc,av,lv,cv,uv,dv,hv,fv,_c,gv,pv,vv,_v,mv,yv,bv,Ev,kv,Sv,mc,yc,wv,Av,Tv,Iv,On,bc,Cn,Rv,Ov,Cv,Tl,Pv,Ec,Nv,Dv,xv,$v,Fv,Sc,Mv,Uv,pn,Bv,Pn,Pe,Ue,He,et,jt,Vv,Gv,jv,Hv,qv,zv,Kv,Wv,Xv,Yv,Qv,Jv,oi,Zv,wc,Ac,e_,Tc,Ic,ai,Il,Rl,t_,i_,Nn,s_,ut,r_,n_,o_,a_,l_,c_,u_,Dn,er,Ks,d_,Ol,f_,Mt,Rc,li,xn,so,Ln,ro,$n,no,Xe,g_,p_,v_,__,m_,Fn,y_,Mn,b_,E_,Oc,k_,S_,w_,ui,Un,Cc,A_,T_,I_,di,vn,_n,R_,O_,C_,Cl,P_,Pc,N_,D_,x_,L_,$_,F_,M_,U_,B_,Nc,V_,G_,Bn,j_,Dc,H_,q_,z_,xc,K_,W_,Vn,X_,Y_,Q_,J_,Pl,Z_,Nl,em,Dl,Gn,tm,im,xl,mn,Lc,sm,tr,Ll,$c,$l,rm,nm,om,am,lm,qi,jn,cm,um,dm,yn,hm,fm,gm,pm,vm,Gi,Hn,qn,zn,_m,mm,ym,Fl,Ml,bm,Em,km,Sm,Ws,Kn,Ul,wm,Am,Wn,Vt,hi,oo=Re(()=>{"use strict";nf=dt(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});of=Number.isInteger||function(e){return e<<0===e};uf=(function(){function i(){this.map={},this.length=0}return i.prototype.set=function(e,t){var s=this.hash(e),r=this.map[s];r||(this.map[s]=r=[]),r.push([e,t]),this.length+=1},i.prototype.hash=function(e){var t=[];for(var s in e)t.push(Object.prototype.toString.call(e[s]));return t.join()},i.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var o=this.map[t],s=0;s<o.length;s+=1){var r=o[s];if(r[0]===e)return r[1]}return}var n=this.hash(e),o=this.map[n];if(o)for(var s=0;s<o.length;s+=1){var r=o[s];if(r[0]===e)return r[1]}},i})(),G=dt(function(e){return e!=null&&typeof e.clone=="function"?e.clone():Bl(e)});hf=Xn(function(e,t,s){var r={},n;t=t||{},s=s||{};for(n in t)$s(n,t)&&(r[n]=$s(n,s)?e(n,t[n],s[n]):t[n]);for(n in s)$s(n,s)&&!$s(n,r)&&(r[n]=s[n]);return r}),ff=Xn(function i(e,t,s){return hf(function(r,n,o){return sl(n)&&sl(o)?i(e,n,o):e(r,n,o)},t,s)}),gf=Xn(function(e,t,s){return ff(function(r,n,o){return e(n,o)},t,s)}),pf=At(df),Vl=At(function(e,t){var s={};for(var r in t)e(t[r],r,t)&&(s[r]=t[r]);return s}),R=i=>typeof i=="function"&&!!(i.constructor&&i.call&&i.apply),te=i=>typeof i=="string",Ne=i=>i===null,me=i=>typeof i>"u",Qe=i=>Ne(i)||me(i),vf=i=>typeof i=="bigint",Y=i=>!me(i),ci=i=>!Qe(i),_f=i=>ci(i)&&i!=="",Yn=i=>{switch(Object.prototype.toString.call(i)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return i instanceof Error}},mf=i=>typeof i=="boolean",bn=(i,e)=>{let t=e.split(".");return pf(t,i)},yf=(i,e)=>!!bn(i,e),bf=i=>typeof i=="object",Ef=i=>!Ne(i)&&bf(i)&&!Array.isArray(i),ie=i=>!Ne(i)&&Object.prototype.toString.call(i)==="[object Object]",kf=(i,e)=>{if(!Array.isArray(i)||!Array.isArray(e))return G(e);let t=G(i);return e.forEach((s,r)=>{t[r]=Array.isArray(s)||Ef(s)?pe(t[r],s):s}),t},pe=(i,e)=>gf(kf,i,e),ht=i=>ie(i)&&Object.keys(i).length>0,ji=i=>{let e=Vl(Y,i);return Object.keys(e).forEach(t=>{let s=e[t];ie(s)&&(e[t]=ji(s))}),e},Xs=i=>{let e=Vl(ci,i);return Object.keys(e).forEach(t=>{let s=e[t];ie(s)&&(e[t]=Xs(s))}),e},lt=i=>{if(ht(i))return Xs(i)},Ze=(i,e)=>typeof i=="boolean"?i:e,Qn=i=>(Object.getOwnPropertyNames(i).forEach(function(e){i[e]&&typeof i[e]=="object"&&Qn(i[e])}),Object.freeze(i)),Sf=i=>i.replace(/^\s+|\s+$/gm,""),rl=i=>i.replace(/^\.+/,""),Ys=i=>{let e=i;if(!te(i)&&!Qe(i))try{e=JSON.stringify(i)}catch{e=null}return e},wf=i=>{let e=Array.from(i,t=>String.fromCodePoint(t)).join("");return globalThis.btoa(e)},Af=i=>wf(new TextEncoder().encode(i)),Qs=(i,e,t,s,r)=>{let n={category:i,name:e,properties:t,options:s,callback:void 0};R(r)&&(n.callback=r),R(s)&&(n.category=i,n.name=e,n.properties=t,n.options=void 0,n.callback=s),R(t)&&(n.category=i,n.name=e,n.properties=void 0,n.options=void 0,n.callback=t),R(e)&&(n.category=i,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),R(i)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=i),ie(i)?(n.name=void 0,n.category=void 0,n.properties=i,R(e)?n.options=void 0:n.options=e):ie(e)&&(n.name=void 0,n.properties=e,R(t)?n.options=void 0:n.options=t),te(i)&&!te(e)&&(n.category=void 0,n.name=i),Y(n.category)||(n.category=void 0),Y(n.name)||(n.name=void 0),n.properties=n.properties?G(n.properties):{},Y(n.options)?n.options=G(n.options):n.options=void 0;let o=te(n.name)?n.name:n.properties.name,a=te(n.category)?n.category:n.properties.category;return n.properties=pe(ie(n.properties)?n.properties:{},{...o&&{name:o},...a&&{category:a}}),n},Jn=(i,e,t,s)=>{let r={name:i,properties:e,options:t,callback:void 0};return R(s)&&(r.callback=s),R(t)&&(r.properties=e,r.options=void 0,r.callback=t),R(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=ci(r.properties)?G(r.properties):{},Y(r.options)?r.options=G(r.options):r.options=void 0,r},Gl=(i,e,t,s)=>{let r={userId:i,traits:e,options:t,callback:void 0};return R(s)&&(r.callback=s),R(t)&&(r.userId=i,r.traits=e,r.options=void 0,r.callback=t),R(e)&&(r.userId=i,r.traits=void 0,r.options=void 0,r.callback=e),(ie(i)||Ne(i))&&(r.userId=null,r.traits=i,R(e)?r.options=void 0:r.options=e),r.userId=Ys(r.userId),ie(r.traits)?r.traits=G(r.traits):r.traits=void 0,Y(r.options)?r.options=G(r.options):r.options=void 0,r},jl=(i,e,t,s)=>{let r={to:i,from:e,options:t,callback:void 0};return R(s)&&(r.callback=s),R(t)&&(r.to=i,r.from=e,r.options=void 0,r.callback=t),R(e)?(r.to=i,r.from=void 0,r.options=void 0,r.callback=e):(ie(e)||Ne(e))&&(r.to=i,r.from=void 0,r.options=e),Y(r.to)&&(r.to=Ys(r.to)),Y(r.from)?r.from=Ys(r.from):r.from=void 0,Y(r.options)?r.options=G(r.options):r.options=void 0,r},Hl=(i,e,t,s)=>{let r={groupId:i,traits:e,options:t,callback:void 0};return R(s)&&(r.callback=s),R(t)&&(r.groupId=i,r.traits=e,r.options=void 0,r.callback=t),R(e)&&(r.groupId=i,r.traits=void 0,r.options=void 0,r.callback=e),(ie(i)||Ne(i))&&(r.groupId=null,r.traits=i,R(e)?r.options=void 0:r.options=e),r.groupId=Ys(r.groupId),ie(r.traits)?r.traits=G(r.traits):r.traits=void 0,Y(r.options)?r.options=G(r.options):r.options=void 0,r},dn=(function(i){return i.UNLOADED="Page Unloaded",i})({}),Zn="API",En="CapabilitiesManager",qe="ConfigManager",ql="EventManager",Vi="PluginsManager",Ut="UserSessionManager",Hi="ErrorHandler",ni="PluginEngine",Tf="StoreManager",hn=`Ready${Zn}`,If=`Load${Zn}`,Rf="HttpClient",Of="RudderStackAnalytics",Fs="AnalyticsCore";nl=4096,Bs=[],Tt=0;for(;Tt<256;Tt++)Bs[Tt]=(Tt+256).toString(16).substring(1);Gt=256,Vs=[];for(;Gt--;)Vs[Gt]=(Gt+256).toString(16).substring(1);Df=()=>!Qe(globalThis.crypto)&&R(globalThis.crypto.getRandomValues),ir=()=>Df()?Pf():Nf(),xf=()=>!!window.chrome?.runtime?.id,zl=()=>te(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),Lf=(i,e=!1)=>{let t=!1,s=!1;function r(){t||(t=!0,i(s),setTimeout(()=>{t=!1},0))}(e||zl())&&globalThis.addEventListener("beforeunload",()=>{s=!1,r()}),globalThis.addEventListener("blur",()=>{s=!0,r()}),globalThis.addEventListener("focus",()=>{t=!1}),document.addEventListener("pagehide",()=>{s=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{s=!0,document.visibilityState==="hidden"?r():t=!1})},Kl=i=>i.toISOString(),$f=()=>Kl(new Date),$=":: ",Ff=i=>`A script with the id "${i}" is already loaded. Skipping the loading of this script to prevent conflicts`,ol=(i,e,t)=>`Unable to load (${te(t)?t:t.type}) the script with the id "${i}" from URL "${e}"`,Mf=(i,e,t)=>`A timeout of ${t} ms occurred while trying to load the script with id "${i}" from URL "${e}"`,Uf=(i,e)=>`${i}${$}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,Bf="Failed to convert the value to a JSON string.",Vf="Failed to encode the cookie data.",Gf=(i,e)=>`${i}${$}The "${e}" storage type is `,jf="JSONStringify",Hf="[BigInt]",Wl="[Circular Reference]",qf=(i,e,t)=>{let s=[];return function(r,n){if(!e?.includes(r)&&!(i&&Qe(n))){if(typeof n!="object"||Ne(n))return n;for(;s.length>0&&s[s.length-1]!==this;)s.pop();return s.includes(n)?(t?.warn(Uf(jf,r)),Wl):(s.push(n),n)}}},Ye=(i,e,t,s)=>{try{return JSON.stringify(i,qf(e,t,s))}catch(r){return s?.warn(Bf,r),null}},zf=i=>{let e=[];return function(s,r){if(vf(r))return Hf;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?Wl:(e.push(r),r)}},Xl=(i,e)=>{let t=Array.isArray(i)?[]:{};for(let s in i)if(Object.hasOwnProperty.call(i,s)){let r=i[s],n=e.call(i,s,r);ie(n)||Array.isArray(n)?t[s]=Xl(n,e):t[s]=n}return t},j=(i,e)=>{let t=zf(),s=t.call(i,"",i);return ie(i)||Array.isArray(i)?Xl(i,t):s},Gs="[SDK DISPATCHED ERROR]",sr=i=>{let{stack:e,stacktrace:t,"opera#sourceloc":s}=i,r=e??t??s;if(r&&typeof r=="string")return r},eo=(i,e)=>{if(!Yn(i))return new Error(`${e}: ${Ye(i)}`);try{let t=i.constructor,s=new t(`${e}: ${i.message}`),r=sr(i);return r&&(s.stack=r),Object.getOwnPropertyNames(i).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{s[n]=i[n]}catch{}}),s}catch{return new Error(`${e}: ${Ye(i)}`)}},ce=i=>{if(Yn(i)){let e=sr(i);if(e){let{stack:t,stacktrace:s,"opera#sourceloc":r}=i;switch(e){case t:i.stack=`${t}
11
- ${Gs}`;break;case s:i.stacktrace=`${s}
12
- ${Gs}`;break;case r:default:i["opera#sourceloc"]=`${r}
13
- ${Gs}`;break}}}globalThis.dispatchEvent(new ErrorEvent("error",{error:i,bubbles:!0,cancelable:!0,composed:!0}))},al="RudderLabs JavaScript SDK",Wi="3.29.0",Kf="com.rudderlabs.javascript",Yl="npm",Wf="modern",ll="RudderJS-Initiated",Xf="ad-block page request",Yf="/ad-blocked",zi="preloadedEventsBuffer",Qf="Consent Management Interaction",Jf="ajs_trait_",Zf="ajs_prop_",cl="ajs_aid",eg="ajs_uid",ul="ajs_event",tg=10*1e3,ig=31536e3*1e3,dl=720*60*1e3,kn=1800*1e3,hl=10*1e3,sg=10*1e3,rg=250,Ql=(i="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[i]||(globalThis.RudderStackGlobals[i]={})},Xi=(i,e,t="app")=>{Ql(t),globalThis.RudderStackGlobals[t][i]=e},Jl=(i,e="app")=>(Ql(e),globalThis.RudderStackGlobals[e][i]);fl=(i,e)=>{let t={};return i.forEach((s,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);t[n]=i.get(r)}}),t},og=(i=[])=>{let e={trait:Jf,properties:Zf},t=new URLSearchParams(globalThis.location.search);t.get(ul)&&i.unshift(["track",t.get(ul),fl(t,e.properties)]);let s=t.get(eg),r=fl(t,e.trait);if(s||ht(r)){let n=[...s?[s]:[],r];i.unshift(["identify",...n])}t.get(cl)&&i.unshift(["setAnonymousId",t.get(cl)])},ag=i=>{let e="load",t=[],s=0;for(;s<i.length;){if(i[s]&&i[s][0]===e){t=G(i[s]),i.splice(s,1);break}s+=1}return t},lg=i=>{let e="consent",t=i.filter(r=>r[0]===e),s=i.filter(r=>r[0]!==e);i.splice(0,i.length,...t,...s)},cg=i=>{let e=Jl(zi)||[];og(e),e.length>0&&(i.enqueuePreloadBufferEvents(e),Xi(zi,[]))},ug=(i,e)=>{let t=i.shift(),s;if(R(e[t])){switch(t){case"page":s=Qs(...i);break;case"track":s=Jn(...i);break;case"identify":s=Gl(...i);break;case"alias":s=jl(...i);break;case"group":s=Hl(...i);break;default:e[t](...i);break}s&&e[t](s)}},dg=10*1e3,hg="RS_JS_SDK",fg=(i,e,t=!0,s=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=s,o.onerror=r,o.src=i,o.id=e,o.async=t,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",hg),o},gg=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 s=document.createElement("head");s.appendChild(i);let r=document.getElementsByTagName("html")[0];r?.insertBefore(s,r.firstChild)},pg=(i,e,t,s=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(Ff(e)));try{let l;gg(fg(i,e,s,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(ol(e,i,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(Mf(e,i,t)))},t)}catch(l){o(eo(l,ol(e,i,"unknown")))}}),Js=class{constructor(e,t=dg){this.logger=e,this.timeout=t}loadJSFile(e){let{url:t,id:s,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!R(o);pg(t,s,r||this.timeout,n,a).then(c=>{l||o(c)}).catch(c=>{l||o(s,c)})}},vg=Symbol.for("preact-signals");W=void 0;Ki=void 0,It=0,Sn=0,Zs=0;we.prototype.brand=vg;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:Zl(function(){var s;(s=e.W)==null||s.call(e)}))};we.prototype.U=function(i){var e=this;if(this.t!==void 0){var t=i.e,s=i.x;t!==void 0&&(t.x=s,i.e=void 0),s!==void 0&&(s.e=t,i.x=void 0),i===this.t&&(this.t=s,s===void 0&&Zl(function(){var r;(r=e.Z)==null||r.call(e)}))}};we.prototype.subscribe=function(i){var e=this;return tt(function(){var t=e.value,s=W;W=void 0;try{i(t)}finally{W=s}},{name:"sub"})};we.prototype.valueOf=function(){return this.value};we.prototype.toString=function(){return this.value+""};we.prototype.toJSON=function(){return this.value};we.prototype.peek=function(){var i=W;W=void 0;try{return this.value}finally{W=i}};Object.defineProperty(we.prototype,"value",{get:function(){var i=ec(this);return i!==void 0&&(i.i=this.i),this.v},set:function(i){if(i!==this.v){if(Sn>100)throw new Error("Cycle detected");this.v=i,this.i++,Zs++,It++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{rr()}}}});fi.prototype=new we;fi.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Zs))return!0;if(this.g=Zs,this.f|=1,this.i>0&&!tc(this))return this.f&=-2,!0;var i=W;try{ic(this),W=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 W=i,sc(this),this.f&=-2,!0};fi.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)};fi.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)}};fi.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(fi.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=ec(this);if(this.h(),i!==void 0&&(i.i=this.i),16&this.f)throw this.v;return this.v}});gi.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()}};gi.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,rc(this),ic(this),It++;var i=W;return W=this,_g.bind(this,i)};gi.prototype.N=function(){2&this.f||(this.f|=2,this.o=Ki,Ki=this)};gi.prototype.d=function(){this.f|=8,1&this.f||to(this)};gi.prototype.dispose=function(){this.d()};wn=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=[]}},Us={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},gl="LOG",nc="ERROR",mg="RS SDK",yg="font-weight: bold; background: black; color: white;",bg="font-weight: normal;",An=class{constructor(e=gl,t="",s=console){this.minLogLevel=Us[e],this.scope=t,this.logProvider=s}log(...e){this.outputLog("LOG",e)}info(...e){this.outputLog("INFO",e)}debug(...e){this.outputLog("DEBUG",e)}warn(...e){this.outputLog("WARN",e)}error(...e){this.outputLog("ERROR",e)}outputLog(e,t){this.minLogLevel<=Us[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=Us[e],me(this.minLogLevel)&&(this.minLogLevel=Us[gl])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t=`%c ${mg}`;this.scope&&(t=`${t} - ${this.scope}`);let s=te(e[0])?e[0].trim():"";t=`${t} %c ${s}`;let r=[t,yg,bg];return te(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},ft=new An,ct=(function(i){return i.HANDLEDEXCEPTION="handledException",i.UNHANDLEDEXCEPTION="unhandledException",i.UNHANDLEDREJECTION="unhandledPromiseRejection",i})({}),oc=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Tn="cookieStorage",pl="Unable to process/parse source configuration response",Eg="The source is disabled. Please enable the source in the dashboard to send events.",kg="Failed to prepare data for the request.",Sg="Failed to invoke plugin because the extension point name is missing.",wg="Failed to invoke plugin because the extension point name is invalid.",Ag=i=>`${i}${$}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,Tg=(i,e,t)=>`${i}${$}The base URL "${t}" for ${e} is not valid.`,Ig=(i,e,t)=>`${i}${$}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(t)}".`,Rg=(i,e)=>`${i}${$}Ignoring a non-error: ${e}.`,vl="Failed to log breadcrumb",Og=i=>`${i}${$}Failed to handle the error.`,Cg=i=>`${i}${$}Plugin name is missing.`,Pg=(i,e)=>`${i}${$}Plugin "${e}" already exists.`,Ng=(i,e)=>`${i}${$}Plugin "${e}" not found.`,Dg=(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.`,xg=(i,e,t)=>`${i}${$}Plugin "${e}" could not be loaded because some of its dependencies "${t}" do not exist.`,Lg=(i,e,t)=>`${i}${$}Failed to invoke the "${e}" extension point of plugin "${t}".`,_l="Failed to fetch the source config",$g=(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.`,Fg=(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.`,Mg=(i,e,t,s,r)=>`${i} with status ${e} (${t}) for URL: ${s}. Response: ${r.trim()}`,Ug=(i,e,t)=>`${i} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${t}`,Bg=(i,e)=>`${i} for URL: ${e}`,Vg=i=>`Failed to save the value for "${i}" to storage`,Gg=i=>`Failed to retrieve or parse data for "${i}" from storage`,jg=i=>`The server responded with status ${i} while setting the cookies. As a fallback, the cookies will be set client side.`,Hg=i=>`The server failed to set the ${i} cookie. As a fallback, the cookies will be set client side.`,ml="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",qg=(i,e,t)=>`${i}${$}The storage type "${e}" is not supported. Please choose one of the following supported types: "${oc}". The default type "${t}" will be used instead.`,zg=(i,e,t,s)=>`${i}${$}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(t)}". The default version "${s}" will be used instead.`,Kg=(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.`,Wg=(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.`,Xg=(i,e,t,s)=>`${i}${$}The "${e}" property defined under "${t}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${s}).`,Yg=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.`,Qg=i=>`${i}${$}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,Jg=(i,e,t)=>`${i}${$}The session timeout value "${e}" is not a number. The default timeout of ${t} ms will be used instead.`,Zg=(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.`,ep=(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.`,tp=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.`,ip=(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.`,sp=(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.`,rp=i=>`${i}${$}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,np=(i,e,t,s)=>`${i}${$}The storage type "${t}" is not available for entry "${e}". The SDK will initialize the entry with "${s}" storage type instead.`,op=i=>`${i}${$}The callback threw an exception`,ap=(i,e)=>`${i}${$}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,lp=(i,e)=>`Failed to load the polyfill script with ID "${i}" from URL ${e}.`,cp=(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.`,up=(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.`,dp=(i,e)=>`${i}${$}${e} plugin is deprecated. Please exclude it from the load API options.`,hp=(i,e,t,s)=>{let r=t.length===1,n=r?` '${t[0]}' plugin was`:` ['${t.join("', '")}'] plugins were`,o=`${i}${$}${e}, but${n} not configured to load.`;return s?`${o} So, ${r?"the plugin":"those plugins"} will be loaded automatically.`:`${o} Ignore if this was intentional. Otherwise, consider adding ${r?"it":"them"} to the 'plugins' load API option.`},fp=(i,e)=>`${i}${$}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,gp=i=>`${i}${$}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,pp=(i,e)=>`${i}${$}Ignoring unknown plugins: ${e.join(", ")}.`,vp=(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.`,_p=(i,e)=>`${i}${$}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,lc={All:!0},nr="js-integrations",cc="plugins",mp=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_]*)?$"),Yi="modern",or="https://cdn.rudderlabs.com",io="v3",uc=`${or}/${io}/${Yi}/${nr}`,dc=`${or}/${io}/${Yi}/${cc}`,hc="https://api.rudderstack.com",Bt="v3",yp="xhr",In={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},js={[Bt]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},bp={[yp]:"XhrQueue",beacon:"BeaconQueue"},Ep="rsaRequest",kp="rsaMetrics",Sp="Custom Device Mode",wp={configUrl:hc,loadIntegration:!0,sessions:{autoTrack:!0,timeout:kn,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:lc,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:sg,storage:{encryption:{version:Bt},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},Ap=y(G(wp)),X=Qn({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),gn=Qn({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Tp=10,Ip={userId:y(X.userId),userTraits:y(X.userTraits),anonymousId:y(X.anonymousId),groupId:y(X.groupId),groupTraits:y(X.groupTraits),initialReferrer:y(X.initialReferrer),initialReferringDomain:y(X.initialReferringDomain),sessionInfo:y(X.sessionInfo),authToken:y(X.authToken)},Rp={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([])},Op={isErrorReportingEnabled:y(!1),isMetricsReportingEnabled:y(!1),breadcrumbs:y([])},Cp=y(void 0),Pp={activeDataplaneUrl:y(void 0),integrationsCDNPath:y(uc),pluginsCDNPath:y(dc),sourceConfigUrl:y(void 0),status:y(void 0),initialized:y(!1),logLevel:y(nc),loaded:y(!1),readyCallbacks:y([]),writeKey:y(void 0),dataPlaneUrl:y(void 0),safeAnalyticsInstance:y(void 0)},Np={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)},Dp={retries:y(0),dropped:y(0),sent:y(0),queued:y(0),triggered:y(0),metricsServiceUrl:y(void 0)},xp=()=>Wf,Lp={app:y({name:al,namespace:Kf,version:Wi,installType:Yl}),traits:y(null),library:y({name:al,version:Wi,snippetVersion:globalThis.RudderSnippetVersion,variant:xp()}),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)},$p={configuredDestinations:y([]),activeDestinations:y([]),loadOnlyIntegrations:y({}),failedDestinations:y([]),loadIntegration:y(!0),initializedDestinations:y([]),clientDestinationsReady:y(!1),integrationsConfig:y({})},Fp={toBeProcessedArray:y([]),readyCallbacksArray:y([])},Mp={ready:y(!1),loadedPlugins:y([]),failedPlugins:y([]),pluginsToLoadFromConfig:y([]),activePlugins:y([]),totalPluginsToLoad:y(0)},Up={encryptionPluginName:y(void 0),migrate:y(!1),type:y(void 0),cookie:y(void 0),entries:y({}),trulyAnonymousTracking:y(!1)},Bp={isEnabledServerSideCookies:y(!1),dataServiceUrl:y(void 0)},Vp={eventsQueuePluginName:y(void 0),deliveryEnabled:y(!0)},Gp={enabled:y(!1),pageLifecycle:{enabled:y(!1),pageViewId:y(void 0),pageLoadedTimestamp:y(void 0)}},jp={capabilities:Rp,consents:Np,context:Lp,eventBuffer:Fp,lifecycle:Pp,loadOptions:Ap,metrics:Dp,nativeDestinations:$p,plugins:Mp,reporting:Op,session:Ip,source:Cp,storage:Up,serverCookies:Bp,dataPlaneEvents:Vp,autoTrack:Gp},d={...G(jp)};Hs={exports:{}},qs={exports:{}},Hp=qs.exports;zp=Hs.exports;Wp=Kp(),Xp=fc(Wp),gc="global code",Yp=i=>Y(i)&&/^global code$/i.test(i)?gc:i,Qp=i=>{let e={file:i.fileName,method:Yp(i.functionName),lineNumber:i.lineNumber,columnNumber:i.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=gc),e},El=i=>te(i)?i:"";pc=(i,e)=>{let t;return Yn(i)&&te(sr(i))?t=i:(e.warn(Rg(Hi,Ye(i))),t=void 0),t},Jp=(i,e)=>{try{let t=Xp.parse(i);return kl(i.name,i.message,e,t)}catch{return kl(i.name,i.message,e,[])}},Sl=(i,e)=>{try{return JSON.parse(i||"")}catch(t){let s=eo(t,"Failed to parse response data");e(s)}},zs="The request failed",Zp=[/Failed to fetch dynamically imported module: .*/],ev=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],tv=[new RegExp(`${zs}.*`),/A script with the id .* is already loaded\./],iv=[...Zp,...ev],sv="integrations",rv="sdk",nv=rv,ov={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},wl=(i,e,t)=>{let s=pe(ov,e||{});return t&&(s.headers=pe(s.headers,{Authorization:t})),s.url=i,s},Al=(i,e=tg,t)=>new Promise((s,r)=>{let n;if(i.sendRawData===!0)n=i.data;else if(n=Ye(i.data,!1,[],t),Ne(n)){r({error:new Error(kg),undefined:void 0,options:i});return}let o=new XMLHttpRequest,a=c=>{r({error:new Error(Mg(zs,o.status,o.statusText,i.url,o.responseText)),xhr:o,options:i})},l=c=>{r({error:new Error(Ug(zs,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?s({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(n)}catch(c){r({error:eo(c,Bg(zs,i.url)),xhr:o,options:i})}}),Rn=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:t,options:s,timeout:r,isRawResponse:n}=e;try{let o=await Al(wl(t,s,this.basicAuthHeader),r,this.logger);return{data:n?o.response:Sl(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:t,url:s,options:r,timeout:n,isRawResponse:o}=e,a=!R(t);Al(wl(s,r,this.basicAuthHeader),n,this.logger).then(l=>{a||t(o?l.response:Sl(l.response,this.onError),l)}).catch(l=>{a||t(void 0,l)})}onError(e,t){this.errorHandler?.onError({error:e,context:Rf,groupingHash:t})}setAuthHeader(e,t=!1){let s=t?e:Af(`${e}:`);this.basicAuthHeader=`Basic ${s}`}resetAuthHeader(){this.basicAuthHeader=void 0}},vc=new Rn(ft),av="1",lv=()=>["rsa"],cv=["www.test-host.com","localhost","127.0.0.1","[::1]"],uv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],dv="RudderStack JavaScript SDK",hv="git+https://github.com/rudderlabs/rudder-sdk-js.git",fv="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:(s,r)=>{d.capabilities.isAdBlockerDetectionInProgress.value=!1,d.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==t}})}catch(e){throw d.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},gv=(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}},pv=i=>({type:"manual",name:i,timestamp:new Date,metaData:{}}),vv=(i=()=>window.location.hostname)=>{let e=i();return!e||e&&cv.includes(e)?"development":"production"},_v=i=>{let e=Ye(i,!1,uv);return e!==null?JSON.parse(e):{}},mv=()=>globalThis.location.href.split("?")[0],yv=(i,e,t,s)=>({id:`${i.value?.id??t.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${s.pageLifecycle.pageViewId.value??"NA"}`,name:i.value?.name??"NA"}),bv=(i,e)=>({locale:i.value??"NA",userAgent:e.value??"NA",time:new Date}),Ev=(i,e,t,s)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:c}=t,{app:u,locale:h,userAgent:g,timezone:f,screen:v,library:p}=r;return{payloadVersion:"5",notifier:{name:dv,version:u.value.version,url:hv},events:[{exceptions:[G(i)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:u.value.version,releaseStage:vv(),type:u.value.installType},device:bv(h,g),request:{url:mv(),clientIp:"[NOT COLLECTED]"},breadcrumbs:G(l.breadcrumbs.value),context:i.message,groupingHash:s,metaData:{app:{snippetVersion:p.value.snippetVersion},device:{...v.value,timezone:f.value},..._v(t)},user:yv(a,o,n,c)}]}},kv=(i,e,t)=>{if(me(i.capabilities.isAdBlocked.value)){i.capabilities.isAdBlockerDetectionInProgress.value===!1&&_c(e);let s=tt(()=>{Y(i.capabilities.isAdBlocked.value)&&(t(i.capabilities.isAdBlocked.value===!1),s())})}else t(i.capabilities.isAdBlocked.value===!1)},Sv=(i,e,t)=>{let s=i.message;return new Promise(r=>{if(iv.some(n=>n.test(s))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(s)?.[0];te(n)?n.startsWith(or)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):kv(e,t,r):r(!1):r(!0)}else r(!tv.some(n=>n.test(s)))})},mc=i=>i?i.split("/").at(-2):void 0,yc=i=>{let e=i.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},wv=i=>{let e=yc(i);if(!e)return!1;let t=e.substring(e.lastIndexOf("/")+1);return mc(e)===nr||lv().some(r=>t.startsWith(r)&&t.endsWith(".js"))},Av=(i,e)=>{if(e)return e;let t=yc(i);return mc(t)===nr?sv:nv},Tv=(i,e,t)=>{let s={version:av,message_id:ir(),source:{name:fv,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 Ye(s)},Iv=(i,e,t)=>{let s;if(!Y(i))s=e;else if(te(i))s=i;else{let r=pc(i,t);Y(r)?s=r.message:s=e}return s},On=class{constructor(e,t){re(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=te(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&t.startsWith(or)&&!d.capabilities.cspBlockedURLs.value.includes(t)&&(d.capabilities.cspBlockedURLs.value=[...d.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{let{error:t,context:s,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??ct.HANDLEDEXCEPTION,l=gv(t,a),c=pc(l,this.logger);if(me(c))return;let u=r?`${r} - `:"",h=`${s}${$}${u}`,g=Jp(c,h),v=sr(c).includes(Gs);if(!v&&!wv(g)&&a!==ct.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await Sv(g,d,this.httpClient)){let m={severity:"error",unhandled:a!==ct.HANDLEDEXCEPTION,severityReason:{type:a}},E=Iv(n,g.message,this.logger),b=Ev(g,m,d,E),O=Av(g,o);this.httpClient.getAsyncData({url:d.metrics.metricsServiceUrl.value,options:{method:"POST",data:Tv(b,d,O),sendRawData:!0},isRawResponse:!0})}(a===ct.HANDLEDEXCEPTION||v)&&this.logger.error(g.message)}catch(t){this.logger.error(Og(Hi),t)}}leaveBreadcrumb(e){try{d.reporting.breadcrumbs.value=[...d.reporting.breadcrumbs.value,pv(e)]}catch(t){this.onError({error:t,context:Hi,customMessage:vl,groupingHash:vl})}}},bc=new On(vc,ft),Cn=class{constructor(e,t={}){re(this,"plugins",[]);re(this,"byName",{});re(this,"cache",{});re(this,"config",{throws:!0});this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){let r=Cg(ni);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=Pg(ni,e.name);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},this.plugins=this.plugins.slice();let s=this.plugins.length;this.plugins.forEach((r,n)=>{r.deps?.includes(e.name)&&(s=Math.min(s,n))}),this.plugins.splice(s,0,e),this.byName[e.name]=e,R(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let r=Ng(ni,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let s=this.plugins.indexOf(t);if(s===-1){let r=Dg(ni,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},delete this.byName[e],this.plugins=this.plugins.slice(),this.plugins.splice(s,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(s=>{if(s.deps?.some(r=>!this.byName[r])){let r=s.deps.filter(n=>!this.byName[n]);return this.logger.error(xg(ni,s.name,r)),!1}return t==="."?!0:yf(s,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...s){let r=e;if(!r)throw new Error(Sg);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(wg);let a=r.split(".");a.pop();let l=a.join(".");return(t?this.getPlugins(r):[this.getPlugins(r)[0]]).map(u=>{let h=bn(u,r);if(!R(h)||n)return h;try{return h.apply(bn(u,l),s)}catch(g){if(o)throw g;this.logger.error(Lg(ni,r,u.name),g)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}},Rv=new Cn(ft,{throws:!0}),Ov=i=>i.config.connectionMode!=="cloud"||i.config.useNativeSDKToSend===!0||i.config.useNativeSDK===!0,Cv=i=>i.config.connectionMode==="hybrid"||i.config.useNativeSDKToSend===!0,Tl=i=>i.filter(Ov),Pv=(i,e)=>`${i.replaceAll(" ","-")}___${e}`,Ec=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],Nv=["Bugsnag","ErrorReporting"],Dv={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"}};xv=i=>kc({},(globalThis.__federation_shared__||{}).default||{});$v=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}},Fv=i=>{let e={};return i.forEach(t=>{if(Ec.includes(t)){let s=$v(t);s&&(e[t]=s)}}),e},Sc=()=>({}),Mv=()=>({}),Uv=i=>Fv?.(i)||{},pn={...Sc(),...Mv()},Bv=i=>({...Uv(i)}),Pn=class{constructor(e,t,s){this.engine=e,this.errorHandler=t,this.logger=s,this.onError=this.onError.bind(this)}init(){d.lifecycle.status.value="pluginsLoading",Xi("pluginsCDNPath",d.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){tt(()=>{(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(r=>Nv.includes(r)?(this.logger.warn(dp(Vi,r)),!1):!0);let t=[{configurationStatus:()=>Y(d.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:d.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(bp),shouldAddMissingPlugins:!0},{configurationStatus:()=>Tl(d.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Tl(d.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>Y(d.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:d.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(In)},{configurationStatus:()=>Y(d.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:d.storage.encryptionPluginName.value,supportedPlugins:Object.values(js)},{configurationStatus:()=>d.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],s=!1;return t.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>Y(n)),this.addMissingPlugins(r,s,e)):e=e.filter(r.basePlugins!==void 0?n=>!(r.basePlugins.includes(n)||r.supportedPlugins.includes(n)):n=>!r.supportedPlugins.includes(n))}),[...Object.keys(Sc()),...e]}addMissingPlugins(e,t,s){let r=e.shouldAddMissingPlugins||t,n;e.activePluginName?n=[...e.basePlugins||[],e.activePluginName]:n=[...e.supportedPlugins];let o=n.filter(a=>!s.includes(a));o.length>0&&(r&&s.push(...o),this.logger.warn(hp(Vi,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(pn),...Ec],s=[],r=[];e.forEach(n=>{t.includes(n)?s.push(n):r.push(n)}),r.length>0&&this.logger.warn(pp(Vi,r)),ke(()=>{d.plugins.totalPluginsToLoad.value=e.length,d.plugins.activePlugins.value=s,d.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(pn).forEach(([t,s])=>{d.plugins.activePlugins.value.includes(t)&&(R(s)?this.register([s()]):e.push(t))}),e.length>0&&(d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,...e],this.logger.error(vp(Vi,e)))}registerRemotePlugins(){let e=Bv(d.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async t=>{await e[t]().then(s=>this.register([s.default()])).catch(s=>{d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,t],this.onError(s,`Failed to load plugin "${t}"`,s)})})).catch(t=>{this.onError(t)})}invokeMultiple(e,...t){try{return this.engine.invokeMultiple(e,...t)}catch(s){return this.onError(s,e),[]}}invokeSingle(e,...t){try{return this.engine.invokeSingle(e,...t)}catch(s){return this.onError(s,e),null}}register(e){e.forEach(t=>{try{this.engine.register(t,d)}catch(s){d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,t.name],this.onError(s,`Failed to register plugin "${t.name}"`)}})}unregisterLocalPlugins(){Object.keys(pn).forEach(e=>{try{this.engine.unregister(e)}catch(t){this.onError(t,`Failed to unregister plugin "${e}"`)}})}onError(e,t,s){this.errorHandler.onError({error:e,context:Vi,customMessage:t,groupingHash:s})}},Pe="cookieStorage",Ue="localStorage",He="sessionStorage",et="memoryStorage",jt="none",Vv="test_rudder_cookie",Gv="test_rudder_ls",jv="test_rudder_ss",Hv="rl_user_id",qv="rl_trait",zv="rl_anonymous_id",Kv="rl_group_id",Wv="rl_group_trait",Xv="rl_page_init_referrer",Yv="rl_page_init_referring_domain",Qv="rl_session",Jv="rl_auth_token",oi={userId:Hv,userTraits:qv,anonymousId:zv,groupId:Kv,groupTraits:Wv,initialReferrer:Xv,initialReferringDomain:Yv,sessionInfo:Qv,authToken:Jv},Zv="__tld__",wc="clientDataInCookie",Ac="clientDataInLocalStorage",e_="clientDataInMemory",Tc="clientDataInSessionStorage",Ic=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ai={[Pe]:wc,[Ue]:Ac,[et]:e_,[He]:Tc},Il=(i,e)=>{try{return encodeURIComponent(i)}catch(t){e?.error(Vf,t);return}},Rl=i=>{try{return decodeURIComponent(i)}catch{return}},t_=i=>{let e={},t=i.split(/\s*;\s*/),s;return t[0]&&t.forEach(r=>{s=r.split("=");let n=s[0]?Rl(s[0]):void 0;n&&(e[n]=s[1]?Rl(s[1]):void 0)}),e},i_=(i,e,t,s)=>{let r={...t||{}},n=`${Il(i,s)}=${Il(e,s)}`;Ne(e)&&(r.maxage=-1),r.maxage&&(r.expires=new Date(+new Date+r.maxage)),r.path&&(n+=`; path=${r.path}`),r.domain&&(n+=`; domain=${r.domain}`),r.expires&&(n+=`; expires=${r.expires.toUTCString()}`),r.samesite&&(n+=`; samesite=${r.samesite}`),r.secure&&(n+="; secure"),globalThis.document.cookie=n},Nn=()=>{let i=globalThis.document.cookie;return t_(i)},s_=i=>Nn()[i],ut=function(i,e,t,s){switch(arguments.length){case 4:case 3:case 2:return i_(i,e,t,s);case 1:return i?s_(i):Nn();default:return Nn()}},r_=i=>{let e=document.createElement("a");return e.href=i,e.hostname},n_=i=>{let t=(typeof globalThis.URL!="function"?r_(i):new URL(i).hostname)?.split(".")??[],s=t[t.length-1],r=[];if(t.length===4&&s&&s===parseInt(s,10).toString())return r;if(t.length<=1)return t[0]&&t[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=t.length-2;n>=0;n-=1)r.push(t.slice(n).join("."));return r},o_=i=>{let e=n_(i);for(let t=0;t<e.length;t+=1){let s=e[t],r=Zv,n={domain:`${s.indexOf("localhost")!==-1?"":"."}${s}`};try{if(ut(r,1,n),ut(r))return ut(r,null,n),s}catch{try{ut(r,null,n)}catch{}}}return""},a_=()=>{let i=`.${o_(globalThis.location.href)}`;return{maxage:ig,path:"/",domain:!i||i==="."?void 0:i,samesite:"Lax",enabled:!0}},l_=()=>({enabled:!0}),c_=()=>({enabled:!0}),u_=()=>({enabled:!0}),Dn=class{constructor(e){re(this,"isEnabled",!0);re(this,"length",0);re(this,"data",{});this.options=u_(),this.logger=e}configure(e){return this.options=pe(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)}},er=new Dn(ft),Ks={exports:{}},d_=Ks.exports;f_=h_(),Mt=fc(f_),Rc=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},li=(i=Ue,e,t)=>{let s,r,n=Gf(En,i),o="unavailable",a=!0,l;try{switch(i){case et:return!0;case Pe:s=e,r=Vv;break;case Ue:s=e??globalThis.localStorage,r=Gv;break;case He:s=e??globalThis.sessionStorage,r=jv;break;default:return!1}if(s&&(s.setItem(r,"true"),s.getItem(r)))return s.removeItem(r),!0;a=!1}catch(c){a=!1,l=c,Rc(c)&&(o="full")}return a||t?.warn(`${n}${o}.`,l),!1},xn=class{constructor(e){re(this,"isSupportAvailable",!0);re(this,"isEnabled",!0);re(this,"length",0);this.options=l_(),this.logger=e}configure(e){return this.options=pe(this.options,e??{}),this.isSupportAvailable=li(Ue),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){Mt.set(e,t),this.length=Mt.len()}getItem(e){let t=Mt.get(e);return me(t)?null:t}removeItem(e){Mt.remove(e),this.length=Mt.len()}clear(){Mt.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Mt.keys()}},so=new xn(ft),Ln=class{constructor(e){re(this,"isSupportAvailable",!0);re(this,"isEnabled",!0);re(this,"length",0);this.options=c_(),this.logger=e}configure(e){return this.options=pe(this.options,e??{}),this.isSupportAvailable=li(He),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 s=this.store.key(t);s!==null&&e.push(s)}return e}},ro=new Ln(ft),$n=class{constructor(e){re(this,"isSupportAvailable",!0);re(this,"isEnabled",!0);re(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=a_()),this.options=pe(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=li(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())}},no=new $n(ft),Xe=i=>{switch(i){case Ue:return so;case He:return ro;case et:return er;case Pe:return no;default:return er}},g_=i=>{let e=no.configure(i);d.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},p_=i=>{so.configure(i)},v_=i=>{er.configure(i)},__=i=>{ro.configure(i)},m_=(i={},e={},t={},s={})=>{g_(i),p_(e),v_(t),__(s)},Fn=class{constructor(e,t,s){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=s}createValidKey(e){let{name:t,id:s,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[t,s,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[t,s,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:s,noCompoundKey:r}=this,n=Xe(et);Object.keys(s).forEach(o=>{let a=this.get(s[o]),l=r?o:[e,t,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,t){let s=this.createValidKey(e);if(s)try{this.engine.setItem(s,this.encrypt(Ye(t,!1,[],this.logger)))}catch(r){if(Rc(r))this.logger.warn(rp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,t);else{let n=Vg(e);this.onError(r,n,n)}}}get(e){let t=this.createValidKey(e),s;try{return!t||(s=this.decrypt(this.engine.getItem(t)),Qe(s)||s==="")?null:JSON.parse(s)}catch(r){let n=d.storage.encryptionPluginName.value;if(!n||!d.plugins.failedPlugins.value.includes(n)){let a=Gg(e);this.onError(r,a,a)}return null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return Qe(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||typeof e!="string"||Sf(e)==="")return e;let r=`storage.${t}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,t,s){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:s})}},y_=(i,e)=>{let t;if(i.consents.preConsent.value.enabled)switch(i.consents.preConsent.value.storage?.strategy){case"none":t=jt;break;case"session":e!=="sessionInfo"&&(t=jt);break;case"anonymousId":e!=="anonymousId"&&(t=jt);break}return t},Mn=class{constructor(e,t,s){re(this,"stores",{});re(this,"isInitialized",!1);this.errorHandler=t,this.logger=s,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:{}};m_(ji(pe(t.cookieStorageOptions??{},d.storage.cookie?.value??{})),ji(t.localStorageOptions),ji(t.inMemoryStorageOptions),ji(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[et,Ue,Pe,He].forEach(t=>{Xe(t)?.isEnabled&&this.setStore({id:ai[t],name:ai[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,s=d.consents.postConsent.value.storage;(Y(s?.type)||Y(s?.entries))&&(e=s?.type,t=s?.entries);let r=!0,n={};Ic.forEach(o=>{let a=o,l=o,c=t?.[a]?.type,h=y_(d,o)??c??e??Tn,g=this.getResolvedStorageTypeForEntry(h,o);g!==jt&&(r=!1),n={...n,[o]:{type:g,key:oi[l]}}}),ke(()=>{d.storage.type.value=e,d.storage.entries.value=n,d.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,t){let s=e;switch(e){case Ue:Xe(Ue)?.isEnabled||(s=et);break;case He:Xe(He)?.isEnabled||(s=et);break;case et:case jt:break;case Pe:default:Xe(Pe)?.isEnabled?s=Pe:Xe(Ue)?.isEnabled?s=Ue:Xe(He)?.isEnabled?s=He:s=et;break}return s!==e&&this.logger.warn(np(Tf,t,e,s)),s}setStore(e){let t=Xe(e.type);return this.stores[e.id]=new Fn(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},b_=i=>ie(i)&&ie(i.source)&&!Qe(i.source.id)&&ie(i.source.config)&&Array.isArray(i.source.destinations),E_=i=>typeof i=="string"&&oc.includes(i),Oc=i=>{let e=new URL(i),{host:t,protocol:s}=e,r=t.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=t,{topDomain:n,protocol:s}},k_=i=>{let{topDomain:e,protocol:t}=Oc(i);return`${t}//${e}`},S_=(i,e)=>{let t=e?window.location.origin:k_(window.location.href),s=i.startsWith("/")?i.substring(1):i;return`${t}/${s}`},w_=i=>{let{topDomain:e}=Oc(window.location.href);return e===i},ui=i=>i?.endsWith("/")?ui(i.substring(0,i.length-1)):i,Un=i=>{try{return new URL(i).host}catch{return null}},Cc=i=>Un(i)??"",A_=i=>{let e={};try{let t=new URL(i),s="utm_";t.searchParams.forEach((r,n)=>{if(n.startsWith(s)){let o=n.substring(s.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},T_=i=>{let e=i;try{let t=new URL(i);e=t.origin+t.pathname+t.search}catch{}return e},I_=i=>i.replace(/\/{2,}/g,"/"),di=i=>{if(!te(i))return!1;try{return R(globalThis.URL)&&new URL(i),mp.test(i)}catch{return!1}},vn="none",_n="immediate",R_=i=>i?.statsCollection?.errors?.enabled===!0,O_=i=>i?.statsCollection?.metrics?.enabled===!0,C_=i=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(ie(i)){let t=G(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=pe(t.consentManagement,{enabled:d.consents.enabled.value}))}return e},Cl=i=>ht(i)||Array.isArray(i),P_=(i,e)=>{let{provider:t}=i,s=t?In[t]:void 0;return t&&!s&&(e.error(Ig(qe,t,In)),t=void 0),{provider:t,consentManagerPluginName:s}},Pc=(i,e)=>{let t,s=[],r=[],n=!1,o,a=i?.enabled===!0;ht(i)&&a&&({provider:o,consentManagerPluginName:t}=P_(i,e),Cl(i.allowedConsentIds)&&(s=i.allowedConsentIds,n=!0),Cl(i.deniedConsentIds)&&(r=i.deniedConsentIds,n=!0));let l={allowedConsentIds:s,deniedConsentIds:r};return a=a&&!!t,{provider:o,consentManagerPluginName:t,initialized:n,enabled:a,consentsData:l}},N_=()=>{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 s of e){let r=s.getAttribute("src");if(r&&t.test(r))return r}},D_=i=>{d.reporting.isErrorReportingEnabled.value=R_(i.source.config)&&!xf(),d.reporting.isMetricsReportingEnabled.value=O_(i.source.config)},x_=i=>{let{useServerSideCookies:e,dataServiceEndpoint:t,storage:s,setCookieDomain:r,sameDomainCookiesOnly:n}=d.loadOptions.value,o=s?.cookie,a=!1,l;if(e){a=e;let c=o.domain??r,u=Y(c)&&!w_(rl(c))||n,h=S_(t??Ep,u);if(di(h)){l=ui(h);let g=Un(window.location.href),f=Un(h);g!==f&&(o={...o,samesite:"None",secure:!0}),!n&&u&&f!==rl(c)&&(a=!1,i.warn(Wg(qe,c,f)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},L_=i=>{let{storage:e}=d.loadOptions.value,t=e?.type;Y(t)&&!E_(t)&&(i.warn(qg(qe,t,Tn)),t=Tn);let s=e?.encryption?.version,r=s&&js[s];!me(s)&&me(r)?(i.warn(zg(qe,s,js,Bt)),s=Bt):me(s)&&(s=Bt);let n=e?.migrate,o=n&&s===Bt;n===!0&&o!==n&&i.warn(Kg(qe,s,Bt));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:c}=x_(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=js[s],d.storage.migrate.value=o})},$_=i=>{let{provider:e,consentManagerPluginName:t,initialized:s,enabled:r,consentsData:n}=Pc(d.loadOptions.value.consentManagement,i),o=d.loadOptions.value.preConsent,a=o?.storage?.strategy??vn,l=["none","session","anonymousId"];Y(a)&&!l.includes(a)&&(a=vn,i.warn(cp(qe,o?.storage?.strategy,vn)));let c=o?.events?.delivery??_n,u=["immediate","buffer"];Y(c)&&!u.includes(c)&&(c=_n,i.warn(up(qe,o?.events?.delivery,_n))),ke(()=>{d.consents.activeConsentManagerPluginName.value=t,d.consents.initialized.value=s,d.consents.enabled.value=r,d.consents.data.value=n,d.consents.provider.value=e,d.consents.preConsent.value={enabled:d.loadOptions.value.preConsent?.enabled===!0&&s===!1&&r===!0,storage:{strategy:a},events:{delivery:c}}})},F_=i=>{let e=d.consents.resolutionStrategy.value,t;ie(i.consentManagementMetadata)&&(d.consents.provider.value&&(e=i.consentManagementMetadata.providers.find(s=>s.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=G(t),d.consents.resolutionStrategy.value=e})},M_=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(Qg(qe)))),ke(()=>{d.dataPlaneEvents.eventsQueuePluginName.value=t})}},U_=(i,e,t,s,r)=>{let n=new URLSearchParams({p:Yl,v:Wi,build:Yi,writeKey:e,lockIntegrationsVersion:t.toString(),lockPluginsVersion:s.toString()}),o=hc,a=n,l="/sourceConfig/",c="";if(di(i)){let u=new URL(i);ui(u.pathname).endsWith("/sourceConfig")||(u.pathname=`${ui(u.pathname)}/sourceConfig/`),u.pathname=I_(u.pathname),n.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 r.warn(ap(qe,i));return`${o}${l}?${a}${c}`},B_=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:Pv(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===Sp})),Nc=(i,e,t,s,r,n,o)=>{let a;if(n){if(!di(n))return o.error(Tg(qe,i,n)),null;a=ui(n)}else if(a=t,d.context.app.value.installType==="cdn"){let l=N_();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${io}/${Yi}/${e}$`),`/${s}/${Yi}/${e}`)),a},V_=(i,e,t,s)=>Nc("integrations",nr,uc,i,e,t,s),G_=(i,e,t,s)=>Nc("plugins",cc,dc,i,e,t,s),Bn=class{constructor(e,t,s){this.errorHandler=t,this.logger=s,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){tt(()=>{this.logger.setMinLogLevel(d.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:t,lockIntegrationsVersion:s,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=d.loadOptions.value,l=V_(Wi,s,n,this.logger);if(Ne(l))return;let c;c=G_(Wi,r,o,this.logger),c!==null&&(this.attachEffects(),d.lifecycle.activeDataplaneUrl.value=ui(d.lifecycle.dataPlaneUrl.value),L_(this.logger),$_(this.logger),M_(this.logger),ke(()=>{d.lifecycle.integrationsCDNPath.value=l,d.lifecycle.pluginsCDNPath.value=c,e&&(d.lifecycle.logLevel.value=e),d.lifecycle.sourceConfigUrl.value=U_(t,d.lifecycle.writeKey.value,s,r,this.logger),d.metrics.metricsServiceUrl.value=`${d.lifecycle.activeDataplaneUrl.value}/${kp}`,d.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,t,s){this.errorHandler.onError({error:e,context:qe,customMessage:t,groupingHash:s})}processConfig(e,t){if(!Y(e)){Y(t)?this.onError(t.error,_l):this.onError(new Error(_l));return}let s;try{te(e)?s=JSON.parse(e):s=e}catch(n){this.onError(n,pl);return}if(!b_(s)){this.onError(new Error(pl));return}if(s.source.enabled===!1){this.logger.error(Eg);return}D_(s);let r=s.source.destinations.length>0?B_(s.source.destinations):[];ke(()=>{d.source.value={config:s.source.config,name:s.source.name,id:s.source.id,workspaceId:s.source.workspaceId},d.nativeDestinations.configuredDestinations.value=r,d.plugins.pluginsToLoadFromConfig.value=d.loadOptions.value.plugins??[],F_(s),d.lifecycle.status.value="configured"})}getConfig(){let e=d.loadOptions.value.getSourceConfig;if(e){if(!R(e)){this.logger.error(Ag(qe));return}let t=e();t instanceof Promise?t.then(s=>this.processConfig(s)).catch(s=>{this.onError(s,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:d.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},j_=()=>{let i=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return i?.[1]?i[1]:"NA"},Dc=(i=()=>document)=>i()?.referrer||"$direct",H_=(i=()=>document)=>{let t=i().getElementsByTagName("link"),s="";for(let r=0;t[r];r+=1){let n=t[r];if(n.getAttribute("rel")==="canonical"&&!s){s=n.getAttribute("href")??"";break}}return s},q_=(i=()=>globalThis.navigator)=>{let e=i();if(me(e))return null;let{userAgent:t}=e,{brave:s}=e;if(s&&Object.getPrototypeOf(s).isBrave){let r=t.match(/(chrome)\/([\w.]+)/i);r&&(t=`${t} Brave/${r[2]}`)}return t},z_=(i=()=>globalThis.navigator)=>{let e=i();return me(e)?null:e.language??e.browserLanguage},xc=(i=()=>globalThis.location,e=()=>document)=>{let t=i(),s=H_(e),r=t.pathname,{href:n}=t,o=n,{search:a}=t;if(s)try{let h=new URL(s);h.search===""?o=s+a:o=s,r=h.pathname}catch{}let l=T_(o),{title:c}=e(),u=Dc(e);return{path:r,referrer:u,referring_domain:Cc(u),search:a,title:c,url:l,tab_url:n}},K_=(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()})},W_=()=>{let i=globalThis.document.createElement("div");return i.setAttribute("data-a-b","c"),i.dataset?i.dataset.aB==="c":!1},Vn={URL:()=>!R(globalThis.URL)||!R(globalThis.URLSearchParams),Promise:()=>!R(globalThis.Promise),"Number.isNaN":()=>!R(globalThis.Number.isNaN),"Number.isInteger":()=>!R(globalThis.Number.isInteger),"Array.from":()=>!R(globalThis.Array.from),"Array.prototype.find":()=>!R(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!R(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!R(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!R(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!R(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!R(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!R(globalThis.String.fromCodePoint),"Object.entries":()=>!R(globalThis.Object.entries),"Object.values":()=>!R(globalThis.Object.values),"Object.assign":()=>!R(globalThis.Object.assign),"Object.fromEntries":()=>!R(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!W_(),TextEncoder:()=>!R(globalThis.TextEncoder)||!R(globalThis.TextDecoder),requestAnimationFrame:()=>!R(globalThis.requestAnimationFrame)||!R(globalThis.cancelAnimationFrame),CustomEvent:()=>!R(globalThis.CustomEvent),"navigator.sendBeacon":()=>!R(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!R(globalThis.Uint8Array),Set:()=>!R(globalThis.Set),atob:()=>!R(globalThis.atob)},X_=()=>{let i=Object.keys(Vn),e=!1;for(let t=0;t<i.length;t++){let s=Vn[i[t]];if(R(s)&&s()){e=!0;break}}return e},Y_="https://polyfill-fastly.io/v3/polyfill.min.js",Q_=`${Y_}?version=3.111.0&features=${Object.keys(Vn).join("%2C")}`,J_=10*1e3,Pl="rudderstackPolyfill",Z_=()=>!Qe(globalThis.crypto)&&R(globalThis.crypto.getRandomValues),Nl=()=>!Qe(globalThis.navigator.userAgentData),em=()=>!Qe(globalThis.navigator.sendBeacon)&&R(globalThis.navigator.sendBeacon),Dl=()=>{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},Gn=class{constructor(e,t,s){this.httpClient=e,this.errorHandler=t,this.logger=s,this.externalSrcLoader=new Js(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=li(Pe,Xe(Pe),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=li(Ue,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=li(He,void 0,this.logger),d.capabilities.isBeaconAvailable.value=em(),d.capabilities.isUaCHAvailable.value=Nl(),d.capabilities.isCryptoAvailable.value=Z_(),d.capabilities.isIE11.value=zl(),d.capabilities.isOnline.value=globalThis.navigator.onLine,d.context.userAgent.value=q_(),d.context.locale.value=z_(),d.context.screen.value=Dl(),d.context.timezone.value=j_(),Nl()&&K_(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),tt(()=>{d.loadOptions.value.sendAdblockPage===!0&&d.lifecycle.sourceConfigUrl.value!==void 0&&_c(this.httpClient)})}prepareBrowserCapabilities(){d.capabilities.isLegacyDOM.value=X_();let e=d.loadOptions.value.polyfillURL,t=Q_;if(ci(e)&&(di(e)?t=e:this.logger.warn(fp(En,e))),d.loadOptions.value.polyfillIfRequired&&d.capabilities.isLegacyDOM.value&&di(t)){let r=t!==d.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${d.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,t=`${t}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:t,id:Pl,async:!0,timeout:J_,callback:n=>{n?r||this.onReady():this.onError(new Error(lp(Pl,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{d.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{d.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",ng(()=>{d.context.screen.value=Dl()},this))}onReady(){this.detectBrowserCapabilities(),d.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:En,groupingHash:t})}},tm="web",im=["integrations","anonymousId","originalTimestamp"],xl=["library","consentManagement","userAgent","ua-ch","screen"],mn=["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"],Lc=i=>typeof i=="number"&&!Number.isNaN(i),sm=(i,e)=>e.toString().length>=i,tr=i=>Lc(i)&&i>=0&&Number.isInteger(i),Ll=10,$c=i=>{let{cutOff:e}=i,t=Date.now();return!!(e?.enabled&&e.expiresAt&&t>e.expiresAt)},$l=i=>!i.expiresAt||Date.now()>i.expiresAt||$c(i),rm=()=>Date.now(),nm=(i,e)=>!i||!tr(i)||!sm(Ll,i)?(e.warn(sp(Ut,i,Ll)),!1):!0,om=i=>{if(i?.enabled)return i.expiresAt??(tr(i.duration)?Date.now()+i.duration:void 0)},am=i=>{let{timeout:e,cutOff:t}=i,s=Date.now();return{id:s,expiresAt:s+e,timeout:e,autoTrack:!0,...t&&{cutOff:t}}},lm=(i,e)=>({id:nm(i,e)?i:rm(),sessionStart:void 0,manualTrack:!0}),qi=i=>i===Pe||i===Ue||i===He||i===et,jn=()=>ir(),cm=i=>{if(mf(i)){let{entries:e,...t}=gn;return{...t,entries:{...e,anonymousId:i}}}return ie(i)&&ie(i.entries)?pe(gn,i):{...gn}},um=i=>{let e=xc(),t={};return Object.keys(e).forEach(s=>{t[s]=i?.[s]||e[s]}),t.initial_referrer=i?.initial_referrer||d.session.initialReferrer.value,t.initial_referring_domain=i?.initial_referring_domain||d.session.initialReferringDomain.value,t},dm=(i,e)=>{let t=e?.page||{},s=i,r=xc();return Object.keys(r).forEach(n=>{me(s[n])&&(s[n]=t[n]||r[n])}),me(s.initial_referrer)&&(s.initial_referrer=t.initial_referrer||d.session.initialReferrer.value),me(s.initial_referring_domain)&&(s.initial_referring_domain=t.initial_referring_domain||d.session.initialReferringDomain.value),s},yn=(i,e,t)=>{ie(i)&&Object.keys(i).forEach(s=>{(mn.includes(s)||mn.includes(s.toLowerCase()))&&t.warn(Xg(ql,s,e,mn))})},hm=(i,e)=>{let{properties:t,traits:s,context:r}=i,{traits:n}=r;yn(t,"properties",e),yn(s,"traits",e),yn(n,"context.traits",e)},fm=(i,e)=>{e.anonymousId&&te(e.anonymousId)&&(i.anonymousId=e.anonymousId),ht(e.integrations)&&(i.integrations=e.integrations),e.originalTimestamp&&te(e.originalTimestamp)&&(i.originalTimestamp=e.originalTimestamp)},gm=(i,e,t)=>{let s=i;return Object.keys(e).forEach(r=>{if(!im.includes(r)&&!xl.includes(r))if(r!=="context")s=pe(s,{[r]:e[r]});else if(!me(e[r])&&ie(e[r])){let n={};Object.keys(e[r]).forEach(o=>{xl.includes(o)||(n[o]=e[r][o])}),s=pe(s,{...n})}else t.warn(Yg(ql))}),s},pm=(i,e,t)=>{ie(e)&&(fm(i,e),i.context=gm(i.context,e,t))},vm=i=>{let e;return d.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=d.consents.postConsent.value.integrations??d.nativeDestinations.loadOnlyIntegrations.value:i?e=i:e=lc,G(e)},Gi=(i,e,t,s)=>{let r={channel:tm,context:{traits:G(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:G(d.consents.data.value.deniedConsentIds),allowedConsentIds:G(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:A_(globalThis.location.href),page:um(t),timezone:d.context.timezone.value,...d.autoTrack.enabled.value&&{autoTrack:{...d.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:d.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:$f(),messageId:ir(),userId:i.userId||d.session.userId.value};qi(d.storage.entries.value.anonymousId?.type)?r.anonymousId=d.session.anonymousId.value:r.anonymousId=jn(),d.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),i.type==="identify"&&(r.context.traits=d.storage.entries.value.userTraits?.type!==jt?G(d.session.userTraits.value):i.context.traits),i.type==="group"&&((i.groupId||d.session.groupId.value)&&(r.groupId=i.groupId||d.session.groupId.value),(i.traits||d.session.groupTraits.value)&&(r.traits=d.storage.entries.value.groupTraits?.type!==jt?G(d.session.groupTraits.value):i.traits));let n=pe(i,r);return n.event===void 0&&(n.event=null),n.properties===void 0&&(n.properties=null),pm(n,e,s),hm(n,s),n.integrations=vm(n.integrations),n},Hn=class{constructor(e){this.logger=e}generatePageEvent(e,t,s,r){let n=s??{};return n=dm(n,r),Gi({properties:n,name:t,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,t,s){return Gi({properties:t,event:e,type:"track"},s,void 0,this.logger)}generateIdentifyEvent(e,t,s){return Gi({userId:e,type:"identify",context:{traits:t}},s,void 0,this.logger)}generateAliasEvent(e,t,s){let n=Gi({previousId:t,type:"alias"},s,void 0,this.logger);return n.userId=e??n.userId,n}generateGroupEvent(e,t,s){let r={type:"group"};return e&&(r.groupId=e),t&&(r.traits=t),Gi(r,s,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}},qn=class{constructor(e,t,s,r){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=s,this.logger=r,this.eventFactory=new Hn(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)}},zn=class{constructor(e,t,s,r,n){this.storeManager=t,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=s,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:e,anonymousIdOptions:t}=d.loadOptions.value,s;ci(e)&&typeof e=="string"&&(s=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(s??this.getAnonymousId(t)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),s=this.getSessionInfo()??X.sessionInfo;e={autoTrack:t.autoTrack&&s.manualTrack!==!0,timeout:t.timeout,manualTrack:s.manualTrack,expiresAt:s.expiresAt,id:s.id,sessionStart:s.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=X.sessionInfo:t.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:s.cutOff?.expiresAt})}else e=X.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 s=e||Dc();this.setInitialReferrer(s),this.setInitialReferringDomain(Cc(s))}}isPersistenceEnabledForStorageEntry(e){return qi(d.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=d.storage.entries.value,t=[Pe,Ue,He];Object.keys(e).forEach(s=>{let r=s,n=e[r]?.type,o=this.storeManager?.getStore(ai[n]);o&&t.forEach(a=>{let l=this.storeManager?.getStore(ai[a]);if(l&&a!==n){let c=l.get(oi[r]);_f(c)&&o.set(oi[r],c),l.remove(oi[r])}})})}migrateStorageIfNeeded(e,t){if(!d.storage.migrate.value)return;let s=e??[];s.length===0&&[wc,Ac,Tc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&s.push(a)}),(t??Object.keys(oi)).forEach(n=>{let o=oi[n];s.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);Qe(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=d.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let t,s=d.loadOptions.value.sessions?.timeout;tr(s)?t=s:(this.logger.warn(Jg(Ut,s,kn)),t=kn),t===0&&(this.logger.warn(tp(Ut)),e=!1),t>0&&t<hl&&this.logger.warn(ip(Ut,t,hl));let r=this.getCutOffInfo(t);return{timeout:t,autoTrack:e,cutOff:r}}getCutOffInfo(e){let t=d.loadOptions.value.sessions.cutOff,s,r=!1;return t.enabled===!0&&(s=t.duration,r=!0,tr(s)?s<e&&(this.logger.warn(ep(Ut,s,e)),r=!1):(this.logger.warn(Zg(Ut,s,dl)),s=dl)),{enabled:r,duration:s}}onError(e,t,s){this.errorHandler.onError({error:e,context:Ut,customMessage:t,groupingHash:s})}getEncryptedCookieData(e,t){let s=[];return e.forEach(r=>{let n=t?.encrypt(Ye(r.value,!1,[],this.logger));ci(n)&&s.push({name:r.name,value:n})}),s}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:d.serverCookies.dataServiceUrl.value,options:{method:"POST",data:Ye({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,s){let r=Object.keys(e),n=()=>r.map(c=>({name:e[c].name,value:d.session[c].value})),o={};r.forEach(c=>{o[e[c].name]=s?.get(e[c].name)});let a=()=>{r.forEach(c=>{this.serverSideCookiesRequestInProgress[c]=!1})},l=()=>{n().forEach(c=>{t&&t(c.name,c.value)})};try{let c={};r.forEach(h=>{c[e[h].name]=d.session[h].value});let u=this.getEncryptedCookieData(n(),s);u.length>0?this.makeRequestToSetCookie(u,(h,g)=>{a(),g?.xhr?.status===200?n().forEach(f=>{let v=o[f.name],p=s?.get(f.name);Ye(c[f.name],!1,[])!==Ye(p,!1,[])&&(Ne(v)&&Ne(p)&&this.logger.error(Hg(f.name)),t&&t(f.name,f.value))}):(this.logger.error(jg(g?.xhr?.status)),l())}):(l(),a())}catch(c){this.onError(c,ml,ml),l(),a()}}syncValueToStorage(e){let t=d.storage.entries.value,s=t[e]?.type;if(qi(s)){let r=this.storeManager.getStore(ai[s]),n=t[e]?.key,o=d.session[e].value;o&&(te(o)||ht(o))?d.serverCookies.isEnabledServerSideCookies.value&&s===Pe?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{let a={[e]:{name:n}};this.setServerSideCookies(a,(l,c)=>{r?.set(l,c)},r)},Tp)):r?.set(n,o):r?.remove(n)}}registerEffects(){Ic.forEach(e=>{tt(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let s=e;(!te(e)||!s)&&(s=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!s&&t&&(s=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t)),s=s||jn()):s=X.anonymousId,d.session.anonymousId.value=s}getAnonymousId(e){let t=d.storage.entries.value.anonymousId?.type;if(qi(t)){let s=d.session.anonymousId.value;(!s||s===X.anonymousId)&&(s=this.getEntryValue("anonymousId")),!s&&e&&(s=this.pluginsManager?.invokeSingle("storage.getAnonymousId",Xe,e)),d.session.anonymousId.value=s||jn()}return d.session.anonymousId.value}getEntryValue(e){let t=d.storage.entries.value,s=t[e]?.type;if(qi(s)){let r=this.storeManager?.getStore(ai[s]);this.migrateStorageIfNeeded([r],[e]);let n=t[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let t=Xe(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()??X.sessionInfo;return e.autoTrack&&!$l(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??X.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:s,timeout:r,cutOff:n}=e.sessionInfo.value;if(s){let o={...X.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){let{session:t}=d,s=cm(e);ke(()=>{Object.keys(X).forEach(r=>{let n=r;if(s.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[n].value=X[n];break}})})}setUserId(e){d.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:X.userId}setUserTraits(e){d.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&ie(e)?pe(d.session.userTraits.value??X.userTraits,e):X.userTraits}setGroupId(e){d.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:X.groupId}setGroupTraits(e){d.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&ie(e)?pe(d.session.groupTraits.value??X.groupTraits,e):X.groupTraits}setInitialReferrer(e){d.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:X.initialReferrer}setInitialReferringDomain(e){d.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:X.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if($l(e))t=am(e);else{let s=Date.now(),r=e.timeout;t.expiresAt=s+r}if($c(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){let s=om(t.cutOff);t.cutOff.expiresAt=s}d.session.sessionInfo.value=t}start(e){d.session.sessionInfo.value=lm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){d.session.sessionInfo.value=X.sessionInfo}setAuthToken(e){d.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:X.authToken}},_m=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],mm=_m,ym=(i,e)=>{let t=G(e);return te(t.setCookieDomain)||(t.setCookieDomain=void 0),["Strict","Lax","None"].includes(t.sameSiteCookie)||(t.sameSiteCookie=void 0),t.secureCookie=Ze(t.secureCookie,i.secureCookie),t.sameDomainCookiesOnly=Ze(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=mm),t.useGlobalIntegrationsConfigInEvents=Ze(t.useGlobalIntegrationsConfigInEvents,i.useGlobalIntegrationsConfigInEvents),t.bufferDataPlaneEventsUntilReady=Ze(t.bufferDataPlaneEventsUntilReady,i.bufferDataPlaneEventsUntilReady),t.sendAdblockPage=Ze(t.sendAdblockPage,i.sendAdblockPage),t.useServerSideCookies=Ze(t.useServerSideCookies,i.useServerSideCookies),te(t.dataServiceEndpoint)||(t.dataServiceEndpoint=void 0),t.sendAdblockPageOptions=lt(t.sendAdblockPageOptions),t.loadIntegration=Ze(t.loadIntegration,i.loadIntegration),ht(t.storage)?(t.storage.migrate=Ze(t.storage.migrate,i.storage?.migrate),t.storage.cookie=lt(t.storage.cookie),t.storage.encryption=lt(t.storage.encryption),t.storage=Xs(t.storage)):t.storage=void 0,t.destinationsQueueOptions=lt(t.destinationsQueueOptions),t.queueOptions=lt(t.queueOptions),t.lockIntegrationsVersion=Ze(t.lockIntegrationsVersion,i.lockIntegrationsVersion),t.lockPluginsVersion=Ze(t.lockPluginsVersion,i.lockPluginsVersion),Lc(t.dataPlaneEventsBufferTimeout)||(t.dataPlaneEventsBufferTimeout=void 0),t.beaconQueueOptions=lt(t.beaconQueueOptions),t.preConsent=lt(t.preConsent),t.sourceConfigurationOverride=lt(t.sourceConfigurationOverride),pe(i,Xs(t))},Fl="dataplaneEventsQueue",Ml="destinationsEventsQueue",bm="transformEvent",Em=(i,e)=>Object.keys(i).filter(t=>i[t]!==!0||!e[t]).reduce((t,s)=>{let r=G(t);return r[s]=i[s],r},{}),km=(i,e)=>{let t=G(i),s=e.nativeDestinations.integrationsConfig.value,r=Em(i.integrations,s);return t.integrations=pe(s,r),t},Sm=i=>i.consents.preConsent.value.enabled&&i.consents.preConsent.value.events?.delivery==="buffer",Ws=(i,e,t,s)=>{if(Y(i))if(R(i))try{i(...e)}catch(r){s.error(op(t),r)}else s.error(ac(t))},Kn=class{constructor(e,t,s,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=s,this.logger=n,this.storeManager=t}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${Fl}.init`,d,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${bm}.init`,d,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${Ml}.init`,d,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),tt(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=Sm(d),t;tt(()=>{let s=d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&d.nativeDestinations.clientDestinationsReady.value===!1;(d.nativeDestinations.activeDestinations.value.some(n=>Cv(n))===!1||s===!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 s=km(e,d);this.pluginsManager.invokeSingle(`${Fl}.enqueue`,d,this.dataplaneEventsQueue,s,this.errorHandler,this.logger);let r=G(e);this.pluginsManager.invokeSingle(`${Ml}.enqueue`,d,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${Zn}`;Ws(t,[s],n,this.logger)}},Ul=i=>{let e=new CustomEvent(i,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},wm=i=>te(i)&&i.trim().length>0,Am=i=>di(i),Wn=class{constructor(){this.preloadBuffer=new wn,this.initialized=!1,this.errorHandler=bc,this.logger=ft,this.externalSrcLoader=new Js(this.logger),this.httpClient=vc,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new Gn(this.httpClient,this.errorHandler,this.logger)}load(e,t,s={}){if(!d.lifecycle.status.value){if(!wm(e)){this.logger.error($g(Fs,e));return}if(!Am(t)){this.logger.error(Fg(Fs,t));return}ke(()=>{d.lifecycle.writeKey.value=G(e),d.lifecycle.dataPlaneUrl.value=G(t),d.loadOptions.value=ym(d.loadOptions.value,s),d.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(d.loadOptions.value.logLevel??nc),Xi("state",d,e),this.startLifecycle()}}startLifecycle(){tt(()=>{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:Fs,customMessage:t,groupingHash:t})}})}onBrowserCapabilitiesReady(){cg(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(G(t)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&ug([...e],this)}}prepareInternalServices(){this.pluginsManager=new Pn(Rv,this.errorHandler,this.logger),this.storeManager=new Mn(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Bn(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new zn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Kn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new qn(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;Ws(e,[globalThis.rudderanalytics],If,this.logger),Ul("RSA_Initialised")}onReady(){d.lifecycle.status.value="readyExecuted",d.eventBuffer.readyCallbacksArray.value.forEach(e=>{Ws(e,[],hn,this.logger)}),Ul("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 s=t[0];R(this[s])&&this[s](...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),tt(()=>{(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 s="ready";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),!R(e)){this.logger.error(ac(hn));return}d.lifecycle.status.value==="readyExecuted"?Ws(e,[],hn,this.logger):d.eventBuffer.readyCallbacksArray.value=[...d.eventBuffer.readyCallbacksArray.value,e]}page(e,t=!1){let s="page";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),d.capabilities.isAdBlocked.value===!0&&e.category!==ll&&this.page(Qs(ll,Xf,{path:Yf},d.loadOptions.value.sendAdblockPageOptions))}track(e,t=!1){let s="track";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event - ${e.name}`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:s,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,t=!1){let s="identify";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,e.userId&&d.session.userId.value&&e.userId!==d.session.userId.value&&this.reset(),Ne(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:s,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,t=!1){let s="alias";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:s,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,t=!1){let s="group";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,Ne(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:s,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,t=!1){let s="reset";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,t,s=!1){let r="setAnonymousId";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,t]];return}this.errorHandler.leaveBreadcrumb(`New ${r} 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 s="startSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let 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 s="consent";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),ke(()=>{d.consents.preConsent.value={...d.consents.preConsent.value,enabled:!1},d.consents.postConsent.value=C_(e);let{initialized:r,consentsData:n}=Pc(d.consents.postConsent.value.consentManagement,this.logger);d.consents.initialized.value=r,d.consents.data.value=n}),d.consents.enabled.value&&!d.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(t)}sendTrackingEvents(e){if(d.consents.postConsent.value.trackConsent){let t=Jn(Qf);e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(d.consents.postConsent.value.sendPageEvent){let t=Qs();e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,s=!1){let r="addCustomIntegration";if(s)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,d,this.logger);else{if(d.lifecycle.loaded.value){this.logger.error(_p(Fs,e));return}d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,t]]}}},Vt=class Vt{constructor(){re(this,"analyticsInstances",{});re(this,"defaultAnalyticsKey","");re(this,"logger",ft);try{if(Vt.globalSingleton)return Vt.globalSingleton;Vt.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.getSessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),Vt.globalSingleton=this,d.autoTrack.pageLifecycle.pageViewId.value=ir(),d.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){ce(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(){bc.init(),no.configure(),so.configure(),ro.configure(),er.configure()}setDefaultInstanceKey(e){te(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;return(!te(t)||!t)&&(t=this.defaultAnalyticsKey),this.analyticsInstances[t]||(this.analyticsInstances[t]=new Wn),this.analyticsInstances[t]}catch(t){ce(t);return}}load(e,t,s){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(s);let r=Jl(zi);lg(r),Xi(zi,G(r)),this.getAnalyticsInstance(e)?.load(e,t,j(s))}catch(r){ce(r)}}trackPageLifecycleEvents(e){let{autoTrack:t,useBeacon:s}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=t??{},{events:a=[dn.UNLOADED],enabled:l=r,options:c=n}=o??{};d.autoTrack.pageLifecycle.enabled.value=l,d.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,s,c)}setupPageUnloadTracking(e,t,s){(e.length===0||e.includes(dn.UNLOADED))&&(t===!0?Lf(r=>{if(r===!1&&d.lifecycle.loaded.value){let n=Date.now(),o=n-d.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(dn.UNLOADED,{timeOnPage:o},{...s,originalTimestamp:Kl(new Date(n))})}},!0):this.logger.warn(gp(Of)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=ag(e);Xi(zi,G([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(j(e))}catch(t){ce(t)}}page(e,t,s,r,n){try{this.getAnalyticsInstance()?.page(Qs(j(e),j(t),j(s),j(r),j(n)))}catch(o){ce(o)}}track(e,t,s,r){try{this.getAnalyticsInstance()?.track(Jn(j(e),j(t),j(s),j(r)))}catch(n){ce(n)}}identify(e,t,s,r){try{this.getAnalyticsInstance()?.identify(Gl(j(e),j(t),j(s),j(r)))}catch(n){ce(n)}}alias(e,t,s,r){try{this.getAnalyticsInstance()?.alias(jl(j(e),j(t),j(s),j(r)))}catch(n){ce(n)}}group(e,t,s,r){try{this.getAnalyticsInstance()?.group(Hl(j(e),j(t),j(s),j(r)))}catch(n){ce(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(j(e))}catch(t){ce(t)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(j(e))}catch(t){ce(t);return}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(j(e),j(t))}catch(s){ce(s)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){ce(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){ce(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){ce(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){ce(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(j(e))}catch(t){ce(t)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){ce(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){ce(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(j(e))}catch(t){ce(t)}}consent(e){try{this.getAnalyticsInstance()?.consent(j(e))}catch(t){ce(t)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(j(e),j(t))}catch(s){ce(s)}}};re(Vt,"globalSingleton",null);hi=Vt});var Mc,Uc,ao,Fc,Bc,Vc,Gc,jc,Qi=Re(()=>{"use strict";Mc="https://deriv.com/cdn-cgi/trace",Uc="https://cdn.growthbook.io",ao="https://deriv-dataplane.rudderstack.com",Fc="https://ph.deriv.com",Bc="https://us.posthog.com",Vc=()=>{if(typeof window>"u")return Fc;let i=window.location.hostname;return i.includes(".deriv.me")?"https://ph.deriv.me":i.includes(".deriv.be")?"https://ph.deriv.be":i.includes(".deriv.ae")?"https://ph.deriv.ae":Fc},Gc=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],jc=["deriv.com","derivcrypto.com","besquare.my","besquare.com.my","ewallet.exchange","champion-fx.com","opalstraits.com","binary.com","binary.marketing","championgbs.com","4x.my","re-work.dev","regentmarkets.com","4x.com","binary.me","deriv.team","firstsource.io","firstsource.tech","deriv.hr","vmgbpo.net","mailisk.net","mailosaur.net","mobileapps.mailisk.net","w3e180zd.mailosaur.net"]});function ar(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)i[s]=t[s]}return i}function lo(i,e){function t(r,n,o){if(!(typeof document>"u")){o=ar({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)o[l]&&(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=r+"="+i.write(n,r)+a}}function s(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var n=document.cookie?document.cookie.split("; "):[],o={},a=0;a<n.length;a++){var l=n[a].split("="),c=l.slice(1).join("=");try{var u=decodeURIComponent(l[0]);if(o[u]=i.read(c,u),r===u)break}catch{}}return r?o[r]:o}}return Object.create({set:t,get:s,remove:function(r,n){t(r,"",ar({},n,{expires:-1}))},withAttributes:function(r){return lo(this.converter,ar({},this.attributes,r))},withConverter:function(r){return lo(ar({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(i)}})}var Tm,Hc,qc=Re(()=>{"use strict";Tm={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)}};Hc=lo(Tm,{path:"/"})});var it,cr,Ji,lr,zc,Ht,Kc,Wc,pi=Re(()=>{"use strict";qc();Qi();it=(i,e)=>(...t)=>{e()&&console.log(`[ANALYTIC]${i}`,...t)},cr=i=>{let e=i.split("@")[1]?.toLowerCase();return e?jc.includes(e):!1},Ji=i=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i),lr=null,zc=async()=>{if(lr)return lr;let i=JSON.parse(Hc.get("website_status")||"{}")?.clients_country;return lr=(async()=>{try{let e=await fetch(Mc).catch(()=>null);if(!e)return i||"";let t=await e.text().catch(()=>"");return t?Object.fromEntries(t.split(`
14
- `).map(r=>r.split("=",2))).loc?.toLowerCase()||i||"":i||""}catch{return i||""}})(),lr},Ht=i=>{if(i==null||typeof i!="object")return i;if(Array.isArray(i)){let s=[];for(let r=0;r<i.length;r++){let n=Ht(i[r]);n!=null&&s.push(n)}return s.length?s:void 0}let e={},t=!1;for(let s in i){if(!Object.prototype.hasOwnProperty.call(i,s))continue;let r=Ht(i[s]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[s]=r,t=!0)}return t?e:void 0},Kc=(i,e)=>{for(let t in i){if(!Object.prototype.hasOwnProperty.call(i,t))continue;let s=i[t];s&&typeof s=="object"&&!Array.isArray(s)?Kc(s,e):e[t]=s}},Wc=i=>{if(i==null||typeof i!="object"||Array.isArray(i))return i;let e={};return Kc(i,e),e}});function su(){return iu}function uo(i){let e=2166136261,t=i.length;for(let s=0;s<t;s++)e^=i.charCodeAt(s),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Zi(i,e,t){return t===2?uo(uo(i+e)+"")%1e4/1e4:t===1?uo(e+i)%1e3/1e3:null}function Rm(i){return i<=0?[]:new Array(i).fill(1/i)}function fr(i,e){return i>=e[0]&&i<e[1]}function ru(i,e){let t=Zi("__"+e[0],i,1);return t===null?!1:t>=e[1]&&t<e[2]}function nu(i,e){for(let t=0;t<e.length;t++)if(fr(i,e[t]))return t;return-1}function fo(i){try{let e=i.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function gr(i,e){if(!e.length)return!1;let t=!1,s=!1;for(let r=0;r<e.length;r++){let n=Pm(i,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else t=!0,n&&(s=!0)}return s||!t}function Om(i,e,t){try{let s=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(s="\\/?"+s.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+s+"$","i").test(i)}catch{return!1}}function Cm(i,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),s=[[i.host,t.host,!1],[i.pathname,t.pathname,!0]];return t.hash&&s.push([i.hash,t.hash,!1]),t.searchParams.forEach((r,n)=>{s.push([i.searchParams.get(n)||"",r,!1])}),!s.some(r=>!Om(r[0],r[1],r[2]))}catch{return!1}}function Pm(i,e,t){try{let s=new URL(i,"https://_");if(e==="regex"){let r=fo(t);return r?r.test(s.href)||r.test(s.href.substring(s.origin.length)):!1}else if(e==="simple")return Cm(s,t);return!1}catch{return!1}}function ou(i,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let s=Rm(i);t=t||s,t.length!==i&&(t=s);let r=t.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(t=s);let n=0;return t.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function au(i,e,t){if(!e)return null;let s=e.split("?")[1];if(!s)return null;let r=s.replace(/#.*/,"").split("&").map(n=>n.split("=",2)).filter(([n])=>n===i).map(([,n])=>parseInt(n));return r.length>0&&r[0]>=0&&r[0]<t?r[0]:null}function lu(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||iu.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let s=await t.importKey("raw",ho(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=i.split("."),o=await t.decrypt({name:"AES-CBC",iv:ho(r)},s,ho(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function es(i){return typeof i=="string"?i:JSON.stringify(i)}function Be(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 cu(){let i;try{i="1.6.5"}catch{i=""}return i}function uu(i,e){let t,s;try{t=new URL(i),s=new URL(e)}catch(r){return console.error(`Unable to merge query strings: ${r}`),e}return t.searchParams.forEach((r,n)=>{s.searchParams.has(n)||s.searchParams.set(n,r)}),s.toString()}function tu(i){return typeof i=="object"&&i!==null}function pr(i){return i.urlPatterns&&i.variations.some(e=>tu(e)&&"urlRedirect"in e)?"redirect":i.variations.some(e=>tu(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function vr(i,e){return new Promise(t=>{let s=!1,r,n=o=>{s||(s=!0,r&&clearTimeout(r),t(o||null))};e&&(r=setTimeout(()=>n(),e)),i.then(o=>n(o)).catch(()=>n())})}var iu,ho,ts=Re(()=>{"use strict";iu={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};ho=i=>Uint8Array.from(atob(i),e=>e.charCodeAt(0))});function fu(i){Object.assign(Se,i),Se.backgroundSync||yo()}async function gu({instance:i,timeout:e,skipCache:t,allowStale:s,backgroundSync:r}){return r||(Se.backgroundSync=!1),Lm({instance:i,allowStale:s,timeout:e,skipCache:t})}function Nm(i){let e=is(i),t=mi.get(e)||new Set;t.add(i),mi.set(e,t)}function pu(i){mi.forEach(e=>e.delete(i))}function Dm(){yi.forEach(i=>{i&&(i.state="idle",_o(i))})}function xm(){yi.forEach(i=>{i&&i.state==="idle"&&mo(i)})}async function hu(){try{if(!st.localStorage)return;await st.localStorage.setItem(Se.cacheKey,JSON.stringify(Array.from(gt.entries())))}catch{}}async function Lm({instance:i,allowStale:e,timeout:t,skipCache:s}){let r=is(i),n=po(i),o=new Date,a=new Date(o.getTime()-Se.maxAge+Se.staleTTL);await $m();let l=!Se.disableCache&&!s?gt.get(n):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&bi.add(r),l.staleAt<o?go(i):vo(i),{data:l.data,success:!0,source:"cache"}):await vr(go(i),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function is(i){let[e,t]=i.getApiInfo();return`${e}||${t}`}function po(i){let e=is(i);if(!("isRemoteEval"in i)||!i.isRemoteEval())return e;let t=i.getAttributes(),s=i.getCacheKeyAttributes()||Object.keys(i.getAttributes()),r={};s.forEach(a=>{r[a]=t[a]});let n=i.getForcedVariations(),o=i.getUrl();return`${e}||${JSON.stringify({ca:r,fv:n,url:o})}`}async function $m(){if(!du){du=!0;try{if(st.localStorage){let i=await st.localStorage.getItem(Se.cacheKey);if(!Se.disableCache&&i){let e=JSON.parse(i);e&&Array.isArray(e)&&e.forEach(([t,s])=>{gt.set(t,{...s,staleAt:new Date(s.staleAt)})}),vu()}}}catch{}if(!Se.disableIdleStreams){let i=_i.startIdleListener();i&&(_i.stopIdleListener=i)}}}function vu(){let i=Array.from(gt.entries()).map(([t,s])=>({key:t,staleAt:s.staleAt.getTime()})).sort((t,s)=>t.staleAt-s.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 _u(i,e,t){let s=t.dateUpdated||"",r=new Date(Date.now()+Se.staleTTL),n=Se.disableCache?void 0:gt.get(e);if(n&&s&&n.version===s){n.staleAt=r,hu();return}Se.disableCache||(gt.set(e,{data:t,version:s,staleAt:r,sse:bi.has(i)}),vu()),hu();let o=mi.get(i);o&&o.forEach(a=>Fm(a,t))}async function Fm(i,e){await i.setPayload(e||i.getPayload())}async function go(i){let{apiHost:e,apiRequestHeaders:t}=i.getApiHosts(),s=i.getClientKey(),r="isRemoteEval"in i&&i.isRemoteEval(),n=is(i),o=po(i),a=_r.get(o);return a||(a=(r?_i.fetchRemoteEvalCall({host:e,clientKey:s,payload:{attributes:i.getAttributes(),forcedVariations:i.getForcedVariations(),forcedFeatures:Array.from(i.getForcedFeatures().entries()),url:i.getUrl()},headers:t}):_i.fetchFeaturesCall({host:e,clientKey:s,headers:t})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&bi.add(n),c.json()}).then(c=>(_u(n,o,c),vo(i),_r.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(_r.delete(o),{data:null,source:"error",success:!1,error:c})),_r.set(o,a)),a}function vo(i,e=!1){let t=is(i),s=po(i),{streamingHost:r,streamingHostRequestHeaders:n}=i.getApiHosts(),o=i.getClientKey();if(e&&bi.add(t),Se.backgroundSync&&bi.has(t)&&st.EventSource){if(yi.has(t))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let c=mi.get(t);c&&c.forEach(u=>{go(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);_u(t,s,c)}a.errors=0}catch{mu(a)}},errors:0,state:"active"};yi.set(t,a),mo(a)}}function mu(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);_o(i),setTimeout(()=>{["idle","active"].includes(i.state)||mo(i)},Math.min(e,3e5))}}function _o(i){i.src&&(i.src.onopen=null,i.src.onerror=null,i.src.close(),i.src=null,i.state==="active"&&(i.state="disabled"))}function mo(i){i.src=_i.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=()=>mu(i),i.src.onopen=()=>{i.errors=0}}function Mm(i,e){_o(i),yi.delete(e)}function yo(){bi.clear(),yi.forEach(Mm),mi.clear(),_i.stopIdleListener()}function mr(i,e){if(e.streaming){if(!i.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&vo(i,!0),Nm(i)}}var Se,st,_i,mi,du,gt,_r,yi,bi,yu=Re(()=>{"use strict";ts();Se={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},st=su(),_i={fetchFeaturesCall:({host:i,clientKey:e,headers:t})=>st.fetch(`${i}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:i,clientKey:e,payload:t,headers:s})=>{let r={method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)};return st.fetch(`${i}/api/eval/${e}`,r)},eventSourceCall:({host:i,clientKey:e,headers:t})=>t?new st.EventSource(`${i}/sub/${e}`,{headers:t}):new st.EventSource(`${i}/sub/${e}`),startIdleListener:()=>{let i;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(i),xm()):document.visibilityState==="hidden"&&(i=window.setTimeout(Dm,Se.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(st.localStorage=globalThis.localStorage)}catch{}mi=new Map,du=!1,gt=new Map,_r=new Map,yi=new Map,bi=new Set});function Bm(i){return i==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[i]}}function Sr(i){var e=kr.get(i);return e||(e={element:i,attributes:{}},kr.set(i,e)),e}function wr(i,e,t,s,r){var n=t(i),o={isDirty:!1,originalValue:n,virtualValue:n,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,r(o))}}),mutationRunner:r,setValue:s,getCurrentValue:t};return e==="position"&&i.parentNode?o.observer.observe(i.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(i,Bm(e)),o}function Ar(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,bu()):i!==t&&(e.isDirty=!0,bu())}function Vm(i){var e=i.originalValue;i.mutations.forEach(function(t){return e=t.mutate(e)}),Ar(ty(e),i)}function Gm(i){var e=new Set(i.originalValue.split(/\s+/).filter(Boolean));i.mutations.forEach(function(t){return t.mutate(e)}),Ar(Array.from(e).filter(Boolean).join(" "),i)}function jm(i){var e=i.originalValue;i.mutations.forEach(function(t){return e=t.mutate(e)}),Ar(e,i)}function Hm(i){var e=i.parentSelector,t=i.insertBeforeSelector,s=document.querySelector(e);if(!s)return null;var r=t?document.querySelector(t):null;return t&&!r?null:{parentNode:s,insertBeforeNode:r}}function qm(i){var e=i.originalValue;i.mutations.forEach(function(t){var s=t.mutate(),r=Hm(s);e=r||e}),Ar(e,i)}function ku(i){var e=Sr(i);return e.html||(e.html=wr(i,"html",zm,Km,Vm)),e.html}function Su(i){var e=Sr(i);return e.position||(e.position=wr(i,"position",Wm,Xm,qm)),e.position}function wu(i){var e=Sr(i);return e.classes||(e.classes=wr(i,"class",Qm,Ym,Gm)),e.classes}function Au(i,e){var t=Sr(i);return t.attributes[e]||(t.attributes[e]=wr(i,e,Jm(e),Zm(e),jm)),t.attributes[e]}function ey(i,e){var t=kr.get(i);if(t)if(e==="html"){var s,r;(s=t.html)==null||(r=s.observer)==null||r.disconnect(),delete t.html}else if(e==="class"){var n,o;(n=t.classes)==null||(o=n.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var c,u,h;(c=t.attributes)==null||(u=c[e])==null||(h=u.observer)==null||h.disconnect(),delete t.attributes[e]}}function ty(i){return yr||(yr=document.createElement("div")),yr.innerHTML=i,yr.innerHTML}function br(i,e,t){if(t.isDirty){t.isDirty=!1;var s=t.virtualValue;t.mutations.length||ey(i,e),t.setValue(i,s)}}function iy(i,e){i.html&&br(e,"html",i.html),i.classes&&br(e,"class",i.classes),i.position&&br(e,"position",i.position),Object.keys(i.attributes).forEach(function(t){br(e,t,i.attributes[t])})}function bu(){kr.forEach(iy)}function sy(i,e){var t=null;i.kind==="html"?t=ku(e):i.kind==="class"?t=wu(e):i.kind==="attribute"?t=Au(e,i.attribute):i.kind==="position"&&(t=Su(e)),t&&(t.mutations.push(i),t.mutationRunner(t))}function ry(i,e){var t=null;if(i.kind==="html"?t=ku(e):i.kind==="class"?t=wu(e):i.kind==="attribute"?t=Au(e,i.attribute):i.kind==="position"&&(t=Su(e)),!!t){var s=t.mutations.indexOf(i);s!==-1&&t.mutations.splice(s,1),t.mutationRunner(t)}}function Tu(i){if(!(i.kind==="position"&&i.elements.size===1)){var e=new Set(i.elements),t=document.querySelectorAll(i.selector);t.forEach(function(s){e.has(s)||(i.elements.add(s),sy(i,s))})}}function ny(i){i.elements.forEach(function(e){return ry(i,e)}),i.elements.clear(),So.delete(i)}function Eu(){So.forEach(Tu)}function oy(){typeof document>"u"||(bo||(bo=new MutationObserver(function(){Eu()})),Eu(),bo.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Tr(i){return typeof document>"u"?ko:(So.add(i),Tu(i),{revert:function(){ny(i)}})}function Eo(i,e){return Tr({kind:"html",elements:new Set,mutate:e,selector:i})}function Iu(i,e){return Tr({kind:"position",elements:new Set,mutate:e,selector:i})}function ss(i,e){return Tr({kind:"class",elements:new Set,mutate:e,selector:i})}function Er(i,e,t){return Um.test(e)?e==="class"||e==="className"?ss(i,function(s){var r=t(Array.from(s).join(" "));s.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return s.add(n)})}):Tr({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:i}):ko}function ay(i){var e=i.selector,t=i.action,s=i.value,r=i.attribute,n=i.parentSelector,o=i.insertBeforeSelector;if(r==="html"){if(t==="append")return Eo(e,function(a){return a+(s??"")});if(t==="set")return Eo(e,function(){return s??""})}else if(r==="class"){if(t==="append")return ss(e,function(a){s&&a.add(s)});if(t==="remove")return ss(e,function(a){s&&a.delete(s)});if(t==="set")return ss(e,function(a){a.clear(),s&&a.add(s)})}else if(r==="position"){if(t==="set"&&n)return Iu(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(t==="append")return Er(e,r,function(a){return a!==null?a+(s??""):s??""});if(t==="set")return Er(e,r,function(){return s??""});if(t==="remove")return Er(e,r,function(){return null})}return ko}var Um,ko,kr,So,zm,Km,Wm,Xm,Ym,Qm,Jm,Zm,yr,bo,ly,Ru,Ou=Re(()=>{"use strict";Um=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,ko={revert:function(){}},kr=new Map,So=new Set;zm=function(e){return e.innerHTML},Km=function(e,t){return e.innerHTML=t};Wm=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Xm=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};Ym=function(e,t){return t?e.className=t:e.removeAttribute("class")},Qm=function(e){return e.className};Jm=function(e){return function(t){var s;return(s=t.getAttribute(e))!=null?s:null}},Zm=function(e){return function(t,s){return s!==null?t.setAttribute(e,s):t.removeAttribute(e)}};oy();ly={html:Eo,classes:ss,attribute:Er,position:Iu,declarative:ay},Ru=ly});function Rt(i,e,t){t=t||{};for(let[s,r]of Object.entries(e))switch(s){case"$or":if(!Nu(i,r,t))return!1;break;case"$nor":if(Nu(i,r,t))return!1;break;case"$and":if(!fy(i,r,t))return!1;break;case"$not":if(Rt(i,r,t))return!1;break;default:if(!rs(r,cy(i,s),t))return!1}return!0}function cy(i,e){let t=e.split("."),s=i;for(let r=0;r<t.length;r++)if(s&&typeof s=="object"&&t[r]in s)s=s[t[r]];else return null;return s}function Cu(i,e=!1){let t=`${i}${e?"/i":""}`;return wo[t]||(wo[t]=new RegExp(i.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),wo[t]}function rs(i,e,t,s=!1){if(typeof i=="string")return s?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)||!Du(i))return JSON.stringify(e)===JSON.stringify(i);for(let r in i)if(!hy(r,e,i[r],t))return!1;return!0}function Du(i){let e=Object.keys(i);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function uy(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 dy(i,e,t){if(!Array.isArray(i))return!1;let s=Du(e)?r=>rs(e,r,t):r=>Rt(r,e,t);for(let r=0;r<i.length;r++)if(i[r]&&s(i[r]))return!0;return!1}function Ei(i,e,t=!1){if(t){let s=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(i)?i.some(r=>e.some(n=>s(r)===s(n))):e.some(r=>s(i)===s(r))}return Array.isArray(i)?i.some(s=>e.includes(s)):e.includes(i)}function Pu(i,e,t,s=!1){if(!Array.isArray(i))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<i.length;o++)if(rs(e[r],i[o],t,s)){n=!0;break}if(!n)return!1}return!0}function hy(i,e,t,s){switch(i){case"$veq":return Be(e)===Be(t);case"$vne":return Be(e)!==Be(t);case"$vgt":return Be(e)>Be(t);case"$vgte":return Be(e)>=Be(t);case"$vlt":return Be(e)<Be(t);case"$vlte":return Be(e)<=Be(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)?Ei(e,t):!1;case"$ini":return Array.isArray(t)?Ei(e,t,!0):!1;case"$inGroup":return Ei(e,s[t]||[]);case"$notInGroup":return!Ei(e,s[t]||[]);case"$nin":return Array.isArray(t)?!Ei(e,t):!1;case"$nini":return Array.isArray(t)?!Ei(e,t,!0):!1;case"$not":return!rs(t,e,s);case"$size":return Array.isArray(e)?rs(t,e.length,s):!1;case"$elemMatch":return dy(e,t,s);case"$all":return Array.isArray(t)?Pu(e,t,s):!1;case"$alli":return Array.isArray(t)?Pu(e,t,s,!0):!1;case"$regex":try{return Cu(t).test(e)}catch{return!1}case"$regexi":try{return Cu(t,!0).test(e)}catch{return!1}case"$type":return uy(e)===t;default:return console.error("Unknown operator: "+i),!1}}function Nu(i,e,t){if(!e.length)return!0;for(let s=0;s<e.length;s++)if(Rt(i,e[s],t))return!0;return!1}function fy(i,e,t){for(let s=0;s<e.length;s++)if(!Rt(i,e[s],t))return!1;return!0}var wo,xu=Re(()=>{"use strict";ts();wo={}});function vy(i){let e=new Map;return i.global.forcedFeatureValues&&i.global.forcedFeatureValues.forEach((t,s)=>e.set(s,t)),i.user.forcedFeatureValues&&i.user.forcedFeatureValues.forEach((t,s)=>e.set(s,t)),e}function _y(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 ki(i){try{await i()}catch{}}function Lu(i,e,t){if(i.user.trackedExperiments){let r=Or(e,t);if(i.user.trackedExperiments.has(r))return[];i.user.trackedExperiments.add(r)}i.user.enableDevMode&&i.user.devLogs&&i.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let s=[];if(i.global.trackingCallback){let r=i.global.trackingCallback;s.push(ki(()=>r(e,t,i.user)))}if(i.user.trackingCallback){let r=i.user.trackingCallback;s.push(ki(()=>r(e,t)))}if(i.global.eventLogger){let r=i.global.eventLogger;s.push(ki(()=>r(py,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},i.user)))}return s}function my(i,e,t){if(i.user.trackedFeatureUsage){let s=JSON.stringify(t.value);if(i.user.trackedFeatureUsage[e]===s)return;i.user.trackedFeatureUsage[e]=s,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 s=i.global.onFeatureUsage;ki(()=>s(e,t,i.user))}if(i.user.onFeatureUsage){let s=i.user.onFeatureUsage;ki(()=>s(e,t))}if(i.global.eventLogger){let s=i.global.eventLogger;ki(()=>s(gy,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},i.user))}}function Ir(i,e){if(e.stack.evaluatedFeatures.has(i))return Ot(e,i,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(i),e.stack.id=i;let t=vy(e);if(t.has(i))return Ot(e,i,t.get(i),"override");if(!e.global.features||!e.global.features[i])return Ot(e,i,null,"unknownFeature");let s=e.global.features[i];if(s.rules){let r=new Set(e.stack.evaluatedFeatures);e:for(let n of s.rules){if(n.parentConditions)for(let l of n.parentConditions){e.stack.evaluatedFeatures=new Set(r);let c=Ir(l.id,e);if(c.source==="cyclicPrerequisite")return Ot(e,i,null,"cyclicPrerequisite");let u={value:c.value};if(!Rt(u,l.condition||{})){if(l.gate)return Ot(e,i,null,"prerequisite");continue e}}if(n.filters&&Mu(n.filters,e))continue;if("force"in n){if(n.condition&&!Fu(n.condition,e)||!yy(e,n.seed||i,n.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0,n.range,n.coverage,n.hashVersion))continue;return n.tracks&&n.tracks.forEach(l=>{!Lu(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),Ot(e,i,n.force,"force",n.id)}if(!n.variations)continue;let o={variations:n.variations,key:n.key||i};"coverage"in n&&(o.coverage=n.coverage),n.weights&&(o.weights=n.weights),n.hashAttribute&&(o.hashAttribute=n.hashAttribute),n.fallbackAttribute&&(o.fallbackAttribute=n.fallbackAttribute),n.disableStickyBucketing&&(o.disableStickyBucketing=n.disableStickyBucketing),n.bucketVersion!==void 0&&(o.bucketVersion=n.bucketVersion),n.minBucketVersion!==void 0&&(o.minBucketVersion=n.minBucketVersion),n.namespace&&(o.namespace=n.namespace),n.meta&&(o.meta=n.meta),n.ranges&&(o.ranges=n.ranges),n.name&&(o.name=n.name),n.phase&&(o.phase=n.phase),n.seed&&(o.seed=n.seed),n.hashVersion&&(o.hashVersion=n.hashVersion),n.filters&&(o.filters=n.filters),n.condition&&(o.condition=n.condition);let{result:a}=Rr(o,i,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return Ot(e,i,a.value,"experiment",n.id,o,a)}}return Ot(e,i,s.defaultValue===void 0?null:s.defaultValue,"defaultValue")}function Rr(i,e,t){let s=i.key,r=i.variations.length;if(r<2)return{result:ne(t,i,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:ne(t,i,-1,!1,e)};if(i=by(i,t),i.urlPatterns&&!gr(t.user.url||"",i.urlPatterns))return{result:ne(t,i,-1,!1,e)};let n=au(s,t.user.url||"",r);if(n!==null)return{result:ne(t,i,n,!1,e)};let o=_y(t);if(s in o){let m=o[s];return{result:ne(t,i,m,!1,e)}}if(i.status==="draft"||i.active===!1)return{result:ne(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:ne(t,i,-1,!1,e)};let c=-1,u=!1,h=!1;if(t.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing){let{variation:m,versionIsBlocked:E}=Sy({ctx:t,expKey:i.key,expBucketVersion:i.bucketVersion,expHashAttribute:i.hashAttribute,expFallbackAttribute:i.fallbackAttribute,expMinBucketVersion:i.minBucketVersion,expMeta:i.meta});u=m>=0,c=m,h=!!E}if(!u){if(i.filters){if(Mu(i.filters,t))return{result:ne(t,i,-1,!1,e)}}else if(i.namespace&&!ru(l,i.namespace))return{result:ne(t,i,-1,!1,e)};if(i.include&&!lu(i.include))return{result:ne(t,i,-1,!1,e)};if(i.condition&&!Fu(i.condition,t))return{result:ne(t,i,-1,!1,e)};if(i.parentConditions){let m=new Set(t.stack.evaluatedFeatures);for(let E of i.parentConditions){t.stack.evaluatedFeatures=new Set(m);let b=Ir(E.id,t);if(b.source==="cyclicPrerequisite")return{result:ne(t,i,-1,!1,e)};let O={value:b.value};if(!Rt(O,E.condition||{}))return{result:ne(t,i,-1,!1,e)}}}if(i.groups&&!ky(i.groups,t))return{result:ne(t,i,-1,!1,e)}}if(i.url&&!Ey(i.url,t))return{result:ne(t,i,-1,!1,e)};let g=Zi(i.seed||s,l,i.hashVersion||1);if(g===null)return{result:ne(t,i,-1,!1,e)};if(!u){let m=i.ranges||ou(r,i.coverage===void 0?1:i.coverage,i.weights);c=nu(g,m)}if(h)return{result:ne(t,i,-1,!1,e,void 0,!0)};if(c<0)return{result:ne(t,i,-1,!1,e)};if("force"in i)return{result:ne(t,i,i.force===void 0?-1:i.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:ne(t,i,-1,!1,e)};if(i.status==="stopped")return{result:ne(t,i,-1,!1,e)};let f=ne(t,i,c,!0,e,g,u);if(t.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing){let{changed:m,key:E,doc:b}=Ay(t,a,es(l),{[Ao(i.key,i.bucketVersion)]:f.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[E]=b,t.user.saveStickyBucketAssignmentDoc(b))}let v=Lu(t,i,f);v.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:i,result:f});let p=v.length?v.length===1?v[0]:Promise.all(v).then(()=>{}):void 0;return"changeId"in i&&i.changeId&&t.global.recordChangeId&&t.global.recordChangeId(i.changeId),{result:f,trackingCall:p}}function Ot(i,e,t,s,r,n,o){let a={value:t,on:!!t,off:!t,source:s,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),s!=="override"&&my(i,e,a),a}function $u(i){return{...i.user.attributes,...i.user.attributeOverrides}}function Fu(i,e){return Rt($u(e),i,e.global.savedGroups||{})}function Mu(i,e){return i.some(t=>{let{hashValue:s}=Kt(e,t.attribute);if(!s)return!0;let r=Zi(t.seed,s,t.hashVersion||2);return r===null?!0:!t.ranges.some(n=>fr(r,n))})}function yy(i,e,t,s,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=Kt(i,t,s);if(!a)return!1;let l=Zi(e,a,o||1);return l===null?!1:r?fr(l,r):n!==void 0?l<=n:!0}function ne(i,e,t,s,r,n,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:r,inExperiment:a,hashUsed:s,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};return u.name&&(h.name=u.name),n!==void 0&&(h.bucket=n),u.passthrough&&(h.passthrough=u.passthrough),h}function by(i,e){let t=i.key,s=e.global.overrides;return s&&s[t]&&(i=Object.assign({},i,s[t]),typeof i.url=="string"&&(i.url=fo(i.url))),i}function Kt(i,e,t){let s=e||"id",r="",n=$u(i);return n[s]&&(r=n[s]),!r&&t&&(n[t]&&(r=n[t]),r&&(s=t)),{hashAttribute:s,hashValue:r}}function Ey(i,e){let t=e.user.url;if(!t)return!1;let s=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(i.test(t)||i.test(s))}function ky(i,e){let t=e.global.groups||{};for(let s=0;s<i.length;s++)if(t[i[s]])return!0;return!1}function Sy({ctx:i,expKey:e,expBucketVersion:t,expHashAttribute:s,expFallbackAttribute:r,expMinBucketVersion:n,expMeta:o}){t=t||0,n=n||0,s=s||"id",o=o||[];let a=Ao(e,t),l=wy(i,s,r);if(n>0)for(let h=0;h<n;h++){let g=Ao(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 Ao(i,e){return e=e||0,`${i}__${e}`}function To(i,e){return`${i}||${e}`}function wy(i,e,t){if(!i.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:s,hashValue:r}=Kt(i,e),n=To(s,es(r)),{hashAttribute:o,hashValue:a}=Kt(i,t),l=a?To(o,es(a)):null,c={};return l&&i.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,i.user.stickyBucketAssignmentDocs[l].assignments||{}),i.user.stickyBucketAssignmentDocs[n]&&Object.assign(c,i.user.stickyBucketAssignmentDocs[n].assignments||{}),c}function Ay(i,e,t,s){let r=To(e,t),n=i.user.stickyBucketAssignmentDocs&&i.user.stickyBucketAssignmentDocs[r]?i.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o={...n,...s},a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function Ty(i,e){let t=new Set,s=e&&e.features?e.features:i.global.features||{},r=e&&e.experiments?e.experiments:i.global.experiments||[];return Object.keys(s).forEach(n=>{let o=s[n];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),r.map(n=>{t.add(n.hashAttribute||"id"),n.fallbackAttribute&&t.add(n.fallbackAttribute)}),Array.from(t)}async function Uu(i,e,t){let s=Io(i,t);return e.getAllAssignments(s)}function Io(i,e){let t={};return Ty(i,e).forEach(r=>{let{hashValue:n}=Kt(i,r);t[r]=es(n)}),t}async function Bu(i,e,t){if(i={...i},i.encryptedFeatures){try{i.features=JSON.parse(await zt(i.encryptedFeatures,e,t))}catch(s){console.error(s)}delete i.encryptedFeatures}if(i.encryptedExperiments){try{i.experiments=JSON.parse(await zt(i.encryptedExperiments,e,t))}catch(s){console.error(s)}delete i.encryptedExperiments}if(i.encryptedSavedGroups){try{i.savedGroups=JSON.parse(await zt(i.encryptedSavedGroups,e,t))}catch(s){console.error(s)}delete i.encryptedSavedGroups}return i}function Vu(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 Or(i,e){return e.hashAttribute+e.hashValue+i.key+e.variationId}var gy,py,Gu=Re(()=>{"use strict";xu();ts();gy="Feature Evaluated",py="Experiment Viewed"});var Si,Iy,ns,ju=Re(()=>{"use strict";Ou();ts();yu();Gu();Si=typeof window<"u"&&typeof document<"u",Iy=cu(),ns=class{constructor(e){if(e=e||{},this.version=Iy,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=s=>t.saveAssignments(s)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),Si&&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 s=this._options.stickyBucketAssignmentDocs[t];s&&this._options.stickyBucketService.saveAssignments(s).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await Bu(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,mr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&fu(e.cacheSettings),e.payload)return await this.setPayload(e.payload),mr(this,e),{success:!0,source:"init"};{let{data:t,...s}=await this._refresh({...e,allowStale:!0});return mr(this,e),await this.setPayload(t||{}),s}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return Vu(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:s,streaming:r}){if(!this._options.clientKey)throw new Error("Missing clientKey");return gu({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:s,backgroundSync:r??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,t,s){let r=await zt(e,t||this._options.decryptionKey,s);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,s){let r=await zt(e,t||this._options.decryptionKey,s);this.setExperiments(JSON.parse(r))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(t=>{try{t()}catch(s){console.error(s)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,pu(this),e.destroyAllStreams&&yo(),this.logs=[],Si&&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}=Rr(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(s=>s.key===e).map(s=>this._runAutoExperiment(s)).filter(s=>s!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,t){let s=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!s)return null;let r=this._isAutoExperimentBlockedByContext(e),n,o;r?n=ne(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=Rr(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!t&&n.inExperiment&&s&&s.valueHash===a)return n;if(s&&this._undoActiveAutoExperiment(e),n.inExperiment){let l=pr(e);if(l==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?uu(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(gr(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=c;let{navigate:u,delay:h}=this._getNavigateFunction();if(u)if(Si)Promise.all([...o?[vr(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(n.value):this._applyDOMChanges(n.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return n}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],s=new Set(t);this._activeAutoExperiments.forEach((r,n)=>{s.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of t){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&pr(r)==="redirect")break}}_onExperimentEval(e,t){let s=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,s)}_fireSubscriptions(e,t,s){(!s||s.result.inExperiment!==t.inExperiment||s.result.variationId!==t.variationId)&&this._subscriptions.forEach(r=>{try{r(e,t)}catch(n){console.error(n)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,t){let s=this.evalFeature(e).value;return s===null?t:s}feature(e){return this.evalFeature(e)}evalFeature(e){return Ir(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=>[Or(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(s){console.error(s)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Or(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(Si?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=pr(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(s=>s.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let s=new URL(this._getContextUrl());for(let r of e.variations){if(!r||!r.urlRedirect)continue;let n=new URL(r.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(n.protocol!==s.protocol||n.host!==s.host))return!0}}catch(s){return this.log("Error parsing current or redirect URL",{id:e.key,error:s}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:Si?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!Si)return;let t=[];if(e.css){let s=document.createElement("style");s.innerHTML=e.css,document.head.appendChild(s),t.push(()=>s.remove())}if(e.js){let s=document.createElement("script");s.innerHTML=e.js,this._options.jsInjectionNonce&&(s.nonce=this._options.jsInjectionNonce),document.head.appendChild(s),t.push(()=>s.remove())}return e.domMutations&&e.domMutations.forEach(s=>{t.push(Ru.declarative(s).revert)}),()=>{t.forEach(s=>s())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),s=await Uu(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=s}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let s=this._getEvalContext(),r=Io(s,t);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var Hu=Re(()=>{"use strict";ju()});var qu={};un(qu,{Growthbook:()=>Ro});var ze,Ro,zu=Re(()=>{"use strict";Hu();oo();Qi();pi();ze=class ze{constructor(e,t,s={},r=!1){this.analytics=new hi;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=it("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:t,user_language:s,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:c,url:u,domain:h,utm_content:g,residence_country:f,loggedIn:v,network_type:p,network_downlink:m,user_id:E,anonymous_id:b,account_mode:O})=>{let I={...this.GrowthBook.getAttributes(),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},...s!==void 0&&{user_language:s},...r!==void 0&&{device_language:r},...n!==void 0&&{device_type:n},...o!==void 0&&{utm_source:o},...a!==void 0&&{utm_medium:a},...l!==void 0&&{utm_campaign:l},...c!==void 0&&{is_authorised:c},...u!==void 0&&{url:u},...h!==void 0&&{domain:h},...g!==void 0&&{utm_content:g},...v!==void 0&&{loggedIn:v},...p!==void 0&&{network_type:p},...m!==void 0&&{network_downlink:m},...O!==void 0&&{account_mode:O}};this.log("setAttributes | updating GrowthBook attributes",I),this.GrowthBook.setAttributes(I)};this.getFeatureValue=(e,t)=>{let s=this.GrowthBook.getFeatureValue(e,t);return this.log("getFeatureValue",{key:e,value:s,defaultValue:t}),s};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let t=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:t}),t};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let t=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:t}),t};this.init=async()=>{this.log("init | initializing GrowthBook SDK");let e=await this.GrowthBook.init({timeout:2e3,streaming:!0}).catch(()=>{});this.status=e,this.isLoaded=!0,this.log("init | GrowthBook SDK loaded",{status:e})};this.destroy=()=>{this.GrowthBook.destroy(),this.isLoaded=!1,this.status=void 0};this.debug=r;let n=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new ns({apiHost:Uc,clientKey:e,decryptionKey:t,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:n,trackingCallback:(o,a)=>{this.log("trackingCallback | experiment viewed",{experiment_id:o.key,variation_id:a.variationId}),typeof window<"u"&&window.dataLayer&&window.dataLayer.push({event:"experiment_viewed",event_category:"experiment",rudder_anonymous_id:this.analytics.getAnonymousId(),experiment_id:o.key,variation_id:a.variationId}),this.analytics.track("experiment_viewed",{experimentId:o.key,variationId:a.variationId})},...s}),this.init()}reapplyExperiment(e){let t=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(t)}waitForIsLoaded(e=1e4){return new Promise((t,s)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),t()):Date.now()-r>=e&&(clearInterval(n),s(new Error("GrowthBook initialization timeout")))},100)})}};ze.getGrowthBookInstance=(e,t,s,r=!1)=>ze._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),ze._instance):(ze._instance=new ze(e,t??"",s,r),ze._instance),ze.resetInstance=()=>{ze._instance&&(ze._instance.destroy(),ze._instance=void 0)};Ro=ze});function Yu(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(s,r)}function _t(i){return function(){var e=this,t=arguments;return new Promise((function(s,r){var n=i.apply(e,t);function o(l){Yu(n,s,r,o,a,"next",l)}function a(l){Yu(n,s,r,o,a,"throw",l)}o(void 0)}))}}function k(){return k=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(i[s]=t[s])}return i},k.apply(null,arguments)}function jd(i,e){if(i==null)return{};var t={};for(var s in i)if({}.hasOwnProperty.call(i,s)){if(e.indexOf(s)!==-1)continue;t[s]=i[s]}return t}function M(i,e){return i.indexOf(e)!==-1}function Yo(i){return i===null||typeof i!="object"}function Mr(i,e){return Object.prototype.toString.call(i)==="[object "+e+"]"}function zd(i){return!w(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(i,Event)}function ot(i,e,t,s,r){return e>t&&(s.warn("min cannot be greater than max."),e=t),at(i)?i>t?(s.warn(" cannot be greater than max: "+t+". Using max value instead."),t):i<e?(s.warn(" cannot be less than min: "+e+". Using min value instead."),e):i:(s.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+r),ot(r||t,e,t,s))}function zy(i){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return Po&&t.length===Zu||(Zu=t.length,Po=t.reduce(((s,r)=>{Cr||(Cr={});var n=Cr[r];if(n)s[n[0]]=n[1];else for(var o=i(r),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,u=e[r];if(c&&u){s[c]=u,Cr[r]=[c,u];break}}return s}),{})),Po}}function ia(i,e,t,s,r){var n={platform:i,filename:e,function:t==="<anonymous>"?xi:t,in_app:!0};return w(s)||(n.lineno=s),w(r)||(n.colno=r),n}function eb(){return(function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s<e;s++)t[s-1]=arguments[s];return function(r,n){n===void 0&&(n=0);for(var o=[],a=r.split(`
15
- `),l=n;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=id.test(c)?c.replace(id,"$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>=sd)break}}}return(function(f){if(!f.length)return[];var v=Array.from(f);return v.reverse(),v.slice(0,sd).map((p=>{return k({},p,{filename:p.filename||(m=v,m[m.length-1]||{}).filename,function:p.function||xi});var m}))})(o)}})("web:javascript",Yy,Zy)}function uh(i,e){e===void 0&&(e=40);var t=Object.keys(i);if(t.sort(),!t.length)return"[object has no keys]";for(var s=t.length;s>0;s--){var r=t.slice(0,s).join(", ");if(!(r.length>e))return s===t.length||r.length<=e?r:r.slice(0,e)+"..."}return""}function Lt(i,e,t){if(q(i)){if(Ku&&i.forEach===Ku)i.forEach(e,t);else if("length"in i&&i.length===+i.length){for(var s=0,r=i.length;s<r;s++)if(s in i&&e.call(t,i[s],s)===Br)return}}}function Z(i,e,t){if(!U(i)){if(q(i))return Lt(i,e,t);if(Py(i)){for(var s of i.entries())if(e.call(t,s[1],s[0])===Br)return}else for(var r in i)if(qd.call(i,r)&&e.call(t,i[r],r)===Br)return}}function $r(i){for(var e=Object.keys(i),t=e.length,s=new Array(t);t--;)s[t]=[e[t],i[e[t]]];return s}function nb(i,e){return t=i,s=n=>he(n)&&!Je(e)?n.slice(0,e):n,r=new Set,(function n(o,a){return o!==Object(o)?s?s(o,a):o:r.has(o)?void 0:(r.add(o),q(o)?(l=[],Lt(o,(c=>{l.push(n(c))}))):(l={},Z(o,((c,u)=>{r.has(c)||(l[u]=n(c,u))}))),l);var l})(t);var t,s,r}function ab(i){var e=i?.hostname;if(!he(e))return!1;var t=e.split(".").slice(-2).join(".");for(var s of ob)if(t===s)return!1;return!0}function hh(i,e){for(var t=0;t<i.length;t++)if(e(i[t]))return i[t]}function de(i,e,t,s){var{capture:r=!1,passive:n=!0}=s??{};i?.addEventListener(e,t,{capture:r,passive:n})}function fh(i){return i.name==="ph_toolbar_internal"}function db(i,e){if(e){var t=(function(r,n){if(n===void 0&&(n=S),as)return as;if(!n||["localhost","127.0.0.1"].includes(r))return"";for(var o=r.split("."),a=Math.min(o.length,8),l="dmn_chk_"+xt();!as&&a--;){var c=o.slice(a).join("."),u=l+"=1;domain=."+c+";path=/";n.cookie=u+";max-age=3",n.cookie.includes(l)&&(n.cookie=u+";max-age=0",as=c)}return as})(i);if(!t){var s=(r=>{var n=r.match(ub);return n?n[0]:""})(i);s!==t&&A.info("Warning: cookie subdomain discovery mismatch",s,t),t=s}return t?"; domain=."+t:""}return""}function vb(i,e){var t=i.config.segment;if(!t)return e();(function(s,r){var n=s.config.segment;if(!n)return r();var o=l=>{var c=()=>l.anonymousId()||xt();s.config.get_device_id=c,l.id()&&(s.register({distinct_id:l.id(),$device_id:c()}),s.persistence.set_property(rt,"identified")),r()},a=n.user();"then"in a&&bt(a.then)?a.then(o):o(a)})(i,(()=>{t.register((s=>{Promise&&Promise.resolve||Do.warn("This browser does not have Promise support, and can not use the segment integration");var r=(n,o)=>{if(!o)return n;n.event.userId||n.event.anonymousId===s.get_distinct_id()||(Do.info("No userId set, resetting PostHog"),s.reset()),n.event.userId&&n.event.userId!==s.get_distinct_id()&&(Do.info("UserId set, identifying with PostHog"),s.identify(n.event.userId));var a=s.calculateEventProperties(o,n.event.properties);return n.event.properties=Object.assign({},a,n.event.properties),n};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:n=>r(n,n.event.event),page:n=>r(n,"$pageview"),identify:n=>r(n,"$identify"),screen:n=>r(n,"$screen")}})(i)).then((()=>{e()}))}))}function bh(i,e){var{organization:t,projectId:s,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,h,g;if(!(n==="*"||n.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 v,p=((l=a.exception)==null?void 0:l.values)||[],m=p.map((b=>k({},b,{stacktrace:b.stacktrace?k({},b.stacktrace,{type:"raw",frames:(b.stacktrace.frames||[]).map((O=>k({},O,{platform:"web:javascript"})))}):void 0}))),E={$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:m,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=p[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(g=p[0])==null?void 0:g.type,$sentry_tags:a.tags};return t&&s&&(E.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+s+"&query="+a.event_id),o&&((v=i.exceptions)==null||v.sendExceptionEvent(E)),a}}function Eh(i,e,t){if(!S)return{};var s,r=e?Li([],$i,t||[]):[],n=kh(Os(S.URL,r,Cs),i),o=(s={},Z(yb,(function(a){var l=nt.A(a);s[a]=l||null})),s);return ue(o,n)}function kh(i,e){var t=mb.concat(e||[]),s={};return Z(t,(function(r){var n=Xr(i,r);s[r]=n||null})),s}function Sh(i){var e=(function(n){return n?n.search(xr+"google.([^/?]*)")===0?"google":n.search(xr+"bing.com")===0?"bing":n.search(xr+"yahoo.com")===0?"yahoo":n.search(xr+"duckduckgo.com")===0?"duckduckgo":null:null})(i),t=e!="yahoo"?"q":"p",s={};if(!Je(e)){s.$search_engine=e;var r=S?Xr(S.referrer,t):"";r.length&&(s.ph_keyword=r)}return s}function gd(){return navigator.language||navigator.userLanguage}function wh(){return S?.referrer||"$direct"}function Ah(i,e){var t=i?Li([],$i,e||[]):[],s=be?.href.substring(0,1e3);return{r:wh().substring(0,1e3),u:s?Os(s,t,Cs):void 0}}function Th(i){var e,{r:t,u:s}=i,r={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Wr(t))==null?void 0:e.host};if(s){r.$current_url=s;var n=Wr(s);r.$host=n?.host,r.$pathname=n?.pathname;var o=kh(s);ue(r,o)}if(t){var a=Sh(t);ue(r,a)}return r}function Ih(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function bb(){try{return new Date().getTimezoneOffset()}catch{return}}function Eb(i,e){var t,s,r,n;if(!xe)return{};var o,a,l,c,u,h,g,f,v=i?Li([],$i,e||[]):[],[p,m]=(function(E){for(var b=0;b<ed.length;b++){var[O,P]=ed[b],I=O.exec(E),z=I&&(bt(P)?P(I,E):P);if(z)return z}return["",""]})(xe);return ue(Ya({$os:p,$os_version:m,$browser:lh(xe,navigator.vendor),$device:td(xe),$device_type:(a=xe,l={userAgentDataPlatform:(t=navigator)==null||(t=t.userAgentData)==null?void 0:t.platform,maxTouchPoints:(s=navigator)==null?void 0:s.maxTouchPoints,screenWidth:_==null||(r=_.screen)==null?void 0:r.width,screenHeight:_==null||(n=_.screen)==null?void 0:n.height,devicePixelRatio:_?.devicePixelRatio},f=td(a),f===Wd||f===Kd||f==="Kobo"||f==="Kindle Fire"||f===ah?Ni:f===Is||f===Pi||f===Rs||f===Zo?"Console":f===Yd?"Wearable":f?Ge:l?.userAgentDataPlatform==="Android"&&((c=l?.maxTouchPoints)!==null&&c!==void 0?c:0)>0?Math.min((u=l?.screenWidth)!==null&&u!==void 0?u:0,(h=l?.screenHeight)!==null&&h!==void 0?h:0)/((g=l?.devicePixelRatio)!==null&&g!==void 0?g:1)>=600?Ni:Ge:"Desktop"),$timezone:Ih(),$timezone_offset:bb()}),{$current_url:Os(be?.href,v,Cs),$host:be?.host,$pathname:be?.pathname,$raw_user_agent:xe.length>1e3?xe.substring(0,997)+"...":xe,$browser_version:Hy(xe,navigator.vendor),$browser_language:gd(),$browser_language_prefix:(o=gd(),typeof o=="string"?o.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.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 Ub(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=Fb[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),s=i.length;t.p(i);var r,n=Mb(i,e,10+((r=e).filename&&r.filename.length+1||0),8),o=n.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&&Mo(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)}})(n,e),Mo(n,o-8,t.d()),Mo(n,o-4,s),n}function Sd(i,e,t){return Es({distinct_id:i,userPropertiesToSet:e,userPropertiesToSetOnce:t})}function xh(i,e){return!i||Object.entries(i).every((t=>{var[s,r]=t,n=e?.[s];if(w(n)||Je(n))return!1;var o=[String(n)],a=Dh[r.operator];return!!a&&a(r.values,o)}))}function Rd(i){return i instanceof Element&&(i.id===_h||!(i.closest==null||!i.closest(".toolbar-global-fade-container")))}function cn(i){return!!i&&i.nodeType===1}function $t(i,e){return!!i&&!!i.tagName&&i.tagName.toLowerCase()===e.toLowerCase()}function Fh(i){return!!i&&i.nodeType===3}function Mh(i){return!!i&&i.nodeType===11}function Za(i){return i?an(i).split(/\s+/):[]}function Od(i){var e=_?.location.href;return!!(e&&i&&i.some((t=>e.match(t))))}function nn(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 Za(e)}function Uh(i){return U(i)?null:an(i).split(/(\s+)/).filter((e=>Ns(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ds(i){var e="";return Ba(i)&&!jh(i)&&i.childNodes&&i.childNodes.length&&Z(i.childNodes,(function(t){var s;Fh(t)&&t.textContent&&(e+=(s=Uh(t.textContent))!==null&&s!==void 0?s:"")})),an(e)}function Cd(i){return w(i.target)?i.srcElement||null:(e=i.target)!=null&&e.shadowRoot?i.composedPath()[0]||null:i.target||null;var e}function Bh(i,e){if(w(e))return!0;var t,s=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of i)if(t=s(r))return t.v;return!1}function Vh(i){var e=i.parentNode;return!(!e||!cn(e))&&e}function Yb(i,e){if(!_||tl(i))return!1;var t,s,r;if(kt(e)?(t=!!e&&Nd,s=void 0):(t=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:Nd,s=e?.content_ignorelist),t===!1)return!1;var{targetElementList:n}=Gh(i,!1);return!(function(o,a){if(o===!1||w(o))return!1;var l;if(o===!0)l=Xb;else{if(!q(o))return!1;if(o.length>Pd)return A.error("[PostHog] content_ignorelist array cannot exceed "+Pd+" 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)))}))})(s,n.map((o=>{var a;return{safeText:Ds(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!Bh(n,t)}function Qb(i,e,t,s,r){var n,o,a,l;if(t===void 0&&(t=void 0),!_||tl(i)||(n=t)!=null&&n.url_allowlist&&!Od(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&Od(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some((v=>e.type===v)))return!1}var{parentIsUsefulElement:u,targetElementList:h}=Gh(i,s);if(!(function(v,p){var m=p?.element_allowlist;if(w(m))return!0;var E,b=function(P){if(m.some((I=>P.tagName.toLowerCase()===I)))return{v:!0}};for(var O of v)if(E=b(O))return E.v;return!1})(h,t)||!Bh(h,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var g=_.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(r||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(e.type)>=0;default:return u?(r||["click"]).indexOf(e.type)>=0:(r||["click"]).indexOf(e.type)>=0&&(el.indexOf(f)>-1||i.getAttribute("contenteditable")==="true")}}function Ba(i){for(var e=i;e.parentNode&&!$t(e,"body");e=e.parentNode){var t=nn(e);if(M(t,"ph-sensitive")||M(t,"ph-no-capture"))return!1}if(M(nn(i),"ph-include"))return!0;var s=i.type||"";if(he(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=i.name||i.id||"";return!(he(r)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))}function jh(i){return!!($t(i,"input")&&!["button","checkbox","submit","reset"].includes(i.type)||$t(i,"select")||$t(i,"textarea")||i.getAttribute("contenteditable")==="true")}function Ns(i,e){return e===void 0&&(e=!0),!(U(i)||he(i)&&(i=an(i),(e?Jb:Zb).test((i||"").replace(/[- ]/g,""))||(e?eE:tE).test(i)))}function zh(i){var e=Ds(i);return Ns(e=(e+" "+Kh(i)).trim())?e:""}function Kh(i){var e="";return i&&i.childNodes&&i.childNodes.length&&Z(i.childNodes,(function(t){var s;if(t&&((s=t.tagName)==null?void 0:s.toLowerCase())==="span")try{var r=Ds(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Kh(t)).trim())}catch(n){A.error("[AutoCapture]",n)}})),e}function iE(i){return(function(e){var t=e.map((s=>{var r,n,o="";if(s.tag_name&&(o+=s.tag_name),s.attr_class)for(var a of(s.attr_class.sort(),s.attr_class))o+="."+a.replace(/"/g,"");var l=k({},s.text?{text:s.text}:{},{"nth-child":(r=s.nth_child)!==null&&r!==void 0?r:0,"nth-of-type":(n=s.nth_of_type)!==null&&n!==void 0?n:0},s.href?{href:s.href}:{},s.attr_id?{attr_id:s.attr_id}:{},s.attributes),c={};return $r(l).sort(((u,h)=>{var[g]=u,[f]=h;return g.localeCompare(f)})).forEach((u=>{var[h,g]=u;return c[Dd(h.toString())]=Dd(g.toString())})),o+=":",o+=$r(c).map((u=>{var[h,g]=u;return h+'="'+g+'"'})).join("")}));return t.join(";")})((function(e){return e.map((t=>{var s,r,n={text:(s=t.$el_text)==null?void 0:s.slice(0,400),tag_name:t.tag_name,href:(r=t.attr__href)==null?void 0:r.slice(0,2048),attr_class:sE(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return $r(t).filter((o=>{var[a]=o;return a.indexOf("attr__")===0})).forEach((o=>{var[a,l]=o;return n.attributes[a]=l})),n}))})(i))}function Dd(i){return i.replace(/"|\\"/g,'\\"')}function sE(i){var e=i.attr__class;return e?q(e)?e:Za(e):void 0}function jo(i,e){return e.length>i?e.slice(0,i)+"...":e}function rE(i){if(i.previousElementSibling)return i.previousElementSibling;var e=i;do e=e.previousSibling;while(e&&!cn(e));return e}function nE(i,e,t,s){var r=i.tagName.toLowerCase(),n={tag_name:r};el.indexOf(r)>-1&&!t&&(r.toLowerCase()==="a"||r.toLowerCase()==="button"?n.$el_text=jo(1024,zh(i)):n.$el_text=jo(1024,Ds(i)));var o=nn(i);o.length>0&&(n.classes=o.filter((function(u){return u!==""}))),Z(i.attributes,(function(u){var h;if((!jh(i)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(s==null||!s.includes(u.name))&&!e&&Ns(u.value)&&(h=u.name,!he(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var g=u.value;u.name==="class"&&(g=Za(g).join(" ")),n["attr__"+u.name]=jo(1024,g)}}));for(var a=1,l=1,c=i;c=rE(c);)a++,c.tagName===i.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function oE(i,e){for(var t,s,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[i],u=i;u.parentNode&&!$t(u,"body");)Mh(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var h,g=[],f={},v=!1,p=!1;if(Z(c,(P=>{var I=Ba(P);P.tagName.toLowerCase()==="a"&&(v=P.getAttribute("href"),v=I&&v&&Ns(v)&&v),M(nn(P),"ph-no-capture")&&(p=!0),g.push(nE(P,n,o,a));var z=(function(B){if(!Ba(B))return{};var N={};return Z(B.attributes,(function(ve){if(ve.name&&ve.name.indexOf("data-ph-capture-attribute")===0){var _e=ve.name.replace("data-ph-capture-attribute-",""),Le=ve.value;_e&&Le&&Ns(Le)&&(N[_e]=Le)}})),N})(P);ue(f,z)})),p)return{props:{},explicitNoCapture:p};if(o||(i.tagName.toLowerCase()==="a"||i.tagName.toLowerCase()==="button"?g[0].$el_text=zh(i):g[0].$el_text=Ds(i)),v){var m,E;g[0].attr__href=v;var b=(m=Wr(v))==null?void 0:m.host,O=_==null||(E=_.location)==null?void 0:E.host;b&&O&&b!==O&&(h=v)}return{props:ue({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:iE(g)},(t=g[0])!=null&&t.$el_text?{$el_text:(s=g[0])==null?void 0:s.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},f)}}function Ld(i,e,t){try{if(!(e in i))return()=>{};var s=i[e],r=t(s);return bt(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),i[e]=r,()=>{i[e]=s}}catch{return()=>{}}}function Fd(i){return fe(i)&&"clientX"in i&&"clientY"in i&&at(i.clientX)&&at(i.clientY)}function Ai(i,e,t){if(U(i))return!1;switch(t){case"exact":return i===e;case"contains":var s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(i);case"regex":try{return new RegExp(e).test(i)}catch{return!1}default:return!1}}var _,Ee,Gd,Ku,Wu,Ve,S,be,zo,Ko,Xu,xe,C,vt,Ry,Oy,Qu,an,Wo,Cy,Hd,qd,ln,q,bt,fe,Ri,w,he,Xo,Je,U,at,Ti,kt,Py,Ny,Dy,Oo,xy,Qo,Ge,Ur,Et,Ni,Kd,Wd,Xd,Yd,Ts,Di,Qd,Jd,Zd,Qt,Ly,eh,za,th,Ka,$y,Wa,ih,Ci,sh,Is,Rs,Pi,rh,nh,ps,Jo,Ju,Zo,oh,Fy,ah,ea,Ae,Co,My,Uy,By,Xa,Vy,Cr,Zu,Po,Gy,lh,jy,Hy,ed,td,qy,ta,xi,ch,Ky,Wy,Xy,Yy,Qy,Jy,Zy,id,sd,sa,ra,na,tb,oa,ib,aa,la,ca,ua,dh,A,le,sb,rd,Br,ue,Li,nd,rb,Ya,ob,gh,vs,_s,od,da,ad,ha,ld,cd,ph,ud,dd,Pr,Vr,vh,Oi,ms,fa,ys,Yt,ga,Gr,pa,jr,rt,va,_a,ma,ya,Hr,qr,_h,os,lb,hd,ba,Ea,fd,mh,ka,xt,cb,as,ub,nt,No,ae,hb,Nr,fb,Wt,ye,mt,Sa,Dr,gb,pb,zr,Do,yh,wa,Kr,yt,Wr,_b,Xr,Os,Yr,xr,$i,mb,Cs,yb,De,ls,kb,Sb,wb,Ab,Tb,Ib,Rb,xo,wi,pd,cs,vd,_d,Ob,Cb,Aa,Pb,Ss,us,Lo,bs,$o,Ta,Nb,md,yd,Ia,ds,Qr,We,Te,Fi,Qa,Ja,bd,Rh,Oh,Db,Ra,Ct,Oa,Jr,ee,ws,Jt,Zr,xb,Lb,Ch,Ph,pt,hs,Fo,Ca,Ed,fs,Pa,kd,$b,Fb,Mb,Mo,Bb,Vb,en,Es,Uo,Fr,Na,Da,Gb,xa,La,jb,tn,Ps,Bo,sn,Nh,rn,Dh,Lr,ks,wd,$a,Q,Lh,Hb,Ad,qb,zb,Kb,Wb,Fa,As,Vo,Ma,Ii,$h,Td,Id,Ua,Mi,el,Xb,Pd,Nd,tl,Gh,Hh,Jb,Zb,qh,eE,tE,on,Go,xd,gs,aE,Pt,$d,Va,Xt,lE,Md,Ho,cE,Nt,Ga,ja,Ha,uE,Ud,Bd,Dt,qo,dE,qa,Ke,hE,fE,gE,pE,vE,_E,mE,yE,bE,EE,kE,SE,Vd,St,Wh=Re(()=>{"use strict";_=typeof window<"u"?window:void 0,Ee=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(Ee.self=Ee),typeof File>"u"&&(Ee.File=function(){});Gd=Array.prototype,Ku=Gd.forEach,Wu=Gd.indexOf,Ve=Ee?.navigator,S=Ee?.document,be=Ee?.location,zo=Ee?.fetch,Ko=Ee!=null&&Ee.XMLHttpRequest&&"withCredentials"in new Ee.XMLHttpRequest?Ee.XMLHttpRequest:void 0,Xu=Ee?.AbortController,xe=Ve?.userAgent,C=_??{},vt={DEBUG:!1,LIB_VERSION:"1.358.0"};Ry=["$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"],Oy=["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"],Qu=function(i,e){if(e===void 0&&(e=[]),!i)return!1;var t=i.toLowerCase();return Oy.concat(e).some((s=>{var r=s.toLowerCase();return t.indexOf(r)!==-1}))};an=function(i){return i.trim()},Wo=function(i){return i.replace(/^\$/,"")},Cy=Array.isArray,Hd=Object.prototype,qd=Hd.hasOwnProperty,ln=Hd.toString,q=Cy||function(i){return ln.call(i)==="[object Array]"},bt=i=>typeof i=="function",fe=i=>i===Object(i)&&!q(i),Ri=i=>{if(fe(i)){for(var e in i)if(qd.call(i,e))return!1;return!0}return!1},w=i=>i===void 0,he=i=>ln.call(i)=="[object String]",Xo=i=>he(i)&&i.trim().length===0,Je=i=>i===null,U=i=>w(i)||Je(i),at=i=>ln.call(i)=="[object Number]"&&i==i,Ti=i=>at(i)&&i>0,kt=i=>ln.call(i)==="[object Boolean]",Py=i=>i instanceof FormData,Ny=i=>M(Ry,i);Dy=[!0,"true",1,"1","yes"],Oo=i=>M(Dy,i),xy=[!1,"false",0,"0","no"];Qo=class{constructor(e){this.t={},this.i=e.i,this.o=ot(e.bucketSize,0,100,e.h),this.m=ot(e.refillRate,0,this.o,e.h),this.S=ot(e.refillInterval,0,864e5,e.h)}$(e,t){var s=t-e.lastAccess,r=Math.floor(s/this.S);if(r>0){var n=r*this.m;e.tokens=Math.min(e.tokens+n,this.o),e.lastAccess=e.lastAccess+r*this.S}}consumeRateLimit(e){var t,s=Date.now(),r=String(e),n=this.t[r];return n?this.$(n,s):(n={tokens:this.o,lastAccess:s},this.t[r]=n),n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.i)==null||t.call(this,e)),n.tokens===0)}stop(){this.t={}}},Ge="Mobile",Ur="iOS",Et="Android",Ni="Tablet",Kd=Et+" "+Ni,Wd="iPad",Xd="Apple",Yd=Xd+" Watch",Ts="Safari",Di="BlackBerry",Qd="Samsung",Jd=Qd+"Browser",Zd=Qd+" Internet",Qt="Chrome",Ly=Qt+" OS",eh=Qt+" "+Ur,za="Internet Explorer",th=za+" "+Ge,Ka="Opera",$y=Ka+" Mini",Wa="Edge",ih="Microsoft "+Wa,Ci="Firefox",sh=Ci+" "+Ur,Is="Nintendo",Rs="PlayStation",Pi="Xbox",rh=Et+" "+Ge,nh=Ge+" "+Ts,ps="Windows",Jo=ps+" Phone",Ju="Nokia",Zo="Ouya",oh="Generic",Fy=oh+" "+Ge.toLowerCase(),ah=oh+" "+Ni.toLowerCase(),ea="Konqueror",Ae="(\\d+(\\.\\d+)?)",Co=new RegExp("Version/"+Ae),My=new RegExp(Pi,"i"),Uy=new RegExp(Rs+" \\w+","i"),By=new RegExp(Is+" \\w+","i"),Xa=new RegExp(Di+"|PlayBook|BB10","i"),Vy={"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"},Gy=(i,e)=>e&&M(e,Xd)||(function(t){return M(t,Ts)&&!M(t,Qt)&&!M(t,Et)})(i),lh=function(i,e){return e=e||"",M(i," OPR/")&&M(i,"Mini")?$y:M(i," OPR/")?Ka:Xa.test(i)?Di:M(i,"IE"+Ge)||M(i,"WPDesktop")?th:M(i,Jd)?Zd:M(i,Wa)||M(i,"Edg/")?ih:M(i,"FBIOS")?"Facebook "+Ge:M(i,"UCWEB")||M(i,"UCBrowser")?"UC Browser":M(i,"CriOS")?eh:M(i,"CrMo")||M(i,Qt)?Qt:M(i,Et)&&M(i,Ts)?rh:M(i,"FxiOS")?sh:M(i.toLowerCase(),ea.toLowerCase())?ea:Gy(i,e)?M(i,Ge)?nh:Ts:M(i,Ci)?Ci:M(i,"MSIE")||M(i,"Trident/")?za:M(i,"Gecko")?Ci:""},jy={[th]:[new RegExp("rv:"+Ae)],[ih]:[new RegExp(Wa+"?\\/"+Ae)],[Qt]:[new RegExp("("+Qt+"|CrMo)\\/"+Ae)],[eh]:[new RegExp("CriOS\\/"+Ae)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ae)],[Ts]:[Co],[nh]:[Co],[Ka]:[new RegExp("(Opera|OPR)\\/"+Ae)],[Ci]:[new RegExp(Ci+"\\/"+Ae)],[sh]:[new RegExp("FxiOS\\/"+Ae)],[ea]:[new RegExp("Konqueror[:/]?"+Ae,"i")],[Di]:[new RegExp(Di+" "+Ae),Co],[rh]:[new RegExp("android\\s"+Ae,"i")],[Zd]:[new RegExp(Jd+"\\/"+Ae)],[za]:[new RegExp("(rv:|MSIE )"+Ae)],Mozilla:[new RegExp("rv:"+Ae)]},Hy=function(i,e){var t=lh(i,e),s=jy[t];if(w(s))return null;for(var r=0;r<s.length;r++){var n=s[r],o=i.match(n);if(o)return parseFloat(o[o.length-2])}return null},ed=[[new RegExp(Pi+"; "+Pi+" (.*?)[);]","i"),i=>[Pi,i&&i[1]||""]],[new RegExp(Is,"i"),[Is,""]],[new RegExp(Rs,"i"),[Rs,""]],[Xa,[Di,""]],[new RegExp(ps,"i"),(i,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Jo,""];if(new RegExp(Ge).test(e)&&!/IEMobile\b/.test(e))return[ps+" "+Ge,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var s=t[1],r=Vy[s]||"";return/arm/i.test(e)&&(r="RT"),[ps,r]}return[ps,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,i=>{if(i&&i[3]){var e=[i[3],i[4],i[5]||"0"];return[Ur,e.join(".")]}return[Ur,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,i=>{var e="";return i&&i.length>=3&&(e=w(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/,[Ly,""]],[/Linux|debian/i,["Linux",""]]],td=function(i){return By.test(i)?Is:Uy.test(i)?Rs:My.test(i)?Pi:new RegExp(Zo,"i").test(i)?Zo:new RegExp("("+Jo+"|WPDesktop)","i").test(i)?Jo:/iPad/.test(i)?Wd:/iPod/.test(i)?"iPod Touch":/iPhone/.test(i)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(i)?Yd:Xa.test(i)?Di:/(kobo)\s(ereader|touch)/i.test(i)?"Kobo":new RegExp(Ju,"i").test(i)?Ju:/(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(Ge).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:Kd:new RegExp("(pda|"+Ge+")","i").test(i)?Fy:new RegExp(Ni,"i").test(i)&&!new RegExp(Ni+" pc","i").test(i)?ah:""},qy=i=>i instanceof Error;ta=class{constructor(e,t,s){s===void 0&&(s=[]),this.coercers=e,this.stackParser=t,this.modifiers=s}buildFromUnknown(e,t){t===void 0&&(t={});var s=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(s,t,0).apply(e),n=this.buildParsingContext(t),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,s),$exception_level:"error"}}modifyFrames(e){var t=this;return _t((function*(){for(var s of e)s.stacktrace&&s.stacktrace.frames&&q(s.stacktrace.frames)&&(s.stacktrace.frames=yield t.applyModifiers(s.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 s,r;return e.cause!=null&&(s=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),k({},e,{cause:s,stack:r})}applyChunkIds(e,t){return e.map((s=>(s.filename&&t&&(s.chunk_id=t[s.filename]),s)))}applyCoercers(e,t){for(var s of this.coercers)if(s.match(e))return s.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return _t((function*(){var s=e;for(var r of t.modifiers)s=yield r(s);return s}))()}convertToExceptionList(e,t){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:(s=t.type)!==null&&s!==void 0?s:"generic",handled:(r=t.handled)===null||r===void 0||r,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,k({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:zy(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,s){s===void 0&&(s=0);var r=(n,o)=>{if(o<=4){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(n,a)}};return k({},t,{syntheticException:s==0?t.syntheticException:void 0,mechanism:e,apply:n=>r(n,s),next:n=>r(n,s+1)})}},xi="?";ch=(i,e)=>{var t=i.indexOf("safari-extension")!==-1,s=i.indexOf("safari-web-extension")!==-1;return t||s?[i.indexOf("@")!==-1?i.split("@")[0]:xi,t?"safari-extension:"+e:"safari-web-extension:"+e]:[i,e]},Ky=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Wy=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Xy=/\((\S*)(?::(\d+))(?::(\d+))\)/,Yy=(i,e)=>{var t=Ky.exec(i);if(t){var[,s,r,n]=t;return ia(e,s,xi,+r,+n)}var o=Wy.exec(i);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Xy.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=ch(o[1]||xi,o[2]);return ia(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Qy=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Jy=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Zy=(i,e)=>{var t=Qy.exec(i);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var s=Jy.exec(t[3]);s&&(t[1]=t[1]||"eval",t[3]=s[1],t[4]=s[2],t[5]="")}var r=t[3],n=t[1]||xi;return[n,r]=ch(n,r),ia(e,r,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},id=/\(error: (.*)\)/,sd=50;sa=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var s=he(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:s?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Mr(e,"DOMException")}isDOMError(e){return Mr(e,"DOMError")}},ra=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 s=e.message;return s.error&&typeof s.error.message=="string"?String(s.error.message):String(s)}getStack(e){return e.stacktrace||e.stack||void 0}},na=class{constructor(){}match(e){return Mr(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var s,r=t.apply(e.error);return r||{type:"ErrorEvent",value:e.message,stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}},tb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,oa=class{match(e){return typeof e=="string"}coerce(e,t){var s,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}getInfos(e){var t="Error",s=e,r=e.match(tb);return r&&(t=r[1],s=r[2]),[t,s]}},ib=["fatal","error","warning","log","info","debug"];aa=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var s,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(s=t.syntheticException)==null?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return zd(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 s=this.getObjectClassName(e);return(s&&s!=="Object"?"'"+s+"'":"Object")+" captured as exception with keys: "+uh(e)}isSeverityLevel(e){return he(e)&&!Xo(e)&&ib.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var s=e[t];if(qy(s))return s}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},la=class{match(e){return zd(e)}coerce(e,t){var s,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+uh(e),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}},ca=class{match(e){return Yo(e)}coerce(e,t){var s;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}},ua=class{match(e){return Mr(e,"PromiseRejectionEvent")}coerce(e,t){var s,r=this.getUnhandledRejectionReason(e);return Yo(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){if(Yo(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}},dh=function(i,e){var{debugEnabled:t}=e===void 0?{}:e,s={k:function(r){if(_&&(vt.DEBUG||C.POSTHOG_DEBUG||t)&&!w(_.console)&&_.console){for(var n=("__rrweb_original__"in _.console[r])?_.console[r].__rrweb_original__:_.console[r],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];n(i,...a)}},info:function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];s.k("log",...n)},warn:function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];s.k("warn",...n)},error:function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];s.k("error",...n)},critical:function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];console.error(i,...n)},uninitializedWarning:r=>{s.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>dh(i+" "+r,n)};return s},A=dh("[PostHog.js]"),le=A.createLogger,sb=le("[ExternalScriptsLoader]"),rd=(i,e,t)=>{if(i.config.disable_external_dependency_loading)return sb.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var s=S?.querySelectorAll("script");if(s){for(var r,n=function(){if(s[o].src===e){var l=s[o];return l.__posthog_loading_callback_fired?{v: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<s.length;o++)if(r=n())return r.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),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")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)};C.__PosthogExtensions__=C.__PosthogExtensions__||{},C.__PosthogExtensions__.loadExternalDependency=(i,e,t)=>{var s="/static/"+e+".js?v="+i.version;if(e==="remote-config"&&(s="/array/"+i.config.token+"/config.js"),e==="toolbar"){var r=3e5;s=s+"&t="+Math.floor(Date.now()/r)*r}var n=i.requestRouter.endpointFor("assets",s);rd(i,n,t)},C.__PosthogExtensions__.loadSiteApp=(i,e,t)=>{var s=i.requestRouter.endpointFor("api",e);rd(i,s,t)};Br={};ue=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s<e;s++)t[s-1]=arguments[s];return Lt(t,(function(r){for(var n in r)r[n]!==void 0&&(i[n]=r[n])})),i},Li=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s<e;s++)t[s-1]=arguments[s];return Lt(t,(function(r){Lt(r,(function(n){i.push(n)}))})),i};nd=function(i){try{return i()}catch{return}},rb=function(i){return function(){try{for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return i.apply(this,t)}catch(r){A.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),A.critical(r)}}},Ya=function(i){var e={};return Z(i,(function(t,s){(he(t)&&t.length>0||at(t))&&(e[s]=t)})),e};ob=["herokuapp.com","vercel.app","netlify.app"];gh="$people_distinct_id",vs="__alias",_s="__timers",od="$autocapture_disabled_server_side",da="$heatmaps_enabled_server_side",ad="$exception_capture_enabled_server_side",ha="$error_tracking_suppression_rules",ld="$error_tracking_capture_extension_exceptions",cd="$web_vitals_enabled_server_side",ph="$dead_clicks_enabled_server_side",ud="$product_tours_enabled_server_side",dd="$web_vitals_allowed_metrics",Pr="$session_recording_remote_config",Vr="$sesid",vh="$session_is_sampled",Oi="$enabled_feature_flags",ms="$early_access_features",fa="$feature_flag_details",ys="$stored_person_properties",Yt="$stored_group_properties",ga="$surveys",Gr="$flag_call_reported",pa="$feature_flag_errors",jr="$feature_flag_evaluated_at",rt="$user_state",va="$client_session_props",_a="$capture_rate_limit",ma="$initial_campaign_params",ya="$initial_referrer_info",Hr="$initial_person_info",qr="$epp",_h="__POSTHOG_TOOLBAR__",os="$posthog_cookieless",lb=[gh,vs,"__cmpns",_s,"$session_recording_enabled_server_side",da,Vr,Oi,ha,rt,ms,fa,Yt,ys,ga,Gr,pa,jr,va,_a,ma,ya,qr,Hr];Math.trunc||(Math.trunc=function(i){return i<0?Math.ceil(i):Math.floor(i)}),Number.isInteger||(Number.isInteger=function(i){return at(i)&&isFinite(i)&&Math.floor(i)===i});hd="0123456789abcdef",ba=class i{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,s,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(s)||!Number.isInteger(r)||e<0||t<0||s<0||r<0||e>0xffffffffffff||t>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new i(n)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+hd.charAt(this.bytes[t]>>>4)+hd.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 s=this.bytes[t]-e.bytes[t];if(s!==0)return Math.sign(s)}return 0}},Ea=class{constructor(){this.P=0,this.T=0,this.R=new ka}generate(){var e=this.generateOrAbort();if(w(e)){this.P=0;var t=this.generateOrAbort();if(w(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.P)this.P=e,this.I();else{if(!(e+1e4>this.P))return;this.T++,this.T>4398046511103&&(this.P++,this.I())}return ba.fromFieldsV7(this.P,Math.trunc(this.T/Math.pow(2,30)),this.T&Math.pow(2,30)-1,this.R.nextUint32())}I(){this.T=1024*this.R.nextUint32()+(1023&this.R.nextUint32())}},mh=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};_&&!w(_.crypto)&&crypto.getRandomValues&&(mh=i=>crypto.getRandomValues(i));ka=class{constructor(){this.C=new Uint32Array(8),this.O=1/0}nextUint32(){return this.O>=this.C.length&&(mh(this.C),this.O=0),this.C[this.O++]}},xt=()=>cb().toString(),cb=()=>(fd||(fd=new Ea)).generate(),as="",ub=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;nt={F:()=>!!S,M:function(i){A.error("cookieStore error: "+i)},A:function(i){if(S){try{for(var e=i+"=",t=S.cookie.split(";").filter((n=>n.length)),s=0;s<t.length;s++){for(var r=t[s];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}}catch{}return null}},D:function(i){var e;try{e=JSON.parse(nt.A(i))||{}}catch{}return e},L:function(i,e,t,s,r){if(S)try{var n="",o="",a=db(S.location.hostname,s);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=i+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&A.warn("cookieStore warning: large cookie, len="+c.length),S.cookie=c,c}catch{return}},j:function(i,e){if(S!=null&&S.cookie)try{nt.L(i,"",-1,e)}catch{return}}},No=null,ae={F:function(){if(!Je(No))return No;var i=!0;if(w(_))i=!1;else try{var e="__mplssupport__";ae.L(e,"xyz"),ae.A(e)!=='"xyz"'&&(i=!1),ae.j(e)}catch{i=!1}return i||A.error("localStorage unsupported; falling back to cookie store"),No=i,i},M:function(i){A.error("localStorage error: "+i)},A:function(i){try{return _?.localStorage.getItem(i)}catch(e){ae.M(e)}return null},D:function(i){try{return JSON.parse(ae.A(i))||{}}catch{}return null},L:function(i,e){try{_?.localStorage.setItem(i,JSON.stringify(e))}catch(t){ae.M(t)}},j:function(i){try{_?.localStorage.removeItem(i)}catch(e){ae.M(e)}}},hb=["$device_id","distinct_id",Vr,vh,qr,Hr,rt],Nr={},fb={F:function(){return!0},M:function(i){A.error("memoryStorage error: "+i)},A:function(i){return Nr[i]||null},D:function(i){return Nr[i]||null},L:function(i,e){Nr[i]=e},j:function(i){delete Nr[i]}},Wt=null,ye={F:function(){if(!Je(Wt))return Wt;if(Wt=!0,w(_))Wt=!1;else try{var i="__support__";ye.L(i,"xyz"),ye.A(i)!=='"xyz"'&&(Wt=!1),ye.j(i)}catch{Wt=!1}return Wt},M:function(i){A.error("sessionStorage error: ",i)},A:function(i){try{return _?.sessionStorage.getItem(i)}catch(e){ye.M(e)}return null},D:function(i){try{return JSON.parse(ye.A(i))||null}catch{}return null},L:function(i,e){try{_?.sessionStorage.setItem(i,JSON.stringify(e))}catch(t){ye.M(t)}},j:function(i){try{_?.sessionStorage.removeItem(i)}catch(e){ye.M(e)}}},mt=(function(i){return i[i.PENDING=-1]="PENDING",i[i.DENIED=0]="DENIED",i[i.GRANTED=1]="GRANTED",i})({}),Sa=class{constructor(e){this._instance=e}get N(){return this._instance.config}get consent(){return this.U()?mt.DENIED:this.H}isOptedOut(){return this.N.cookieless_mode==="always"||this.consent===mt.DENIED||this.consent===mt.PENDING&&(this.N.opt_out_capturing_by_default||this.N.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===mt.DENIED}optInOut(e){this.B.L(this.q,e?1:0,this.N.cookie_expiration,this.N.cross_subdomain_cookie,this.N.secure_cookie)}reset(){this.B.j(this.q,this.N.cross_subdomain_cookie)}get q(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:s}=this._instance.config;return s||(t?t+e:"__ph_opt_in_out_"+e)}get H(){var e=this.B.A(this.q);return Oo(e)?mt.GRANTED:M(xy,e)?mt.DENIED:mt.PENDING}get B(){if(!this.V){var e=this.N.opt_out_capturing_persistence_type;this.V=e==="localStorage"?ae:nt;var t=e==="localStorage"?nt:ae;t.A(this.q)&&(this.V.A(this.q)||this.optInOut(Oo(t.A(this.q))),t.j(this.q,this.N.cross_subdomain_cookie))}return this.V}U(){return!!this.N.respect_dnt&&!!hh([Ve?.doNotTrack,Ve?.msDoNotTrack,C.doNotTrack],(e=>Oo(e)))}},Dr=le("[Dead Clicks]"),gb=()=>!0,pb=i=>{var e,t=!((e=i.instance.persistence)==null||!e.get_property(ph)),s=i.instance.config.capture_dead_clicks;return kt(s)?s:!!fe(s)||t},zr=class{get lazyLoadedDeadClicksAutocapture(){return this.W}constructor(e,t,s){this.instance=e,this.isEnabled=t,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[ph]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.G((()=>{this.Y()})):this.stop()}G(e){var t,s;(t=C.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(s=C.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Dr.error("failed to load script",r):e()}))}Y(){var e;if(S){if(!this.W&&(e=C.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=fe(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.W=C.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.W.start(S),Dr.info("starting...")}}else Dr.error("`document` not found. Cannot start.")}stop(){this.W&&(this.W.stop(),this.W=void 0,Dr.info("stopping..."))}},Do=le("[SegmentIntegration]");yh="posthog-js";wa=class{constructor(e,t,s,r,n,o){this.name=yh,this.setupOnce=function(a){a(bh(e,{organization:t,projectId:s,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},Kr=class{constructor(e){this.J=(t,s,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(A.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.K=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.X()}X(){var e;this.Z=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.J)}destroy(){var e;(e=this.Z)==null||e.call(this),this.Z=void 0}doPageView(e,t){var s,r=this.tt(e,t);return this.K={pathname:(s=_?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.tt(e,(t=this.K)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.K)==null?void 0:e.pageViewId}}tt(e,t){var s=this.K;if(!s)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:s.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:h}=n;if(!(w(o)||w(a)||w(l)||w(c)||w(u)||w(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:ot(a/o,0,1,A),f=o<=1?1:ot(l/o,0,1,A),v=c<=1?1:ot(u/c,0,1,A),p=c<=1?1:ot(h/c,0,1,A);r=ue(r,{$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:v,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:p})}}return s.pathname&&(r.$prev_pageview_pathname=s.pathname),s.timestamp&&(r.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),r}},yt=(function(i){return i.GZipJS="gzip-js",i.Base64="base64",i})({}),Wr=i=>{var e=S?.createElement("a");return w(e)?null:(e.href=i,e)},_b=function(i,e){var t,s;e===void 0&&(e="&");var r=[];return Z(i,(function(n,o){w(n)||w(o)||o==="undefined"||(t=encodeURIComponent((a=>a instanceof File)(n)?n.name:n.toString()),s=encodeURIComponent(o),r[r.length]=s+"="+t)})),r.join(e)},Xr=function(i,e){for(var t,s=((i.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var n=s[r].split("=");if(n[0]===e){t=n;break}}if(!q(t)||t.length<2)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{A.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Os=function(i,e,t){if(!i||!e||!e.length)return i;for(var s=i.split("#"),r=s[0]||"",n=s[1],o=r.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],h=0;h<c.length;h++){var g=c[h].split("=");q(g)&&(e.includes(g[0])?u.push(g[0]+"="+t):u.push(c[h]))}var f=l;return a!=null&&(f+="?"+u.join("&")),n!=null&&(f+="#"+n),f},Yr=function(i,e){var t=i.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},xr="https?://(.*)",$i=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],mb=Li(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],$i),Cs="<masked>",yb=["li_fat_id"];De=le("[FeatureFlags]"),ls=le("[FeatureFlags]",{debugEnabled:!0}),kb="errors_while_computing_flags",Sb="flag_missing",wb="quota_limited",Ab="timeout",Tb="connection_error",Ib="unknown_error",Rb=i=>"api_error_"+i,xo="$active_feature_flags",wi="$override_feature_flags",pd="$feature_flag_payloads",cs="$override_feature_flag_payloads",vd="$feature_flag_request_id",_d=i=>{var e={};for(var[t,s]of $r(i||{}))s&&(e[t]=s);return e},Ob=i=>{var e=i.flags;return e?(i.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var s;return[t,(s=e[t].variant)!==null&&s!==void 0?s:e[t].enabled]}))),i.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var s;return(s=e[t].metadata)==null?void 0:s.payload})).map((t=>{var s;return[t,(s=e[t].metadata)==null?void 0:s.payload]})))):De.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),i},Cb=(function(i){return i.FeatureFlags="feature_flags",i.Recordings="recordings",i})({}),Aa=class{constructor(e){this.it=!1,this.et=!1,this.rt=!1,this.st=!1,this.nt=!1,this.ot=!1,this.ut=!1,this.ht=!1,this._instance=e,this.featureFlagEventHandlers=[]}dt(){var e,t;return(e=(t=this._instance.persistence)==null?void 0:t.vt(this._instance.config.feature_flag_cache_ttl_ms))!==null&&e!==void 0&&e}ct(){return!!this.dt()&&(this.ht||this.rt||(this.ht=!0,De.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}ft(){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.ut||(De.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ut=!0),t!=null&&t.length?t.filter((s=>{var r=s&&typeof s=="string"&&s.trim().length>0;return r||De.error("Invalid evaluation context found:",s,"Expected non-empty string"),r})):[]}_t(){return this.ft().length>0}get hasLoadedFlags(){return this.et}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(fa),t=this._instance.get_property(wi),s=this._instance.get_property(cs);if(!s&&!t)return e||{};var r=ue({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(var o of n){var a,l,c=r[o],u=t?.[o],h=w(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,g=w(u)?c.variant:typeof u=="string"?u:void 0,f=s?.[o],v=k({},c,{enabled:h,variant:h?g??c?.variant:void 0});h!==c?.enabled&&(v.original_enabled=c?.enabled),g!==c?.variant&&(v.original_variant=c?.variant),f&&(v.metadata=k({},c?.metadata,{payload:f,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),r[o]=v}return this.it||(De.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:r}),this.it=!0),r}getFlagVariants(){var e=this._instance.get_property(Oi),t=this._instance.get_property(wi);if(!t)return e||{};for(var s=ue({},e),r=Object.keys(t),n=0;n<r.length;n++)s[r[n]]=t[r[n]];return this.it||(De.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:s}),this.it=!0),s}getFlagPayloads(){var e=this._instance.get_property(pd),t=this._instance.get_property(cs);if(!t)return e||{};for(var s=ue({},e||{}),r=Object.keys(t),n=0;n<r.length;n++)s[r[n]]=t[r[n]];return this.it||(De.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:s}),this.it=!0),s}reloadFeatureFlags(){this.st||this._instance.config.advanced_disable_feature_flags||this.bt||(this._instance.yt.emit("featureFlagsReloading",!0),this.bt=setTimeout((()=>{this.wt()}),5))}Et(){clearTimeout(this.bt),this.bt=void 0}ensureFlagsLoaded(){this.et||this.rt||this.bt||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.st=e}wt(e){var t;if(this.Et(),!this._instance.xt())if(this.rt)this.nt=!0;else{var s=this._instance.config.token,r=this._instance.get_property("$device_id"),n={token:s,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:k({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(ys)||{}),group_properties:this._instance.get_property(Yt),timezone:Ih()};Je(r)||w(r)||(n.$device_id=r),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this._t()&&(n.evaluation_contexts=this.ft());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.rt=!0,this._instance._send_request({method:"POST",url:a,data:n,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.nt||(this.$anon_distinct_id=void 0),g=!1),this.rt=!1,!n.disable_flags||this.nt){this.ot=!g;var f=[];l.error?l.error instanceof Error?f.push(l.error.name==="AbortError"?Ab:Tb):f.push(Ib):l.statusCode!==200&&f.push(Rb(l.statusCode)),(c=l.json)!=null&&c.errorsWhileComputingFlags&&f.push(kb);var v=!((u=l.json)==null||(u=u.quotaLimited)==null||!u.includes(Cb.FeatureFlags));if(v&&f.push(wb),(h=this._instance.persistence)==null||h.register({[pa]:f}),v)De.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 p;n.disable_flags||this.receivedFeatureFlags((p=l.json)!==null&&p!==void 0?p:{},g),this.nt&&(this.nt=!1,this.wt())}}}})}}getFeatureFlag(e,t){var s;if(t===void 0&&(t={}),!t.fresh||this.ot)if(this.et||this.getFlags()&&this.getFlags().length>0){if(!this.ct()){var r=this.getFeatureFlagResult(e,t);return(s=r?.variant)!==null&&s!==void 0?s:r?.enabled}}else De.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.ot)if(this.et||this.getFlags()&&this.getFlags().length>0){if(!this.ct()){var s=this.getFlagVariants(),r=e in s,n=s[e],o=this.getFlagPayloads()[e],a=String(n),l=this._instance.get_property(vd)||void 0,c=this._instance.get_property(jr)||void 0,u=this._instance.get_property(Gr)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var h,g,f,v,p,m,E,b,O,P;q(u[e])?u[e].push(a):u[e]=[a],(h=this._instance.persistence)==null||h.register({[Gr]:u});var I=this.getFeatureFlagDetails(e),z=[...(g=this._instance.get_property(pa))!==null&&g!==void 0?g:[]];w(n)&&z.push(Sb);var B={$feature_flag:e,$feature_flag_response:n,$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:((v=this._instance.config.bootstrap)==null||(v=v.featureFlagPayloads)==null?void 0:v[e])||null,$used_bootstrap_value:!this.ot};w(I==null||(p=I.metadata)==null?void 0:p.version)||(B.$feature_flag_version=I.metadata.version);var N,ve=(m=I==null||(E=I.reason)==null?void 0:E.description)!==null&&m!==void 0?m:I==null||(b=I.reason)==null?void 0:b.code;ve&&(B.$feature_flag_reason=ve),I!=null&&(O=I.metadata)!=null&&O.id&&(B.$feature_flag_id=I.metadata.id),w(I?.original_variant)&&w(I?.original_enabled)||(B.$feature_flag_original_response=w(I.original_variant)?I.original_enabled:I.original_variant),I!=null&&(P=I.metadata)!=null&&P.original_payload&&(B.$feature_flag_original_payload=I==null||(N=I.metadata)==null?void 0:N.original_payload),z.length&&(B.$feature_flag_error=z.join(",")),this._instance.capture("$feature_flag_called",B)}if(r){var _e=o;if(!w(o))try{_e=JSON.parse(o)}catch{}return{key:e,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:_e}}}}else De.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var s=this._instance.config.token,r={distinct_id:this._instance.get_distinct_id(),token:s};this._t()&&(r.evaluation_contexts=this.ft()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this._instance.config.disable_compression?void 0:yt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:n=>{var o,a=(o=n.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.ot){if(this.et||this.getFlags()&&this.getFlags().length>0){var s=this.getFeatureFlag(e,t);return w(s)?void 0:!!s}De.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.et=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var h=Ob(o),g=h.flags,f=h.featureFlags,v=h.featureFlagPayloads;if(f){var p=o.requestId,m=o.evaluatedAt;if(q(f)){De.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({[xo]:f,[Oi]:E})}else{var O=f,P=v,I=g;if(o.errorsWhileComputingFlags)if(g){var z=new Set(Object.keys(g).filter((B=>{var N;return!((N=g[B])!=null&&N.failed)})));O=k({},l,Object.fromEntries(Object.entries(O).filter((B=>{var[N]=B;return z.has(N)})))),P=k({},c,Object.fromEntries(Object.entries(P||{}).filter((B=>{var[N]=B;return z.has(N)})))),I=k({},u,Object.fromEntries(Object.entries(I||{}).filter((B=>{var[N]=B;return z.has(N)}))))}else O=k({},l,O),P=k({},c,P),I=k({},u,I);a&&a.register(k({[xo]:Object.keys(_d(O)),[Oi]:O||{},[pd]:P||{},[fa]:I||{}},p?{[vd]:p}:{},m?{[jr]:m}:{}))}}})(e,this._instance.persistence,s,r,n),t||(this.ht=!1),this.St(t)}}override(e,t){t===void 0&&(t=!1),De.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return De.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(wi),this._instance.persistence.unregister(cs),this.St(),ls.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,s=e;if(this.it=!!((t=s.suppressWarning)!==null&&t!==void 0&&t),"flags"in s){if(s.flags===!1)this._instance.persistence.unregister(wi),ls.info("Flag overrides cleared");else if(s.flags){if(q(s.flags)){for(var r={},n=0;n<s.flags.length;n++)r[s.flags[n]]=!0;this._instance.persistence.register({[wi]:r})}else this._instance.persistence.register({[wi]:s.flags});ls.info("Flag overrides set",{flags:s.flags})}}return"payloads"in s&&(s.payloads===!1?(this._instance.persistence.unregister(cs),ls.info("Payload overrides cleared")):s.payloads&&(this._instance.persistence.register({[cs]:s.payloads}),ls.info("Payload overrides set",{payloads:s.payloads}))),void this.St()}this.St()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.et){var{flags:t,flagVariants:s}=this.$t();e(t,s)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var r,n=(this._instance.get_property(ms)||[]).find((c=>c.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),s&&(a.$feature_enrollment_stage=s),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=k({},this.getFlagVariants(),{[e]:t});(r=this._instance.persistence)==null||r.register({[xo]:Object.keys(_d(l)),[Oi]:l}),this.St()}getEarlyAccessFeatures(e,t,s){t===void 0&&(t=!1);var r=this._instance.get_property(ms),n=s?"&"+s.map((o=>"stage="+o)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+n),method:"GET",callback:o=>{var a,l;if(o.json){var c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(ms),(l=this._instance.persistence)==null||l.register({[ms]:c}),e(c)}}})}$t(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((s=>t[s])),flagVariants:Object.keys(t).filter((s=>t[s])).reduce(((s,r)=>(s[r]=t[r],s)),{})}}St(e){var{flags:t,flagVariants:s}=this.$t();this.featureFlagEventHandlers.forEach((r=>r(t,s,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var s=this._instance.get_property(ys)||{};this._instance.register({[ys]:k({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(ys)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var s=this._instance.get_property(Yt)||{};Object.keys(s).length!==0&&Object.keys(s).forEach((r=>{s[r]=k({},s[r],e[r]),delete e[r]})),this._instance.register({[Yt]:k({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Yt)||{};this._instance.register({[Yt]:k({},t,{[e]:{}})})}else this._instance.unregister(Yt)}reset(){this.et=!1,this.rt=!1,this.st=!1,this.nt=!1,this.ot=!1,this.$anon_distinct_id=void 0,this.Et(),this.it=!1}},Pb=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ss=class{constructor(e,t){this.N=e,this.props={},this.kt=!1,this.Pt=(s=>{var r="";return s.token&&(r=s.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),s.persistence_name?"ph_"+s.persistence_name:"ph_"+r+"_posthog"})(e),this.B=this.Tt(e),this.load(),e.debug&&A.info("Persistence loaded",e.persistence,k({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Rt}Tt(e){Pb.indexOf(e.persistence.toLowerCase())===-1&&(A.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(r){r===void 0&&(r=[]);var n=[...hb,...r];return k({},ae,{D:function(o){try{var a={};try{a=nt.D(o)||{}}catch{}var l=ue(a,JSON.parse(ae.A(o)||"{}"));return ae.L(o,l),l}catch{}return null},L:function(o,a,l,c,u,h){try{ae.L(o,a,void 0,void 0,h);var g={};n.forEach((f=>{a[f]&&(g[f]=a[f])})),Object.keys(g).length&&nt.L(o,g,l,c,u,h)}catch(f){ae.M(f)}},j:function(o,a){try{_?.localStorage.removeItem(o),nt.j(o,a)}catch(l){ae.M(l)}}})})(e.cookie_persisted_properties||[]),s=e.persistence.toLowerCase();return s==="localstorage"&&ae.F()?ae:s==="localstorage+cookie"&&t.F()?t:s==="sessionstorage"&&ye.F()?ye:s==="memory"?fb:s==="cookie"?nt:t.F()?t:nt}vt(e){var t=e??this.N.feature_flag_cache_ttl_ms;if(!t||t<=0)return!1;var s=this.props[jr];return!s||typeof s!="number"||Date.now()-s>t}properties(){var e={};return Z(this.props,((t,s)=>{if(s===Oi&&fe(t)){if(!this.vt())for(var r=Object.keys(t),n=0;n<r.length;n++)e["$feature/"+r[n]]=t[r[n]]}else a=s,l=!1,(Je(o=lb)?l:Wu&&o.indexOf===Wu?o.indexOf(a)!=-1:(Z(o,(function(c){if(l||(l=c===a))return Br})),l))||(e[s]=t);var o,a,l})),e}load(){if(!this.Rt){var e=this.B.D(this.Pt);e&&(this.props=ue({},e))}}save(){this.Rt||this.B.L(this.Pt,this.props,this.It,this.Ct,this.Ot,this.N.debug)}remove(){this.B.j(this.Pt,!1),this.B.j(this.Pt,!0)}clear(){this.remove(),this.props={}}register_once(e,t,s){if(fe(e)){w(t)&&(t="None"),this.It=w(s)?this.Ft:s;var r=!1;if(Z(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=n,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(fe(e)){this.It=w(t)?this.Ft:t;var s=!1;if(Z(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.props[n]=r,s=!0)})),s)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.kt){var e=Eh(this.N.custom_campaign_params,this.N.mask_personal_data_properties,this.N.custom_personal_data_properties);Ri(Ya(e))||this.register(e),this.kt=!0}}update_search_keyword(){var e;this.register((e=S?.referrer)?Sh(e):{})}update_referrer_info(){var e;this.register_once({$referrer:wh(),$referring_domain:S!=null&&S.referrer&&((e=Wr(S.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[ma]||this.props[ya]||this.register_once({[Hr]:Ah(this.N.mask_personal_data_properties,this.N.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Z([ya,ma],(o=>{var a=this.props[o];a&&Z(a,(function(l,c){e["$initial_"+Wo(c)]=l}))}));var t,s,r=this.props[Hr];if(r){var n=(t=Th(r),s={},Z(t,(function(o,a){s["$initial_"+Wo(a)]=o})),s);ue(e,n)}return e}safe_merge(e){return Z(this.props,(function(t,s){s in e||(e[s]=t)})),e}update_config(e,t,s){if(this.Ft=this.It=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==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 r=this.Tt(e),n=this.props;this.clear(),this.B=r,this.props=n,this.save()}}set_disabled(e){this.Rt=e,this.Rt?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ct&&(this.Ct=e,this.remove(),this.save())}set_secure(e){e!==this.Ot&&(this.Ot=e,this.remove(),this.save())}set_event_timer(e,t){var s=this.props[_s]||{};s[e]=t,this.props[_s]=s,this.save()}remove_event_timer(e){var t=(this.props[_s]||{})[e];return w(t)||(delete this.props[_s][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},us={Activation:"events",Cancellation:"cancelEvents"},Lo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},bs={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},$o={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},Ta={Popover:"popover",Inline:"inline"},Nb=(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})({}),md=(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.TOUR_LAST_SEEN_DATE="$product_tour_last_seen_date",i.TOUR_TYPE="$product_tour_type",i})({}),yd=le("[RateLimiter]"),Ia=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var s=t.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach((r=>{yd.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void yd.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:s})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,s,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(s=this.instance.persistence)==null?void 0:s.get_property(_a))!==null&&t!==void 0?t:{tokens:n,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>n&&(l.tokens=n);var c=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 "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(r=this.instance.persistence)==null||r.set_property(_a,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ds=le("[RemoteConfig]"),Qr=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=C._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Mt(e){var t,s;(t=C.__PosthogExtensions__)!=null&&t.loadExternalDependency?(s=C.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}At(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 ds.info("Using preloaded remote config",this.remoteConfig),this.Dt(this.remoteConfig),void this.Lt();if(this._instance.xt())return void ds.warn("Remote config is disabled. Falling back to local config.");this.Mt((e=>{if(!e)return ds.info("No config found after loading remote JS config. Falling back to JSON."),void this.At((t=>{this.Dt(t),this.Lt()}));this.Dt(e),this.Lt()}))}catch(e){ds.error("Error loading remote config",e)}}stop(){this.jt&&(clearInterval(this.jt),this.jt=void 0)}refresh(){this._instance.xt()||S?.visibilityState==="hidden"||this._instance.featureFlags.reloadFeatureFlags()}Lt(){var e;if(!this.jt){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.jt=setInterval((()=>{this.refresh()}),t))}}Dt(e){e||ds.error("Failed to fetch remote config from PostHog."),this._instance.Dt(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||this._instance.featureFlags.ensureFlagsLoaded())}},We=Uint8Array,Te=Uint16Array,Fi=Uint32Array,Qa=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]),Ja=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]),bd=new We([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Rh=function(i,e){for(var t=new Te(31),s=0;s<31;++s)t[s]=e+=1<<i[s-1];var r=new Fi(t[30]);for(s=1;s<30;++s)for(var n=t[s];n<t[s+1];++n)r[n]=n-t[s]<<5|s;return[t,r]},Oh=Rh(Qa,2),Db=Oh[0],Ra=Oh[1];Db[28]=258,Ra[258]=28;for(Oa=Rh(Ja,0)[1],Jr=new Te(32768),ee=0;ee<32768;++ee)Ct=(43690&ee)>>>1|(21845&ee)<<1,Ct=(61680&(Ct=(52428&Ct)>>>2|(13107&Ct)<<2))>>>4|(3855&Ct)<<4,Jr[ee]=((65280&Ct)>>>8|(255&Ct)<<8)>>>1;ws=function(i,e,t){for(var s=i.length,r=0,n=new Te(e);r<s;++r)++n[i[r]-1];var o,a=new Te(e);for(r=0;r<e;++r)a[r]=a[r-1]+n[r-1]<<1;if(t){o=new Te(1<<e);var l=15-e;for(r=0;r<s;++r)if(i[r])for(var c=r<<4|i[r],u=e-i[r],h=a[i[r]-1]++<<u,g=h|(1<<u)-1;h<=g;++h)o[Jr[h]>>>l]=c}else for(o=new Te(s),r=0;r<s;++r)o[r]=Jr[a[i[r]-1]++]>>>15-i[r];return o},Jt=new We(288);for(ee=0;ee<144;++ee)Jt[ee]=8;for(ee=144;ee<256;++ee)Jt[ee]=9;for(ee=256;ee<280;++ee)Jt[ee]=7;for(ee=280;ee<288;++ee)Jt[ee]=8;Zr=new We(32);for(ee=0;ee<32;++ee)Zr[ee]=5;xb=ws(Jt,9,0),Lb=ws(Zr,5,0),Ch=function(i){return(i/8>>0)+(7&i&&1)},Ph=function(i,e,t){(t==null||t>i.length)&&(t=i.length);var s=new(i instanceof Te?Te:i instanceof Fi?Fi:We)(t-e);return s.set(i.subarray(e,t)),s},pt=function(i,e,t){t<<=7&e;var s=e/8>>0;i[s]|=t,i[s+1]|=t>>>8},hs=function(i,e,t){t<<=7&e;var s=e/8>>0;i[s]|=t,i[s+1]|=t>>>8,i[s+2]|=t>>>16},Fo=function(i,e){for(var t=[],s=0;s<i.length;++s)i[s]&&t.push({s,f:i[s]});var r=t.length,n=t.slice();if(!r)return[new We(0),0];if(r==1){var o=new We(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(I,z){return I.f-z.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!=r-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=n[0].s;for(s=1;s<r;++s)n[s].s>g&&(g=n[s].s);var f=new Te(g+1),v=Ca(t[u-1],f,0);if(v>e){s=0;var p=0,m=v-e,E=1<<m;for(n.sort((function(I,z){return f[z.s]-f[I.s]||I.f-z.f}));s<r;++s){var b=n[s].s;if(!(f[b]>e))break;p+=E-(1<<v-f[b]),f[b]=e}for(p>>>=m;p>0;){var O=n[s].s;f[O]<e?p-=1<<e-f[O]++-1:++s}for(;s>=0&&p;--s){var P=n[s].s;f[P]==e&&(--f[P],++p)}v=e}return[new We(f),v]},Ca=function(i,e,t){return i.s==-1?Math.max(Ca(i.l,e,t+1),Ca(i.r,e,t+1)):e[i.s]=t},Ed=function(i){for(var e=i.length;e&&!i[--e];);for(var t=new Te(++e),s=0,r=i[0],n=1,o=function(l){t[s++]=l},a=1;a<=e;++a)if(i[a]==r&&a!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=i[a]}return[t.subarray(0,s),e]},fs=function(i,e){for(var t=0,s=0;s<e.length;++s)t+=i[s]*e[s];return t},Pa=function(i,e,t){var s=t.length,r=Ch(e+2);i[r]=255&s,i[r+1]=s>>>8,i[r+2]=255^i[r],i[r+3]=255^i[r+1];for(var n=0;n<s;++n)i[r+n+4]=t[n];return 8*(r+4+s)},kd=function(i,e,t,s,r,n,o,a,l,c,u){pt(e,u++,t),++r[256];for(var h=Fo(r,15),g=h[0],f=h[1],v=Fo(n,15),p=v[0],m=v[1],E=Ed(g),b=E[0],O=E[1],P=Ed(p),I=P[0],z=P[1],B=new Te(19),N=0;N<b.length;++N)B[31&b[N]]++;for(N=0;N<I.length;++N)B[31&I[N]]++;for(var ve=Fo(B,7),_e=ve[0],Le=ve[1],$e=19;$e>4&&!_e[bd[$e-1]];--$e);var je,T,x,F,L=c+5<<3,ge=fs(r,Jt)+fs(n,Zr)+o,H=fs(r,g)+fs(n,p)+o+14+3*$e+fs(B,_e)+(2*B[16]+3*B[17]+7*B[18]);if(L<=ge&&L<=H)return Pa(e,u,i.subarray(l,l+c));if(pt(e,u,1+(H<ge)),u+=2,H<ge){je=ws(g,f,0),T=g,x=ws(p,m,0),F=p;var K=ws(_e,Le,0);for(pt(e,u,O-257),pt(e,u+5,z-1),pt(e,u+10,$e-4),u+=14,N=0;N<$e;++N)pt(e,u+3*N,_e[bd[N]]);u+=3*$e;for(var J=[b,I],V=0;V<2;++V){var se=J[V];for(N=0;N<se.length;++N){var D=31&se[N];pt(e,u,K[D]),u+=_e[D],D>15&&(pt(e,u,se[N]>>>5&127),u+=se[N]>>>12)}}}else je=xb,T=Jt,x=Lb,F=Zr;for(N=0;N<a;++N)if(s[N]>255){D=s[N]>>>18&31,hs(e,u,je[D+257]),u+=T[D+257],D>7&&(pt(e,u,s[N]>>>23&31),u+=Qa[D]);var Ie=31&s[N];hs(e,u,x[Ie]),u+=F[Ie],Ie>3&&(hs(e,u,s[N]>>>5&8191),u+=Ja[Ie])}else hs(e,u,je[s[N]]),u+=T[s[N]];return hs(e,u,je[256]),u+T[256]},$b=new Fi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Fb=(function(){for(var i=new Fi(256),e=0;e<256;++e){for(var t=e,s=9;--s;)t=(1&t&&3988292384)^t>>>1;i[e]=t}return i})(),Mb=function(i,e,t,s,r){return(function(n,o,a,l,c,u){var h=n.length,g=new We(l+h+5*(1+Math.floor(h/7e3))+c),f=g.subarray(l,g.length-c),v=0;if(!o||h<8)for(var p=0;p<=h;p+=65535){var m=p+65535;m<h?v=Pa(f,v,n.subarray(p,m)):(f[p]=u,v=Pa(f,v,n.subarray(p,h)))}else{for(var E=$b[o-1],b=E>>>13,O=8191&E,P=(1<<a)-1,I=new Te(32768),z=new Te(P+1),B=Math.ceil(a/3),N=2*B,ve=function(wt){return(n[wt]^n[wt+1]<<B^n[wt+2]<<N)&P},_e=new Fi(25e3),Le=new Te(288),$e=new Te(32),je=0,T=0,x=(p=0,0),F=0,L=0;p<h;++p){var ge=ve(p),H=32767&p,K=z[ge];if(I[H]=K,z[ge]=H,F<=p){var J=h-p;if((je>7e3||x>24576)&&J>423){v=kd(n,f,0,_e,Le,$e,T,x,L,p-L,v),x=je=T=0,L=p;for(var V=0;V<286;++V)Le[V]=0;for(V=0;V<30;++V)$e[V]=0}var se=2,D=0,Ie=O,Fe=H-K&32767;if(J>2&&ge==ve(p-Fe))for(var ei=Math.min(b,J)-1,xs=Math.min(32767,p),Ui=Math.min(258,J);Fe<=xs&&--Ie&&H!=K;){if(n[p+se]==n[p+se-Fe]){for(var Me=0;Me<Ui&&n[p+Me]==n[p+Me-Fe];++Me);if(Me>se){if(se=Me,D=Fe,Me>ei)break;var Bi=Math.min(Fe,Me-2),ti=0;for(V=0;V<Bi;++V){var Ft=p-Fe+V+32768&32767,ii=Ft-I[Ft]+32768&32767;ii>ti&&(ti=ii,K=Ft)}}}Fe+=(H=K)-(K=I[H])+32768&32767}if(D){_e[x++]=268435456|Ra[se]<<18|Oa[D];var si=31&Ra[se],ri=31&Oa[D];T+=Qa[si]+Ja[ri],++Le[257+si],++$e[ri],F=p+se,++je}else _e[x++]=n[p],++Le[n[p]]}}v=kd(n,f,u,_e,Le,$e,T,x,L,p-L,v)}return Ph(g,0,l+Ch(v)+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,s,!0)},Mo=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};Bb=function(i){var e,t,s,r,n="";for(e=t=0,s=(i=(i+"").replace(/\r\n/g,`
7
+ `).length?this.parseOpera9(l):l.stack?this.parseOpera11(l):this.parseOpera10(l)},parseOpera9:function(l){for(var u=/Line (\d+).*script (?:in )?(\S+)/i,c=l.message.split(`
8
+ `),h=[],g=2,f=c.length;g<f;g+=2){var v=u.exec(c[g]);v&&h.push(new s({fileName:v[2],lineNumber:v[1],source:c[g]}))}return h},parseOpera10:function(l){for(var u=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,c=l.stacktrace.split(`
9
+ `),h=[],g=0,f=c.length;g<f;g+=2){var v=u.exec(c[g]);v&&h.push(new s({functionName:v[3]||void 0,fileName:v[2],lineNumber:v[1],source:c[g]}))}return h},parseOpera11:function(l){var u=l.stack.split(`
10
+ `).filter(function(c){return!!c.match(r)&&!c.match(/^Error created at/)},this);return u.map(function(c){var h=c.split("@"),g=this.extractLocation(h.pop()),f=h.shift()||"",v=f.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,p;f.match(/\(([^)]*)\)/)&&(p=f.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var m=p===void 0||p==="[arguments not available]"?void 0:p.split(",");return new s({functionName:v,args:m,fileName:g[0],lineNumber:g[1],columnNumber:g[2],source:c})},this)}}})})(qs)),qs.exports}function wl(i,e,t,s){return{errorClass:Sl(i),message:`${t}${Sl(e)}`,type:"browserjs",stacktrace:s.reduce((r,n)=>{let o=tv(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function wc(i,e){let t=Object.assign(i,e);for(let s of Object.keys(t))typeof t[s]=="object"&&typeof e[s]=="object"&&(t[s]=wc(t[s],e[s]));return t}async function Uv(i){let e=Fv[i];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((t,s)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=Mv();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}t(e.lib)}).catch(s)})})}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 Uv(i).then(t=>t.get(e).then(s=>s()))}function v_(){return Pl||(Pl=1,(function(i,e){(function(t,s){i.exports=s()})(p_,function(){function t(f){return f=JSON.stringify(f),!!/^\{[\s\S]*\}$/.test(f)}function s(f){return f===void 0||typeof f=="function"?f+"":JSON.stringify(f)}function r(f){if(typeof f=="string")try{return JSON.parse(f)}catch{return f}}function n(f){return{}.toString.call(f)==="[object Function]"}function o(f){return Object.prototype.toString.call(f)==="[object Array]"}function a(f){var v="_Is_Incognit",p="yes";try{f||(f=window.localStorage),f.setItem(v,p),f.removeItem(v)}catch{var m={};m._data={},m.setItem=function(T,x){return m._data[T]=String(x)},m.getItem=function(T){return m._data.hasOwnProperty(T)?m._data[T]:void 0},m.removeItem=function(T){return delete m._data[T]},m.clear=function(){return m._data={}},f=m}finally{f.getItem(v)===p&&f.removeItem(v)}return f}var l=a();function u(){if(!(this instanceof u))return new u}u.prototype={set:function(v,p){if(v&&!t(v))l.setItem(v,s(p));else if(t(v))for(var m in v)this.set(m,v[m]);return this},get:function(v){if(v===void 0){var p={};return this.forEach(function(M,F){return p[M]=F}),p}if(v.charAt(0)==="?")return this.has(v.substr(1));var m=arguments;if(m.length>1){for(var E={},T=0,x=m.length;T<x;T++){var R=r(l.getItem(m[T]));this.has(m[T])&&(E[m[T]]=R)}return E}return r(l.getItem(v))},clear:function(){return l.clear(),this},remove:function(v){var p=this.get(v);return l.removeItem(v),p},has:function(v){return{}.hasOwnProperty.call(this.get(),v)},keys:function(){var v=[];return this.forEach(function(p){v.push(p)}),v},forEach:function(v){for(var p=0,m=l.length;p<m;p++){var E=l.key(p);v(E,this.get(E))}return this},search:function(v){for(var p=this.keys(),m={},E=0,T=p.length;E<T;E++)p[E].indexOf(v)>-1&&(m[p[E]]=this.get(p[E]));return m},len:function(){return l.length}};var c=null;function h(f,v){var p=arguments,m=null;if(c||(c=u()),p.length===0)return c.get();if(p.length===1){if(typeof f=="string")return c.get(f);if(t(f))return c.set(f)}if(p.length===2&&typeof f=="string"){if(!v)return c.remove(f);if(v&&typeof v=="string")return c.set(f,v);v&&n(v)&&(m=null,m=v(f,c.get(f)),h.set(f,m))}if(p.length===2&&o(f)&&n(v))for(var E=0,T=f.length;E<T;E++)m=v(f[E],c.get(f[E])),h.set(f[E],m);return h}for(var g in u.prototype)h[g]=u.prototype[g];return h})})(Ws)),Ws.exports}var lg,cg,gg,G,pg,vg,_g,mg,jl,I,te,Ne,_e,Je,yg,Y,ci,bg,Zn,Eg,Sn,kg,Sg,wg,ie,Ag,pe,ht,ji,Ys,lt,Ze,eo,Tg,ol,Js,Ig,Rg,Qs,to,Hl,ql,zl,fn,io,wn,qe,Kl,Vi,Ut,Hi,ni,Og,pn,Cg,Pg,Ng,Ms,al,Vs,Tt,vn,Gt,Gs,Us,$g,sr,Fg,Wl,Mg,Xl,Ug,D,Bg,ll,Vg,Gg,jg,Hg,qg,zg,Kg,Yl,Wg,Ye,Xg,Jl,j,js,rr,so,ce,cl,Wi,Yg,Ql,Jg,ul,Qg,Zg,zi,ef,tf,sf,dl,rf,hl,nf,of,gl,An,fl,af,lf,Zl,Xi,ec,pl,uf,df,hf,gf,ff,pf,vf,_f,mf,yf,Zs,bf,K,Ki,It,Tn,er,In,Bs,vl,ac,kf,Sf,wf,Rn,gt,ct,lc,On,_l,Af,Tf,If,Rf,Of,Cf,Pf,Nf,ml,Df,xf,Lf,$f,Ff,Mf,Uf,yl,Bf,Vf,cc,Gf,jf,Hf,qf,zf,Kf,Wf,bl,Xf,Yf,Jf,Qf,Zf,ep,tp,ip,sp,rp,np,op,ap,lp,cp,up,dp,hp,gp,fp,pp,vp,_p,mp,yp,bp,Ep,uc,or,dc,kp,Yi,ar,no,hc,gc,fc,Bt,Sp,Cn,Hs,wp,Ap,Tp,Ip,Rp,Op,X,_n,Cp,Pp,Np,Dp,xp,Lp,$p,Fp,Mp,Up,Bp,Vp,Gp,jp,Hp,qp,zp,Kp,d,qs,zs,Wp,El,Yp,kl,Qp,Zp,vc,ev,tv,Sl,_c,iv,Al,Ks,sv,rv,nv,ov,av,lv,cv,uv,Tl,Il,Pn,mc,dv,hv,gv,fv,pv,vv,_v,yc,mv,yv,bv,Ev,kv,Sv,wv,Av,Tv,Iv,bc,Ec,Rv,Ov,Cv,Pv,Nn,kc,Dn,Nv,Dv,xv,Rl,Lv,Sc,$v,Fv,Mv,Bv,Vv,Ac,Gv,jv,mn,Hv,xn,Pe,Me,He,et,jt,qv,zv,Kv,Wv,Xv,Yv,Jv,Qv,Zv,e_,t_,i_,oi,s_,Tc,Ic,r_,Rc,Oc,ai,Ol,Cl,n_,o_,Ln,a_,ut,l_,c_,u_,d_,h_,g_,f_,$n,tr,Ws,p_,Pl,__,Mt,Cc,li,Fn,oo,Mn,ao,Un,lo,Xe,m_,y_,b_,E_,k_,Bn,S_,Vn,w_,A_,Pc,T_,I_,R_,ui,Gn,Nc,O_,C_,P_,di,yn,bn,N_,D_,x_,Nl,L_,Dc,$_,F_,M_,U_,B_,V_,G_,j_,H_,xc,q_,z_,jn,K_,Lc,W_,X_,Y_,$c,J_,Q_,Hn,Z_,em,tm,im,Dl,sm,xl,rm,Ll,qn,nm,om,$l,En,Fc,am,ir,Fl,Mc,Ml,lm,cm,um,dm,hm,qi,zn,gm,fm,pm,kn,vm,_m,mm,ym,bm,Gi,Kn,Wn,Xn,Em,km,Sm,Ul,Bl,wm,Am,Tm,Im,Xs,Yn,Vl,Rm,Om,Jn,Vt,hi,co=Re(()=>{"use strict";lg=dt(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});cg=Number.isInteger||function(e){return e<<0===e};gg=(function(){function i(){this.map={},this.length=0}return i.prototype.set=function(e,t){var s=this.hash(e),r=this.map[s];r||(this.map[s]=r=[]),r.push([e,t]),this.length+=1},i.prototype.hash=function(e){var t=[];for(var s in e)t.push(Object.prototype.toString.call(e[s]));return t.join()},i.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var o=this.map[t],s=0;s<o.length;s+=1){var r=o[s];if(r[0]===e)return r[1]}return}var n=this.hash(e),o=this.map[n];if(o)for(var s=0;s<o.length;s+=1){var r=o[s];if(r[0]===e)return r[1]}},i})(),G=dt(function(e){return e!=null&&typeof e.clone=="function"?e.clone():Gl(e)});pg=Qn(function(e,t,s){var r={},n;t=t||{},s=s||{};for(n in t)Fs(n,t)&&(r[n]=Fs(n,s)?e(n,t[n],s[n]):t[n]);for(n in s)Fs(n,s)&&!Fs(n,r)&&(r[n]=s[n]);return r}),vg=Qn(function i(e,t,s){return pg(function(r,n,o){return nl(n)&&nl(o)?i(e,n,o):e(r,n,o)},t,s)}),_g=Qn(function(e,t,s){return vg(function(r,n,o){return e(n,o)},t,s)}),mg=At(fg),jl=At(function(e,t){var s={};for(var r in t)e(t[r],r,t)&&(s[r]=t[r]);return s}),I=i=>typeof i=="function"&&!!(i.constructor&&i.call&&i.apply),te=i=>typeof i=="string",Ne=i=>i===null,_e=i=>typeof i>"u",Je=i=>Ne(i)||_e(i),yg=i=>typeof i=="bigint",Y=i=>!_e(i),ci=i=>!Je(i),bg=i=>ci(i)&&i!=="",Zn=i=>{switch(Object.prototype.toString.call(i)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return i instanceof Error}},Eg=i=>typeof i=="boolean",Sn=(i,e)=>{let t=e.split(".");return mg(t,i)},kg=(i,e)=>!!Sn(i,e),Sg=i=>typeof i=="object",wg=i=>!Ne(i)&&Sg(i)&&!Array.isArray(i),ie=i=>!Ne(i)&&Object.prototype.toString.call(i)==="[object Object]",Ag=(i,e)=>{if(!Array.isArray(i)||!Array.isArray(e))return G(e);let t=G(i);return e.forEach((s,r)=>{t[r]=Array.isArray(s)||wg(s)?pe(t[r],s):s}),t},pe=(i,e)=>_g(Ag,i,e),ht=i=>ie(i)&&Object.keys(i).length>0,ji=i=>{let e=jl(Y,i);return Object.keys(e).forEach(t=>{let s=e[t];ie(s)&&(e[t]=ji(s))}),e},Ys=i=>{let e=jl(ci,i);return Object.keys(e).forEach(t=>{let s=e[t];ie(s)&&(e[t]=Ys(s))}),e},lt=i=>{if(ht(i))return Ys(i)},Ze=(i,e)=>typeof i=="boolean"?i:e,eo=i=>(Object.getOwnPropertyNames(i).forEach(function(e){i[e]&&typeof i[e]=="object"&&eo(i[e])}),Object.freeze(i)),Tg=i=>i.replace(/^\s+|\s+$/gm,""),ol=i=>i.replace(/^\.+/,""),Js=i=>{let e=i;if(!te(i)&&!Je(i))try{e=JSON.stringify(i)}catch{e=null}return e},Ig=i=>{let e=Array.from(i,t=>String.fromCodePoint(t)).join("");return globalThis.btoa(e)},Rg=i=>Ig(new TextEncoder().encode(i)),Qs=(i,e,t,s,r)=>{let n={category:i,name:e,properties:t,options:s,callback:void 0};I(r)&&(n.callback=r),I(s)&&(n.category=i,n.name=e,n.properties=t,n.options=void 0,n.callback=s),I(t)&&(n.category=i,n.name=e,n.properties=void 0,n.options=void 0,n.callback=t),I(e)&&(n.category=i,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),I(i)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=i),ie(i)?(n.name=void 0,n.category=void 0,n.properties=i,I(e)?n.options=void 0:n.options=e):ie(e)&&(n.name=void 0,n.properties=e,I(t)?n.options=void 0:n.options=t),te(i)&&!te(e)&&(n.category=void 0,n.name=i),Y(n.category)||(n.category=void 0),Y(n.name)||(n.name=void 0),n.properties=n.properties?G(n.properties):{},Y(n.options)?n.options=G(n.options):n.options=void 0;let o=te(n.name)?n.name:n.properties.name,a=te(n.category)?n.category:n.properties.category;return n.properties=pe(ie(n.properties)?n.properties:{},{...o&&{name:o},...a&&{category:a}}),n},to=(i,e,t,s)=>{let r={name:i,properties:e,options:t,callback:void 0};return I(s)&&(r.callback=s),I(t)&&(r.properties=e,r.options=void 0,r.callback=t),I(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=ci(r.properties)?G(r.properties):{},Y(r.options)?r.options=G(r.options):r.options=void 0,r},Hl=(i,e,t,s)=>{let r={userId:i,traits:e,options:t,callback:void 0};return I(s)&&(r.callback=s),I(t)&&(r.userId=i,r.traits=e,r.options=void 0,r.callback=t),I(e)&&(r.userId=i,r.traits=void 0,r.options=void 0,r.callback=e),(ie(i)||Ne(i))&&(r.userId=null,r.traits=i,I(e)?r.options=void 0:r.options=e),r.userId=Js(r.userId),ie(r.traits)?r.traits=G(r.traits):r.traits=void 0,Y(r.options)?r.options=G(r.options):r.options=void 0,r},ql=(i,e,t,s)=>{let r={to:i,from:e,options:t,callback:void 0};return I(s)&&(r.callback=s),I(t)&&(r.to=i,r.from=e,r.options=void 0,r.callback=t),I(e)?(r.to=i,r.from=void 0,r.options=void 0,r.callback=e):(ie(e)||Ne(e))&&(r.to=i,r.from=void 0,r.options=e),Y(r.to)&&(r.to=Js(r.to)),Y(r.from)?r.from=Js(r.from):r.from=void 0,Y(r.options)?r.options=G(r.options):r.options=void 0,r},zl=(i,e,t,s)=>{let r={groupId:i,traits:e,options:t,callback:void 0};return I(s)&&(r.callback=s),I(t)&&(r.groupId=i,r.traits=e,r.options=void 0,r.callback=t),I(e)&&(r.groupId=i,r.traits=void 0,r.options=void 0,r.callback=e),(ie(i)||Ne(i))&&(r.groupId=null,r.traits=i,I(e)?r.options=void 0:r.options=e),r.groupId=Js(r.groupId),ie(r.traits)?r.traits=G(r.traits):r.traits=void 0,Y(r.options)?r.options=G(r.options):r.options=void 0,r},fn=(function(i){return i.UNLOADED="Page Unloaded",i})({}),io="API",wn="CapabilitiesManager",qe="ConfigManager",Kl="EventManager",Vi="PluginsManager",Ut="UserSessionManager",Hi="ErrorHandler",ni="PluginEngine",Og="StoreManager",pn=`Ready${io}`,Cg=`Load${io}`,Pg="HttpClient",Ng="RudderStackAnalytics",Ms="AnalyticsCore";al=4096,Vs=[],Tt=0;for(;Tt<256;Tt++)Vs[Tt]=(Tt+256).toString(16).substring(1);Gt=256,Gs=[];for(;Gt--;)Gs[Gt]=(Gt+256).toString(16).substring(1);$g=()=>!Je(globalThis.crypto)&&I(globalThis.crypto.getRandomValues),sr=()=>$g()?xg():Lg(),Fg=()=>!!window.chrome?.runtime?.id,Wl=()=>te(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),Mg=(i,e=!1)=>{let t=!1,s=!1;function r(){t||(t=!0,i(s),setTimeout(()=>{t=!1},0))}(e||Wl())&&globalThis.addEventListener("beforeunload",()=>{s=!1,r()}),globalThis.addEventListener("blur",()=>{s=!0,r()}),globalThis.addEventListener("focus",()=>{t=!1}),document.addEventListener("pagehide",()=>{s=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{s=!0,document.visibilityState==="hidden"?r():t=!1})},Xl=i=>i.toISOString(),Ug=()=>Xl(new Date),D=":: ",Bg=i=>`A script with the id "${i}" is already loaded. Skipping the loading of this script to prevent conflicts`,ll=(i,e,t)=>`Unable to load (${te(t)?t:t.type}) the script with the id "${i}" from URL "${e}"`,Vg=(i,e,t)=>`A timeout of ${t} ms occurred while trying to load the script with id "${i}" from URL "${e}"`,Gg=(i,e)=>`${i}${D}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,jg="Failed to convert the value to a JSON string.",Hg="Failed to encode the cookie data.",qg=(i,e)=>`${i}${D}The "${e}" storage type is `,zg="JSONStringify",Kg="[BigInt]",Yl="[Circular Reference]",Wg=(i,e,t)=>{let s=[];return function(r,n){if(!e?.includes(r)&&!(i&&Je(n))){if(typeof n!="object"||Ne(n))return n;for(;s.length>0&&s[s.length-1]!==this;)s.pop();return s.includes(n)?(t?.warn(Gg(zg,r)),Yl):(s.push(n),n)}}},Ye=(i,e,t,s)=>{try{return JSON.stringify(i,Wg(e,t,s))}catch(r){return s?.warn(jg,r),null}},Xg=i=>{let e=[];return function(s,r){if(yg(r))return Kg;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?Yl:(e.push(r),r)}},Jl=(i,e)=>{let t=Array.isArray(i)?[]:{};for(let s in i)if(Object.hasOwnProperty.call(i,s)){let r=i[s],n=e.call(i,s,r);ie(n)||Array.isArray(n)?t[s]=Jl(n,e):t[s]=n}return t},j=(i,e)=>{let t=Xg(),s=t.call(i,"",i);return ie(i)||Array.isArray(i)?Jl(i,t):s},js="[SDK DISPATCHED ERROR]",rr=i=>{let{stack:e,stacktrace:t,"opera#sourceloc":s}=i,r=e??t??s;if(r&&typeof r=="string")return r},so=(i,e)=>{if(!Zn(i))return new Error(`${e}: ${Ye(i)}`);try{let t=i.constructor,s=new t(`${e}: ${i.message}`),r=rr(i);return r&&(s.stack=r),Object.getOwnPropertyNames(i).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{s[n]=i[n]}catch{}}),s}catch{return new Error(`${e}: ${Ye(i)}`)}},ce=i=>{if(Zn(i)){let e=rr(i);if(e){let{stack:t,stacktrace:s,"opera#sourceloc":r}=i;switch(e){case t:i.stack=`${t}
11
+ ${js}`;break;case s:i.stacktrace=`${s}
12
+ ${js}`;break;case r:default:i["opera#sourceloc"]=`${r}
13
+ ${js}`;break}}}globalThis.dispatchEvent(new ErrorEvent("error",{error:i,bubbles:!0,cancelable:!0,composed:!0}))},cl="RudderLabs JavaScript SDK",Wi="3.29.0",Yg="com.rudderlabs.javascript",Ql="npm",Jg="modern",ul="RudderJS-Initiated",Qg="ad-block page request",Zg="/ad-blocked",zi="preloadedEventsBuffer",ef="Consent Management Interaction",tf="ajs_trait_",sf="ajs_prop_",dl="ajs_aid",rf="ajs_uid",hl="ajs_event",nf=10*1e3,of=31536e3*1e3,gl=720*60*1e3,An=1800*1e3,fl=10*1e3,af=10*1e3,lf=250,Zl=(i="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[i]||(globalThis.RudderStackGlobals[i]={})},Xi=(i,e,t="app")=>{Zl(t),globalThis.RudderStackGlobals[t][i]=e},ec=(i,e="app")=>(Zl(e),globalThis.RudderStackGlobals[e][i]);pl=(i,e)=>{let t={};return i.forEach((s,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);t[n]=i.get(r)}}),t},uf=(i=[])=>{let e={trait:tf,properties:sf},t=new URLSearchParams(globalThis.location.search);t.get(hl)&&i.unshift(["track",t.get(hl),pl(t,e.properties)]);let s=t.get(rf),r=pl(t,e.trait);if(s||ht(r)){let n=[...s?[s]:[],r];i.unshift(["identify",...n])}t.get(dl)&&i.unshift(["setAnonymousId",t.get(dl)])},df=i=>{let e="load",t=[],s=0;for(;s<i.length;){if(i[s]&&i[s][0]===e){t=G(i[s]),i.splice(s,1);break}s+=1}return t},hf=i=>{let e="consent",t=i.filter(r=>r[0]===e),s=i.filter(r=>r[0]!==e);i.splice(0,i.length,...t,...s)},gf=i=>{let e=ec(zi)||[];uf(e),e.length>0&&(i.enqueuePreloadBufferEvents(e),Xi(zi,[]))},ff=(i,e)=>{let t=i.shift(),s;if(I(e[t])){switch(t){case"page":s=Qs(...i);break;case"track":s=to(...i);break;case"identify":s=Hl(...i);break;case"alias":s=ql(...i);break;case"group":s=zl(...i);break;default:e[t](...i);break}s&&e[t](s)}},pf=10*1e3,vf="RS_JS_SDK",_f=(i,e,t=!0,s=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=s,o.onerror=r,o.src=i,o.id=e,o.async=t,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",vf),o},mf=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 s=document.createElement("head");s.appendChild(i);let r=document.getElementsByTagName("html")[0];r?.insertBefore(s,r.firstChild)},yf=(i,e,t,s=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(Bg(e)));try{let l;mf(_f(i,e,s,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(ll(e,i,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(Vg(e,i,t)))},t)}catch(l){o(so(l,ll(e,i,"unknown")))}}),Zs=class{constructor(e,t=pf){this.logger=e,this.timeout=t}loadJSFile(e){let{url:t,id:s,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!I(o);yf(t,s,r||this.timeout,n,a).then(u=>{l||o(u)}).catch(u=>{l||o(s,u)})}},bf=Symbol.for("preact-signals");K=void 0;Ki=void 0,It=0,Tn=0,er=0;we.prototype.brand=bf;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:tc(function(){var s;(s=e.W)==null||s.call(e)}))};we.prototype.U=function(i){var e=this;if(this.t!==void 0){var t=i.e,s=i.x;t!==void 0&&(t.x=s,i.e=void 0),s!==void 0&&(s.e=t,i.x=void 0),i===this.t&&(this.t=s,s===void 0&&tc(function(){var r;(r=e.Z)==null||r.call(e)}))}};we.prototype.subscribe=function(i){var e=this;return tt(function(){var t=e.value,s=K;K=void 0;try{i(t)}finally{K=s}},{name:"sub"})};we.prototype.valueOf=function(){return this.value};we.prototype.toString=function(){return this.value+""};we.prototype.toJSON=function(){return this.value};we.prototype.peek=function(){var i=K;K=void 0;try{return this.value}finally{K=i}};Object.defineProperty(we.prototype,"value",{get:function(){var i=ic(this);return i!==void 0&&(i.i=this.i),this.v},set:function(i){if(i!==this.v){if(Tn>100)throw new Error("Cycle detected");this.v=i,this.i++,er++,It++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{nr()}}}});gi.prototype=new we;gi.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===er))return!0;if(this.g=er,this.f|=1,this.i>0&&!sc(this))return this.f&=-2,!0;var i=K;try{rc(this),K=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 K=i,nc(this),this.f&=-2,!0};gi.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)};gi.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)}};gi.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(gi.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=ic(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,oc(this),rc(this),It++;var i=K;return K=this,Ef.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||ro(this)};fi.prototype.dispose=function(){this.d()};In=class{constructor(){this.items=[]}enqueue(e){this.items.push(e)}dequeue(){return this.items.length===0?null:this.items.shift()}isEmpty(){return this.items.length===0}size(){return this.items.length}clear(){this.items=[]}},Bs={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},vl="LOG",ac="ERROR",kf="RS SDK",Sf="font-weight: bold; background: black; color: white;",wf="font-weight: normal;",Rn=class{constructor(e=vl,t="",s=console){this.minLogLevel=Bs[e],this.scope=t,this.logProvider=s}log(...e){this.outputLog("LOG",e)}info(...e){this.outputLog("INFO",e)}debug(...e){this.outputLog("DEBUG",e)}warn(...e){this.outputLog("WARN",e)}error(...e){this.outputLog("ERROR",e)}outputLog(e,t){this.minLogLevel<=Bs[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=Bs[e],_e(this.minLogLevel)&&(this.minLogLevel=Bs[vl])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t=`%c ${kf}`;this.scope&&(t=`${t} - ${this.scope}`);let s=te(e[0])?e[0].trim():"";t=`${t} %c ${s}`;let r=[t,Sf,wf];return te(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},gt=new Rn,ct=(function(i){return i.HANDLEDEXCEPTION="handledException",i.UNHANDLEDEXCEPTION="unhandledException",i.UNHANDLEDREJECTION="unhandledPromiseRejection",i})({}),lc=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],On="cookieStorage",_l="Unable to process/parse source configuration response",Af="The source is disabled. Please enable the source in the dashboard to send events.",Tf="Failed to prepare data for the request.",If="Failed to invoke plugin because the extension point name is missing.",Rf="Failed to invoke plugin because the extension point name is invalid.",Of=i=>`${i}${D}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,Cf=(i,e,t)=>`${i}${D}The base URL "${t}" for ${e} is not valid.`,Pf=(i,e,t)=>`${i}${D}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(t)}".`,Nf=(i,e)=>`${i}${D}Ignoring a non-error: ${e}.`,ml="Failed to log breadcrumb",Df=i=>`${i}${D}Failed to handle the error.`,xf=i=>`${i}${D}Plugin name is missing.`,Lf=(i,e)=>`${i}${D}Plugin "${e}" already exists.`,$f=(i,e)=>`${i}${D}Plugin "${e}" not found.`,Ff=(i,e)=>`${i}${D}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.`,Mf=(i,e,t)=>`${i}${D}Plugin "${e}" could not be loaded because some of its dependencies "${t}" do not exist.`,Uf=(i,e,t)=>`${i}${D}Failed to invoke the "${e}" extension point of plugin "${t}".`,yl="Failed to fetch the source config",Bf=(i,e)=>`${i}${D}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,Vf=(i,e)=>`${i}${D}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.`,cc=i=>`${i}${D}The provided callback parameter is not a function.`,Gf=(i,e,t,s,r)=>`${i} with status ${e} (${t}) for URL: ${s}. Response: ${r.trim()}`,jf=(i,e,t)=>`${i} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${t}`,Hf=(i,e)=>`${i} for URL: ${e}`,qf=i=>`Failed to save the value for "${i}" to storage`,zf=i=>`Failed to retrieve or parse data for "${i}" from storage`,Kf=i=>`The server responded with status ${i} while setting the cookies. As a fallback, the cookies will be set client side.`,Wf=i=>`The server failed to set the ${i} cookie. As a fallback, the cookies will be set client side.`,bl="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",Xf=(i,e,t)=>`${i}${D}The storage type "${e}" is not supported. Please choose one of the following supported types: "${lc}". The default type "${t}" will be used instead.`,Yf=(i,e,t,s)=>`${i}${D}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(t)}". The default version "${s}" will be used instead.`,Jf=(i,e,t)=>`${i}${D}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.`,Qf=(i,e,t)=>`${i}${D}The provided cookie domain (${e}) does not match the current webpage's domain (${t}). Hence, the cookies will be set client-side.`,Zf=(i,e,t,s)=>`${i}${D}The "${e}" property defined under "${t}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${s}).`,ep=i=>`${i}${D}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,tp=i=>`${i}${D}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,ip=(i,e,t)=>`${i}${D}The session timeout value "${e}" is not a number. The default timeout of ${t} ms will be used instead.`,sp=(i,e,t)=>`${i}${D}The session cut off duration value "${e}" is not a number. The default cut off duration of ${t} ms will be used instead.`,rp=(i,e,t)=>`${i}${D}The session cut off duration value "${e}" ms is less than the session timeout value "${t}" ms. The cut off functionality will be disabled.`,np=i=>`${i}${D}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.`,op=(i,e,t)=>`${i}${D}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.`,ap=(i,e,t)=>`${i}${D}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.`,lp=i=>`${i}${D}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,cp=(i,e,t,s)=>`${i}${D}The storage type "${t}" is not available for entry "${e}". The SDK will initialize the entry with "${s}" storage type instead.`,up=i=>`${i}${D}The callback threw an exception`,dp=(i,e)=>`${i}${D}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,hp=(i,e)=>`Failed to load the polyfill script with ID "${i}" from URL ${e}.`,gp=(i,e,t)=>`${i}${D}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.`,fp=(i,e,t)=>`${i}${D}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.`,pp=(i,e)=>`${i}${D}${e} plugin is deprecated. Please exclude it from the load API options.`,vp=(i,e,t,s)=>{let r=t.length===1,n=r?` '${t[0]}' plugin was`:` ['${t.join("', '")}'] plugins were`,o=`${i}${D}${e}, but${n} not configured to load.`;return s?`${o} So, ${r?"the plugin":"those plugins"} will be loaded automatically.`:`${o} Ignore if this was intentional. Otherwise, consider adding ${r?"it":"them"} to the 'plugins' load API option.`},_p=(i,e)=>`${i}${D}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,mp=i=>`${i}${D}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,yp=(i,e)=>`${i}${D}Ignoring unknown plugins: ${e.join(", ")}.`,bp=(i,e)=>`${i}${D}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.`,Ep=(i,e)=>`${i}${D}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,uc={All:!0},or="js-integrations",dc="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_]*)?$"),Yi="modern",ar="https://cdn.rudderlabs.com",no="v3",hc=`${ar}/${no}/${Yi}/${or}`,gc=`${ar}/${no}/${Yi}/${dc}`,fc="https://api.rudderstack.com",Bt="v3",Sp="xhr",Cn={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Hs={[Bt]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},wp={[Sp]:"XhrQueue",beacon:"BeaconQueue"},Ap="rsaRequest",Tp="rsaMetrics",Ip="Custom Device Mode",Rp={configUrl:fc,loadIntegration:!0,sessions:{autoTrack:!0,timeout:An,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:uc,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:af,storage:{encryption:{version:Bt},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},Op=y(G(Rp)),X=eo({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),_n=eo({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Cp=10,Pp={userId:y(X.userId),userTraits:y(X.userTraits),anonymousId:y(X.anonymousId),groupId:y(X.groupId),groupTraits:y(X.groupTraits),initialReferrer:y(X.initialReferrer),initialReferringDomain:y(X.initialReferringDomain),sessionInfo:y(X.sessionInfo),authToken:y(X.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),Lp={activeDataplaneUrl:y(void 0),integrationsCDNPath:y(hc),pluginsCDNPath:y(gc),sourceConfigUrl:y(void 0),status:y(void 0),initialized:y(!1),logLevel:y(ac),loaded:y(!1),readyCallbacks:y([]),writeKey:y(void 0),dataPlaneUrl:y(void 0),safeAnalyticsInstance:y(void 0)},$p={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=()=>Jg,Up={app:y({name:cl,namespace:Yg,version:Wi,installType:Ql}),traits:y(null),library:y({name:cl,version:Wi,snippetVersion:globalThis.RudderSnippetVersion,variant:Mp()}),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)},Bp={configuredDestinations:y([]),activeDestinations:y([]),loadOnlyIntegrations:y({}),failedDestinations:y([]),loadIntegration:y(!0),initializedDestinations:y([]),clientDestinationsReady:y(!1),integrationsConfig:y({})},Vp={toBeProcessedArray:y([]),readyCallbacksArray:y([])},Gp={ready:y(!1),loadedPlugins:y([]),failedPlugins:y([]),pluginsToLoadFromConfig:y([]),activePlugins:y([]),totalPluginsToLoad:y(0)},jp={encryptionPluginName:y(void 0),migrate:y(!1),type:y(void 0),cookie:y(void 0),entries:y({}),trulyAnonymousTracking:y(!1)},Hp={isEnabledServerSideCookies:y(!1),dataServiceUrl:y(void 0)},qp={eventsQueuePluginName:y(void 0),deliveryEnabled:y(!0)},zp={enabled:y(!1),pageLifecycle:{enabled:y(!1),pageViewId:y(void 0),pageLoadedTimestamp:y(void 0)}},Kp={capabilities:Np,consents:$p,context:Up,eventBuffer:Vp,lifecycle:Lp,loadOptions:Op,metrics:Fp,nativeDestinations:Bp,plugins:Gp,reporting:Dp,session:Pp,source:xp,storage:jp,serverCookies:Hp,dataPlaneEvents:qp,autoTrack:zp},d={...G(Kp)};qs={exports:{}},zs={exports:{}},Wp=zs.exports;Yp=qs.exports;Qp=Jp(),Zp=pc(Qp),vc="global code",ev=i=>Y(i)&&/^global code$/i.test(i)?vc:i,tv=i=>{let e={file:i.fileName,method:ev(i.functionName),lineNumber:i.lineNumber,columnNumber:i.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=vc),e},Sl=i=>te(i)?i:"";_c=(i,e)=>{let t;return Zn(i)&&te(rr(i))?t=i:(e.warn(Nf(Hi,Ye(i))),t=void 0),t},iv=(i,e)=>{try{let t=Zp.parse(i);return wl(i.name,i.message,e,t)}catch{return wl(i.name,i.message,e,[])}},Al=(i,e)=>{try{return JSON.parse(i||"")}catch(t){let s=so(t,"Failed to parse response data");e(s)}},Ks="The request failed",sv=[/Failed to fetch dynamically imported module: .*/],rv=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],nv=[new RegExp(`${Ks}.*`),/A script with the id .* is already loaded\./],ov=[...sv,...rv],av="integrations",lv="sdk",cv=lv,uv={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Tl=(i,e,t)=>{let s=pe(uv,e||{});return t&&(s.headers=pe(s.headers,{Authorization:t})),s.url=i,s},Il=(i,e=nf,t)=>new Promise((s,r)=>{let n;if(i.sendRawData===!0)n=i.data;else if(n=Ye(i.data,!1,[],t),Ne(n)){r({error:new Error(Tf),undefined:void 0,options:i});return}let o=new XMLHttpRequest,a=u=>{r({error:new Error(Gf(Ks,o.status,o.statusText,i.url,o.responseText)),xhr:o,options:i})},l=u=>{r({error:new Error(jf(Ks,u,i.url)),xhr:o,options:i,...u?.type==="timeout"?{timedOut:!0}:{}})};o.ontimeout=l,o.onerror=l,o.onload=()=>{o.status>=200&&o.status<400?s({response:o.responseText,xhr:o,options:i}):a()},o.open(i.method,i.url,!0),i.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(i.headers).forEach(u=>{i.headers[u]&&o.setRequestHeader(u,i.headers[u])});try{o.send(n)}catch(u){r({error:so(u,Hf(Ks,i.url)),xhr:o,options:i})}}),Pn=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:t,options:s,timeout:r,isRawResponse:n}=e;try{let o=await Il(Tl(t,s,this.basicAuthHeader),r,this.logger);return{data:n?o.response:Al(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:t,url:s,options:r,timeout:n,isRawResponse:o}=e,a=!I(t);Il(Tl(s,r,this.basicAuthHeader),n,this.logger).then(l=>{a||t(o?l.response:Al(l.response,this.onError),l)}).catch(l=>{a||t(void 0,l)})}onError(e,t){this.errorHandler?.onError({error:e,context:Pg,groupingHash:t})}setAuthHeader(e,t=!1){let s=t?e:Rg(`${e}:`);this.basicAuthHeader=`Basic ${s}`}resetAuthHeader(){this.basicAuthHeader=void 0}},mc=new Pn(gt),dv="1",hv=()=>["rsa"],gv=["www.test-host.com","localhost","127.0.0.1","[::1]"],fv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],pv="RudderStack JavaScript SDK",vv="git+https://github.com/rudderlabs/rudder-sdk-js.git",_v="js",yc=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:(s,r)=>{d.capabilities.isAdBlockerDetectionInProgress.value=!1,d.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==t}})}catch(e){throw d.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},mv=(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}},yv=i=>({type:"manual",name:i,timestamp:new Date,metaData:{}}),bv=(i=()=>window.location.hostname)=>{let e=i();return!e||e&&gv.includes(e)?"development":"production"},Ev=i=>{let e=Ye(i,!1,fv);return e!==null?JSON.parse(e):{}},kv=()=>globalThis.location.href.split("?")[0],Sv=(i,e,t,s)=>({id:`${i.value?.id??t.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${s.pageLifecycle.pageViewId.value??"NA"}`,name:i.value?.name??"NA"}),wv=(i,e)=>({locale:i.value??"NA",userAgent:e.value??"NA",time:new Date}),Av=(i,e,t,s)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:u}=t,{app:c,locale:h,userAgent:g,timezone:f,screen:v,library:p}=r;return{payloadVersion:"5",notifier:{name:pv,version:c.value.version,url:vv},events:[{exceptions:[G(i)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:c.value.version,releaseStage:bv(),type:c.value.installType},device:wv(h,g),request:{url:kv(),clientIp:"[NOT COLLECTED]"},breadcrumbs:G(l.breadcrumbs.value),context:i.message,groupingHash:s,metaData:{app:{snippetVersion:p.value.snippetVersion},device:{...v.value,timezone:f.value},...Ev(t)},user:Sv(a,o,n,u)}]}},Tv=(i,e,t)=>{if(_e(i.capabilities.isAdBlocked.value)){i.capabilities.isAdBlockerDetectionInProgress.value===!1&&yc(e);let s=tt(()=>{Y(i.capabilities.isAdBlocked.value)&&(t(i.capabilities.isAdBlocked.value===!1),s())})}else t(i.capabilities.isAdBlocked.value===!1)},Iv=(i,e,t)=>{let s=i.message;return new Promise(r=>{if(ov.some(n=>n.test(s))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(s)?.[0];te(n)?n.startsWith(ar)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):Tv(e,t,r):r(!1):r(!0)}else r(!nv.some(n=>n.test(s)))})},bc=i=>i?i.split("/").at(-2):void 0,Ec=i=>{let e=i.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},Rv=i=>{let e=Ec(i);if(!e)return!1;let t=e.substring(e.lastIndexOf("/")+1);return bc(e)===or||hv().some(r=>t.startsWith(r)&&t.endsWith(".js"))},Ov=(i,e)=>{if(e)return e;let t=Ec(i);return bc(t)===or?av:cv},Cv=(i,e,t)=>{let s={version:dv,message_id:sr(),source:{name:_v,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 Ye(s)},Pv=(i,e,t)=>{let s;if(!Y(i))s=e;else if(te(i))s=i;else{let r=_c(i,t);Y(r)?s=r.message:s=e}return s},Nn=class{constructor(e,t){re(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=te(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&t.startsWith(ar)&&!d.capabilities.cspBlockedURLs.value.includes(t)&&(d.capabilities.cspBlockedURLs.value=[...d.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{let{error:t,context:s,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??ct.HANDLEDEXCEPTION,l=mv(t,a),u=_c(l,this.logger);if(_e(u))return;let c=r?`${r} - `:"",h=`${s}${D}${c}`,g=iv(u,h),v=rr(u).includes(js);if(!v&&!Rv(g)&&a!==ct.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await Iv(g,d,this.httpClient)){let m={severity:"error",unhandled:a!==ct.HANDLEDEXCEPTION,severityReason:{type:a}},E=Pv(n,g.message,this.logger),T=Av(g,m,d,E),x=Ov(g,o);this.httpClient.getAsyncData({url:d.metrics.metricsServiceUrl.value,options:{method:"POST",data:Cv(T,d,x),sendRawData:!0},isRawResponse:!0})}(a===ct.HANDLEDEXCEPTION||v)&&this.logger.error(g.message)}catch(t){this.logger.error(Df(Hi),t)}}leaveBreadcrumb(e){try{d.reporting.breadcrumbs.value=[...d.reporting.breadcrumbs.value,yv(e)]}catch(t){this.onError({error:t,context:Hi,customMessage:ml,groupingHash:ml})}}},kc=new Nn(mc,gt),Dn=class{constructor(e,t={}){re(this,"plugins",[]);re(this,"byName",{});re(this,"cache",{});re(this,"config",{throws:!0});this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){let r=xf(ni);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=Lf(ni,e.name);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},this.plugins=this.plugins.slice();let s=this.plugins.length;this.plugins.forEach((r,n)=>{r.deps?.includes(e.name)&&(s=Math.min(s,n))}),this.plugins.splice(s,0,e),this.byName[e.name]=e,I(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let r=$f(ni,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let s=this.plugins.indexOf(t);if(s===-1){let r=Ff(ni,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},delete this.byName[e],this.plugins=this.plugins.slice(),this.plugins.splice(s,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(s=>{if(s.deps?.some(r=>!this.byName[r])){let r=s.deps.filter(n=>!this.byName[n]);return this.logger.error(Mf(ni,s.name,r)),!1}return t==="."?!0:kg(s,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...s){let r=e;if(!r)throw new Error(If);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(Rf);let a=r.split(".");a.pop();let l=a.join(".");return(t?this.getPlugins(r):[this.getPlugins(r)[0]]).map(c=>{let h=Sn(c,r);if(!I(h)||n)return h;try{return h.apply(Sn(c,l),s)}catch(g){if(o)throw g;this.logger.error(Uf(ni,r,c.name),g)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}},Nv=new Dn(gt,{throws:!0}),Dv=i=>i.config.connectionMode!=="cloud"||i.config.useNativeSDKToSend===!0||i.config.useNativeSDK===!0,xv=i=>i.config.connectionMode==="hybrid"||i.config.useNativeSDKToSend===!0,Rl=i=>i.filter(Dv),Lv=(i,e)=>`${i.replaceAll(" ","-")}___${e}`,Sc=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],$v=["Bugsnag","ErrorReporting"],Fv={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"}};Mv=i=>wc({},(globalThis.__federation_shared__||{}).default||{});Bv=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}},Vv=i=>{let e={};return i.forEach(t=>{if(Sc.includes(t)){let s=Bv(t);s&&(e[t]=s)}}),e},Ac=()=>({}),Gv=()=>({}),jv=i=>Vv?.(i)||{},mn={...Ac(),...Gv()},Hv=i=>({...jv(i)}),xn=class{constructor(e,t,s){this.engine=e,this.errorHandler=t,this.logger=s,this.onError=this.onError.bind(this)}init(){d.lifecycle.status.value="pluginsLoading",Xi("pluginsCDNPath",d.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){tt(()=>{(d.plugins.activePlugins.value.length===0||d.plugins.loadedPlugins.value.length+d.plugins.failedPlugins.value.length===d.plugins.totalPluginsToLoad.value)&&Ee(()=>{d.plugins.ready.value=!0,d.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=d.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>$v.includes(r)?(this.logger.warn(pp(Vi,r)),!1):!0);let t=[{configurationStatus:()=>Y(d.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:d.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(wp),shouldAddMissingPlugins:!0},{configurationStatus:()=>Rl(d.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Rl(d.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>Y(d.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:d.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Cn)},{configurationStatus:()=>Y(d.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:d.storage.encryptionPluginName.value,supportedPlugins:Object.values(Hs)},{configurationStatus:()=>d.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],s=!1;return t.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>Y(n)),this.addMissingPlugins(r,s,e)):e=e.filter(r.basePlugins!==void 0?n=>!(r.basePlugins.includes(n)||r.supportedPlugins.includes(n)):n=>!r.supportedPlugins.includes(n))}),[...Object.keys(Ac()),...e]}addMissingPlugins(e,t,s){let r=e.shouldAddMissingPlugins||t,n;e.activePluginName?n=[...e.basePlugins||[],e.activePluginName]:n=[...e.supportedPlugins];let o=n.filter(a=>!s.includes(a));o.length>0&&(r&&s.push(...o),this.logger.warn(vp(Vi,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(mn),...Sc],s=[],r=[];e.forEach(n=>{t.includes(n)?s.push(n):r.push(n)}),r.length>0&&this.logger.warn(yp(Vi,r)),Ee(()=>{d.plugins.totalPluginsToLoad.value=e.length,d.plugins.activePlugins.value=s,d.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(mn).forEach(([t,s])=>{d.plugins.activePlugins.value.includes(t)&&(I(s)?this.register([s()]):e.push(t))}),e.length>0&&(d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,...e],this.logger.error(bp(Vi,e)))}registerRemotePlugins(){let e=Hv(d.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async t=>{await e[t]().then(s=>this.register([s.default()])).catch(s=>{d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,t],this.onError(s,`Failed to load plugin "${t}"`,s)})})).catch(t=>{this.onError(t)})}invokeMultiple(e,...t){try{return this.engine.invokeMultiple(e,...t)}catch(s){return this.onError(s,e),[]}}invokeSingle(e,...t){try{return this.engine.invokeSingle(e,...t)}catch(s){return this.onError(s,e),null}}register(e){e.forEach(t=>{try{this.engine.register(t,d)}catch(s){d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,t.name],this.onError(s,`Failed to register plugin "${t.name}"`)}})}unregisterLocalPlugins(){Object.keys(mn).forEach(e=>{try{this.engine.unregister(e)}catch(t){this.onError(t,`Failed to unregister plugin "${e}"`)}})}onError(e,t,s){this.errorHandler.onError({error:e,context:Vi,customMessage:t,groupingHash:s})}},Pe="cookieStorage",Me="localStorage",He="sessionStorage",et="memoryStorage",jt="none",qv="test_rudder_cookie",zv="test_rudder_ls",Kv="test_rudder_ss",Wv="rl_user_id",Xv="rl_trait",Yv="rl_anonymous_id",Jv="rl_group_id",Qv="rl_group_trait",Zv="rl_page_init_referrer",e_="rl_page_init_referring_domain",t_="rl_session",i_="rl_auth_token",oi={userId:Wv,userTraits:Xv,anonymousId:Yv,groupId:Jv,groupTraits:Qv,initialReferrer:Zv,initialReferringDomain:e_,sessionInfo:t_,authToken:i_},s_="__tld__",Tc="clientDataInCookie",Ic="clientDataInLocalStorage",r_="clientDataInMemory",Rc="clientDataInSessionStorage",Oc=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ai={[Pe]:Tc,[Me]:Ic,[et]:r_,[He]:Rc},Ol=(i,e)=>{try{return encodeURIComponent(i)}catch(t){e?.error(Hg,t);return}},Cl=i=>{try{return decodeURIComponent(i)}catch{return}},n_=i=>{let e={},t=i.split(/\s*;\s*/),s;return t[0]&&t.forEach(r=>{s=r.split("=");let n=s[0]?Cl(s[0]):void 0;n&&(e[n]=s[1]?Cl(s[1]):void 0)}),e},o_=(i,e,t,s)=>{let r={...t||{}},n=`${Ol(i,s)}=${Ol(e,s)}`;Ne(e)&&(r.maxage=-1),r.maxage&&(r.expires=new Date(+new Date+r.maxage)),r.path&&(n+=`; path=${r.path}`),r.domain&&(n+=`; domain=${r.domain}`),r.expires&&(n+=`; expires=${r.expires.toUTCString()}`),r.samesite&&(n+=`; samesite=${r.samesite}`),r.secure&&(n+="; secure"),globalThis.document.cookie=n},Ln=()=>{let i=globalThis.document.cookie;return n_(i)},a_=i=>Ln()[i],ut=function(i,e,t,s){switch(arguments.length){case 4:case 3:case 2:return o_(i,e,t,s);case 1:return i?a_(i):Ln();default:return Ln()}},l_=i=>{let e=document.createElement("a");return e.href=i,e.hostname},c_=i=>{let t=(typeof globalThis.URL!="function"?l_(i):new URL(i).hostname)?.split(".")??[],s=t[t.length-1],r=[];if(t.length===4&&s&&s===parseInt(s,10).toString())return r;if(t.length<=1)return t[0]&&t[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=t.length-2;n>=0;n-=1)r.push(t.slice(n).join("."));return r},u_=i=>{let e=c_(i);for(let t=0;t<e.length;t+=1){let s=e[t],r=s_,n={domain:`${s.indexOf("localhost")!==-1?"":"."}${s}`};try{if(ut(r,1,n),ut(r))return ut(r,null,n),s}catch{try{ut(r,null,n)}catch{}}}return""},d_=()=>{let i=`.${u_(globalThis.location.href)}`;return{maxage:of,path:"/",domain:!i||i==="."?void 0:i,samesite:"Lax",enabled:!0}},h_=()=>({enabled:!0}),g_=()=>({enabled:!0}),f_=()=>({enabled:!0}),$n=class{constructor(e){re(this,"isEnabled",!0);re(this,"length",0);re(this,"data",{});this.options=f_(),this.logger=e}configure(e){return this.options=pe(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)}},tr=new $n(gt),Ws={exports:{}},p_=Ws.exports;__=v_(),Mt=pc(__),Cc=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},li=(i=Me,e,t)=>{let s,r,n=qg(wn,i),o="unavailable",a=!0,l;try{switch(i){case et:return!0;case Pe:s=e,r=qv;break;case Me:s=e??globalThis.localStorage,r=zv;break;case He:s=e??globalThis.sessionStorage,r=Kv;break;default:return!1}if(s&&(s.setItem(r,"true"),s.getItem(r)))return s.removeItem(r),!0;a=!1}catch(u){a=!1,l=u,Cc(u)&&(o="full")}return a||t?.warn(`${n}${o}.`,l),!1},Fn=class{constructor(e){re(this,"isSupportAvailable",!0);re(this,"isEnabled",!0);re(this,"length",0);this.options=h_(),this.logger=e}configure(e){return this.options=pe(this.options,e??{}),this.isSupportAvailable=li(Me),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){Mt.set(e,t),this.length=Mt.len()}getItem(e){let t=Mt.get(e);return _e(t)?null:t}removeItem(e){Mt.remove(e),this.length=Mt.len()}clear(){Mt.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Mt.keys()}},oo=new Fn(gt),Mn=class{constructor(e){re(this,"isSupportAvailable",!0);re(this,"isEnabled",!0);re(this,"length",0);this.options=g_(),this.logger=e}configure(e){return this.options=pe(this.options,e??{}),this.isSupportAvailable=li(He),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 s=this.store.key(t);s!==null&&e.push(s)}return e}},ao=new Mn(gt),Un=class{constructor(e){re(this,"isSupportAvailable",!0);re(this,"isEnabled",!0);re(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=d_()),this.options=pe(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=li(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 _e(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())}},lo=new Un(gt),Xe=i=>{switch(i){case Me:return oo;case He:return ao;case et:return tr;case Pe:return lo;default:return tr}},m_=i=>{let e=lo.configure(i);d.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},y_=i=>{oo.configure(i)},b_=i=>{tr.configure(i)},E_=i=>{ao.configure(i)},k_=(i={},e={},t={},s={})=>{m_(i),y_(e),b_(t),E_(s)},Bn=class{constructor(e,t,s){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=s}createValidKey(e){let{name:t,id:s,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[t,s,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[t,s,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:s,noCompoundKey:r}=this,n=Xe(et);Object.keys(s).forEach(o=>{let a=this.get(s[o]),l=r?o:[e,t,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,t){let s=this.createValidKey(e);if(s)try{this.engine.setItem(s,this.encrypt(Ye(t,!1,[],this.logger)))}catch(r){if(Cc(r))this.logger.warn(lp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,t);else{let n=qf(e);this.onError(r,n,n)}}}get(e){let t=this.createValidKey(e),s;try{return!t||(s=this.decrypt(this.engine.getItem(t)),Je(s)||s==="")?null:JSON.parse(s)}catch(r){let n=d.storage.encryptionPluginName.value;if(!n||!d.plugins.failedPlugins.value.includes(n)){let a=zf(e);this.onError(r,a,a)}return null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return Je(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||typeof e!="string"||Tg(e)==="")return e;let r=`storage.${t}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,t,s){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:s})}},S_=(i,e)=>{let t;if(i.consents.preConsent.value.enabled)switch(i.consents.preConsent.value.storage?.strategy){case"none":t=jt;break;case"session":e!=="sessionInfo"&&(t=jt);break;case"anonymousId":e!=="anonymousId"&&(t=jt);break}return t},Vn=class{constructor(e,t,s){re(this,"stores",{});re(this,"isInitialized",!1);this.errorHandler=t,this.logger=s,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:{}};k_(ji(pe(t.cookieStorageOptions??{},d.storage.cookie?.value??{})),ji(t.localStorageOptions),ji(t.inMemoryStorageOptions),ji(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[et,Me,Pe,He].forEach(t=>{Xe(t)?.isEnabled&&this.setStore({id:ai[t],name:ai[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,s=d.consents.postConsent.value.storage;(Y(s?.type)||Y(s?.entries))&&(e=s?.type,t=s?.entries);let r=!0,n={};Oc.forEach(o=>{let a=o,l=o,u=t?.[a]?.type,h=S_(d,o)??u??e??On,g=this.getResolvedStorageTypeForEntry(h,o);g!==jt&&(r=!1),n={...n,[o]:{type:g,key:oi[l]}}}),Ee(()=>{d.storage.type.value=e,d.storage.entries.value=n,d.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,t){let s=e;switch(e){case Me:Xe(Me)?.isEnabled||(s=et);break;case He:Xe(He)?.isEnabled||(s=et);break;case et:case jt:break;case Pe:default:Xe(Pe)?.isEnabled?s=Pe:Xe(Me)?.isEnabled?s=Me:Xe(He)?.isEnabled?s=He:s=et;break}return s!==e&&this.logger.warn(cp(Og,t,e,s)),s}setStore(e){let t=Xe(e.type);return this.stores[e.id]=new Bn(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},w_=i=>ie(i)&&ie(i.source)&&!Je(i.source.id)&&ie(i.source.config)&&Array.isArray(i.source.destinations),A_=i=>typeof i=="string"&&lc.includes(i),Pc=i=>{let e=new URL(i),{host:t,protocol:s}=e,r=t.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=t,{topDomain:n,protocol:s}},T_=i=>{let{topDomain:e,protocol:t}=Pc(i);return`${t}//${e}`},I_=(i,e)=>{let t=e?window.location.origin:T_(window.location.href),s=i.startsWith("/")?i.substring(1):i;return`${t}/${s}`},R_=i=>{let{topDomain:e}=Pc(window.location.href);return e===i},ui=i=>i?.endsWith("/")?ui(i.substring(0,i.length-1)):i,Gn=i=>{try{return new URL(i).host}catch{return null}},Nc=i=>Gn(i)??"",O_=i=>{let e={};try{let t=new URL(i),s="utm_";t.searchParams.forEach((r,n)=>{if(n.startsWith(s)){let o=n.substring(s.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},C_=i=>{let e=i;try{let t=new URL(i);e=t.origin+t.pathname+t.search}catch{}return e},P_=i=>i.replace(/\/{2,}/g,"/"),di=i=>{if(!te(i))return!1;try{return I(globalThis.URL)&&new URL(i),kp.test(i)}catch{return!1}},yn="none",bn="immediate",N_=i=>i?.statsCollection?.errors?.enabled===!0,D_=i=>i?.statsCollection?.metrics?.enabled===!0,x_=i=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(ie(i)){let t=G(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=pe(t.consentManagement,{enabled:d.consents.enabled.value}))}return e},Nl=i=>ht(i)||Array.isArray(i),L_=(i,e)=>{let{provider:t}=i,s=t?Cn[t]:void 0;return t&&!s&&(e.error(Pf(qe,t,Cn)),t=void 0),{provider:t,consentManagerPluginName:s}},Dc=(i,e)=>{let t,s=[],r=[],n=!1,o,a=i?.enabled===!0;ht(i)&&a&&({provider:o,consentManagerPluginName:t}=L_(i,e),Nl(i.allowedConsentIds)&&(s=i.allowedConsentIds,n=!0),Nl(i.deniedConsentIds)&&(r=i.deniedConsentIds,n=!0));let l={allowedConsentIds:s,deniedConsentIds:r};return a=a&&!!t,{provider:o,consentManagerPluginName:t,initialized:n,enabled:a,consentsData:l}},$_=()=>{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 s of e){let r=s.getAttribute("src");if(r&&t.test(r))return r}},F_=i=>{d.reporting.isErrorReportingEnabled.value=N_(i.source.config)&&!Fg(),d.reporting.isMetricsReportingEnabled.value=D_(i.source.config)},M_=i=>{let{useServerSideCookies:e,dataServiceEndpoint:t,storage:s,setCookieDomain:r,sameDomainCookiesOnly:n}=d.loadOptions.value,o=s?.cookie,a=!1,l;if(e){a=e;let u=o.domain??r,c=Y(u)&&!R_(ol(u))||n,h=I_(t??Ap,c);if(di(h)){l=ui(h);let g=Gn(window.location.href),f=Gn(h);g!==f&&(o={...o,samesite:"None",secure:!0}),!n&&c&&f!==ol(u)&&(a=!1,i.warn(Qf(qe,u,f)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},U_=i=>{let{storage:e}=d.loadOptions.value,t=e?.type;Y(t)&&!A_(t)&&(i.warn(Xf(qe,t,On)),t=On);let s=e?.encryption?.version,r=s&&Hs[s];!_e(s)&&_e(r)?(i.warn(Yf(qe,s,Hs,Bt)),s=Bt):_e(s)&&(s=Bt);let n=e?.migrate,o=n&&s===Bt;n===!0&&o!==n&&i.warn(Jf(qe,s,Bt));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:u}=M_(i);Ee(()=>{d.storage.type.value=t,d.storage.cookie.value=u,d.serverCookies.isEnabledServerSideCookies.value=a,d.serverCookies.dataServiceUrl.value=l,d.storage.encryptionPluginName.value=Hs[s],d.storage.migrate.value=o})},B_=i=>{let{provider:e,consentManagerPluginName:t,initialized:s,enabled:r,consentsData:n}=Dc(d.loadOptions.value.consentManagement,i),o=d.loadOptions.value.preConsent,a=o?.storage?.strategy??yn,l=["none","session","anonymousId"];Y(a)&&!l.includes(a)&&(a=yn,i.warn(gp(qe,o?.storage?.strategy,yn)));let u=o?.events?.delivery??bn,c=["immediate","buffer"];Y(u)&&!c.includes(u)&&(u=bn,i.warn(fp(qe,o?.events?.delivery,bn))),Ee(()=>{d.consents.activeConsentManagerPluginName.value=t,d.consents.initialized.value=s,d.consents.enabled.value=r,d.consents.data.value=n,d.consents.provider.value=e,d.consents.preConsent.value={enabled:d.loadOptions.value.preConsent?.enabled===!0&&s===!1&&r===!0,storage:{strategy:a},events:{delivery:u}}})},V_=i=>{let e=d.consents.resolutionStrategy.value,t;ie(i.consentManagementMetadata)&&(d.consents.provider.value&&(e=i.consentManagementMetadata.providers.find(s=>s.provider===d.consents.provider.value)?.resolutionStrategy??d.consents.resolutionStrategy.value),t=i.consentManagementMetadata),d.consents.provider.value==="custom"&&(e=void 0),Ee(()=>{d.consents.metadata.value=G(t),d.consents.resolutionStrategy.value=e})},G_=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(tp(qe)))),Ee(()=>{d.dataPlaneEvents.eventsQueuePluginName.value=t})}},j_=(i,e,t,s,r)=>{let n=new URLSearchParams({p:Ql,v:Wi,build:Yi,writeKey:e,lockIntegrationsVersion:t.toString(),lockPluginsVersion:s.toString()}),o=fc,a=n,l="/sourceConfig/",u="";if(di(i)){let c=new URL(i);ui(c.pathname).endsWith("/sourceConfig")||(c.pathname=`${ui(c.pathname)}/sourceConfig/`),c.pathname=P_(c.pathname),n.forEach((h,g)=>{c.searchParams.get(g)===null&&c.searchParams.set(g,h)}),o=c.origin,l=c.pathname,a=c.searchParams,u=c.hash}else r.warn(dp(qe,i));return`${o}${l}?${a}${u}`},H_=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:Lv(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===Ip})),xc=(i,e,t,s,r,n,o)=>{let a;if(n){if(!di(n))return o.error(Cf(qe,i,n)),null;a=ui(n)}else if(a=t,d.context.app.value.installType==="cdn"){let l=$_();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${no}/${Yi}/${e}$`),`/${s}/${Yi}/${e}`)),a},q_=(i,e,t,s)=>xc("integrations",or,hc,i,e,t,s),z_=(i,e,t,s)=>xc("plugins",dc,gc,i,e,t,s),jn=class{constructor(e,t,s){this.errorHandler=t,this.logger=s,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){tt(()=>{this.logger.setMinLogLevel(d.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:t,lockIntegrationsVersion:s,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=d.loadOptions.value,l=q_(Wi,s,n,this.logger);if(Ne(l))return;let u;u=z_(Wi,r,o,this.logger),u!==null&&(this.attachEffects(),d.lifecycle.activeDataplaneUrl.value=ui(d.lifecycle.dataPlaneUrl.value),U_(this.logger),B_(this.logger),G_(this.logger),Ee(()=>{d.lifecycle.integrationsCDNPath.value=l,d.lifecycle.pluginsCDNPath.value=u,e&&(d.lifecycle.logLevel.value=e),d.lifecycle.sourceConfigUrl.value=j_(t,d.lifecycle.writeKey.value,s,r,this.logger),d.metrics.metricsServiceUrl.value=`${d.lifecycle.activeDataplaneUrl.value}/${Tp}`,d.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,t,s){this.errorHandler.onError({error:e,context:qe,customMessage:t,groupingHash:s})}processConfig(e,t){if(!Y(e)){Y(t)?this.onError(t.error,yl):this.onError(new Error(yl));return}let s;try{te(e)?s=JSON.parse(e):s=e}catch(n){this.onError(n,_l);return}if(!w_(s)){this.onError(new Error(_l));return}if(s.source.enabled===!1){this.logger.error(Af);return}F_(s);let r=s.source.destinations.length>0?H_(s.source.destinations):[];Ee(()=>{d.source.value={config:s.source.config,name:s.source.name,id:s.source.id,workspaceId:s.source.workspaceId},d.nativeDestinations.configuredDestinations.value=r,d.plugins.pluginsToLoadFromConfig.value=d.loadOptions.value.plugins??[],V_(s),d.lifecycle.status.value="configured"})}getConfig(){let e=d.loadOptions.value.getSourceConfig;if(e){if(!I(e)){this.logger.error(Of(qe));return}let t=e();t instanceof Promise?t.then(s=>this.processConfig(s)).catch(s=>{this.onError(s,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:d.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},K_=()=>{let i=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return i?.[1]?i[1]:"NA"},Lc=(i=()=>document)=>i()?.referrer||"$direct",W_=(i=()=>document)=>{let t=i().getElementsByTagName("link"),s="";for(let r=0;t[r];r+=1){let n=t[r];if(n.getAttribute("rel")==="canonical"&&!s){s=n.getAttribute("href")??"";break}}return s},X_=(i=()=>globalThis.navigator)=>{let e=i();if(_e(e))return null;let{userAgent:t}=e,{brave:s}=e;if(s&&Object.getPrototypeOf(s).isBrave){let r=t.match(/(chrome)\/([\w.]+)/i);r&&(t=`${t} Brave/${r[2]}`)}return t},Y_=(i=()=>globalThis.navigator)=>{let e=i();return _e(e)?null:e.language??e.browserLanguage},$c=(i=()=>globalThis.location,e=()=>document)=>{let t=i(),s=W_(e),r=t.pathname,{href:n}=t,o=n,{search:a}=t;if(s)try{let h=new URL(s);h.search===""?o=s+a:o=s,r=h.pathname}catch{}let l=C_(o),{title:u}=e(),c=Lc(e);return{path:r,referrer:c,referring_domain:Nc(c),search:a,title:u,url:l,tab_url:n}},J_=(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()})},Q_=()=>{let i=globalThis.document.createElement("div");return i.setAttribute("data-a-b","c"),i.dataset?i.dataset.aB==="c":!1},Hn={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":()=>!Q_(),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)},Z_=()=>{let i=Object.keys(Hn),e=!1;for(let t=0;t<i.length;t++){let s=Hn[i[t]];if(I(s)&&s()){e=!0;break}}return e},em="https://polyfill-fastly.io/v3/polyfill.min.js",tm=`${em}?version=3.111.0&features=${Object.keys(Hn).join("%2C")}`,im=10*1e3,Dl="rudderstackPolyfill",sm=()=>!Je(globalThis.crypto)&&I(globalThis.crypto.getRandomValues),xl=()=>!Je(globalThis.navigator.userAgentData),rm=()=>!Je(globalThis.navigator.sendBeacon)&&I(globalThis.navigator.sendBeacon),Ll=()=>{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},qn=class{constructor(e,t,s){this.httpClient=e,this.errorHandler=t,this.logger=s,this.externalSrcLoader=new Zs(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Ee(()=>{d.capabilities.storage.isCookieStorageAvailable.value=li(Pe,Xe(Pe),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=li(Me,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=li(He,void 0,this.logger),d.capabilities.isBeaconAvailable.value=rm(),d.capabilities.isUaCHAvailable.value=xl(),d.capabilities.isCryptoAvailable.value=sm(),d.capabilities.isIE11.value=Wl(),d.capabilities.isOnline.value=globalThis.navigator.onLine,d.context.userAgent.value=X_(),d.context.locale.value=Y_(),d.context.screen.value=Ll(),d.context.timezone.value=K_(),xl()&&J_(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),tt(()=>{d.loadOptions.value.sendAdblockPage===!0&&d.lifecycle.sourceConfigUrl.value!==void 0&&yc(this.httpClient)})}prepareBrowserCapabilities(){d.capabilities.isLegacyDOM.value=Z_();let e=d.loadOptions.value.polyfillURL,t=tm;if(ci(e)&&(di(e)?t=e:this.logger.warn(_p(wn,e))),d.loadOptions.value.polyfillIfRequired&&d.capabilities.isLegacyDOM.value&&di(t)){let r=t!==d.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${d.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,t=`${t}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:t,id:Dl,async:!0,timeout:im,callback:n=>{n?r||this.onReady():this.onError(new Error(hp(Dl,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{d.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{d.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",cf(()=>{d.context.screen.value=Ll()},this))}onReady(){this.detectBrowserCapabilities(),d.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:wn,groupingHash:t})}},nm="web",om=["integrations","anonymousId","originalTimestamp"],$l=["library","consentManagement","userAgent","ua-ch","screen"],En=["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"],Fc=i=>typeof i=="number"&&!Number.isNaN(i),am=(i,e)=>e.toString().length>=i,ir=i=>Fc(i)&&i>=0&&Number.isInteger(i),Fl=10,Mc=i=>{let{cutOff:e}=i,t=Date.now();return!!(e?.enabled&&e.expiresAt&&t>e.expiresAt)},Ml=i=>!i.expiresAt||Date.now()>i.expiresAt||Mc(i),lm=()=>Date.now(),cm=(i,e)=>!i||!ir(i)||!am(Fl,i)?(e.warn(ap(Ut,i,Fl)),!1):!0,um=i=>{if(i?.enabled)return i.expiresAt??(ir(i.duration)?Date.now()+i.duration:void 0)},dm=i=>{let{timeout:e,cutOff:t}=i,s=Date.now();return{id:s,expiresAt:s+e,timeout:e,autoTrack:!0,...t&&{cutOff:t}}},hm=(i,e)=>({id:cm(i,e)?i:lm(),sessionStart:void 0,manualTrack:!0}),qi=i=>i===Pe||i===Me||i===He||i===et,zn=()=>sr(),gm=i=>{if(Eg(i)){let{entries:e,...t}=_n;return{...t,entries:{...e,anonymousId:i}}}return ie(i)&&ie(i.entries)?pe(_n,i):{..._n}},fm=i=>{let e=$c(),t={};return Object.keys(e).forEach(s=>{t[s]=i?.[s]||e[s]}),t.initial_referrer=i?.initial_referrer||d.session.initialReferrer.value,t.initial_referring_domain=i?.initial_referring_domain||d.session.initialReferringDomain.value,t},pm=(i,e)=>{let t=e?.page||{},s=i,r=$c();return Object.keys(r).forEach(n=>{_e(s[n])&&(s[n]=t[n]||r[n])}),_e(s.initial_referrer)&&(s.initial_referrer=t.initial_referrer||d.session.initialReferrer.value),_e(s.initial_referring_domain)&&(s.initial_referring_domain=t.initial_referring_domain||d.session.initialReferringDomain.value),s},kn=(i,e,t)=>{ie(i)&&Object.keys(i).forEach(s=>{(En.includes(s)||En.includes(s.toLowerCase()))&&t.warn(Zf(Kl,s,e,En))})},vm=(i,e)=>{let{properties:t,traits:s,context:r}=i,{traits:n}=r;kn(t,"properties",e),kn(s,"traits",e),kn(n,"context.traits",e)},_m=(i,e)=>{e.anonymousId&&te(e.anonymousId)&&(i.anonymousId=e.anonymousId),ht(e.integrations)&&(i.integrations=e.integrations),e.originalTimestamp&&te(e.originalTimestamp)&&(i.originalTimestamp=e.originalTimestamp)},mm=(i,e,t)=>{let s=i;return Object.keys(e).forEach(r=>{if(!om.includes(r)&&!$l.includes(r))if(r!=="context")s=pe(s,{[r]:e[r]});else if(!_e(e[r])&&ie(e[r])){let n={};Object.keys(e[r]).forEach(o=>{$l.includes(o)||(n[o]=e[r][o])}),s=pe(s,{...n})}else t.warn(ep(Kl))}),s},ym=(i,e,t)=>{ie(e)&&(_m(i,e),i.context=mm(i.context,e,t))},bm=i=>{let e;return d.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=d.consents.postConsent.value.integrations??d.nativeDestinations.loadOnlyIntegrations.value:i?e=i:e=uc,G(e)},Gi=(i,e,t,s)=>{let r={channel:nm,context:{traits:G(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:G(d.consents.data.value.deniedConsentIds),allowedConsentIds:G(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:O_(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:Ug(),messageId:sr(),userId:i.userId||d.session.userId.value};qi(d.storage.entries.value.anonymousId?.type)?r.anonymousId=d.session.anonymousId.value:r.anonymousId=zn(),d.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),i.type==="identify"&&(r.context.traits=d.storage.entries.value.userTraits?.type!==jt?G(d.session.userTraits.value):i.context.traits),i.type==="group"&&((i.groupId||d.session.groupId.value)&&(r.groupId=i.groupId||d.session.groupId.value),(i.traits||d.session.groupTraits.value)&&(r.traits=d.storage.entries.value.groupTraits?.type!==jt?G(d.session.groupTraits.value):i.traits));let n=pe(i,r);return n.event===void 0&&(n.event=null),n.properties===void 0&&(n.properties=null),ym(n,e,s),vm(n,s),n.integrations=bm(n.integrations),n},Kn=class{constructor(e){this.logger=e}generatePageEvent(e,t,s,r){let n=s??{};return n=pm(n,r),Gi({properties:n,name:t,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,t,s){return Gi({properties:t,event:e,type:"track"},s,void 0,this.logger)}generateIdentifyEvent(e,t,s){return Gi({userId:e,type:"identify",context:{traits:t}},s,void 0,this.logger)}generateAliasEvent(e,t,s){let n=Gi({previousId:t,type:"alias"},s,void 0,this.logger);return n.userId=e??n.userId,n}generateGroupEvent(e,t,s){let r={type:"group"};return e&&(r.groupId=e),t&&(r.traits=t),Gi(r,s,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}},Wn=class{constructor(e,t,s,r){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=s,this.logger=r,this.eventFactory=new Kn(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)}},Xn=class{constructor(e,t,s,r,n){this.storeManager=t,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=s,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:e,anonymousIdOptions:t}=d.loadOptions.value,s;ci(e)&&typeof e=="string"&&(s=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(s??this.getAnonymousId(t)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),s=this.getSessionInfo()??X.sessionInfo;e={autoTrack:t.autoTrack&&s.manualTrack!==!0,timeout:t.timeout,manualTrack:s.manualTrack,expiresAt:s.expiresAt,id:s.id,sessionStart:s.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=X.sessionInfo:t.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:s.cutOff?.expiresAt})}else e=X.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 s=e||Lc();this.setInitialReferrer(s),this.setInitialReferringDomain(Nc(s))}}isPersistenceEnabledForStorageEntry(e){return qi(d.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=d.storage.entries.value,t=[Pe,Me,He];Object.keys(e).forEach(s=>{let r=s,n=e[r]?.type,o=this.storeManager?.getStore(ai[n]);o&&t.forEach(a=>{let l=this.storeManager?.getStore(ai[a]);if(l&&a!==n){let u=l.get(oi[r]);bg(u)&&o.set(oi[r],u),l.remove(oi[r])}})})}migrateStorageIfNeeded(e,t){if(!d.storage.migrate.value)return;let s=e??[];s.length===0&&[Tc,Ic,Rc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&s.push(a)}),(t??Object.keys(oi)).forEach(n=>{let o=oi[n];s.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,s=d.loadOptions.value.sessions?.timeout;ir(s)?t=s:(this.logger.warn(ip(Ut,s,An)),t=An),t===0&&(this.logger.warn(np(Ut)),e=!1),t>0&&t<fl&&this.logger.warn(op(Ut,t,fl));let r=this.getCutOffInfo(t);return{timeout:t,autoTrack:e,cutOff:r}}getCutOffInfo(e){let t=d.loadOptions.value.sessions.cutOff,s,r=!1;return t.enabled===!0&&(s=t.duration,r=!0,ir(s)?s<e&&(this.logger.warn(rp(Ut,s,e)),r=!1):(this.logger.warn(sp(Ut,s,gl)),s=gl)),{enabled:r,duration:s}}onError(e,t,s){this.errorHandler.onError({error:e,context:Ut,customMessage:t,groupingHash:s})}getEncryptedCookieData(e,t){let s=[];return e.forEach(r=>{let n=t?.encrypt(Ye(r.value,!1,[],this.logger));ci(n)&&s.push({name:r.name,value:n})}),s}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:d.serverCookies.dataServiceUrl.value,options:{method:"POST",data:Ye({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,s){let r=Object.keys(e),n=()=>r.map(u=>({name:e[u].name,value:d.session[u].value})),o={};r.forEach(u=>{o[e[u].name]=s?.get(e[u].name)});let a=()=>{r.forEach(u=>{this.serverSideCookiesRequestInProgress[u]=!1})},l=()=>{n().forEach(u=>{t&&t(u.name,u.value)})};try{let u={};r.forEach(h=>{u[e[h].name]=d.session[h].value});let c=this.getEncryptedCookieData(n(),s);c.length>0?this.makeRequestToSetCookie(c,(h,g)=>{a(),g?.xhr?.status===200?n().forEach(f=>{let v=o[f.name],p=s?.get(f.name);Ye(u[f.name],!1,[])!==Ye(p,!1,[])&&(Ne(v)&&Ne(p)&&this.logger.error(Wf(f.name)),t&&t(f.name,f.value))}):(this.logger.error(Kf(g?.xhr?.status)),l())}):(l(),a())}catch(u){this.onError(u,bl,bl),l(),a()}}syncValueToStorage(e){let t=d.storage.entries.value,s=t[e]?.type;if(qi(s)){let r=this.storeManager.getStore(ai[s]),n=t[e]?.key,o=d.session[e].value;o&&(te(o)||ht(o))?d.serverCookies.isEnabledServerSideCookies.value&&s===Pe?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{let a={[e]:{name:n}};this.setServerSideCookies(a,(l,u)=>{r?.set(l,u)},r)},Cp)):r?.set(n,o):r?.remove(n)}}registerEffects(){Oc.forEach(e=>{tt(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let s=e;(!te(e)||!s)&&(s=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!s&&t&&(s=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t)),s=s||zn()):s=X.anonymousId,d.session.anonymousId.value=s}getAnonymousId(e){let t=d.storage.entries.value.anonymousId?.type;if(qi(t)){let s=d.session.anonymousId.value;(!s||s===X.anonymousId)&&(s=this.getEntryValue("anonymousId")),!s&&e&&(s=this.pluginsManager?.invokeSingle("storage.getAnonymousId",Xe,e)),d.session.anonymousId.value=s||zn()}return d.session.anonymousId.value}getEntryValue(e){let t=d.storage.entries.value,s=t[e]?.type;if(qi(s)){let r=this.storeManager?.getStore(ai[s]);this.migrateStorageIfNeeded([r],[e]);let n=t[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let t=Xe(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()??X.sessionInfo;return e.autoTrack&&!Ml(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??X.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:s,timeout:r,cutOff:n}=e.sessionInfo.value;if(s){let o={...X.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){let{session:t}=d,s=gm(e);Ee(()=>{Object.keys(X).forEach(r=>{let n=r;if(s.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[n].value=X[n];break}})})}setUserId(e){d.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:X.userId}setUserTraits(e){d.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&ie(e)?pe(d.session.userTraits.value??X.userTraits,e):X.userTraits}setGroupId(e){d.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:X.groupId}setGroupTraits(e){d.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&ie(e)?pe(d.session.groupTraits.value??X.groupTraits,e):X.groupTraits}setInitialReferrer(e){d.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:X.initialReferrer}setInitialReferringDomain(e){d.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:X.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if(Ml(e))t=dm(e);else{let s=Date.now(),r=e.timeout;t.expiresAt=s+r}if(Mc(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){let s=um(t.cutOff);t.cutOff.expiresAt=s}d.session.sessionInfo.value=t}start(e){d.session.sessionInfo.value=hm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){d.session.sessionInfo.value=X.sessionInfo}setAuthToken(e){d.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:X.authToken}},Em=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],km=Em,Sm=(i,e)=>{let t=G(e);return te(t.setCookieDomain)||(t.setCookieDomain=void 0),["Strict","Lax","None"].includes(t.sameSiteCookie)||(t.sameSiteCookie=void 0),t.secureCookie=Ze(t.secureCookie,i.secureCookie),t.sameDomainCookiesOnly=Ze(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=km),t.useGlobalIntegrationsConfigInEvents=Ze(t.useGlobalIntegrationsConfigInEvents,i.useGlobalIntegrationsConfigInEvents),t.bufferDataPlaneEventsUntilReady=Ze(t.bufferDataPlaneEventsUntilReady,i.bufferDataPlaneEventsUntilReady),t.sendAdblockPage=Ze(t.sendAdblockPage,i.sendAdblockPage),t.useServerSideCookies=Ze(t.useServerSideCookies,i.useServerSideCookies),te(t.dataServiceEndpoint)||(t.dataServiceEndpoint=void 0),t.sendAdblockPageOptions=lt(t.sendAdblockPageOptions),t.loadIntegration=Ze(t.loadIntegration,i.loadIntegration),ht(t.storage)?(t.storage.migrate=Ze(t.storage.migrate,i.storage?.migrate),t.storage.cookie=lt(t.storage.cookie),t.storage.encryption=lt(t.storage.encryption),t.storage=Ys(t.storage)):t.storage=void 0,t.destinationsQueueOptions=lt(t.destinationsQueueOptions),t.queueOptions=lt(t.queueOptions),t.lockIntegrationsVersion=Ze(t.lockIntegrationsVersion,i.lockIntegrationsVersion),t.lockPluginsVersion=Ze(t.lockPluginsVersion,i.lockPluginsVersion),Fc(t.dataPlaneEventsBufferTimeout)||(t.dataPlaneEventsBufferTimeout=void 0),t.beaconQueueOptions=lt(t.beaconQueueOptions),t.preConsent=lt(t.preConsent),t.sourceConfigurationOverride=lt(t.sourceConfigurationOverride),pe(i,Ys(t))},Ul="dataplaneEventsQueue",Bl="destinationsEventsQueue",wm="transformEvent",Am=(i,e)=>Object.keys(i).filter(t=>i[t]!==!0||!e[t]).reduce((t,s)=>{let r=G(t);return r[s]=i[s],r},{}),Tm=(i,e)=>{let t=G(i),s=e.nativeDestinations.integrationsConfig.value,r=Am(i.integrations,s);return t.integrations=pe(s,r),t},Im=i=>i.consents.preConsent.value.enabled&&i.consents.preConsent.value.events?.delivery==="buffer",Xs=(i,e,t,s)=>{if(Y(i))if(I(i))try{i(...e)}catch(r){s.error(up(t),r)}else s.error(cc(t))},Yn=class{constructor(e,t,s,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=s,this.logger=n,this.storeManager=t}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${Ul}.init`,d,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${wm}.init`,d,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${Bl}.init`,d,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),tt(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=Im(d),t;tt(()=>{let s=d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&d.nativeDestinations.clientDestinationsReady.value===!1;(d.nativeDestinations.activeDestinations.value.some(n=>xv(n))===!1||s===!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 s=Tm(e,d);this.pluginsManager.invokeSingle(`${Ul}.enqueue`,d,this.dataplaneEventsQueue,s,this.errorHandler,this.logger);let r=G(e);this.pluginsManager.invokeSingle(`${Bl}.enqueue`,d,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${io}`;Xs(t,[s],n,this.logger)}},Vl=i=>{let e=new CustomEvent(i,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},Rm=i=>te(i)&&i.trim().length>0,Om=i=>di(i),Jn=class{constructor(){this.preloadBuffer=new In,this.initialized=!1,this.errorHandler=kc,this.logger=gt,this.externalSrcLoader=new Zs(this.logger),this.httpClient=mc,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new qn(this.httpClient,this.errorHandler,this.logger)}load(e,t,s={}){if(!d.lifecycle.status.value){if(!Rm(e)){this.logger.error(Bf(Ms,e));return}if(!Om(t)){this.logger.error(Vf(Ms,t));return}Ee(()=>{d.lifecycle.writeKey.value=G(e),d.lifecycle.dataPlaneUrl.value=G(t),d.loadOptions.value=Sm(d.loadOptions.value,s),d.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(d.loadOptions.value.logLevel??ac),Xi("state",d,e),this.startLifecycle()}}startLifecycle(){tt(()=>{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:Ms,customMessage:t,groupingHash:t})}})}onBrowserCapabilitiesReady(){gf(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(G(t)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&ff([...e],this)}}prepareInternalServices(){this.pluginsManager=new xn(Nv,this.errorHandler,this.logger),this.storeManager=new Vn(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new jn(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Xn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Yn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Wn(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(),Ee(()=>{d.lifecycle.loaded.value=!0,d.lifecycle.status.value="loaded"}),this.initialized=!0;let e=d.loadOptions.value.onLoaded;Xs(e,[globalThis.rudderanalytics],Cg,this.logger),Vl("RSA_Initialised")}onReady(){d.lifecycle.status.value="readyExecuted",d.eventBuffer.readyCallbacksArray.value.forEach(e=>{Xs(e,[],pn,this.logger)}),Vl("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 s=t[0];I(this[s])&&this[s](...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),tt(()=>{(e===0||d.nativeDestinations.initializedDestinations.value.length+d.nativeDestinations.failedDestinations.value.length===e)&&Ee(()=>{d.lifecycle.status.value="destinationsReady",d.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){d.lifecycle.status.value!=="ready"&&Ee(()=>{d.lifecycle.status.value="ready"})}ready(e,t=!1){let s="ready";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),!I(e)){this.logger.error(cc(pn));return}d.lifecycle.status.value==="readyExecuted"?Xs(e,[],pn,this.logger):d.eventBuffer.readyCallbacksArray.value=[...d.eventBuffer.readyCallbacksArray.value,e]}page(e,t=!1){let s="page";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),d.capabilities.isAdBlocked.value===!0&&e.category!==ul&&this.page(Qs(ul,Qg,{path:Zg},d.loadOptions.value.sendAdblockPageOptions))}track(e,t=!1){let s="track";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event - ${e.name}`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:s,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,t=!1){let s="identify";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,e.userId&&d.session.userId.value&&e.userId!==d.session.userId.value&&this.reset(),Ne(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:s,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,t=!1){let s="alias";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:s,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,t=!1){let s="group";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,Ne(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:s,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,t=!1){let s="reset";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,t,s=!1){let r="setAnonymousId";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,t]];return}this.errorHandler.leaveBreadcrumb(`New ${r} 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 s="startSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let 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 s="consent";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Ee(()=>{d.consents.preConsent.value={...d.consents.preConsent.value,enabled:!1},d.consents.postConsent.value=x_(e);let{initialized:r,consentsData:n}=Dc(d.consents.postConsent.value.consentManagement,this.logger);d.consents.initialized.value=r,d.consents.data.value=n}),d.consents.enabled.value&&!d.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(t)}sendTrackingEvents(e){if(d.consents.postConsent.value.trackConsent){let t=to(ef);e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(d.consents.postConsent.value.sendPageEvent){let t=Qs();e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,s=!1){let r="addCustomIntegration";if(s)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,d,this.logger);else{if(d.lifecycle.loaded.value){this.logger.error(Ep(Ms,e));return}d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,t]]}}},Vt=class Vt{constructor(){re(this,"analyticsInstances",{});re(this,"defaultAnalyticsKey","");re(this,"logger",gt);try{if(Vt.globalSingleton)return Vt.globalSingleton;Vt.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.getSessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),Vt.globalSingleton=this,d.autoTrack.pageLifecycle.pageViewId.value=sr(),d.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){ce(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(){kc.init(),lo.configure(),oo.configure(),ao.configure(),tr.configure()}setDefaultInstanceKey(e){te(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;return(!te(t)||!t)&&(t=this.defaultAnalyticsKey),this.analyticsInstances[t]||(this.analyticsInstances[t]=new Jn),this.analyticsInstances[t]}catch(t){ce(t);return}}load(e,t,s){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(s);let r=ec(zi);hf(r),Xi(zi,G(r)),this.getAnalyticsInstance(e)?.load(e,t,j(s))}catch(r){ce(r)}}trackPageLifecycleEvents(e){let{autoTrack:t,useBeacon:s}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=t??{},{events:a=[fn.UNLOADED],enabled:l=r,options:u=n}=o??{};d.autoTrack.pageLifecycle.enabled.value=l,d.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,s,u)}setupPageUnloadTracking(e,t,s){(e.length===0||e.includes(fn.UNLOADED))&&(t===!0?Mg(r=>{if(r===!1&&d.lifecycle.loaded.value){let n=Date.now(),o=n-d.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(fn.UNLOADED,{timeOnPage:o},{...s,originalTimestamp:Xl(new Date(n))})}},!0):this.logger.warn(mp(Ng)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=df(e);Xi(zi,G([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(j(e))}catch(t){ce(t)}}page(e,t,s,r,n){try{this.getAnalyticsInstance()?.page(Qs(j(e),j(t),j(s),j(r),j(n)))}catch(o){ce(o)}}track(e,t,s,r){try{this.getAnalyticsInstance()?.track(to(j(e),j(t),j(s),j(r)))}catch(n){ce(n)}}identify(e,t,s,r){try{this.getAnalyticsInstance()?.identify(Hl(j(e),j(t),j(s),j(r)))}catch(n){ce(n)}}alias(e,t,s,r){try{this.getAnalyticsInstance()?.alias(ql(j(e),j(t),j(s),j(r)))}catch(n){ce(n)}}group(e,t,s,r){try{this.getAnalyticsInstance()?.group(zl(j(e),j(t),j(s),j(r)))}catch(n){ce(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(j(e))}catch(t){ce(t)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(j(e))}catch(t){ce(t);return}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(j(e),j(t))}catch(s){ce(s)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){ce(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){ce(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){ce(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){ce(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(j(e))}catch(t){ce(t)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){ce(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){ce(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(j(e))}catch(t){ce(t)}}consent(e){try{this.getAnalyticsInstance()?.consent(j(e))}catch(t){ce(t)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(j(e),j(t))}catch(s){ce(s)}}};re(Vt,"globalSingleton",null);hi=Vt});var Bc,Vc,uo,Uc,Gc,jc,Hc,qc,Ji=Re(()=>{"use strict";Bc="https://deriv.com/cdn-cgi/trace",Vc="https://cdn.growthbook.io",uo="https://deriv-dataplane.rudderstack.com",Uc="https://ph.deriv.com",Gc="https://us.posthog.com",jc=()=>{if(typeof window>"u")return Uc;let i=window.location.hostname;return i.includes(".deriv.me")?"https://ph.deriv.me":i.includes(".deriv.be")?"https://ph.deriv.be":i.includes(".deriv.ae")?"https://ph.deriv.ae":Uc},Hc=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],qc=["deriv.com","derivcrypto.com","besquare.my","besquare.com.my","ewallet.exchange","champion-fx.com","opalstraits.com","binary.com","binary.marketing","championgbs.com","4x.my","re-work.dev","regentmarkets.com","4x.com","binary.me","deriv.team","firstsource.io","firstsource.tech","deriv.hr","vmgbpo.net","mailisk.net","mailosaur.net","mobileapps.mailisk.net","w3e180zd.mailosaur.net"]});function lr(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)i[s]=t[s]}return i}function ho(i,e){function t(r,n,o){if(!(typeof document>"u")){o=lr({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)o[l]&&(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=r+"="+i.write(n,r)+a}}function s(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var n=document.cookie?document.cookie.split("; "):[],o={},a=0;a<n.length;a++){var l=n[a].split("="),u=l.slice(1).join("=");try{var c=decodeURIComponent(l[0]);if(o[c]=i.read(u,c),r===c)break}catch{}}return r?o[r]:o}}return Object.create({set:t,get:s,remove:function(r,n){t(r,"",lr({},n,{expires:-1}))},withAttributes:function(r){return ho(this.converter,lr({},this.attributes,r))},withConverter:function(r){return ho(lr({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(i)}})}var Cm,zc,Kc=Re(()=>{"use strict";Cm={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)}};zc=ho(Cm,{path:"/"})});var it,ur,Qi,cr,Wc,Ht,Xc,Yc,pi=Re(()=>{"use strict";Kc();Ji();it=(i,e)=>(...t)=>{e()&&console.log(`[ANALYTIC]${i}`,...t)},ur=i=>{let e=i.split("@")[1]?.toLowerCase();return e?qc.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),cr=null,Wc=async()=>{if(cr)return cr;let i=JSON.parse(zc.get("website_status")||"{}")?.clients_country;return cr=(async()=>{try{let e=await fetch(Bc).catch(()=>null);if(!e)return i||"";let t=await e.text().catch(()=>"");return t?Object.fromEntries(t.split(`
14
+ `).map(r=>r.split("=",2))).loc?.toLowerCase()||i||"":i||""}catch{return i||""}})(),cr},Ht=i=>{if(i==null||typeof i!="object")return i;if(Array.isArray(i)){let s=[];for(let r=0;r<i.length;r++){let n=Ht(i[r]);n!=null&&s.push(n)}return s.length?s:void 0}let e={},t=!1;for(let s in i){if(!Object.prototype.hasOwnProperty.call(i,s))continue;let r=Ht(i[s]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[s]=r,t=!0)}return t?e:void 0},Xc=(i,e)=>{for(let t in i){if(!Object.prototype.hasOwnProperty.call(i,t))continue;let s=i[t];s&&typeof s=="object"&&!Array.isArray(s)?Xc(s,e):e[t]=s}},Yc=i=>{if(i==null||typeof i!="object"||Array.isArray(i))return i;let e={};return Xc(i,e),e}});function nu(){return ru}function fo(i){let e=2166136261,t=i.length;for(let s=0;s<t;s++)e^=i.charCodeAt(s),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Zi(i,e,t){return t===2?fo(fo(i+e)+"")%1e4/1e4:t===1?fo(e+i)%1e3/1e3:null}function Nm(i){return i<=0?[]:new Array(i).fill(1/i)}function fr(i,e){return i>=e[0]&&i<e[1]}function ou(i,e){let t=Zi("__"+e[0],i,1);return t===null?!1:t>=e[1]&&t<e[2]}function au(i,e){for(let t=0;t<e.length;t++)if(fr(i,e[t]))return t;return-1}function vo(i){try{let e=i.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function pr(i,e){if(!e.length)return!1;let t=!1,s=!1;for(let r=0;r<e.length;r++){let n=Lm(i,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else t=!0,n&&(s=!0)}return s||!t}function Dm(i,e,t){try{let s=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(s="\\/?"+s.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+s+"$","i").test(i)}catch{return!1}}function xm(i,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),s=[[i.host,t.host,!1],[i.pathname,t.pathname,!0]];return t.hash&&s.push([i.hash,t.hash,!1]),t.searchParams.forEach((r,n)=>{s.push([i.searchParams.get(n)||"",r,!1])}),!s.some(r=>!Dm(r[0],r[1],r[2]))}catch{return!1}}function Lm(i,e,t){try{let s=new URL(i,"https://_");if(e==="regex"){let r=vo(t);return r?r.test(s.href)||r.test(s.href.substring(s.origin.length)):!1}else if(e==="simple")return xm(s,t);return!1}catch{return!1}}function lu(i,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let s=Nm(i);t=t||s,t.length!==i&&(t=s);let r=t.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(t=s);let n=0;return t.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function cu(i,e,t){if(!e)return null;let s=e.split("?")[1];if(!s)return null;let r=s.replace(/#.*/,"").split("&").map(n=>n.split("=",2)).filter(([n])=>n===i).map(([,n])=>parseInt(n));return r.length>0&&r[0]>=0&&r[0]<t?r[0]:null}function uu(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||ru.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let s=await t.importKey("raw",po(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=i.split("."),o=await t.decrypt({name:"AES-CBC",iv:po(r)},s,po(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function es(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 du(){let i;try{i="1.6.5"}catch{i=""}return i}function hu(i,e){let t,s;try{t=new URL(i),s=new URL(e)}catch(r){return console.error(`Unable to merge query strings: ${r}`),e}return t.searchParams.forEach((r,n)=>{s.searchParams.has(n)||s.searchParams.set(n,r)}),s.toString()}function su(i){return typeof i=="object"&&i!==null}function vr(i){return i.urlPatterns&&i.variations.some(e=>su(e)&&"urlRedirect"in e)?"redirect":i.variations.some(e=>su(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function _r(i,e){return new Promise(t=>{let s=!1,r,n=o=>{s||(s=!0,r&&clearTimeout(r),t(o||null))};e&&(r=setTimeout(()=>n(),e)),i.then(o=>n(o)).catch(()=>n())})}var ru,po,ts=Re(()=>{"use strict";ru={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};po=i=>Uint8Array.from(atob(i),e=>e.charCodeAt(0))});function pu(i){Object.assign(ke,i),ke.backgroundSync||ko()}async function vu({instance:i,timeout:e,skipCache:t,allowStale:s,backgroundSync:r}){return r||(ke.backgroundSync=!1),Um({instance:i,allowStale:s,timeout:e,skipCache:t})}function $m(i){let e=is(i),t=mi.get(e)||new Set;t.add(i),mi.set(e,t)}function _u(i){mi.forEach(e=>e.delete(i))}function Fm(){yi.forEach(i=>{i&&(i.state="idle",bo(i))})}function Mm(){yi.forEach(i=>{i&&i.state==="idle"&&Eo(i)})}async function fu(){try{if(!st.localStorage)return;await st.localStorage.setItem(ke.cacheKey,JSON.stringify(Array.from(ft.entries())))}catch{}}async function Um({instance:i,allowStale:e,timeout:t,skipCache:s}){let r=is(i),n=mo(i),o=new Date,a=new Date(o.getTime()-ke.maxAge+ke.staleTTL);await Bm();let l=!ke.disableCache&&!s?ft.get(n):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&bi.add(r),l.staleAt<o?_o(i):yo(i),{data:l.data,success:!0,source:"cache"}):await _r(_o(i),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function is(i){let[e,t]=i.getApiInfo();return`${e}||${t}`}function mo(i){let e=is(i);if(!("isRemoteEval"in i)||!i.isRemoteEval())return e;let t=i.getAttributes(),s=i.getCacheKeyAttributes()||Object.keys(i.getAttributes()),r={};s.forEach(a=>{r[a]=t[a]});let n=i.getForcedVariations(),o=i.getUrl();return`${e}||${JSON.stringify({ca:r,fv:n,url:o})}`}async function Bm(){if(!gu){gu=!0;try{if(st.localStorage){let i=await st.localStorage.getItem(ke.cacheKey);if(!ke.disableCache&&i){let e=JSON.parse(i);e&&Array.isArray(e)&&e.forEach(([t,s])=>{ft.set(t,{...s,staleAt:new Date(s.staleAt)})}),mu()}}}catch{}if(!ke.disableIdleStreams){let i=_i.startIdleListener();i&&(_i.stopIdleListener=i)}}}function mu(){let i=Array.from(ft.entries()).map(([t,s])=>({key:t,staleAt:s.staleAt.getTime()})).sort((t,s)=>t.staleAt-s.staleAt),e=Math.min(Math.max(0,ft.size-ke.maxEntries),ft.size);for(let t=0;t<e;t++)ft.delete(i[t].key)}function yu(i,e,t){let s=t.dateUpdated||"",r=new Date(Date.now()+ke.staleTTL),n=ke.disableCache?void 0:ft.get(e);if(n&&s&&n.version===s){n.staleAt=r,fu();return}ke.disableCache||(ft.set(e,{data:t,version:s,staleAt:r,sse:bi.has(i)}),mu()),fu();let o=mi.get(i);o&&o.forEach(a=>Vm(a,t))}async function Vm(i,e){await i.setPayload(e||i.getPayload())}async function _o(i){let{apiHost:e,apiRequestHeaders:t}=i.getApiHosts(),s=i.getClientKey(),r="isRemoteEval"in i&&i.isRemoteEval(),n=is(i),o=mo(i),a=mr.get(o);return a||(a=(r?_i.fetchRemoteEvalCall({host:e,clientKey:s,payload:{attributes:i.getAttributes(),forcedVariations:i.getForcedVariations(),forcedFeatures:Array.from(i.getForcedFeatures().entries()),url:i.getUrl()},headers:t}):_i.fetchFeaturesCall({host:e,clientKey:s,headers:t})).then(u=>{if(!u.ok)throw new Error(`HTTP error: ${u.status}`);return u.headers.get("x-sse-support")==="enabled"&&bi.add(n),u.json()}).then(u=>(yu(n,o,u),yo(i),mr.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(mr.delete(o),{data:null,source:"error",success:!1,error:u})),mr.set(o,a)),a}function yo(i,e=!1){let t=is(i),s=mo(i),{streamingHost:r,streamingHostRequestHeaders:n}=i.getApiHosts(),o=i.getClientKey();if(e&&bi.add(t),ke.backgroundSync&&bi.has(t)&&st.EventSource){if(yi.has(t))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let u=mi.get(t);u&&u.forEach(c=>{_o(c)})}else if(l.type==="features"){let u=JSON.parse(l.data);yu(t,s,u)}a.errors=0}catch{bu(a)}},errors:0,state:"active"};yi.set(t,a),Eo(a)}}function bu(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);bo(i),setTimeout(()=>{["idle","active"].includes(i.state)||Eo(i)},Math.min(e,3e5))}}function bo(i){i.src&&(i.src.onopen=null,i.src.onerror=null,i.src.close(),i.src=null,i.state==="active"&&(i.state="disabled"))}function Eo(i){i.src=_i.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=()=>bu(i),i.src.onopen=()=>{i.errors=0}}function Gm(i,e){bo(i),yi.delete(e)}function ko(){bi.clear(),yi.forEach(Gm),mi.clear(),_i.stopIdleListener()}function yr(i,e){if(e.streaming){if(!i.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&yo(i,!0),$m(i)}}var ke,st,_i,mi,gu,ft,mr,yi,bi,Eu=Re(()=>{"use strict";ts();ke={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},st=nu(),_i={fetchFeaturesCall:({host:i,clientKey:e,headers:t})=>st.fetch(`${i}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:i,clientKey:e,payload:t,headers:s})=>{let r={method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)};return st.fetch(`${i}/api/eval/${e}`,r)},eventSourceCall:({host:i,clientKey:e,headers:t})=>t?new st.EventSource(`${i}/sub/${e}`,{headers:t}):new st.EventSource(`${i}/sub/${e}`),startIdleListener:()=>{let i;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(i),Mm()):document.visibilityState==="hidden"&&(i=window.setTimeout(Fm,ke.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(st.localStorage=globalThis.localStorage)}catch{}mi=new Map,gu=!1,ft=new Map,mr=new Map,yi=new Map,bi=new Set});function Hm(i){return i==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[i]}}function wr(i){var e=Sr.get(i);return e||(e={element:i,attributes:{}},Sr.set(i,e)),e}function Ar(i,e,t,s,r){var n=t(i),o={isDirty:!1,originalValue:n,virtualValue:n,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,r(o))}}),mutationRunner:r,setValue:s,getCurrentValue:t};return e==="position"&&i.parentNode?o.observer.observe(i.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(i,Hm(e)),o}function Tr(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,ku()):i!==t&&(e.isDirty=!0,ku())}function qm(i){var e=i.originalValue;i.mutations.forEach(function(t){return e=t.mutate(e)}),Tr(ny(e),i)}function zm(i){var e=new Set(i.originalValue.split(/\s+/).filter(Boolean));i.mutations.forEach(function(t){return t.mutate(e)}),Tr(Array.from(e).filter(Boolean).join(" "),i)}function Km(i){var e=i.originalValue;i.mutations.forEach(function(t){return e=t.mutate(e)}),Tr(e,i)}function Wm(i){var e=i.parentSelector,t=i.insertBeforeSelector,s=document.querySelector(e);if(!s)return null;var r=t?document.querySelector(t):null;return t&&!r?null:{parentNode:s,insertBeforeNode:r}}function Xm(i){var e=i.originalValue;i.mutations.forEach(function(t){var s=t.mutate(),r=Wm(s);e=r||e}),Tr(e,i)}function wu(i){var e=wr(i);return e.html||(e.html=Ar(i,"html",Ym,Jm,qm)),e.html}function Au(i){var e=wr(i);return e.position||(e.position=Ar(i,"position",Qm,Zm,Xm)),e.position}function Tu(i){var e=wr(i);return e.classes||(e.classes=Ar(i,"class",ty,ey,zm)),e.classes}function Iu(i,e){var t=wr(i);return t.attributes[e]||(t.attributes[e]=Ar(i,e,iy(e),sy(e),Km)),t.attributes[e]}function ry(i,e){var t=Sr.get(i);if(t)if(e==="html"){var s,r;(s=t.html)==null||(r=s.observer)==null||r.disconnect(),delete t.html}else if(e==="class"){var n,o;(n=t.classes)==null||(o=n.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var u,c,h;(u=t.attributes)==null||(c=u[e])==null||(h=c.observer)==null||h.disconnect(),delete t.attributes[e]}}function ny(i){return br||(br=document.createElement("div")),br.innerHTML=i,br.innerHTML}function Er(i,e,t){if(t.isDirty){t.isDirty=!1;var s=t.virtualValue;t.mutations.length||ry(i,e),t.setValue(i,s)}}function oy(i,e){i.html&&Er(e,"html",i.html),i.classes&&Er(e,"class",i.classes),i.position&&Er(e,"position",i.position),Object.keys(i.attributes).forEach(function(t){Er(e,t,i.attributes[t])})}function ku(){Sr.forEach(oy)}function ay(i,e){var t=null;i.kind==="html"?t=wu(e):i.kind==="class"?t=Tu(e):i.kind==="attribute"?t=Iu(e,i.attribute):i.kind==="position"&&(t=Au(e)),t&&(t.mutations.push(i),t.mutationRunner(t))}function ly(i,e){var t=null;if(i.kind==="html"?t=wu(e):i.kind==="class"?t=Tu(e):i.kind==="attribute"?t=Iu(e,i.attribute):i.kind==="position"&&(t=Au(e)),!!t){var s=t.mutations.indexOf(i);s!==-1&&t.mutations.splice(s,1),t.mutationRunner(t)}}function Ru(i){if(!(i.kind==="position"&&i.elements.size===1)){var e=new Set(i.elements),t=document.querySelectorAll(i.selector);t.forEach(function(s){e.has(s)||(i.elements.add(s),ay(i,s))})}}function cy(i){i.elements.forEach(function(e){return ly(i,e)}),i.elements.clear(),To.delete(i)}function Su(){To.forEach(Ru)}function uy(){typeof document>"u"||(So||(So=new MutationObserver(function(){Su()})),Su(),So.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Ir(i){return typeof document>"u"?Ao:(To.add(i),Ru(i),{revert:function(){cy(i)}})}function wo(i,e){return Ir({kind:"html",elements:new Set,mutate:e,selector:i})}function Ou(i,e){return Ir({kind:"position",elements:new Set,mutate:e,selector:i})}function ss(i,e){return Ir({kind:"class",elements:new Set,mutate:e,selector:i})}function kr(i,e,t){return jm.test(e)?e==="class"||e==="className"?ss(i,function(s){var r=t(Array.from(s).join(" "));s.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return s.add(n)})}):Ir({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:i}):Ao}function dy(i){var e=i.selector,t=i.action,s=i.value,r=i.attribute,n=i.parentSelector,o=i.insertBeforeSelector;if(r==="html"){if(t==="append")return wo(e,function(a){return a+(s??"")});if(t==="set")return wo(e,function(){return s??""})}else if(r==="class"){if(t==="append")return ss(e,function(a){s&&a.add(s)});if(t==="remove")return ss(e,function(a){s&&a.delete(s)});if(t==="set")return ss(e,function(a){a.clear(),s&&a.add(s)})}else if(r==="position"){if(t==="set"&&n)return Ou(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(t==="append")return kr(e,r,function(a){return a!==null?a+(s??""):s??""});if(t==="set")return kr(e,r,function(){return s??""});if(t==="remove")return kr(e,r,function(){return null})}return Ao}var jm,Ao,Sr,To,Ym,Jm,Qm,Zm,ey,ty,iy,sy,br,So,hy,Cu,Pu=Re(()=>{"use strict";jm=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Ao={revert:function(){}},Sr=new Map,To=new Set;Ym=function(e){return e.innerHTML},Jm=function(e,t){return e.innerHTML=t};Qm=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Zm=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};ey=function(e,t){return t?e.className=t:e.removeAttribute("class")},ty=function(e){return e.className};iy=function(e){return function(t){var s;return(s=t.getAttribute(e))!=null?s:null}},sy=function(e){return function(t,s){return s!==null?t.setAttribute(e,s):t.removeAttribute(e)}};uy();hy={html:wo,classes:ss,attribute:kr,position:Ou,declarative:dy},Cu=hy});function Rt(i,e,t){t=t||{};for(let[s,r]of Object.entries(e))switch(s){case"$or":if(!xu(i,r,t))return!1;break;case"$nor":if(xu(i,r,t))return!1;break;case"$and":if(!_y(i,r,t))return!1;break;case"$not":if(Rt(i,r,t))return!1;break;default:if(!rs(r,gy(i,s),t))return!1}return!0}function gy(i,e){let t=e.split("."),s=i;for(let r=0;r<t.length;r++)if(s&&typeof s=="object"&&t[r]in s)s=s[t[r]];else return null;return s}function Nu(i,e=!1){let t=`${i}${e?"/i":""}`;return Io[t]||(Io[t]=new RegExp(i.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Io[t]}function rs(i,e,t,s=!1){if(typeof i=="string")return s?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)||!Lu(i))return JSON.stringify(e)===JSON.stringify(i);for(let r in i)if(!vy(r,e,i[r],t))return!1;return!0}function Lu(i){let e=Object.keys(i);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function fy(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 py(i,e,t){if(!Array.isArray(i))return!1;let s=Lu(e)?r=>rs(e,r,t):r=>Rt(r,e,t);for(let r=0;r<i.length;r++)if(i[r]&&s(i[r]))return!0;return!1}function Ei(i,e,t=!1){if(t){let s=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(i)?i.some(r=>e.some(n=>s(r)===s(n))):e.some(r=>s(i)===s(r))}return Array.isArray(i)?i.some(s=>e.includes(s)):e.includes(i)}function Du(i,e,t,s=!1){if(!Array.isArray(i))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<i.length;o++)if(rs(e[r],i[o],t,s)){n=!0;break}if(!n)return!1}return!0}function vy(i,e,t,s){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)?Ei(e,t):!1;case"$ini":return Array.isArray(t)?Ei(e,t,!0):!1;case"$inGroup":return Ei(e,s[t]||[]);case"$notInGroup":return!Ei(e,s[t]||[]);case"$nin":return Array.isArray(t)?!Ei(e,t):!1;case"$nini":return Array.isArray(t)?!Ei(e,t,!0):!1;case"$not":return!rs(t,e,s);case"$size":return Array.isArray(e)?rs(t,e.length,s):!1;case"$elemMatch":return py(e,t,s);case"$all":return Array.isArray(t)?Du(e,t,s):!1;case"$alli":return Array.isArray(t)?Du(e,t,s,!0):!1;case"$regex":try{return Nu(t).test(e)}catch{return!1}case"$regexi":try{return Nu(t,!0).test(e)}catch{return!1}case"$type":return fy(e)===t;default:return console.error("Unknown operator: "+i),!1}}function xu(i,e,t){if(!e.length)return!0;for(let s=0;s<e.length;s++)if(Rt(i,e[s],t))return!0;return!1}function _y(i,e,t){for(let s=0;s<e.length;s++)if(!Rt(i,e[s],t))return!1;return!0}var Io,$u=Re(()=>{"use strict";ts();Io={}});function by(i){let e=new Map;return i.global.forcedFeatureValues&&i.global.forcedFeatureValues.forEach((t,s)=>e.set(s,t)),i.user.forcedFeatureValues&&i.user.forcedFeatureValues.forEach((t,s)=>e.set(s,t)),e}function Ey(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 ki(i){try{await i()}catch{}}function Fu(i,e,t){if(i.user.trackedExperiments){let r=Cr(e,t);if(i.user.trackedExperiments.has(r))return[];i.user.trackedExperiments.add(r)}i.user.enableDevMode&&i.user.devLogs&&i.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let s=[];if(i.global.trackingCallback){let r=i.global.trackingCallback;s.push(ki(()=>r(e,t,i.user)))}if(i.user.trackingCallback){let r=i.user.trackingCallback;s.push(ki(()=>r(e,t)))}if(i.global.eventLogger){let r=i.global.eventLogger;s.push(ki(()=>r(yy,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},i.user)))}return s}function ky(i,e,t){if(i.user.trackedFeatureUsage){let s=JSON.stringify(t.value);if(i.user.trackedFeatureUsage[e]===s)return;i.user.trackedFeatureUsage[e]=s,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 s=i.global.onFeatureUsage;ki(()=>s(e,t,i.user))}if(i.user.onFeatureUsage){let s=i.user.onFeatureUsage;ki(()=>s(e,t))}if(i.global.eventLogger){let s=i.global.eventLogger;ki(()=>s(my,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},i.user))}}function Rr(i,e){if(e.stack.evaluatedFeatures.has(i))return Ot(e,i,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(i),e.stack.id=i;let t=by(e);if(t.has(i))return Ot(e,i,t.get(i),"override");if(!e.global.features||!e.global.features[i])return Ot(e,i,null,"unknownFeature");let s=e.global.features[i];if(s.rules){let r=new Set(e.stack.evaluatedFeatures);e:for(let n of s.rules){if(n.parentConditions)for(let l of n.parentConditions){e.stack.evaluatedFeatures=new Set(r);let u=Rr(l.id,e);if(u.source==="cyclicPrerequisite")return Ot(e,i,null,"cyclicPrerequisite");let c={value:u.value};if(!Rt(c,l.condition||{})){if(l.gate)return Ot(e,i,null,"prerequisite");continue e}}if(n.filters&&Bu(n.filters,e))continue;if("force"in n){if(n.condition&&!Uu(n.condition,e)||!Sy(e,n.seed||i,n.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0,n.range,n.coverage,n.hashVersion))continue;return n.tracks&&n.tracks.forEach(l=>{!Fu(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),Ot(e,i,n.force,"force",n.id)}if(!n.variations)continue;let o={variations:n.variations,key:n.key||i};"coverage"in n&&(o.coverage=n.coverage),n.weights&&(o.weights=n.weights),n.hashAttribute&&(o.hashAttribute=n.hashAttribute),n.fallbackAttribute&&(o.fallbackAttribute=n.fallbackAttribute),n.disableStickyBucketing&&(o.disableStickyBucketing=n.disableStickyBucketing),n.bucketVersion!==void 0&&(o.bucketVersion=n.bucketVersion),n.minBucketVersion!==void 0&&(o.minBucketVersion=n.minBucketVersion),n.namespace&&(o.namespace=n.namespace),n.meta&&(o.meta=n.meta),n.ranges&&(o.ranges=n.ranges),n.name&&(o.name=n.name),n.phase&&(o.phase=n.phase),n.seed&&(o.seed=n.seed),n.hashVersion&&(o.hashVersion=n.hashVersion),n.filters&&(o.filters=n.filters),n.condition&&(o.condition=n.condition);let{result:a}=Or(o,i,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return Ot(e,i,a.value,"experiment",n.id,o,a)}}return Ot(e,i,s.defaultValue===void 0?null:s.defaultValue,"defaultValue")}function Or(i,e,t){let s=i.key,r=i.variations.length;if(r<2)return{result:ne(t,i,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:ne(t,i,-1,!1,e)};if(i=wy(i,t),i.urlPatterns&&!pr(t.user.url||"",i.urlPatterns))return{result:ne(t,i,-1,!1,e)};let n=cu(s,t.user.url||"",r);if(n!==null)return{result:ne(t,i,n,!1,e)};let o=Ey(t);if(s in o){let m=o[s];return{result:ne(t,i,m,!1,e)}}if(i.status==="draft"||i.active===!1)return{result:ne(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:ne(t,i,-1,!1,e)};let u=-1,c=!1,h=!1;if(t.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing){let{variation:m,versionIsBlocked:E}=Iy({ctx:t,expKey:i.key,expBucketVersion:i.bucketVersion,expHashAttribute:i.hashAttribute,expFallbackAttribute:i.fallbackAttribute,expMinBucketVersion:i.minBucketVersion,expMeta:i.meta});c=m>=0,u=m,h=!!E}if(!c){if(i.filters){if(Bu(i.filters,t))return{result:ne(t,i,-1,!1,e)}}else if(i.namespace&&!ou(l,i.namespace))return{result:ne(t,i,-1,!1,e)};if(i.include&&!uu(i.include))return{result:ne(t,i,-1,!1,e)};if(i.condition&&!Uu(i.condition,t))return{result:ne(t,i,-1,!1,e)};if(i.parentConditions){let m=new Set(t.stack.evaluatedFeatures);for(let E of i.parentConditions){t.stack.evaluatedFeatures=new Set(m);let T=Rr(E.id,t);if(T.source==="cyclicPrerequisite")return{result:ne(t,i,-1,!1,e)};let x={value:T.value};if(!Rt(x,E.condition||{}))return{result:ne(t,i,-1,!1,e)}}}if(i.groups&&!Ty(i.groups,t))return{result:ne(t,i,-1,!1,e)}}if(i.url&&!Ay(i.url,t))return{result:ne(t,i,-1,!1,e)};let g=Zi(i.seed||s,l,i.hashVersion||1);if(g===null)return{result:ne(t,i,-1,!1,e)};if(!c){let m=i.ranges||lu(r,i.coverage===void 0?1:i.coverage,i.weights);u=au(g,m)}if(h)return{result:ne(t,i,-1,!1,e,void 0,!0)};if(u<0)return{result:ne(t,i,-1,!1,e)};if("force"in i)return{result:ne(t,i,i.force===void 0?-1:i.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:ne(t,i,-1,!1,e)};if(i.status==="stopped")return{result:ne(t,i,-1,!1,e)};let f=ne(t,i,u,!0,e,g,c);if(t.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing){let{changed:m,key:E,doc:T}=Oy(t,a,es(l),{[Ro(i.key,i.bucketVersion)]:f.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[E]=T,t.user.saveStickyBucketAssignmentDoc(T))}let v=Fu(t,i,f);v.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:i,result:f});let p=v.length?v.length===1?v[0]:Promise.all(v).then(()=>{}):void 0;return"changeId"in i&&i.changeId&&t.global.recordChangeId&&t.global.recordChangeId(i.changeId),{result:f,trackingCall:p}}function Ot(i,e,t,s,r,n,o){let a={value:t,on:!!t,off:!t,source:s,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),s!=="override"&&ky(i,e,a),a}function Mu(i){return{...i.user.attributes,...i.user.attributeOverrides}}function Uu(i,e){return Rt(Mu(e),i,e.global.savedGroups||{})}function Bu(i,e){return i.some(t=>{let{hashValue:s}=Kt(e,t.attribute);if(!s)return!0;let r=Zi(t.seed,s,t.hashVersion||2);return r===null?!0:!t.ranges.some(n=>fr(r,n))})}function Sy(i,e,t,s,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=Kt(i,t,s);if(!a)return!1;let l=Zi(e,a,o||1);return l===null?!1:r?fr(l,r):n!==void 0?l<=n:!0}function ne(i,e,t,s,r,n,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:u}=Kt(i,e.hashAttribute,i.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),c=e.meta?e.meta[t]:{},h={key:c.key||""+t,featureId:r,inExperiment:a,hashUsed:s,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};return c.name&&(h.name=c.name),n!==void 0&&(h.bucket=n),c.passthrough&&(h.passthrough=c.passthrough),h}function wy(i,e){let t=i.key,s=e.global.overrides;return s&&s[t]&&(i=Object.assign({},i,s[t]),typeof i.url=="string"&&(i.url=vo(i.url))),i}function Kt(i,e,t){let s=e||"id",r="",n=Mu(i);return n[s]&&(r=n[s]),!r&&t&&(n[t]&&(r=n[t]),r&&(s=t)),{hashAttribute:s,hashValue:r}}function Ay(i,e){let t=e.user.url;if(!t)return!1;let s=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(i.test(t)||i.test(s))}function Ty(i,e){let t=e.global.groups||{};for(let s=0;s<i.length;s++)if(t[i[s]])return!0;return!1}function Iy({ctx:i,expKey:e,expBucketVersion:t,expHashAttribute:s,expFallbackAttribute:r,expMinBucketVersion:n,expMeta:o}){t=t||0,n=n||0,s=s||"id",o=o||[];let a=Ro(e,t),l=Ry(i,s,r);if(n>0)for(let h=0;h<n;h++){let g=Ro(e,h);if(l[g]!==void 0)return{variation:-1,versionIsBlocked:!0}}let u=l[a];if(u===void 0)return{variation:-1};let c=o.findIndex(h=>h.key===u);return c<0?{variation:-1}:{variation:c}}function Ro(i,e){return e=e||0,`${i}__${e}`}function Oo(i,e){return`${i}||${e}`}function Ry(i,e,t){if(!i.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:s,hashValue:r}=Kt(i,e),n=Oo(s,es(r)),{hashAttribute:o,hashValue:a}=Kt(i,t),l=a?Oo(o,es(a)):null,u={};return l&&i.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,i.user.stickyBucketAssignmentDocs[l].assignments||{}),i.user.stickyBucketAssignmentDocs[n]&&Object.assign(u,i.user.stickyBucketAssignmentDocs[n].assignments||{}),u}function Oy(i,e,t,s){let r=Oo(e,t),n=i.user.stickyBucketAssignmentDocs&&i.user.stickyBucketAssignmentDocs[r]?i.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o={...n,...s},a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function Cy(i,e){let t=new Set,s=e&&e.features?e.features:i.global.features||{},r=e&&e.experiments?e.experiments:i.global.experiments||[];return Object.keys(s).forEach(n=>{let o=s[n];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),r.map(n=>{t.add(n.hashAttribute||"id"),n.fallbackAttribute&&t.add(n.fallbackAttribute)}),Array.from(t)}async function Vu(i,e,t){let s=Co(i,t);return e.getAllAssignments(s)}function Co(i,e){let t={};return Cy(i,e).forEach(r=>{let{hashValue:n}=Kt(i,r);t[r]=es(n)}),t}async function Gu(i,e,t){if(i={...i},i.encryptedFeatures){try{i.features=JSON.parse(await zt(i.encryptedFeatures,e,t))}catch(s){console.error(s)}delete i.encryptedFeatures}if(i.encryptedExperiments){try{i.experiments=JSON.parse(await zt(i.encryptedExperiments,e,t))}catch(s){console.error(s)}delete i.encryptedExperiments}if(i.encryptedSavedGroups){try{i.savedGroups=JSON.parse(await zt(i.encryptedSavedGroups,e,t))}catch(s){console.error(s)}delete i.encryptedSavedGroups}return i}function ju(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 Cr(i,e){return e.hashAttribute+e.hashValue+i.key+e.variationId}var my,yy,Hu=Re(()=>{"use strict";$u();ts();my="Feature Evaluated",yy="Experiment Viewed"});var Si,Py,ns,qu=Re(()=>{"use strict";Pu();ts();Eu();Hu();Si=typeof window<"u"&&typeof document<"u",Py=du(),ns=class{constructor(e){if(e=e||{},this.version=Py,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=s=>t.saveAssignments(s)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),Si&&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 s=this._options.stickyBucketAssignmentDocs[t];s&&this._options.stickyBucketService.saveAssignments(s).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await Gu(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,yr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&pu(e.cacheSettings),e.payload)return await this.setPayload(e.payload),yr(this,e),{success:!0,source:"init"};{let{data:t,...s}=await this._refresh({...e,allowStale:!0});return yr(this,e),await this.setPayload(t||{}),s}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return ju(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:s,streaming:r}){if(!this._options.clientKey)throw new Error("Missing clientKey");return vu({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:s,backgroundSync:r??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,t,s){let r=await zt(e,t||this._options.decryptionKey,s);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,s){let r=await zt(e,t||this._options.decryptionKey,s);this.setExperiments(JSON.parse(r))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(t=>{try{t()}catch(s){console.error(s)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,_u(this),e.destroyAllStreams&&ko(),this.logs=[],Si&&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}=Or(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(s=>s.key===e).map(s=>this._runAutoExperiment(s)).filter(s=>s!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,t){let s=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!s)return null;let r=this._isAutoExperimentBlockedByContext(e),n,o;r?n=ne(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=Or(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!t&&n.inExperiment&&s&&s.valueHash===a)return n;if(s&&this._undoActiveAutoExperiment(e),n.inExperiment){let l=vr(e);if(l==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let u=e.persistQueryString?hu(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(pr(u,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=u;let{navigate:c,delay:h}=this._getNavigateFunction();if(c)if(Si)Promise.all([...o?[_r(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(g=>window.setTimeout(g,this._options.navigateDelay??h))]).then(()=>{try{c(u)}catch(g){console.error(g)}});else try{c(u)}catch(g){console.error(g)}}else if(l==="visual"){let u=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(n.value):this._applyDOMChanges(n.value);u&&this._activeAutoExperiments.set(e,{undo:u,valueHash:a})}}return n}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],s=new Set(t);this._activeAutoExperiments.forEach((r,n)=>{s.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of t){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&vr(r)==="redirect")break}}_onExperimentEval(e,t){let s=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,s)}_fireSubscriptions(e,t,s){(!s||s.result.inExperiment!==t.inExperiment||s.result.variationId!==t.variationId)&&this._subscriptions.forEach(r=>{try{r(e,t)}catch(n){console.error(n)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,t){let s=this.evalFeature(e).value;return s===null?t:s}feature(e){return this.evalFeature(e)}evalFeature(e){return Rr(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=>[Cr(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(s){console.error(s)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Cr(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(Si?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=vr(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(s=>s.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let s=new URL(this._getContextUrl());for(let r of e.variations){if(!r||!r.urlRedirect)continue;let n=new URL(r.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(n.protocol!==s.protocol||n.host!==s.host))return!0}}catch(s){return this.log("Error parsing current or redirect URL",{id:e.key,error:s}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:Si?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!Si)return;let t=[];if(e.css){let s=document.createElement("style");s.innerHTML=e.css,document.head.appendChild(s),t.push(()=>s.remove())}if(e.js){let s=document.createElement("script");s.innerHTML=e.js,this._options.jsInjectionNonce&&(s.nonce=this._options.jsInjectionNonce),document.head.appendChild(s),t.push(()=>s.remove())}return e.domMutations&&e.domMutations.forEach(s=>{t.push(Cu.declarative(s).revert)}),()=>{t.forEach(s=>s())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),s=await Vu(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=s}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let s=this._getEvalContext(),r=Co(s,t);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var zu=Re(()=>{"use strict";qu()});var Ku={};gn(Ku,{Growthbook:()=>Po});var ze,Po,Wu=Re(()=>{"use strict";zu();co();Ji();pi();ze=class ze{constructor(e,t,s={},r=!1){this.analytics=new hi;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=it("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:t,user_language:s,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:u,url:c,domain:h,utm_content:g,residence_country:f,loggedIn:v,network_type:p,network_downlink:m,user_id:E,anonymous_id:T,account_mode:x})=>{let M={...this.GrowthBook.getAttributes(),id:e,...E!==void 0&&{user_id:E},...T!==void 0&&{anonymous_id:T},...t!==void 0&&{country:t},...f!==void 0&&{residence_country:f},...s!==void 0&&{user_language:s},...r!==void 0&&{device_language:r},...n!==void 0&&{device_type:n},...o!==void 0&&{utm_source:o},...a!==void 0&&{utm_medium:a},...l!==void 0&&{utm_campaign:l},...u!==void 0&&{is_authorised:u},...c!==void 0&&{url:c},...h!==void 0&&{domain:h},...g!==void 0&&{utm_content:g},...v!==void 0&&{loggedIn:v},...p!==void 0&&{network_type:p},...m!==void 0&&{network_downlink:m},...x!==void 0&&{account_mode:x}};this.log("setAttributes | updating GrowthBook attributes",M),this.GrowthBook.setAttributes(M)};this.getFeatureValue=(e,t)=>{let s=this.GrowthBook.getFeatureValue(e,t);return this.log("getFeatureValue",{key:e,value:s,defaultValue:t}),s};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let t=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:t}),t};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let t=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:t}),t};this.init=async()=>{this.log("init | initializing GrowthBook SDK");let e=await this.GrowthBook.init({timeout:2e3,streaming:!0}).catch(()=>{});this.status=e,this.isLoaded=!0,this.log("init | GrowthBook SDK loaded",{status:e})};this.destroy=()=>{this.GrowthBook.destroy(),this.isLoaded=!1,this.status=void 0};this.debug=r;let n=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new ns({apiHost:Vc,clientKey:e,decryptionKey:t,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:n,trackingCallback:(o,a)=>{this.log("trackingCallback | experiment viewed",{experiment_id:o.key,variation_id:a.variationId}),typeof window<"u"&&window.dataLayer&&window.dataLayer.push({event:"experiment_viewed",event_category:"experiment",rudder_anonymous_id:this.analytics.getAnonymousId(),experiment_id:o.key,variation_id:a.variationId}),this.analytics.track("experiment_viewed",{experimentId:o.key,variationId:a.variationId})},...s}),this.init()}reapplyExperiment(e){let t=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(t)}waitForIsLoaded(e=1e4){return new Promise((t,s)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),t()):Date.now()-r>=e&&(clearInterval(n),s(new Error("GrowthBook initialization timeout")))},100)})}};ze.getGrowthBookInstance=(e,t,s,r=!1)=>ze._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),ze._instance):(ze._instance=new ze(e,t??"",s,r),ze._instance),ze.resetInstance=()=>{ze._instance&&(ze._instance.destroy(),ze._instance=void 0)};Po=ze});function Qu(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(u){return void t(u)}a.done?e(l):Promise.resolve(l).then(s,r)}function _t(i){return function(){var e=this,t=arguments;return new Promise((function(s,r){var n=i.apply(e,t);function o(l){Qu(n,s,r,o,a,"next",l)}function a(l){Qu(n,s,r,o,a,"throw",l)}o(void 0)}))}}function b(){return b=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(i[s]=t[s])}return i},b.apply(null,arguments)}function Kd(i,e){if(i==null)return{};var t={};for(var s in i)if({}.hasOwnProperty.call(i,s)){if(e.indexOf(s)!==-1)continue;t[s]=i[s]}return t}function U(i,e){return i.indexOf(e)!==-1}function Yd(i){return i===null||typeof i!="object"}function Br(i,e){return Object.prototype.toString.call(i)==="[object "+e+"]"}function Ka(i){return!S(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(i,Event)}function ot(i,e,t,s,r){return e>t&&(s.warn("min cannot be greater than max."),e=t),at(i)?i>t?(s.warn(" cannot be greater than max: "+t+". Using max value instead."),t):i<e?(s.warn(" cannot be less than min: "+e+". Using min value instead."),e):i:(s.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+r),ot(r||t,e,t,s))}function Yy(i){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return xo&&t.length===td||(td=t.length,xo=t.reduce(((s,r)=>{Pr||(Pr={});var n=Pr[r];if(n)s[n[0]]=n[1];else for(var o=i(r),a=o.length-1;a>=0;a--){var l=o[a],u=l?.filename,c=e[r];if(u&&c){s[u]=c,Pr[r]=[u,c];break}}return s}),{})),xo}}function ra(i,e,t,s,r){var n={platform:i,filename:e,function:t==="<anonymous>"?xi:t,in_app:!0};return S(s)||(n.lineno=s),S(r)||(n.colno=r),n}function rb(){return(function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s<e;s++)t[s-1]=arguments[s];return function(r,n){n===void 0&&(n=0);for(var o=[],a=r.split(`
15
+ `),l=n;l<a.length;l++){var u=a[l];if(!(u.length>1024)){var c=rd.test(u)?u.replace(rd,"$1"):u;if(!c.match(/\S*Error: /)){for(var h of t){var g=h(c,i);if(g){o.push(g);break}}if(o.length>=nd)break}}}return(function(f){if(!f.length)return[];var v=Array.from(f);return v.reverse(),v.slice(0,nd).map((p=>{return b({},p,{filename:p.filename||(m=v,m[m.length-1]||{}).filename,function:p.function||xi});var m}))})(o)}})("web:javascript",eb,sb)}function fh(i,e){e===void 0&&(e=40);var t=Object.keys(i);if(t.sort(),!t.length)return"[object has no keys]";for(var s=t.length;s>0;s--){var r=t.slice(0,s).join(", ");if(!(r.length>e))return s===t.length||r.length<=e?r:r.slice(0,e)+"..."}return""}function Lt(i,e,t){if(q(i)){if(Xu&&i.forEach===Xu)i.forEach(e,t);else if("length"in i&&i.length===+i.length){for(var s=0,r=i.length;s<r;s++)if(s in i&&e.call(t,i[s],s)===Gr)return}}}function Z(i,e,t){if(!B(i)){if(q(i))return Lt(i,e,t);if(Ly(i)){for(var s of i.entries())if(e.call(t,s[1],s[0])===Gr)return}else for(var r in i)if(Xd.call(i,r)&&e.call(t,i[r],r)===Gr)return}}function Mr(i){for(var e=Object.keys(i),t=e.length,s=new Array(t);t--;)s[t]=[e[t],i[e[t]]];return s}function cb(i,e){return t=i,s=n=>he(n)&&!Qe(e)?n.slice(0,e):n,r=new Set,(function n(o,a){return o!==Object(o)?s?s(o,a):o:r.has(o)?void 0:(r.add(o),q(o)?(l=[],Lt(o,(u=>{l.push(n(u))}))):(l={},Z(o,((u,c)=>{r.has(u)||(l[c]=n(u,c))}))),l);var l})(t);var t,s,r}function db(i){var e=i?.hostname;if(!he(e))return!1;var t=e.split(".").slice(-2).join(".");for(var s of ub)if(t===s)return!1;return!0}function vh(i,e){for(var t=0;t<i.length;t++)if(e(i[t]))return i[t]}function de(i,e,t,s){var{capture:r=!1,passive:n=!0}=s??{};i?.addEventListener(e,t,{capture:r,passive:n})}function _h(i){return i.name==="ph_toolbar_internal"}function pb(i,e){if(e){var t=(function(r,n){if(n===void 0&&(n=k),as)return as;if(!n||["localhost","127.0.0.1"].includes(r))return"";for(var o=r.split("."),a=Math.min(o.length,8),l="dmn_chk_"+xt();!as&&a--;){var u=o.slice(a).join("."),c=l+"=1;domain=."+u+";path=/";n.cookie=c+";max-age=3",n.cookie.includes(l)&&(n.cookie=c+";max-age=0",as=u)}return as})(i);if(!t){var s=(r=>{var n=r.match(fb);return n?n[0]:""})(i);s!==t&&w.info("Warning: cookie subdomain discovery mismatch",s,t),t=s}return t?"; domain=."+t:""}return""}function bb(i,e){var t=i.config.segment;if(!t)return e();(function(s,r){var n=s.config.segment;if(!n)return r();var o=l=>{var u=()=>l.anonymousId()||xt();s.config.get_device_id=u,l.id()&&(s.register({distinct_id:l.id(),$device_id:u()}),s.persistence.set_property(rt,"identified")),r()},a=n.user();"then"in a&&bt(a.then)?a.then(o):o(a)})(i,(()=>{t.register((s=>{Promise&&Promise.resolve||$o.warn("This browser does not have Promise support, and can not use the segment integration");var r=(n,o)=>{if(!o)return n;n.event.userId||n.event.anonymousId===s.get_distinct_id()||($o.info("No userId set, resetting PostHog"),s.reset()),n.event.userId&&n.event.userId!==s.get_distinct_id()&&($o.info("UserId set, identifying with PostHog"),s.identify(n.event.userId));var a=s.calculateEventProperties(o,n.event.properties);return n.event.properties=Object.assign({},a,n.event.properties),n};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:n=>r(n,n.event.event),page:n=>r(n,"$pageview"),identify:n=>r(n,"$identify"),screen:n=>r(n,"$screen")}})(i)).then((()=>{e()}))}))}function wh(i,e){var{organization:t,projectId:s,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,u,c,h,g;if(!(n==="*"||n.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 v,p=((l=a.exception)==null?void 0:l.values)||[],m=p.map((T=>b({},T,{stacktrace:T.stacktrace?b({},T.stacktrace,{type:"raw",frames:(T.stacktrace.frames||[]).map((x=>b({},x,{platform:"web:javascript"})))}):void 0}))),E={$exception_message:((u=p[0])==null?void 0:u.value)||a.message,$exception_type:(c=p[0])==null?void 0:c.type,$exception_level:a.level,$exception_list:m,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=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&&s&&(E.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+s+"&query="+a.event_id),o&&((v=i.exceptions)==null||v.sendExceptionEvent(E)),a}}function Ah(i,e,t){if(!k)return{};var s,r=e?Li([],$i,t||[]):[],n=Th(Cs(k.URL,r,Ps),i),o=(s={},Z(Sb,(function(a){var l=nt.A(a);s[a]=l||null})),s);return ue(o,n)}function Th(i,e){var t=kb.concat(e||[]),s={};return Z(t,(function(r){var n=Jr(i,r);s[r]=n||null})),s}function Ih(i){var e=(function(n){return n?n.search(Lr+"google.([^/?]*)")===0?"google":n.search(Lr+"bing.com")===0?"bing":n.search(Lr+"yahoo.com")===0?"yahoo":n.search(Lr+"duckduckgo.com")===0?"duckduckgo":null:null})(i),t=e!="yahoo"?"q":"p",s={};if(!Qe(e)){s.$search_engine=e;var r=k?Jr(k.referrer,t):"";r.length&&(s.ph_keyword=r)}return s}function vd(){return navigator.language||navigator.userLanguage}function Rh(){return k?.referrer||"$direct"}function Oh(i,e){var t=i?Li([],$i,e||[]):[],s=ye?.href.substring(0,1e3);return{r:Rh().substring(0,1e3),u:s?Cs(s,t,Ps):void 0}}function Ch(i){var e,{r:t,u:s}=i,r={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Yr(t))==null?void 0:e.host};if(s){r.$current_url=s;var n=Yr(s);r.$host=n?.host,r.$pathname=n?.pathname;var o=Th(s);ue(r,o)}if(t){var a=Ih(t);ue(r,a)}return r}function Ph(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function wb(){try{return new Date().getTimezoneOffset()}catch{return}}function Ab(i,e){var t,s,r,n;if(!xe)return{};var o,a,l,u,c,h,g,f,v=i?Li([],$i,e||[]):[],[p,m]=(function(E){for(var T=0;T<id.length;T++){var[x,R]=id[T],M=x.exec(E),F=M&&(bt(R)?R(M,E):R);if(F)return F}return["",""]})(xe);return ue(Qa({$os:p,$os_version:m,$browser:hh(xe,navigator.vendor),$device:sd(xe),$device_type:(a=xe,l={userAgentDataPlatform:(t=navigator)==null||(t=t.userAgentData)==null?void 0:t.platform,maxTouchPoints:(s=navigator)==null?void 0:s.maxTouchPoints,screenWidth:_==null||(r=_.screen)==null?void 0:r.width,screenHeight:_==null||(n=_.screen)==null?void 0:n.height,devicePixelRatio:_?.devicePixelRatio},f=sd(a),f===Qd||f===Jd||f==="Kobo"||f==="Kindle Fire"||f===dh?Ni:f===Rs||f===Pi||f===Os||f===ta?"Console":f===eh?"Wearable":f?Ve:l?.userAgentDataPlatform==="Android"&&((u=l?.maxTouchPoints)!==null&&u!==void 0?u:0)>0?Math.min((c=l?.screenWidth)!==null&&c!==void 0?c:0,(h=l?.screenHeight)!==null&&h!==void 0?h:0)/((g=l?.devicePixelRatio)!==null&&g!==void 0?g:1)>=600?Ni:Ve:"Desktop"),$timezone:Ph(),$timezone_offset:wb()}),{$current_url:Cs(ye?.href,v,Ps),$host:ye?.host,$pathname:ye?.pathname,$raw_user_agent:xe.length>1e3?xe.substring(0,997)+"...":xe,$browser_version:Wy(xe,navigator.vendor),$browser_language:vd(),$browser_language_prefix:(o=vd(),typeof o=="string"?o.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.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 xb(i,e){e===void 0&&(e={});var t=(function(){var a=4294967295;return{p:function(l){for(var u=a,c=0;c<l.length;++c)u=Nb[255&u^l[c]]^u>>>8;a=u},d:function(){return 4294967295^a}}})(),s=i.length;t.p(i);var r,n=Db(i,e,10+((r=e).filename&&r.filename.length+1||0),8),o=n.length;return(function(a,l){var u=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&&Bo(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),u){a[3]=8;for(var c=0;c<=u.length;++c)a[c+10]=u.charCodeAt(c)}})(n,e),Bo(n,o-8,t.d()),Bo(n,o-4,s),n}function kd(i,e,t){return ks({distinct_id:i,userPropertiesToSet:e,userPropertiesToSetOnce:t})}function Mh(i,e){return!i||Object.entries(i).every((t=>{var[s,r]=t,n=e?.[s];if(S(n)||Qe(n))return!1;var o=[String(n)],a=Fh[r.operator];return!!a&&a(r.values,o)}))}function Id(i){return i instanceof Element&&(i.id===Eh||!(i.closest==null||!i.closest(".toolbar-global-fade-container")))}function dn(i){return!!i&&i.nodeType===1}function $t(i,e){return!!i&&!!i.tagName&&i.tagName.toLowerCase()===e.toLowerCase()}function Vh(i){return!!i&&i.nodeType===3}function Gh(i){return!!i&&i.nodeType===11}function tl(i){return i?cn(i).split(/\s+/):[]}function Rd(i){var e=_?.location.href;return!!(e&&i&&i.some((t=>e.match(t))))}function an(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 tl(e)}function jh(i){return B(i)?null:cn(i).split(/(\s+)/).filter((e=>Ds(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function xs(i){var e="";return Va(i)&&!Kh(i)&&i.childNodes&&i.childNodes.length&&Z(i.childNodes,(function(t){var s;Vh(t)&&t.textContent&&(e+=(s=jh(t.textContent))!==null&&s!==void 0?s:"")})),cn(e)}function Od(i){return S(i.target)?i.srcElement||null:(e=i.target)!=null&&e.shadowRoot?i.composedPath()[0]||null:i.target||null;var e}function Hh(i,e){if(S(e))return!0;var t,s=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of i)if(t=s(r))return t.v;return!1}function qh(i){var e=i.parentNode;return!(!e||!dn(e))&&e}function qb(i,e){if(!_||sl(i))return!1;var t,s,r;if(kt(e)?(t=!!e&&Pd,s=void 0):(t=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:Pd,s=e?.content_ignorelist),t===!1)return!1;var{targetElementList:n}=zh(i,!1);return!(function(o,a){if(o===!1||S(o))return!1;var l;if(o===!0)l=Hb;else{if(!q(o))return!1;if(o.length>Cd)return w.error("[PostHog] content_ignorelist array cannot exceed "+Cd+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map((u=>u.toLowerCase()))}return a.some((u=>{var{safeText:c,ariaLabel:h}=u;return l.some((g=>c.includes(g)||h.includes(g)))}))})(s,n.map((o=>{var a;return{safeText:xs(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!Hh(n,t)}function zb(i,e,t,s,r){var n,o,a,l;if(t===void 0&&(t=void 0),!_||sl(i)||(n=t)!=null&&n.url_allowlist&&!Rd(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&Rd(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var u=t.dom_event_allowlist;if(u&&!u.some((v=>e.type===v)))return!1}var{parentIsUsefulElement:c,targetElementList:h}=zh(i,s);if(!(function(v,p){var m=p?.element_allowlist;if(S(m))return!0;var E,T=function(R){if(m.some((M=>R.tagName.toLowerCase()===M)))return{v:!0}};for(var x of v)if(E=T(x))return E.v;return!1})(h,t)||!Hh(h,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var g=_.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(r||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(e.type)>=0;default:return c?(r||["click"]).indexOf(e.type)>=0:(r||["click"]).indexOf(e.type)>=0&&(il.indexOf(f)>-1||i.getAttribute("contenteditable")==="true")}}function Va(i){for(var e=i;e.parentNode&&!$t(e,"body");e=e.parentNode){var t=an(e);if(U(t,"ph-sensitive")||U(t,"ph-no-capture"))return!1}if(U(an(i),"ph-include"))return!0;var s=i.type||"";if(he(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=i.name||i.id||"";return!(he(r)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))}function Kh(i){return!!($t(i,"input")&&!["button","checkbox","submit","reset"].includes(i.type)||$t(i,"select")||$t(i,"textarea")||i.getAttribute("contenteditable")==="true")}function Ds(i,e){return e===void 0&&(e=!0),!(B(i)||he(i)&&(i=cn(i),(e?Kb:Wb).test((i||"").replace(/[- ]/g,""))||(e?Xb:Yb).test(i)))}function Yh(i){var e=xs(i);return Ds(e=(e+" "+Jh(i)).trim())?e:""}function Jh(i){var e="";return i&&i.childNodes&&i.childNodes.length&&Z(i.childNodes,(function(t){var s;if(t&&((s=t.tagName)==null?void 0:s.toLowerCase())==="span")try{var r=xs(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Jh(t)).trim())}catch(n){w.error("[AutoCapture]",n)}})),e}function Jb(i){return(function(e){var t=e.map((s=>{var r,n,o="";if(s.tag_name&&(o+=s.tag_name),s.attr_class)for(var a of(s.attr_class.sort(),s.attr_class))o+="."+a.replace(/"/g,"");var l=b({},s.text?{text:s.text}:{},{"nth-child":(r=s.nth_child)!==null&&r!==void 0?r:0,"nth-of-type":(n=s.nth_of_type)!==null&&n!==void 0?n:0},s.href?{href:s.href}:{},s.attr_id?{attr_id:s.attr_id}:{},s.attributes),u={};return Mr(l).sort(((c,h)=>{var[g]=c,[f]=h;return g.localeCompare(f)})).forEach((c=>{var[h,g]=c;return u[Nd(h.toString())]=Nd(g.toString())})),o+=":",o+=Mr(u).map((c=>{var[h,g]=c;return h+'="'+g+'"'})).join("")}));return t.join(";")})((function(e){return e.map((t=>{var s,r,n={text:(s=t.$el_text)==null?void 0:s.slice(0,400),tag_name:t.tag_name,href:(r=t.attr__href)==null?void 0:r.slice(0,2048),attr_class:Qb(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Mr(t).filter((o=>{var[a]=o;return a.indexOf("attr__")===0})).forEach((o=>{var[a,l]=o;return n.attributes[a]=l})),n}))})(i))}function Nd(i){return i.replace(/"|\\"/g,'\\"')}function Qb(i){var e=i.attr__class;return e?q(e)?e:tl(e):void 0}function qo(i,e){return e.length>i?e.slice(0,i)+"...":e}function Zb(i){if(i.previousElementSibling)return i.previousElementSibling;var e=i;do e=e.previousSibling;while(e&&!dn(e));return e}function eE(i,e,t,s){var r=i.tagName.toLowerCase(),n={tag_name:r};il.indexOf(r)>-1&&!t&&(r.toLowerCase()==="a"||r.toLowerCase()==="button"?n.$el_text=qo(1024,Yh(i)):n.$el_text=qo(1024,xs(i)));var o=an(i);o.length>0&&(n.classes=o.filter((function(c){return c!==""}))),Z(i.attributes,(function(c){var h;if((!Kh(i)||["name","id","class","aria-label"].indexOf(c.name)!==-1)&&(s==null||!s.includes(c.name))&&!e&&Ds(c.value)&&(h=c.name,!he(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var g=c.value;c.name==="class"&&(g=tl(g).join(" ")),n["attr__"+c.name]=qo(1024,g)}}));for(var a=1,l=1,u=i;u=Zb(u);)a++,u.tagName===i.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function tE(i,e){for(var t,s,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,u=[i],c=i;c.parentNode&&!$t(c,"body");)Gh(c.parentNode)?(u.push(c.parentNode.host),c=c.parentNode.host):(u.push(c.parentNode),c=c.parentNode);var h,g=[],f={},v=!1,p=!1;if(Z(u,(R=>{var M=Va(R);R.tagName.toLowerCase()==="a"&&(v=R.getAttribute("href"),v=M&&v&&Ds(v)&&v),U(an(R),"ph-no-capture")&&(p=!0),g.push(eE(R,n,o,a));var F=(function(W){if(!Va(W))return{};var $={};return Z(W.attributes,(function(ve){if(ve.name&&ve.name.indexOf("data-ph-capture-attribute")===0){var Se=ve.name.replace("data-ph-capture-attribute-",""),Ge=ve.value;Se&&Ge&&Ds(Ge)&&($[Se]=Ge)}})),$})(R);ue(f,F)})),p)return{props:{},explicitNoCapture:p};if(o||(i.tagName.toLowerCase()==="a"||i.tagName.toLowerCase()==="button"?g[0].$el_text=Yh(i):g[0].$el_text=xs(i)),v){var m,E;g[0].attr__href=v;var T=(m=Yr(v))==null?void 0:m.host,x=_==null||(E=_.location)==null?void 0:E.host;T&&x&&T!==x&&(h=v)}return{props:ue({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:Jb(g)},(t=g[0])!=null&&t.$el_text?{$el_text:(s=g[0])==null?void 0:s.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},f)}}function xd(i,e,t){try{if(!(e in i))return()=>{};var s=i[e],r=t(s);return bt(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),i[e]=r,()=>{i[e]=s}}catch{return()=>{}}}function Md(i){return ge(i)&&"clientX"in i&&"clientY"in i&&at(i.clientX)&&at(i.clientY)}function wi(i,e,t){if(B(i))return!1;switch(t){case"exact":return i===e;case"contains":var s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(i);case"regex":try{return new RegExp(e).test(i)}catch{return!1}default:return!1}}var _,be,zd,Xu,Yu,Be,k,ye,Xo,Yo,Ju,xe,O,vt,Ny,Dy,Zu,cn,Jo,xy,Wd,Xd,un,q,bt,ge,Ri,S,he,Qo,Qe,B,at,Ti,kt,Ly,$y,Fy,No,My,Zo,Ve,Vr,Et,Ni,Jd,Qd,Zd,eh,Is,Di,th,ih,sh,Jt,Uy,rh,Wa,nh,Xa,By,Ya,oh,Ci,ah,Rs,Os,Pi,lh,ch,vs,ea,ed,ta,uh,Vy,dh,ia,Ae,Do,Gy,jy,Hy,Ja,qy,Pr,td,xo,zy,hh,Ky,Wy,id,sd,Xy,sa,xi,gh,Jy,Qy,Zy,eb,tb,ib,sb,rd,nd,na,oa,aa,nb,la,ob,ca,ua,da,ha,ph,w,le,ab,od,Gr,ue,Li,ad,lb,Qa,ub,mh,_s,ms,ld,ga,cd,fa,ud,dd,yh,hd,gd,Nr,jr,bh,Oi,ys,pa,bs,Yt,va,Hr,_a,qr,rt,ma,ya,ba,Ea,zr,Kr,Eh,os,hb,fd,ka,Sa,pd,kh,wa,xt,gb,as,fb,nt,Lo,ae,vb,Dr,_b,Wt,me,mt,Aa,xr,mb,yb,Wr,$o,Sh,Ta,Xr,Yr,Eb,Jr,Cs,Qr,Lr,$i,kb,Ps,Sb,Tb,ws,ls,Fo,Es,Mo,Ia,Ib,_d,md,Ra,cs,Zr,yt,We,Te,Fi,Za,el,yd,Nh,Dh,Rb,Oa,Ct,Ca,en,ee,As,Qt,tn,Ob,Cb,xh,Lh,pt,us,Uo,Pa,bd,ds,Na,Ed,Pb,Nb,Db,Bo,Lb,$b,sn,ks,Vo,Ur,Da,xa,Fb,La,$a,Mb,rn,Ns,Go,nn,$h,on,Fh,$r,Ss,Sd,Fa,J,Uh,Ub,wd,Bb,Vb,Gb,jb,Ma,Ts,jo,Ua,Ii,Bh,Ad,Td,Ba,Mi,il,Hb,Cd,Pd,sl,zh,Wh,Kb,Wb,Xh,Xb,Yb,ln,Ho,Dd,hs,iE,Pt,Ld,$d,Fd,gs,Fr,Ga,Xt,sE,Ud,zo,rE,Nt,ja,Ha,qa,nE,Bd,Vd,Dt,De,fs,oE,aE,lE,cE,uE,dE,hE,Ko,Ai,Gd,ps,jd,Hd,gE,fE,Wo,pE,za,Ke,hn,vE,_E,mE,yE,bE,EE,kE,SE,wE,AE,TE,IE,qd,St,Qh=Re(()=>{"use strict";_=typeof window<"u"?window:void 0,be=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(be.self=be),typeof File>"u"&&(be.File=function(){});zd=Array.prototype,Xu=zd.forEach,Yu=zd.indexOf,Be=be?.navigator,k=be?.document,ye=be?.location,Xo=be?.fetch,Yo=be!=null&&be.XMLHttpRequest&&"withCredentials"in new be.XMLHttpRequest?be.XMLHttpRequest:void 0,Ju=be?.AbortController,xe=Be?.userAgent,O=_??{},vt={DEBUG:!1,LIB_VERSION:"1.360.1"};Ny=["$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"],Dy=["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"],Zu=function(i,e){if(e===void 0&&(e=[]),!i)return!1;var t=i.toLowerCase();return Dy.concat(e).some((s=>{var r=s.toLowerCase();return t.indexOf(r)!==-1}))};cn=function(i){return i.trim()},Jo=function(i){return i.replace(/^\$/,"")},xy=Array.isArray,Wd=Object.prototype,Xd=Wd.hasOwnProperty,un=Wd.toString,q=xy||function(i){return un.call(i)==="[object Array]"},bt=i=>typeof i=="function",ge=i=>i===Object(i)&&!q(i),Ri=i=>{if(ge(i)){for(var e in i)if(Xd.call(i,e))return!1;return!0}return!1},S=i=>i===void 0,he=i=>un.call(i)=="[object String]",Qo=i=>he(i)&&i.trim().length===0,Qe=i=>i===null,B=i=>S(i)||Qe(i),at=i=>un.call(i)=="[object Number]"&&i==i,Ti=i=>at(i)&&i>0,kt=i=>un.call(i)==="[object Boolean]",Ly=i=>i instanceof FormData,$y=i=>U(Ny,i);Fy=[!0,"true",1,"1","yes"],No=i=>U(Fy,i),My=[!1,"false",0,"0","no"];Zo=class{constructor(e){this.t={},this.i=e.i,this.o=ot(e.bucketSize,0,100,e.h),this.m=ot(e.refillRate,0,this.o,e.h),this.S=ot(e.refillInterval,0,864e5,e.h)}$(e,t){var s=t-e.lastAccess,r=Math.floor(s/this.S);if(r>0){var n=r*this.m;e.tokens=Math.min(e.tokens+n,this.o),e.lastAccess=e.lastAccess+r*this.S}}consumeRateLimit(e){var t,s=Date.now(),r=String(e),n=this.t[r];return n?this.$(n,s):(n={tokens:this.o,lastAccess:s},this.t[r]=n),n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.i)==null||t.call(this,e)),n.tokens===0)}stop(){this.t={}}},Ve="Mobile",Vr="iOS",Et="Android",Ni="Tablet",Jd=Et+" "+Ni,Qd="iPad",Zd="Apple",eh=Zd+" Watch",Is="Safari",Di="BlackBerry",th="Samsung",ih=th+"Browser",sh=th+" Internet",Jt="Chrome",Uy=Jt+" OS",rh=Jt+" "+Vr,Wa="Internet Explorer",nh=Wa+" "+Ve,Xa="Opera",By=Xa+" Mini",Ya="Edge",oh="Microsoft "+Ya,Ci="Firefox",ah=Ci+" "+Vr,Rs="Nintendo",Os="PlayStation",Pi="Xbox",lh=Et+" "+Ve,ch=Ve+" "+Is,vs="Windows",ea=vs+" Phone",ed="Nokia",ta="Ouya",uh="Generic",Vy=uh+" "+Ve.toLowerCase(),dh=uh+" "+Ni.toLowerCase(),ia="Konqueror",Ae="(\\d+(\\.\\d+)?)",Do=new RegExp("Version/"+Ae),Gy=new RegExp(Pi,"i"),jy=new RegExp(Os+" \\w+","i"),Hy=new RegExp(Rs+" \\w+","i"),Ja=new RegExp(Di+"|PlayBook|BB10","i"),qy={"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"},zy=(i,e)=>e&&U(e,Zd)||(function(t){return U(t,Is)&&!U(t,Jt)&&!U(t,Et)})(i),hh=function(i,e){return e=e||"",U(i," OPR/")&&U(i,"Mini")?By:U(i," OPR/")?Xa:Ja.test(i)?Di:U(i,"IE"+Ve)||U(i,"WPDesktop")?nh:U(i,ih)?sh:U(i,Ya)||U(i,"Edg/")?oh:U(i,"FBIOS")?"Facebook "+Ve:U(i,"UCWEB")||U(i,"UCBrowser")?"UC Browser":U(i,"CriOS")?rh:U(i,"CrMo")||U(i,Jt)?Jt:U(i,Et)&&U(i,Is)?lh:U(i,"FxiOS")?ah:U(i.toLowerCase(),ia.toLowerCase())?ia:zy(i,e)?U(i,Ve)?ch:Is:U(i,Ci)?Ci:U(i,"MSIE")||U(i,"Trident/")?Wa:U(i,"Gecko")?Ci:""},Ky={[nh]:[new RegExp("rv:"+Ae)],[oh]:[new RegExp(Ya+"?\\/"+Ae)],[Jt]:[new RegExp("("+Jt+"|CrMo)\\/"+Ae)],[rh]:[new RegExp("CriOS\\/"+Ae)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ae)],[Is]:[Do],[ch]:[Do],[Xa]:[new RegExp("(Opera|OPR)\\/"+Ae)],[Ci]:[new RegExp(Ci+"\\/"+Ae)],[ah]:[new RegExp("FxiOS\\/"+Ae)],[ia]:[new RegExp("Konqueror[:/]?"+Ae,"i")],[Di]:[new RegExp(Di+" "+Ae),Do],[lh]:[new RegExp("android\\s"+Ae,"i")],[sh]:[new RegExp(ih+"\\/"+Ae)],[Wa]:[new RegExp("(rv:|MSIE )"+Ae)],Mozilla:[new RegExp("rv:"+Ae)]},Wy=function(i,e){var t=hh(i,e),s=Ky[t];if(S(s))return null;for(var r=0;r<s.length;r++){var n=s[r],o=i.match(n);if(o)return parseFloat(o[o.length-2])}return null},id=[[new RegExp(Pi+"; "+Pi+" (.*?)[);]","i"),i=>[Pi,i&&i[1]||""]],[new RegExp(Rs,"i"),[Rs,""]],[new RegExp(Os,"i"),[Os,""]],[Ja,[Di,""]],[new RegExp(vs,"i"),(i,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[ea,""];if(new RegExp(Ve).test(e)&&!/IEMobile\b/.test(e))return[vs+" "+Ve,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var s=t[1],r=qy[s]||"";return/arm/i.test(e)&&(r="RT"),[vs,r]}return[vs,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,i=>{if(i&&i[3]){var e=[i[3],i[4],i[5]||"0"];return[Vr,e.join(".")]}return[Vr,""]}],[/(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/,[Uy,""]],[/Linux|debian/i,["Linux",""]]],sd=function(i){return Hy.test(i)?Rs:jy.test(i)?Os:Gy.test(i)?Pi:new RegExp(ta,"i").test(i)?ta:new RegExp("("+ea+"|WPDesktop)","i").test(i)?ea:/iPad/.test(i)?Qd:/iPod/.test(i)?"iPod Touch":/iPhone/.test(i)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(i)?eh:Ja.test(i)?Di:/(kobo)\s(ereader|touch)/i.test(i)?"Kobo":new RegExp(ed,"i").test(i)?ed:/(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(Ve).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:Jd:new RegExp("(pda|"+Ve+")","i").test(i)?Vy:new RegExp(Ni,"i").test(i)&&!new RegExp(Ni+" pc","i").test(i)?dh:""},Xy=i=>i instanceof Error;sa=class{constructor(e,t,s){s===void 0&&(s=[]),this.coercers=e,this.stackParser=t,this.modifiers=s}buildFromUnknown(e,t){t===void 0&&(t={});var s=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(s,t,0).apply(e),n=this.buildParsingContext(t),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,s),$exception_level:"error"}}modifyFrames(e){var t=this;return _t((function*(){for(var s of e)s.stacktrace&&s.stacktrace.frames&&q(s.stacktrace.frames)&&(s.stacktrace.frames=yield t.applyModifiers(s.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 s,r;return e.cause!=null&&(s=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),b({},e,{cause:s,stack:r})}applyChunkIds(e,t){return e.map((s=>(s.filename&&t&&(s.chunk_id=t[s.filename]),s)))}applyCoercers(e,t){for(var s of this.coercers)if(s.match(e))return s.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return _t((function*(){var s=e;for(var r of t.modifiers)s=yield r(s);return s}))()}convertToExceptionList(e,t){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:(s=t.type)!==null&&s!==void 0?s:"generic",handled:(r=t.handled)===null||r===void 0||r,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,b({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:Yy(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,s){s===void 0&&(s=0);var r=(n,o)=>{if(o<=4){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(n,a)}};return b({},t,{syntheticException:s==0?t.syntheticException:void 0,mechanism:e,apply:n=>r(n,s),next:n=>r(n,s+1)})}},xi="?";gh=(i,e)=>{var t=i.indexOf("safari-extension")!==-1,s=i.indexOf("safari-web-extension")!==-1;return t||s?[i.indexOf("@")!==-1?i.split("@")[0]:xi,t?"safari-extension:"+e:"safari-web-extension:"+e]:[i,e]},Jy=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Qy=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Zy=/\((\S*)(?::(\d+))(?::(\d+))\)/,eb=(i,e)=>{var t=Jy.exec(i);if(t){var[,s,r,n]=t;return ra(e,s,xi,+r,+n)}var o=Qy.exec(i);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Zy.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=gh(o[1]||xi,o[2]);return ra(e,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},tb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ib=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,sb=(i,e)=>{var t=tb.exec(i);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var s=ib.exec(t[3]);s&&(t[1]=t[1]||"eval",t[3]=s[1],t[4]=s[2],t[5]="")}var r=t[3],n=t[1]||xi;return[n,r]=gh(n,r),ra(e,r,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},rd=/\(error: (.*)\)/,nd=50;na=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var s=he(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:s?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 Br(e,"DOMException")}isDOMError(e){return Br(e,"DOMError")}},oa=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 s=e.message;return s.error&&typeof s.error.message=="string"?String(s.error.message):String(s)}getStack(e){return e.stacktrace||e.stack||void 0}},aa=class{constructor(){}match(e){return Br(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var s,r=t.apply(e.error);return r||{type:"ErrorEvent",value:e.message,stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}},nb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,la=class{match(e){return typeof e=="string"}coerce(e,t){var s,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}getInfos(e){var t="Error",s=e,r=e.match(nb);return r&&(t=r[1],s=r[2]),[t,s]}},ob=["fatal","error","warning","log","info","debug"];ca=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var s,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(s=t.syntheticException)==null?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return Ka(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 s=this.getObjectClassName(e);return(s&&s!=="Object"?"'"+s+"'":"Object")+" captured as exception with keys: "+fh(e)}isSeverityLevel(e){return he(e)&&!Qo(e)&&ob.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var s=e[t];if(Xy(s))return s}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},ua=class{match(e){return Ka(e)}coerce(e,t){var s,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+fh(e),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}},da=class{match(e){return Yd(e)}coerce(e,t){var s;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}},ha=class{match(e){return Br(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ka(e))return!1;try{var t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var s,r=this.getUnhandledRejectionReason(e);return Yd(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}},ph=function(i,e){var{debugEnabled:t}=e===void 0?{}:e,s={k:function(r){if(_&&(vt.DEBUG||O.POSTHOG_DEBUG||t)&&!S(_.console)&&_.console){for(var n=("__rrweb_original__"in _.console[r])?_.console[r].__rrweb_original__:_.console[r],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];n(i,...a)}},info:function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];s.k("log",...n)},warn:function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];s.k("warn",...n)},error:function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];s.k("error",...n)},critical:function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];console.error(i,...n)},uninitializedWarning:r=>{s.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>ph(i+" "+r,n)};return s},w=ph("[PostHog.js]"),le=w.createLogger,ab=le("[ExternalScriptsLoader]"),od=(i,e,t)=>{if(i.config.disable_external_dependency_loading)return ab.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var s=k?.querySelectorAll("script");if(s){for(var r,n=function(){if(s[o].src===e){var l=s[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(u=>{l.__posthog_loading_callback_fired=!0,t(void 0,u)})),l.onerror=u=>t(u),{v:void 0})}},o=0;o<s.length;o++)if(r=n())return r.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 u,c=k.querySelectorAll("body > script");c.length>0?(u=c[0].parentNode)==null||u.insertBefore(l,c[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 s="/static/"+e+".js?v="+i.version;if(e==="remote-config"&&(s="/array/"+i.config.token+"/config.js"),e==="toolbar"){var r=3e5;s=s+"&t="+Math.floor(Date.now()/r)*r}var n=i.requestRouter.endpointFor("assets",s);od(i,n,t)},O.__PosthogExtensions__.loadSiteApp=(i,e,t)=>{var s=i.requestRouter.endpointFor("api",e);od(i,s,t)};Gr={};ue=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s<e;s++)t[s-1]=arguments[s];return Lt(t,(function(r){for(var n in r)r[n]!==void 0&&(i[n]=r[n])})),i},Li=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s<e;s++)t[s-1]=arguments[s];return Lt(t,(function(r){Lt(r,(function(n){i.push(n)}))})),i};ad=function(i){try{return i()}catch{return}},lb=function(i){return function(){try{for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return i.apply(this,t)}catch(r){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(r)}}},Qa=function(i){var e={};return Z(i,(function(t,s){(he(t)&&t.length>0||at(t))&&(e[s]=t)})),e};ub=["herokuapp.com","vercel.app","netlify.app"];mh="$people_distinct_id",_s="__alias",ms="__timers",ld="$autocapture_disabled_server_side",ga="$heatmaps_enabled_server_side",cd="$exception_capture_enabled_server_side",fa="$error_tracking_suppression_rules",ud="$error_tracking_capture_extension_exceptions",dd="$web_vitals_enabled_server_side",yh="$dead_clicks_enabled_server_side",hd="$product_tours_enabled_server_side",gd="$web_vitals_allowed_metrics",Nr="$session_recording_remote_config",jr="$sesid",bh="$session_is_sampled",Oi="$enabled_feature_flags",ys="$early_access_features",pa="$feature_flag_details",bs="$stored_person_properties",Yt="$stored_group_properties",va="$surveys",Hr="$flag_call_reported",_a="$feature_flag_errors",qr="$feature_flag_evaluated_at",rt="$user_state",ma="$client_session_props",ya="$capture_rate_limit",ba="$initial_campaign_params",Ea="$initial_referrer_info",zr="$initial_person_info",Kr="$epp",Eh="__POSTHOG_TOOLBAR__",os="$posthog_cookieless",hb=[mh,_s,"__cmpns",ms,"$session_recording_enabled_server_side",ga,jr,Oi,fa,rt,ys,pa,Yt,bs,va,Hr,_a,qr,ma,ya,ba,Ea,Kr,zr];Math.trunc||(Math.trunc=function(i){return i<0?Math.ceil(i):Math.floor(i)}),Number.isInteger||(Number.isInteger=function(i){return at(i)&&isFinite(i)&&Math.floor(i)===i});fd="0123456789abcdef",ka=class i{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,s,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(s)||!Number.isInteger(r)||e<0||t<0||s<0||r<0||e>0xffffffffffff||t>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new i(n)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+fd.charAt(this.bytes[t]>>>4)+fd.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 s=this.bytes[t]-e.bytes[t];if(s!==0)return Math.sign(s)}return 0}},Sa=class{constructor(){this.P=0,this.T=0,this.R=new wa}generate(){var e=this.generateOrAbort();if(S(e)){this.P=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.P)this.P=e,this.I();else{if(!(e+1e4>this.P))return;this.T++,this.T>4398046511103&&(this.P++,this.I())}return ka.fromFieldsV7(this.P,Math.trunc(this.T/Math.pow(2,30)),this.T&Math.pow(2,30)-1,this.R.nextUint32())}I(){this.T=1024*this.R.nextUint32()+(1023&this.R.nextUint32())}},kh=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};_&&!S(_.crypto)&&crypto.getRandomValues&&(kh=i=>crypto.getRandomValues(i));wa=class{constructor(){this.C=new Uint32Array(8),this.O=1/0}nextUint32(){return this.O>=this.C.length&&(kh(this.C),this.O=0),this.C[this.O++]}},xt=()=>gb().toString(),gb=()=>(pd||(pd=new Sa)).generate(),as="",fb=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;nt={F:()=>!!k,M:function(i){w.error("cookieStore error: "+i)},A:function(i){if(k){try{for(var e=i+"=",t=k.cookie.split(";").filter((n=>n.length)),s=0;s<t.length;s++){for(var r=t[s];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}}catch{}return null}},D:function(i){var e;try{e=JSON.parse(nt.A(i))||{}}catch{}return e},j:function(i,e,t,s,r){if(k)try{var n="",o="",a=pb(k.location.hostname,s);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=i+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&w.warn("cookieStore warning: large cookie, len="+u.length),k.cookie=u,u}catch{return}},L:function(i,e){if(k!=null&&k.cookie)try{nt.j(i,"",-1,e)}catch{return}}},Lo=null,ae={F:function(){if(!Qe(Lo))return Lo;var i=!0;if(S(_))i=!1;else try{var e="__mplssupport__";ae.j(e,"xyz"),ae.A(e)!=='"xyz"'&&(i=!1),ae.L(e)}catch{i=!1}return i||w.error("localStorage unsupported; falling back to cookie store"),Lo=i,i},M:function(i){w.error("localStorage error: "+i)},A:function(i){try{return _?.localStorage.getItem(i)}catch(e){ae.M(e)}return null},D:function(i){try{return JSON.parse(ae.A(i))||{}}catch{}return null},j:function(i,e){try{_?.localStorage.setItem(i,JSON.stringify(e))}catch(t){ae.M(t)}},L:function(i){try{_?.localStorage.removeItem(i)}catch(e){ae.M(e)}}},vb=["$device_id","distinct_id",jr,bh,Kr,zr,rt],Dr={},_b={F:function(){return!0},M:function(i){w.error("memoryStorage error: "+i)},A:function(i){return Dr[i]||null},D:function(i){return Dr[i]||null},j:function(i,e){Dr[i]=e},L:function(i){delete Dr[i]}},Wt=null,me={F:function(){if(!Qe(Wt))return Wt;if(Wt=!0,S(_))Wt=!1;else try{var i="__support__";me.j(i,"xyz"),me.A(i)!=='"xyz"'&&(Wt=!1),me.L(i)}catch{Wt=!1}return Wt},M:function(i){w.error("sessionStorage error: ",i)},A:function(i){try{return _?.sessionStorage.getItem(i)}catch(e){me.M(e)}return null},D:function(i){try{return JSON.parse(me.A(i))||null}catch{}return null},j:function(i,e){try{_?.sessionStorage.setItem(i,JSON.stringify(e))}catch(t){me.M(t)}},L:function(i){try{_?.sessionStorage.removeItem(i)}catch(e){me.M(e)}}},mt=(function(i){return i[i.PENDING=-1]="PENDING",i[i.DENIED=0]="DENIED",i[i.GRANTED=1]="GRANTED",i})({}),Aa=class{constructor(e){this._instance=e}get N(){return this._instance.config}get consent(){return this.U()?mt.DENIED:this.H}isOptedOut(){return this.N.cookieless_mode==="always"||this.consent===mt.DENIED||this.consent===mt.PENDING&&(this.N.opt_out_capturing_by_default||this.N.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===mt.DENIED}optInOut(e){this.B.j(this.q,e?1:0,this.N.cookie_expiration,this.N.cross_subdomain_cookie,this.N.secure_cookie)}reset(){this.B.L(this.q,this.N.cross_subdomain_cookie)}get q(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:s}=this._instance.config;return s||(t?t+e:"__ph_opt_in_out_"+e)}get H(){var e=this.B.A(this.q);return No(e)?mt.GRANTED:U(My,e)?mt.DENIED:mt.PENDING}get B(){if(!this.V){var e=this.N.opt_out_capturing_persistence_type;this.V=e==="localStorage"?ae:nt;var t=e==="localStorage"?nt:ae;t.A(this.q)&&(this.V.A(this.q)||this.optInOut(No(t.A(this.q))),t.L(this.q,this.N.cross_subdomain_cookie))}return this.V}U(){return!!this.N.respect_dnt&&!!vh([Be?.doNotTrack,Be?.msDoNotTrack,O.doNotTrack],(e=>No(e)))}},xr=le("[Dead Clicks]"),mb=()=>!0,yb=i=>{var e,t=!((e=i.instance.persistence)==null||!e.get_property(yh)),s=i.instance.config.capture_dead_clicks;return kt(s)?s:!!ge(s)||t},Wr=class{get lazyLoadedDeadClicksAutocapture(){return this.W}constructor(e,t,s){this.instance=e,this.isEnabled=t,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[yh]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.G((()=>{this.Y()})):this.stop()}G(e){var t,s;(t=O.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(s=O.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?xr.error("failed to load script",r):e()}))}Y(){var e;if(k){if(!this.W&&(e=O.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=ge(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.W=O.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.W.start(k),xr.info("starting...")}}else xr.error("`document` not found. Cannot start.")}stop(){this.W&&(this.W.stop(),this.W=void 0,xr.info("stopping..."))}},$o=le("[SegmentIntegration]");Sh="posthog-js";Ta=class{constructor(e,t,s,r,n,o){this.name=Sh,this.setupOnce=function(a){a(wh(e,{organization:t,projectId:s,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},Xr=class{constructor(e){this.J=(t,s,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(w.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.K=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.X()}X(){var e;this.Z=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.J)}destroy(){var e;(e=this.Z)==null||e.call(this),this.Z=void 0}doPageView(e,t){var s,r=this.tt(e,t);return this.K={pathname:(s=_?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.tt(e,(t=this.K)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.K)==null?void 0:e.pageViewId}}tt(e,t){var s=this.K;if(!s)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:s.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:u,lastContentY:c,maxContentY:h}=n;if(!(S(o)||S(a)||S(l)||S(u)||S(c)||S(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),h=Math.ceil(h);var g=o<=1?1:ot(a/o,0,1,w),f=o<=1?1:ot(l/o,0,1,w),v=u<=1?1:ot(c/u,0,1,w),p=u<=1?1:ot(h/u,0,1,w);r=ue(r,{$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:c,$prev_pageview_last_content_percentage:v,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:p})}}return s.pathname&&(r.$prev_pageview_pathname=s.pathname),s.timestamp&&(r.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),r}},Yr=i=>{var e=k?.createElement("a");return S(e)?null:(e.href=i,e)},Eb=function(i,e){var t,s;e===void 0&&(e="&");var r=[];return Z(i,(function(n,o){S(n)||S(o)||o==="undefined"||(t=encodeURIComponent((a=>a instanceof File)(n)?n.name:n.toString()),s=encodeURIComponent(o),r[r.length]=s+"="+t)})),r.join(e)},Jr=function(i,e){for(var t,s=((i.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var n=s[r].split("=");if(n[0]===e){t=n;break}}if(!q(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," ")},Cs=function(i,e,t){if(!i||!e||!e.length)return i;for(var s=i.split("#"),r=s[0]||"",n=s[1],o=r.split("?"),a=o[1],l=o[0],u=(a||"").split("&"),c=[],h=0;h<u.length;h++){var g=u[h].split("=");q(g)&&(e.includes(g[0])?c.push(g[0]+"="+t):c.push(u[h]))}var f=l;return a!=null&&(f+="?"+c.join("&")),n!=null&&(f+="#"+n),f},Qr=function(i,e){var t=i.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Lr="https?://(.*)",$i=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],kb=Li(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],$i),Ps="<masked>",Sb=["li_fat_id"];Tb=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],ws=class{constructor(e,t){this.N=e,this.props={},this.it=!1,this.et=(s=>{var r="";return s.token&&(r=s.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),s.persistence_name?"ph_"+s.persistence_name:"ph_"+r+"_posthog"})(e),this.B=this.rt(e),this.load(),e.debug&&w.info("Persistence loaded",e.persistence,b({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.st}rt(e){Tb.indexOf(e.persistence.toLowerCase())===-1&&(w.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(r){r===void 0&&(r=[]);var n=[...vb,...r];return b({},ae,{D:function(o){try{var a={};try{a=nt.D(o)||{}}catch{}var l=ue(a,JSON.parse(ae.A(o)||"{}"));return ae.j(o,l),l}catch{}return null},j:function(o,a,l,u,c,h){try{ae.j(o,a,void 0,void 0,h);var g={};n.forEach((f=>{a[f]&&(g[f]=a[f])})),Object.keys(g).length&&nt.j(o,g,l,u,c,h)}catch(f){ae.M(f)}},L:function(o,a){try{_?.localStorage.removeItem(o),nt.L(o,a)}catch(l){ae.M(l)}}})})(e.cookie_persisted_properties||[]),s=e.persistence.toLowerCase();return s==="localstorage"&&ae.F()?ae:s==="localstorage+cookie"&&t.F()?t:s==="sessionstorage"&&me.F()?me:s==="memory"?_b:s==="cookie"?nt:t.F()?t:nt}nt(e){var t=e??this.N.feature_flag_cache_ttl_ms;if(!t||t<=0)return!1;var s=this.props[qr];return!s||typeof s!="number"||Date.now()-s>t}properties(){var e={};return Z(this.props,((t,s)=>{if(s===Oi&&ge(t)){if(!this.nt())for(var r=Object.keys(t),n=0;n<r.length;n++)e["$feature/"+r[n]]=t[r[n]]}else a=s,l=!1,(Qe(o=hb)?l:Yu&&o.indexOf===Yu?o.indexOf(a)!=-1:(Z(o,(function(u){if(l||(l=u===a))return Gr})),l))||(e[s]=t);var o,a,l})),e}load(){if(!this.st){var e=this.B.D(this.et);e&&(this.props=ue({},e))}}save(){this.st||this.B.j(this.et,this.props,this.ot,this.ut,this.ht,this.N.debug)}remove(){this.B.L(this.et,!1),this.B.L(this.et,!0)}clear(){this.remove(),this.props={}}register_once(e,t,s){if(ge(e)){S(t)&&(t="None"),this.ot=S(s)?this.dt:s;var r=!1;if(Z(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=n,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(ge(e)){this.ot=S(t)?this.dt:t;var s=!1;if(Z(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.props[n]=r,s=!0)})),s)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.it){var e=Ah(this.N.custom_campaign_params,this.N.mask_personal_data_properties,this.N.custom_personal_data_properties);Ri(Qa(e))||this.register(e),this.it=!0}}update_search_keyword(){var e;this.register((e=k?.referrer)?Ih(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Rh(),$referring_domain:k!=null&&k.referrer&&((e=Yr(k.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[ba]||this.props[Ea]||this.register_once({[zr]:Oh(this.N.mask_personal_data_properties,this.N.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Z([Ea,ba],(o=>{var a=this.props[o];a&&Z(a,(function(l,u){e["$initial_"+Jo(u)]=l}))}));var t,s,r=this.props[zr];if(r){var n=(t=Ch(r),s={},Z(t,(function(o,a){s["$initial_"+Jo(a)]=o})),s);ue(e,n)}return e}safe_merge(e){return Z(this.props,(function(t,s){s in e||(e[s]=t)})),e}update_config(e,t,s){if(this.dt=this.ot=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),u=[...a].sort();return l.every(((c,h)=>c===u[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.rt(e),n=this.props;this.clear(),this.B=r,this.props=n,this.save()}}set_disabled(e){this.st=e,this.st?this.remove():this.save()}set_cross_subdomain(e){e!==this.ut&&(this.ut=e,this.remove(),this.save())}set_secure(e){e!==this.ht&&(this.ht=e,this.remove(),this.save())}set_event_timer(e,t){var s=this.props[ms]||{};s[e]=t,this.props[ms]=s,this.save()}remove_event_timer(e){var t=(this.props[ms]||{})[e];return S(t)||(delete this.props[ms][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},ls={Activation:"events",Cancellation:"cancelEvents"},Fo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Es={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Mo={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},Ia={Popover:"popover",Inline:"inline"},Ib=(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})({}),_d=(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.TOUR_LAST_SEEN_DATE="$product_tour_last_seen_date",i.TOUR_TYPE="$product_tour_type",i})({}),md=le("[RateLimiter]"),Ra=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var s=t.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach((r=>{md.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void md.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:s})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,s,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(s=this.instance.persistence)==null?void 0:s.get_property(ya))!==null&&t!==void 0?t:{tokens:n,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>n&&(l.tokens=n);var u=l.tokens<1;return u||e||(l.tokens=Math.max(0,l.tokens-1)),!u||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=u,(r=this.instance.persistence)==null||r.set_property(ya,l),{isRateLimited:u,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},cs=le("[RemoteConfig]"),Zr=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}vt(e){var t,s;(t=O.__PosthogExtensions__)!=null&&t.loadExternalDependency?(s=O.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}ct(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return cs.info("Using preloaded remote config",this.remoteConfig),this.ft(this.remoteConfig),void this._t();if(this._instance.bt())return void cs.warn("Remote config is disabled. Falling back to local config.");this.vt((e=>{if(!e)return cs.info("No config found after loading remote JS config. Falling back to JSON."),void this.ct((t=>{this.ft(t),this._t()}));this.ft(e),this._t()}))}catch(e){cs.error("Error loading remote config",e)}}stop(){this.yt&&(clearInterval(this.yt),this.yt=void 0)}refresh(){this._instance.bt()||k?.visibilityState==="hidden"||this._instance.reloadFeatureFlags()}_t(){var e;if(!this.yt){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.yt=setInterval((()=>{this.refresh()}),t))}}ft(e){var t;e||cs.error("Failed to fetch remote config from PostHog."),this._instance.ft(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},yt=(function(i){return i.GZipJS="gzip-js",i.Base64="base64",i})({}),We=Uint8Array,Te=Uint16Array,Fi=Uint32Array,Za=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]),el=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]),yd=new We([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Nh=function(i,e){for(var t=new Te(31),s=0;s<31;++s)t[s]=e+=1<<i[s-1];var r=new Fi(t[30]);for(s=1;s<30;++s)for(var n=t[s];n<t[s+1];++n)r[n]=n-t[s]<<5|s;return[t,r]},Dh=Nh(Za,2),Rb=Dh[0],Oa=Dh[1];Rb[28]=258,Oa[258]=28;for(Ca=Nh(el,0)[1],en=new Te(32768),ee=0;ee<32768;++ee)Ct=(43690&ee)>>>1|(21845&ee)<<1,Ct=(61680&(Ct=(52428&Ct)>>>2|(13107&Ct)<<2))>>>4|(3855&Ct)<<4,en[ee]=((65280&Ct)>>>8|(255&Ct)<<8)>>>1;As=function(i,e,t){for(var s=i.length,r=0,n=new Te(e);r<s;++r)++n[i[r]-1];var o,a=new Te(e);for(r=0;r<e;++r)a[r]=a[r-1]+n[r-1]<<1;if(t){o=new Te(1<<e);var l=15-e;for(r=0;r<s;++r)if(i[r])for(var u=r<<4|i[r],c=e-i[r],h=a[i[r]-1]++<<c,g=h|(1<<c)-1;h<=g;++h)o[en[h]>>>l]=u}else for(o=new Te(s),r=0;r<s;++r)o[r]=en[a[i[r]-1]++]>>>15-i[r];return o},Qt=new We(288);for(ee=0;ee<144;++ee)Qt[ee]=8;for(ee=144;ee<256;++ee)Qt[ee]=9;for(ee=256;ee<280;++ee)Qt[ee]=7;for(ee=280;ee<288;++ee)Qt[ee]=8;tn=new We(32);for(ee=0;ee<32;++ee)tn[ee]=5;Ob=As(Qt,9,0),Cb=As(tn,5,0),xh=function(i){return(i/8>>0)+(7&i&&1)},Lh=function(i,e,t){(t==null||t>i.length)&&(t=i.length);var s=new(i instanceof Te?Te:i instanceof Fi?Fi:We)(t-e);return s.set(i.subarray(e,t)),s},pt=function(i,e,t){t<<=7&e;var s=e/8>>0;i[s]|=t,i[s+1]|=t>>>8},us=function(i,e,t){t<<=7&e;var s=e/8>>0;i[s]|=t,i[s+1]|=t>>>8,i[s+2]|=t>>>16},Uo=function(i,e){for(var t=[],s=0;s<i.length;++s)i[s]&&t.push({s,f:i[s]});var r=t.length,n=t.slice();if(!r)return[new We(0),0];if(r==1){var o=new We(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(M,F){return M.f-F.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],u=0,c=1,h=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=t[t[u].f<t[h].f?u++:h++],l=t[u!=c&&t[u].f<t[h].f?u++:h++],t[c++]={s:-1,f:a.f+l.f,l:a,r:l};var g=n[0].s;for(s=1;s<r;++s)n[s].s>g&&(g=n[s].s);var f=new Te(g+1),v=Pa(t[c-1],f,0);if(v>e){s=0;var p=0,m=v-e,E=1<<m;for(n.sort((function(M,F){return f[F.s]-f[M.s]||M.f-F.f}));s<r;++s){var T=n[s].s;if(!(f[T]>e))break;p+=E-(1<<v-f[T]),f[T]=e}for(p>>>=m;p>0;){var x=n[s].s;f[x]<e?p-=1<<e-f[x]++-1:++s}for(;s>=0&&p;--s){var R=n[s].s;f[R]==e&&(--f[R],++p)}v=e}return[new We(f),v]},Pa=function(i,e,t){return i.s==-1?Math.max(Pa(i.l,e,t+1),Pa(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),s=0,r=i[0],n=1,o=function(l){t[s++]=l},a=1;a<=e;++a)if(i[a]==r&&a!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=i[a]}return[t.subarray(0,s),e]},ds=function(i,e){for(var t=0,s=0;s<e.length;++s)t+=i[s]*e[s];return t},Na=function(i,e,t){var s=t.length,r=xh(e+2);i[r]=255&s,i[r+1]=s>>>8,i[r+2]=255^i[r],i[r+3]=255^i[r+1];for(var n=0;n<s;++n)i[r+n+4]=t[n];return 8*(r+4+s)},Ed=function(i,e,t,s,r,n,o,a,l,u,c){pt(e,c++,t),++r[256];for(var h=Uo(r,15),g=h[0],f=h[1],v=Uo(n,15),p=v[0],m=v[1],E=bd(g),T=E[0],x=E[1],R=bd(p),M=R[0],F=R[1],W=new Te(19),$=0;$<T.length;++$)W[31&T[$]]++;for($=0;$<M.length;++$)W[31&M[$]]++;for(var ve=Uo(W,7),Se=ve[0],Ge=ve[1],Le=19;Le>4&&!Se[yd[Le-1]];--Le);var je,A,P,L,N=u+5<<3,fe=ds(r,Qt)+ds(n,tn)+o,H=ds(r,g)+ds(n,p)+o+14+3*Le+ds(W,Se)+(2*W[16]+3*W[17]+7*W[18]);if(N<=fe&&N<=H)return Na(e,c,i.subarray(l,l+u));if(pt(e,c,1+(H<fe)),c+=2,H<fe){je=As(g,f,0),A=g,P=As(p,m,0),L=p;var z=As(Se,Ge,0);for(pt(e,c,x-257),pt(e,c+5,F-1),pt(e,c+10,Le-4),c+=14,$=0;$<Le;++$)pt(e,c+3*$,Se[yd[$]]);c+=3*Le;for(var Q=[T,M],V=0;V<2;++V){var se=Q[V];for($=0;$<se.length;++$){var C=31&se[$];pt(e,c,z[C]),c+=Se[C],C>15&&(pt(e,c,se[$]>>>5&127),c+=se[$]>>>12)}}}else je=Ob,A=Qt,P=Cb,L=tn;for($=0;$<a;++$)if(s[$]>255){C=s[$]>>>18&31,us(e,c,je[C+257]),c+=A[C+257],C>7&&(pt(e,c,s[$]>>>23&31),c+=Za[C]);var Ie=31&s[$];us(e,c,P[Ie]),c+=L[Ie],Ie>3&&(us(e,c,s[$]>>>5&8191),c+=el[Ie])}else us(e,c,je[s[$]]),c+=A[s[$]];return us(e,c,je[256]),c+A[256]},Pb=new Fi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Nb=(function(){for(var i=new Fi(256),e=0;e<256;++e){for(var t=e,s=9;--s;)t=(1&t&&3988292384)^t>>>1;i[e]=t}return i})(),Db=function(i,e,t,s,r){return(function(n,o,a,l,u,c){var h=n.length,g=new We(l+h+5*(1+Math.floor(h/7e3))+u),f=g.subarray(l,g.length-u),v=0;if(!o||h<8)for(var p=0;p<=h;p+=65535){var m=p+65535;m<h?v=Na(f,v,n.subarray(p,m)):(f[p]=c,v=Na(f,v,n.subarray(p,h)))}else{for(var E=Pb[o-1],T=E>>>13,x=8191&E,R=(1<<a)-1,M=new Te(32768),F=new Te(R+1),W=Math.ceil(a/3),$=2*W,ve=function(wt){return(n[wt]^n[wt+1]<<W^n[wt+2]<<$)&R},Se=new Fi(25e3),Ge=new Te(288),Le=new Te(32),je=0,A=0,P=(p=0,0),L=0,N=0;p<h;++p){var fe=ve(p),H=32767&p,z=F[fe];if(M[H]=z,F[fe]=H,L<=p){var Q=h-p;if((je>7e3||P>24576)&&Q>423){v=Ed(n,f,0,Se,Ge,Le,A,P,N,p-N,v),P=je=A=0,N=p;for(var V=0;V<286;++V)Ge[V]=0;for(V=0;V<30;++V)Le[V]=0}var se=2,C=0,Ie=x,$e=H-z&32767;if(Q>2&&fe==ve(p-$e))for(var ei=Math.min(T,Q)-1,Ls=Math.min(32767,p),Ui=Math.min(258,Q);$e<=Ls&&--Ie&&H!=z;){if(n[p+se]==n[p+se-$e]){for(var Fe=0;Fe<Ui&&n[p+Fe]==n[p+Fe-$e];++Fe);if(Fe>se){if(se=Fe,C=$e,Fe>ei)break;var Bi=Math.min($e,Fe-2),ti=0;for(V=0;V<Bi;++V){var Ft=p-$e+V+32768&32767,ii=Ft-M[Ft]+32768&32767;ii>ti&&(ti=ii,z=Ft)}}}$e+=(H=z)-(z=M[H])+32768&32767}if(C){Se[P++]=268435456|Oa[se]<<18|Ca[C];var si=31&Oa[se],ri=31&Ca[C];A+=Za[si]+el[ri],++Ge[257+si],++Le[ri],L=p+se,++je}else Se[P++]=n[p],++Ge[n[p]]}}v=Ed(n,f,c,Se,Ge,Le,A,P,N,p-N,v)}return Lh(g,0,l+xh(v)+u)})(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,s,!0)},Bo=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};Lb=function(i){var e,t,s,r,n="";for(e=t=0,s=(i=(i+"").replace(/\r\n/g,`
16
16
  `).replace(/\r/g,`
17
- `)).length,r=0;r<s;r++){var o=i.charCodeAt(r),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&&(n+=i.substring(e,t)),n+=a,e=t=r+1)}return t>e&&(n+=i.substring(e,i.length)),n},Vb=!!Ko||!!zo,en=function(i,e,t){var s;t===void 0&&(t=!0);var[r,n]=i.split("?"),o=k({},e),a=(s=n?.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&&s!==void 0?s:[],l=_b(o);return l&&a.push(l),r+"?"+a.join("&")},Es=(i,e)=>JSON.stringify(i,((t,s)=>typeof s=="bigint"?s.toString():s),e),Uo=i=>{var{data:e,compression:t}=i;if(e){if(t===yt.GZipJS){var s=Ub((function(a,l){var c=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var u=new We(a.length+(a.length>>>1)),h=0,g=function(m){u[h++]=m},f=0;f<c;++f){if(h+5>u.length){var v=new We(h+8+(c-f<<1));v.set(u),u=v}var p=a.charCodeAt(f);p<128||l?g(p):p<2048?(g(192|p>>>6),g(128|63&p)):p>55295&&p<57344?(g(240|(p=65536+(1047552&p)|1023&a.charCodeAt(++f))>>>18),g(128|p>>>12&63),g(128|p>>>6&63),g(128|63&p)):(g(224|p>>>12),g(128|p>>>6&63),g(128|63&p))}return Ph(u,0,h)})(Es(e)),{mtime:0});return{contentType:"text/plain",body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(t===yt.Base64){var r=(function(a){var l,c,u,h,g,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,p=0,m="",E=[];if(!a)return a;a=Bb(a);do l=(g=a.charCodeAt(v++)<<16|a.charCodeAt(v++)<<8|a.charCodeAt(v++))>>18&63,c=g>>12&63,u=g>>6&63,h=63&g,E[p++]=f.charAt(l)+f.charAt(c)+f.charAt(u)+f.charAt(h);while(v<a.length);switch(m=E.join(""),a.length%3){case 1:m=m.slice(0,-2)+"==";break;case 2:m=m.slice(0,-1)+"="}return m})(Es(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Es(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Es(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Fr=[];zo&&Fr.push({transport:"fetch",method:i=>{var e,t,{contentType:s,body:r,estimatedSize:n}=(e=Uo(i))!==null&&e!==void 0?e:{},o=new Headers;Z(i.headers,(function(u,h){o.append(h,u)})),s&&o.append("Content-Type",s);var a=i.url,l=null;if(Xu){var c=new Xu;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),i.timeout)}}zo(a,k({method:i?.method||"GET",headers:o,keepalive:i.method==="POST"&&(n||0)<52428.8,body:r,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){A.error(f)}i.callback==null||i.callback(g)})))).catch((u=>{A.error(u),i.callback==null||i.callback({statusCode:0,error:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Ko&&Fr.push({transport:"XHR",method:i=>{var e,t=new Ko;t.open(i.method||"GET",i.url,!0);var{contentType:s,body:r}=(e=Uo(i))!==null&&e!==void 0?e:{};Z(i.headers,(function(n,o){t.setRequestHeader(o,n)})),s&&t.setRequestHeader("Content-Type",s),i.timeout&&(t.timeout=i.timeout),i.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}i.callback==null||i.callback(n)}},t.send(r)}}),Ve!=null&&Ve.sendBeacon&&Fr.push({transport:"sendBeacon",method:i=>{var e=en(i.url,{beacon:"1"});try{var t,{contentType:s,body:r}=(t=Uo(i))!==null&&t!==void 0?t:{},n=typeof r=="string"?new Blob([r],{type:s}):r;Ve.sendBeacon(e,n)}catch{}}});Na=3e3,Da=class{constructor(e,t){this.Nt=!0,this.Ut=[],this.zt=ot(t?.flush_interval_ms||Na,250,5e3,A.createLogger("flush interval"),Na),this.Ht=e}enqueue(e){this.Ut.push(e),this.Bt||this.qt()}unload(){this.Vt();var e=this.Ut.length>0?this.Wt():{},t=Object.values(e);[...t.filter((s=>s.url.indexOf("/e")===0)),...t.filter((s=>s.url.indexOf("/e")!==0))].map((s=>{this.Ht(k({},s,{transport:"sendBeacon"}))}))}enable(){this.Nt=!1,this.qt()}qt(){var e=this;this.Nt||(this.Bt=setTimeout((()=>{if(this.Vt(),this.Ut.length>0){var t=this.Wt(),s=function(){var n=t[r],o=new Date().getTime();n.data&&q(n.data)&&Z(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Ht(n)};for(var r in t)s()}}),this.zt))}Vt(){clearTimeout(this.Bt),this.Bt=void 0}Wt(){var e={};return Z(this.Ut,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;w(e[n])&&(e[n]=k({},r,{data:[]})),(s=e[n].data)==null||s.push(r.data)})),this.Ut=[],e}},Gb=["retriesPerformedSoFar"],xa=class{constructor(e){this.Gt=!1,this.Yt=3e3,this.Ut=[],this._instance=e,this.Ut=[],this.Jt=!0,!w(_)&&"onLine"in _.navigator&&(this.Jt=_.navigator.onLine,this.Kt=()=>{this.Jt=!0,this.Xt()},this.Qt=()=>{this.Jt=!1},de(_,"online",this.Kt),de(_,"offline",this.Qt))}get length(){return this.Ut.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=jd(e,Gb);Ti(t)&&(s.url=en(s.url,{retry_count:t})),this._instance._send_request(k({},s,{callback:r=>{r.statusCode!==200&&(r.statusCode<400||r.statusCode>=500)&&(t??0)<10?this.Zt(k({retriesPerformedSoFar:t},s)):s.callback==null||s.callback(r)}}))}Zt(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var s=(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),r=Date.now()+s;this.Ut.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+s;navigator.onLine||(n+=" (Browser is offline)"),A.warn(n),this.Gt||(this.Gt=!0,this.ti())}ti(){if(this.ii&&clearTimeout(this.ii),this.Ut.length===0)return this.Gt=!1,void(this.ii=void 0);this.ii=setTimeout((()=>{this.Jt&&this.Ut.length>0&&this.Xt(),this.ti()}),this.Yt)}Xt(){var e=Date.now(),t=[],s=this.Ut.filter((n=>n.retryAt<e||(t.push(n),!1)));if(this.Ut=t,s.length>0)for(var{requestOptions:r}of s)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.ii&&(clearTimeout(this.ii),this.ii=void 0),this.Gt=!1,w(_)||(this.Kt&&(_.removeEventListener("online",this.Kt),this.Kt=void 0),this.Qt&&(_.removeEventListener("offline",this.Qt),this.Qt=void 0)),this.Ut))try{this._instance._send_request(k({},e,{transport:"sendBeacon"}))}catch(t){A.error(t)}this.Ut=[]}},La=class{constructor(e){this.ei=()=>{var t,s,r,n;this.ri||(this.ri={});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.ri.lastScrollY=Math.ceil(a),this.ri.maxScrollY=Math.max(a,(t=this.ri.maxScrollY)!==null&&t!==void 0?t:0),this.ri.maxScrollHeight=Math.max(l,(s=this.ri.maxScrollHeight)!==null&&s!==void 0?s:0),this.ri.lastContentY=c,this.ri.maxContentY=Math.max(c,(r=this.ri.maxContentY)!==null&&r!==void 0?r:0),this.ri.maxContentHeight=Math.max(u,(n=this.ri.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}getContext(){return this.ri}resetContext(){var e=this.ri;return setTimeout(this.ei,0),e}startMeasuringScrollPosition(){de(_,"scroll",this.ei,{capture:!0}),de(_,"scrollend",this.ei,{capture:!0}),de(_,"resize",this.ei)}scrollElement(){if(!this._instance.config.scroll_root_selector)return _?.document.documentElement;var e=q(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var s=_?.document.querySelector(t);if(s)return s}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return _&&(_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return _&&(_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft)||0}},jb=i=>Ah(i?.config.mask_personal_data_properties,i?.config.custom_personal_data_properties),tn=class{constructor(e,t,s,r){this.si=n=>{var o=this.ni();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.oi(this._instance)};this.ai.register({[va]:a})}},this._instance=e,this.li=t,this.ai=s,this.oi=r||jb,this.li.onSessionId(this.si)}ni(){return this.ai.props[va]}getSetOnceProps(){var e,t=(e=this.ni())==null?void 0:e.props;return t?"r"in t?Th(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 Z(Ya(this.getSetOnceProps()),((t,s)=>{s==="$current_url"&&(s="url"),e["$session_entry_"+Wo(s)]=t})),e}},Ps=class{constructor(){this.ui={},this.ui={}}on(e,t){return this.ui[e]||(this.ui[e]=[]),this.ui[e].push(t),()=>{this.ui[e]=this.ui[e].filter((s=>s!==t))}}emit(e,t){for(var s of this.ui[e]||[])s(t);for(var r of this.ui["*"]||[])r(e,t)}},Bo=le("[SessionId]"),sn=class{on(e,t){return this.hi.on(e,t)}constructor(e,t,s){var r;if(this.di=[],this.vi=void 0,this.hi=new Ps,this.ci=(u,h)=>!(!Ti(u)||!Ti(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.N=e.config,this.ai=e.persistence,this.fi=void 0,this.pi=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.gi=t||xt,this.mi=s||xt;var n=this.N.persistence_name||this.N.token,o=this.N.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*ot(o,60,36e3,Bo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.bi(),this.yi="ph_"+n+"_window_id",this.wi="ph_"+n+"_primary_window_exists",this.Ei()){var a=ye.D(this.yi),l=ye.D(this.wi);a&&!l?this.fi=a:ye.j(this.yi),ye.L(this.wi,!0)}if((r=this.N.bootstrap)!=null&&r.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.N.bootstrap.sessionID);this.xi(this.N.bootstrap.sessionID,new Date().getTime(),c)}catch(u){Bo.error("Invalid sessionID in bootstrap",u)}this.Si()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return w(this.di)&&(this.di=[]),this.di.push(e),this.pi&&e(this.pi,this.fi),()=>{this.di=this.di.filter((t=>t!==e))}}Ei(){return this.N.persistence!=="memory"&&!this.ai.Rt&&ye.F()}$i(e){e!==this.fi&&(this.fi=e,this.Ei()&&ye.L(this.yi,e))}ki(){return this.fi?this.fi:this.Ei()?ye.D(this.yi):null}xi(e,t,s){e===this.pi&&t===this._sessionActivityTimestamp&&s===this._sessionStartTimestamp||(this._sessionStartTimestamp=s,this._sessionActivityTimestamp=t,this.pi=e,this.ai.register({[Vr]:[t,e,s]}))}Pi(){var e=this.ai.props[Vr];return q(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.xi(null,null,null)}destroy(){clearTimeout(this.Ti),this.Ti=void 0,this.vi&&_&&(_.removeEventListener("beforeunload",this.vi,{capture:!1}),this.vi=void 0),this.di=[]}Si(){this.vi=()=>{this.Ei()&&ye.j(this.wi)},de(_,"beforeunload",this.vi,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.N.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=t||new Date().getTime(),[r,n,o]=this.Pi(),a=this.ki(),l=Ti(o)&&Math.abs(s-o)>864e5,c=!1,u=!n,h=!u&&!e&&this.ci(s,r);u||h||l?(n=this.gi(),a=this.mi(),Bo.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}}),o=s,c=!0):a||(a=this.mi(),c=!0);var g=Ti(r)&&e&&!l?r:s,f=Ti(o)?o:new Date().getTime();return this.$i(a),this.xi(n,g,f),e||this.bi(),c&&this.di.forEach((v=>v(n,a,c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:f,changeReason:c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}bi(){clearTimeout(this.Ti),this.Ti=setTimeout((()=>{var[e]=this.Pi();if(this.ci(new Date().getTime(),e)){var t=this.pi;this.resetSessionId(),this.hi.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},Nh=function(i,e){if(!i)return!1;var t=i.userAgent;if(t&&Qu(t,e))return!0;try{var s=i?.userAgentData;if(s!=null&&s.brands&&s.brands.some((r=>Qu(r?.brand,e))))return!0}catch{}return!!i.webdriver},rn=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}};Dh={exact:(i,e)=>e.some((t=>i.some((s=>t===s)))),is_not:(i,e)=>e.every((t=>i.every((s=>t!==s)))),regex:(i,e)=>e.some((t=>i.some((s=>rn(t,s))))),not_regex:(i,e)=>e.every((t=>i.every((s=>!rn(t,s))))),icontains:(i,e)=>e.map(Lr).some((t=>i.map(Lr).some((s=>t.includes(s))))),not_icontains:(i,e)=>e.map(Lr).every((t=>i.map(Lr).every((s=>!t.includes(s))))),gt:(i,e)=>e.some((t=>{var s=parseFloat(t);return!isNaN(s)&&i.some((r=>s>parseFloat(r)))})),lt:(i,e)=>e.some((t=>{var s=parseFloat(t);return!isNaN(s)&&i.some((r=>s<parseFloat(r)))}))},Lr=i=>i.toLowerCase();ks=(function(i){return i.US="us",i.EU="eu",i.CUSTOM="custom",i})({}),wd="i.posthog.com",$a=class{constructor(e){this.Ri={},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("."+wd,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Ri[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Ri[this.apiHost]=ks.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Ri[this.apiHost]=ks.EU:this.Ri[this.apiHost]=ks.CUSTOM),this.Ri[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===ks.CUSTOM)return this.apiHost+t;var s=wd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+s;case"api":return"https://"+this.region+"."+s}}},Q=le("[Surveys]"),Lh="seenSurvey_",Hb=(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},Ad=i=>((e,t)=>{var s=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(s=""+e+t.id+"_"+t.current_iteration),s})(Lh,i),qb=[Lo.Popover,Lo.Widget,Lo.API],zb={ignoreConditions:!1,ignoreDelay:!1,displayType:Ta.Popover},Kb=le("[PostHog ExternalIntegrations]"),Wb={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Fa=class{constructor(e){this._instance=e}G(e,t){var s;(s=C.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,e,(r=>{if(r)return Kb.error("failed to load script",r);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!r||(a=C.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.G(Wb[o],(()=>{var u;(u=C.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!r&&(l=C.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=C.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[s,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;t(s)}}},As={},Vo=0,Ma=()=>{},Ii="posthog",$h=!Vb&&xe?.indexOf("MSIE")===-1&&xe?.indexOf("Mozilla")===-1,Td=i=>{var e;return k({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:ab(S?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ma,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&&he(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:(_==null||(e=_.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var s="Bad HTTP status: "+t.statusCode+" "+t.text;A.error(s)},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:Na},error_tracking:{},_onCapture:Ma,__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))},Id=i=>{var e={};w(i.process_person)||(e.person_profiles=i.process_person),w(i.xhr_headers)||(e.request_headers=i.xhr_headers),w(i.cookie_name)||(e.persistence_name=i.cookie_name),w(i.disable_cookie)||(e.disable_persistence=i.disable_cookie),w(i.store_google)||(e.save_campaign_params=i.store_google),w(i.verbose)||(e.debug=i.verbose);var t=ue({},e,i);return q(i.property_blacklist)&&(w(i.property_denylist)?t.property_denylist=i.property_blacklist:q(i.property_denylist)?t.property_denylist=[...i.property_blacklist,...i.property_denylist]:A.error("Invalid value for property_denylist config: "+i.property_denylist)),t},Ua=class{constructor(){this.__forceAllowLocalhost=!1}get Ii(){return this.__forceAllowLocalhost}set Ii(e){A.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Mi=class i{Ci(e,t){if(e){var s=this.Oi.indexOf(e);s!==-1&&this.Oi.splice(s,1)}return this.Oi.push(t),t.initialize==null||t.initialize(),t}get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new Ua,this.Fi=!1,this.version=vt.LIB_VERSION,this.yt=new Ps,this.Oi=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Td(),this.SentryIntegration=wa,this.sentryIntegration=s=>(function(r,n){var o=bh(r,n);return{name:yh,processEvent:a=>o(a)}})(this,s),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Mi=!1,this.Ai=null,this.Di=null,this.Li=null,this.featureFlags=new Aa(this),this.scrollManager=new La(this),this.pageViewManager=new Kr(this),this.rateLimiter=new Ia(this),this.requestRouter=new $a(this),this.consent=new Sa(this),this.externalIntegrations=new Fa(this);var t=(e=i.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(s,r,n)=>{var o=he(s)?{[s]:r}:s;this.setPersonProperties(o),n?.({})},set_once:(s,r,n)=>{var o=he(s)?{[s]:r}:s;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(s=>A.info('send "'+s?.event+'"',s)))}init(e,t,s){if(s&&s!==Ii){var r,n=(r=As[s])!==null&&r!==void 0?r:new i;return n._init(e,t,s),As[s]=n,As[Ii][s]=n,n}return this._init(e,t,s)}_init(e,t,s){var r;if(t===void 0&&(t={}),w(e)||Xo(e))return A.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.ji(t.debug),this.Ni=t,this.Ui=[],t.person_profiles?this.Di=t.person_profiles:t.process_person&&(this.Di=t.process_person),this.set_config(ue({},Td(t.defaults),Id(t),{name:s,token:e})),this.config.on_xhr_error&&A.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:yt.GZipJS;var n=this.zi();this.persistence=new Ss(this.config,n),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Ss(k({},this.config,{persistence:"sessionStorage"}),n);var o=k({},this.persistence.props),a=k({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Hi=new Da((b=>this.Bi(b)),this.config.request_queue_config),this.qi=new xa(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 sn(this),this.sessionPropsManager=new tn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(A.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Vi(l)}),0)):(A.info("Initializing extensions synchronously"),this.Vi(l)),vt.DEBUG=vt.DEBUG||this.config.debug,vt.DEBUG&&A.info("Starting in debug mode",{this:this,config:t,thisC:k({},this.config),p:o,s:a}),((r=t.bootstrap)==null?void 0:r.distinctID)!==void 0){var c,u,h=this.config.get_device_id(xt()),g=(c=t.bootstrap)!=null&&c.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(rt,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:g})}if(this.Wi()){var f,v,p=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlags)||{}).filter((b=>{var O;return!((O=t.bootstrap)==null||(O=O.featureFlags)==null||!O[b])})).reduce(((b,O)=>{var P;return b[O]=((P=t.bootstrap)==null||(P=P.featureFlags)==null?void 0:P[O])||!1,b}),{}),m=Object.keys(((v=t.bootstrap)==null?void 0:v.featureFlagPayloads)||{}).filter((b=>p[b])).reduce(((b,O)=>{var P,I;return(P=t.bootstrap)!=null&&(P=P.featureFlagPayloads)!=null&&P[O]&&(b[O]=(I=t.bootstrap)==null||(I=I.featureFlagPayloads)==null?void 0:I[O]),b}),{});this.featureFlags.receivedFeatureFlags({featureFlags:p,featureFlagPayloads:m})}if(l)this.register_once({distinct_id:os,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id(xt());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(rt,"anonymous")}return de(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?vb(this,(()=>this.Gi())):this.Gi(),bt(this.config._onCapture)&&this.config._onCapture!==Ma&&(A.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(b=>this.config._onCapture(b.event,b)))),this.config.ip&&A.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Vi(e){var t,s,r,n,o,a,l=performance.now(),c=k({},i.__defaultExtensionClasses,this.config.__extensionClasses),u=[];c.exceptions&&this.Oi.push(this.exceptions=(t=this.exceptions)!==null&&t!==void 0?t:new c.exceptions(this)),c.historyAutocapture&&this.Oi.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this.Oi.push(new c.tracingHeaders(this)),c.siteApps&&this.Oi.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this.Oi.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||u.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this.Oi.push(this.autocapture=new c.autocapture(this)),c.surveys&&this.Oi.push(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new c.surveys(this)),c.logs&&this.Oi.push(this.logs=(r=this.logs)!==null&&r!==void 0?r:new c.logs(this)),c.conversations&&this.Oi.push(this.conversations=(n=this.conversations)!==null&&n!==void 0?n:new c.conversations(this)),c.productTours&&this.Oi.push(this.productTours=new c.productTours(this)),c.heatmaps&&this.Oi.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this.Oi.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this.Oi.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this.Oi.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,pb)),c.toolbar&&this.Oi.push(this.toolbar=(o=this.toolbar)!==null&&o!==void 0?o:new c.toolbar(this)),c.experiments&&this.Oi.push(this.experiments=(a=this.experiments)!==null&&a!==void 0?a:new c.experiments(this)),this.Oi.forEach((h=>{h.initialize&&u.push((()=>{h.initialize==null||h.initialize()}))})),u.push((()=>{if(this.Yi){var h=this.Yi;this.Yi=void 0,this.Dt(h)}})),this.Ji(u,l)}Ji(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.Ji(e,t)}),0);var s=e.shift();if(s)try{s()}catch(n){A.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&A.info("PostHog extensions initialized ("+r+"ms)")}Dt(e){var t;if(!S||!S.body)return A.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Dt(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Yi=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=M(e.supportedCompression,yt.GZipJS)?yt.GZipJS:M(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.Di?this.Di:"identified_only"}),this.Oi.forEach((s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(e)))}Gi(){try{this.config.loaded(this)}catch(s){A.critical("`loaded` function failed",s)}if(this.Ki(),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.Xi()}),1),this.Qi=new Qr(this),this.Qi.load()}Ki(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Hi)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Lt(this.__request_queue,(e=>this.Bi(e))),this.__request_queue=[],this.Ki()}_handle_unload(){var e,t,s;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Zi()&&this.capture("$pageleave"),(t=this.Hi)==null||t.unload(),(s=this.qi)==null||s.unload()):this.Zi()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&($h?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=en(e.url,{ip:this.config.ip?1:0}),e.headers=k({},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 s,r,n,o=k({},t);o.timeout=o.timeout||6e4,o.url=en(o.url,{_:new Date().getTime().toString(),ver:vt.LIB_VERSION,compression:o.compression});var a=(s=o.transport)!==null&&s!==void 0?s:"fetch",l=Fr.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(r=(n=hh(l,(u=>u.transport===a)))==null?void 0:n.method)!==null&&r!==void 0?r:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(k({},e,{callback:t=>{var s,r;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((s=(r=this.config).on_request_error)==null||s.call(r,t)),e.callback==null||e.callback(t)}}))))}Bi(e){this.qi?this.qi.retriableRequest(e):this._send_request(e)}_execute_array(e){Vo++;try{var t,s=[],r=[],n=[];Lt(e,(a=>{a&&(t=a[0],q(t)?n.push(a):bt(a)?a.call(this):q(a)&&t==="alias"?s.push(a):q(a)&&t.indexOf("capture")!==-1&&bt(this[t])?n.push(a):r.push(a))}));var o=function(a,l){Lt(a,(function(c){if(q(c[0])){var u=l;Z(c,(function(h){u=u[h[0]].apply(u,h.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};o(s,this),o(r,this),o(n,this)}finally{Vo--}}Wi(){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(Vo>0&&q(e)&&he(e[0])){var t=i.prototype[e[0]];bt(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,s){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Hi){if(this.is_capturing())if(!w(e)&&he(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(n&&!this.config.__preview_capture_bot_pageviews)){var o=s!=null&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!he(t?.$current_url)&&(A.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"||s!=null&&s.te||A.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=s?.timestamp||a,c=xt(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&n&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),s?.$set&&(u.$set=s?.$set);var h,g=e!=="$groupidentify",f=this.ie(s?.$set_once,g);if(f&&(u.$set_once=f),(u=nb(u,s!=null&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,w(s?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===bs.DISMISSED||e===bs.SENT){var v=t?.[$o.SURVEY_ID],p=t?.[$o.SURVEY_ITERATION];h={id:v,current_iteration:p},localStorage.getItem(Ad(h))||localStorage.setItem(Ad(h),"true"),u.$set=k({},u.$set,{[Hb({id:v,current_iteration:p},e===bs.SENT?"responded":"dismissed")]:!0})}else e===bs.SHOWN&&(u.$set=k({},u.$set,{[$o.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Nb.SHOWN){var m=t?.[md.TOUR_TYPE];m&&(u.$set=k({},u.$set,{[md.TOUR_LAST_SEEN_DATE+"/"+m]:new Date().toISOString()}))}var E=k({},u.properties.$set,u.$set);if(Ri(E)||this.setPersonPropertiesForFlags(E),!U(this.config.before_send)){var b=this.ee(u);if(!b)return;u=b}this.yt.emit("eventCaptured",u);var O={method:"POST",url:(r=s?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:s?._batchKey};return!this.config.request_batching||s&&(s==null||!s._batchKey)||s!=null&&s.send_instantly?this.Bi(O):this.Hi.enqueue(O),u}A.critical("This capture call is ignored due to client rate limiting.")}}else A.error("No event name provided to posthog.capture")}else A.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=k({},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=k({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!he(a.distinct_id)&&!at(a.distinct_id)||Xo(a.distinct_id))&&A.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=Eb(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime());a.$session_id=h,a.$window_id=g}this.sessionPropsManager&&ue(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&ue(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this.qi)==null?void 0:f.length}catch(E){a.$sdk_debug_error_capturing_properties=String(E)}if(this.requestRouter.region===ks.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||n?e!=="$pageleave"||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=ue(a,c),e==="$pageview"&&S&&(a.title=S.title),!w(o)){var v=s.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}xe&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=ue({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),q(this.config.property_denylist)?Z(this.config.property_denylist,(function(E){delete a[E]})):A.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(A.error("sanitize_properties is deprecated. Use before_send instead"),a=p(a,e));var m=this.re();return a.$process_person_profile=m,m&&!n&&this.se("_calculate_event_properties"),a}ie(e,t){var s;if(t===void 0&&(t=!0),!this.persistence||!this.re()||this.Fi)return e;var r=this.persistence.get_initial_props(),n=(s=this.sessionPropsManager)==null?void 0:s.getSetOnceProps(),o=ue({},r,n||{},e||{}),a=this.config.sanitize_properties;return a&&(A.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Fi=!0),Ri(o)?void 0:o}register(e,t){var s;(s=this.persistence)==null||s.register(e,t)}register_once(e,t,s){var r;(r=this.persistence)==null||r.register_once(e,t,s)}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)}ne(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,s){var r=s!=null&&s.merge?this.featureFlags.getFlagVariants():{},n=s!=null&&s.merge?this.featureFlags.getFlagPayloads():{},o=k({},r,e),a=k({},n,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:w(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,s){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,s)}getEarlyAccessFeatures(e,t,s){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,s)}on(e,t){return this.yt.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:"Surveys module not available"}),()=>{})}onSessionId(e){var t,s;return(t=(s=this.sessionManager)==null?void 0:s.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:"Surveys module not available"})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:"Surveys module not available"})}renderSurvey(e,t){var s;(s=this.surveys)==null||s.renderSurvey(e,t)}displaySurvey(e,t){var s;t===void 0&&(t=zb),(s=this.surveys)==null||s.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,s;return(t=(s=this.surveys)==null?void 0:s.canRenderSurvey(e))!==null&&t!==void 0?t:{visible:!1,disabledReason:"Surveys module not available"}}canRenderSurveyAsync(e,t){var s,r;return t===void 0&&(t=!1),(s=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,t))!==null&&s!==void 0?s:Promise.resolve({visible:!1,disabledReason:"Surveys module not available"})}identify(e,t,s){if(!this.__loaded||!this.persistence)return A.uninitializedWarning("posthog.identify");if(at(e)&&(e=e.toString(),A.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()))A.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!==os){if(this.se("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(vs)&&(this.unregister(vs),this.register({distinct_id:e}));var o=(this.persistence.get_property(rt)||"anonymous")==="anonymous";e!==r&&o?(this.persistence.set_property(rt,"identified"),this.setPersonPropertiesForFlags(k({},s||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:s||{}}),this.Li=Sd(e,t,s),this.featureFlags.setAnonymousDistinctId(r)):(t||s)&&this.setPersonProperties(t,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(Gr))}}else A.critical('The string "'+os+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else A.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.se("posthog.setPersonProperties")){var s=Sd(this.get_distinct_id(),e,t);this.Li!==s?(this.setPersonPropertiesForFlags(k({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Li=s):A.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,s){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:k({},r,{[e]:t})}),s&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s}),this.setGroupPropertiesForFlags({[e]:s})),r[e]===t||s||this.reloadFeatureFlags()}else A.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.se("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,s,r,n,o,a;if(A.info("reset"),!this.__loaded)return A.uninitializedWarning("posthog.reset");var l=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(s=this.sessionPersistence)==null||s.clear(),(r=this.surveys)==null||r.reset(),(n=this.Qi)==null||n.stop(),this.featureFlags.reset(),(o=this.persistence)==null||o.set_property(rt,"anonymous"),(a=this.sessionManager)==null||a.resetSessionId(),this.Li=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:os,$device_id:null},"");else{var c=this.config.get_device_id(xt());this.register_once({distinct_id:c,$device_id:e?c:l},"")}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:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&s){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!s)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-s)/1e3)-o,0)}return r}alias(e,t){return e===this.get_property(gh)?(A.critical("Attempting to create alias for existing People user - aborting."),-2):this.se("posthog.alias")?(w(t)&&(t=this.get_distinct_id()),e!==t?(this.ne(vs,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(A.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=k({},this.config);if(fe(e)){var s,r,n,o,a,l,c,u,h;ue(this.config,Id(e));var g=this.zi();(s=this.persistence)==null||s.update_config(this.config,t,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Ss(k({},this.config,{persistence:"sessionStorage"}),g);var f=this.ji(this.config.debug);kt(f)&&(this.config.debug=f),kt(this.config.debug)&&(this.config.debug?(vt.DEBUG=!0,ae.F()&&ae.L("ph_debug","true"),A.info("set_config",{config:e,oldConfig:t,newConfig:k({},this.config)})):(vt.DEBUG=!1,ae.F()&&ae.j("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(u=this.surveys)==null||u.loadIfEnabled(),this.oe(),(h=this.externalIntegrations)==null||h.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,s={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(s).some(Boolean)){var r,n,o,a,l;(r=this.sessionManager)==null||r.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),s.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),s.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){if(this.exceptions){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(k({},r,t))}}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,s;return(t=(s=this.toolbar)==null?void 0:s.loadToolbar(e))!==null&&t!==void 0&&t}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Ii;return t!==Ii&&(t=Ii+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(rt))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(rt))==="identified"}re(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Ri(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[vs])&&((t=this.persistence)==null||(t=t.props)==null||!t[qr]))}Zi(){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.re()||this.se("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.se("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}se(e){return this.config.person_profiles==="never"?(A.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.ne(qr,!0),!0)}zi(){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}oe(){var e,t,s,r,n=this.zi();return((e=this.persistence)==null?void 0:e.Rt)!==n&&((s=this.persistence)==null||s.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.Rt)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){if(this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()){var s,r,n,o,a;this.reset(!0),(s=this.sessionManager)==null||s.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new sn(this),this.pageViewManager=new Kr(this),this.persistence&&(this.sessionPropsManager=new tn(this,this.sessionManager,this.persistence));var l=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=i.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=this.Ci(this.sessionRecording,new l(this)))}var c,u;this.consent.optInOut(!0),this.oe(),this.Ki(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((c=this.surveys)==null||c.loadIfEnabled()),(w(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((u=e?.captureEventName)!==null&&u!==void 0?u:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Xi()}else A.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,s;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.oe(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:os,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(s=this.sessionRecording)==null||s.stopRecording(),this.sessionRecording=void 0,this.Xi())):A.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.oe()}_is_bot(){return Ve?Nh(Ve,this.config.custom_blocked_useragents):void 0}Xi(){S&&(S.visibilityState==="visible"?this.Mi||(this.Mi=!0,this.capture("$pageview",{title:S.title},{send_instantly:!0}),this.Ai&&(S.removeEventListener("visibilitychange",this.Ai),this.Ai=null)):this.Ai||(this.Ai=this.Xi.bind(this),de(S,"visibilitychange",this.Ai)))}debug(e){e===!1?(_?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(_?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}xt(){var e,t,s,r,n,o,a,l=this.Ni||{};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?(A.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(s="advanced_disable_decide",r=!1,n=A,o=(t="advanced_disable_flags")in(e=l)&&!U(e[t]),a=s in e&&!U(e[s]),o?e[t]:a?(n&&n.warn("Config field '"+s+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[s]):r)}ee(e){if(U(this.config.before_send))return e;var t=q(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var r of t){if(s=r(s),U(s)){var n="Event '"+e.event+"' was rejected in beforeSend function";return Ny(e.event)?A.warn(n+". This can cause unexpected behavior."):A.info(n),null}s.properties&&!Ri(s.properties)||A.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return s}getPageViewId(){var e;return(e=this.pageViewManager.K)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,s){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(s)})}ji(e){var t=kt(e)&&!e,s=ae.F()&&ae.A("ph_debug")==="true";return!t&&(!!s||e)}};Mi.__defaultExtensionClasses={},(function(i,e){for(var t=0;t<e.length;t++)i.prototype[e[t]]=rb(i.prototype[e[t]])})(Mi,["identify"]);el=["a","button","form","input","select","textarea","label"];Xb=["next","previous","prev",">","<"],Pd=10,Nd=[".ph-no-rageclick",".ph-no-capture"];tl=i=>!i||$t(i,"html")||!cn(i),Gh=(i,e)=>{if(!_||tl(i))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,s=[i],r=i;r.parentNode&&!$t(r,"body");)if(Mh(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=Vh(r);if(!n)break;if(e||el.indexOf(n.tagName.toLowerCase())>-1)t=!0;else{var o=_.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}s.push(n),r=n}return{parentIsUsefulElement:t,targetElementList:s}};Hh="(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})",Jb=new RegExp("^(?:"+Hh+")$"),Zb=new RegExp(Hh),qh="\\d{3}-?\\d{2}-?\\d{4}",eE=new RegExp("^("+qh+")$"),tE=new RegExp("("+qh+")");on=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,s){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&s-r.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:s}];return!1}},Go="$copy_autocapture",xd=le("[AutoCapture]");gs=le("[ExceptionAutocapture]");aE=le("[TracingHeaders]"),Pt=le("[Web Vitals]"),$d=9e5;le("[SessionRecording]");Va="[SessionRecording]",Xt=le(Va),lE=le("[Heatmaps]");Md=le("[Product Tours]"),Ho="ph_product_tours",cE=["$set_once","$set"],Nt=le("[SiteApps]");Ga=class{constructor(e){this.ae=new Ps,this.le=(t,s)=>this.ue(t,s)&&this.he(t,s)&&this.de(t,s)&&this.ve(t,s),this.ue=(t,s)=>s==null||!s.event||t?.event===s?.event,this._instance=e,this.ce=new Set,this.fe=new Set}init(){var e;if(!w((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((s,r)=>{this.on(s,r)}))}}register(e){var t,s;if(!w((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.fe)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.ce)==null||u.add(c?.event||"")}))})),(s=this._instance)!=null&&s.autocapture)){var r,n=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&n.add(l?.selector)}))})),(r=this._instance)==null||r.autocapture.setElementSelectors(n)}}on(e,t){var s;t!=null&&e.length!=0&&(this.ce.has(e)||this.ce.has(t?.event))&&this.fe&&((s=this.fe)==null?void 0:s.size)>0&&this.fe.forEach((r=>{this.pe(t,r)&&this.ae.emit("actionCaptured",r.name)}))}_e(e){this.onAction("actionCaptured",(t=>e(t)))}pe(e,t){if(t?.steps==null)return!1;for(var s of t.steps)if(this.le(e,s))return!0;return!1}onAction(e,t){return this.ae.on(e,t)}he(e,t){if(t!=null&&t.url){var s,r=e==null||(s=e.properties)==null?void 0:s.$current_url;if(!r||typeof r!="string"||!Ai(r,t.url,t.url_matching||"contains"))return!1}return!0}de(e,t){return!!this.ge(e,t)&&!!this.me(e,t)&&!!this.be(e,t)}ge(e,t){var s;if(t==null||!t.href)return!0;var r=this.ye(e);if(r.length>0)return r.some((a=>Ai(a.href,t.href,t.href_matching||"exact")));var n,o=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!o&&Ai((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}me(e,t){var s;if(t==null||!t.text)return!0;var r=this.ye(e);if(r.length>0)return r.some((c=>Ai(c.text,t.text,t.text_matching||"exact")||Ai(c.$el_text,t.text,t.text_matching||"exact")));var n,o,a,l=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!l&&(n=(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",n.some((c=>Ai(c,o,a))))}be(e,t){var s,r;if(t==null||!t.selector)return!0;var n=e==null||(s=e.properties)==null?void 0:s.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}ye(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}ve(e,t){return t==null||!t.properties||t.properties.length===0||xh(t.properties.reduce(((s,r)=>{var n=q(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return s[r.key]={values:n,operator:r.operator||"exact"},s}),{}),e?.properties)}},ja=class{constructor(e){this._instance=e,this.we=new Map,this.Ee=new Map,this.xe=new Map}Se(e,t){return!!e&&xh(e.propertyFilters,t?.properties)}$e(e,t){var s=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=s.get(o.name)||[];a.push(r.id),s.set(o.name,a)}}))})),s}ke(e,t,s){var r=(s===us.Activation?this.we:this.Ee).get(e),n=[];return this.Pe((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[s])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.Se(l,t)}))}register(e){var t;w((t=this._instance)==null?void 0:t._addCaptureHook)||(this.Te(e),this.Re(e))}Re(e){var t=e.filter((s=>{var r,n;return((r=s.conditions)==null?void 0:r.actions)&&((n=s.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.Ie==null&&(this.Ie=new Ga(this._instance),this.Ie.init(),this.Ie._e((s=>{this.onAction(s)}))),t.forEach((s=>{var r,n,o,a,l;s.conditions&&(r=s.conditions)!=null&&r.actions&&(n=s.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=s.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.Ie)==null||a.register(s.conditions.actions.values),(l=s.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.xe.get(c.name);u&&u.push(s.id),this.xe.set(c.name,u||[s.id])}})))})))}Te(e){var t,s=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.events)&&((a=n.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),r=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.cancelEvents)&&((a=n.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(s.length!==0||r.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.we=this.$e(e,us.Activation),this.Ee=this.$e(e,us.Cancellation))}onEvent(e,t){var s,r=this.Ce(),n=this.Oe(),o=this.Fe(),a=((s=this._instance)==null||(s=s.persistence)==null?void 0:s.props[n])||[];if(o===e&&t&&a.length>0){var l,c;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var 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.Me(a))}}else{if(this.Ee.has(e)){var g=this.ke(e,t,us.Cancellation);g.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:g.map((v=>v.id))}),g.forEach((v=>{var p=a.indexOf(v.id);p>=0&&a.splice(p,1),this.Ae(v.id)})),this.Me(a))}if(this.we.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.we.get(e)});var f=this.ke(e,t,us.Activation);this.Me(a.concat(f.map((v=>v.id))||[]))}}}onAction(e){var t,s=this.Oe(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[s])||[];this.xe.has(e)&&this.Me(r.concat(this.xe.get(e)||[]))}Me(e){var t,s=this.Ce(),r=this.Oe(),n=[...new Set(e)].filter((o=>!this.De(o)));s.info("updating activated items",{activatedItems:n}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:n})}getActivatedIds(){var e,t=this.Oe(),s=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return s||[]}getEventToItemsMap(){return this.we}Le(){return this.Ie}},Ha=class extends ja{constructor(e){super(e)}Oe(){return"$surveys_activated"}Fe(){return bs.SHOWN}Pe(e){var t;(t=this._instance)==null||t.getSurveys(e)}Ae(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}Ce(){return Q}De(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},uE=_!=null&&_.location?Yr(_.location.hash,"__posthog")||Yr(location.hash,"state"):null,Ud="_postHogToolbarParams",Bd=le("[Toolbar]"),Dt=(function(i){return i[i.UNINITIALIZED=0]="UNINITIALIZED",i[i.LOADING=1]="LOADING",i[i.LOADED=2]="LOADED",i})(Dt||{}),qo=le("[Error tracking]"),dE={icontains:(i,e)=>!!_&&e.href.toLowerCase().indexOf(i.toLowerCase())>-1,not_icontains:(i,e)=>!!_&&e.href.toLowerCase().indexOf(i.toLowerCase())===-1,regex:(i,e)=>!!_&&rn(e.href,i),not_regex:(i,e)=>!!_&&!rn(e.href,i),exact:(i,e)=>e.href===i,is_not:(i,e)=>e.href!==i},qa=class i{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(s){s===void 0&&(s=!1),t.getWebExperiments((r=>{i.je("retrieved web experiments from the server"),t.Ne=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;t.Ne&&(i.je("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=t.Ne)==null||o.set(n.feature_flag_key,n));var a=t._instance.getFeatureFlag(n.feature_flag_key);he(a)&&n.variants[a]&&t.Ue(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var c=n.variants[l];i.ze(c)&&t.Ue(n.name,l,c.transforms)}}))}),s)},this._instance=e,this._instance.onFeatureFlags((s=>{this.onFeatureFlags(s)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())i.je("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(U(this.Ne))return this.Ne=new Map,this.loadIfEnabled(),void this.previewWebExperiment();i.je("applying feature flags",e),e.forEach((t=>{var s;if(this.Ne&&(s=this.Ne)!=null&&s.has(t)){var r,n=this._instance.getFeatureFlag(t),o=(r=this.Ne)==null?void 0:r.get(t);n&&o!=null&&o.variants[n]&&this.Ue(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=i.getWindowLocation();if(e!=null&&e.search){var t=Xr(e?.search,"__experiment_id"),s=Xr(e?.search,"__experiment_variant");t&&s&&(i.je("previewing web experiments "+t+" && "+s),this.getWebExperiments((r=>{this.He(parseInt(t),s,r)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,s){if(this._instance.config.disable_web_experiments&&!s)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:n=>{if(n.statusCode!==200||!n.json)return e([]);var o=n.json.experiments||[];return e(o)}})}He(e,t,s){var r=s.filter((n=>n.id===e));r&&r.length>0&&(i.je("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Ue(r[0].name,t,r[0].variants[t].transforms))}static ze(e){return!U(e.conditions)&&i.Be(e)&&i.qe(e)}static Be(e){var t;if(U(e.conditions)||U((t=e.conditions)==null?void 0:t.url))return!0;var s,r,n,o=i.getWindowLocation();return!!o&&((s=e.conditions)==null||!s.url||dE[(r=(n=e.conditions)==null?void 0:n.urlMatchType)!==null&&r!==void 0?r:"icontains"](e.conditions.url,o))}static getWindowLocation(){return _?.location}static qe(e){var t;if(U(e.conditions)||U((t=e.conditions)==null?void 0:t.utm))return!0;var s=Eh();if(s.utm_source){var r,n,o,a,l,c,u,h,g=(r=e.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==s.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)==s.utm_source,v=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==s.utm_medium,p=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==s.utm_term;return g&&v&&p&&f}return!1}static je(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),r=1;r<t;r++)s[r-1]=arguments[r];A.info("[WebExperiments] "+e,s)}Ue(e,t,s){this._is_bot()?i.je("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?s.forEach((r=>{if(r.selector){var n;i.je("applying transform of variant "+t+" for experiment "+e+" ",r);var o=(n=document)==null?void 0:n.querySelectorAll(r.selector);o?.forEach((a=>{var l=a;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)}))}})):i.je("Control variants leave the page unmodified.")}_is_bot(){return Ve&&this._instance?Nh(Ve,this._instance.config.custom_blocked_useragents):void 0}},Ke=le("[Conversations]"),hE={sessionRecording:class{get started(){var i;return!((i=this.Ve)==null||!i.isStarted)}get status(){return this.Ve?this.Ve.status:this.We?this.Ge?"lazy_loading":"disabled":"pending_config"}constructor(i){if(this._forceAllowLocalhostNetworkCapture=!1,this.We=!1,this.Ye=!1,this.Je=void 0,this._instance=i,!this._instance.sessionManager)throw Xt.error("started without valid sessionManager"),new Error(Va+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Va+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Ge(){var i,e=!((i=this._instance.get_property(Pr))==null||!i.enabled),t=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&t&&!s}startIfEnabledOrStop(i){var e;if(this.We&&(!this.Ge||(e=this.Ve)==null||!e.isStarted)){var t=!w(Object.assign)&&!w(Array.from);this.Ge&&t?(this.Ke(i),Xt.info("starting")):this.stopRecording()}}Ke(i){var e,t,s;this.Ge&&(C!=null&&(e=C.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=C.__PosthogExtensions__)!=null&&t.initSessionRecording?this.Xe(i):(s=C.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.Qe,(r=>{if(r)return Xt.error("could not load recorder",r);this.Xe(i)})))}stopRecording(){var i,e;(i=this.Je)==null||i.call(this),this.Je=void 0,(e=this.Ve)==null||e.stop()}Ze(){var i;(i=this._instance.persistence)==null||i.unregister(vh)}tr(i,e){if(U(i))return null;var t,s=at(i)?i:parseFloat(i);return typeof(t=s)=="number"&&Number.isFinite(t)&&t>=0&&t<=1?s:(Xt.warn(e+" must be between 0 and 1. Ignoring invalid value:",i),null)}ir(i){if(this._instance.persistence){var e,t,s=this._instance.persistence,r=()=>{var n,o=i.sessionRecording===!1?void 0:i.sessionRecording,a=this.tr((n=this._instance.config.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.tr(o?.sampleRate,"remote config sampleRate"),c=a??l;U(c)&&this.Ze();var u=o?.minimumDurationMilliseconds;s.register({[Pr]:k({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:k({capturePerformance:i.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:w(u)?null:u,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};r(),(e=this.Je)==null||e.call(this),this.Je=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(r)}}onRemoteConfig(i){"sessionRecording"in i?i.sessionRecording!==!1?(this.Ye=!1,this.ir(i),this.We=!0,this.startIfEnabledOrStop()):this.We=!0:Xt.info("skipping remote config with no sessionRecording",i)}log(i,e){var t;e===void 0&&(e="log"),(t=this.Ve)!=null&&t.log?this.Ve.log(i,e):Xt.warn("log called before recorder was ready")}get Qe(){var i,e,t=(i=this._instance)==null||(i=i.persistence)==null?void 0:i.get_property(Pr);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}er(){var i,e=this._instance.get_property(Pr);if(!e)return!1;var t=(i=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&i!==void 0?i:Date.now();return Date.now()-t<=3e5}Xe(i){var e,t;if((e=C.__PosthogExtensions__)==null||!e.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Ve||(this.Ve=(t=C.__PosthogExtensions__)==null?void 0:t.initSessionRecording(this._instance),this.Ve._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.er()?this.Ve.start(i):this.Ye||(this.Ye=!0,Xt.info("persisted remote config is stale, requesting fresh config before starting"),new Qr(this._instance).load())}onRRwebEmit(i){var e;(e=this.Ve)==null||e.onRRwebEmit==null||e.onRRwebEmit(i)}overrideLinkedFlag(){var i,e;this.Ve||(e=this._instance.persistence)==null||e.register({$replay_override_linked_flag:!0}),(i=this.Ve)==null||i.overrideLinkedFlag()}overrideSampling(){var i,e;this.Ve||(e=this._instance.persistence)==null||e.register({$replay_override_sampling:!0}),(i=this.Ve)==null||i.overrideSampling()}overrideTrigger(i){var e,t;this.Ve||(t=this._instance.persistence)==null||t.register({[i==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.Ve)==null||e.overrideTrigger(i)}get sdkDebugProperties(){var i;return((i=this.Ve)==null?void 0:i.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(i,e){var t;return!((t=this.Ve)==null||!t.tryAddCustomEvent(i,e))}}},fE={autocapture:class{constructor(i){this.rr=!1,this.sr=null,this.nr=!1,this.instance=i,this.rageclicks=new on(i.config.rageclick),this.ar=null}initialize(){this.startIfEnabled()}get N(){var i,e,t=fe(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(i=t.url_allowlist)==null?void 0:i.map((s=>new RegExp(s))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((s=>new RegExp(s))),t}lr(){if(this.isBrowserSupported()){if(_&&S){var i=t=>{t=t||_?.event;try{this.ur(t)}catch(s){xd.error("Failed to capture event",s)}};if(de(S,"submit",i,{capture:!0}),de(S,"change",i,{capture:!0}),de(S,"click",i,{capture:!0}),this.N.capture_copied_text){var e=t=>{t=t||_?.event,this.ur(t,Go)};de(S,"copy",e,{capture:!0}),de(S,"cut",e,{capture:!0})}}}else xd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.rr&&(this.lr(),this.rr=!0)}onRemoteConfig(i){i.elementsChainAsString&&(this.nr=i.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[od]:!!i.autocapture_opt_out}),this.sr=!!i.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(i){this.ar=i}getElementSelectors(i){var e,t=[];return(e=this.ar)==null||e.forEach((s=>{var r=S?.querySelectorAll(s);r?.forEach((n=>{i===n&&t.push(s)}))})),t}get isEnabled(){var i,e,t=(i=this.instance.persistence)==null?void 0:i.props[od],s=this.sr;if(Je(s)&&!kt(t)&&!this.instance.xt())return!1;var r=(e=this.sr)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!r}ur(i,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,s=Cd(i);Fh(s)&&(s=s.parentNode||null),e==="$autocapture"&&i.type==="click"&&i instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(i.clientX,i.clientY,i.timeStamp||new Date().getTime())&&Yb(s,this.instance.config.rageclick)&&this.ur(i,"$rageclick");var r=e===Go;if(s&&Qb(s,i,this.N,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=oE(s,{e:i,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.N.element_attribute_ignorelist,elementsChainAsString:this.nr});if(o)return!1;var a=this.getElementSelectors(s);if(a&&a.length>0&&(n.$element_selectors=a),e===Go){var l,c=Uh(_==null||(l=_.getSelection())==null?void 0:l.toString()),u=i.type||"clipboard";if(!c)return!1;n.$selected_content=c,n.$copy_type=u}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return bt(S?.querySelectorAll)}},historyAutocapture:class{constructor(i){var e;this._instance=i,this.hr=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(A.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.dr&&this.dr(),this.dr=void 0,A.info("History API monitoring stopped")}monitorHistoryChanges(){var i,e;if(_&&_.history){var t=this;(i=_.history.pushState)!=null&&i.__posthog_wrapped__||Ld(_.history,"pushState",(s=>function(r,n,o){s.call(this,r,n,o),t.vr("pushState")})),(e=_.history.replaceState)!=null&&e.__posthog_wrapped__||Ld(_.history,"replaceState",(s=>function(r,n,o){s.call(this,r,n,o),t.vr("replaceState")})),this.cr()}}vr(i){try{var e,t=_==null||(e=_.location)==null?void 0:e.pathname;if(!t)return;t!==this.hr&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:i}),this.hr=t}catch(s){A.error("Error capturing "+i+" pageview",s)}}cr(){if(!this.dr){var i=()=>{this.vr("popstate")};de(_,"popstate",i),this.dr=()=>{_&&_.removeEventListener("popstate",i)}}}},heatmaps:class{constructor(i){var e;this.pr=!1,this.rr=!1,this._r=null,this.instance=i,this.pr=!((e=this.instance.persistence)==null||!e.props[da]),this.rageclicks=new on(i.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var i=5e3;return fe(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(i=this.instance.config.capture_heatmaps.flush_interval_milliseconds),i}get isEnabled(){return U(this.instance.config.capture_heatmaps)?U(this.instance.config.enable_heatmaps)?this.pr:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.rr)return;lE.info("starting..."),this.gr(),this.mr()}else{var i;clearInterval((i=this._r)!==null&&i!==void 0?i:void 0),this.br(),this.getAndClearBuffer()}}onRemoteConfig(i){if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[da]:e}),this.pr=e,this.startIfEnabled()}}getAndClearBuffer(){var i=this.C;return this.C=void 0,i}yr(i){this.wr(i.originalEvent,"deadclick")}mr(){this._r&&clearInterval(this._r),this._r=(function(i){return i?.visibilityState==="visible"})(S)?setInterval(this.Xt.bind(this),this.flushIntervalMilliseconds):null}gr(){_&&S&&(this.Er=this.Xt.bind(this),de(_,"beforeunload",this.Er),this.Sr=i=>this.wr(i||_?.event),de(S,"click",this.Sr,{capture:!0}),this.$r=i=>this.kr(i||_?.event),de(S,"mousemove",this.$r,{capture:!0}),this.Pr=new zr(this.instance,gb,this.yr.bind(this)),this.Pr.startIfEnabledOrStop(),this.Tr=this.mr.bind(this),de(S,"visibilitychange",this.Tr),this.rr=!0)}br(){var i;_&&S&&(this.Er&&_.removeEventListener("beforeunload",this.Er),this.Sr&&S.removeEventListener("click",this.Sr,{capture:!0}),this.$r&&S.removeEventListener("mousemove",this.$r,{capture:!0}),this.Tr&&S.removeEventListener("visibilitychange",this.Tr),clearTimeout(this.Rr),(i=this.Pr)==null||i.stop(),this.rr=!1)}Ir(i,e){var t=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var c=o;c&&cn(c)&&!$t(c,"body");){if(c===l)return!1;if(M(a,_?.getComputedStyle(c).position))return!0;c=Vh(c)}return!1})(Cd(i),["fixed","sticky"],r);return{x:i.clientX+(n?0:s),y:i.clientY+(n?0:t),target_fixed:n,type:e}}wr(i,e){var t;if(e===void 0&&(e="click"),!Rd(i.target)&&Fd(i)){var s=this.Ir(i,e);(t=this.rageclicks)!=null&&t.isRageClick(i.clientX,i.clientY,new Date().getTime())&&this.Cr(k({},s,{type:"rageclick"})),this.Cr(s)}}kr(i){!Rd(i.target)&&Fd(i)&&(clearTimeout(this.Rr),this.Rr=setTimeout((()=>{this.Cr(this.Ir(i,"mousemove"))}),500))}Cr(i){if(_){var e=_.location.href,t=this.instance.config.mask_personal_data_properties,s=this.instance.config.custom_personal_data_properties,r=t?Li([],$i,s||[]):[],n=Os(e,r,Cs);this.C=this.C||{},this.C[n]||(this.C[n]=[]),this.C[n].push(i)}}Xt(){this.C&&!Ri(this.C)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:zr,webVitalsAutocapture:class{constructor(i){var e;this.pr=!1,this.rr=!1,this.C={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Or=()=>{clearTimeout(this.Fr),this.C.metrics.length!==0&&(this._instance.capture("$web_vitals",this.C.metrics.reduce(((t,s)=>k({},t,{["$web_vitals_"+s.name+"_event"]:k({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{})),this.C={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Mr=t=>{var s,r=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(w(r))Pt.error("Could not read session ID. Dropping metrics!");else{this.C=this.C||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Ar();w(n)||(U(t?.name)||U(t?.value)?Pt.error("Invalid metric received",t):this.Dr&&t.value>=this.Dr?Pt.error("Ignoring metric with value >= "+this.Dr,t):(this.C.url!==n&&(this.Or(),this.Fr=setTimeout(this.Or,this.flushToCaptureTimeoutMs)),w(this.C.url)&&(this.C.url=n),this.C.firstMetricTimestamp=w(this.C.firstMetricTimestamp)?Date.now():this.C.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0),this.C.metrics.push(k({},t,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.C.metrics.length===this.allowedMetrics.length&&this.Or()))}},this.Lr=()=>{if(!this.rr){var t,s,r,n,o=C.__PosthogExtensions__;w(o)||w(o.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:s,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),t&&s&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.Mr.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.Mr.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Mr.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.Mr.bind(this)),this.rr=!0):Pt.error("web vitals callbacks not loaded - not starting")}},this._instance=i,this.pr=!((e=this._instance.persistence)==null||!e.props[cd]),this.startIfEnabled()}get allowedMetrics(){var i,e,t=fe(this._instance.config.capture_performance)?(i=this._instance.config.capture_performance)==null?void 0:i.web_vitals_allowed_metrics:void 0;return U(t)?((e=this._instance.persistence)==null?void 0:e.props[dd])||["CLS","FCP","INP","LCP"]:t}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 i=fe(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return i!=null&&i}get Dr(){var i=fe(this._instance.config.capture_performance)&&at(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:$d;return 0<i&&i<=6e4?$d:i}get isEnabled(){var i=be?.protocol;if(i!=="http:"&&i!=="https:")return Pt.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=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(e)?e:this.pr}startIfEnabled(){this.isEnabled&&!this.rr&&(Pt.info("enabled, starting..."),this.G(this.Lr))}onRemoteConfig(i){if("capturePerformance"in i){var e=fe(i.capturePerformance)&&!!i.capturePerformance.web_vitals,t=fe(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[cd]:e}),this._instance.persistence.register({[dd]:t})),this.pr=e,this.startIfEnabled()}}G(i){var e,t;if((e=C.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks)i();else{var s=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(t=C.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,s,(r=>{r?Pt.error("failed to load script",r):i()}))}}Ar(){var i=_?_.location.href:void 0;if(i){var e=this._instance.config.mask_personal_data_properties,t=this._instance.config.custom_personal_data_properties,s=e?Li([],$i,t||[]):[];return Os(i,s,Cs)}Pt.error("Could not determine current URL")}}},gE={exceptionObserver:class{constructor(i){var e,t,s;this.Lr=()=>{var r;if(_&&this.isEnabled&&(r=C.__PosthogExtensions__)!=null&&r.errorWrappingFunctions){var n=C.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=C.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=C.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.jr&&this.N.capture_unhandled_errors&&(this.jr=n(this.captureException.bind(this))),!this.Nr&&this.N.capture_unhandled_rejections&&(this.Nr=o(this.captureException.bind(this))),!this.Ur&&this.N.capture_console_errors&&(this.Ur=a(this.captureException.bind(this)))}catch(l){gs.error("failed to start",l),this.zr()}}},this._instance=i,this.Hr=!((e=this._instance.persistence)==null||!e.props[ad]),this.Br=new Qo({refillRate:(t=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&t!==void 0?t:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,h:gs}),this.N=this.qr(),this.startIfEnabledOrStop()}qr(){var i=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return fe(i)?e=k({},e,i):(w(i)?this.Hr:i)&&(e=k({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.N.capture_console_errors||this.N.capture_unhandled_errors||this.N.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(gs.info("enabled"),this.zr(),this.G(this.Lr)):this.zr()}G(i){var e,t;(e=C.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&i(),(t=C.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return gs.error("failed to load script",s);i()}))}zr(){var i,e,t;(i=this.jr)==null||i.call(this),this.jr=void 0,(e=this.Nr)==null||e.call(this),this.Nr=void 0,(t=this.Ur)==null||t.call(this),this.Ur=void 0}onRemoteConfig(i){if("autocaptureExceptions"in i){var e=i.autocaptureExceptions;this.Hr=!!e||!1,this._instance.persistence&&this._instance.persistence.register({[ad]:this.Hr}),this.N=this.qr(),this.startIfEnabledOrStop()}}onConfigChange(){this.N=this.qr()}captureException(i){var e,t,s,r=(e=i==null||(t=i.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.Br.consumeRateLimit(r)?gs.info("Skipping exception capture because of client rate limiting.",{exception:r}):(s=this._instance.exceptions)==null||s.sendExceptionEvent(i)}},exceptions:class{constructor(i){var e,t;this.Vr=[],this.Wr=new ta([new sa,new ua,new na,new ra,new la,new aa,new oa,new ca],eb()),this._instance=i,this.Vr=(e=(t=this._instance.persistence)==null?void 0:t.get_property(ha))!==null&&e!==void 0?e:[]}onRemoteConfig(i){var e,t,s;if("errorTracking"in i){var r=(e=(t=i.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],n=(s=i.errorTracking)==null?void 0:s.captureExtensionExceptions;this.Vr=r,this._instance.persistence&&this._instance.persistence.register({[ha]:this.Vr,[ld]:n})}}get Gr(){var i,e=!!this._instance.get_property(ld),t=this._instance.config.error_tracking.captureExtensionExceptions;return(i=t??e)!==null&&i!==void 0&&i}buildProperties(i,e){return this.Wr.buildFromUnknown(i,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}sendExceptionEvent(i){var e=i.$exception_list;if(this.Yr(e)){if(this.Jr(e))return void qo.info("Skipping exception capture because a suppression rule matched");if(!this.Gr&&this.Kr(e))return void qo.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Xr(e))return void qo.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",te:!0})}Jr(i){if(i.length===0)return!1;var e=i.reduce(((t,s)=>{var{type:r,value:n}=s;return he(r)&&r.length>0&&t.$exception_types.push(r),he(n)&&n.length>0&&t.$exception_values.push(n),t}),{$exception_types:[],$exception_values:[]});return this.Vr.some((t=>{var s=t.values.map((r=>{var n,o=Dh[r.operator],a=q(r.value)?r.value:[r.value],l=(n=e[r.key])!==null&&n!==void 0?n:[];return a.length>0&&o(a,l)}));return t.type==="OR"?s.some(Boolean):s.every(Boolean)}))}Kr(i){return i.flatMap((e=>{var t,s;return(t=(s=e.stacktrace)==null?void 0:s.frames)!==null&&t!==void 0?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}Xr(i){if(i.length>0){var e,t,s,r,n=(e=(t=i[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(s=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}Yr(i){return!U(i)&&q(i)}}},pE={productTours:class{constructor(i){this.Qr=null,this.Zr=null,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){"productTours"in i&&(this._instance.persistence&&this._instance.persistence.register({[ud]:!!i.productTours}),this.loadIfEnabled())}loadIfEnabled(){var i,e;this.Qr||(i=this._instance).config.disable_product_tours||(e=i.persistence)==null||!e.get_property(ud)||this.G((()=>this.ts()))}G(i){var e,t;(e=C.__PosthogExtensions__)!=null&&e.generateProductTours?i():(t=C.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(s=>{s?Md.error("Could not load product tours script",s):i()}))}ts(){var i;!this.Qr&&(i=C.__PosthogExtensions__)!=null&&i.generateProductTours&&(this.Qr=C.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(i,e){if(e===void 0&&(e=!1),!q(this.Zr)||e){var t=this._instance.persistence;if(t){var s=t.props[Ho];if(q(s)&&!e)return this.Zr=s,void i(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:r=>{var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return Md.error(o),void i([],{isLoaded:!1,error:o})}var a=q(r.json.product_tours)?r.json.product_tours:[];this.Zr=a,t&&t.register({[Ho]:a}),i(a,{isLoaded:!0})}})}else i(this.Zr,{isLoaded:!0})}getActiveProductTours(i){U(this.Qr)?i([],{isLoaded:!1,error:"Product tours not loaded"}):this.Qr.getActiveProductTours(i)}showProductTour(i){var e;(e=this.Qr)==null||e.showTourById(i)}previewTour(i){this.Qr?this.Qr.previewTour(i):this.G((()=>{var e;this.ts(),(e=this.Qr)==null||e.previewTour(i)}))}dismissProductTour(){var i;(i=this.Qr)==null||i.dismissTour("user_clicked_skip")}nextStep(){var i;(i=this.Qr)==null||i.nextStep()}previousStep(){var i;(i=this.Qr)==null||i.previousStep()}clearCache(){var i;this.Zr=null,(i=this._instance.persistence)==null||i.unregister(Ho)}resetTour(i){var e;(e=this.Qr)==null||e.resetTour(i)}resetAllTours(){var i;(i=this.Qr)==null||i.resetAllTours()}cancelPendingTour(i){var e;(e=this.Qr)==null||e.cancelPendingTour(i)}}},vE={siteApps:class{constructor(i){this._instance=i,this.es=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}rs(i,e){if(e){var t=this.globalsForEvent(e);this.es.push(t),this.es.length>1e3&&(this.es=this.es.slice(10))}}get siteAppLoaders(){var i;return(i=C._POSTHOG_REMOTE_CONFIG)==null||(i=i[this._instance.config.token])==null?void 0:i.siteApps}initialize(){if(this.isEnabled){var i=this._instance._addCaptureHook(this.rs.bind(this));this.ss=()=>{i(),this.es=[],this.ss=void 0}}}globalsForEvent(i){var e,t,s,r,n,o,a;if(!i)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var[h,g]of Object.entries(u))l[h]={id:c[h],type:h,properties:g};var{$set_once:f,$set:v}=i;return{event:k({},jd(i,cE),{properties:k({},i.properties,v?{$set:k({},(e=(t=i.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},v)}:{},f?{$set_once:k({},(s=(r=i.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},f)}:{}),elements_chain:(n=(o=i.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=i.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(i){var e=this.apps[i.id],t=()=>{var o;!e.errored&&this.es.length&&(Nt.info("Processing "+this.es.length+" events for site app with id "+i.id),this.es.forEach((a=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every((a=>a.processedBuffer||a.errored))&&((o=this.ss)==null||o.call(this))},s=!1,r=o=>{e.errored=!o,e.loaded=!0,Nt.info("Site app with id "+i.id+" "+(o?"loaded":"errored")),s&&t()};try{var{processEvent:n}=i.init({posthog:this._instance,callback:o=>{r(o)}});n&&(e.processEvent=n),s=!0}catch(o){Nt.error("Error while initializing PostHog app with config id "+i.id,o),r(!1)}if(s&&e.loaded)try{t()}catch(o){Nt.error("Error while processing buffered events PostHog app with config id "+i.id,o),e.errored=!0}}ns(){var i=this.siteAppLoaders||[];for(var e of i)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of i)this.setupSiteApp(t)}os(i){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(i);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(s){Nt.error("Error while processing event "+i.event+" for site app "+t.id,s)}}}onRemoteConfig(i){var e,t,s,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.ns(),void this._instance.on("eventCaptured",(l=>this.os(l)))):void Nt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.ss)==null||t.call(this),(s=i.siteApps)!=null&&s.length)if(this.isEnabled){var n=function(l){var c;C["__$$ph_site_app_"+l]=r._instance,(c=C.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(r._instance,a,(u=>{if(u)return Nt.error("Error while initializing PostHog app with config id "+l,u)}))};for(var{id:o,url:a}of i.siteApps)n(o)}else Nt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},_E={tracingHeaders:class{constructor(i){this.ls=void 0,this.us=void 0,this.Lr=()=>{var e,t;w(this.ls)&&((e=C.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),w(this.us)&&((t=C.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=i}initialize(){this.startIfEnabledOrStop()}G(i){var e,t;(e=C.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&i(),(t=C.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return aE.error("failed to load script",s);i()}))}startIfEnabledOrStop(){var i,e;this._instance.config.__add_tracing_headers?this.G(this.Lr):((i=this.ls)==null||i.call(this),(e=this.us)==null||e.call(this),this.ls=void 0,this.us=void 0)}}},mE={surveys:class{constructor(i){this.hs=void 0,this._surveyManager=null,this.ds=!1,this.vs=[],this.cs=null,this._instance=i,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this._instance.config.disable_surveys){var e=i.surveys;if(U(e))return Q.warn("Flags not loaded yet. Not loading surveys.");var t=q(e);this.hs=t?e.length>0:e,Q.info("flags response received, isSurveysEnabled: "+this.hs),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var t=localStorage.key(e);(t!=null&&t.startsWith(Lh)||t!=null&&t.startsWith("inProgressSurvey_"))&&i.push(t)}i.forEach((s=>localStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.ds)Q.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Q.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Q.info("Not loading surveys in cookieless mode without consent.");else{var i=C?.__PosthogExtensions__;if(i){if(!w(this.hs)||this._instance.config.advanced_enable_surveys){var e=this.hs||this._instance.config.advanced_enable_surveys;this.ds=!0;try{var t=i.generateSurveys;if(t)return void this.fs(t,e);var s=i.loadExternalDependency;if(!s)return void this.ps("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",(r=>{r||!i.generateSurveys?this.ps("Could not load surveys script",r):this.fs(i.generateSurveys,e)}))}catch(r){throw this.ps("Error initializing surveys",r),r}finally{this.ds=!1}}}else Q.error("PostHog Extensions not found.")}}fs(i,e){this._surveyManager=i(this._instance,e),this._surveyEventReceiver=new Ha(this._instance),Q.info("Surveys loaded successfully"),this._s({isLoaded:!0})}ps(i,e){Q.error(i,e),this._s({isLoaded:!1,error:i})}onSurveysLoaded(i){return this.vs.push(i),this._surveyManager&&this._s({isLoaded:!0}),()=>{this.vs=this.vs.filter((e=>e!==i))}}getSurveys(i,e){if(e===void 0&&(e=!1),this._instance.config.disable_surveys)return Q.info("Disabled. Not loading surveys."),i([]);var t,s=this._instance.get_property(ga);if(s&&!e)return i(s,{isLoaded:!0});typeof Promise<"u"&&this.cs?this.cs.then((r=>{var{surveys:n,context:o}=r;return i(n,o)})):(typeof Promise<"u"&&(this.cs=new Promise((r=>{t=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 n;this.cs=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;Q.error(a);var l={isLoaded:!1,error:a};return i([],l),void(t==null||t({surveys:[],context:l}))}var c,u=r.json.surveys||[],h=u.filter((f=>(function(v){return!(!v.start_date||v.end_date)})(f)&&((function(v){var p;return!((p=v.conditions)==null||(p=p.events)==null||(p=p.values)==null||!p.length)})(f)||(function(v){var p;return!((p=v.conditions)==null||(p=p.actions)==null||(p=p.values)==null||!p.length)})(f))));h.length>0&&((c=this._surveyEventReceiver)==null||c.register(h)),(n=this._instance.persistence)==null||n.register({[ga]:u});var g={isLoaded:!0};i(u,g),t?.({surveys:u,context:g})}}))}_s(i){for(var e of this.vs)try{if(!i.isLoaded)return e([],i);this.getSurveys(e)}catch(t){Q.error("Error in survey callback",t)}}getActiveMatchingSurveys(i,e){if(e===void 0&&(e=!1),!U(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(i,e);Q.warn("init was not called")}gs(i){var e=null;return this.getSurveys((t=>{var s;e=(s=t.find((r=>r.id===i)))!==null&&s!==void 0?s:null})),e}bs(i){if(U(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var e=typeof i=="string"?this.gs(i):i;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(i){if(U(this._surveyManager))return Q.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var e=this.bs(i);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(i,e){return U(this._surveyManager)?(Q.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((t=>{this.getSurveys((s=>{var r,n=(r=s.find((a=>a.id===i)))!==null&&r!==void 0?r:null;if(n){var o=this.bs(n);t({visible:o.eligible,disabledReason:o.reason})}else t({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(i,e,t){var s;if(U(this._surveyManager))Q.warn("init was not called");else{var r=typeof i=="string"?this.gs(i):i;if(r!=null&&r.id)if(qb.includes(r.type)){var n=S?.querySelector(e);if(n)return(s=r.appearance)!=null&&s.surveyPopupDelaySeconds?(Q.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;Q.info("Rendering survey "+r.id+" with delay of "+((o=r.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(r,n,t),Q.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,t);Q.warn("Survey element not found")}else Q.warn("Surveys of type "+r.type+" cannot be rendered in the app");else Q.warn("Survey not found")}}displaySurvey(i,e){var t;if(U(this._surveyManager))Q.warn("init was not called");else{var s=this.gs(i);if(s){var r=s;if((t=s.appearance)!=null&&t.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=k({},s,{appearance:k({},s.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Ta.Popover&&e.initialResponses&&Q.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(s);if(!n.visible)return void Q.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==Ta.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else Q.warn("Survey not found")}}cancelPendingSurvey(i){U(this._surveyManager)?Q.warn("init was not called"):this._surveyManager.cancelSurvey(i)}handlePageUnload(){var i;(i=this._surveyManager)==null||i.handlePageUnload()}}},yE={toolbar:class{constructor(i){this.instance=i}ys(i){C.ph_toolbar_state=i}ws(){var i;return(i=C.ph_toolbar_state)!==null&&i!==void 0?i:Dt.UNINITIALIZED}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i,e,t){if(i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),fh(this.instance.config)||!_||!S)return!1;i=i??_.location,t=t??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var s,r=uE||Yr(i.hash,"__posthog")||Yr(i.hash,"state"),n=r?nd((()=>JSON.parse(atob(decodeURIComponent(r)))))||nd((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?i.hash=n.desiredHash:t?t.replaceState(t.state,"",i.pathname+i.search):i.hash="")):((s=JSON.parse(e.getItem(Ud)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch{return!1}}Es(i){var e=C.ph_load_toolbar||C.ph_load_editor;!U(e)&&bt(e)?e(i,this.instance):Bd.warn("No toolbar load function found")}loadToolbar(i){var e=!(S==null||!S.getElementById(_h));if(!_||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=k({token:this.instance.config.token},i,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(_.localStorage.setItem(Ud,JSON.stringify(k({},s,{source:void 0}))),this.ws()===Dt.LOADED)this.Es(s);else if(this.ws()===Dt.UNINITIALIZED){var r;this.ys(Dt.LOADING),(r=C.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return Bd.error("[Toolbar] Failed to load",n),void this.ys(Dt.UNINITIALIZED);this.ys(Dt.LOADED),this.Es(s)})),de(_,"turbolinks:load",(()=>{this.ys(Dt.UNINITIALIZED),this.loadToolbar(s)}))}return!0}xs(i){return this.loadToolbar(i)}maybeLoadEditor(i,e,t){return i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(i,e,t)}}},bE={experiments:qa},EE={conversations:class{constructor(i){this.Ss=void 0,this._conversationsManager=null,this.$s=!1,this.ks=null,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this._instance.config.disable_conversations){var e=i.conversations;U(e)||(kt(e)?this.Ss=e:(this.Ss=e.enabled,this.ks=e),this.loadIfEnabled())}}reset(){var i;(i=this._conversationsManager)==null||i.reset(),this._conversationsManager=null,this.Ss=void 0,this.ks=null}loadIfEnabled(){if(!(this._conversationsManager||this.$s||this._instance.config.disable_conversations||fh(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var i=C?.__PosthogExtensions__;if(i&&!w(this.Ss)&&this.Ss)if(this.ks&&this.ks.token){this.$s=!0;try{var e=i.initConversations;if(e)return this.Ps(e),void(this.$s=!1);var t=i.loadExternalDependency;if(!t)return void this.Ts("PostHog loadExternalDependency extension not found.");t(this._instance,"conversations",(s=>{s||!i.initConversations?this.Ts("Could not load conversations script",s):this.Ps(i.initConversations),this.$s=!1}))}catch(s){this.Ts("Error initializing conversations",s),this.$s=!1}}else Ke.error("Conversations enabled but missing token in remote config.")}}Ps(i){if(this.ks)try{this._conversationsManager=i(this.ks,this._instance),Ke.info("Conversations loaded successfully")}catch(e){this.Ts("Error completing conversations initialization",e)}else Ke.error("Cannot complete initialization: remote config is null")}Ts(i,e){Ke.error(i,e),this._conversationsManager=null,this.$s=!1}show(){this._conversationsManager?this._conversationsManager.show():Ke.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Ss===!0&&!Je(this._conversationsManager)}isVisible(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&i!==void 0&&i}sendMessage(i,e,t){var s=this;return _t((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(i,e,t):(Ke.warn("Conversations not available yet."),null)}))()}getMessages(i,e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.getMessages(i,e):(Ke.warn("Conversations not available yet."),null)}))()}markAsRead(i){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(i):(Ke.warn("Conversations not available yet."),null)}))()}getTickets(i){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.getTickets(i):(Ke.warn("Conversations not available yet."),null)}))()}requestRestoreLink(i){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(i):(Ke.warn("Conversations not available yet."),null)}))()}restoreFromToken(i){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(i):(Ke.warn("Conversations not available yet."),null)}))()}restoreFromUrlToken(){var i=this;return _t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromUrlToken():(Ke.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&i!==void 0?i:null}getWidgetSessionId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&i!==void 0?i:null}}},kE={logs:class{constructor(i){var e;this.Rs=!1,this.Is=!1,this._instance=i,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Rs=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(i){var e,t=(e=i.logs)==null?void 0:e.captureConsoleLogs;!U(t)&&t&&(this.Rs=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Rs&&!this.Is){var i=le("[logs]"),e=C?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(s=>{var r;s||(r=e.logs)==null||!r.initializeLogs?i.error("Could not load logs script",s):(e.logs.initializeLogs(this._instance),this.Is=!0)})):i.error("PostHog loadExternalDependency extension not found.")}else i.error("PostHog Extensions not found.")}}}},SE=k({},hE,fE,gE,pE,vE,_E,mE,yE,bE,EE,kE);Mi.__defaultExtensionClasses=k({},SE);St=(Vd=As[Ii]=new Mi,(function(){function i(){i.done||(i.done=!0,$h=!1,Z(As,(function(e){e._dom_loaded()})))}S!=null&&S.addEventListener?S.readyState==="complete"?i():de(S,"DOMContentLoaded",i,{capture:!1}):_&&A.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),Vd)});var Xh={};un(Xh,{Posthog:()=>il});var Zt,il,Yh=Re(()=>{"use strict";Wh();Qi();pi();Zt=class Zt{constructor(e,t=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=it("[PostHog]",()=>this.debug);this.init=()=>{try{let{apiKey:e,api_host:t,config:s={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}let r=t||Vc();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:Bc,autocapture:!0,capture_pageview:"history_change",persistence:"localStorage",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...s.session_recording},before_send:o=>{if(typeof window>"u")return null;let a=window.location.hostname;if(a==="localhost"||a==="127.0.0.1")return o;let l=Gc.some(c=>a.endsWith(`.${c}`)||a===c);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...s};St.init(e,n),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let s=typeof St._isIdentified=="function"?St._isIdentified():this.has_identified;e&&!s?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),St.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),St.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,country_of_residence:s})=>{if(!(!this.has_initialized||!e))try{let r=St.get_property("$stored_person_properties")??{},n={};r.client_id||(n.client_id=e),t&&r.is_internal===void 0&&(n.is_internal=cr(t)),s&&!r.country_of_residence&&(n.country_of_residence=s),Object.keys(n).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:n}),St.setPersonProperties(n)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e,country_of_residence:s})}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}),St.capture(e,t)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.options=e,this.debug=t,this.init()}};Zt.getPosthogInstance=(e,t=!1)=>(Zt._instance||(Zt._instance=new Zt(e,t)),Zt._instance);il=Zt});var AE={};un(AE,{Analytics:()=>Qh,cacheTrackEvents:()=>vi});oo();Qi();pi();var Im=2*365*24*60*60,qt=class qt{constructor(e,t,s=!1){this.analytics=new hi;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=it("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let t=window.location.hostname,n=["webflow.io"].some(c=>t.endsWith(c))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let c=new Uint8Array(16);crypto.getRandomValues(c),c[6]=c[6]&15|64,c[8]=c[8]&63|128;let 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=${n}; max-age=${Im}; 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:ao});try{this.setCookieIfNotExists(),this.analytics.load(e,ao,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,storage:{type:"localStorage"},lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.log("init | SDK loaded successfully",{userId:this.getUserId(),anonymousId:this.getAnonymousId()}),this.onLoadedCallback?.()}})}catch(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let s=this.getUserId();if(!s||s!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:t}),this.analytics.identify(e,t||{}),this.has_identified=!0}catch(r){console.error("RudderStack: Failed to identify user",r)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,t="Deriv App",s,r)=>{if(!(!this.has_initialized||e===this.current_page))try{let n={...s&&{user_id:s},...r};this.log("pageView | tracking page view",{platform:t,current_page:e,properties:n}),this.analytics.page(t,e,n),this.current_page=e}catch(n){console.error("RudderStack: Failed to track page view",n)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting RudderStack session"),this.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,t)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:t}),this.analytics.track(e,t)}catch(s){console.warn("RudderStack: Failed to track event",s)}};this.onLoadedCallback=t,this.debug=s,this.init(e)}};qt.getRudderStackInstance=(e,t,s=!1)=>(qt._instance||(qt._instance=new qt(e,t,s)),qt._instance);var ur=qt;var dr="cached_analytics_events",hr="cached_analytics_page_views",Xc=(i,e)=>{try{let t=localStorage.getItem(dr),s=t?JSON.parse(t):[];s.push({name:i,properties:e,timestamp:Date.now()}),localStorage.setItem(dr,JSON.stringify(s))}catch(t){console.warn("Analytics: Failed to cache event",t)}},Yc=(i,e)=>{try{let t=localStorage.getItem(hr),s=t?JSON.parse(t):[];s.push({name:i,properties:e,timestamp:Date.now()}),localStorage.setItem(hr,JSON.stringify(s))}catch(t){console.warn("Analytics: Failed to cache page view",t)}},Qc=()=>{try{let i=localStorage.getItem(dr);if(i){let e=JSON.parse(i);return Array.isArray(e)?e:[]}}catch(i){console.warn("Analytics: Failed to get cached events",i)}return[]},Jc=()=>{try{let i=localStorage.getItem(hr);if(i){let e=JSON.parse(i);return Array.isArray(e)?e:[]}}catch(i){console.warn("Analytics: Failed to get cached pages",i)}return[]},Zc=()=>{try{localStorage.removeItem(dr)}catch(i){console.warn("Analytics: Failed to clear cached events",i)}},eu=()=>{try{localStorage.removeItem(hr)}catch(i){console.warn("Analytics: Failed to clear cached page views",i)}};pi();pi();var co=class{constructor(){this.interval=null;this.responses=[];this.isTrackingResponses=!1;this.delegatedSelectors=new Set;this.debug=!1;this.log=it("[CacheManager]",()=>this.debug);this.addEventhandler=this.addEventHandler.bind(this)}setDebug(e){this.debug=e}hash(e,t=32){let s=a=>{let l=2166136261;for(let c=0;c<a.length;c++)l^=a.charCodeAt(c),l=l*16777619>>>0;return l.toString(16)},r=a=>btoa(a),n=s(e),o=r(n);for(;o.length<t;)o+=r(s(o));return o.substring(0,t)}getCookies(e){let s=`; ${document.cookie}`.split(`; ${e}=`);if(s.length===2){let r=decodeURIComponent(s.pop().split(";").shift());try{return JSON.parse(r)}catch{return r}}return null}trackPageUnload(){typeof window>"u"||window.addEventListener("beforeunload",()=>{this.isPageViewSent()||this.push("cached_analytics_page_views",{name:window.location.origin+window.location.pathname})})}trackResponses(){if(typeof window>"u"||typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(s,r){return this._url=r,this._method=s,e.apply(this,arguments)},XMLHttpRequest.prototype.send=function(s){return this.addEventListener("load",function(){let r=null;if(typeof s=="string")try{r=JSON.parse(s)}catch{r=s}let n={url:this._url,method:this._method,status:this.status,headers:this.getAllResponseHeaders(),data:this.responseText,payload:r};vi.responses.push(n)}),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}parseFromLocalStorage(e){if(typeof localStorage>"u")return null;try{let t=localStorage.getItem(e);return t===null?null:JSON.parse(t)}catch{return null}}isPageViewSent(){return!!this.responses.find(e=>e.payload?.type==="page"&&e.payload?.anonymousId)}set(e){this.log("set | caching event to localStorage",e),this.push("cached_analytics_events",e)}push(e,t){if(typeof localStorage>"u")return;let s=this.parseFromLocalStorage(e),r=Array.isArray(s)?s:[];r.push(t);try{localStorage.setItem(e,JSON.stringify(r))}catch(n){console.warn("AnalyticsCacheManager: Failed to push to localStorage",n)}}processEvent(e){let t=this.getCookies("client_information");if(t){let{email:s=null}=t;s&&(e.properties.email_hash=this.hash(s))}if(e?.properties?.email){let s=e.properties.email;delete e.properties.email,e.properties.email_hash=this.hash(s)}return e}track(e,t=!1){if(typeof window>"u")return;let s=this.processEvent(e),r=this.getAnalyticsInstance();this.isReady()&&!t?(this.log("track | analytics ready \u2014 calling trackEvent",{event:s.name,properties:s.properties}),r.trackEvent(s.name,s.properties)):(this.log("track | analytics not ready or cache=true \u2014 storing event",{event:s.name,cache:t}),this.set(s))}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:s={}},r=!1,n=null){let o=l=>{l.dataset?.clickEventTracking||(l.addEventListener("click",c=>{let u={name:t,properties:s,cache:r};if(typeof n=="function"){let h=n(c);u={...h,cache:h.cache??r}}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:s={name:"",properties:{}},cache:r=!1,callback:n=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:s.name,properties:s.properties,cache:r};if(typeof n=="function"){let g=n(l);h={...g,cache:g.cache??r}}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,s,r,n)})}),this)}loadEvent(e){return this.log("loadEvent | firing load events",e.map(t=>t.event.name)),e.forEach(({event:t})=>{let{name:s,properties:r}=t;this.track({name:s,properties:r})}),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:s=[],excludedPages:r=[],event:n,callback:o=null})=>{let a=!1;if(s.length?s.includes(t)&&(a=!0):r.length&&r.includes(t)||(a=!0),a){let l=o?o():n;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:n.name,pages:s,excludedPages:r})}),this}clearInterval(){this.interval&&(clearInterval(this.interval),this.interval=null)}cleanup(){this.clearInterval(),this.responses=[],this.isTrackingResponses=!1}},vi=new co;typeof window<"u"&&(window.cacheTrackEvents=vi);function wE(i){let e=i?.debug??!1,t=it("",()=>e),s,r,n,o={},a={},l=[],c=[],u=!1,h=()=>{if(!u&&r?.has_initialized){u=!0;try{let T=Qc();T.length>0&&(t(`processCookieCache | replaying ${T.length} cached event(s)`,T),T.forEach(F=>{let L=Ht(F.properties);r?.track(F.name,L)}),Zc());let x=Jc();x.length>0&&(t(`processCookieCache | replaying ${x.length} cached page view(s)`,x),x.forEach(F=>{r?.pageView(F.name,"Deriv App",P(),F.properties)}),eu())}catch(T){console.warn("Analytics: Failed to process cookie cache",T)}}},g=()=>{t("onSdkLoaded | RudderStack SDK loaded"),h(),c.length>0&&t(`onSdkLoaded | flushing ${c.length} pending identify call(s)`),c.forEach(({userId:T,traits:x})=>{T&&r?.identifyEvent(T,x)}),c=[]},f=async({growthbookKey:T,growthbookDecryptionKey:x,rudderstackKey:F,growthbookOptions:L,posthogOptions:ge,debug:H})=>{var K,J;H!==void 0&&(e=H),vi.setDebug(e),t("initialise | starting analytics initialization",{rudderstack:!!F,growthbook:!!T,posthog:!!ge});try{let V=L?.attributes?.country||(T?await zc():void 0);if(F&&(t("initialise | initializing RudderStack"),r=ur.getRudderStackInstance(F,g,e)),L?.attributes&&Object.keys(L.attributes).length>0){let D=L.attributes,Ie=r?.getAnonymousId();o={...o,country:V,...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&&!Ji(D.user_id)&&{user_id:D.user_id},...Ie&&{anonymous_id:Ie}}}L??(L={}),L.attributes??(L.attributes={});let se=r?.getAnonymousId();if((K=L.attributes).id??(K.id=se),(J=L.attributes).country??(J.country=V),T){t("initialise | initializing GrowthBook");let{Growthbook:D}=await Promise.resolve().then(()=>(zu(),qu));s=D.getGrowthBookInstance(T,x,L,e),t("initialise | GrowthBook initialized");let Ie=setInterval(()=>{Object.keys(a).length>0?clearInterval(Ie):a=m("tracking-buttons-config",{})},1e3)}if(ge){t("initialise | initializing PostHog");let{Posthog:D}=await Promise.resolve().then(()=>(Yh(),Xh));n=D.getPosthogInstance(ge,e),t("initialise | PostHog initialized")}t("initialise | analytics initialization complete")}catch(V){console.warn("Analytics: Failed to initialize",V)}},v=({country:T,user_language:x,device_language:F,device_type:L,account_type:ge,user_id:H,anonymous_id:K,app_id:J,utm_source:V,utm_medium:se,utm_campaign:D,is_authorised:Ie,residence_country:Fe,url:ei,domain:xs,geo_location:Ui,loggedIn:Me,network_downlink:Bi,network_rtt:ti,network_type:Ft,account_currency:ii,account_mode:si})=>{let ri=H??P();if(t("setAttributes | received attributes",{country:T,user_language:x,device_language:F,device_type:L,account_type:ge,user_id:H,anonymous_id:K,app_id:J,utm_source:V,utm_medium:se,utm_campaign:D,is_authorised:Ie,residence_country:Fe,url:ei,domain:xs,geo_location:Ui,loggedIn:Me,network_downlink:Bi,network_rtt:ti,network_type:Ft,account_currency:ii,account_mode:si}),s){let wt={country:T,residence_country:Fe,user_language:x,device_language:F,device_type:L,utm_source:V,utm_medium:se,utm_campaign:D,is_authorised:Ie,url:ei,domain:xs,loggedIn:Me,...H&&!Ji(H)&&{user_id:H},anonymous_id:K};ri&&(wt.id=ri,wt.user_id=ri),t("setAttributes | called GrowthBook setAttributes",wt),s.setAttributes(wt)}o={...o,...T!==void 0&&{country:T},...Ui!==void 0&&{geo_location:Ui},...x!==void 0&&{user_language:x},...ge!==void 0&&{account_type:ge},...J!==void 0&&{app_id:J},...Fe!==void 0&&{residence_country:Fe},...L!==void 0&&{device_type:L},...ei!==void 0&&{url:ei},...Me!==void 0&&{loggedIn:Me},...Bi!==void 0&&{network_downlink:Bi},...ti!==void 0&&{network_rtt:ti},...Ft!==void 0&&{network_type:Ft},...H!==void 0&&!Ji(H)&&{user_id:H},...K!==void 0&&{anonymous_id:K},...ii!==void 0&&{account_currency:ii},...si!==void 0&&{account_mode:si}},t("setAttributes | updated core_data",o)},p=T=>s?.getFeatureState(T)?.experimentResult?.name,m=(T,x)=>s?.getFeatureValue(T,x),E=async()=>await s?.getStatus(),b=T=>s?.isOn(T),O=T=>s?.setUrl(T),P=()=>{let T=r?.getUserId()||"";return T&&!Ji(T)?T:""},I=()=>r?.getAnonymousId()||"",z=(T,x="Deriv App",F)=>{let L=P();t("pageView | called",{current_page:T,platform:x,properties:F,userId:L}),r&&(r.has_initialized?(t("pageView | sending page view to RudderStack",{current_page:T,platform:x}),r.pageView(T,x,L,F)):(t("pageView | RudderStack not initialized \u2014 caching page view to cookie",{current_page:T}),Yc(T,{platform:x,...F})))},B=(T,x)=>{let F=T||P();if(!F){t("identifyEvent | skipped \u2014 no user_id available");return}t("identifyEvent | called",{user_id:F,traits:x});let L=J=>{if(!J)return J;let{email:V,...se}=J;return{...se,...V&&{is_internal:cr(V)}}},ge=x?.rudderstack!==void 0||x?.posthog!==void 0,H,K;if(ge){let{rudderstack:J,posthog:V,...se}=x;H=L({...se,...J}),K=L({...se,...V})}else H=L(x),K=L(x);r&&(r.has_initialized?(t("identifyEvent | calling RudderStack identify",{user_id:F,traits:H}),r.identifyEvent(F,H)):c.some(J=>J.userId===F)||(t("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:F}),c.push({userId:F,traits:H}))),n?.has_initialized&&K&&(t("identifyEvent | calling PostHog identify",{user_id:F,traits:K}),n.identifyEvent(F,K))},N=()=>{t("reset | resetting all providers"),r?.has_initialized&&(t("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(t("reset | resetting PostHog"),n.reset())},ve=T=>"event_metadata"in T||"cta_information"in T||"error"in T,je={initialise:f,setAttributes:v,identifyEvent:B,backfillPersonProperties:({user_id:T,email:x,country_of_residence:F})=>{t("backfillPersonProperties | called",{user_id:T}),n?.has_initialized?(t("backfillPersonProperties | backfilling person properties in PostHog",{user_id:T}),n.backfillPersonProperties({user_id:T,email:x,country_of_residence:F})):t("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:p,getFeatureValue:m,getGrowthbookStatus:E,isFeatureOn:b,setUrl:O,getId:P,getAnonymousId:I,trackEvent:(T,x)=>{let F=P(),L={};if(t("trackEvent | called",{event:T,analytics_data:x,userId:F,core_data:o}),ve(x)){let K=x;L={...K,event_metadata:{...o,...F&&!o.user_id&&{user_id:F},...K.event_metadata}},t("trackEvent | built V2 payload",{event:T,final_payload:L})}else L={...o,...x,...F&&!o.user_id&&{user_id:F}},t("trackEvent | built V1 payload",{event:T,final_payload:L});if(!(!(T in a)||a[T])){t("trackEvent | skipped \u2014 event disabled by tracking_config",{event:T});return}let H=r?.has_initialized;if(!navigator.onLine||!H)H?(t("trackEvent | offline \u2014 caching event to memory",{event:T}),l.push({event:T,payload:L})):(t("trackEvent | RudderStack not initialized \u2014 caching event to cookie",{event:T}),Xc(T,L));else{l.length>0&&(t(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(J=>{let V=Ht(J.payload);r?.track(J.event,V)}),l=[]);let K=Ht(L);t("trackEvent | sending event to RudderStack",{event:T,payload:K}),r?.track(T,K)}if(n?.has_initialized){let K=["page_name","user_language","form_name","version","email_hash"],J=Wc(L),V=Ht(Object.fromEntries(Object.entries(J).filter(([se])=>!K.includes(se))));t("trackEvent | sending event to PostHog",{event:T,payload:V}),n.capture(T,V)}},getInstances:()=>({ab:s,tracking:r,posthog:n}),pageView:z,reset:N};return typeof window<"u"&&(window.AnalyticsInstance=je),je}var Qh=wE();return rf(AE);})();
17
+ `)).length,r=0;r<s;r++){var o=i.charCodeAt(r),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),Qe(a)||(t>e&&(n+=i.substring(e,t)),n+=a,e=t=r+1)}return t>e&&(n+=i.substring(e,i.length)),n},$b=!!Yo||!!Xo,sn=function(i,e,t){var s;t===void 0&&(t=!0);var[r,n]=i.split("?"),o=b({},e),a=(s=n?.split("&").map((u=>{var c,[h,g]=u.split("="),f=t&&(c=o[h])!==null&&c!==void 0?c:g;return delete o[h],h+"="+f})))!==null&&s!==void 0?s:[],l=Eb(o);return l&&a.push(l),r+"?"+a.join("&")},ks=(i,e)=>JSON.stringify(i,((t,s)=>typeof s=="bigint"?s.toString():s),e),Vo=i=>{var{data:e,compression:t}=i;if(e){if(t===yt.GZipJS){var s=xb((function(a,l){var u=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var c=new We(a.length+(a.length>>>1)),h=0,g=function(m){c[h++]=m},f=0;f<u;++f){if(h+5>c.length){var v=new We(h+8+(u-f<<1));v.set(c),c=v}var p=a.charCodeAt(f);p<128||l?g(p):p<2048?(g(192|p>>>6),g(128|63&p)):p>55295&&p<57344?(g(240|(p=65536+(1047552&p)|1023&a.charCodeAt(++f))>>>18),g(128|p>>>12&63),g(128|p>>>6&63),g(128|63&p)):(g(224|p>>>12),g(128|p>>>6&63),g(128|63&p))}return Lh(c,0,h)})(ks(e)),{mtime:0});return{contentType:"text/plain",body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(t===yt.Base64){var r=(function(a){var l,u,c,h,g,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,p=0,m="",E=[];if(!a)return a;a=Lb(a);do l=(g=a.charCodeAt(v++)<<16|a.charCodeAt(v++)<<8|a.charCodeAt(v++))>>18&63,u=g>>12&63,c=g>>6&63,h=63&g,E[p++]=f.charAt(l)+f.charAt(u)+f.charAt(c)+f.charAt(h);while(v<a.length);switch(m=E.join(""),a.length%3){case 1:m=m.slice(0,-2)+"==";break;case 2:m=m.slice(0,-1)+"="}return m})(ks(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:ks(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=ks(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Ur=[];Xo&&Ur.push({transport:"fetch",method:i=>{var e,t,{contentType:s,body:r,estimatedSize:n}=(e=Vo(i))!==null&&e!==void 0?e:{},o=new Headers;Z(i.headers,(function(c,h){o.append(h,c)})),s&&o.append("Content-Type",s);var a=i.url,l=null;if(Ju){var u=new Ju;l={signal:u.signal,timeout:setTimeout((()=>u.abort()),i.timeout)}}Xo(a,b({method:i?.method||"GET",headers:o,keepalive:i.method==="POST"&&(n||0)<52428.8,body:r,signal:(t=l)==null?void 0:t.signal},i.fetchOptions)).then((c=>c.text().then((h=>{var g={statusCode:c.status,text:h};if(c.status===200)try{g.json=JSON.parse(h)}catch(f){w.error(f)}i.callback==null||i.callback(g)})))).catch((c=>{w.error(c),i.callback==null||i.callback({statusCode:0,error:c})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Yo&&Ur.push({transport:"XHR",method:i=>{var e,t=new Yo;t.open(i.method||"GET",i.url,!0);var{contentType:s,body:r}=(e=Vo(i))!==null&&e!==void 0?e:{};Z(i.headers,(function(n,o){t.setRequestHeader(o,n)})),s&&t.setRequestHeader("Content-Type",s),i.timeout&&(t.timeout=i.timeout),i.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}i.callback==null||i.callback(n)}},t.send(r)}}),Be!=null&&Be.sendBeacon&&Ur.push({transport:"sendBeacon",method:i=>{var e=sn(i.url,{beacon:"1"});try{var t,{contentType:s,body:r}=(t=Vo(i))!==null&&t!==void 0?t:{},n=typeof r=="string"?new Blob([r],{type:s}):r;Be.sendBeacon(e,n)}catch{}}});Da=3e3,xa=class{constructor(e,t){this.wt=!0,this.Et=[],this.xt=ot(t?.flush_interval_ms||Da,250,5e3,w.createLogger("flush interval"),Da),this.St=e}enqueue(e){this.Et.push(e),this.$t||this.kt()}unload(){this.Pt();var e=this.Et.length>0?this.Tt():{},t=Object.values(e);[...t.filter((s=>s.url.indexOf("/e")===0)),...t.filter((s=>s.url.indexOf("/e")!==0))].map((s=>{this.St(b({},s,{transport:"sendBeacon"}))}))}enable(){this.wt=!1,this.kt()}kt(){var e=this;this.wt||(this.$t=setTimeout((()=>{if(this.Pt(),this.Et.length>0){var t=this.Tt(),s=function(){var n=t[r],o=new Date().getTime();n.data&&q(n.data)&&Z(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.St(n)};for(var r in t)s()}}),this.xt))}Pt(){clearTimeout(this.$t),this.$t=void 0}Tt(){var e={};return Z(this.Et,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;S(e[n])&&(e[n]=b({},r,{data:[]})),(s=e[n].data)==null||s.push(r.data)})),this.Et=[],e}},Fb=["retriesPerformedSoFar"],La=class{constructor(e){this.Rt=!1,this.It=3e3,this.Et=[],this._instance=e,this.Et=[],this.Ct=!0,!S(_)&&"onLine"in _.navigator&&(this.Ct=_.navigator.onLine,this.Ot=()=>{this.Ct=!0,this.Ft()},this.Mt=()=>{this.Ct=!1},de(_,"online",this.Ot),de(_,"offline",this.Mt))}get length(){return this.Et.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=Kd(e,Fb);Ti(t)&&(s.url=sn(s.url,{retry_count:t})),this._instance._send_request(b({},s,{callback:r=>{r.statusCode!==200&&(r.statusCode<400||r.statusCode>=500)&&(t??0)<10?this.At(b({retriesPerformedSoFar:t},s)):s.callback==null||s.callback(r)}}))}At(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var s=(function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=(Math.random()-.5)*(u-l);return Math.ceil(u+c)})(t),r=Date.now()+s;this.Et.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+s;navigator.onLine||(n+=" (Browser is offline)"),w.warn(n),this.Rt||(this.Rt=!0,this.Dt())}Dt(){if(this.jt&&clearTimeout(this.jt),this.Et.length===0)return this.Rt=!1,void(this.jt=void 0);this.jt=setTimeout((()=>{this.Ct&&this.Et.length>0&&this.Ft(),this.Dt()}),this.It)}Ft(){var e=Date.now(),t=[],s=this.Et.filter((n=>n.retryAt<e||(t.push(n),!1)));if(this.Et=t,s.length>0)for(var{requestOptions:r}of s)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.jt&&(clearTimeout(this.jt),this.jt=void 0),this.Rt=!1,S(_)||(this.Ot&&(_.removeEventListener("online",this.Ot),this.Ot=void 0),this.Mt&&(_.removeEventListener("offline",this.Mt),this.Mt=void 0)),this.Et))try{this._instance._send_request(b({},e,{transport:"sendBeacon"}))}catch(t){w.error(t)}this.Et=[]}},$a=class{constructor(e){this.Lt=()=>{var t,s,r,n;this.Nt||(this.Nt={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+(o?.clientHeight||0),c=o?.scrollHeight||0;this.Nt.lastScrollY=Math.ceil(a),this.Nt.maxScrollY=Math.max(a,(t=this.Nt.maxScrollY)!==null&&t!==void 0?t:0),this.Nt.maxScrollHeight=Math.max(l,(s=this.Nt.maxScrollHeight)!==null&&s!==void 0?s:0),this.Nt.lastContentY=u,this.Nt.maxContentY=Math.max(u,(r=this.Nt.maxContentY)!==null&&r!==void 0?r:0),this.Nt.maxContentHeight=Math.max(c,(n=this.Nt.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}getContext(){return this.Nt}resetContext(){var e=this.Nt;return setTimeout(this.Lt,0),e}startMeasuringScrollPosition(){de(_,"scroll",this.Lt,{capture:!0}),de(_,"scrollend",this.Lt,{capture:!0}),de(_,"resize",this.Lt)}scrollElement(){if(!this._instance.config.scroll_root_selector)return _?.document.documentElement;var e=q(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var s=_?.document.querySelector(t);if(s)return s}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return _&&(_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return _&&(_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft)||0}},Mb=i=>Oh(i?.config.mask_personal_data_properties,i?.config.custom_personal_data_properties),rn=class{constructor(e,t,s,r){this.Ut=n=>{var o=this.zt();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.Ht(this._instance)};this.Bt.register({[ma]:a})}},this._instance=e,this.qt=t,this.Bt=s,this.Ht=r||Mb,this.qt.onSessionId(this.Ut)}zt(){return this.Bt.props[ma]}getSetOnceProps(){var e,t=(e=this.zt())==null?void 0:e.props;return t?"r"in t?Ch(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 Z(Qa(this.getSetOnceProps()),((t,s)=>{s==="$current_url"&&(s="url"),e["$session_entry_"+Jo(s)]=t})),e}},Ns=class{constructor(){this.Vt={},this.Vt={}}on(e,t){return this.Vt[e]||(this.Vt[e]=[]),this.Vt[e].push(t),()=>{this.Vt[e]=this.Vt[e].filter((s=>s!==t))}}emit(e,t){for(var s of this.Vt[e]||[])s(t);for(var r of this.Vt["*"]||[])r(e,t)}},Go=le("[SessionId]"),nn=class{on(e,t){return this.Wt.on(e,t)}constructor(e,t,s){var r;if(this.Gt=[],this.Yt=void 0,this.Wt=new Ns,this.Jt=(c,h)=>!(!Ti(c)||!Ti(h))&&Math.abs(c-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.N=e.config,this.Bt=e.persistence,this.Kt=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Qt=t||xt,this.Zt=s||xt;var n=this.N.persistence_name||this.N.token,o=this.N.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*ot(o,60,36e3,Go.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ti(),this.ii="ph_"+n+"_window_id",this.ei="ph_"+n+"_primary_window_exists",this.ri()){var a=me.D(this.ii),l=me.D(this.ei);a&&!l?this.Kt=a:me.L(this.ii),me.j(this.ei,!0)}if((r=this.N.bootstrap)!=null&&r.sessionID)try{var u=(c=>{var h=c.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.N.bootstrap.sessionID);this.si(this.N.bootstrap.sessionID,new Date().getTime(),u)}catch(c){Go.error("Invalid sessionID in bootstrap",c)}this.ni()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return S(this.Gt)&&(this.Gt=[]),this.Gt.push(e),this.Xt&&e(this.Xt,this.Kt),()=>{this.Gt=this.Gt.filter((t=>t!==e))}}ri(){return this.N.persistence!=="memory"&&!this.Bt.st&&me.F()}oi(e){e!==this.Kt&&(this.Kt=e,this.ri()&&me.j(this.ii,e))}ai(){return this.Kt?this.Kt:this.ri()?me.D(this.ii):null}si(e,t,s){e===this.Xt&&t===this._sessionActivityTimestamp&&s===this._sessionStartTimestamp||(this._sessionStartTimestamp=s,this._sessionActivityTimestamp=t,this.Xt=e,this.Bt.register({[jr]:[t,e,s]}))}li(){var e=this.Bt.props[jr];return q(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.si(null,null,null)}destroy(){clearTimeout(this.ui),this.ui=void 0,this.Yt&&_&&(_.removeEventListener("beforeunload",this.Yt,{capture:!1}),this.Yt=void 0),this.Gt=[]}ni(){this.Yt=()=>{this.ri()&&me.L(this.ei)},de(_,"beforeunload",this.Yt,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.N.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=t||new Date().getTime(),[r,n,o]=this.li(),a=this.ai(),l=Ti(o)&&Math.abs(s-o)>864e5,u=!1,c=!n,h=!c&&!e&&this.Jt(s,r);c||h||l?(n=this.Qt(),a=this.Zt(),Go.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}}),o=s,u=!0):a||(a=this.Zt(),u=!0);var g=Ti(r)&&e&&!l?r:s,f=Ti(o)?o:new Date().getTime();return this.oi(a),this.si(n,g,f),e||this.ti(),u&&this.Gt.forEach((v=>v(n,a,u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:f,changeReason:u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}ti(){clearTimeout(this.ui),this.ui=setTimeout((()=>{var[e]=this.li();if(this.Jt(new Date().getTime(),e)){var t=this.Xt;this.resetSessionId(),this.Wt.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},$h=function(i,e){if(!i)return!1;var t=i.userAgent;if(t&&Zu(t,e))return!0;try{var s=i?.userAgentData;if(s!=null&&s.brands&&s.brands.some((r=>Zu(r?.brand,e))))return!0}catch{}return!!i.webdriver},on=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}};Fh={exact:(i,e)=>e.some((t=>i.some((s=>t===s)))),is_not:(i,e)=>e.every((t=>i.every((s=>t!==s)))),regex:(i,e)=>e.some((t=>i.some((s=>on(t,s))))),not_regex:(i,e)=>e.every((t=>i.every((s=>!on(t,s))))),icontains:(i,e)=>e.map($r).some((t=>i.map($r).some((s=>t.includes(s))))),not_icontains:(i,e)=>e.map($r).every((t=>i.map($r).every((s=>!t.includes(s))))),gt:(i,e)=>e.some((t=>{var s=parseFloat(t);return!isNaN(s)&&i.some((r=>s>parseFloat(r)))})),lt:(i,e)=>e.some((t=>{var s=parseFloat(t);return!isNaN(s)&&i.some((r=>s<parseFloat(r)))}))},$r=i=>i.toLowerCase();Ss=(function(i){return i.US="us",i.EU="eu",i.CUSTOM="custom",i})({}),Sd="i.posthog.com",Fa=class{constructor(e){this.hi={},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("."+Sd,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.hi[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.hi[this.apiHost]=Ss.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.hi[this.apiHost]=Ss.EU:this.hi[this.apiHost]=Ss.CUSTOM),this.hi[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===Ss.CUSTOM)return this.apiHost+t;var s=Sd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+s;case"api":return"https://"+this.region+"."+s}}},J=le("[Surveys]"),Uh="seenSurvey_",Ub=(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},wd=i=>((e,t)=>{var s=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(s=""+e+t.id+"_"+t.current_iteration),s})(Uh,i),Bb=[Fo.Popover,Fo.Widget,Fo.API],Vb={ignoreConditions:!1,ignoreDelay:!1,displayType:Ia.Popover},Gb=le("[PostHog ExternalIntegrations]"),jb={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ma=class{constructor(e){this._instance=e}G(e,t){var s;(s=O.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,e,(r=>{if(r)return Gb.error("failed to load script",r);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,u;!r||(a=O.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.G(jb[o],(()=>{var c;(c=O.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.start(e._instance)})),!r&&(l=O.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((u=O.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.stop())};for(var[s,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;t(s)}}},Ts={},jo=0,Ua=()=>{},Ii="posthog",Bh=!$b&&xe?.indexOf("MSIE")===-1&&xe?.indexOf("Mozilla")===-1,Ad=i=>{var e;return b({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:db(k?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ua,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:ye&&he(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:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(_==null||(e=_.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var s="Bad HTTP status: "+t.statusCode+" "+t.text;w.error(s)},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:Da},error_tracking:{},_onCapture:Ua,__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))},Td=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=ue({},e,i);return q(i.property_blacklist)&&(S(i.property_denylist)?t.property_denylist=i.property_blacklist:q(i.property_denylist)?t.property_denylist=[...i.property_blacklist,...i.property_denylist]:w.error("Invalid value for property_denylist config: "+i.property_denylist)),t},Ba=class{constructor(){this.__forceAllowLocalhost=!1}get di(){return this.__forceAllowLocalhost}set di(e){w.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Mi=class i{vi(e,t){if(e){var s=this.ci.indexOf(e);s!==-1&&this.ci.splice(s,1)}return this.ci.push(t),t.initialize==null||t.initialize(),t}get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new Ba,this.fi=!1,this.version=vt.LIB_VERSION,this.pi=new Ns,this.ci=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ad(),this.SentryIntegration=Ta,this.sentryIntegration=s=>(function(r,n){var o=wh(r,n);return{name:Sh,processEvent:a=>o(a)}})(this,s),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.gi=!1,this.mi=null,this.bi=null,this.yi=null,this.scrollManager=new $a(this),this.pageViewManager=new Xr(this),this.rateLimiter=new Ra(this),this.requestRouter=new Fa(this),this.consent=new Aa(this),this.externalIntegrations=new Ma(this);var t=(e=i.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(s,r,n)=>{var o=he(s)?{[s]:r}:s;this.setPersonProperties(o),n?.({})},set_once:(s,r,n)=>{var o=he(s)?{[s]:r}:s;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(s=>w.info('send "'+s?.event+'"',s)))}init(e,t,s){if(s&&s!==Ii){var r,n=(r=Ts[s])!==null&&r!==void 0?r:new i;return n._init(e,t,s),Ts[s]=n,Ts[Ii][s]=n,n}return this._init(e,t,s)}_init(e,t,s){var r;if(t===void 0&&(t={}),S(e)||Qo(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.wi(t.debug),this.Ei=t,this.xi=[],t.person_profiles?this.bi=t.person_profiles:t.process_person&&(this.bi=t.process_person),this.set_config(ue({},Ad(t.defaults),Td(t),{name:s,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 n=this.Si();this.persistence=new ws(this.config,n),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new ws(b({},this.config,{persistence:"sessionStorage"}),n);var o=b({},this.persistence.props),a=b({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.$i=new xa((v=>this.ki(v)),this.config.request_queue_config),this.Pi=new La(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 nn(this),this.sessionPropsManager=new rn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(w.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Ti(l)}),0)):(w.info("Initializing extensions synchronously"),this.Ti(l)),vt.DEBUG=vt.DEBUG||this.config.debug,vt.DEBUG&&w.info("Starting in debug mode",{this:this,config:t,thisC:b({},this.config),p:o,s:a}),((r=t.bootstrap)==null?void 0:r.distinctID)!==void 0){var u,c,h=this.config.get_device_id(xt()),g=(u=t.bootstrap)!=null&&u.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(rt,(c=t.bootstrap)!=null&&c.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:g})}if(l)this.register_once({distinct_id:os,$device_id:null},"");else if(!this.get_distinct_id()){var f=this.config.get_device_id(xt());this.register_once({distinct_id:f,$device_id:f},""),this.persistence.set_property(rt,"anonymous")}return de(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?bb(this,(()=>this.Ri())):this.Ri(),bt(this.config._onCapture)&&this.config._onCapture!==Ua&&(w.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(v=>this.config._onCapture(v.event,v)))),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}Ti(e){var t,s,r,n,o,a,l,u=performance.now(),c=b({},i.__defaultExtensionClasses,this.config.__extensionClasses),h=[];c.featureFlags&&this.ci.push(this.featureFlags=(t=this.featureFlags)!==null&&t!==void 0?t:new c.featureFlags(this)),c.exceptions&&this.ci.push(this.exceptions=(s=this.exceptions)!==null&&s!==void 0?s:new c.exceptions(this)),c.historyAutocapture&&this.ci.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this.ci.push(new c.tracingHeaders(this)),c.siteApps&&this.ci.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this.ci.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this.ci.push(this.autocapture=new c.autocapture(this)),c.surveys&&this.ci.push(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new c.surveys(this)),c.logs&&this.ci.push(this.logs=(n=this.logs)!==null&&n!==void 0?n:new c.logs(this)),c.conversations&&this.ci.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new c.conversations(this)),c.productTours&&this.ci.push(this.productTours=new c.productTours(this)),c.heatmaps&&this.ci.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this.ci.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this.ci.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this.ci.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,yb)),c.toolbar&&this.ci.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new c.toolbar(this)),c.experiments&&this.ci.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new c.experiments(this)),this.ci.forEach((g=>{g.initialize&&h.push((()=>{g.initialize==null||g.initialize()}))})),h.push((()=>{if(this.Ii){var g=this.Ii;this.Ii=void 0,this.ft(g)}})),this.Ci(h,u)}Ci(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.Ci(e,t)}),0);var s=e.shift();if(s)try{s()}catch(n){w.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&w.info("PostHog extensions initialized ("+r+"ms)")}ft(e){var t;if(!k||!k.body)return w.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.ft(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Ii=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=U(e.supportedCompression,yt.GZipJS)?yt.GZipJS:U(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.bi?this.bi:"identified_only"}),this.ci.forEach((s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(e)))}Ri(){try{this.config.loaded(this)}catch(s){w.critical("`loaded` function failed",s)}if(this.Oi(),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.Fi()}),1),this.Mi=new Zr(this),this.Mi.load()}Oi(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.$i)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Lt(this.__request_queue,(e=>this.ki(e))),this.__request_queue=[],this.Oi()}_handle_unload(){var e,t,s;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Ai()&&this.capture("$pageleave"),(t=this.$i)==null||t.unload(),(s=this.Pi)==null||s.unload()):this.Ai()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Bh?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=sn(e.url,{ip:this.config.ip?1:0}),e.headers=b({},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 s,r,n,o=b({},t);o.timeout=o.timeout||6e4,o.url=sn(o.url,{_:new Date().getTime().toString(),ver:vt.LIB_VERSION,compression:o.compression});var a=(s=o.transport)!==null&&s!==void 0?s:"fetch",l=Ur.filter((c=>!o.disableTransport||!c.transport||!o.disableTransport.includes(c.transport))),u=(r=(n=vh(l,(c=>c.transport===a)))==null?void 0:n.method)!==null&&r!==void 0?r:l[0].method;if(!u)throw new Error("No available transport method");u(o)})(b({},e,{callback:t=>{var s,r;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((s=(r=this.config).on_request_error)==null||s.call(r,t)),e.callback==null||e.callback(t)}}))))}ki(e){this.Pi?this.Pi.retriableRequest(e):this._send_request(e)}_execute_array(e){jo++;try{var t,s=[],r=[],n=[];Lt(e,(a=>{a&&(t=a[0],q(t)?n.push(a):bt(a)?a.call(this):q(a)&&t==="alias"?s.push(a):q(a)&&t.indexOf("capture")!==-1&&bt(this[t])?n.push(a):r.push(a))}));var o=function(a,l){Lt(a,(function(u){if(q(u[0])){var c=l;Z(u,(function(h){c=c[h[0]].apply(c,h.slice(1))}))}else this[u[0]].apply(this,u.slice(1))}),l)};o(s,this),o(r,this),o(n,this)}finally{jo--}}push(e){if(jo>0&&q(e)&&he(e[0])){var t=i.prototype[e[0]];bt(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,s){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.$i){if(this.is_capturing())if(!S(e)&&he(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(n&&!this.config.__preview_capture_bot_pageviews)){var o=s!=null&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!he(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"||s!=null&&s.Di||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=s?.timestamp||a,u=xt(),c={uuid:u,event:e,properties:this.calculateEventProperties(e,t||{},l,u)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&n&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),o&&(c.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),s?.$set&&(c.$set=s?.$set);var h,g=e!=="$groupidentify",f=this.ji(s?.$set_once,g);if(f&&(c.$set_once=f),(c=cb(c,s!=null&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,S(s?.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=a),e===Es.DISMISSED||e===Es.SENT){var v=t?.[Mo.SURVEY_ID],p=t?.[Mo.SURVEY_ITERATION];h={id:v,current_iteration:p},localStorage.getItem(wd(h))||localStorage.setItem(wd(h),"true"),c.$set=b({},c.$set,{[Ub({id:v,current_iteration:p},e===Es.SENT?"responded":"dismissed")]:!0})}else e===Es.SHOWN&&(c.$set=b({},c.$set,{[Mo.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Ib.SHOWN){var m=t?.[_d.TOUR_TYPE];m&&(c.$set=b({},c.$set,{[_d.TOUR_LAST_SEEN_DATE+"/"+m]:new Date().toISOString()}))}var E=b({},c.properties.$set,c.$set);if(Ri(E)||this.setPersonPropertiesForFlags(E),!B(this.config.before_send)){var T=this.Li(c);if(!T)return;c=T}this.pi.emit("eventCaptured",c);var x={method:"POST",url:(r=s?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:s?._batchKey};return!this.config.request_batching||s&&(s==null||!s._batchKey)||s!=null&&s.send_instantly?this.ki(x):this.$i.enqueue(x),c}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,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=b({},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=b({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!he(a.distinct_id)&&!at(a.distinct_id)||Qo(a.distinct_id))&&w.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=Ab(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime());a.$session_id=h,a.$window_id=g}this.sessionPropsManager&&ue(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&ue(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this.Pi)==null?void 0:f.length}catch(E){a.$sdk_debug_error_capturing_properties=String(E)}if(this.requestRouter.region===Ss.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||n?e!=="$pageleave"||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=ue(a,u),e==="$pageview"&&k&&(a.title=k.title),!S(o)){var v=s.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}xe&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=ue({},c,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),q(this.config.property_denylist)?Z(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 p=this.config.sanitize_properties;p&&(w.error("sanitize_properties is deprecated. Use before_send instead"),a=p(a,e));var m=this.Ni();return a.$process_person_profile=m,m&&!n&&this.Ui("_calculate_event_properties"),a}ji(e,t){var s;if(t===void 0&&(t=!0),!this.persistence||!this.Ni()||this.fi)return e;var r=this.persistence.get_initial_props(),n=(s=this.sessionPropsManager)==null?void 0:s.getSetOnceProps(),o=ue({},r,n||{},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.fi=!0),Ri(o)?void 0:o}register(e,t){var s;(s=this.persistence)==null||s.register(e,t)}register_once(e,t,s){var r;(r=this.persistence)==null||r.register_once(e,t,s)}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)}zi(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return(t=this.featureFlags)==null?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var s;return(s=this.featureFlags)==null?void 0:s.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,s){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,s)}updateEarlyAccessFeatureEnrollment(e,t,s){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,s)}getEarlyAccessFeatures(e,t,s){var r;return t===void 0&&(t=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,t,s)}on(e,t){return this.pi.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:"Surveys module not available"}),()=>{})}onSessionId(e){var t,s;return(t=(s=this.sessionManager)==null?void 0:s.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:"Surveys module not available"})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:"Surveys module not available"})}renderSurvey(e,t){var s;(s=this.surveys)==null||s.renderSurvey(e,t)}displaySurvey(e,t){var s;t===void 0&&(t=Vb),(s=this.surveys)==null||s.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,s;return(t=(s=this.surveys)==null?void 0:s.canRenderSurvey(e))!==null&&t!==void 0?t:{visible:!1,disabledReason:"Surveys module not available"}}canRenderSurveyAsync(e,t){var s,r;return t===void 0&&(t=!1),(s=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,t))!==null&&s!==void 0?s:Promise.resolve({visible:!1,disabledReason:"Surveys module not available"})}identify(e,t,s){if(!this.__loaded||!this.persistence)return w.uninitializedWarning("posthog.identify");if(at(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!==os){if(this.Ui("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(_s)&&(this.unregister(_s),this.register({distinct_id:e}));var o,a=(this.persistence.get_property(rt)||"anonymous")==="anonymous";e!==r&&a?(this.persistence.set_property(rt,"identified"),this.setPersonPropertiesForFlags(b({},s||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:s||{}}),this.yi=kd(e,t,s),(o=this.featureFlags)==null||o.setAnonymousDistinctId(r)):(t||s)&&this.setPersonProperties(t,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(Hr))}}else w.critical('The string "'+os+'" 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.Ui("posthog.setPersonProperties")){var s=kd(this.get_distinct_id(),e,t);this.yi!==s?(this.setPersonPropertiesForFlags(b({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.yi=s):w.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,s){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:b({},r,{[e]:t})}),s&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s}),this.setGroupPropertiesForFlags({[e]:s})),r[e]===t||s||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){var s;t===void 0&&(t=!0),(s=this.featureFlags)==null||s.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var s;t===void 0&&(t=!0),this.Ui("posthog.setGroupPropertiesForFlags")&&((s=this.featureFlags)==null||s.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,s,r,n,o,a,l;if(w.info("reset"),!this.__loaded)return w.uninitializedWarning("posthog.reset");var u=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(s=this.sessionPersistence)==null||s.clear(),(r=this.surveys)==null||r.reset(),(n=this.Mi)==null||n.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.persistence)==null||a.set_property(rt,"anonymous"),(l=this.sessionManager)==null||l.resetSessionId(),this.yi=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:os,$device_id:null},"");else{var c=this.config.get_device_id(xt());this.register_once({distinct_id:c,$device_id:e?c:u},"")}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:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&s){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!s)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-s)/1e3)-o,0)}return r}alias(e,t){return e===this.get_property(mh)?(w.critical("Attempting to create alias for existing People user - aborting."),-2):this.Ui("posthog.alias")?(S(t)&&(t=this.get_distinct_id()),e!==t?(this.zi(_s,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=b({},this.config);if(ge(e)){var s,r,n,o,a,l,u,c,h;ue(this.config,Td(e));var g=this.Si();(s=this.persistence)==null||s.update_config(this.config,t,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new ws(b({},this.config,{persistence:"sessionStorage"}),g);var f=this.wi(this.config.debug);kt(f)&&(this.config.debug=f),kt(this.config.debug)&&(this.config.debug?(vt.DEBUG=!0,ae.F()&&ae.j("ph_debug","true"),w.info("set_config",{config:e,oldConfig:t,newConfig:b({},this.config)})):(vt.DEBUG=!1,ae.F()&&ae.L("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(u=this.deadClicksAutocapture)==null||u.startIfEnabledOrStop(),(c=this.surveys)==null||c.loadIfEnabled(),this.Hi(),(h=this.externalIntegrations)==null||h.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,s={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(s).some(Boolean)){var r,n,o,a,l;(r=this.sessionManager)==null||r.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),s.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),s.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){if(this.exceptions){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(b({},r,t))}}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,s;return(t=(s=this.toolbar)==null?void 0:s.loadToolbar(e))!==null&&t!==void 0&&t}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Ii;return t!==Ii&&(t=Ii+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(rt))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(rt))==="identified"}Ni(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Ri(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[_s])&&((t=this.persistence)==null||(t=t.props)==null||!t[Kr]))}Ai(){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.Ni()||this.Ui("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Ui("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Ui(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.zi(Kr,!0),!0)}Si(){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}Hi(){var e,t,s,r,n=this.Si();return((e=this.persistence)==null?void 0:e.st)!==n&&((s=this.persistence)==null||s.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.st)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){if(this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()){var s,r,n,o,a;this.reset(!0),(s=this.sessionManager)==null||s.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new nn(this),this.pageViewManager=new Xr(this),this.persistence&&(this.sessionPropsManager=new rn(this,this.sessionManager,this.persistence));var l=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=i.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=this.vi(this.sessionRecording,new l(this)))}var u,c;this.consent.optInOut(!0),this.Hi(),this.Oi(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((u=this.surveys)==null||u.loadIfEnabled()),(S(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((c=e?.captureEventName)!==null&&c!==void 0?c:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Fi()}else w.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,s;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Hi(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:os,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(s=this.sessionRecording)==null||s.stopRecording(),this.sessionRecording=void 0,this.Fi())):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.Hi()}_is_bot(){return Be?$h(Be,this.config.custom_blocked_useragents):void 0}Fi(){k&&(k.visibilityState==="visible"?this.gi||(this.gi=!0,this.capture("$pageview",{title:k.title},{send_instantly:!0}),this.mi&&(k.removeEventListener("visibilitychange",this.mi),this.mi=null)):this.mi||(this.mi=this.Fi.bind(this),de(k,"visibilitychange",this.mi)))}debug(e){e===!1?(_?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(_?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}bt(){var e,t,s,r,n,o,a,l=this.Ei||{};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):(s="advanced_disable_decide",r=!1,n=w,o=(t="advanced_disable_flags")in(e=l)&&!B(e[t]),a=s in e&&!B(e[s]),o?e[t]:a?(n&&n.warn("Config field '"+s+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[s]):r)}Li(e){if(B(this.config.before_send))return e;var t=q(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var r of t){if(s=r(s),B(s)){var n="Event '"+e.event+"' was rejected in beforeSend function";return $y(e.event)?w.warn(n+". This can cause unexpected behavior."):w.info(n),null}s.properties&&!Ri(s.properties)||w.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return s}getPageViewId(){var e;return(e=this.pageViewManager.K)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,s){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(s)})}wi(e){var t=kt(e)&&!e,s=ae.F()&&ae.A("ph_debug")==="true";return!t&&(!!s||e)}};Mi.__defaultExtensionClasses={},(function(i,e){for(var t=0;t<e.length;t++)i.prototype[e[t]]=lb(i.prototype[e[t]])})(Mi,["identify"]);il=["a","button","form","input","select","textarea","label"];Hb=["next","previous","prev",">","<"],Cd=10,Pd=[".ph-no-rageclick",".ph-no-capture"];sl=i=>!i||$t(i,"html")||!dn(i),zh=(i,e)=>{if(!_||sl(i))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,s=[i],r=i;r.parentNode&&!$t(r,"body");)if(Gh(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=qh(r);if(!n)break;if(e||il.indexOf(n.tagName.toLowerCase())>-1)t=!0;else{var o=_.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}s.push(n),r=n}return{parentIsUsefulElement:t,targetElementList:s}};Wh="(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})",Kb=new RegExp("^(?:"+Wh+")$"),Wb=new RegExp(Wh),Xh="\\d{3}-?\\d{2}-?\\d{4}",Xb=new RegExp("^("+Xh+")$"),Yb=new RegExp("("+Xh+")");ln=class{constructor(e){this.disabled=e===!1;var t=ge(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,s){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&s-r.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:s}];return!1}},Ho="$copy_autocapture",Dd=le("[AutoCapture]");hs=le("[ExceptionAutocapture]");iE=le("[TracingHeaders]"),Pt=le("[Web Vitals]"),Ld=9e5,$d="disabled",Fd="lazy_loading",gs="awaiting_config",Fr="missing_config";le("[SessionRecording]");Ga="[SessionRecording]",Xt=le(Ga),sE=le("[Heatmaps]");Ud=le("[Product Tours]"),zo="ph_product_tours",rE=["$set_once","$set"],Nt=le("[SiteApps]");ja=class{constructor(e){this.Bi=new Ns,this.qi=(t,s)=>this.Vi(t,s)&&this.Wi(t,s)&&this.Gi(t,s)&&this.Yi(t,s),this.Vi=(t,s)=>s==null||!s.event||t?.event===s?.event,this._instance=e,this.Ji=new Set,this.Ki=new Set}init(){var e;if(!S((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((s,r)=>{this.on(s,r)}))}}register(e){var t,s;if(!S((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.Ki)==null||a.add(o),(l=o.steps)==null||l.forEach((u=>{var c;(c=this.Ji)==null||c.add(u?.event||"")}))})),(s=this._instance)!=null&&s.autocapture)){var r,n=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&n.add(l?.selector)}))})),(r=this._instance)==null||r.autocapture.setElementSelectors(n)}}on(e,t){var s;t!=null&&e.length!=0&&(this.Ji.has(e)||this.Ji.has(t?.event))&&this.Ki&&((s=this.Ki)==null?void 0:s.size)>0&&this.Ki.forEach((r=>{this.Xi(t,r)&&this.Bi.emit("actionCaptured",r.name)}))}Qi(e){this.onAction("actionCaptured",(t=>e(t)))}Xi(e,t){if(t?.steps==null)return!1;for(var s of t.steps)if(this.qi(e,s))return!0;return!1}onAction(e,t){return this.Bi.on(e,t)}Wi(e,t){if(t!=null&&t.url){var s,r=e==null||(s=e.properties)==null?void 0:s.$current_url;if(!r||typeof r!="string"||!wi(r,t.url,t.url_matching||"contains"))return!1}return!0}Gi(e,t){return!!this.Zi(e,t)&&!!this.te(e,t)&&!!this.ie(e,t)}Zi(e,t){var s;if(t==null||!t.href)return!0;var r=this.ee(e);if(r.length>0)return r.some((a=>wi(a.href,t.href,t.href_matching||"exact")));var n,o=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!o&&wi((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}te(e,t){var s;if(t==null||!t.text)return!0;var r=this.ee(e);if(r.length>0)return r.some((u=>wi(u.text,t.text,t.text_matching||"exact")||wi(u.$el_text,t.text,t.text_matching||"exact")));var n,o,a,l=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!l&&(n=(function(u){for(var c,h=[],g=/(?::|")text="(.*?)"/g;!B(c=g.exec(u));)h.includes(c[1])||h.push(c[1]);return h})(l),o=t.text,a=t.text_matching||"exact",n.some((u=>wi(u,o,a))))}ie(e,t){var s,r;if(t==null||!t.selector)return!0;var n=e==null||(s=e.properties)==null?void 0:s.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}ee(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Yi(e,t){return t==null||!t.properties||t.properties.length===0||Mh(t.properties.reduce(((s,r)=>{var n=q(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return s[r.key]={values:n,operator:r.operator||"exact"},s}),{}),e?.properties)}},Ha=class{constructor(e){this._instance=e,this.re=new Map,this.se=new Map,this.ne=new Map}oe(e,t){return!!e&&Mh(e.propertyFilters,t?.properties)}ae(e,t){var s=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=s.get(o.name)||[];a.push(r.id),s.set(o.name,a)}}))})),s}le(e,t,s){var r=(s===ls.Activation?this.re:this.se).get(e),n=[];return this.ue((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[s])==null||(a=a.values)==null?void 0:a.find((u=>u.name===e));return this.oe(l,t)}))}register(e){var t;S((t=this._instance)==null?void 0:t._addCaptureHook)||(this.he(e),this.de(e))}de(e){var t=e.filter((s=>{var r,n;return((r=s.conditions)==null?void 0:r.actions)&&((n=s.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.ve==null&&(this.ve=new ja(this._instance),this.ve.init(),this.ve.Qi((s=>{this.onAction(s)}))),t.forEach((s=>{var r,n,o,a,l;s.conditions&&(r=s.conditions)!=null&&r.actions&&(n=s.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=s.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.ve)==null||a.register(s.conditions.actions.values),(l=s.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((u=>{if(u&&u.name){var c=this.ne.get(u.name);c&&c.push(s.id),this.ne.set(u.name,c||[s.id])}})))})))}he(e){var t,s=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.events)&&((a=n.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),r=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.cancelEvents)&&((a=n.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(s.length!==0||r.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.re=this.ae(e,ls.Activation),this.se=this.ae(e,ls.Cancellation))}onEvent(e,t){var s,r=this.ce(),n=this.fe(),o=this.pe(),a=((s=this._instance)==null||(s=s.persistence)==null?void 0:s.props[n])||[];if(o===e&&t&&a.length>0){var l,u;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var c=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(u=t.properties)==null?void 0:u.$product_tour_id);if(c){var h=a.indexOf(c);h>=0&&(a.splice(h,1),this._e(a))}}else{if(this.se.has(e)){var g=this.le(e,t,ls.Cancellation);g.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:g.map((v=>v.id))}),g.forEach((v=>{var p=a.indexOf(v.id);p>=0&&a.splice(p,1),this.ge(v.id)})),this._e(a))}if(this.re.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.re.get(e)});var f=this.le(e,t,ls.Activation);this._e(a.concat(f.map((v=>v.id))||[]))}}}onAction(e){var t,s=this.fe(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[s])||[];this.ne.has(e)&&this._e(r.concat(this.ne.get(e)||[]))}_e(e){var t,s=this.ce(),r=this.fe(),n=[...new Set(e)].filter((o=>!this.me(o)));s.info("updating activated items",{activatedItems:n}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:n})}getActivatedIds(){var e,t=this.fe(),s=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return s||[]}getEventToItemsMap(){return this.re}be(){return this.ve}},qa=class extends Ha{constructor(e){super(e)}fe(){return"$surveys_activated"}pe(){return Es.SHOWN}ue(e){var t;(t=this._instance)==null||t.getSurveys(e)}ge(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}ce(){return J}me(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},nE=_!=null&&_.location?Qr(_.location.hash,"__posthog")||Qr(location.hash,"state"):null,Bd="_postHogToolbarParams",Vd=le("[Toolbar]"),Dt=(function(i){return i[i.UNINITIALIZED=0]="UNINITIALIZED",i[i.LOADING=1]="LOADING",i[i.LOADED=2]="LOADED",i})(Dt||{}),De=le("[FeatureFlags]"),fs=le("[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,Ko="$active_feature_flags",Ai="$override_feature_flags",Gd="$feature_flag_payloads",ps="$override_feature_flag_payloads",jd="$feature_flag_request_id",Hd=i=>{var e={};for(var[t,s]of Mr(i||{}))s&&(e[t]=s);return e},gE=i=>{var e=i.flags;return e?(i.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var s;return[t,(s=e[t].variant)!==null&&s!==void 0?s:e[t].enabled]}))),i.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var s;return(s=e[t].metadata)==null?void 0:s.payload})).map((t=>{var s;return[t,(s=e[t].metadata)==null?void 0:s.payload]})))):De.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),i},fE=(function(i){return i.FeatureFlags="feature_flags",i.Recordings="recordings",i})({}),Wo=le("[Error tracking]"),pE={icontains:(i,e)=>!!_&&e.href.toLowerCase().indexOf(i.toLowerCase())>-1,not_icontains:(i,e)=>!!_&&e.href.toLowerCase().indexOf(i.toLowerCase())===-1,regex:(i,e)=>!!_&&on(e.href,i),not_regex:(i,e)=>!!_&&!on(e.href,i),exact:(i,e)=>e.href===i,is_not:(i,e)=>e.href!==i},za=class i{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(s){s===void 0&&(s=!1),t.getWebExperiments((r=>{i.ye("retrieved web experiments from the server"),t.we=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;t.we&&(i.ye("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=t.we)==null||o.set(n.feature_flag_key,n));var a=t._instance.getFeatureFlag(n.feature_flag_key);he(a)&&n.variants[a]&&t.Ee(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];i.xe(u)&&t.Ee(n.name,l,u.transforms)}}))}),s)},this._instance=e,this._instance.onFeatureFlags((s=>{this.onFeatureFlags(s)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())i.ye("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(B(this.we))return this.we=new Map,this.loadIfEnabled(),void this.previewWebExperiment();i.ye("applying feature flags",e),e.forEach((t=>{var s;if(this.we&&(s=this.we)!=null&&s.has(t)){var r,n=this._instance.getFeatureFlag(t),o=(r=this.we)==null?void 0:r.get(t);n&&o!=null&&o.variants[n]&&this.Ee(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=i.getWindowLocation();if(e!=null&&e.search){var t=Jr(e?.search,"__experiment_id"),s=Jr(e?.search,"__experiment_variant");t&&s&&(i.ye("previewing web experiments "+t+" && "+s),this.getWebExperiments((r=>{this.Se(parseInt(t),s,r)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,s){if(this._instance.config.disable_web_experiments&&!s)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:n=>{if(n.statusCode!==200||!n.json)return e([]);var o=n.json.experiments||[];return e(o)}})}Se(e,t,s){var r=s.filter((n=>n.id===e));r&&r.length>0&&(i.ye("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Ee(r[0].name,t,r[0].variants[t].transforms))}static xe(e){return!B(e.conditions)&&i.$e(e)&&i.ke(e)}static $e(e){var t;if(B(e.conditions)||B((t=e.conditions)==null?void 0:t.url))return!0;var s,r,n,o=i.getWindowLocation();return!!o&&((s=e.conditions)==null||!s.url||pE[(r=(n=e.conditions)==null?void 0:n.urlMatchType)!==null&&r!==void 0?r:"icontains"](e.conditions.url,o))}static getWindowLocation(){return _?.location}static ke(e){var t;if(B(e.conditions)||B((t=e.conditions)==null?void 0:t.utm))return!0;var s=Ah();if(s.utm_source){var r,n,o,a,l,u,c,h,g=(r=e.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==s.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)==s.utm_source,v=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==s.utm_medium,p=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==s.utm_term;return g&&v&&p&&f}return!1}static ye(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),r=1;r<t;r++)s[r-1]=arguments[r];w.info("[WebExperiments] "+e,s)}Ee(e,t,s){this._is_bot()?i.ye("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?s.forEach((r=>{if(r.selector){var n;i.ye("applying transform of variant "+t+" for experiment "+e+" ",r);var o=(n=document)==null?void 0:n.querySelectorAll(r.selector);o?.forEach((a=>{var l=a;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)}))}})):i.ye("Control variants leave the page unmodified.")}_is_bot(){return Be&&this._instance?$h(Be,this._instance.config.custom_blocked_useragents):void 0}},Ke=le("[Conversations]"),hn={featureFlags:class{constructor(i){this.Pe=!1,this.Te=!1,this.Re=!1,this.Ie=!1,this.Ce=!1,this.Oe=!1,this.Fe=!1,this.Me=!1,this._instance=i,this.featureFlagEventHandlers=[]}Ae(){var i,e;return(i=(e=this._instance.persistence)==null?void 0:e.nt(this._instance.config.feature_flag_cache_ttl_ms))!==null&&i!==void 0&&i}De(){return!!this.Ae()&&(this.Me||this.Re||(this.Me=!0,De.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}je(){var i,e=(i=this._instance.config.evaluation_contexts)!==null&&i!==void 0?i:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.Fe||(De.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Fe=!0),e!=null&&e.length?e.filter((t=>{var s=t&&typeof t=="string"&&t.trim().length>0;return s||De.error("Invalid evaluation context found:",t,"Expected non-empty string"),s})):[]}Le(){return this.je().length>0}initialize(){var i,e,{config:t}=this._instance,s=(i=(e=t.bootstrap)==null?void 0:e.featureFlags)!==null&&i!==void 0?i:{};if(Object.keys(s).length){var r,n,o=(r=(n=t.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(s).filter((u=>!!s[u])).reduce(((u,c)=>(u[c]=s[c]||!1,u)),{}),l=Object.keys(o).filter((u=>a[u])).reduce(((u,c)=>(o[c]&&(u[c]=o[c]),u)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(i,e,t){var s=t!=null&&t.merge?this.getFlagVariants():{},r=t!=null&&t.merge?this.getFlagPayloads():{},n=b({},s,i),o=b({},r,e),a={};for(var[l,u]of Object.entries(n)){var c=typeof u=="string";a[l]={key:l,enabled:!!c||!!u,variant:c?u:void 0,reason:void 0,metadata:S(o?.[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.receivedFeatureFlags({flags:a})}get hasLoadedFlags(){return this.Te}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var i=this._instance.get_property(pa),e=this._instance.get_property(Ai),t=this._instance.get_property(ps);if(!t&&!e)return i||{};var s=ue({},i||{}),r=[...new Set([...Object.keys(t||{}),...Object.keys(e||{})])];for(var n of r){var o,a,l=s[n],u=e?.[n],c=S(u)?(o=l?.enabled)!==null&&o!==void 0&&o:!!u,h=S(u)?l.variant:typeof u=="string"?u:void 0,g=t?.[n],f=b({},l,{enabled:c,variant:c?h??l?.variant:void 0});c!==l?.enabled&&(f.original_enabled=l?.enabled),h!==l?.variant&&(f.original_variant=l?.variant),g&&(f.metadata=b({},l?.metadata,{payload:g,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),s[n]=f}return this.Pe||(De.warn(" Overriding feature flag details!",{flagDetails:i,overriddenPayloads:t,finalDetails:s}),this.Pe=!0),s}getFlagVariants(){var i=this._instance.get_property(Oi),e=this._instance.get_property(Ai);if(!e)return i||{};for(var t=ue({},i),s=Object.keys(e),r=0;r<s.length;r++)t[s[r]]=e[s[r]];return this.Pe||(De.warn(" Overriding feature flags!",{enabledFlags:i,overriddenFlags:e,finalFlags:t}),this.Pe=!0),t}getFlagPayloads(){var i=this._instance.get_property(Gd),e=this._instance.get_property(ps);if(!e)return i||{};for(var t=ue({},i||{}),s=Object.keys(e),r=0;r<s.length;r++)t[s[r]]=e[s[r]];return this.Pe||(De.warn(" Overriding feature flag payloads!",{flagPayloads:i,overriddenPayloads:e,finalPayloads:t}),this.Pe=!0),t}reloadFeatureFlags(){this.Ie||this._instance.config.advanced_disable_feature_flags||this.Ne||(this._instance.pi.emit("featureFlagsReloading",!0),this.Ne=setTimeout((()=>{this.Ue()}),5))}ze(){clearTimeout(this.Ne),this.Ne=void 0}ensureFlagsLoaded(){this.Te||this.Re||this.Ne||this.reloadFeatureFlags()}setAnonymousDistinctId(i){this.$anon_distinct_id=i}setReloadingPaused(i){this.Ie=i}Ue(i){var e;if(this.ze(),!this._instance.bt())if(this.Re)this.Ce=!0;else{var t=this._instance.config.token,s=this._instance.get_property("$device_id"),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:b({},((e=this._instance.persistence)==null?void 0:e.get_initial_props())||{},this._instance.get_property(bs)||{}),group_properties:this._instance.get_property(Yt),timezone:Ph()};Qe(s)||S(s)||(r.$device_id=s),(i!=null&&i.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Le()&&(r.evaluation_contexts=this.je());var n=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",o=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+n);this.Re=!0,this._instance._send_request({method:"POST",url:o,data:r,compression:this._instance.config.disable_compression?void 0:yt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:a=>{var l,u,c,h=!0;if(a.statusCode===200&&(this.Ce||(this.$anon_distinct_id=void 0),h=!1),this.Re=!1,!r.disable_flags||this.Ce){this.Oe=!h;var g=[];a.error?a.error instanceof Error?g.push(a.error.name==="AbortError"?cE:uE):g.push(dE):a.statusCode!==200&&g.push(hE(a.statusCode)),(l=a.json)!=null&&l.errorsWhileComputingFlags&&g.push(oE);var f=!((u=a.json)==null||(u=u.quotaLimited)==null||!u.includes(fE.FeatureFlags));if(f&&g.push(lE),(c=this._instance.persistence)==null||c.register({[_a]:g}),f)De.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;r.disable_flags||this.receivedFeatureFlags((v=a.json)!==null&&v!==void 0?v:{},h),this.Ce&&(this.Ce=!1,this.Ue())}}}})}}getFeatureFlag(i,e){var t;if(e===void 0&&(e={}),!e.fresh||this.Oe)if(this.Te||this.getFlags()&&this.getFlags().length>0){if(!this.De()){var s=this.getFeatureFlagResult(i,e);return(t=s?.variant)!==null&&t!==void 0?t:s?.enabled}}else De.warn('getFeatureFlag for key "'+i+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(i){return this.getFlagsWithDetails()[i]}getFeatureFlagPayload(i){var e=this.getFeatureFlagResult(i,{send_event:!1});return e?.payload}getFeatureFlagResult(i,e){if(e===void 0&&(e={}),!e.fresh||this.Oe)if(this.Te||this.getFlags()&&this.getFlags().length>0){if(!this.De()){var t=this.getFlagVariants(),s=i in t,r=t[i],n=this.getFlagPayloads()[i],o=String(r),a=this._instance.get_property(jd)||void 0,l=this._instance.get_property(qr)||void 0,u=this._instance.get_property(Hr)||{};if((e.send_event||!("send_event"in e))&&(!(i in u)||!u[i].includes(o))){var c,h,g,f,v,p,m,E,T,x;q(u[i])?u[i].push(o):u[i]=[o],(c=this._instance.persistence)==null||c.register({[Hr]:u});var R=this.getFeatureFlagDetails(i),M=[...(h=this._instance.get_property(_a))!==null&&h!==void 0?h:[]];S(r)&&M.push(aE);var F={$feature_flag:i,$feature_flag_response:r,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:((g=this._instance.config.bootstrap)==null||(g=g.featureFlags)==null?void 0:g[i])||null,$feature_flag_bootstrapped_payload:((f=this._instance.config.bootstrap)==null||(f=f.featureFlagPayloads)==null?void 0:f[i])||null,$used_bootstrap_value:!this.Oe};S(R==null||(v=R.metadata)==null?void 0:v.version)||(F.$feature_flag_version=R.metadata.version);var W,$=(p=R==null||(m=R.reason)==null?void 0:m.description)!==null&&p!==void 0?p:R==null||(E=R.reason)==null?void 0:E.code;$&&(F.$feature_flag_reason=$),R!=null&&(T=R.metadata)!=null&&T.id&&(F.$feature_flag_id=R.metadata.id),S(R?.original_variant)&&S(R?.original_enabled)||(F.$feature_flag_original_response=S(R.original_variant)?R.original_enabled:R.original_variant),R!=null&&(x=R.metadata)!=null&&x.original_payload&&(F.$feature_flag_original_payload=R==null||(W=R.metadata)==null?void 0:W.original_payload),M.length&&(F.$feature_flag_error=M.join(",")),this._instance.capture("$feature_flag_called",F)}if(s){var ve=n;if(!S(n))try{ve=JSON.parse(n)}catch{}return{key:i,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:ve}}}}else De.warn('getFeatureFlagResult for key "'+i+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(i,e){var t=this._instance.config.token,s={distinct_id:this._instance.get_distinct_id(),token:t};this.Le()&&(s.evaluation_contexts=this.je()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:s,compression:this._instance.config.disable_compression?void 0:yt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:r=>{var n,o=(n=r.json)==null?void 0:n.featureFlagPayloads;e(o?.[i]||void 0)}})}isFeatureEnabled(i,e){if(e===void 0&&(e={}),!e.fresh||this.Oe){if(this.Te||this.getFlags()&&this.getFlags().length>0){var t=this.getFeatureFlag(i,e);return S(t)?void 0:!!t}De.warn('isFeatureEnabled for key "'+i+`" failed. Feature flags didn't load in time.`)}}addFeatureFlagsHandler(i){this.featureFlagEventHandlers.push(i)}removeFeatureFlagsHandler(i){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==i))}receivedFeatureFlags(i,e){if(this._instance.persistence){this.Te=!0;var t=this.getFlagVariants(),s=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(n,o,a,l,u){a===void 0&&(a={}),l===void 0&&(l={}),u===void 0&&(u={});var c=gE(n),h=c.flags,g=c.featureFlags,f=c.featureFlagPayloads;if(g){var v=n.requestId,p=n.evaluatedAt;if(q(g)){De.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(g)for(var E=0;E<g.length;E++)m[g[E]]=!0;o&&o.register({[Ko]:g,[Oi]:m})}else{var T=g,x=f,R=h;if(n.errorsWhileComputingFlags)if(h){var M=new Set(Object.keys(h).filter((F=>{var W;return!((W=h[F])!=null&&W.failed)})));T=b({},a,Object.fromEntries(Object.entries(T).filter((F=>{var[W]=F;return M.has(W)})))),x=b({},l,Object.fromEntries(Object.entries(x||{}).filter((F=>{var[W]=F;return M.has(W)})))),R=b({},u,Object.fromEntries(Object.entries(R||{}).filter((F=>{var[W]=F;return M.has(W)}))))}else T=b({},a,T),x=b({},l,x),R=b({},u,R);o&&o.register(b({[Ko]:Object.keys(Hd(T)),[Oi]:T||{},[Gd]:x||{},[pa]:R||{}},v?{[jd]:v}:{},p?{[qr]:p}:{}))}}})(i,this._instance.persistence,t,s,r),e||(this.Me=!1),this.He(e)}}override(i,e){e===void 0&&(e=!1),De.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:i,suppressWarning:e})}overrideFeatureFlags(i){if(!this._instance.__loaded||!this._instance.persistence)return De.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(i===!1)return this._instance.persistence.unregister(Ai),this._instance.persistence.unregister(ps),this.He(),fs.info("All overrides cleared");if(i&&typeof i=="object"&&("flags"in i||"payloads"in i)){var e,t=i;if(this.Pe=!!((e=t.suppressWarning)!==null&&e!==void 0&&e),"flags"in t){if(t.flags===!1)this._instance.persistence.unregister(Ai),fs.info("Flag overrides cleared");else if(t.flags){if(q(t.flags)){for(var s={},r=0;r<t.flags.length;r++)s[t.flags[r]]=!0;this._instance.persistence.register({[Ai]:s})}else this._instance.persistence.register({[Ai]:t.flags});fs.info("Flag overrides set",{flags:t.flags})}}return"payloads"in t&&(t.payloads===!1?(this._instance.persistence.unregister(ps),fs.info("Payload overrides cleared")):t.payloads&&(this._instance.persistence.register({[ps]:t.payloads}),fs.info("Payload overrides set",{payloads:t.payloads}))),void this.He()}this.He()}onFeatureFlags(i){if(this.addFeatureFlagsHandler(i),this.Te){var{flags:e,flagVariants:t}=this.Be();i(e,t)}return()=>this.removeFeatureFlagsHandler(i)}updateEarlyAccessFeatureEnrollment(i,e,t){var s,r=(this._instance.get_property(ys)||[]).find((l=>l.flagKey===i)),n={["$feature_enrollment/"+i]:e},o={$feature_flag:i,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),t&&(o.$feature_enrollment_stage=t),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=b({},this.getFlagVariants(),{[i]:e});(s=this._instance.persistence)==null||s.register({[Ko]:Object.keys(Hd(a)),[Oi]:a}),this.He()}getEarlyAccessFeatures(i,e,t){e===void 0&&(e=!1);var s=this._instance.get_property(ys),r=t?"&"+t.map((n=>"stage="+n)).join("&"):"";if(s&&!e)return i(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+r),method:"GET",callback:n=>{var o,a;if(n.json){var l=n.json.earlyAccessFeatures;return(o=this._instance.persistence)==null||o.unregister(ys),(a=this._instance.persistence)==null||a.register({[ys]:l}),i(l)}}})}Be(){var i=this.getFlags(),e=this.getFlagVariants();return{flags:i.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,s)=>(t[s]=e[s],t)),{})}}He(i){var{flags:e,flagVariants:t}=this.Be();this.featureFlagEventHandlers.forEach((s=>s(e,t,{errorsLoading:i})))}setPersonPropertiesForFlags(i,e){e===void 0&&(e=!0);var t=this._instance.get_property(bs)||{};this._instance.register({[bs]:b({},t,i)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(bs)}setGroupPropertiesForFlags(i,e){e===void 0&&(e=!0);var t=this._instance.get_property(Yt)||{};Object.keys(t).length!==0&&Object.keys(t).forEach((s=>{t[s]=b({},t[s],i[s]),delete i[s]})),this._instance.register({[Yt]:b({},t,i)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(i){if(i){var e=this._instance.get_property(Yt)||{};this._instance.register({[Yt]:b({},e,{[i]:{}})})}else this._instance.unregister(Yt)}reset(){this.Te=!1,this.Re=!1,this.Ie=!1,this.Ce=!1,this.Oe=!1,this.$anon_distinct_id=void 0,this.ze(),this.Pe=!1}}},vE={sessionRecording:class{get started(){var i;return!((i=this.qe)==null||!i.isStarted)}get status(){var i,e;return this.Ve===gs||this.Ve===Fr?this.Ve:(i=(e=this.qe)==null?void 0:e.status)!==null&&i!==void 0?i:this.Ve}constructor(i){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ve=$d,this.We=void 0,this._instance=i,!this._instance.sessionManager)throw Xt.error("started without valid sessionManager"),new Error(Ga+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Ga+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Ge(){var i,e=!((i=this._instance.get_property(Nr))==null||!i.enabled),t=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&t&&!s}startIfEnabledOrStop(i){var e;if(!this.Ge||(e=this.qe)==null||!e.isStarted){var t=!S(Object.assign)&&!S(Array.from);this.Ge&&t?(this.Ye(i),Xt.info("starting")):(this.Ve=$d,this.stopRecording())}}Ye(i){var e,t,s;this.Ge&&(this.Ve!==gs&&this.Ve!==Fr&&(this.Ve=Fd),O!=null&&(e=O.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=O.__PosthogExtensions__)!=null&&t.initSessionRecording?this.Je(i):(s=O.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.Ke,(r=>{if(r)return Xt.error("could not load recorder",r);this.Je(i)})))}stopRecording(){var i,e;(i=this.We)==null||i.call(this),this.We=void 0,(e=this.qe)==null||e.stop()}Xe(){var i,e;(i=this.We)==null||i.call(this),this.We=void 0,(e=this.qe)==null||e.discard()}Qe(){var i;(i=this._instance.persistence)==null||i.unregister(bh)}Ze(i,e){if(B(i))return null;var t,s=at(i)?i:parseFloat(i);return typeof(t=s)=="number"&&Number.isFinite(t)&&t>=0&&t<=1?s:(Xt.warn(e+" must be between 0 and 1. Ignoring invalid value:",i),null)}tr(i){if(this._instance.persistence){var e,t,s=this._instance.persistence,r=()=>{var n,o=i.sessionRecording===!1?void 0:i.sessionRecording,a=this.Ze((n=this._instance.config.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.Ze(o?.sampleRate,"remote config sampleRate"),u=a??l;B(u)&&this.Qe();var c=o?.minimumDurationMilliseconds;s.register({[Nr]:b({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:b({capturePerformance:i.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:S(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};r(),(e=this.We)==null||e.call(this),this.We=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(r)}}onRemoteConfig(i){return"sessionRecording"in i?i.sessionRecording===!1?(this.tr(i),void this.Xe()):(this.tr(i),void this.startIfEnabledOrStop()):(this.Ve===gs&&(this.Ve=Fr,Xt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(i,e){var t;e===void 0&&(e="log"),(t=this.qe)!=null&&t.log?this.qe.log(i,e):Xt.warn("log called before recorder was ready")}get Ke(){var i,e,t=(i=this._instance)==null||(i=i.persistence)==null?void 0:i.get_property(Nr);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}ir(){var i,e=this._instance.get_property(Nr);if(!e)return!1;var t=(i=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&i!==void 0?i:Date.now();return Date.now()-t<=36e5}Je(i){var e,t;if((e=O.__PosthogExtensions__)==null||!e.initSessionRecording)throw Error("Called on script loaded before session recording is available");if(this.qe||(this.qe=(t=O.__PosthogExtensions__)==null?void 0:t.initSessionRecording(this._instance),this.qe._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ir())return this.Ve===Fr||this.Ve===gs?void 0:(this.Ve=gs,Xt.info("persisted remote config is stale, requesting fresh config before starting"),void new Zr(this._instance).load());this.Ve=Fd,this.qe.start(i)}onRRwebEmit(i){var e;(e=this.qe)==null||e.onRRwebEmit==null||e.onRRwebEmit(i)}overrideLinkedFlag(){var i,e;this.qe||(e=this._instance.persistence)==null||e.register({$replay_override_linked_flag:!0}),(i=this.qe)==null||i.overrideLinkedFlag()}overrideSampling(){var i,e;this.qe||(e=this._instance.persistence)==null||e.register({$replay_override_sampling:!0}),(i=this.qe)==null||i.overrideSampling()}overrideTrigger(i){var e,t;this.qe||(t=this._instance.persistence)==null||t.register({[i==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.qe)==null||e.overrideTrigger(i)}get sdkDebugProperties(){var i;return((i=this.qe)==null?void 0:i.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(i,e){var t;return!((t=this.qe)==null||!t.tryAddCustomEvent(i,e))}}},_E={autocapture:class{constructor(i){this.er=!1,this.rr=null,this.sr=!1,this.instance=i,this.rageclicks=new ln(i.config.rageclick),this.nr=null}initialize(){this.startIfEnabled()}get N(){var i,e,t=ge(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(i=t.url_allowlist)==null?void 0:i.map((s=>new RegExp(s))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((s=>new RegExp(s))),t}ar(){if(this.isBrowserSupported()){if(_&&k){var i=t=>{t=t||_?.event;try{this.lr(t)}catch(s){Dd.error("Failed to capture event",s)}};if(de(k,"submit",i,{capture:!0}),de(k,"change",i,{capture:!0}),de(k,"click",i,{capture:!0}),this.N.capture_copied_text){var e=t=>{t=t||_?.event,this.lr(t,Ho)};de(k,"copy",e,{capture:!0}),de(k,"cut",e,{capture:!0})}}}else Dd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.er&&(this.ar(),this.er=!0)}onRemoteConfig(i){i.elementsChainAsString&&(this.sr=i.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[ld]:!!i.autocapture_opt_out}),this.rr=!!i.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(i){this.nr=i}getElementSelectors(i){var e,t=[];return(e=this.nr)==null||e.forEach((s=>{var r=k?.querySelectorAll(s);r?.forEach((n=>{i===n&&t.push(s)}))})),t}get isEnabled(){var i,e,t=(i=this.instance.persistence)==null?void 0:i.props[ld],s=this.rr;if(Qe(s)&&!kt(t)&&!this.instance.bt())return!1;var r=(e=this.rr)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!r}lr(i,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,s=Od(i);Vh(s)&&(s=s.parentNode||null),e==="$autocapture"&&i.type==="click"&&i instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(i.clientX,i.clientY,i.timeStamp||new Date().getTime())&&qb(s,this.instance.config.rageclick)&&this.lr(i,"$rageclick");var r=e===Ho;if(s&&zb(s,i,this.N,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=tE(s,{e:i,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.N.element_attribute_ignorelist,elementsChainAsString:this.sr});if(o)return!1;var a=this.getElementSelectors(s);if(a&&a.length>0&&(n.$element_selectors=a),e===Ho){var l,u=jh(_==null||(l=_.getSelection())==null?void 0:l.toString()),c=i.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return bt(k?.querySelectorAll)}},historyAutocapture:class{constructor(i){var e;this._instance=i,this.ur=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(w.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.hr&&this.hr(),this.hr=void 0,w.info("History API monitoring stopped")}monitorHistoryChanges(){var i,e;if(_&&_.history){var t=this;(i=_.history.pushState)!=null&&i.__posthog_wrapped__||xd(_.history,"pushState",(s=>function(r,n,o){s.call(this,r,n,o),t.dr("pushState")})),(e=_.history.replaceState)!=null&&e.__posthog_wrapped__||xd(_.history,"replaceState",(s=>function(r,n,o){s.call(this,r,n,o),t.dr("replaceState")})),this.vr()}}dr(i){try{var e,t=_==null||(e=_.location)==null?void 0:e.pathname;if(!t)return;t!==this.ur&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:i}),this.ur=t}catch(s){w.error("Error capturing "+i+" pageview",s)}}vr(){if(!this.hr){var i=()=>{this.dr("popstate")};de(_,"popstate",i),this.hr=()=>{_&&_.removeEventListener("popstate",i)}}}},heatmaps:class{constructor(i){var e;this.cr=!1,this.er=!1,this.pr=null,this.instance=i,this.cr=!((e=this.instance.persistence)==null||!e.props[ga]),this.rageclicks=new ln(i.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var i=5e3;return ge(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(i=this.instance.config.capture_heatmaps.flush_interval_milliseconds),i}get isEnabled(){return B(this.instance.config.capture_heatmaps)?B(this.instance.config.enable_heatmaps)?this.cr:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.er)return;sE.info("starting..."),this._r(),this.gr()}else{var i;clearInterval((i=this.pr)!==null&&i!==void 0?i:void 0),this.mr(),this.getAndClearBuffer()}}onRemoteConfig(i){if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ga]:e}),this.cr=e,this.startIfEnabled()}}getAndClearBuffer(){var i=this.C;return this.C=void 0,i}br(i){this.yr(i.originalEvent,"deadclick")}gr(){this.pr&&clearInterval(this.pr),this.pr=(function(i){return i?.visibilityState==="visible"})(k)?setInterval(this.Ft.bind(this),this.flushIntervalMilliseconds):null}_r(){_&&k&&(this.wr=this.Ft.bind(this),de(_,"beforeunload",this.wr),this.Er=i=>this.yr(i||_?.event),de(k,"click",this.Er,{capture:!0}),this.Sr=i=>this.$r(i||_?.event),de(k,"mousemove",this.Sr,{capture:!0}),this.kr=new Wr(this.instance,mb,this.br.bind(this)),this.kr.startIfEnabledOrStop(),this.Pr=this.gr.bind(this),de(k,"visibilitychange",this.Pr),this.er=!0)}mr(){var i;_&&k&&(this.wr&&_.removeEventListener("beforeunload",this.wr),this.Er&&k.removeEventListener("click",this.Er,{capture:!0}),this.Sr&&k.removeEventListener("mousemove",this.Sr,{capture:!0}),this.Pr&&k.removeEventListener("visibilitychange",this.Pr),clearTimeout(this.Tr),(i=this.kr)==null||i.stop(),this.er=!1)}Rr(i,e){var t=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var u=o;u&&dn(u)&&!$t(u,"body");){if(u===l)return!1;if(U(a,_?.getComputedStyle(u).position))return!0;u=qh(u)}return!1})(Od(i),["fixed","sticky"],r);return{x:i.clientX+(n?0:s),y:i.clientY+(n?0:t),target_fixed:n,type:e}}yr(i,e){var t;if(e===void 0&&(e="click"),!Id(i.target)&&Md(i)){var s=this.Rr(i,e);(t=this.rageclicks)!=null&&t.isRageClick(i.clientX,i.clientY,new Date().getTime())&&this.Ir(b({},s,{type:"rageclick"})),this.Ir(s)}}$r(i){!Id(i.target)&&Md(i)&&(clearTimeout(this.Tr),this.Tr=setTimeout((()=>{this.Ir(this.Rr(i,"mousemove"))}),500))}Ir(i){if(_){var e=_.location.href,t=this.instance.config.mask_personal_data_properties,s=this.instance.config.custom_personal_data_properties,r=t?Li([],$i,s||[]):[],n=Cs(e,r,Ps);this.C=this.C||{},this.C[n]||(this.C[n]=[]),this.C[n].push(i)}}Ft(){this.C&&!Ri(this.C)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Wr,webVitalsAutocapture:class{constructor(i){var e;this.cr=!1,this.er=!1,this.C={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Cr=()=>{clearTimeout(this.Or),this.C.metrics.length!==0&&(this._instance.capture("$web_vitals",this.C.metrics.reduce(((t,s)=>b({},t,{["$web_vitals_"+s.name+"_event"]:b({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{})),this.C={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Fr=t=>{var s,r=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(S(r))Pt.error("Could not read session ID. Dropping metrics!");else{this.C=this.C||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Mr();S(n)||(B(t?.name)||B(t?.value)?Pt.error("Invalid metric received",t):this.Ar&&t.value>=this.Ar?Pt.error("Ignoring metric with value >= "+this.Ar,t):(this.C.url!==n&&(this.Cr(),this.Or=setTimeout(this.Cr,this.flushToCaptureTimeoutMs)),S(this.C.url)&&(this.C.url=n),this.C.firstMetricTimestamp=S(this.C.firstMetricTimestamp)?Date.now():this.C.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0),this.C.metrics.push(b({},t,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.C.metrics.length===this.allowedMetrics.length&&this.Cr()))}},this.Dr=()=>{if(!this.er){var t,s,r,n,o=O.__PosthogExtensions__;S(o)||S(o.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:s,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),t&&s&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.Fr.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.Fr.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Fr.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.Fr.bind(this)),this.er=!0):Pt.error("web vitals callbacks not loaded - not starting")}},this._instance=i,this.cr=!((e=this._instance.persistence)==null||!e.props[dd]),this.startIfEnabled()}get allowedMetrics(){var i,e,t=ge(this._instance.config.capture_performance)?(i=this._instance.config.capture_performance)==null?void 0:i.web_vitals_allowed_metrics:void 0;return B(t)?((e=this._instance.persistence)==null?void 0:e.props[gd])||["CLS","FCP","INP","LCP"]:t}get flushToCaptureTimeoutMs(){return(ge(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var i=ge(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return i!=null&&i}get Ar(){var i=ge(this._instance.config.capture_performance)&&at(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Ld;return 0<i&&i<=6e4?Ld:i}get isEnabled(){var i=ye?.protocol;if(i!=="http:"&&i!=="https:")return Pt.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=ge(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(e)?e:this.cr}startIfEnabled(){this.isEnabled&&!this.er&&(Pt.info("enabled, starting..."),this.G(this.Dr))}onRemoteConfig(i){if("capturePerformance"in i){var e=ge(i.capturePerformance)&&!!i.capturePerformance.web_vitals,t=ge(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[dd]:e}),this._instance.persistence.register({[gd]:t})),this.cr=e,this.startIfEnabled()}}G(i){var e,t;if((e=O.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks)i();else{var s=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,s,(r=>{r?Pt.error("failed to load script",r):i()}))}}Mr(){var i=_?_.location.href:void 0;if(i){var e=this._instance.config.mask_personal_data_properties,t=this._instance.config.custom_personal_data_properties,s=e?Li([],$i,t||[]):[];return Cs(i,s,Ps)}Pt.error("Could not determine current URL")}}},mE={exceptionObserver:class{constructor(i){var e,t,s;this.Dr=()=>{var r;if(_&&this.isEnabled&&(r=O.__PosthogExtensions__)!=null&&r.errorWrappingFunctions){var n=O.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=O.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=O.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.jr&&this.N.capture_unhandled_errors&&(this.jr=n(this.captureException.bind(this))),!this.Lr&&this.N.capture_unhandled_rejections&&(this.Lr=o(this.captureException.bind(this))),!this.Nr&&this.N.capture_console_errors&&(this.Nr=a(this.captureException.bind(this)))}catch(l){hs.error("failed to start",l),this.Ur()}}},this._instance=i,this.zr=!((e=this._instance.persistence)==null||!e.props[cd]),this.Hr=new Zo({refillRate:(t=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&t!==void 0?t:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,h:hs}),this.N=this.Br(),this.startIfEnabledOrStop()}Br(){var i=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return ge(i)?e=b({},e,i):(S(i)?this.zr:i)&&(e=b({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.N.capture_console_errors||this.N.capture_unhandled_errors||this.N.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(hs.info("enabled"),this.Ur(),this.G(this.Dr)):this.Ur()}G(i){var e,t;(e=O.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&i(),(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return hs.error("failed to load script",s);i()}))}Ur(){var i,e,t;(i=this.jr)==null||i.call(this),this.jr=void 0,(e=this.Lr)==null||e.call(this),this.Lr=void 0,(t=this.Nr)==null||t.call(this),this.Nr=void 0}onRemoteConfig(i){if("autocaptureExceptions"in i){var e=i.autocaptureExceptions;this.zr=!!e||!1,this._instance.persistence&&this._instance.persistence.register({[cd]:this.zr}),this.N=this.Br(),this.startIfEnabledOrStop()}}onConfigChange(){this.N=this.Br()}captureException(i){var e,t,s,r=(e=i==null||(t=i.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.Hr.consumeRateLimit(r)?hs.info("Skipping exception capture because of client rate limiting.",{exception:r}):(s=this._instance.exceptions)==null||s.sendExceptionEvent(i)}},exceptions:class{constructor(i){var e,t;this.qr=[],this.Vr=new sa([new na,new ha,new aa,new oa,new ua,new ca,new la,new da],rb()),this._instance=i,this.qr=(e=(t=this._instance.persistence)==null?void 0:t.get_property(fa))!==null&&e!==void 0?e:[]}onRemoteConfig(i){var e,t,s;if("errorTracking"in i){var r=(e=(t=i.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],n=(s=i.errorTracking)==null?void 0:s.captureExtensionExceptions;this.qr=r,this._instance.persistence&&this._instance.persistence.register({[fa]:this.qr,[ud]:n})}}get Wr(){var i,e=!!this._instance.get_property(ud),t=this._instance.config.error_tracking.captureExtensionExceptions;return(i=t??e)!==null&&i!==void 0&&i}buildProperties(i,e){return this.Vr.buildFromUnknown(i,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}sendExceptionEvent(i){var e=i.$exception_list;if(this.Gr(e)){if(this.Yr(e))return void Wo.info("Skipping exception capture because a suppression rule matched");if(!this.Wr&&this.Jr(e))return void Wo.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Kr(e))return void Wo.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Di:!0})}Yr(i){if(i.length===0)return!1;var e=i.reduce(((t,s)=>{var{type:r,value:n}=s;return he(r)&&r.length>0&&t.$exception_types.push(r),he(n)&&n.length>0&&t.$exception_values.push(n),t}),{$exception_types:[],$exception_values:[]});return this.qr.some((t=>{var s=t.values.map((r=>{var n,o=Fh[r.operator],a=q(r.value)?r.value:[r.value],l=(n=e[r.key])!==null&&n!==void 0?n:[];return a.length>0&&o(a,l)}));return t.type==="OR"?s.some(Boolean):s.every(Boolean)}))}Jr(i){return i.flatMap((e=>{var t,s;return(t=(s=e.stacktrace)==null?void 0:s.frames)!==null&&t!==void 0?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}Kr(i){if(i.length>0){var e,t,s,r,n=(e=(t=i[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(s=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}Gr(i){return!B(i)&&q(i)}}},yE=b({productTours:class{constructor(i){this.Xr=null,this.Qr=null,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){"productTours"in i&&(this._instance.persistence&&this._instance.persistence.register({[hd]:!!i.productTours}),this.loadIfEnabled())}loadIfEnabled(){var i,e;this.Xr||(i=this._instance).config.disable_product_tours||(e=i.persistence)==null||!e.get_property(hd)||this.G((()=>this.Zr()))}G(i){var e,t;(e=O.__PosthogExtensions__)!=null&&e.generateProductTours?i():(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(s=>{s?Ud.error("Could not load product tours script",s):i()}))}Zr(){var i;!this.Xr&&(i=O.__PosthogExtensions__)!=null&&i.generateProductTours&&(this.Xr=O.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(i,e){if(e===void 0&&(e=!1),!q(this.Qr)||e){var t=this._instance.persistence;if(t){var s=t.props[zo];if(q(s)&&!e)return this.Qr=s,void i(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:r=>{var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return Ud.error(o),void i([],{isLoaded:!1,error:o})}var a=q(r.json.product_tours)?r.json.product_tours:[];this.Qr=a,t&&t.register({[zo]:a}),i(a,{isLoaded:!0})}})}else i(this.Qr,{isLoaded:!0})}getActiveProductTours(i){B(this.Xr)?i([],{isLoaded:!1,error:"Product tours not loaded"}):this.Xr.getActiveProductTours(i)}showProductTour(i){var e;(e=this.Xr)==null||e.showTourById(i)}previewTour(i){this.Xr?this.Xr.previewTour(i):this.G((()=>{var e;this.Zr(),(e=this.Xr)==null||e.previewTour(i)}))}dismissProductTour(){var i;(i=this.Xr)==null||i.dismissTour("user_clicked_skip")}nextStep(){var i;(i=this.Xr)==null||i.nextStep()}previousStep(){var i;(i=this.Xr)==null||i.previousStep()}clearCache(){var i;this.Qr=null,(i=this._instance.persistence)==null||i.unregister(zo)}resetTour(i){var e;(e=this.Xr)==null||e.resetTour(i)}resetAllTours(){var i;(i=this.Xr)==null||i.resetAllTours()}cancelPendingTour(i){var e;(e=this.Xr)==null||e.cancelPendingTour(i)}}},hn),bE={siteApps:class{constructor(i){this._instance=i,this.ts=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}es(i,e){if(e){var t=this.globalsForEvent(e);this.ts.push(t),this.ts.length>1e3&&(this.ts=this.ts.slice(10))}}get siteAppLoaders(){var i;return(i=O._POSTHOG_REMOTE_CONFIG)==null||(i=i[this._instance.config.token])==null?void 0:i.siteApps}initialize(){if(this.isEnabled){var i=this._instance._addCaptureHook(this.es.bind(this));this.rs=()=>{i(),this.ts=[],this.rs=void 0}}}globalsForEvent(i){var e,t,s,r,n,o,a;if(!i)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var[h,g]of Object.entries(c))l[h]={id:u[h],type:h,properties:g};var{$set_once:f,$set:v}=i;return{event:b({},Kd(i,rE),{properties:b({},i.properties,v?{$set:b({},(e=(t=i.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},v)}:{},f?{$set_once:b({},(s=(r=i.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},f)}:{}),elements_chain:(n=(o=i.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=i.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(i){var e=this.apps[i.id],t=()=>{var o;!e.errored&&this.ts.length&&(Nt.info("Processing "+this.ts.length+" events for site app with id "+i.id),this.ts.forEach((a=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every((a=>a.processedBuffer||a.errored))&&((o=this.rs)==null||o.call(this))},s=!1,r=o=>{e.errored=!o,e.loaded=!0,Nt.info("Site app with id "+i.id+" "+(o?"loaded":"errored")),s&&t()};try{var{processEvent:n}=i.init({posthog:this._instance,callback:o=>{r(o)}});n&&(e.processEvent=n),s=!0}catch(o){Nt.error("Error while initializing PostHog app with config id "+i.id,o),r(!1)}if(s&&e.loaded)try{t()}catch(o){Nt.error("Error while processing buffered events PostHog app with config id "+i.id,o),e.errored=!0}}ss(){var i=this.siteAppLoaders||[];for(var e of i)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of i)this.setupSiteApp(t)}ns(i){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(i);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(s){Nt.error("Error while processing event "+i.event+" for site app "+t.id,s)}}}onRemoteConfig(i){var e,t,s,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.ss(),void this._instance.on("eventCaptured",(l=>this.ns(l)))):void Nt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.rs)==null||t.call(this),(s=i.siteApps)!=null&&s.length)if(this.isEnabled){var n=function(l){var u;O["__$$ph_site_app_"+l]=r._instance,(u=O.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(r._instance,a,(c=>{if(c)return Nt.error("Error while initializing PostHog app with config id "+l,c)}))};for(var{id:o,url:a}of i.siteApps)n(o)}else Nt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},EE={tracingHeaders:class{constructor(i){this.os=void 0,this.ls=void 0,this.Dr=()=>{var e,t;S(this.os)&&((e=O.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),S(this.ls)&&((t=O.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=i}initialize(){this.startIfEnabledOrStop()}G(i){var e,t;(e=O.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&i(),(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return iE.error("failed to load script",s);i()}))}startIfEnabledOrStop(){var i,e;this._instance.config.__add_tracing_headers?this.G(this.Dr):((i=this.os)==null||i.call(this),(e=this.ls)==null||e.call(this),this.os=void 0,this.ls=void 0)}}},kE=b({surveys:class{constructor(i){this.us=void 0,this._surveyManager=null,this.hs=!1,this.ds=[],this.vs=null,this._instance=i,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this._instance.config.disable_surveys){var e=i.surveys;if(B(e))return J.warn("Flags not loaded yet. Not loading surveys.");var t=q(e);this.us=t?e.length>0:e,J.info("flags response received, isSurveysEnabled: "+this.us),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var t=localStorage.key(e);(t!=null&&t.startsWith(Uh)||t!=null&&t.startsWith("inProgressSurvey_"))&&i.push(t)}i.forEach((s=>localStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.hs)J.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)J.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())J.info("Not loading surveys in cookieless mode without consent.");else{var i=O?.__PosthogExtensions__;if(i){if(!S(this.us)||this._instance.config.advanced_enable_surveys){var e=this.us||this._instance.config.advanced_enable_surveys;this.hs=!0;try{var t=i.generateSurveys;if(t)return void this.cs(t,e);var s=i.loadExternalDependency;if(!s)return void this.fs("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",(r=>{r||!i.generateSurveys?this.fs("Could not load surveys script",r):this.cs(i.generateSurveys,e)}))}catch(r){throw this.fs("Error initializing surveys",r),r}finally{this.hs=!1}}}else J.error("PostHog Extensions not found.")}}cs(i,e){this._surveyManager=i(this._instance,e),this._surveyEventReceiver=new qa(this._instance),J.info("Surveys loaded successfully"),this.ps({isLoaded:!0})}fs(i,e){J.error(i,e),this.ps({isLoaded:!1,error:i})}onSurveysLoaded(i){return this.ds.push(i),this._surveyManager&&this.ps({isLoaded:!0}),()=>{this.ds=this.ds.filter((e=>e!==i))}}getSurveys(i,e){if(e===void 0&&(e=!1),this._instance.config.disable_surveys)return J.info("Disabled. Not loading surveys."),i([]);var t,s=this._instance.get_property(va);if(s&&!e)return i(s,{isLoaded:!0});typeof Promise<"u"&&this.vs?this.vs.then((r=>{var{surveys:n,context:o}=r;return i(n,o)})):(typeof Promise<"u"&&(this.vs=new Promise((r=>{t=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 n;this.vs=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;J.error(a);var l={isLoaded:!1,error:a};return i([],l),void(t==null||t({surveys:[],context:l}))}var u,c=r.json.surveys||[],h=c.filter((f=>(function(v){return!(!v.start_date||v.end_date)})(f)&&((function(v){var p;return!((p=v.conditions)==null||(p=p.events)==null||(p=p.values)==null||!p.length)})(f)||(function(v){var p;return!((p=v.conditions)==null||(p=p.actions)==null||(p=p.values)==null||!p.length)})(f))));h.length>0&&((u=this._surveyEventReceiver)==null||u.register(h)),(n=this._instance.persistence)==null||n.register({[va]:c});var g={isLoaded:!0};i(c,g),t?.({surveys:c,context:g})}}))}ps(i){for(var e of this.ds)try{if(!i.isLoaded)return e([],i);this.getSurveys(e)}catch(t){J.error("Error in survey callback",t)}}getActiveMatchingSurveys(i,e){if(e===void 0&&(e=!1),!B(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(i,e);J.warn("init was not called")}_s(i){var e=null;return this.getSurveys((t=>{var s;e=(s=t.find((r=>r.id===i)))!==null&&s!==void 0?s:null})),e}gs(i){if(B(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var e=typeof i=="string"?this._s(i):i;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(i){if(B(this._surveyManager))return J.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var e=this.gs(i);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(i,e){return B(this._surveyManager)?(J.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((t=>{this.getSurveys((s=>{var r,n=(r=s.find((a=>a.id===i)))!==null&&r!==void 0?r:null;if(n){var o=this.gs(n);t({visible:o.eligible,disabledReason:o.reason})}else t({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(i,e,t){var s;if(B(this._surveyManager))J.warn("init was not called");else{var r=typeof i=="string"?this._s(i):i;if(r!=null&&r.id)if(Bb.includes(r.type)){var n=k?.querySelector(e);if(n)return(s=r.appearance)!=null&&s.surveyPopupDelaySeconds?(J.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;J.info("Rendering survey "+r.id+" with delay of "+((o=r.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(r,n,t),J.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,t);J.warn("Survey element not found")}else J.warn("Surveys of type "+r.type+" cannot be rendered in the app");else J.warn("Survey not found")}}displaySurvey(i,e){var t;if(B(this._surveyManager))J.warn("init was not called");else{var s=this._s(i);if(s){var r=s;if((t=s.appearance)!=null&&t.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=b({},s,{appearance:b({},s.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Ia.Popover&&e.initialResponses&&J.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(s);if(!n.visible)return void J.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==Ia.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else J.warn("Survey not found")}}cancelPendingSurvey(i){B(this._surveyManager)?J.warn("init was not called"):this._surveyManager.cancelSurvey(i)}handlePageUnload(){var i;(i=this._surveyManager)==null||i.handlePageUnload()}}},hn),SE={toolbar:class{constructor(i){this.instance=i}bs(i){O.ph_toolbar_state=i}ys(){var i;return(i=O.ph_toolbar_state)!==null&&i!==void 0?i:Dt.UNINITIALIZED}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i,e,t){if(i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),_h(this.instance.config)||!_||!k)return!1;i=i??_.location,t=t??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var s,r=nE||Qr(i.hash,"__posthog")||Qr(i.hash,"state"),n=r?ad((()=>JSON.parse(atob(decodeURIComponent(r)))))||ad((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?i.hash=n.desiredHash:t?t.replaceState(t.state,"",i.pathname+i.search):i.hash="")):((s=JSON.parse(e.getItem(Bd)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch{return!1}}ws(i){var e=O.ph_load_toolbar||O.ph_load_editor;!B(e)&&bt(e)?e(i,this.instance):Vd.warn("No toolbar load function found")}loadToolbar(i){var e=!(k==null||!k.getElementById(Eh));if(!_||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=b({token:this.instance.config.token},i,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(_.localStorage.setItem(Bd,JSON.stringify(b({},s,{source:void 0}))),this.ys()===Dt.LOADED)this.ws(s);else if(this.ys()===Dt.UNINITIALIZED){var r;this.bs(Dt.LOADING),(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return Vd.error("[Toolbar] Failed to load",n),void this.bs(Dt.UNINITIALIZED);this.bs(Dt.LOADED),this.ws(s)})),de(_,"turbolinks:load",(()=>{this.bs(Dt.UNINITIALIZED),this.loadToolbar(s)}))}return!0}Es(i){return this.loadToolbar(i)}maybeLoadEditor(i,e,t){return i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(i,e,t)}}},wE=b({experiments:za},hn),AE={conversations:class{constructor(i){this.xs=void 0,this._conversationsManager=null,this.Ss=!1,this.$s=null,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this._instance.config.disable_conversations){var e=i.conversations;B(e)||(kt(e)?this.xs=e:(this.xs=e.enabled,this.$s=e),this.loadIfEnabled())}}reset(){var i;(i=this._conversationsManager)==null||i.reset(),this._conversationsManager=null,this.xs=void 0,this.$s=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ss||this._instance.config.disable_conversations||_h(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var i=O?.__PosthogExtensions__;if(i&&!S(this.xs)&&this.xs)if(this.$s&&this.$s.token){this.Ss=!0;try{var e=i.initConversations;if(e)return this.ks(e),void(this.Ss=!1);var t=i.loadExternalDependency;if(!t)return void this.Ps("PostHog loadExternalDependency extension not found.");t(this._instance,"conversations",(s=>{s||!i.initConversations?this.Ps("Could not load conversations script",s):this.ks(i.initConversations),this.Ss=!1}))}catch(s){this.Ps("Error initializing conversations",s),this.Ss=!1}}else Ke.error("Conversations enabled but missing token in remote config.")}}ks(i){if(this.$s)try{this._conversationsManager=i(this.$s,this._instance),Ke.info("Conversations loaded successfully")}catch(e){this.Ps("Error completing conversations initialization",e)}else Ke.error("Cannot complete initialization: remote config is null")}Ps(i,e){Ke.error(i,e),this._conversationsManager=null,this.Ss=!1}show(){this._conversationsManager?this._conversationsManager.show():Ke.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.xs===!0&&!Qe(this._conversationsManager)}isVisible(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&i!==void 0&&i}sendMessage(i,e,t){var s=this;return _t((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(i,e,t):(Ke.warn("Conversations not available yet."),null)}))()}getMessages(i,e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.getMessages(i,e):(Ke.warn("Conversations not available yet."),null)}))()}markAsRead(i){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(i):(Ke.warn("Conversations not available yet."),null)}))()}getTickets(i){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.getTickets(i):(Ke.warn("Conversations not available yet."),null)}))()}requestRestoreLink(i){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(i):(Ke.warn("Conversations not available yet."),null)}))()}restoreFromToken(i){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(i):(Ke.warn("Conversations not available yet."),null)}))()}restoreFromUrlToken(){var i=this;return _t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromUrlToken():(Ke.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&i!==void 0?i:null}getWidgetSessionId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&i!==void 0?i:null}}},TE={logs:class{constructor(i){var e;this.Ts=!1,this.Rs=!1,this._instance=i,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Ts=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(i){var e,t=(e=i.logs)==null?void 0:e.captureConsoleLogs;!B(t)&&t&&(this.Ts=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Ts&&!this.Rs){var i=le("[logs]"),e=O?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(s=>{var r;s||(r=e.logs)==null||!r.initializeLogs?i.error("Could not load logs script",s):(e.logs.initializeLogs(this._instance),this.Rs=!0)})):i.error("PostHog loadExternalDependency extension not found.")}else i.error("PostHog Extensions not found.")}}}},IE=b({},hn,vE,_E,mE,yE,bE,kE,EE,SE,wE,AE,TE);Mi.__defaultExtensionClasses=b({},IE);St=(qd=Ts[Ii]=new Mi,(function(){function i(){i.done||(i.done=!0,Bh=!1,Z(Ts,(function(e){e._dom_loaded()})))}k!=null&&k.addEventListener?k.readyState==="complete"?i():de(k,"DOMContentLoaded",i,{capture:!1}):_&&w.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),qd)});var Zh={};gn(Zh,{Posthog:()=>rl});var Zt,rl,eg=Re(()=>{"use strict";Qh();Ji();pi();Zt=class Zt{constructor(e,t=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=it("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let t=`ph_${e}_posthog`,s=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==t);if(s.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;s.forEach(a=>{[o,r,""].forEach(u=>{let c=u?`; Domain=${u}`:"";document.cookie=`${a}=; path=/${c}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(u=>u.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:t,config:s={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.cleanupStalePosthogCookies(e);let r=t||jc();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:Gc,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...s.session_recording},before_send:o=>{if(typeof window>"u")return null;let a=window.location.hostname;if(a==="localhost"||a==="127.0.0.1")return o;let l=Hc.some(u=>a.endsWith(`.${u}`)||a===u);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...s};St.init(e,n),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let s=typeof St._isIdentified=="function"?St._isIdentified():this.has_identified;e&&!s?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),St.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),St.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,country_of_residence:s})=>{if(!(!this.has_initialized||!e))try{let r=St.get_property("$stored_person_properties")??{},n={};r.client_id||(n.client_id=e),t&&r.is_internal===void 0&&(n.is_internal=ur(t)),s&&!r.country_of_residence&&(n.country_of_residence=s),Object.keys(n).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:n}),St.setPersonProperties(n)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e,country_of_residence:s})}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}),St.capture(e,t)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.options=e,this.debug=t,this.init()}};Zt.getPosthogInstance=(e,t=!1)=>(Zt._instance||(Zt._instance=new Zt(e,t)),Zt._instance);rl=Zt});var OE={};gn(OE,{Analytics:()=>tg,cacheTrackEvents:()=>vi});co();Ji();pi();var Pm=4320*60*60,qt=class qt{constructor(e,t,s=!1){this.analytics=new hi;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=it("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let t=window.location.hostname,n=["webflow.io"].some(u=>t.endsWith(u))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let u=new Uint8Array(16);crypto.getRandomValues(u),u[6]=u[6]&15|64,u[8]=u[8]&63|128;let c=Array.from(u,h=>h.toString(16).padStart(2,"0")).join("");o=`${c.slice(0,8)}-${c.slice(8,12)}-${c.slice(12,16)}-${c.slice(16,20)}-${c.slice(20)}`}else throw new Error("Crypto API not available for secure random UUID generation");let l=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${this.rudderstack_anonymous_cookie_key}=${o}; path=/; Domain=${n}; max-age=${Pm}; 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:uo});try{this.setCookieIfNotExists(),this.analytics.load(e,uo,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,storage:{type:"localStorage"},lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.log("init | SDK loaded successfully",{userId:this.getUserId(),anonymousId:this.getAnonymousId()}),this.onLoadedCallback?.()}})}catch(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let s=this.getUserId();if(!s||s!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:t}),this.analytics.identify(e,t||{}),this.has_identified=!0}catch(r){console.error("RudderStack: Failed to identify user",r)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,t="Deriv App",s,r)=>{if(!(!this.has_initialized||e===this.current_page))try{let n={...s&&{user_id:s},...r};this.log("pageView | tracking page view",{platform:t,current_page:e,properties:n}),this.analytics.page(t,e,n),this.current_page=e}catch(n){console.error("RudderStack: Failed to track page view",n)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting RudderStack session"),this.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,t)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:t}),this.analytics.track(e,t)}catch(s){console.warn("RudderStack: Failed to track event",s)}};this.onLoadedCallback=t,this.debug=s,this.init(e)}};qt.getRudderStackInstance=(e,t,s=!1)=>(qt._instance||(qt._instance=new qt(e,t,s)),qt._instance);var dr=qt;var hr="cached_analytics_events",gr="cached_analytics_page_views",Jc=(i,e)=>{try{let t=localStorage.getItem(hr),s=t?JSON.parse(t):[];s.push({name:i,properties:e,timestamp:Date.now()}),localStorage.setItem(hr,JSON.stringify(s))}catch(t){console.warn("Analytics: Failed to cache event",t)}},Qc=(i,e)=>{try{let t=localStorage.getItem(gr),s=t?JSON.parse(t):[];s.push({name:i,properties:e,timestamp:Date.now()}),localStorage.setItem(gr,JSON.stringify(s))}catch(t){console.warn("Analytics: Failed to cache page view",t)}},Zc=()=>{try{let i=localStorage.getItem(hr);if(i){let e=JSON.parse(i);return Array.isArray(e)?e:[]}}catch(i){console.warn("Analytics: Failed to get cached events",i)}return[]},eu=()=>{try{let i=localStorage.getItem(gr);if(i){let e=JSON.parse(i);return Array.isArray(e)?e:[]}}catch(i){console.warn("Analytics: Failed to get cached pages",i)}return[]},tu=()=>{try{localStorage.removeItem(hr)}catch(i){console.warn("Analytics: Failed to clear cached events",i)}},iu=()=>{try{localStorage.removeItem(gr)}catch(i){console.warn("Analytics: Failed to clear cached page views",i)}};pi();pi();var go=class{constructor(){this.interval=null;this.responses=[];this.isTrackingResponses=!1;this.delegatedSelectors=new Set;this.debug=!1;this.log=it("[CacheManager]",()=>this.debug);this.addEventhandler=this.addEventHandler.bind(this)}setDebug(e){this.debug=e}hash(e,t=32){let s=a=>{let l=2166136261;for(let u=0;u<a.length;u++)l^=a.charCodeAt(u),l=l*16777619>>>0;return l.toString(16)},r=a=>btoa(a),n=s(e),o=r(n);for(;o.length<t;)o+=r(s(o));return o.substring(0,t)}getCookies(e){let s=`; ${document.cookie}`.split(`; ${e}=`);if(s.length===2){let r=decodeURIComponent(s.pop().split(";").shift());try{return JSON.parse(r)}catch{return r}}return null}trackPageUnload(){typeof window>"u"||window.addEventListener("beforeunload",()=>{this.isPageViewSent()||this.push("cached_analytics_page_views",{name:window.location.origin+window.location.pathname})})}trackResponses(){if(typeof window>"u"||typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(s,r){return this._url=r,this._method=s,e.apply(this,arguments)},XMLHttpRequest.prototype.send=function(s){return this.addEventListener("load",function(){let r=null;if(typeof s=="string")try{r=JSON.parse(s)}catch{r=s}let n={url:this._url,method:this._method,status:this.status,headers:this.getAllResponseHeaders(),data:this.responseText,payload:r};vi.responses.push(n)}),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}parseFromLocalStorage(e){if(typeof localStorage>"u")return null;try{let t=localStorage.getItem(e);return t===null?null:JSON.parse(t)}catch{return null}}isPageViewSent(){return!!this.responses.find(e=>e.payload?.type==="page"&&e.payload?.anonymousId)}set(e){this.log("set | caching event to localStorage",e),this.push("cached_analytics_events",e)}push(e,t){if(typeof localStorage>"u")return;let s=this.parseFromLocalStorage(e),r=Array.isArray(s)?s:[];r.push(t);try{localStorage.setItem(e,JSON.stringify(r))}catch(n){console.warn("AnalyticsCacheManager: Failed to push to localStorage",n)}}processEvent(e){let t=this.getCookies("client_information");if(t){let{email:s=null}=t;s&&(e.properties.email_hash=this.hash(s))}if(e?.properties?.email){let s=e.properties.email;delete e.properties.email,e.properties.email_hash=this.hash(s)}return e}track(e,t=!1){if(typeof window>"u")return;let s=this.processEvent(e),r=this.getAnalyticsInstance();this.isReady()&&!t?(this.log("track | analytics ready \u2014 calling trackEvent",{event:s.name,properties:s.properties}),r.trackEvent(s.name,s.properties)):(this.log("track | analytics not ready or cache=true \u2014 storing event",{event:s.name,cache:t}),this.set(s))}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:s={}},r=!1,n=null){let o=l=>{l.dataset?.clickEventTracking||(l.addEventListener("click",u=>{let c={name:t,properties:s,cache:r};if(typeof n=="function"){let h=n(u);c={...h,cache:h.cache??r}}this.track(c,c.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:s={name:"",properties:{}},cache:r=!1,callback:n=null})=>{if(typeof t=="string"){let o=t;if(!this.delegatedSelectors.has(o)){let a=l=>{let u=l.target;if(!u)return;let c=u.closest(o);if(c&&!c.dataset?.clickEventTracking){let h={name:s.name,properties:s.properties,cache:r};if(typeof n=="function"){let g=n(l);h={...g,cache:g.cache??r}}c.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,s,r,n)})}),this)}loadEvent(e){return this.log("loadEvent | firing load events",e.map(t=>t.event.name)),e.forEach(({event:t})=>{let{name:s,properties:r}=t;this.track({name:s,properties:r})}),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:s=[],excludedPages:r=[],event:n,callback:o=null})=>{let a=!1;if(s.length?s.includes(t)&&(a=!0):r.length&&r.includes(t)||(a=!0),a){let l=o?o():n;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:n.name,pages:s,excludedPages:r})}),this}clearInterval(){this.interval&&(clearInterval(this.interval),this.interval=null)}cleanup(){this.clearInterval(),this.responses=[],this.isTrackingResponses=!1}},vi=new go;typeof window<"u"&&(window.cacheTrackEvents=vi);function RE(i){let e=i?.debug??!1,t=it("",()=>e),s,r,n,o={},a={},l=[],u=[],c=!1,h=()=>{if(!c&&r?.has_initialized){c=!0;try{let A=Zc();A.length>0&&(t(`processStorageCache | replaying ${A.length} cached event(s)`,A),A.forEach(L=>{let N=Ht(L.properties);r?.track(L.name,N)}),tu());let P=eu();P.length>0&&(t(`processStorageCache | replaying ${P.length} cached page view(s)`,P),P.forEach(L=>{r?.pageView(L.name,"Deriv App",R(),L.properties)}),iu())}catch(A){console.warn("Analytics: Failed to process storage cache",A)}}},g=()=>{t("onSdkLoaded | RudderStack SDK loaded"),h(),u.length>0&&t(`onSdkLoaded | flushing ${u.length} pending identify call(s)`),u.forEach(({userId:A,traits:P})=>{A&&r?.identifyEvent(A,P)}),u=[]},f=async({growthbookKey:A,growthbookDecryptionKey:P,rudderstackKey:L,growthbookOptions:N,posthogOptions:fe,debug:H})=>{var z,Q;H!==void 0&&(e=H),vi.setDebug(e),t("initialise | starting analytics initialization",{rudderstack:!!L,growthbook:!!A,posthog:!!fe});try{let V=N?.attributes?.country||(A?await Wc():void 0);if(L&&(t("initialise | initializing RudderStack"),r=dr.getRudderStackInstance(L,g,e)),N?.attributes&&Object.keys(N.attributes).length>0){let C=N.attributes,Ie=r?.getAnonymousId();o={...o,country:V,...C.user_language&&{user_language:C.user_language},...C.account_type&&{account_type:C.account_type},...C.app_id&&{app_id:C.app_id},...C.residence_country&&{residence_country:C.residence_country},...C.device_type&&{device_type:C.device_type},...C.url&&{url:C.url},...C.email_hash&&{email_hash:C.email_hash},...C.network_type&&{network_type:C.network_type},...C.network_rtt&&{network_rtt:C.network_rtt},...C.network_downlink&&{network_downlink:C.network_downlink},...C.account_currency&&{account_currency:C.account_currency},...C.account_mode&&{account_mode:C.account_mode},loggedIn:!!C.loggedIn,...C.user_id&&!Qi(C.user_id)&&{user_id:C.user_id},...Ie&&{anonymous_id:Ie}}}N??(N={}),N.attributes??(N.attributes={});let se=r?.getAnonymousId();if((z=N.attributes).id??(z.id=se),(Q=N.attributes).country??(Q.country=V),A){t("initialise | initializing GrowthBook");let{Growthbook:C}=await Promise.resolve().then(()=>(Wu(),Ku));s=C.getGrowthBookInstance(A,P,N,e),t("initialise | GrowthBook initialized");let Ie=setInterval(()=>{Object.keys(a).length>0?clearInterval(Ie):a=m("tracking-buttons-config",{})},1e3)}if(fe){t("initialise | initializing PostHog");let{Posthog:C}=await Promise.resolve().then(()=>(eg(),Zh));n=C.getPosthogInstance(fe,e),t("initialise | PostHog initialized")}t("initialise | analytics initialization complete")}catch(V){console.warn("Analytics: Failed to initialize",V)}},v=({country:A,user_language:P,device_language:L,device_type:N,account_type:fe,user_id:H,anonymous_id:z,app_id:Q,utm_source:V,utm_medium:se,utm_campaign:C,is_authorised:Ie,residence_country:$e,url:ei,domain:Ls,geo_location:Ui,loggedIn:Fe,network_downlink:Bi,network_rtt:ti,network_type:Ft,account_currency:ii,account_mode:si})=>{let ri=H??R();if(t("setAttributes | received attributes",{country:A,user_language:P,device_language:L,device_type:N,account_type:fe,user_id:H,anonymous_id:z,app_id:Q,utm_source:V,utm_medium:se,utm_campaign:C,is_authorised:Ie,residence_country:$e,url:ei,domain:Ls,geo_location:Ui,loggedIn:Fe,network_downlink:Bi,network_rtt:ti,network_type:Ft,account_currency:ii,account_mode:si}),s){let wt={country:A,residence_country:$e,user_language:P,device_language:L,device_type:N,utm_source:V,utm_medium:se,utm_campaign:C,is_authorised:Ie,url:ei,domain:Ls,loggedIn:Fe,...H&&!Qi(H)&&{user_id:H},anonymous_id:z};ri&&(wt.id=ri,wt.user_id=ri),t("setAttributes | called GrowthBook setAttributes",wt),s.setAttributes(wt)}o={...o,...A!==void 0&&{country:A},...Ui!==void 0&&{geo_location:Ui},...P!==void 0&&{user_language:P},...fe!==void 0&&{account_type:fe},...Q!==void 0&&{app_id:Q},...$e!==void 0&&{residence_country:$e},...N!==void 0&&{device_type:N},...ei!==void 0&&{url:ei},...Fe!==void 0&&{loggedIn:Fe},...Bi!==void 0&&{network_downlink:Bi},...ti!==void 0&&{network_rtt:ti},...Ft!==void 0&&{network_type:Ft},...H!==void 0&&!Qi(H)&&{user_id:H},...z!==void 0&&{anonymous_id:z},...ii!==void 0&&{account_currency:ii},...si!==void 0&&{account_mode:si}},t("setAttributes | updated core_data",o)},p=A=>s?.getFeatureState(A)?.experimentResult?.name,m=(A,P)=>s?.getFeatureValue(A,P),E=async()=>await s?.getStatus(),T=A=>s?.isOn(A),x=A=>s?.setUrl(A),R=()=>{let A=r?.getUserId()||"";return A&&!Qi(A)?A:""},M=()=>r?.getAnonymousId()||"",F=(A,P="Deriv App",L)=>{let N=R();t("pageView | called",{current_page:A,platform:P,properties:L,userId:N}),r&&(r.has_initialized?(t("pageView | sending page view to RudderStack",{current_page:A,platform:P}),r.pageView(A,P,N,L)):(t("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:A}),Qc(A,{platform:P,...L})))},W=(A,P)=>{let L=A||R();if(!L){t("identifyEvent | skipped \u2014 no user_id available");return}t("identifyEvent | called",{user_id:L,traits:P});let N=Q=>{if(!Q)return Q;let{email:V,...se}=Q;return{...se,...V&&{is_internal:ur(V)}}},fe=P?.rudderstack!==void 0||P?.posthog!==void 0,H,z;if(fe){let{rudderstack:Q,posthog:V,...se}=P;H=N({...se,...Q}),z=N({...se,...V})}else H=N(P),z=N(P);r&&(r.has_initialized?(t("identifyEvent | calling RudderStack identify",{user_id:L,traits:H}),r.identifyEvent(L,H)):u.some(Q=>Q.userId===L)||(t("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:L}),u.push({userId:L,traits:H}))),n?.has_initialized&&z&&(t("identifyEvent | calling PostHog identify",{user_id:L,traits:z}),n.identifyEvent(L,z))},$=()=>{t("reset | resetting all providers"),r?.has_initialized&&(t("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(t("reset | resetting PostHog"),n.reset())},ve=A=>"event_metadata"in A||"cta_information"in A||"error"in A,je={initialise:f,setAttributes:v,identifyEvent:W,backfillPersonProperties:({user_id:A,email:P,country_of_residence:L})=>{t("backfillPersonProperties | called",{user_id:A}),n?.has_initialized?(t("backfillPersonProperties | backfilling person properties in PostHog",{user_id:A}),n.backfillPersonProperties({user_id:A,email:P,country_of_residence:L})):t("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:p,getFeatureValue:m,getGrowthbookStatus:E,isFeatureOn:T,setUrl:x,getId:R,getAnonymousId:M,trackEvent:(A,P)=>{let L=R(),N={};if(t("trackEvent | called",{event:A,analytics_data:P,userId:L,core_data:o}),ve(P)){let z=P;N={...z,event_metadata:{...o,...L&&!o.user_id&&{user_id:L},...z.event_metadata}},t("trackEvent | built V2 payload",{event:A,final_payload:N})}else N={...o,...P,...L&&!o.user_id&&{user_id:L}},t("trackEvent | built V1 payload",{event:A,final_payload:N});if(!(!(A in a)||a[A])){t("trackEvent | skipped \u2014 event disabled by tracking_config",{event:A});return}let H=r?.has_initialized;if(!navigator.onLine||!H)H?(t("trackEvent | offline \u2014 caching event to memory",{event:A}),l.push({event:A,payload:N})):(t("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:A}),Jc(A,N));else{l.length>0&&(t(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(Q=>{let V=Ht(Q.payload);r?.track(Q.event,V)}),l=[]);let z=Ht(N);t("trackEvent | sending event to RudderStack",{event:A,payload:z}),r?.track(A,z)}if(n?.has_initialized){let z=["page_name","user_language","form_name","version","email_hash"],Q=Yc(N),V=Ht(Object.fromEntries(Object.entries(Q).filter(([se])=>!z.includes(se))));t("trackEvent | sending event to PostHog",{event:A,payload:V}),n.capture(A,V)}},getInstances:()=>({ab:s,tracking:r,posthog:n}),pageView:F,reset:$};return typeof window<"u"&&(window.AnalyticsInstance=je),je}var tg=RE();return ag(OE);})();
18
18
  /*! Bundled license information:
19
19
 
20
20
  js-cookie/dist/js.cookie.mjs: