@deriv-com/analytics 1.39.2 → 1.39.3

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.
@@ -14,7 +14,7 @@ ${Hi}`;break}}}globalThis.dispatchEvent(new ErrorEvent("error",{error:s,bubbles:
14
14
  `).map(n=>n.split("=",2))).loc?.toLowerCase()||s||"":s||""}catch{return s||""}})(),dn},qt=s=>{if(s==null||typeof s!="object")return s;if(Array.isArray(s)){let i=[];for(let n=0;n<s.length;n++){let r=qt(s[n]);r!=null&&i.push(r)}return i.length?i:void 0}let e={},t=!1;for(let i in s){if(!Object.prototype.hasOwnProperty.call(s,i))continue;let n=qt(s[i]);n==null||n===""||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0||Array.isArray(n)&&n.length===0||(e[i]=n,t=!0)}return t?e:void 0},Zc=(s,e)=>{for(let t in s){if(!Object.prototype.hasOwnProperty.call(s,t))continue;let i=s[t];i&&typeof i=="object"&&!Array.isArray(i)?Zc(i,e):e[t]=i}},eu=s=>{if(s==null||typeof s!="object"||Array.isArray(s))return s;let e={};return Zc(s,e),e}});function cu(){return lu}function po(s){let e=2166136261,t=s.length;for(let i=0;i<t;i++)e^=s.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function ei(s,e,t){return t===2?po(po(s+e)+"")%1e4/1e4:t===1?po(e+s)%1e3/1e3:null}function Lm(s){return s<=0?[]:new Array(s).fill(1/s)}function vn(s,e){return s>=e[0]&&s<e[1]}function uu(s,e){let t=ei("__"+e[0],s,1);return t===null?!1:t>=e[1]&&t<e[2]}function du(s,e){for(let t=0;t<e.length;t++)if(vn(s,e[t]))return t;return-1}function _o(s){try{let e=s.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function _n(s,e){if(!e.length)return!1;let t=!1,i=!1;for(let n=0;n<e.length;n++){let r=Fm(s,e[n].type,e[n].pattern);if(e[n].include===!1){if(r)return!1}else t=!0,r&&(i=!0)}return i||!t}function $m(s,e,t){try{let i=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(i="\\/?"+i.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+i+"$","i").test(s)}catch{return!1}}function Mm(s,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),i=[[s.host,t.host,!1],[s.pathname,t.pathname,!0]];return t.hash&&i.push([s.hash,t.hash,!1]),t.searchParams.forEach((n,r)=>{i.push([s.searchParams.get(r)||"",n,!1])}),!i.some(n=>!$m(n[0],n[1],n[2]))}catch{return!1}}function Fm(s,e,t){try{let i=new URL(s,"https://_");if(e==="regex"){let n=_o(t);return n?n.test(i.href)||n.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return Mm(i,t);return!1}catch{return!1}}function hu(s,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=Lm(s);t=t||i,t.length!==s&&(t=i);let n=t.reduce((o,a)=>a+o,0);(n<.99||n>1.01)&&(t=i);let r=0;return t.map(o=>{let a=r;return r+=o,[a,a+e*o]})}function fu(s,e,t){if(!e)return null;let i=e.split("?")[1];if(!i)return null;let n=i.replace(/#.*/,"").split("&").map(r=>r.split("=",2)).filter(([r])=>r===s).map(([,r])=>parseInt(r));return n.length>0&&n[0]>=0&&n[0]<t?n[0]:null}function gu(s){try{return s()}catch(e){return console.error(e),!1}}async function Kt(s,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||lu.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let i=await t.importKey("raw",vo(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[n,r]=s.split("."),o=await t.decrypt({name:"AES-CBC",iv:vo(n)},i,vo(r));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function ti(s){return typeof s=="string"?s:JSON.stringify(s)}function Be(s){typeof s=="number"&&(s=s+""),(!s||typeof s!="string")&&(s="0");let e=s.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}function pu(){let s;try{s="1.6.5"}catch{s=""}return s}function vu(s,e){let t,i;try{t=new URL(s),i=new URL(e)}catch(n){return console.error(`Unable to merge query strings: ${n}`),e}return t.searchParams.forEach((n,r)=>{i.searchParams.has(r)||i.searchParams.set(r,n)}),i.toString()}function au(s){return typeof s=="object"&&s!==null}function mn(s){return s.urlPatterns&&s.variations.some(e=>au(e)&&"urlRedirect"in e)?"redirect":s.variations.some(e=>au(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function yn(s,e){return new Promise(t=>{let i=!1,n,r=o=>{i||(i=!0,n&&clearTimeout(n),t(o||null))};e&&(n=setTimeout(()=>r(),e)),s.then(o=>r(o)).catch(()=>r())})}var lu,vo,si=Re(()=>{"use strict";lu={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};vo=s=>Uint8Array.from(atob(s),e=>e.charCodeAt(0))});function yu(s){Object.assign(Se,s),Se.backgroundSync||So()}async function bu({instance:s,timeout:e,skipCache:t,allowStale:i,backgroundSync:n}){return n||(Se.backgroundSync=!1),Gm({instance:s,allowStale:i,timeout:e,skipCache:t})}function Um(s){let e=ii(s),t=ys.get(e)||new Set;t.add(s),ys.set(e,t)}function Eu(s){ys.forEach(e=>e.delete(s))}function Bm(){bs.forEach(s=>{s&&(s.state="idle",Eo(s))})}function Vm(){bs.forEach(s=>{s&&s.state==="idle"&&ko(s)})}async function mu(){try{if(!nt.localStorage)return;await nt.localStorage.setItem(Se.cacheKey,JSON.stringify(Array.from(gt.entries())))}catch{}}async function Gm({instance:s,allowStale:e,timeout:t,skipCache:i}){let n=ii(s),r=yo(s),o=new Date,a=new Date(o.getTime()-Se.maxAge+Se.staleTTL);await jm();let l=!Se.disableCache&&!i?gt.get(r):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&Es.add(n),l.staleAt<o?mo(s):bo(s),{data:l.data,success:!0,source:"cache"}):await yn(mo(s),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function ii(s){let[e,t]=s.getApiInfo();return`${e}||${t}`}function yo(s){let e=ii(s);if(!("isRemoteEval"in s)||!s.isRemoteEval())return e;let t=s.getAttributes(),i=s.getCacheKeyAttributes()||Object.keys(s.getAttributes()),n={};i.forEach(a=>{n[a]=t[a]});let r=s.getForcedVariations(),o=s.getUrl();return`${e}||${JSON.stringify({ca:n,fv:r,url:o})}`}async function jm(){if(!_u){_u=!0;try{if(nt.localStorage){let s=await nt.localStorage.getItem(Se.cacheKey);if(!Se.disableCache&&s){let e=JSON.parse(s);e&&Array.isArray(e)&&e.forEach(([t,i])=>{gt.set(t,{...i,staleAt:new Date(i.staleAt)})}),ku()}}}catch{}if(!Se.disableIdleStreams){let s=ms.startIdleListener();s&&(ms.stopIdleListener=s)}}}function ku(){let s=Array.from(gt.entries()).map(([t,i])=>({key:t,staleAt:i.staleAt.getTime()})).sort((t,i)=>t.staleAt-i.staleAt),e=Math.min(Math.max(0,gt.size-Se.maxEntries),gt.size);for(let t=0;t<e;t++)gt.delete(s[t].key)}function Su(s,e,t){let i=t.dateUpdated||"",n=new Date(Date.now()+Se.staleTTL),r=Se.disableCache?void 0:gt.get(e);if(r&&i&&r.version===i){r.staleAt=n,mu();return}Se.disableCache||(gt.set(e,{data:t,version:i,staleAt:n,sse:Es.has(s)}),ku()),mu();let o=ys.get(s);o&&o.forEach(a=>Hm(a,t))}async function Hm(s,e){await s.setPayload(e||s.getPayload())}async function mo(s){let{apiHost:e,apiRequestHeaders:t}=s.getApiHosts(),i=s.getClientKey(),n="isRemoteEval"in s&&s.isRemoteEval(),r=ii(s),o=yo(s),a=bn.get(o);return a||(a=(n?ms.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:s.getAttributes(),forcedVariations:s.getForcedVariations(),forcedFeatures:Array.from(s.getForcedFeatures().entries()),url:s.getUrl()},headers:t}):ms.fetchFeaturesCall({host:e,clientKey:i,headers:t})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&Es.add(r),c.json()}).then(c=>(Su(r,o,c),bo(s),bn.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(bn.delete(o),{data:null,source:"error",success:!1,error:c})),bn.set(o,a)),a}function bo(s,e=!1){let t=ii(s),i=yo(s),{streamingHost:n,streamingHostRequestHeaders:r}=s.getApiHosts(),o=s.getClientKey();if(e&&Es.add(t),Se.backgroundSync&&Es.has(t)&&nt.EventSource){if(bs.has(t))return;let a={src:null,host:n,clientKey:o,headers:r,cb:l=>{try{if(l.type==="features-updated"){let c=ys.get(t);c&&c.forEach(u=>{mo(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);Su(t,i,c)}a.errors=0}catch{wu(a)}},errors:0,state:"active"};bs.set(t,a),ko(a)}}function wu(s){if(s.state!=="idle"&&(s.errors++,s.errors>3||s.src&&s.src.readyState===2)){let e=Math.pow(3,s.errors-3)*(1e3+Math.random()*1e3);Eo(s),setTimeout(()=>{["idle","active"].includes(s.state)||ko(s)},Math.min(e,3e5))}}function Eo(s){s.src&&(s.src.onopen=null,s.src.onerror=null,s.src.close(),s.src=null,s.state==="active"&&(s.state="disabled"))}function ko(s){s.src=ms.eventSourceCall({host:s.host,clientKey:s.clientKey,headers:s.headers}),s.state="active",s.src.addEventListener("features",s.cb),s.src.addEventListener("features-updated",s.cb),s.src.onerror=()=>wu(s),s.src.onopen=()=>{s.errors=0}}function qm(s,e){Eo(s),bs.delete(e)}function So(){Es.clear(),bs.forEach(qm),ys.clear(),ms.stopIdleListener()}function En(s,e){if(e.streaming){if(!s.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&bo(s,!0),Um(s)}}var Se,nt,ms,ys,_u,gt,bn,bs,Es,Au=Re(()=>{"use strict";si();Se={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},nt=cu(),ms={fetchFeaturesCall:({host:s,clientKey:e,headers:t})=>nt.fetch(`${s}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:s,clientKey:e,payload:t,headers:i})=>{let n={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(t)};return nt.fetch(`${s}/api/eval/${e}`,n)},eventSourceCall:({host:s,clientKey:e,headers:t})=>t?new nt.EventSource(`${s}/sub/${e}`,{headers:t}):new nt.EventSource(`${s}/sub/${e}`),startIdleListener:()=>{let s;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(s),Vm()):document.visibilityState==="hidden"&&(s=window.setTimeout(Bm,Se.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(nt.localStorage=globalThis.localStorage)}catch{}ys=new Map,_u=!1,gt=new Map,bn=new Map,bs=new Map,Es=new Set});function Km(s){return s==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[s]}}function Tn(s){var e=An.get(s);return e||(e={element:s,attributes:{}},An.set(s,e)),e}function In(s,e,t,i,n){var r=t(s),o={isDirty:!1,originalValue:r,virtualValue:r,mutations:[],el:s,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=t(s);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,n(o))}}),mutationRunner:n,setValue:i,getCurrentValue:t};return e==="position"&&s.parentNode?o.observer.observe(s.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(s,Km(e)),o}function Rn(s,e){var t=e.getCurrentValue(e.el);e.virtualValue=s,s&&typeof s!="string"?(!t||s.parentNode!==t.parentNode||s.insertBeforeNode!==t.insertBeforeNode)&&(e.isDirty=!0,Tu()):s!==t&&(e.isDirty=!0,Tu())}function Wm(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),Rn(ly(e),s)}function Xm(s){var e=new Set(s.originalValue.split(/\s+/).filter(Boolean));s.mutations.forEach(function(t){return t.mutate(e)}),Rn(Array.from(e).filter(Boolean).join(" "),s)}function Ym(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),Rn(e,s)}function Jm(s){var e=s.parentSelector,t=s.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var n=t?document.querySelector(t):null;return t&&!n?null:{parentNode:i,insertBeforeNode:n}}function Qm(s){var e=s.originalValue;s.mutations.forEach(function(t){var i=t.mutate(),n=Jm(i);e=n||e}),Rn(e,s)}function Ru(s){var e=Tn(s);return e.html||(e.html=In(s,"html",Zm,ey,Wm)),e.html}function Ou(s){var e=Tn(s);return e.position||(e.position=In(s,"position",ty,sy,Qm)),e.position}function Cu(s){var e=Tn(s);return e.classes||(e.classes=In(s,"class",ny,iy,Xm)),e.classes}function Pu(s,e){var t=Tn(s);return t.attributes[e]||(t.attributes[e]=In(s,e,ry(e),oy(e),Ym)),t.attributes[e]}function ay(s,e){var t=An.get(s);if(t)if(e==="html"){var i,n;(i=t.html)==null||(n=i.observer)==null||n.disconnect(),delete t.html}else if(e==="class"){var r,o;(r=t.classes)==null||(o=r.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var c,u,h;(c=t.attributes)==null||(u=c[e])==null||(h=u.observer)==null||h.disconnect(),delete t.attributes[e]}}function ly(s){return kn||(kn=document.createElement("div")),kn.innerHTML=s,kn.innerHTML}function Sn(s,e,t){if(t.isDirty){t.isDirty=!1;var i=t.virtualValue;t.mutations.length||ay(s,e),t.setValue(s,i)}}function cy(s,e){s.html&&Sn(e,"html",s.html),s.classes&&Sn(e,"class",s.classes),s.position&&Sn(e,"position",s.position),Object.keys(s.attributes).forEach(function(t){Sn(e,t,s.attributes[t])})}function Tu(){An.forEach(cy)}function uy(s,e){var t=null;s.kind==="html"?t=Ru(e):s.kind==="class"?t=Cu(e):s.kind==="attribute"?t=Pu(e,s.attribute):s.kind==="position"&&(t=Ou(e)),t&&(t.mutations.push(s),t.mutationRunner(t))}function dy(s,e){var t=null;if(s.kind==="html"?t=Ru(e):s.kind==="class"?t=Cu(e):s.kind==="attribute"?t=Pu(e,s.attribute):s.kind==="position"&&(t=Ou(e)),!!t){var i=t.mutations.indexOf(s);i!==-1&&t.mutations.splice(i,1),t.mutationRunner(t)}}function Nu(s){if(!(s.kind==="position"&&s.elements.size===1)){var e=new Set(s.elements),t=document.querySelectorAll(s.selector);t.forEach(function(i){e.has(i)||(s.elements.add(i),uy(s,i))})}}function hy(s){s.elements.forEach(function(e){return dy(s,e)}),s.elements.clear(),Io.delete(s)}function Iu(){Io.forEach(Nu)}function fy(){typeof document>"u"||(wo||(wo=new MutationObserver(function(){Iu()})),Iu(),wo.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function On(s){return typeof document>"u"?To:(Io.add(s),Nu(s),{revert:function(){hy(s)}})}function Ao(s,e){return On({kind:"html",elements:new Set,mutate:e,selector:s})}function Du(s,e){return On({kind:"position",elements:new Set,mutate:e,selector:s})}function ni(s,e){return On({kind:"class",elements:new Set,mutate:e,selector:s})}function wn(s,e,t){return zm.test(e)?e==="class"||e==="className"?ni(s,function(i){var n=t(Array.from(i).join(" "));i.clear(),n&&n.split(/\s+/g).filter(Boolean).forEach(function(r){return i.add(r)})}):On({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:s}):To}function gy(s){var e=s.selector,t=s.action,i=s.value,n=s.attribute,r=s.parentSelector,o=s.insertBeforeSelector;if(n==="html"){if(t==="append")return Ao(e,function(a){return a+(i??"")});if(t==="set")return Ao(e,function(){return i??""})}else if(n==="class"){if(t==="append")return ni(e,function(a){i&&a.add(i)});if(t==="remove")return ni(e,function(a){i&&a.delete(i)});if(t==="set")return ni(e,function(a){a.clear(),i&&a.add(i)})}else if(n==="position"){if(t==="set"&&r)return Du(e,function(){return{insertBeforeSelector:o,parentSelector:r}})}else{if(t==="append")return wn(e,n,function(a){return a!==null?a+(i??""):i??""});if(t==="set")return wn(e,n,function(){return i??""});if(t==="remove")return wn(e,n,function(){return null})}return To}var zm,To,An,Io,Zm,ey,ty,sy,iy,ny,ry,oy,kn,wo,py,xu,Lu=Re(()=>{"use strict";zm=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,To={revert:function(){}},An=new Map,Io=new Set;Zm=function(e){return e.innerHTML},ey=function(e,t){return e.innerHTML=t};ty=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},sy=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};iy=function(e,t){return t?e.className=t:e.removeAttribute("class")},ny=function(e){return e.className};ry=function(e){return function(t){var i;return(i=t.getAttribute(e))!=null?i:null}},oy=function(e){return function(t,i){return i!==null?t.setAttribute(e,i):t.removeAttribute(e)}};fy();py={html:Ao,classes:ni,attribute:wn,position:Du,declarative:gy},xu=py});function Ot(s,e,t){t=t||{};for(let[i,n]of Object.entries(e))switch(i){case"$or":if(!Fu(s,n,t))return!1;break;case"$nor":if(Fu(s,n,t))return!1;break;case"$and":if(!by(s,n,t))return!1;break;case"$not":if(Ot(s,n,t))return!1;break;default:if(!ri(n,vy(s,i),t))return!1}return!0}function vy(s,e){let t=e.split("."),i=s;for(let n=0;n<t.length;n++)if(i&&typeof i=="object"&&t[n]in i)i=i[t[n]];else return null;return i}function $u(s,e=!1){let t=`${s}${e?"/i":""}`;return Ro[t]||(Ro[t]=new RegExp(s.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Ro[t]}function ri(s,e,t,i=!1){if(typeof s=="string")return i?String(e).toLowerCase()===s.toLowerCase():e+""===s;if(typeof s=="number")return e*1===s;if(typeof s=="boolean")return e!==null&&!!e===s;if(s===null)return e===null;if(Array.isArray(s)||!Uu(s))return JSON.stringify(e)===JSON.stringify(s);for(let n in s)if(!yy(n,e,s[n],t))return!1;return!0}function Uu(s){let e=Object.keys(s);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function _y(s){if(s===null)return"null";if(Array.isArray(s))return"array";let e=typeof s;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function my(s,e,t){if(!Array.isArray(s))return!1;let i=Uu(e)?n=>ri(e,n,t):n=>Ot(n,e,t);for(let n=0;n<s.length;n++)if(s[n]&&i(s[n]))return!0;return!1}function ks(s,e,t=!1){if(t){let i=n=>typeof n=="string"?n.toLowerCase():n;return Array.isArray(s)?s.some(n=>e.some(r=>i(n)===i(r))):e.some(n=>i(s)===i(n))}return Array.isArray(s)?s.some(i=>e.includes(i)):e.includes(s)}function Mu(s,e,t,i=!1){if(!Array.isArray(s))return!1;for(let n=0;n<e.length;n++){let r=!1;for(let o=0;o<s.length;o++)if(ri(e[n],s[o],t,i)){r=!0;break}if(!r)return!1}return!0}function yy(s,e,t,i){switch(s){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)?ks(e,t):!1;case"$ini":return Array.isArray(t)?ks(e,t,!0):!1;case"$inGroup":return ks(e,i[t]||[]);case"$notInGroup":return!ks(e,i[t]||[]);case"$nin":return Array.isArray(t)?!ks(e,t):!1;case"$nini":return Array.isArray(t)?!ks(e,t,!0):!1;case"$not":return!ri(t,e,i);case"$size":return Array.isArray(e)?ri(t,e.length,i):!1;case"$elemMatch":return my(e,t,i);case"$all":return Array.isArray(t)?Mu(e,t,i):!1;case"$alli":return Array.isArray(t)?Mu(e,t,i,!0):!1;case"$regex":try{return $u(t).test(e)}catch{return!1}case"$regexi":try{return $u(t,!0).test(e)}catch{return!1}case"$type":return _y(e)===t;default:return console.error("Unknown operator: "+s),!1}}function Fu(s,e,t){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(Ot(s,e[i],t))return!0;return!1}function by(s,e,t){for(let i=0;i<e.length;i++)if(!Ot(s,e[i],t))return!1;return!0}var Ro,Bu=Re(()=>{"use strict";si();Ro={}});function Sy(s){let e=new Map;return s.global.forcedFeatureValues&&s.global.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),s.user.forcedFeatureValues&&s.user.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),e}function wy(s){return s.global.forcedVariations&&s.user.forcedVariations?{...s.global.forcedVariations,...s.user.forcedVariations}:s.global.forcedVariations?s.global.forcedVariations:s.user.forcedVariations?s.user.forcedVariations:{}}async function Ss(s){try{await s()}catch{}}function Vu(s,e,t){if(s.user.trackedExperiments){let n=Nn(e,t);if(s.user.trackedExperiments.has(n))return[];s.user.trackedExperiments.add(n)}s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let i=[];if(s.global.trackingCallback){let n=s.global.trackingCallback;i.push(Ss(()=>n(e,t,s.user)))}if(s.user.trackingCallback){let n=s.user.trackingCallback;i.push(Ss(()=>n(e,t)))}if(s.global.eventLogger){let n=s.global.eventLogger;i.push(Ss(()=>n(ky,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},s.user)))}return i}function Ay(s,e,t){if(s.user.trackedFeatureUsage){let i=JSON.stringify(t.value);if(s.user.trackedFeatureUsage[e]===i)return;s.user.trackedFeatureUsage[e]=i,s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({featureKey:e,result:t,timestamp:Date.now().toString(),logType:"feature"})}if(s.global.onFeatureUsage){let i=s.global.onFeatureUsage;Ss(()=>i(e,t,s.user))}if(s.user.onFeatureUsage){let i=s.user.onFeatureUsage;Ss(()=>i(e,t))}if(s.global.eventLogger){let i=s.global.eventLogger;Ss(()=>i(Ey,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},s.user))}}function Cn(s,e){if(e.stack.evaluatedFeatures.has(s))return Ct(e,s,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(s),e.stack.id=s;let t=Sy(e);if(t.has(s))return Ct(e,s,t.get(s),"override");if(!e.global.features||!e.global.features[s])return Ct(e,s,null,"unknownFeature");let i=e.global.features[s];if(i.rules){let n=new Set(e.stack.evaluatedFeatures);e:for(let r of i.rules){if(r.parentConditions)for(let l of r.parentConditions){e.stack.evaluatedFeatures=new Set(n);let c=Cn(l.id,e);if(c.source==="cyclicPrerequisite")return Ct(e,s,null,"cyclicPrerequisite");let u={value:c.value};if(!Ot(u,l.condition||{})){if(l.gate)return Ct(e,s,null,"prerequisite");continue e}}if(r.filters&&Hu(r.filters,e))continue;if("force"in r){if(r.condition&&!ju(r.condition,e)||!Ty(e,r.seed||s,r.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!r.disableStickyBucketing?r.fallbackAttribute:void 0,r.range,r.coverage,r.hashVersion))continue;return r.tracks&&r.tracks.forEach(l=>{!Vu(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),Ct(e,s,r.force,"force",r.id)}if(!r.variations)continue;let o={variations:r.variations,key:r.key||s};"coverage"in r&&(o.coverage=r.coverage),r.weights&&(o.weights=r.weights),r.hashAttribute&&(o.hashAttribute=r.hashAttribute),r.fallbackAttribute&&(o.fallbackAttribute=r.fallbackAttribute),r.disableStickyBucketing&&(o.disableStickyBucketing=r.disableStickyBucketing),r.bucketVersion!==void 0&&(o.bucketVersion=r.bucketVersion),r.minBucketVersion!==void 0&&(o.minBucketVersion=r.minBucketVersion),r.namespace&&(o.namespace=r.namespace),r.meta&&(o.meta=r.meta),r.ranges&&(o.ranges=r.ranges),r.name&&(o.name=r.name),r.phase&&(o.phase=r.phase),r.seed&&(o.seed=r.seed),r.hashVersion&&(o.hashVersion=r.hashVersion),r.filters&&(o.filters=r.filters),r.condition&&(o.condition=r.condition);let{result:a}=Pn(o,s,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return Ct(e,s,a.value,"experiment",r.id,o,a)}}return Ct(e,s,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function Pn(s,e,t){let i=s.key,n=s.variations.length;if(n<2)return{result:re(t,s,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:re(t,s,-1,!1,e)};if(s=Iy(s,t),s.urlPatterns&&!_n(t.user.url||"",s.urlPatterns))return{result:re(t,s,-1,!1,e)};let r=fu(i,t.user.url||"",n);if(r!==null)return{result:re(t,s,r,!1,e)};let o=wy(t);if(i in o){let _=o[i];return{result:re(t,s,_,!1,e)}}if(s.status==="draft"||s.active===!1)return{result:re(t,s,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Wt(t,s.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing?s.fallbackAttribute:void 0);if(!l)return{result:re(t,s,-1,!1,e)};let c=-1,u=!1,h=!1;if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{variation:_,versionIsBlocked:b}=Cy({ctx:t,expKey:s.key,expBucketVersion:s.bucketVersion,expHashAttribute:s.hashAttribute,expFallbackAttribute:s.fallbackAttribute,expMinBucketVersion:s.minBucketVersion,expMeta:s.meta});u=_>=0,c=_,h=!!b}if(!u){if(s.filters){if(Hu(s.filters,t))return{result:re(t,s,-1,!1,e)}}else if(s.namespace&&!uu(l,s.namespace))return{result:re(t,s,-1,!1,e)};if(s.include&&!gu(s.include))return{result:re(t,s,-1,!1,e)};if(s.condition&&!ju(s.condition,t))return{result:re(t,s,-1,!1,e)};if(s.parentConditions){let _=new Set(t.stack.evaluatedFeatures);for(let b of s.parentConditions){t.stack.evaluatedFeatures=new Set(_);let E=Cn(b.id,t);if(E.source==="cyclicPrerequisite")return{result:re(t,s,-1,!1,e)};let C={value:E.value};if(!Ot(C,b.condition||{}))return{result:re(t,s,-1,!1,e)}}}if(s.groups&&!Oy(s.groups,t))return{result:re(t,s,-1,!1,e)}}if(s.url&&!Ry(s.url,t))return{result:re(t,s,-1,!1,e)};let g=ei(s.seed||i,l,s.hashVersion||1);if(g===null)return{result:re(t,s,-1,!1,e)};if(!u){let _=s.ranges||hu(n,s.coverage===void 0?1:s.coverage,s.weights);c=du(g,_)}if(h)return{result:re(t,s,-1,!1,e,void 0,!0)};if(c<0)return{result:re(t,s,-1,!1,e)};if("force"in s)return{result:re(t,s,s.force===void 0?-1:s.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:re(t,s,-1,!1,e)};if(s.status==="stopped")return{result:re(t,s,-1,!1,e)};let f=re(t,s,c,!0,e,g,u);if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{changed:_,key:b,doc:E}=Ny(t,a,ti(l),{[Oo(s.key,s.bucketVersion)]:f.key});_&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[b]=E,t.user.saveStickyBucketAssignmentDoc(E))}let p=Vu(t,s,f);p.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:s,result:f});let v=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in s&&s.changeId&&t.global.recordChangeId&&t.global.recordChangeId(s.changeId),{result:f,trackingCall:v}}function Ct(s,e,t,i,n,r,o){let a={value:t,on:!!t,off:!t,source:i,ruleId:n||""};return r&&(a.experiment=r),o&&(a.experimentResult=o),i!=="override"&&Ay(s,e,a),a}function Gu(s){return{...s.user.attributes,...s.user.attributeOverrides}}function ju(s,e){return Ot(Gu(e),s,e.global.savedGroups||{})}function Hu(s,e){return s.some(t=>{let{hashValue:i}=Wt(e,t.attribute);if(!i)return!0;let n=ei(t.seed,i,t.hashVersion||2);return n===null?!0:!t.ranges.some(r=>vn(n,r))})}function Ty(s,e,t,i,n,r,o){if(!n&&r===void 0)return!0;if(!n&&r===0)return!1;let{hashValue:a}=Wt(s,t,i);if(!a)return!1;let l=ei(e,a,o||1);return l===null?!1:n?vn(l,n):r!==void 0?l<=r:!0}function re(s,e,t,i,n,r,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:c}=Wt(s,e.hashAttribute,s.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),u=e.meta?e.meta[t]:{},h={key:u.key||""+t,featureId:n,inExperiment:a,hashUsed:i,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};return u.name&&(h.name=u.name),r!==void 0&&(h.bucket=r),u.passthrough&&(h.passthrough=u.passthrough),h}function Iy(s,e){let t=s.key,i=e.global.overrides;return i&&i[t]&&(s=Object.assign({},s,i[t]),typeof s.url=="string"&&(s.url=_o(s.url))),s}function Wt(s,e,t){let i=e||"id",n="",r=Gu(s);return r[i]&&(n=r[i]),!n&&t&&(r[t]&&(n=r[t]),n&&(i=t)),{hashAttribute:i,hashValue:n}}function Ry(s,e){let t=e.user.url;if(!t)return!1;let i=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(s.test(t)||s.test(i))}function Oy(s,e){let t=e.global.groups||{};for(let i=0;i<s.length;i++)if(t[s[i]])return!0;return!1}function Cy({ctx:s,expKey:e,expBucketVersion:t,expHashAttribute:i,expFallbackAttribute:n,expMinBucketVersion:r,expMeta:o}){t=t||0,r=r||0,i=i||"id",o=o||[];let a=Oo(e,t),l=Py(s,i,n);if(r>0)for(let h=0;h<r;h++){let g=Oo(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 Oo(s,e){return e=e||0,`${s}__${e}`}function Co(s,e){return`${s}||${e}`}function Py(s,e,t){if(!s.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:n}=Wt(s,e),r=Co(i,ti(n)),{hashAttribute:o,hashValue:a}=Wt(s,t),l=a?Co(o,ti(a)):null,c={};return l&&s.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,s.user.stickyBucketAssignmentDocs[l].assignments||{}),s.user.stickyBucketAssignmentDocs[r]&&Object.assign(c,s.user.stickyBucketAssignmentDocs[r].assignments||{}),c}function Ny(s,e,t,i){let n=Co(e,t),r=s.user.stickyBucketAssignmentDocs&&s.user.stickyBucketAssignmentDocs[n]?s.user.stickyBucketAssignmentDocs[n].assignments||{}:{},o={...r,...i},a=JSON.stringify(r)!==JSON.stringify(o);return{key:n,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function Dy(s,e){let t=new Set,i=e&&e.features?e.features:s.global.features||{},n=e&&e.experiments?e.experiments:s.global.experiments||[];return Object.keys(i).forEach(r=>{let o=i[r];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),n.map(r=>{t.add(r.hashAttribute||"id"),r.fallbackAttribute&&t.add(r.fallbackAttribute)}),Array.from(t)}async function qu(s,e,t){let i=Po(s,t);return e.getAllAssignments(i)}function Po(s,e){let t={};return Dy(s,e).forEach(n=>{let{hashValue:r}=Wt(s,n);t[n]=ti(r)}),t}async function zu(s,e,t){if(s={...s},s.encryptedFeatures){try{s.features=JSON.parse(await Kt(s.encryptedFeatures,e,t))}catch(i){console.error(i)}delete s.encryptedFeatures}if(s.encryptedExperiments){try{s.experiments=JSON.parse(await Kt(s.encryptedExperiments,e,t))}catch(i){console.error(i)}delete s.encryptedExperiments}if(s.encryptedSavedGroups){try{s.savedGroups=JSON.parse(await Kt(s.encryptedSavedGroups,e,t))}catch(i){console.error(i)}delete s.encryptedSavedGroups}return s}function Ku(s){let e=s.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(s.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:s.apiHostRequestHeaders,streamingHostRequestHeaders:s.streamingHostRequestHeaders}}function Nn(s,e){return e.hashAttribute+e.hashValue+s.key+e.variationId}var Ey,ky,Wu=Re(()=>{"use strict";Bu();si();Ey="Feature Evaluated",ky="Experiment Viewed"});var ws,xy,oi,Xu=Re(()=>{"use strict";Lu();si();Au();Wu();ws=typeof window<"u"&&typeof document<"u",xy=pu(),oi=class{constructor(e){if(e=e||{},this.version=xy,this._options=this.context=e,this._renderer=e.renderer||null,this._trackedExperiments=new Set,this._completedChangeIds=new Set,this._trackedFeatures={},this.debug=!!e.debug,this._subscriptions=new Set,this.ready=!1,this._assigned=new Map,this._activeAutoExperiments=new Map,this._triggeredExpKeys=new Set,this._initialized=!1,this._redirectedUrl="",this._deferredTrackingCalls=new Map,this._autoExperimentsAllowed=!e.disableExperimentsOnLoad,this._destroyCallbacks=[],this.logs=[],this.log=this.log.bind(this),this._saveDeferredTrack=this._saveDeferredTrack.bind(this),this._onExperimentEval=this._onExperimentEval.bind(this),this._fireSubscriptions=this._fireSubscriptions.bind(this),this._recordChangedId=this._recordChangedId.bind(this),e.remoteEval){if(e.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!e.clientKey)throw new Error("Missing clientKey");let t=!1;try{t=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(t)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(e.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(e.stickyBucketService){let t=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=i=>t.saveAssignments(i)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),ws&&e.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),e.experiments&&(this.ready=!0,this._updateAllAutoExperiments()),this._options.stickyBucketService&&this._options.stickyBucketAssignmentDocs)for(let t in this._options.stickyBucketAssignmentDocs){let i=this._options.stickyBucketAssignmentDocs[t];i&&this._options.stickyBucketService.saveAssignments(i).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await zu(e,this._options.decryptionKey);this._decryptedPayload=t,await this.refreshStickyBuckets(t),t.features&&(this._options.features=t.features),t.savedGroups&&(this._options.savedGroups=t.savedGroups),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let t=e.payload;if(t.encryptedExperiments||t.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this._options.stickyBucketService&&!this._options.stickyBucketAssignmentDocs&&(this._options.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this._options.stickyBucketService,t)),this._payload=t,this._decryptedPayload=t,t.features&&(this._options.features=t.features),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,En(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&yu(e.cacheSettings),e.payload)return await this.setPayload(e.payload),En(this,e),{success:!0,source:"init"};{let{data:t,...i}=await this._refresh({...e,allowStale:!0});return En(this,e),await this.setPayload(t||{}),i}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return Ku(this._options)}getClientKey(){return this._options.clientKey||""}getPayload(){return this._payload||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this._decryptedPayload||this.getPayload()}isRemoteEval(){return this._options.remoteEval||!1}getCacheKeyAttributes(){return this._options.cacheKeyAttributes}async _refresh({timeout:e,skipCache:t,allowStale:i,streaming:n}){if(!this._options.clientKey)throw new Error("Missing clientKey");return bu({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:i,backgroundSync:n??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,t,i){let n=await Kt(e,t||this._options.decryptionKey,i);this.setFeatures(JSON.parse(n))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,i){let n=await Kt(e,t||this._options.decryptionKey,i);this.setExperiments(JSON.parse(n))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(t=>{try{t()}catch(i){console.error(i)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,Eu(this),e.destroyAllStreams&&So(),this.logs=[],ws&&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}=Pn(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(i=>i.key===e).map(i=>this._runAutoExperiment(i)).filter(i=>i!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,t){let i=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!i)return null;let n=this._isAutoExperimentBlockedByContext(e),r,o;n?r=re(this._getEvalContext(),e,-1,!1,""):({result:r,trackingCall:o}=Pn(e,null,this._getEvalContext()),this._onExperimentEval(e,r));let a=JSON.stringify(r.value);if(!t&&r.inExperiment&&i&&i.valueHash===a)return r;if(i&&this._undoActiveAutoExperiment(e),r.inExperiment){let l=mn(e);if(l==="redirect"&&r.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?vu(this._getContextUrl(),r.value.urlRedirect):r.value.urlRedirect;if(_n(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),r;this._redirectedUrl=c;let{navigate:u,delay:h}=this._getNavigateFunction();if(u)if(ws)Promise.all([...o?[yn(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(g=>window.setTimeout(g,this._options.navigateDelay??h))]).then(()=>{try{u(c)}catch(g){console.error(g)}});else try{u(c)}catch(g){console.error(g)}}else if(l==="visual"){let c=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(r.value):this._applyDOMChanges(r.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return r}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],i=new Set(t);this._activeAutoExperiments.forEach((n,r)=>{i.has(r)||(n.undo(),this._activeAutoExperiments.delete(r))});for(let n of t){let r=this._runAutoExperiment(n,e);if(r&&r.inExperiment&&mn(n)==="redirect")break}}_onExperimentEval(e,t){let i=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,i)}_fireSubscriptions(e,t,i){(!i||i.result.inExperiment!==t.inExperiment||i.result.variationId!==t.variationId)&&this._subscriptions.forEach(n=>{try{n(e,t)}catch(r){console.error(r)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,t){let i=this.evalFeature(e).value;return i===null?t:i}feature(e){return this.evalFeature(e)}evalFeature(e){return Cn(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=>[Nn(t.experiment,t.result),t]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(t=>{!t||!t.experiment||!t.result?console.error("Invalid deferred tracking call",{call:t}):e.push(this._options.trackingCallback(t.experiment,t.result))}),this._deferredTrackingCalls.clear(),await Promise.all(e)}setTrackingCallback(e){this._options.trackingCallback=e,this.fireDeferredTrackingCalls()}setFeatureUsageCallback(e){this._options.onFeatureUsage=e}setEventLogger(e){this._options.eventLogger=e}async logEvent(e,t){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:t,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,t||{},this._getUserContext())}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Nn(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(ws?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=mn(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(i=>i.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let i=new URL(this._getContextUrl());for(let n of e.variations){if(!n||!n.urlRedirect)continue;let r=new URL(n.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(r.protocol!==i.protocol||r.host!==i.host))return!0}}catch(i){return this.log("Error parsing current or redirect URL",{id:e.key,error:i}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:ws?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!ws)return;let t=[];if(e.css){let i=document.createElement("style");i.innerHTML=e.css,document.head.appendChild(i),t.push(()=>i.remove())}if(e.js){let i=document.createElement("script");i.innerHTML=e.js,this._options.jsInjectionNonce&&(i.nonce=this._options.jsInjectionNonce),document.head.appendChild(i),t.push(()=>i.remove())}return e.domMutations&&e.domMutations.forEach(i=>{t.push(xu.declarative(i).revert)}),()=>{t.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),i=await qu(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=i}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let i=this._getEvalContext(),n=Po(i,t);return e.getAllAssignmentsSync(n)}inDevMode(){return!!this._options.enableDevMode}}});var Yu=Re(()=>{"use strict";Xu()});var Ju={};hr(Ju,{Growthbook:()=>No});var qe,No,Qu=Re(()=>{"use strict";Yu();lo();ps();vs();qe=class qe{constructor(e,t,i={},n=!1){this.analytics=new hs;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=it("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:t,user_language:i,device_language:n,device_type:r,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:c,url:u,domain:h,utm_content:g,residence_country:f,loggedIn:p,network_type:v,network_downlink:_,user_id:b,anonymous_id:E,account_mode:C})=>{let I={...this.GrowthBook.getAttributes(),id:e,...b!==void 0&&{user_id:b},...E!==void 0&&{anonymous_id:E},...t!==void 0&&{country:t},...f!==void 0&&{residence_country:f},...i!==void 0&&{user_language:i},...n!==void 0&&{device_language:n},...r!==void 0&&{device_type:r},...o!==void 0&&{utm_source:o},...a!==void 0&&{utm_medium:a},...l!==void 0&&{utm_campaign:l},...c!==void 0&&{is_authorised:c},...u!==void 0&&{url:u},...h!==void 0&&{domain:h},...g!==void 0&&{utm_content:g},...p!==void 0&&{loggedIn:p},...v!==void 0&&{network_type:v},..._!==void 0&&{network_downlink:_},...C!==void 0&&{account_mode:C}};this.log("setAttributes | updating GrowthBook attributes",I),this.GrowthBook.setAttributes(I)};this.getFeatureValue=(e,t)=>{let i=this.GrowthBook.getFeatureValue(e,t);return this.log("getFeatureValue",{key:e,value:i,defaultValue:t}),i};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let t=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:t}),t};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let t=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:t}),t};this.init=async()=>{this.log("init | initializing GrowthBook SDK");let e=await this.GrowthBook.init({timeout:2e3,streaming:!0}).catch(()=>{});this.status=e,this.isLoaded=!0,this.log("init | GrowthBook SDK loaded",{status:e})};this.destroy=()=>{this.GrowthBook.destroy(),this.isLoaded=!1,this.status=void 0};this.debug=n;let r=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new oi({apiHost:Wc,clientKey:e,decryptionKey:t,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:r,trackingCallback:(o,a)=>{this.log("trackingCallback | experiment viewed",{experiment_id:o.key,variation_id:a.variationId}),typeof window<"u"&&window.dataLayer&&window.dataLayer.push({event:"experiment_viewed",event_category:"experiment",rudder_anonymous_id:this.analytics.getAnonymousId(),experiment_id:o.key,variation_id:a.variationId}),this.analytics.track("experiment_viewed",{experimentId:o.key,variationId:a.variationId})},...i}),this.init()}reapplyExperiment(e){let t=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(t)}waitForIsLoaded(e=1e4){return new Promise((t,i)=>{let n=Date.now(),r=setInterval(()=>{this.isLoaded?(clearInterval(r),t()):Date.now()-n>=e&&(clearInterval(r),i(new Error("GrowthBook initialization timeout")))},100)})}};qe.getGrowthBookInstance=(e,t,i,n=!1)=>qe._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),qe._instance):(qe._instance=new qe(e,t??"",i,n),qe._instance),qe.resetInstance=()=>{qe._instance&&(qe._instance.destroy(),qe._instance=void 0)};No=qe});function sd(s,e,t,i,n,r,o){try{var a=s[r](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(i,n)}function _t(s){return function(){var e=this,t=arguments;return new Promise((function(i,n){var r=s.apply(e,t);function o(l){sd(r,i,n,o,a,"next",l)}function a(l){sd(r,i,n,o,a,"throw",l)}o(void 0)}))}}function k(){return k=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},k.apply(null,arguments)}function Yd(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}function F(s,e){return s.indexOf(e)!==-1}function ea(s){return s===null||typeof s!="object"}function Vn(s,e){return Object.prototype.toString.call(s)==="[object "+e+"]"}function Zd(s){return!w(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(s,Event)}function at(s,e,t,i,n){return e>t&&(i.warn("min cannot be greater than max."),e=t),St(s)?s>t?(i.warn(" cannot be greater than max: "+t+". Using max value instead."),t):s<e?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):s:(i.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+n),at(n||t,e,t,i))}function Zy(s){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return Lo&&t.length===rd||(rd=t.length,Lo=t.reduce(((i,n)=>{Dn||(Dn={});var r=Dn[n];if(r)i[r[0]]=r[1];else for(var o=s(n),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,u=e[n];if(c&&u){i[c]=u,Dn[n]=[c,u];break}}return i}),{})),Lo}}function oa(s,e,t,i,n){var r={platform:s,filename:e,function:t==="<anonymous>"?Ls:t,in_app:!0};return w(i)||(r.lineno=i),w(n)||(r.colno=n),r}function ab(){return(function(s){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return function(n,r){r===void 0&&(r=0);for(var o=[],a=n.split(`
15
15
  `),l=r;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=ld.test(c)?c.replace(ld,"$1"):c;if(!u.match(/\S*Error: /)){for(var h of t){var g=h(u,s);if(g){o.push(g);break}}if(o.length>=cd)break}}}return(function(f){if(!f.length)return[];var p=Array.from(f);return p.reverse(),p.slice(0,cd).map((v=>{return k({},v,{filename:v.filename||(_=p,_[_.length-1]||{}).filename,function:v.function||Ls});var _}))})(o)}})("web:javascript",ib,ob)}function _h(s,e){e===void 0&&(e=40);var t=Object.keys(s);if(t.sort(),!t.length)return"[object has no keys]";for(var i=t.length;i>0;i--){var n=t.slice(0,i).join(", ");if(!(n.length>e))return i===t.length||n.length<=e?n:n.slice(0,e)+"..."}return""}function $t(s,e,t){if(q(s)){if(Zu&&s.forEach===Zu)s.forEach(e,t);else if("length"in s&&s.length===+s.length){for(var i=0,n=s.length;i<n;i++)if(i in s&&e.call(t,s[i],i)===jn)return}}}function Z(s,e,t){if(!U(s)){if(q(s))return $t(s,e,t);if(Fy(s)){for(var i of s.entries())if(e.call(t,i[1],i[0])===jn)return}else for(var n in s)if(Qd.call(s,n)&&e.call(t,s[n],n)===jn)return}}function Un(s){for(var e=Object.keys(s),t=e.length,i=new Array(t);t--;)i[t]=[e[t],s[e[t]]];return i}function hb(s,e){return t=s,i=r=>he(r)&&!Ze(e)?r.slice(0,e):r,n=new Set,(function r(o,a){return o!==Object(o)?i?i(o,a):o:n.has(o)?void 0:(n.add(o),q(o)?(l=[],$t(o,(c=>{l.push(r(c))}))):(l={},Z(o,((c,u)=>{n.has(c)||(l[u]=r(c,u))}))),l);var l})(t);var t,i,n}function gb(s){var e=s?.hostname;if(!he(e))return!1;var t=e.split(".").slice(-2).join(".");for(var i of fb)if(t===i)return!1;return!0}function yh(s,e){for(var t=0;t<s.length;t++)if(e(s[t]))return s[t]}function de(s,e,t,i){var{capture:n=!1,passive:r=!0}=i??{};s?.addEventListener(e,t,{capture:n,passive:r})}function bh(s){return s.name==="ph_toolbar_internal"}function mb(s,e){if(e){var t=(function(n,r){if(r===void 0&&(r=S),li)return li;if(!r||["localhost","127.0.0.1"].includes(n))return"";for(var o=n.split("."),a=Math.min(o.length,8),l="dmn_chk_"+Lt();!li&&a--;){var c=o.slice(a).join("."),u=l+"=1;domain=."+c+";path=/";r.cookie=u+";max-age=3",r.cookie.includes(l)&&(r.cookie=u+";max-age=0",li=c)}return li})(s);if(!t){var i=(n=>{var r=n.match(_b);return r?r[0]:""})(s);i!==t&&A.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}function Sb(s,e){var t=s.config.segment;if(!t)return e();(function(i,n){var r=i.config.segment;if(!r)return n();var o=l=>{var c=()=>l.anonymousId()||Lt();i.config.get_device_id=c,l.id()&&(i.register({distinct_id:l.id(),$device_id:c()}),i.persistence.set_property(rt,"identified")),n()},a=r.user();"then"in a&&bt(a.then)?a.then(o):o(a)})(s,(()=>{t.register((i=>{Promise&&Promise.resolve||Mo.warn("This browser does not have Promise support, and can not use the segment integration");var n=(r,o)=>{if(!o)return r;r.event.userId||r.event.anonymousId===i.get_distinct_id()||(Mo.info("No userId set, resetting PostHog"),i.reset()),r.event.userId&&r.event.userId!==i.get_distinct_id()&&(Mo.info("UserId set, identifying with PostHog"),i.identify(r.event.userId));var a=i.calculateEventProperties(o,r.event.properties);return r.event.properties=Object.assign({},a,r.event.properties),r};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:r=>n(r,r.event.event),page:r=>n(r,"$pageview"),identify:r=>n(r,"$identify"),screen:r=>n(r,"$screen")}})(s)).then((()=>{e()}))}))}function Ih(s,e){var{organization:t,projectId:i,prefix:n,severityAllowList:r=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,h,g;if(!(r==="*"||r.includes(a.level))||!s.__loaded)return a;a.tags||(a.tags={});var f=s.requestRouter.endpointFor("ui","/project/"+s.config.token+"/person/"+s.get_distinct_id());a.tags["PostHog Person URL"]=f,s.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=s.get_session_replay_url({withTimestamp:!0}));var p=((l=a.exception)==null?void 0:l.values)||[],v=p.map((b=>k({},b,{stacktrace:b.stacktrace?k({},b.stacktrace,{type:"raw",frames:(b.stacktrace.frames||[]).map((E=>k({},E,{platform:"web:javascript"})))}):void 0}))),_={$exception_message:((c=p[0])==null?void 0:c.value)||a.message,$exception_type:(u=p[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:v,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=p[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(g=p[0])==null?void 0:g.type,$sentry_tags:a.tags};return t&&i&&(_.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+a.event_id),o&&s.exceptions.sendExceptionEvent(_),a}}function Nb(s,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=Cb[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),i=s.length;t.p(s);var n,r=Pb(s,e,10+((n=e).filename&&n.filename.length+1||0),8),o=r.length;return(function(a,l){var c=l.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=l.level<2?4:l.level==9?2:0,a[9]=3,l.mtime!=0&&Uo(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),c){a[3]=8;for(var u=0;u<=c.length;++u)a[u+10]=c.charCodeAt(u)}})(r,e),Uo(r,o-8,t.d()),Uo(r,o-4,i),r}function Td(s,e,t){return Ei({distinct_id:s,userPropertiesToSet:e,userPropertiesToSetOnce:t})}function Dh(s,e){return!s||Object.entries(s).every((t=>{var[i,n]=t,r=e?.[i];if(w(r)||Ze(r))return!1;var o=[String(r)],a=Nh[n.operator];return!!a&&a(n.values,o)}))}function xh(s,e,t){if(!S)return{};var i,n=e?$s([],Fs,t||[]):[],r=Lh(Pi(S.URL,n,Ni),s),o=(i={},Z($b,(function(a){var l=ot.A(a);i[a]=l||null})),i);return ue(o,r)}function Lh(s,e){var t=Lb.concat(e||[]),i={};return Z(t,(function(n){var r=Jn(s,n);i[n]=r||null})),i}function $h(s){var e=(function(r){return r?r.search(Fn+"google.([^/?]*)")===0?"google":r.search(Fn+"bing.com")===0?"bing":r.search(Fn+"yahoo.com")===0?"yahoo":r.search(Fn+"duckduckgo.com")===0?"duckduckgo":null:null})(s),t=e!="yahoo"?"q":"p",i={};if(!Ze(e)){i.$search_engine=e;var n=S?Jn(S.referrer,t):"";n.length&&(i.ph_keyword=n)}return i}function Id(){return navigator.language||navigator.userLanguage}function Mh(){return S?.referrer||"$direct"}function Fh(s,e){var t=s?$s([],Fs,e||[]):[],i=be?.href.substring(0,1e3);return{r:Mh().substring(0,1e3),u:i?Pi(i,t,Ni):void 0}}function Uh(s){var e,{r:t,u:i}=s,n={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Yn(t))==null?void 0:e.host};if(i){n.$current_url=i;var r=Yn(i);n.$host=r?.host,n.$pathname=r?.pathname;var o=Lh(i);ue(n,o)}if(t){var a=$h(t);ue(n,a)}return n}function Bh(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Mb(){try{return new Date().getTimezoneOffset()}catch{return}}function Fb(s,e){var t,i;if(!xe)return{};var n,r,o=s?$s([],Fs,e||[]):[],[a,l]=(function(b){for(var E=0;E<od.length;E++){var[C,P]=od[E],I=C.exec(b),z=I&&(bt(P)?P(I,b):P);if(z)return z}return["",""]})(xe),c=(n=ad(xe))===th||n===eh||n==="Kobo"||n==="Kindle Fire"||n===gh?Ii:n===Oi||n===Ds||n===Ci||n===ia?"Console":n===ih?"Wearable":n?Ke:"Desktop";if(c==="Desktop"&&((t=navigator)==null||(t=t.userAgentData)==null?void 0:t.platform)==="Android"&&((i=navigator)==null?void 0:i.maxTouchPoints)>0){var u,h,g,f,p,v=(u=m==null||(h=m.screen)==null?void 0:h.width)!==null&&u!==void 0?u:0,_=(g=m==null||(f=m.screen)==null?void 0:f.height)!==null&&g!==void 0?g:0;c=Math.min(v,_)/((p=m?.devicePixelRatio)!==null&&p!==void 0?p:1)>=600?"Tablet":"Mobile"}return ue(rl({$os:a,$os_version:l,$browser:ph(xe,navigator.vendor),$device:ad(xe),$device_type:c,$timezone:Bh(),$timezone_offset:Mb()}),{$current_url:Pi(be?.href,o,Ni),$host:be?.host,$pathname:be?.pathname,$raw_user_agent:xe.length>1e3?xe.substring(0,997)+"...":xe,$browser_version:Jy(xe,navigator.vendor),$browser_language:Id(),$browser_language_prefix:(r=Id(),typeof r=="string"?r.split("-")[0]:void 0),$screen_height:m?.screen.height,$screen_width:m?.screen.width,$viewport_height:m?.innerHeight,$viewport_width:m?.innerWidth,$lib:"web",$lib_version:vt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}function Ts(s,e,t){if(U(s))return!1;switch(t){case"exact":return s===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(s);case"regex":try{return new RegExp(e).test(s)}catch{return!1}default:return!1}}function Md(s){return s instanceof Element&&(s.id===wh||!(s.closest==null||!s.closest(".toolbar-global-fade-container")))}function dr(s){return!!s&&s.nodeType===1}function Mt(s,e){return!!s&&!!s.tagName&&s.tagName.toLowerCase()===e.toLowerCase()}function Hh(s){return!!s&&s.nodeType===3}function qh(s){return!!s&&s.nodeType===11}function ll(s){return s?cr(s).split(/\s+/):[]}function Fd(s){var e=m?.location.href;return!!(e&&s&&s.some((t=>e.match(t))))}function ar(s){var e="";switch(typeof s.className){case"string":e=s.className;break;case"object":e=(s.className&&"baseVal"in s.className?s.className.baseVal:null)||s.getAttribute("class")||"";break;default:e=""}return ll(e)}function zh(s){return U(s)?null:cr(s).split(/(\s+)/).filter((e=>xi(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Li(s){var e="";return Za(s)&&!Yh(s)&&s.childNodes&&s.childNodes.length&&Z(s.childNodes,(function(t){var i;Hh(t)&&t.textContent&&(e+=(i=zh(t.textContent))!==null&&i!==void 0?i:"")})),cr(e)}function Ud(s){return w(s.target)?s.srcElement||null:(e=s.target)!=null&&e.shadowRoot?s.composedPath()[0]||null:s.target||null;var e}function Kh(s,e){if(w(e))return!0;var t,i=function(r){if(e.some((o=>r.matches(o))))return{v:!0}};for(var n of s)if(t=i(n))return t.v;return!1}function Wh(s){var e=s.parentNode;return!(!e||!dr(e))&&e}function rE(s,e){if(!m||ul(s))return!1;var t,i,n;if(kt(e)?(t=!!e&&Vd,i=void 0):(t=(n=e?.css_selector_ignorelist)!==null&&n!==void 0?n:Vd,i=e?.content_ignorelist),t===!1)return!1;var{targetElementList:r}=Xh(s,!1);return!(function(o,a){if(o===!1||w(o))return!1;var l;if(o===!0)l=nE;else{if(!q(o))return!1;if(o.length>Bd)return A.error("[PostHog] content_ignorelist array cannot exceed "+Bd+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map((c=>c.toLowerCase()))}return a.some((c=>{var{safeText:u,ariaLabel:h}=c;return l.some((g=>u.includes(g)||h.includes(g)))}))})(i,r.map((o=>{var a;return{safeText:Li(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!Kh(r,t)}function oE(s,e,t,i,n){var r,o,a,l;if(t===void 0&&(t=void 0),!m||ul(s)||(r=t)!=null&&r.url_allowlist&&!Fd(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&Fd(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some((p=>e.type===p)))return!1}var{parentIsUsefulElement:u,targetElementList:h}=Xh(s,i);if(!(function(p,v){var _=v?.element_allowlist;if(w(_))return!0;var b,E=function(P){if(_.some((I=>P.tagName.toLowerCase()===I)))return{v:!0}};for(var C of p)if(b=E(C))return b.v;return!1})(h,t)||!Kh(h,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var g=m.getComputedStyle(s);if(g&&g.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var f=s.tagName.toLowerCase();switch(f){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return u?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(cl.indexOf(f)>-1||s.getAttribute("contenteditable")==="true")}}function Za(s){for(var e=s;e.parentNode&&!Mt(e,"body");e=e.parentNode){var t=ar(e);if(F(t,"ph-sensitive")||F(t,"ph-no-capture"))return!1}if(F(ar(s),"ph-include"))return!0;var i=s.type||"";if(he(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var n=s.name||s.id||"";return!(he(n)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,"")))}function Yh(s){return!!(Mt(s,"input")&&!["button","checkbox","submit","reset"].includes(s.type)||Mt(s,"select")||Mt(s,"textarea")||s.getAttribute("contenteditable")==="true")}function xi(s,e){return e===void 0&&(e=!0),!(U(s)||he(s)&&(s=cr(s),(e?aE:lE).test((s||"").replace(/[- ]/g,""))||(e?cE:uE).test(s)))}function Zh(s){var e=Li(s);return xi(e=(e+" "+ef(s)).trim())?e:""}function ef(s){var e="";return s&&s.childNodes&&s.childNodes.length&&Z(s.childNodes,(function(t){var i;if(t&&((i=t.tagName)==null?void 0:i.toLowerCase())==="span")try{var n=Li(t);e=(e+" "+n).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+ef(t)).trim())}catch(r){A.error("[AutoCapture]",r)}})),e}function dE(s){return(function(e){var t=e.map((i=>{var n,r,o="";if(i.tag_name&&(o+=i.tag_name),i.attr_class)for(var a of(i.attr_class.sort(),i.attr_class))o+="."+a.replace(/"/g,"");var l=k({},i.text?{text:i.text}:{},{"nth-child":(n=i.nth_child)!==null&&n!==void 0?n:0,"nth-of-type":(r=i.nth_of_type)!==null&&r!==void 0?r:0},i.href?{href:i.href}:{},i.attr_id?{attr_id:i.attr_id}:{},i.attributes),c={};return Un(l).sort(((u,h)=>{var[g]=u,[f]=h;return g.localeCompare(f)})).forEach((u=>{var[h,g]=u;return c[Gd(h.toString())]=Gd(g.toString())})),o+=":",o+=Un(c).map((u=>{var[h,g]=u;return h+'="'+g+'"'})).join("")}));return t.join(";")})((function(e){return e.map((t=>{var i,n,r={text:(i=t.$el_text)==null?void 0:i.slice(0,400),tag_name:t.tag_name,href:(n=t.attr__href)==null?void 0:n.slice(0,2048),attr_class:hE(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Un(t).filter((o=>{var[a]=o;return a.indexOf("attr__")===0})).forEach((o=>{var[a,l]=o;return r.attributes[a]=l})),r}))})(s))}function Gd(s){return s.replace(/"|\\"/g,'\\"')}function hE(s){var e=s.attr__class;return e?q(e)?e:ll(e):void 0}function Wo(s,e){return e.length>s?e.slice(0,s)+"...":e}function fE(s){if(s.previousElementSibling)return s.previousElementSibling;var e=s;do e=e.previousSibling;while(e&&!dr(e));return e}function gE(s,e,t,i){var n=s.tagName.toLowerCase(),r={tag_name:n};cl.indexOf(n)>-1&&!t&&(n.toLowerCase()==="a"||n.toLowerCase()==="button"?r.$el_text=Wo(1024,Zh(s)):r.$el_text=Wo(1024,Li(s)));var o=ar(s);o.length>0&&(r.classes=o.filter((function(u){return u!==""}))),Z(s.attributes,(function(u){var h;if((!Yh(s)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(i==null||!i.includes(u.name))&&!e&&xi(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=ll(g).join(" ")),r["attr__"+u.name]=Wo(1024,g)}}));for(var a=1,l=1,c=s;c=fE(c);)a++,c.tagName===s.tagName&&l++;return r.nth_child=a,r.nth_of_type=l,r}function pE(s,e){for(var t,i,{e:n,maskAllElementAttributes:r,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[s],u=s;u.parentNode&&!Mt(u,"body");)qh(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var h,g=[],f={},p=!1,v=!1;if(Z(c,(P=>{var I=Za(P);P.tagName.toLowerCase()==="a"&&(p=P.getAttribute("href"),p=I&&p&&xi(p)&&p),F(ar(P),"ph-no-capture")&&(v=!0),g.push(gE(P,r,o,a));var z=(function(B){if(!Za(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&&xi(Le)&&(N[_e]=Le)}})),N})(P);ue(f,z)})),v)return{props:{},explicitNoCapture:v};if(o||(s.tagName.toLowerCase()==="a"||s.tagName.toLowerCase()==="button"?g[0].$el_text=Zh(s):g[0].$el_text=Li(s)),p){var _,b;g[0].attr__href=p;var E=(_=Yn(p))==null?void 0:_.host,C=m==null||(b=m.location)==null?void 0:b.host;E&&C&&E!==C&&(h=p)}return{props:ue({$event_type:n.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:dE(g)},(t=g[0])!=null&&t.$el_text?{$el_text:(i=g[0])==null?void 0:i.$el_text}:{},h&&n.type==="click"?{$external_click_url:h}:{},f)}}function Hd(s,e,t){try{if(!(e in s))return()=>{};var i=s[e],n=t(i);return bt(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0}})),s[e]=n,()=>{s[e]=i}}catch{return()=>{}}}function zd(s){return fe(s)&&"clientX"in s&&"clientY"in s&&St(s.clientX)&&St(s.clientY)}var m,Ee,Xd,Zu,ed,Ve,S,be,Yo,Jo,td,xe,O,vt,Ly,$y,id,cr,Qo,My,Jd,Qd,ur,q,bt,fe,Cs,w,he,Zo,Ze,U,St,Rs,kt,Fy,Uy,By,Do,Vy,ta,Ke,Gn,Et,Ii,eh,th,sh,ih,Ri,xs,nh,rh,oh,Jt,Gy,ah,tl,lh,sl,jy,il,ch,Ns,uh,Oi,Ci,Ds,dh,hh,vi,sa,nd,ia,fh,Hy,gh,na,Ae,xo,qy,zy,Ky,nl,Wy,Dn,rd,Lo,Xy,ph,Yy,Jy,od,ad,Qy,ra,Ls,vh,eb,tb,sb,ib,nb,rb,ob,ld,cd,aa,la,ca,lb,ua,cb,da,ha,fa,ga,mh,A,le,ub,ud,jn,ue,$s,dd,db,rl,fb,Eh,_i,mi,hd,pa,fd,va,gd,pd,kh,vd,_d,xn,Hn,Sh,Ps,yi,_a,bi,Yt,ma,qn,ya,zn,rt,ba,Ea,ka,Sa,Kn,Wn,wh,ai,pb,md,wa,Aa,yd,Ah,Ta,Lt,vb,li,_b,ot,$o,ae,yb,Ln,bb,Xt,ye,mt,Ia,$n,Eb,kb,Xn,Mo,Th,Ra,Yn,wb,Jn,Pi,Qn,Ab,bd,Ed,xt,Oa,Zn,yt,We,Te,Ms,ol,al,kd,Rh,Oh,Tb,Ca,Pt,Pa,er,ee,wi,Qt,tr,Ib,Rb,Ch,Ph,pt,ci,Fo,Na,Sd,ui,Da,wd,Ob,Cb,Pb,Uo,Db,xb,Ad,sr,Ei,Bo,Bn,ir,Nh,Mn,Vo,xa,Fn,Fs,Lb,Ni,$b,De,di,Ub,Bb,Vb,Gb,jb,Hb,qb,Go,As,Rd,hi,Od,Cd,zb,Kb,La,Wb,Ai,fi,hk,fk,gk,jo,pk,vk,_k,ki,Ho,$a,J,Vh,Xb,Pd,Yb,Jb,Di,Ma,Fa,Ua,Ba,ze,Va,Qb,Nd,Ga,Dd,ja,gi,nr,Ha,qa,Zb,za,Ka,eE,rr,qo,or,Gh,Si,xd,Wa,tE,Xa,sE,iE,Ya,Ti,zo,Ja,Os,jh,Ld,$d,Qa,Us,cl,nE,Bd,Vd,ul,Xh,Jh,aE,lE,Qh,cE,uE,lr,Ko,jd,pi,vE,Nt,qd,el,Is,_E,Kd,Xo,mE,Dt,yE,bE,EE,kE,SE,wE,Wd,wt,tf=Re(()=>{"use strict";m=typeof window<"u"?window:void 0,Ee=typeof globalThis<"u"?globalThis:m;typeof self>"u"&&(Ee.self=Ee),typeof File>"u"&&(Ee.File=function(){});Xd=Array.prototype,Zu=Xd.forEach,ed=Xd.indexOf,Ve=Ee?.navigator,S=Ee?.document,be=Ee?.location,Yo=Ee?.fetch,Jo=Ee!=null&&Ee.XMLHttpRequest&&"withCredentials"in new Ee.XMLHttpRequest?Ee.XMLHttpRequest:void 0,td=Ee?.AbortController,xe=Ve?.userAgent,O=m??{},vt={DEBUG:!1,LIB_VERSION:"1.356.1"};Ly=["$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"],$y=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],id=function(s,e){if(e===void 0&&(e=[]),!s)return!1;var t=s.toLowerCase();return $y.concat(e).some((i=>{var n=i.toLowerCase();return t.indexOf(n)!==-1}))};cr=function(s){return s.trim()},Qo=function(s){return s.replace(/^\$/,"")},My=Array.isArray,Jd=Object.prototype,Qd=Jd.hasOwnProperty,ur=Jd.toString,q=My||function(s){return ur.call(s)==="[object Array]"},bt=s=>typeof s=="function",fe=s=>s===Object(s)&&!q(s),Cs=s=>{if(fe(s)){for(var e in s)if(Qd.call(s,e))return!1;return!0}return!1},w=s=>s===void 0,he=s=>ur.call(s)=="[object String]",Zo=s=>he(s)&&s.trim().length===0,Ze=s=>s===null,U=s=>w(s)||Ze(s),St=s=>ur.call(s)=="[object Number]"&&s==s,Rs=s=>St(s)&&s>0,kt=s=>ur.call(s)==="[object Boolean]",Fy=s=>s instanceof FormData,Uy=s=>F(Ly,s);By=[!0,"true",1,"1","yes"],Do=s=>F(By,s),Vy=[!1,"false",0,"0","no"];ta=class{constructor(e){this.t={},this.i=e.i,this.o=at(e.bucketSize,0,100,e.h),this.m=at(e.refillRate,0,this.o,e.h),this.$=at(e.refillInterval,0,864e5,e.h)}S(e,t){var i=t-e.lastAccess,n=Math.floor(i/this.$);if(n>0){var r=n*this.m;e.tokens=Math.min(e.tokens+r,this.o),e.lastAccess=e.lastAccess+n*this.$}}consumeRateLimit(e){var t,i=Date.now(),n=String(e),r=this.t[n];return r?this.S(r,i):(r={tokens:this.o,lastAccess:i},this.t[n]=r),r.tokens===0||(r.tokens--,r.tokens===0&&((t=this.i)==null||t.call(this,e)),r.tokens===0)}stop(){this.t={}}},Ke="Mobile",Gn="iOS",Et="Android",Ii="Tablet",eh=Et+" "+Ii,th="iPad",sh="Apple",ih=sh+" Watch",Ri="Safari",xs="BlackBerry",nh="Samsung",rh=nh+"Browser",oh=nh+" Internet",Jt="Chrome",Gy=Jt+" OS",ah=Jt+" "+Gn,tl="Internet Explorer",lh=tl+" "+Ke,sl="Opera",jy=sl+" Mini",il="Edge",ch="Microsoft "+il,Ns="Firefox",uh=Ns+" "+Gn,Oi="Nintendo",Ci="PlayStation",Ds="Xbox",dh=Et+" "+Ke,hh=Ke+" "+Ri,vi="Windows",sa=vi+" Phone",nd="Nokia",ia="Ouya",fh="Generic",Hy=fh+" "+Ke.toLowerCase(),gh=fh+" "+Ii.toLowerCase(),na="Konqueror",Ae="(\\d+(\\.\\d+)?)",xo=new RegExp("Version/"+Ae),qy=new RegExp(Ds,"i"),zy=new RegExp(Ci+" \\w+","i"),Ky=new RegExp(Oi+" \\w+","i"),nl=new RegExp(xs+"|PlayBook|BB10","i"),Wy={"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"},Xy=(s,e)=>e&&F(e,sh)||(function(t){return F(t,Ri)&&!F(t,Jt)&&!F(t,Et)})(s),ph=function(s,e){return e=e||"",F(s," OPR/")&&F(s,"Mini")?jy:F(s," OPR/")?sl:nl.test(s)?xs:F(s,"IE"+Ke)||F(s,"WPDesktop")?lh:F(s,rh)?oh:F(s,il)||F(s,"Edg/")?ch:F(s,"FBIOS")?"Facebook "+Ke:F(s,"UCWEB")||F(s,"UCBrowser")?"UC Browser":F(s,"CriOS")?ah:F(s,"CrMo")||F(s,Jt)?Jt:F(s,Et)&&F(s,Ri)?dh:F(s,"FxiOS")?uh:F(s.toLowerCase(),na.toLowerCase())?na:Xy(s,e)?F(s,Ke)?hh:Ri:F(s,Ns)?Ns:F(s,"MSIE")||F(s,"Trident/")?tl:F(s,"Gecko")?Ns:""},Yy={[lh]:[new RegExp("rv:"+Ae)],[ch]:[new RegExp(il+"?\\/"+Ae)],[Jt]:[new RegExp("("+Jt+"|CrMo)\\/"+Ae)],[ah]:[new RegExp("CriOS\\/"+Ae)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ae)],[Ri]:[xo],[hh]:[xo],[sl]:[new RegExp("(Opera|OPR)\\/"+Ae)],[Ns]:[new RegExp(Ns+"\\/"+Ae)],[uh]:[new RegExp("FxiOS\\/"+Ae)],[na]:[new RegExp("Konqueror[:/]?"+Ae,"i")],[xs]:[new RegExp(xs+" "+Ae),xo],[dh]:[new RegExp("android\\s"+Ae,"i")],[oh]:[new RegExp(rh+"\\/"+Ae)],[tl]:[new RegExp("(rv:|MSIE )"+Ae)],Mozilla:[new RegExp("rv:"+Ae)]},Jy=function(s,e){var t=ph(s,e),i=Yy[t];if(w(i))return null;for(var n=0;n<i.length;n++){var r=i[n],o=s.match(r);if(o)return parseFloat(o[o.length-2])}return null},od=[[new RegExp(Ds+"; "+Ds+" (.*?)[);]","i"),s=>[Ds,s&&s[1]||""]],[new RegExp(Oi,"i"),[Oi,""]],[new RegExp(Ci,"i"),[Ci,""]],[nl,[xs,""]],[new RegExp(vi,"i"),(s,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[sa,""];if(new RegExp(Ke).test(e)&&!/IEMobile\b/.test(e))return[vi+" "+Ke,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var i=t[1],n=Wy[i]||"";return/arm/i.test(e)&&(n="RT"),[vi,n]}return[vi,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,s=>{if(s&&s[3]){var e=[s[3],s[4],s[5]||"0"];return[Gn,e.join(".")]}return[Gn,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,s=>{var e="";return s&&s.length>=3&&(e=w(s[2])?s[3]:s[2]),["watchOS",e]}],[new RegExp("("+Et+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Et+")","i"),s=>{if(s&&s[2]){var e=[s[2],s[3],s[4]||"0"];return[Et,e.join(".")]}return[Et,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,s=>{var e=["Mac OS X",""];if(s&&s[1]){var t=[s[1],s[2],s[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Gy,""]],[/Linux|debian/i,["Linux",""]]],ad=function(s){return Ky.test(s)?Oi:zy.test(s)?Ci:qy.test(s)?Ds:new RegExp(ia,"i").test(s)?ia:new RegExp("("+sa+"|WPDesktop)","i").test(s)?sa:/iPad/.test(s)?th:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?ih:nl.test(s)?xs:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(nd,"i").test(s)?nd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":/(Android|ZTE)/i.test(s)?new RegExp(Ke).test(s)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)||/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?Et:eh:new RegExp("(pda|"+Ke+")","i").test(s)?Hy:new RegExp(Ii,"i").test(s)&&!new RegExp(Ii+" pc","i").test(s)?gh:""},Qy=s=>s instanceof Error;ra=class{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},n=this.buildCoercingContext(i,t,0).apply(e),r=this.buildParsingContext(t),o=this.parseStacktrace(n,r);return{$exception_list:this.convertToExceptionList(o,i),$exception_level:"error"}}modifyFrames(e){var t=this;return _t((function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&q(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,n;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(n=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),k({},e,{cause:i,stack:n})}applyChunkIds(e,t){return e.map((i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return _t((function*(){var i=e;for(var n of t.modifiers)i=yield n(i);return i}))()}convertToExceptionList(e,t){var i,n,r,o={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(n=t.handled)===null||n===void 0||n,synthetic:(r=e.synthetic)!==null&&r!==void 0&&r}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,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,i){i===void 0&&(i=0);var n=(r,o)=>{if(o<=4){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(r,a)}};return k({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:r=>n(r,i),next:r=>n(r,i+1)})}},Ls="?";vh=(s,e)=>{var t=s.indexOf("safari-extension")!==-1,i=s.indexOf("safari-web-extension")!==-1;return t||i?[s.indexOf("@")!==-1?s.split("@")[0]:Ls,t?"safari-extension:"+e:"safari-web-extension:"+e]:[s,e]},eb=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,tb=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,sb=/\((\S*)(?::(\d+))(?::(\d+))\)/,ib=(s,e)=>{var t=eb.exec(s);if(t){var[,i,n,r]=t;return oa(e,i,Ls,+n,+r)}var o=tb.exec(s);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=sb.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=vh(o[1]||Ls,o[2]);return oa(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},nb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,rb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ob=(s,e)=>{var t=nb.exec(s);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=rb.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var n=t[3],r=t[1]||Ls;return[r,n]=vh(r,n),oa(e,n,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},ld=/\(error: (.*)\)/,cd=50;aa=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=he(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Vn(e,"DOMException")}isDOMError(e){return Vn(e,"DOMError")}},la=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return i.error&&typeof i.error.message=="string"?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}},ca=class{constructor(){}match(e){return Vn(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var i,n=t.apply(e.error);return n||{type:"ErrorEvent",value:e.message,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},lb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ua=class{match(e){return typeof e=="string"}coerce(e,t){var i,[n,r]=this.getInfos(e);return{type:n??"Error",value:r??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,n=e.match(lb);return n&&(t=n[1],i=n[2]),[t,i]}},cb=["fatal","error","warning","log","info","debug"];da=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:(i=t.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return 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 i=this.getObjectClassName(e);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+_h(e)}isSeverityLevel(e){return he(e)&&!Zo(e)&&cb.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Qy(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},ha=class{match(e){return Zd(e)}coerce(e,t){var i,n=e.constructor.name;return{type:n,value:n+" captured as exception with keys: "+_h(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},fa=class{match(e){return ea(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},ga=class{match(e){return Vn(e,"PromiseRejectionEvent")}coerce(e,t){var i,n=this.getUnhandledRejectionReason(e);return ea(n)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(n),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){if(ea(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}},mh=function(s,e){var{debugEnabled:t}=e===void 0?{}:e,i={k:function(n){if(m&&(vt.DEBUG||O.POSTHOG_DEBUG||t)&&!w(m.console)&&m.console){for(var r=("__rrweb_original__"in m.console[n])?m.console[n].__rrweb_original__:m.console[n],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];r(s,...a)}},info:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];i.k("log",...r)},warn:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];i.k("warn",...r)},error:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];i.k("error",...r)},critical:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];console.error(s,...r)},uninitializedWarning:n=>{i.error("You must initialize PostHog before calling "+n)},createLogger:(n,r)=>mh(s+" "+n,r)};return i},A=mh("[PostHog.js]"),le=A.createLogger,ub=le("[ExternalScriptsLoader]"),ud=(s,e,t)=>{if(s.config.disable_external_dependency_loading)return ub.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var i=S?.querySelectorAll("script");if(i){for(var n,r=function(){if(i[o].src===e){var l=i[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)})),l.onerror=c=>t(c),{v:void 0})}},o=0;o<i.length;o++)if(n=r())return n.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),s.config.prepare_external_dependency_script&&(l=s.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(s.config.external_scripts_inject_target==="head")S.head.appendChild(l);else{var c,u=S.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):S.body.appendChild(l)}};S!=null&&S.body?a():S?.addEventListener("DOMContentLoaded",a)};O.__PosthogExtensions__=O.__PosthogExtensions__||{},O.__PosthogExtensions__.loadExternalDependency=(s,e,t)=>{var i="/static/"+e+".js?v="+s.version;if(e==="remote-config"&&(i="/array/"+s.config.token+"/config.js"),e==="toolbar"){var n=3e5;i=i+"&t="+Math.floor(Date.now()/n)*n}var r=s.requestRouter.endpointFor("assets",i);ud(s,r,t)},O.__PosthogExtensions__.loadSiteApp=(s,e,t)=>{var i=s.requestRouter.endpointFor("api",e);ud(s,i,t)};jn={};ue=function(s){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return $t(t,(function(n){for(var r in n)n[r]!==void 0&&(s[r]=n[r])})),s},$s=function(s){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return $t(t,(function(n){$t(n,(function(r){s.push(r)}))})),s};dd=function(s){try{return s()}catch{return}},db=function(s){return function(){try{for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return s.apply(this,t)}catch(n){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(n)}}},rl=function(s){var e={};return Z(s,(function(t,i){(he(t)&&t.length>0||St(t))&&(e[i]=t)})),e};fb=["herokuapp.com","vercel.app","netlify.app"];Eh="$people_distinct_id",_i="__alias",mi="__timers",hd="$autocapture_disabled_server_side",pa="$heatmaps_enabled_server_side",fd="$exception_capture_enabled_server_side",va="$error_tracking_suppression_rules",gd="$error_tracking_capture_extension_exceptions",pd="$web_vitals_enabled_server_side",kh="$dead_clicks_enabled_server_side",vd="$product_tours_enabled_server_side",_d="$web_vitals_allowed_metrics",xn="$session_recording_remote_config",Hn="$sesid",Sh="$session_is_sampled",Ps="$enabled_feature_flags",yi="$early_access_features",_a="$feature_flag_details",bi="$stored_person_properties",Yt="$stored_group_properties",ma="$surveys",qn="$flag_call_reported",ya="$feature_flag_errors",zn="$feature_flag_evaluated_at",rt="$user_state",ba="$client_session_props",Ea="$capture_rate_limit",ka="$initial_campaign_params",Sa="$initial_referrer_info",Kn="$initial_person_info",Wn="$epp",wh="__POSTHOG_TOOLBAR__",ai="$posthog_cookieless",pb=[Eh,_i,"__cmpns",mi,"$session_recording_enabled_server_side",pa,Hn,Ps,va,rt,yi,_a,Yt,bi,ma,qn,ya,zn,ba,Ea,ka,Sa,Wn,Kn];Math.trunc||(Math.trunc=function(s){return s<0?Math.ceil(s):Math.floor(s)}),Number.isInteger||(Number.isInteger=function(s){return St(s)&&isFinite(s)&&Math.floor(s)===s});md="0123456789abcdef",wa=class s{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,n){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(n)||e<0||t<0||i<0||n<0||e>0xffffffffffff||t>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");var r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new s(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+md.charAt(this.bytes[t]>>>4)+md.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 s(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(i!==0)return Math.sign(i)}return 0}},Aa=class{constructor(){this.P=0,this.T=0,this.C=new Ta}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 wa.fromFieldsV7(this.P,Math.trunc(this.T/Math.pow(2,30)),this.T&Math.pow(2,30)-1,this.C.nextUint32())}I(){this.T=1024*this.C.nextUint32()+(1023&this.C.nextUint32())}},Ah=s=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<s.length;e++)s[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return s};m&&!w(m.crypto)&&crypto.getRandomValues&&(Ah=s=>crypto.getRandomValues(s));Ta=class{constructor(){this.R=new Uint32Array(8),this.F=1/0}nextUint32(){return this.F>=this.R.length&&(Ah(this.R),this.F=0),this.R[this.F++]}},Lt=()=>vb().toString(),vb=()=>(yd||(yd=new Aa)).generate(),li="",_b=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;ot={O:()=>!!S,M:function(s){A.error("cookieStore error: "+s)},A:function(s){if(S){try{for(var e=s+"=",t=S.cookie.split(";").filter((r=>r.length)),i=0;i<t.length;i++){for(var n=t[i];n.charAt(0)==" ";)n=n.substring(1,n.length);if(n.indexOf(e)===0)return decodeURIComponent(n.substring(e.length,n.length))}}catch{}return null}},D:function(s){var e;try{e=JSON.parse(ot.A(s))||{}}catch{}return e},j:function(s,e,t,i,n){if(S)try{var r="",o="",a=mb(S.location.hostname,i);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),r="; expires="+l.toUTCString()}n&&(o="; secure");var c=s+"="+encodeURIComponent(JSON.stringify(e))+r+"; 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}},L:function(s,e){if(S!=null&&S.cookie)try{ot.j(s,"",-1,e)}catch{return}}},$o=null,ae={O:function(){if(!Ze($o))return $o;var s=!0;if(w(m))s=!1;else try{var e="__mplssupport__";ae.j(e,"xyz"),ae.A(e)!=='"xyz"'&&(s=!1),ae.L(e)}catch{s=!1}return s||A.error("localStorage unsupported; falling back to cookie store"),$o=s,s},M:function(s){A.error("localStorage error: "+s)},A:function(s){try{return m?.localStorage.getItem(s)}catch(e){ae.M(e)}return null},D:function(s){try{return JSON.parse(ae.A(s))||{}}catch{}return null},j:function(s,e){try{m?.localStorage.setItem(s,JSON.stringify(e))}catch(t){ae.M(t)}},L:function(s){try{m?.localStorage.removeItem(s)}catch(e){ae.M(e)}}},yb=["$device_id","distinct_id",Hn,Sh,Wn,Kn,rt],Ln={},bb={O:function(){return!0},M:function(s){A.error("memoryStorage error: "+s)},A:function(s){return Ln[s]||null},D:function(s){return Ln[s]||null},j:function(s,e){Ln[s]=e},L:function(s){delete Ln[s]}},Xt=null,ye={O:function(){if(!Ze(Xt))return Xt;if(Xt=!0,w(m))Xt=!1;else try{var s="__support__";ye.j(s,"xyz"),ye.A(s)!=='"xyz"'&&(Xt=!1),ye.L(s)}catch{Xt=!1}return Xt},M:function(s){A.error("sessionStorage error: ",s)},A:function(s){try{return m?.sessionStorage.getItem(s)}catch(e){ye.M(e)}return null},D:function(s){try{return JSON.parse(ye.A(s))||null}catch{}return null},j:function(s,e){try{m?.sessionStorage.setItem(s,JSON.stringify(e))}catch(t){ye.M(t)}},L:function(s){try{m?.sessionStorage.removeItem(s)}catch(e){ye.M(e)}}},mt=(function(s){return s[s.PENDING=-1]="PENDING",s[s.DENIED=0]="DENIED",s[s.GRANTED=1]="GRANTED",s})({}),Ia=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:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get H(){var e=this.B.A(this.q);return Do(e)?mt.GRANTED:F(Vy,e)?mt.DENIED:mt.PENDING}get B(){if(!this.W){var e=this.N.opt_out_capturing_persistence_type;this.W=e==="localStorage"?ae:ot;var t=e==="localStorage"?ot:ae;t.A(this.q)&&(this.W.A(this.q)||this.optInOut(Do(t.A(this.q))),t.L(this.q,this.N.cross_subdomain_cookie))}return this.W}U(){return!!this.N.respect_dnt&&!!yh([Ve?.doNotTrack,Ve?.msDoNotTrack,O.doNotTrack],(e=>Do(e)))}},$n=le("[Dead Clicks]"),Eb=()=>!0,kb=s=>{var e,t=!((e=s.instance.persistence)==null||!e.get_property(kh)),i=s.instance.config.capture_dead_clicks;return kt(i)?i:!!fe(i)||t},Xn=class{get lazyLoadedDeadClicksAutocapture(){return this.G}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[kh]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.V((()=>{this.J()})):this.stop()}V(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(n=>{n?$n.error("failed to load script",n):e()}))}J(){var e;if(S){if(!this.G&&(e=O.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=fe(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.G=O.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.G.start(S),$n.info("starting...")}}else $n.error("`document` not found. Cannot start.")}stop(){this.G&&(this.G.stop(),this.G=void 0,$n.info("stopping..."))}},Mo=le("[SegmentIntegration]");Th="posthog-js";Ra=class{constructor(e,t,i,n,r,o){this.name=Th,this.setupOnce=function(a){a(Ih(e,{organization:t,projectId:i,prefix:n,severityAllowList:r,sendExceptionsToPostHog:o==null||o}))}}},Yn=s=>{var e=S?.createElement("a");return w(e)?null:(e.href=s,e)},wb=function(s,e){var t,i;e===void 0&&(e="&");var n=[];return Z(s,(function(r,o){w(r)||w(o)||o==="undefined"||(t=encodeURIComponent((a=>a instanceof File)(r)?r.name:r.toString()),i=encodeURIComponent(o),n[n.length]=i+"="+t)})),n.join(e)},Jn=function(s,e){for(var t,i=((s.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;n<i.length;n++){var r=i[n].split("=");if(r[0]===e){t=r;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," ")},Pi=function(s,e,t){if(!s||!e||!e.length)return s;for(var i=s.split("#"),n=i[0]||"",r=i[1],o=n.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],h=0;h<c.length;h++){var g=c[h].split("=");q(g)&&(e.includes(g[0])?u.push(g[0]+"="+t):u.push(c[h]))}var f=l;return a!=null&&(f+="?"+u.join("&")),r!=null&&(f+="#"+r),f},Qn=function(s,e){var t=s.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Ab=m!=null&&m.location?Qn(m.location.hash,"__posthog")||Qn(location.hash,"state"):null,bd="_postHogToolbarParams",Ed=le("[Toolbar]"),xt=(function(s){return s[s.UNINITIALIZED=0]="UNINITIALIZED",s[s.LOADING=1]="LOADING",s[s.LOADED=2]="LOADED",s})(xt||{}),Oa=class{constructor(e){this.instance=e}K(e){O.ph_toolbar_state=e}Y(){var e;return(e=O.ph_toolbar_state)!==null&&e!==void 0?e:xt.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),bh(this.instance.config)||!m||!S)return!1;e=e??m.location,i=i??m.history;try{if(!t){try{m.localStorage.setItem("test","test"),m.localStorage.removeItem("test")}catch{return!1}t=m?.localStorage}var n,r=Ab||Qn(e.hash,"__posthog")||Qn(e.hash,"state"),o=r?dd((()=>JSON.parse(atob(decodeURIComponent(r)))))||dd((()=>JSON.parse(decodeURIComponent(r)))):null;return o&&o.action==="ph_authorize"?((n=o).source="url",n&&Object.keys(n).length>0&&(o.desiredHash?e.hash=o.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((n=JSON.parse(t.getItem(bd)||"{}")).source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token)&&(this.loadToolbar(n),!0)}catch{return!1}}X(e){var t=O.ph_load_toolbar||O.ph_load_editor;!U(t)&&bt(t)?t(e,this.instance):Ed.warn("No toolbar load function found")}loadToolbar(e){var t=!(S==null||!S.getElementById(wh));if(!m||t)return!1;var i=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,n=k({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(m.localStorage.setItem(bd,JSON.stringify(k({},n,{source:void 0}))),this.Y()===xt.LOADED)this.X(n);else if(this.Y()===xt.UNINITIALIZED){var r;this.K(xt.LOADING),(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(o=>{if(o)return Ed.error("[Toolbar] Failed to load",o),void this.K(xt.UNINITIALIZED);this.K(xt.LOADED),this.X(n)})),de(m,"turbolinks:load",(()=>{this.K(xt.UNINITIALIZED),this.loadToolbar(n)}))}return!0}Z(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),this.maybeLoadToolbar(e,t,i)}},Zn=class{constructor(e){this.tt=(t,i,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength)&&(A.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:n}),this.it=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.et()}et(){var e;this.rt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.tt)}destroy(){var e;(e=this.rt)==null||e.call(this),this.rt=void 0}doPageView(e,t){var i,n=this.st(e,t);return this.it={pathname:(i=m?.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){var t;return this.st(e,(t=this.it)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.it)==null?void 0:e.pageViewId}}st(e,t){var i=this.it;if(!i)return{$pageview_id:t};var n={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:h}=r;if(!(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:at(a/o,0,1,A),f=o<=1?1:at(l/o,0,1,A),p=c<=1?1:at(u/c,0,1,A),v=c<=1?1:at(h/c,0,1,A);n=ue(n,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:g,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return i.pathname&&(n.$prev_pageview_pathname=i.pathname),i.timestamp&&(n.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),n}},yt=(function(s){return s.GZipJS="gzip-js",s.Base64="base64",s})({}),We=Uint8Array,Te=Uint16Array,Ms=Uint32Array,ol=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]),al=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]),kd=new We([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Rh=function(s,e){for(var t=new Te(31),i=0;i<31;++i)t[i]=e+=1<<s[i-1];var n=new Ms(t[30]);for(i=1;i<30;++i)for(var r=t[i];r<t[i+1];++r)n[r]=r-t[i]<<5|i;return[t,n]},Oh=Rh(ol,2),Tb=Oh[0],Ca=Oh[1];Tb[28]=258,Ca[258]=28;for(Pa=Rh(al,0)[1],er=new Te(32768),ee=0;ee<32768;++ee)Pt=(43690&ee)>>>1|(21845&ee)<<1,Pt=(61680&(Pt=(52428&Pt)>>>2|(13107&Pt)<<2))>>>4|(3855&Pt)<<4,er[ee]=((65280&Pt)>>>8|(255&Pt)<<8)>>>1;wi=function(s,e,t){for(var i=s.length,n=0,r=new Te(e);n<i;++n)++r[s[n]-1];var o,a=new Te(e);for(n=0;n<e;++n)a[n]=a[n-1]+r[n-1]<<1;if(t){o=new Te(1<<e);var l=15-e;for(n=0;n<i;++n)if(s[n])for(var c=n<<4|s[n],u=e-s[n],h=a[s[n]-1]++<<u,g=h|(1<<u)-1;h<=g;++h)o[er[h]>>>l]=c}else for(o=new Te(i),n=0;n<i;++n)o[n]=er[a[s[n]-1]++]>>>15-s[n];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;tr=new We(32);for(ee=0;ee<32;++ee)tr[ee]=5;Ib=wi(Qt,9,0),Rb=wi(tr,5,0),Ch=function(s){return(s/8>>0)+(7&s&&1)},Ph=function(s,e,t){(t==null||t>s.length)&&(t=s.length);var i=new(s instanceof Te?Te:s instanceof Ms?Ms:We)(t-e);return i.set(s.subarray(e,t)),i},pt=function(s,e,t){t<<=7&e;var i=e/8>>0;s[i]|=t,s[i+1]|=t>>>8},ci=function(s,e,t){t<<=7&e;var i=e/8>>0;s[i]|=t,s[i+1]|=t>>>8,s[i+2]|=t>>>16},Fo=function(s,e){for(var t=[],i=0;i<s.length;++i)s[i]&&t.push({s:i,f:s[i]});var n=t.length,r=t.slice();if(!n)return[new We(0),0];if(n==1){var o=new We(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(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!=n-1;)a=t[t[c].f<t[h].f?c++:h++],l=t[c!=u&&t[c].f<t[h].f?c++:h++],t[u++]={s:-1,f:a.f+l.f,l:a,r:l};var g=r[0].s;for(i=1;i<n;++i)r[i].s>g&&(g=r[i].s);var f=new Te(g+1),p=Na(t[u-1],f,0);if(p>e){i=0;var v=0,_=p-e,b=1<<_;for(r.sort((function(I,z){return f[z.s]-f[I.s]||I.f-z.f}));i<n;++i){var E=r[i].s;if(!(f[E]>e))break;v+=b-(1<<p-f[E]),f[E]=e}for(v>>>=_;v>0;){var C=r[i].s;f[C]<e?v-=1<<e-f[C]++-1:++i}for(;i>=0&&v;--i){var P=r[i].s;f[P]==e&&(--f[P],++v)}p=e}return[new We(f),p]},Na=function(s,e,t){return s.s==-1?Math.max(Na(s.l,e,t+1),Na(s.r,e,t+1)):e[s.s]=t},Sd=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new Te(++e),i=0,n=s[0],r=1,o=function(l){t[i++]=l},a=1;a<=e;++a)if(s[a]==n&&a!=e)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=s[a]}return[t.subarray(0,i),e]},ui=function(s,e){for(var t=0,i=0;i<e.length;++i)t+=s[i]*e[i];return t},Da=function(s,e,t){var i=t.length,n=Ch(e+2);s[n]=255&i,s[n+1]=i>>>8,s[n+2]=255^s[n],s[n+3]=255^s[n+1];for(var r=0;r<i;++r)s[n+r+4]=t[r];return 8*(n+4+i)},wd=function(s,e,t,i,n,r,o,a,l,c,u){pt(e,u++,t),++n[256];for(var h=Fo(n,15),g=h[0],f=h[1],p=Fo(r,15),v=p[0],_=p[1],b=Sd(g),E=b[0],C=b[1],P=Sd(v),I=P[0],z=P[1],B=new Te(19),N=0;N<E.length;++N)B[31&E[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[kd[$e-1]];--$e);var Ge,T,x,M,L=c+5<<3,ge=ui(n,Qt)+ui(r,tr)+o,H=ui(n,g)+ui(r,v)+o+14+3*$e+ui(B,_e)+(2*B[16]+3*B[17]+7*B[18]);if(L<=ge&&L<=H)return Da(e,u,s.subarray(l,l+c));if(pt(e,u,1+(H<ge)),u+=2,H<ge){Ge=wi(g,f,0),T=g,x=wi(v,_,0),M=v;var K=wi(_e,Le,0);for(pt(e,u,C-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[kd[N]]);u+=3*$e;for(var Q=[E,I],V=0;V<2;++V){var ie=Q[V];for(N=0;N<ie.length;++N){var D=31&ie[N];pt(e,u,K[D]),u+=_e[D],D>15&&(pt(e,u,ie[N]>>>5&127),u+=ie[N]>>>12)}}}else Ge=Ib,T=Qt,x=Rb,M=tr;for(N=0;N<a;++N)if(i[N]>255){D=i[N]>>>18&31,ci(e,u,Ge[D+257]),u+=T[D+257],D>7&&(pt(e,u,i[N]>>>23&31),u+=ol[D]);var Ie=31&i[N];ci(e,u,x[Ie]),u+=M[Ie],Ie>3&&(ci(e,u,i[N]>>>5&8191),u+=al[Ie])}else ci(e,u,Ge[i[N]]),u+=T[i[N]];return ci(e,u,Ge[256]),u+T[256]},Ob=new Ms([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Cb=(function(){for(var s=new Ms(256),e=0;e<256;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;s[e]=t}return s})(),Pb=function(s,e,t,i,n){return(function(r,o,a,l,c,u){var h=r.length,g=new We(l+h+5*(1+Math.floor(h/7e3))+c),f=g.subarray(l,g.length-c),p=0;if(!o||h<8)for(var v=0;v<=h;v+=65535){var _=v+65535;_<h?p=Da(f,p,r.subarray(v,_)):(f[v]=u,p=Da(f,p,r.subarray(v,h)))}else{for(var b=Ob[o-1],E=b>>>13,C=8191&b,P=(1<<a)-1,I=new Te(32768),z=new Te(P+1),B=Math.ceil(a/3),N=2*B,ve=function(At){return(r[At]^r[At+1]<<B^r[At+2]<<N)&P},_e=new Ms(25e3),Le=new Te(288),$e=new Te(32),Ge=0,T=0,x=(v=0,0),M=0,L=0;v<h;++v){var ge=ve(v),H=32767&v,K=z[ge];if(I[H]=K,z[ge]=H,M<=v){var Q=h-v;if((Ge>7e3||x>24576)&&Q>423){p=wd(r,f,0,_e,Le,$e,T,x,L,v-L,p),x=Ge=T=0,L=v;for(var V=0;V<286;++V)Le[V]=0;for(V=0;V<30;++V)$e[V]=0}var ie=2,D=0,Ie=C,Me=H-K&32767;if(Q>2&&ge==ve(v-Me))for(var es=Math.min(E,Q)-1,$i=Math.min(32767,v),Bs=Math.min(258,Q);Me<=$i&&--Ie&&H!=K;){if(r[v+ie]==r[v+ie-Me]){for(var Fe=0;Fe<Bs&&r[v+Fe]==r[v+Fe-Me];++Fe);if(Fe>ie){if(ie=Fe,D=Me,Fe>es)break;var Vs=Math.min(Me,Fe-2),ts=0;for(V=0;V<Vs;++V){var Ft=v-Me+V+32768&32767,ss=Ft-I[Ft]+32768&32767;ss>ts&&(ts=ss,K=Ft)}}}Me+=(H=K)-(K=I[H])+32768&32767}if(D){_e[x++]=268435456|Ca[ie]<<18|Pa[D];var is=31&Ca[ie],ns=31&Pa[D];T+=ol[is]+al[ns],++Le[257+is],++$e[ns],M=v+ie,++Ge}else _e[x++]=r[v],++Le[r[v]]}}p=wd(r,f,u,_e,Le,$e,T,x,L,v-L,p)}return Ph(g,0,l+Ch(p)+c)})(s,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(s.length)))):12+e.mem,t,i,!0)},Uo=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8};Db=function(s){var e,t,i,n,r="";for(e=t=0,i=(s=(s+"").replace(/\r\n/g,`
16
16
  `).replace(/\r/g,`
17
- `)).length,n=0;n<i;n++){var o=s.charCodeAt(n),a=null;o<128?t++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Ze(a)||(t>e&&(r+=s.substring(e,t)),r+=a,e=t=n+1)}return t>e&&(r+=s.substring(e,s.length)),r},xb=!!Jo||!!Yo,Ad="text/plain",sr=function(s,e,t){var i;t===void 0&&(t=!0);var[n,r]=s.split("?"),o=k({},e),a=(i=r?.split("&").map((c=>{var u,[h,g]=c.split("="),f=t&&(u=o[h])!==null&&u!==void 0?u:g;return delete o[h],h+"="+f})))!==null&&i!==void 0?i:[],l=wb(o);return l&&a.push(l),n+"?"+a.join("&")},Ei=(s,e)=>JSON.stringify(s,((t,i)=>typeof i=="bigint"?i.toString():i),e),Bo=s=>{var{data:e,compression:t}=s;if(e){if(t===yt.GZipJS){var i=Nb((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var h=new We(l.length+(l.length>>>1)),g=0,f=function(b){h[g++]=b},p=0;p<u;++p){if(g+5>h.length){var v=new We(g+8+(u-p<<1));v.set(h),h=v}var _=l.charCodeAt(p);_<128||c?f(_):_<2048?(f(192|_>>>6),f(128|63&_)):_>55295&&_<57344?(f(240|(_=65536+(1047552&_)|1023&l.charCodeAt(++p))>>>18),f(128|_>>>12&63),f(128|_>>>6&63),f(128|63&_)):(f(224|_>>>12),f(128|_>>>6&63),f(128|63&_))}return Ph(h,0,g)})(Ei(e)),{mtime:0}),n=new Blob([i],{type:Ad});return{contentType:Ad,body:n,estimatedSize:n.size}}if(t===yt.Base64){var r=(function(l){var c,u,h,g,f,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,_=0,b="",E=[];if(!l)return l;l=Db(l);do c=(f=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=f>>12&63,h=f>>6&63,g=63&f,E[_++]=p.charAt(c)+p.charAt(u)+p.charAt(h)+p.charAt(g);while(v<l.length);switch(b=E.join(""),l.length%3){case 1:b=b.slice(0,-2)+"==";break;case 2:b=b.slice(0,-1)+"="}return b})(Ei(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Ei(l)))(r);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Ei(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Bn=[];Yo&&Bn.push({transport:"fetch",method:s=>{var e,t,{contentType:i,body:n,estimatedSize:r}=(e=Bo(s))!==null&&e!==void 0?e:{},o=new Headers;Z(s.headers,(function(u,h){o.append(h,u)})),i&&o.append("Content-Type",i);var a=s.url,l=null;if(td){var c=new td;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),s.timeout)}}Yo(a,k({method:s?.method||"GET",headers:o,keepalive:s.method==="POST"&&(r||0)<52428.8,body:n,signal:(t=l)==null?void 0:t.signal},s.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)}s.callback==null||s.callback(g)})))).catch((u=>{A.error(u),s.callback==null||s.callback({statusCode:0,error:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Jo&&Bn.push({transport:"XHR",method:s=>{var e,t=new Jo;t.open(s.method||"GET",s.url,!0);var{contentType:i,body:n}=(e=Bo(s))!==null&&e!==void 0?e:{};Z(s.headers,(function(r,o){t.setRequestHeader(o,r)})),i&&t.setRequestHeader("Content-Type",i),s.timeout&&(t.timeout=s.timeout),s.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var r={statusCode:t.status,text:t.responseText};if(t.status===200)try{r.json=JSON.parse(t.responseText)}catch{}s.callback==null||s.callback(r)}},t.send(n)}}),Ve!=null&&Ve.sendBeacon&&Bn.push({transport:"sendBeacon",method:s=>{var e=sr(s.url,{beacon:"1"});try{var t,{contentType:i,body:n}=(t=Bo(s))!==null&&t!==void 0?t:{},r=typeof n=="string"?new Blob([n],{type:i}):n;Ve.sendBeacon(e,r)}catch{}}});ir=function(s,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(s)}catch{return!1}};Nh={exact:(s,e)=>e.some((t=>s.some((i=>t===i)))),is_not:(s,e)=>e.every((t=>s.every((i=>t!==i)))),regex:(s,e)=>e.some((t=>s.some((i=>ir(t,i))))),not_regex:(s,e)=>e.every((t=>s.every((i=>!ir(t,i))))),icontains:(s,e)=>e.map(Mn).some((t=>s.map(Mn).some((i=>t.includes(i))))),not_icontains:(s,e)=>e.map(Mn).every((t=>s.map(Mn).every((i=>!t.includes(i))))),gt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((n=>i>parseFloat(n)))})),lt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((n=>i<parseFloat(n)))}))},Mn=s=>s.toLowerCase();Vo=le("[Error tracking]"),xa=class{constructor(e){var t,i;this.nt=[],this.ot=new ra([new aa,new ga,new ca,new la,new ha,new da,new ua,new fa],ab()),this._instance=e,this.nt=(t=(i=this._instance.persistence)==null?void 0:i.get_property(va))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,i,n;if("errorTracking"in e){var r=(t=(i=e.errorTracking)==null?void 0:i.suppressionRules)!==null&&t!==void 0?t:[],o=(n=e.errorTracking)==null?void 0:n.captureExtensionExceptions;this.nt=r,this._instance.persistence&&this._instance.persistence.register({[va]:this.nt,[gd]:o})}}get ut(){var e,t=!!this._instance.get_property(gd),i=this._instance.config.error_tracking.captureExtensionExceptions;return(e=i??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ot.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ht(t)){if(this.dt(t))return void Vo.info("Skipping exception capture because a suppression rule matched");if(!this.ut&&this.vt(t))return void Vo.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ct(t))return void Vo.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",ft:!0})}dt(e){if(e.length===0)return!1;var t=e.reduce(((i,n)=>{var{type:r,value:o}=n;return he(r)&&r.length>0&&i.$exception_types.push(r),he(o)&&o.length>0&&i.$exception_values.push(o),i}),{$exception_types:[],$exception_values:[]});return this.nt.some((i=>{var n=i.values.map((r=>{var o,a=Nh[r.operator],l=q(r.value)?r.value:[r.value],c=(o=t[r.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)}));return i.type==="OR"?n.some(Boolean):n.every(Boolean)}))}vt(e){return e.flatMap((t=>{var i,n;return(i=(n=t.stacktrace)==null?void 0:n.frames)!==null&&i!==void 0?i:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ct(e){if(e.length>0){var t,i,n,r,o=(t=(i=e[0].stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(n=a==null||(r=a.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&n!==void 0&&n}return!1}ht(e){return!U(e)&&q(e)}},Fn="https?://(.*)",Fs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Lb=$s(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Fs),Ni="<masked>",$b=["li_fat_id"];De=le("[FeatureFlags]"),di=le("[FeatureFlags]",{debugEnabled:!0}),Ub="errors_while_computing_flags",Bb="flag_missing",Vb="quota_limited",Gb="timeout",jb="connection_error",Hb="unknown_error",qb=s=>"api_error_"+s,Go="$active_feature_flags",As="$override_feature_flags",Rd="$feature_flag_payloads",hi="$override_feature_flag_payloads",Od="$feature_flag_request_id",Cd=s=>{var e={};for(var[t,i]of Un(s||{}))i&&(e[t]=i);return e},zb=s=>{var e=s.flags;return e?(s.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,(i=e[t].variant)!==null&&i!==void 0?i:e[t].enabled]}))),s.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return(i=e[t].metadata)==null?void 0:i.payload})).map((t=>{var i;return[t,(i=e[t].metadata)==null?void 0:i.payload]})))):De.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),s},Kb=(function(s){return s.FeatureFlags="feature_flags",s.Recordings="recordings",s})({}),La=class{constructor(e){this._t=!1,this.bt=!1,this.yt=!1,this.wt=!1,this.xt=!1,this.$t=!1,this.Et=!1,this.St=!1,this._instance=e,this.featureFlagEventHandlers=[]}kt(){var e,t;return(e=(t=this._instance.persistence)==null?void 0:t.Pt(this._instance.config.feature_flag_cache_ttl_ms))!==null&&e!==void 0&&e}Tt(){return!!this.kt()&&(this.St||this.yt||(this.St=!0,De.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Ct(){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.Et||(De.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Et=!0),t!=null&&t.length?t.filter((i=>{var n=i&&typeof i=="string"&&i.trim().length>0;return n||De.error("Invalid evaluation context found:",i,"Expected non-empty string"),n})):[]}It(){return this.Ct().length>0}get hasLoadedFlags(){return this.bt}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(_a),t=this._instance.get_property(As),i=this._instance.get_property(hi);if(!i&&!t)return e||{};var n=ue({},e||{}),r=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var o of r){var a,l,c=n[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=i?.[o],p=k({},c,{enabled:h,variant:h?g??c?.variant:void 0});h!==c?.enabled&&(p.original_enabled=c?.enabled),g!==c?.variant&&(p.original_variant=c?.variant),f&&(p.metadata=k({},c?.metadata,{payload:f,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),n[o]=p}return this._t||(De.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:n}),this._t=!0),n}getFlagVariants(){var e=this._instance.get_property(Ps),t=this._instance.get_property(As);if(!t)return e||{};for(var i=ue({},e),n=Object.keys(t),r=0;r<n.length;r++)i[n[r]]=t[n[r]];return this._t||(De.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._t=!0),i}getFlagPayloads(){var e=this._instance.get_property(Rd),t=this._instance.get_property(hi);if(!t)return e||{};for(var i=ue({},e||{}),n=Object.keys(t),r=0;r<n.length;r++)i[n[r]]=t[n[r]];return this._t||(De.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._t=!0),i}reloadFeatureFlags(){this.wt||this._instance.config.advanced_disable_feature_flags||this.Rt||(this._instance.Ft.emit("featureFlagsReloading",!0),this.Rt=setTimeout((()=>{this.Ot()}),5))}Mt(){clearTimeout(this.Rt),this.Rt=void 0}ensureFlagsLoaded(){this.bt||this.yt||this.Rt||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.wt=e}Ot(e){var t;if(this.Mt(),!this._instance.At())if(this.yt)this.xt=!0;else{var i=this._instance.config.token,n=this._instance.get_property("$device_id"),r={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:k({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(bi)||{}),group_properties:this._instance.get_property(Yt),timezone:Bh()};Ze(n)||w(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.It()&&(r.evaluation_contexts=this.Ct());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.yt=!0,this._instance._send_request({method:"POST",url:a,data:r,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.xt||(this.$anon_distinct_id=void 0),g=!1),this.yt=!1,!r.disable_flags||this.xt){this.$t=!g;var f=[];l.error?l.error instanceof Error?f.push(l.error.name==="AbortError"?Gb:jb):f.push(Hb):l.statusCode!==200&&f.push(qb(l.statusCode)),(c=l.json)!=null&&c.errorsWhileComputingFlags&&f.push(Ub);var p=!((u=l.json)==null||(u=u.quotaLimited)==null||!u.includes(Kb.FeatureFlags));if(p&&f.push(Vb),(h=this._instance.persistence)==null||h.register({[ya]:f}),p)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=l.json)!==null&&v!==void 0?v:{},g),this.xt&&(this.xt=!1,this.Ot())}}}})}}getFeatureFlag(e,t){var i;if(t===void 0&&(t={}),!t.fresh||this.$t)if(this.bt||this.getFlags()&&this.getFlags().length>0){if(!this.Tt()){var n=this.getFeatureFlagResult(e,t);return(i=n?.variant)!==null&&i!==void 0?i:n?.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.$t)if(this.bt||this.getFlags()&&this.getFlags().length>0){if(!this.Tt()){var i=this.getFlagVariants(),n=e in i,r=i[e],o=this.getFlagPayloads()[e],a=String(r),l=this._instance.get_property(Od)||void 0,c=this._instance.get_property(zn)||void 0,u=this._instance.get_property(qn)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var h,g,f,p,v,_,b,E,C,P;q(u[e])?u[e].push(a):u[e]=[a],(h=this._instance.persistence)==null||h.register({[qn]:u});var I=this.getFeatureFlagDetails(e),z=[...(g=this._instance.get_property(ya))!==null&&g!==void 0?g:[]];w(r)&&z.push(Bb);var B={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((f=this._instance.config.bootstrap)==null||(f=f.featureFlags)==null?void 0:f[e])||null,$feature_flag_bootstrapped_payload:((p=this._instance.config.bootstrap)==null||(p=p.featureFlagPayloads)==null?void 0:p[e])||null,$used_bootstrap_value:!this.$t};w(I==null||(v=I.metadata)==null?void 0:v.version)||(B.$feature_flag_version=I.metadata.version);var N,ve=(_=I==null||(b=I.reason)==null?void 0:b.description)!==null&&_!==void 0?_:I==null||(E=I.reason)==null?void 0:E.code;ve&&(B.$feature_flag_reason=ve),I!=null&&(C=I.metadata)!=null&&C.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(n){var _e=o;if(!w(o))try{_e=JSON.parse(o)}catch{}return{key:e,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:_e}}}}else De.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var i=this._instance.config.token,n={distinct_id:this._instance.get_distinct_id(),token:i};this.It()&&(n.evaluation_contexts=this.Ct()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:n,compression:this._instance.config.disable_compression?void 0:yt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:r=>{var o,a=(o=r.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.$t){if(this.bt||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return w(i)?void 0:!!i}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.bt=!0;var i=this.getFlagVariants(),n=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var h=zb(o),g=h.flags,f=h.featureFlags,p=h.featureFlagPayloads;if(f){var v=o.requestId,_=o.evaluatedAt;if(q(f)){De.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var b={};if(f)for(var E=0;E<f.length;E++)b[f[E]]=!0;a&&a.register({[Go]:f,[Ps]:b})}else{var C=f,P=p,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)})));C=k({},l,Object.fromEntries(Object.entries(C).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 C=k({},l,C),P=k({},c,P),I=k({},u,I);a&&a.register(k({[Go]:Object.keys(Cd(C)),[Ps]:C||{},[Rd]:P||{},[_a]:I||{}},v?{[Od]:v}:{},_?{[zn]:_}:{}))}}})(e,this._instance.persistence,i,n,r),t||(this.St=!1),this.Dt(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(As),this._instance.persistence.unregister(hi),this.Dt(),di.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,i=e;if(this._t=!!((t=i.suppressWarning)!==null&&t!==void 0&&t),"flags"in i){if(i.flags===!1)this._instance.persistence.unregister(As),di.info("Flag overrides cleared");else if(i.flags){if(q(i.flags)){for(var n={},r=0;r<i.flags.length;r++)n[i.flags[r]]=!0;this._instance.persistence.register({[As]:n})}else this._instance.persistence.register({[As]:i.flags});di.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this._instance.persistence.unregister(hi),di.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[hi]:i.payloads}),di.info("Payload overrides set",{payloads:i.payloads}))),void this.Dt()}this.Dt()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.bt){var{flags:t,flagVariants:i}=this.jt();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var n,r=(this._instance.get_property(yi)||[]).find((c=>c.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};r&&(a.$early_access_feature_name=r.name),i&&(a.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=k({},this.getFlagVariants(),{[e]:t});(n=this._instance.persistence)==null||n.register({[Go]:Object.keys(Cd(l)),[Ps]:l}),this.Dt()}getEarlyAccessFeatures(e,t,i){t===void 0&&(t=!1);var n=this._instance.get_property(yi),r=i?"&"+i.map((o=>"stage="+o)).join("&"):"";if(n&&!t)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+r),method:"GET",callback:o=>{var a,l;if(o.json){var c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(yi),(l=this._instance.persistence)==null||l.register({[yi]:c}),e(c)}}})}jt(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((i=>t[i])),flagVariants:Object.keys(t).filter((i=>t[i])).reduce(((i,n)=>(i[n]=t[n],i)),{})}}Dt(e){var{flags:t,flagVariants:i}=this.jt();this.featureFlagEventHandlers.forEach((n=>n(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(bi)||{};this._instance.register({[bi]:k({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(bi)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(Yt)||{};Object.keys(i).length!==0&&Object.keys(i).forEach((n=>{i[n]=k({},i[n],e[n]),delete e[n]})),this._instance.register({[Yt]:k({},i,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.bt=!1,this.yt=!1,this.wt=!1,this.xt=!1,this.$t=!1,this.$anon_distinct_id=void 0,this.Mt(),this._t=!1}},Wb=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ai=class{constructor(e,t){this.N=e,this.props={},this.Lt=!1,this.Nt=(i=>{var n="";return i.token&&(n=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+n+"_posthog"})(e),this.B=this.Ut(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.zt}Ut(e){Wb.indexOf(e.persistence.toLowerCase())===-1&&(A.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(n){n===void 0&&(n=[]);var r=[...yb,...n];return k({},ae,{D:function(o){try{var a={};try{a=ot.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,c,u,h){try{ae.j(o,a,void 0,void 0,h);var g={};r.forEach((f=>{a[f]&&(g[f]=a[f])})),Object.keys(g).length&&ot.j(o,g,l,c,u,h)}catch(f){ae.M(f)}},L:function(o,a){try{m?.localStorage.removeItem(o),ot.L(o,a)}catch(l){ae.M(l)}}})})(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return i==="localstorage"&&ae.O()?ae:i==="localstorage+cookie"&&t.O()?t:i==="sessionstorage"&&ye.O()?ye:i==="memory"?bb:i==="cookie"?ot:t.O()?t:ot}Pt(e){var t=e??this.N.feature_flag_cache_ttl_ms;if(!t||t<=0)return!1;var i=this.props[zn];return!i||typeof i!="number"||Date.now()-i>t}properties(){var e={};return Z(this.props,((t,i)=>{if(i===Ps&&fe(t)){if(!this.Pt())for(var n=Object.keys(t),r=0;r<n.length;r++)e["$feature/"+n[r]]=t[n[r]]}else a=i,l=!1,(Ze(o=pb)?l:ed&&o.indexOf===ed?o.indexOf(a)!=-1:(Z(o,(function(c){if(l||(l=c===a))return jn})),l))||(e[i]=t);var o,a,l})),e}load(){if(!this.zt){var e=this.B.D(this.Nt);e&&(this.props=ue({},e))}}save(){this.zt||this.B.j(this.Nt,this.props,this.Ht,this.Bt,this.qt,this.N.debug)}remove(){this.B.L(this.Nt,!1),this.B.L(this.Nt,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(fe(e)){w(t)&&(t="None"),this.Ht=w(i)?this.Wt:i;var n=!1;if(Z(e,((r,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=r,n=!0)})),n)return this.save(),!0}return!1}register(e,t){if(fe(e)){this.Ht=w(t)?this.Wt:t;var i=!1;if(Z(e,((n,r)=>{e.hasOwnProperty(r)&&this.props[r]!==n&&(this.props[r]=n,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Lt){var e=xh(this.N.custom_campaign_params,this.N.mask_personal_data_properties,this.N.custom_personal_data_properties);Cs(rl(e))||this.register(e),this.Lt=!0}}update_search_keyword(){var e;this.register((e=S?.referrer)?$h(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Mh(),$referring_domain:S!=null&&S.referrer&&((e=Yn(S.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[ka]||this.props[Sa]||this.register_once({[Kn]:Fh(this.N.mask_personal_data_properties,this.N.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Z([Sa,ka],(o=>{var a=this.props[o];a&&Z(a,(function(l,c){e["$initial_"+Qo(c)]=l}))}));var t,i,n=this.props[Kn];if(n){var r=(t=Uh(n),i={},Z(t,(function(o,a){i["$initial_"+Qo(a)]=o})),i);ue(e,r)}return e}safe_merge(e){return Z(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this.Wt=this.Ht=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((u,h)=>u===c[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var n=this.Ut(e),r=this.props;this.clear(),this.B=n,this.props=r,this.save()}}set_disabled(e){this.zt=e,this.zt?this.remove():this.save()}set_cross_subdomain(e){e!==this.Bt&&(this.Bt=e,this.remove(),this.save())}set_secure(e){e!==this.qt&&(this.qt=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[mi]||{};i[e]=t,this.props[mi]=i,this.save()}remove_event_timer(e){var t=(this.props[mi]||{})[e];return w(t)||(delete this.props[mi][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},fi=(function(s){return s.Activation="events",s.Cancellation="cancelEvents",s})({}),hk=(function(s){return s.Button="button",s.Tab="tab",s.Selector="selector",s})({}),fk=(function(s){return s.TopLeft="top_left",s.TopRight="top_right",s.TopCenter="top_center",s.MiddleLeft="middle_left",s.MiddleRight="middle_right",s.MiddleCenter="middle_center",s.Left="left",s.Center="center",s.Right="right",s.NextToTrigger="next_to_trigger",s})({}),gk=(function(s){return s.Top="top",s.Left="left",s.Right="right",s.Bottom="bottom",s})({}),jo=(function(s){return s.Popover="popover",s.API="api",s.Widget="widget",s.ExternalSurvey="external_survey",s})({}),pk=(function(s){return s.Open="open",s.MultipleChoice="multiple_choice",s.SingleChoice="single_choice",s.Rating="rating",s.Link="link",s})({}),vk=(function(s){return s.NextQuestion="next_question",s.End="end",s.ResponseBased="response_based",s.SpecificQuestion="specific_question",s})({}),_k=(function(s){return s.Once="once",s.Recurring="recurring",s.Always="always",s})({}),ki=(function(s){return s.SHOWN="survey shown",s.DISMISSED="survey dismissed",s.SENT="survey sent",s.ABANDONED="survey abandoned",s})({}),Ho=(function(s){return s.SURVEY_ID="$survey_id",s.SURVEY_NAME="$survey_name",s.SURVEY_RESPONSE="$survey_response",s.SURVEY_ITERATION="$survey_iteration",s.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",s.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",s.SURVEY_SUBMISSION_ID="$survey_submission_id",s.SURVEY_QUESTIONS="$survey_questions",s.SURVEY_COMPLETED="$survey_completed",s.PRODUCT_TOUR_ID="$product_tour_id",s.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",s})({}),$a=(function(s){return s.Popover="popover",s.Inline="inline",s})({}),J=le("[Surveys]"),Vh="seenSurvey_",Xb=(s,e)=>{var t="$survey_"+e+"/"+s.id;return s.current_iteration&&s.current_iteration>0&&(t="$survey_"+e+"/"+s.id+"/"+s.current_iteration),t},Pd=s=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(Vh,s),Yb=[jo.Popover,jo.Widget,jo.API],Jb={ignoreConditions:!1,ignoreDelay:!1,displayType:$a.Popover},Di=class{constructor(){this.Gt={},this.Gt={}}on(e,t){return this.Gt[e]||(this.Gt[e]=[]),this.Gt[e].push(t),()=>{this.Gt[e]=this.Gt[e].filter((i=>i!==t))}}emit(e,t){for(var i of this.Gt[e]||[])i(t);for(var n of this.Gt["*"]||[])n(e,t)}};Ma=class{constructor(e){this.Vt=new Di,this.Jt=(t,i)=>this.Kt(t,i)&&this.Yt(t,i)&&this.Xt(t,i)&&this.Qt(t,i),this.Kt=(t,i)=>i==null||!i.event||t?.event===i?.event,this._instance=e,this.Zt=new Set,this.ti=new Set}init(){var e;if(!w((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((i,n)=>{this.on(i,n)}))}}register(e){var t,i;if(!w((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.ti)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.Zt)==null||u.add(c?.event||"")}))})),(i=this._instance)!=null&&i.autocapture)){var n,r=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&r.add(l?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){var i;t!=null&&e.length!=0&&(this.Zt.has(e)||this.Zt.has(t?.event))&&this.ti&&((i=this.ti)==null?void 0:i.size)>0&&this.ti.forEach((n=>{this.ii(t,n)&&this.Vt.emit("actionCaptured",n.name)}))}ei(e){this.onAction("actionCaptured",(t=>e(t)))}ii(e,t){if(t?.steps==null)return!1;for(var i of t.steps)if(this.Jt(e,i))return!0;return!1}onAction(e,t){return this.Vt.on(e,t)}Yt(e,t){if(t!=null&&t.url){var i,n=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!n||typeof n!="string"||!Ts(n,t.url,t.url_matching||"contains"))return!1}return!0}Xt(e,t){return!!this.ri(e,t)&&!!this.si(e,t)&&!!this.ni(e,t)}ri(e,t){var i;if(t==null||!t.href)return!0;var n=this.oi(e);if(n.length>0)return n.some((a=>Ts(a.href,t.href,t.href_matching||"exact")));var r,o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!o&&Ts((r=o.match(/(?::|")href="(.*?)"/))?r[1]:"",t.href,t.href_matching||"exact")}si(e,t){var i;if(t==null||!t.text)return!0;var n=this.oi(e);if(n.length>0)return n.some((c=>Ts(c.text,t.text,t.text_matching||"exact")||Ts(c.$el_text,t.text,t.text_matching||"exact")));var r,o,a,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(r=(function(c){for(var u,h=[],g=/(?::|")text="(.*?)"/g;!U(u=g.exec(c));)h.includes(u[1])||h.push(u[1]);return h})(l),o=t.text,a=t.text_matching||"exact",r.some((c=>Ts(c,o,a))))}ni(e,t){var i,n;if(t==null||!t.selector)return!0;var r=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(r!=null&&r.includes(t.selector))return!0;var o=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}oi(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Qt(e,t){return t==null||!t.properties||t.properties.length===0||Dh(t.properties.reduce(((i,n)=>{var r=q(n.value)?n.value.map(String):n.value!=null?[String(n.value)]:[];return i[n.key]={values:r,operator:n.operator||"exact"},i}),{}),e?.properties)}},Fa=class{constructor(e){this._instance=e,this.ai=new Map,this.li=new Map,this.ui=new Map}hi(e,t){return!!e&&Dh(e.propertyFilters,t?.properties)}di(e,t){var i=new Map;return e.forEach((n=>{var r;(r=n.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((o=>{if(o!=null&&o.name){var a=i.get(o.name)||[];a.push(n.id),i.set(o.name,a)}}))})),i}vi(e,t,i){var n=(i===fi.Activation?this.ai:this.li).get(e),r=[];return this.ci((o=>{r=o.filter((a=>n?.includes(a.id)))})),r.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[i])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.hi(l,t)}))}register(e){var t;w((t=this._instance)==null?void 0:t._addCaptureHook)||(this.fi(e),this.pi(e))}pi(e){var t=e.filter((i=>{var n,r;return((n=i.conditions)==null?void 0:n.actions)&&((r=i.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0}));t.length!==0&&(this.gi==null&&(this.gi=new Ma(this._instance),this.gi.init(),this.gi.ei((i=>{this.onAction(i)}))),t.forEach((i=>{var n,r,o,a,l;i.conditions&&(n=i.conditions)!=null&&n.actions&&(r=i.conditions)!=null&&(r=r.actions)!=null&&r.values&&((o=i.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.gi)==null||a.register(i.conditions.actions.values),(l=i.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.ui.get(c.name);u&&u.push(i.id),this.ui.set(c.name,u||[i.id])}})))})))}fi(e){var t,i=e.filter((r=>{var o,a;return((o=r.conditions)==null?void 0:o.events)&&((a=r.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),n=e.filter((r=>{var o,a;return((o=r.conditions)==null?void 0:o.cancelEvents)&&((a=r.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(i.length!==0||n.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((r,o)=>{this.onEvent(r,o)})),this.ai=this.di(e,fi.Activation),this.li=this.di(e,fi.Cancellation))}onEvent(e,t){var i,n=this.mi(),r=this.bi(),o=this.yi(),a=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[r])||[];if(o===e&&t&&a.length>0){var l,c;n.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var h=a.indexOf(u);h>=0&&(a.splice(h,1),this.wi(a))}}else{if(this.li.has(e)){var g=this.vi(e,t,fi.Cancellation);g.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:g.map((p=>p.id))}),g.forEach((p=>{var v=a.indexOf(p.id);v>=0&&a.splice(v,1),this.xi(p.id)})),this.wi(a))}if(this.ai.has(e)){n.info("event name matched",{event:e,eventPayload:t,items:this.ai.get(e)});var f=this.vi(e,t,fi.Activation);this.wi(a.concat(f.map((p=>p.id))||[]))}}}onAction(e){var t,i=this.bi(),n=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[i])||[];this.ui.has(e)&&this.wi(n.concat(this.ui.get(e)||[]))}wi(e){var t,i=this.mi(),n=this.bi(),r=[...new Set(e)].filter((o=>!this.$i(o)));i.info("updating activated items",{activatedItems:r}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[n]:r})}getActivatedIds(){var e,t=this.bi(),i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return i||[]}getEventToItemsMap(){return this.ai}Ei(){return this.gi}},Ua=class extends Fa{constructor(e){super(e)}bi(){return"$surveys_activated"}yi(){return ki.SHOWN}ci(e){var t;(t=this._instance)==null||t.getSurveys(e)}xi(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}mi(){return J}$i(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ba=class{constructor(e){this.Si=void 0,this._surveyManager=null,this.ki=!1,this.Pi=[],this.Ti=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(U(t))return J.warn("Flags not loaded yet. Not loading surveys.");var i=q(t);this.Si=i?t.length>0:t,J.info("flags response received, isSurveysEnabled: "+this.Si),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(i!=null&&i.startsWith(Vh)||i!=null&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((n=>localStorage.removeItem(n)))}loadIfEnabled(){if(!this._surveyManager)if(this.ki)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 e=O?.__PosthogExtensions__;if(e){if(!w(this.Si)||this._instance.config.advanced_enable_surveys){var t=this.Si||this._instance.config.advanced_enable_surveys;this.ki=!0;try{var i=e.generateSurveys;if(i)return void this.Ci(i,t);var n=e.loadExternalDependency;if(!n)return void this.Ii("PostHog loadExternalDependency extension not found.");n(this._instance,"surveys",(r=>{r||!e.generateSurveys?this.Ii("Could not load surveys script",r):this.Ci(e.generateSurveys,t)}))}catch(r){throw this.Ii("Error initializing surveys",r),r}finally{this.ki=!1}}}else J.error("PostHog Extensions not found.")}}Ci(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ua(this._instance),J.info("Surveys loaded successfully"),this.Ri({isLoaded:!0})}Ii(e,t){J.error(e,t),this.Ri({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Pi.push(e),this._surveyManager&&this.Ri({isLoaded:!0}),()=>{this.Pi=this.Pi.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return J.info("Disabled. Not loading surveys."),e([]);var i,n=this._instance.get_property(ma);if(n&&!t)return e(n,{isLoaded:!0});typeof Promise<"u"&&this.Ti?this.Ti.then((r=>{var{surveys:o,context:a}=r;return e(o,a)})):(typeof Promise<"u"&&(this.Ti=new Promise((r=>{i=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:r=>{var o;this.Ti=null;var a=r.statusCode;if(a!==200||!r.json){var l="Surveys API could not be loaded, status: "+a;J.error(l);var c={isLoaded:!1,error:l};return e([],c),void(i==null||i({surveys:[],context:c}))}var u,h=r.json.surveys||[],g=h.filter((p=>(function(v){return!(!v.start_date||v.end_date)})(p)&&((function(v){var _;return!((_=v.conditions)==null||(_=_.events)==null||(_=_.values)==null||!_.length)})(p)||(function(v){var _;return!((_=v.conditions)==null||(_=_.actions)==null||(_=_.values)==null||!_.length)})(p))));g.length>0&&((u=this._surveyEventReceiver)==null||u.register(g)),(o=this._instance.persistence)==null||o.register({[ma]:h});var f={isLoaded:!0};e(h,f),i?.({surveys:h,context:f})}}))}Ri(e){for(var t of this.Pi)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){J.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!U(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);J.warn("init was not called")}Fi(e){var t=null;return this.getSurveys((i=>{var n;t=(n=i.find((r=>r.id===e)))!==null&&n!==void 0?n:null})),t}Oi(e){if(U(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.Fi(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(U(this._surveyManager))return J.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.Oi(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return U(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((i=>{this.getSurveys((n=>{var r,o=(r=n.find((l=>l.id===e)))!==null&&r!==void 0?r:null;if(o){var a=this.Oi(o);i({visible:a.eligible,disabledReason:a.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var n;if(U(this._surveyManager))J.warn("init was not called");else{var r=typeof e=="string"?this.Fi(e):e;if(r!=null&&r.id)if(Yb.includes(r.type)){var o=S?.querySelector(t);if(o)return(n=r.appearance)!=null&&n.surveyPopupDelaySeconds?(J.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,l;J.info("Rendering survey "+r.id+" with delay of "+((a=r.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(r,o,i),J.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,o,i);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(e,t){var i;if(U(this._surveyManager))J.warn("init was not called");else{var n=this.Fi(e);if(n){var r=n;if((i=n.appearance)!=null&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(r=k({},n,{appearance:k({},n.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==$a.Popover&&t.initialResponses&&J.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(n);if(!o.visible)return void J.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==$a.Inline?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}else J.warn("Survey not found")}}cancelPendingSurvey(e){U(this._surveyManager)?J.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},ze=le("[Conversations]"),Va=class{constructor(e){this.Mi=void 0,this._conversationsManager=null,this.Ai=!1,this.Di=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;U(t)||(kt(t)?this.Mi=t:(this.Mi=t.enabled,this.Di=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Mi=void 0,this.Di=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ai||this._instance.config.disable_conversations||bh(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=O?.__PosthogExtensions__;if(e&&!w(this.Mi)&&this.Mi)if(this.Di&&this.Di.token){this.Ai=!0;try{var t=e.initConversations;if(t)return this.ji(t),void(this.Ai=!1);var i=e.loadExternalDependency;if(!i)return void this.Li("PostHog loadExternalDependency extension not found.");i(this._instance,"conversations",(n=>{n||!e.initConversations?this.Li("Could not load conversations script",n):this.ji(e.initConversations),this.Ai=!1}))}catch(n){this.Li("Error initializing conversations",n),this.Ai=!1}}else ze.error("Conversations enabled but missing token in remote config.")}}ji(e){if(this.Di)try{this._conversationsManager=e(this.Di,this._instance),ze.info("Conversations loaded successfully")}catch(t){this.Li("Error completing conversations initialization",t)}else ze.error("Cannot complete initialization: remote config is null")}Li(e,t){ze.error(e,t),this._conversationsManager=null,this.Ai=!1}show(){this._conversationsManager?this._conversationsManager.show():ze.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Mi===!0&&!Ze(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,i){var n=this;return _t((function*(){return n._conversationsManager?n._conversationsManager.sendMessage(e,t,i):(ze.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var i=this;return _t((function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(ze.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(ze.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(ze.warn("Conversations not available yet."),null)}))()}requestRestoreLink(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(ze.warn("Conversations not available yet."),null)}))()}restoreFromToken(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(ze.warn("Conversations not available yet."),null)}))()}restoreFromUrlToken(){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(ze.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},Qb=(function(s){return s.SHOWN="product tour shown",s.DISMISSED="product tour dismissed",s.COMPLETED="product tour completed",s.STEP_SHOWN="product tour step shown",s.STEP_COMPLETED="product tour step completed",s.BUTTON_CLICKED="product tour button clicked",s.STEP_SELECTOR_FAILED="product tour step selector failed",s.BANNER_CONTAINER_SELECTOR_FAILED="product tour banner container selector failed",s.BANNER_ACTION_CLICKED="product tour banner action clicked",s})({}),Nd=(function(s){return s.TOUR_ID="$product_tour_id",s.TOUR_NAME="$product_tour_name",s.TOUR_ITERATION="$product_tour_iteration",s.TOUR_RENDER_REASON="$product_tour_render_reason",s.TOUR_STEP_ID="$product_tour_step_id",s.TOUR_STEP_ORDER="$product_tour_step_order",s.TOUR_STEP_TYPE="$product_tour_step_type",s.TOUR_DISMISS_REASON="$product_tour_dismiss_reason",s.TOUR_BUTTON_TEXT="$product_tour_button_text",s.TOUR_BUTTON_ACTION="$product_tour_button_action",s.TOUR_BUTTON_LINK="$product_tour_button_link",s.TOUR_BUTTON_TOUR_ID="$product_tour_button_tour_id",s.TOUR_STEPS_COUNT="$product_tour_steps_count",s.TOUR_STEP_SELECTOR="$product_tour_step_selector",s.TOUR_STEP_SELECTOR_FOUND="$product_tour_step_selector_found",s.TOUR_STEP_ELEMENT_TAG="$product_tour_step_element_tag",s.TOUR_STEP_ELEMENT_ID="$product_tour_step_element_id",s.TOUR_STEP_ELEMENT_CLASSES="$product_tour_step_element_classes",s.TOUR_STEP_ELEMENT_TEXT="$product_tour_step_element_text",s.TOUR_ERROR="$product_tour_error",s.TOUR_MATCHES_COUNT="$product_tour_matches_count",s.TOUR_FAILURE_PHASE="$product_tour_failure_phase",s.TOUR_WAITED_FOR_ELEMENT="$product_tour_waited_for_element",s.TOUR_WAIT_DURATION_MS="$product_tour_wait_duration_ms",s.TOUR_BANNER_SELECTOR="$product_tour_banner_selector",s.TOUR_LINKED_SURVEY_ID="$product_tour_linked_survey_id",s.USE_MANUAL_SELECTOR="$use_manual_selector",s.INFERENCE_DATA_PRESENT="$inference_data_present",s.TOUR_LAST_SEEN_DATE="$product_tour_last_seen_date",s.TOUR_TYPE="$product_tour_type",s})({}),Ga=class{constructor(e){var t;this.Ni=!1,this.Ui=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Ni=!0)}onRemoteConfig(e){var t,i=(t=e.logs)==null?void 0:t.captureConsoleLogs;!U(i)&&i&&(this.Ni=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Ni&&!this.Ui){var e=le("[logs]"),t=O?.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",(n=>{var r;n||(r=t.logs)==null||!r.initializeLogs?e.error("Could not load logs script",n):(t.logs.initializeLogs(this._instance),this.Ui=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},Dd=le("[RateLimiter]"),ja=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((n=>{Dd.info((n||"events")+" is quota limited."),this.serverLimits[n]=new Date().getTime()+6e4}))}catch(n){return void Dd.warn('could not rate limit - continuing. Error: "'+n?.message+'"',{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,n;e===void 0&&(e=!1);var{captureEventsBurstLimit:r,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(Ea))!==null&&t!==void 0?t:{tokens:r,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>r&&(l.tokens=r);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(n=this.instance.persistence)==null||n.set_property(Ea,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},gi=le("[RemoteConfig]"),nr=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}zi(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Hi(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 gi.info("Using preloaded remote config",this.remoteConfig),this.Bi(this.remoteConfig),void this.qi();if(this._instance.At())return void gi.warn("Remote config is disabled. Falling back to local config.");this.zi((e=>{if(!e)return gi.info("No config found after loading remote JS config. Falling back to JSON."),void this.Hi((t=>{this.Bi(t),this.qi()}));this.Bi(e),this.qi()}))}catch(e){gi.error("Error loading remote config",e)}}stop(){this.Wi&&(clearInterval(this.Wi),this.Wi=void 0)}refresh(){this._instance.At()||S?.visibilityState==="hidden"||this._instance.featureFlags.reloadFeatureFlags()}qi(){var e;if(!this.Wi){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.Wi=setInterval((()=>{this.refresh()}),t))}}Bi(e){e||gi.error("Failed to fetch remote config from PostHog."),this._instance.Bi(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||this._instance.featureFlags.ensureFlagsLoaded())}},Ha=3e3,qa=class{constructor(e,t){this.Gi=!0,this.Vi=[],this.Ji=at(t?.flush_interval_ms||Ha,250,5e3,A.createLogger("flush interval"),Ha),this.Ki=e}enqueue(e){this.Vi.push(e),this.Yi||this.Xi()}unload(){this.Qi();var e=this.Vi.length>0?this.Zi():{},t=Object.values(e);[...t.filter((i=>i.url.indexOf("/e")===0)),...t.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.Ki(k({},i,{transport:"sendBeacon"}))}))}enable(){this.Gi=!1,this.Xi()}Xi(){var e=this;this.Gi||(this.Yi=setTimeout((()=>{if(this.Qi(),this.Vi.length>0){var t=this.Zi(),i=function(){var r=t[n],o=new Date().getTime();r.data&&q(r.data)&&Z(r.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Ki(r)};for(var n in t)i()}}),this.Ji))}Qi(){clearTimeout(this.Yi),this.Yi=void 0}Zi(){var e={};return Z(this.Vi,(t=>{var i,n=t,r=(n?n.batchKey:null)||n.url;w(e[r])&&(e[r]=k({},n,{data:[]})),(i=e[r].data)==null||i.push(n.data)})),this.Vi=[],e}},Zb=["retriesPerformedSoFar"],za=class{constructor(e){this.te=!1,this.ie=3e3,this.Vi=[],this._instance=e,this.Vi=[],this.ee=!0,!w(m)&&"onLine"in m.navigator&&(this.ee=m.navigator.onLine,this.re=()=>{this.ee=!0,this.se()},this.ne=()=>{this.ee=!1},de(m,"online",this.re),de(m,"offline",this.ne))}get length(){return this.Vi.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=Yd(e,Zb);Rs(t)&&(i.url=sr(i.url,{retry_count:t})),this._instance._send_request(k({},i,{callback:n=>{n.statusCode!==200&&(n.statusCode<400||n.statusCode>=500)&&(t??0)<10?this.oe(k({retriesPerformedSoFar:t},i)):i.callback==null||i.callback(n)}}))}oe(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(t),n=Date.now()+i;this.Vi.push({retryAt:n,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),A.warn(r),this.te||(this.te=!0,this.ae())}ae(){if(this.le&&clearTimeout(this.le),this.Vi.length===0)return this.te=!1,void(this.le=void 0);this.le=setTimeout((()=>{this.ee&&this.Vi.length>0&&this.se(),this.ae()}),this.ie)}se(){var e=Date.now(),t=[],i=this.Vi.filter((r=>r.retryAt<e||(t.push(r),!1)));if(this.Vi=t,i.length>0)for(var{requestOptions:n}of i)this.retriableRequest(n)}unload(){for(var{requestOptions:e}of(this.le&&(clearTimeout(this.le),this.le=void 0),this.te=!1,w(m)||(this.re&&(m.removeEventListener("online",this.re),this.re=void 0),this.ne&&(m.removeEventListener("offline",this.ne),this.ne=void 0)),this.Vi))try{this._instance._send_request(k({},e,{transport:"sendBeacon"}))}catch(t){A.error(t)}this.Vi=[]}},Ka=class{constructor(e){this.ue=()=>{var t,i,n,r;this.he||(this.he={});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.he.lastScrollY=Math.ceil(a),this.he.maxScrollY=Math.max(a,(t=this.he.maxScrollY)!==null&&t!==void 0?t:0),this.he.maxScrollHeight=Math.max(l,(i=this.he.maxScrollHeight)!==null&&i!==void 0?i:0),this.he.lastContentY=c,this.he.maxContentY=Math.max(c,(n=this.he.maxContentY)!==null&&n!==void 0?n:0),this.he.maxContentHeight=Math.max(u,(r=this.he.maxContentHeight)!==null&&r!==void 0?r:0)},this._instance=e}getContext(){return this.he}resetContext(){var e=this.he;return setTimeout(this.ue,0),e}startMeasuringScrollPosition(){de(m,"scroll",this.ue,{capture:!0}),de(m,"scrollend",this.ue,{capture:!0}),de(m,"resize",this.ue)}scrollElement(){if(!this._instance.config.scroll_root_selector)return m?.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 i=m?.document.querySelector(t);if(i)return i}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return m&&(m.scrollY||m.pageYOffset||m.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return m&&(m.scrollX||m.pageXOffset||m.document.documentElement.scrollLeft)||0}},eE=s=>Fh(s?.config.mask_personal_data_properties,s?.config.custom_personal_data_properties),rr=class{constructor(e,t,i,n){this.de=r=>{var o=this.ve();if(!o||o.sessionId!==r){var a={sessionId:r,props:this.ce(this._instance)};this.fe.register({[ba]:a})}},this._instance=e,this.pe=t,this.fe=i,this.ce=n||eE,this.pe.onSessionId(this.de)}ve(){return this.fe.props[ba]}getSetOnceProps(){var e,t=(e=this.ve())==null?void 0:e.props;return t?"r"in t?Uh(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(rl(this.getSetOnceProps()),((t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+Qo(i)]=t})),e}},qo=le("[SessionId]"),or=class{on(e,t){return this._e.on(e,t)}constructor(e,t,i){var n;if(this.ge=[],this.me=void 0,this._e=new Di,this.be=(u,h)=>!(!Rs(u)||!Rs(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.fe=e.persistence,this.ye=void 0,this.we=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.xe=t||Lt,this.$e=i||Lt;var r=this.N.persistence_name||this.N.token,o=this.N.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*at(o,60,36e3,qo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Ee(),this.Se="ph_"+r+"_window_id",this.ke="ph_"+r+"_primary_window_exists",this.Pe()){var a=ye.D(this.Se),l=ye.D(this.ke);a&&!l?this.ye=a:ye.L(this.Se),ye.j(this.ke,!0)}if((n=this.N.bootstrap)!=null&&n.sessionID)try{var c=(u=>{var h=u.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})(this.N.bootstrap.sessionID);this.Te(this.N.bootstrap.sessionID,new Date().getTime(),c)}catch(u){qo.error("Invalid sessionID in bootstrap",u)}this.Ce()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return w(this.ge)&&(this.ge=[]),this.ge.push(e),this.we&&e(this.we,this.ye),()=>{this.ge=this.ge.filter((t=>t!==e))}}Pe(){return this.N.persistence!=="memory"&&!this.fe.zt&&ye.O()}Ie(e){e!==this.ye&&(this.ye=e,this.Pe()&&ye.j(this.Se,e))}Re(){return this.ye?this.ye:this.Pe()?ye.D(this.Se):null}Te(e,t,i){e===this.we&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.we=e,this.fe.register({[Hn]:[t,e,i]}))}Fe(){var e=this.fe.props[Hn];return q(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Te(null,null,null)}destroy(){clearTimeout(this.Oe),this.Oe=void 0,this.me&&m&&(m.removeEventListener("beforeunload",this.me,{capture:!1}),this.me=void 0),this.ge=[]}Ce(){this.me=()=>{this.Pe()&&ye.L(this.ke)},de(m,"beforeunload",this.me,{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 i=t||new Date().getTime(),[n,r,o]=this.Fe(),a=this.Re(),l=Rs(o)&&Math.abs(i-o)>864e5,c=!1,u=!r,h=!u&&!e&&this.be(i,n);u||h||l?(r=this.xe(),a=this.$e(),qo.info("new session ID generated",{sessionId:r,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}}),o=i,c=!0):a||(a=this.$e(),c=!0);var g=Rs(n)&&e&&!l?n:i,f=Rs(o)?o:new Date().getTime();return this.Ie(a),this.Te(r,g,f),e||this.Ee(),c&&this.ge.forEach((p=>p(r,a,c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:r,windowId:a,sessionStartTimestamp:f,changeReason:c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:n}}Ee(){clearTimeout(this.Oe),this.Oe=setTimeout((()=>{var[e]=this.Fe();if(this.be(new Date().getTime(),e)){var t=this.we;this.resetSessionId(),this._e.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},Gh=function(s,e){if(!s)return!1;var t=s.userAgent;if(t&&id(t,e))return!0;try{var i=s?.userAgentData;if(i!=null&&i.brands&&i.brands.some((n=>id(n?.brand,e))))return!0}catch{}return!!s.webdriver},Si=(function(s){return s.US="us",s.EU="eu",s.CUSTOM="custom",s})({}),xd="i.posthog.com",Wa=class{constructor(e){this.Me={},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("."+xd,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Me[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Me[this.apiHost]=Si.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Me[this.apiHost]=Si.EU:this.Me[this.apiHost]=Si.CUSTOM),this.Me[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===Si.CUSTOM)return this.apiHost+t;var i=xd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}},tE={icontains:(s,e)=>!!m&&e.href.toLowerCase().indexOf(s.toLowerCase())>-1,not_icontains:(s,e)=>!!m&&e.href.toLowerCase().indexOf(s.toLowerCase())===-1,regex:(s,e)=>!!m&&ir(e.href,s),not_regex:(s,e)=>!!m&&!ir(e.href,s),exact:(s,e)=>e.href===s,is_not:(s,e)=>e.href!==s},Xa=class s{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments((n=>{s.Ae("retrieved web experiments from the server"),t.De=new Map,n.forEach((r=>{if(r.feature_flag_key){var o;t.De&&(s.Ae("setting flag key ",r.feature_flag_key," to web experiment ",r),(o=t.De)==null||o.set(r.feature_flag_key,r));var a=t._instance.getFeatureFlag(r.feature_flag_key);he(a)&&r.variants[a]&&t.je(r.name,a,r.variants[a].transforms)}else if(r.variants)for(var l in r.variants){var c=r.variants[l];s.Le(c)&&t.je(r.name,l,c.transforms)}}))}),i)},this._instance=e,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}onFeatureFlags(e){if(this._is_bot())s.Ae("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(U(this.De))return this.De=new Map,this.loadIfEnabled(),void this.previewWebExperiment();s.Ae("applying feature flags",e),e.forEach((t=>{var i;if(this.De&&(i=this.De)!=null&&i.has(t)){var n,r=this._instance.getFeatureFlag(t),o=(n=this.De)==null?void 0:n.get(t);r&&o!=null&&o.variants[r]&&this.je(o.name,r,o.variants[r].transforms)}}))}}previewWebExperiment(){var e=s.getWindowLocation();if(e!=null&&e.search){var t=Jn(e?.search,"__experiment_id"),i=Jn(e?.search,"__experiment_variant");t&&i&&(s.Ae("previewing web experiments "+t+" && "+i),this.getWebExperiments((n=>{this.Ne(parseInt(t),i,n)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._instance.config.disable_web_experiments&&!i)return e([]);var n=this._instance.get_property("$web_experiments");if(n&&!t)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:r=>{if(r.statusCode!==200||!r.json)return e([]);var o=r.json.experiments||[];return e(o)}})}Ne(e,t,i){var n=i.filter((r=>r.id===e));n&&n.length>0&&(s.Ae("Previewing web experiment ["+n[0].name+"] with variant ["+t+"]"),this.je(n[0].name,t,n[0].variants[t].transforms))}static Le(e){return!U(e.conditions)&&s.Ue(e)&&s.ze(e)}static Ue(e){var t;if(U(e.conditions)||U((t=e.conditions)==null?void 0:t.url))return!0;var i,n,r,o=s.getWindowLocation();return!!o&&((i=e.conditions)==null||!i.url||tE[(n=(r=e.conditions)==null?void 0:r.urlMatchType)!==null&&n!==void 0?n:"icontains"](e.conditions.url,o))}static getWindowLocation(){return m?.location}static ze(e){var t;if(U(e.conditions)||U((t=e.conditions)==null?void 0:t.utm))return!0;var i=xh();if(i.utm_source){var n,r,o,a,l,c,u,h,g=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==i.utm_campaign,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==i.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==i.utm_medium,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return g&&p&&v&&f}return!1}static Ae(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];A.info("[WebExperiments] "+e,i)}je(e,t,i){this._is_bot()?s.Ae("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?i.forEach((n=>{if(n.selector){var r;s.Ae("applying transform of variant "+t+" for experiment "+e+" ",n);var o=(r=document)==null?void 0:r.querySelectorAll(n.selector);o?.forEach((a=>{var l=a;n.html&&(l.innerHTML=n.html),n.css&&l.setAttribute("style",n.css)}))}})):s.Ae("Control variants leave the page unmodified.")}_is_bot(){return Ve&&this._instance?Gh(Ve,this._instance.config.custom_blocked_useragents):void 0}},sE=le("[PostHog ExternalIntegrations]"),iE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ya=class{constructor(e){this._instance=e}V(e,t){var i;(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,(n=>{if(n)return sE.error("failed to load script",n);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!n||(a=O.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.V(iE[o],(()=>{var u;(u=O.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!n&&(l=O.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=O.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[i,n]of Object.entries((r=this._instance.config.integrations)!==null&&r!==void 0?r:{})){var r;t(i)}}},Ti={},zo=0,Ja=()=>{},Os="posthog",jh=!xb&&xe?.indexOf("MSIE")===-1&&xe?.indexOf("Mozilla")===-1,Ld=s=>{var e;return k({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:gb(S?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ja,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:s??"unset",__preview_deferred_init_extensions:!1,debug: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:(m==null||(e=m.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var i="Bad HTTP status: "+t.statusCode+" "+t.text;A.error(i)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Ha},error_tracking:{},_onCapture:Ja,__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}))(s))},$d=s=>{var e={};w(s.process_person)||(e.person_profiles=s.process_person),w(s.xhr_headers)||(e.request_headers=s.xhr_headers),w(s.cookie_name)||(e.persistence_name=s.cookie_name),w(s.disable_cookie)||(e.disable_persistence=s.disable_cookie),w(s.store_google)||(e.save_campaign_params=s.store_google),w(s.verbose)||(e.debug=s.verbose);var t=ue({},e,s);return q(s.property_blacklist)&&(w(s.property_denylist)?t.property_denylist=s.property_blacklist:q(s.property_denylist)?t.property_denylist=[...s.property_blacklist,...s.property_denylist]:A.error("Invalid value for property_denylist config: "+s.property_denylist)),t},Qa=class{constructor(){this.__forceAllowLocalhost=!1}get He(){return this.__forceAllowLocalhost}set He(e){A.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Us=class s{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new Qa,this.Be=!1,this.version=vt.LIB_VERSION,this.Ft=new Di,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ld(),this.SentryIntegration=Ra,this.sentryIntegration=e=>(function(t,i){var n=Ih(t,i);return{name:Th,processEvent:r=>n(r)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.qe=!1,this.We=null,this.Ge=null,this.Ve=null,this.featureFlags=new La(this),this.toolbar=new Oa(this),this.scrollManager=new Ka(this),this.pageViewManager=new Zn(this),this.surveys=new Ba(this),this.conversations=new Va(this),this.logs=new Ga(this),this.experiments=new Xa(this),this.exceptions=new xa(this),this.rateLimiter=new ja(this),this.requestRouter=new Wa(this),this.consent=new Ia(this),this.externalIntegrations=new Ya(this),this.people={set:(e,t,i)=>{var n=he(e)?{[e]:t}:e;this.setPersonProperties(n),i?.({})},set_once:(e,t,i)=>{var n=he(e)?{[e]:t}:e;this.setPersonProperties(void 0,n),i?.({})}},this.on("eventCaptured",(e=>A.info('send "'+e?.event+'"',e)))}init(e,t,i){if(i&&i!==Os){var n,r=(n=Ti[i])!==null&&n!==void 0?n:new s;return r._init(e,t,i),Ti[i]=r,Ti[Os][i]=r,r}return this._init(e,t,i)}_init(e,t,i){var n;if(t===void 0&&(t={}),w(e)||Zo(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.Je(t.debug),this.Ke=t,this.Ye=[],t.person_profiles?this.Ge=t.person_profiles:t.process_person&&(this.Ge=t.process_person),this.set_config(ue({},Ld(t.defaults),$d(t),{name:i,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 r=this.Xe();this.persistence=new Ai(this.config,r),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Ai(k({},this.config,{persistence:"sessionStorage"}),r);var o=k({},this.persistence.props),a=k({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Qe=new qa((E=>this.Ze(E)),this.config.request_queue_config),this.tr=new za(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 or(this),this.sessionPropsManager=new rr(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(A.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.ir(l)}),0)):(A.info("Initializing extensions synchronously"),this.ir(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}),((n=t.bootstrap)==null?void 0:n.distinctID)!==void 0){var c,u,h=this.config.get_device_id(Lt()),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.er()){var f,p,v=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlags)||{}).filter((E=>{var C;return!((C=t.bootstrap)==null||(C=C.featureFlags)==null||!C[E])})).reduce(((E,C)=>{var P;return E[C]=((P=t.bootstrap)==null||(P=P.featureFlags)==null?void 0:P[C])||!1,E}),{}),_=Object.keys(((p=t.bootstrap)==null?void 0:p.featureFlagPayloads)||{}).filter((E=>v[E])).reduce(((E,C)=>{var P,I;return(P=t.bootstrap)!=null&&(P=P.featureFlagPayloads)!=null&&P[C]&&(E[C]=(I=t.bootstrap)==null||(I=I.featureFlagPayloads)==null?void 0:I[C]),E}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:_})}if(l)this.register_once({distinct_id:ai,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(Lt());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(rt,"anonymous")}return de(m,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Sb(this,(()=>this.rr())):this.rr(),bt(this.config._onCapture)&&this.config._onCapture!==Ja&&(A.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(E=>this.config._onCapture(E.event,E)))),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}ir(e){var t=performance.now(),i=k({},s.__defaultExtensionClasses,this.config.__extensionClasses);i.historyAutocapture&&(this.historyAutocapture=new i.historyAutocapture(this),this.historyAutocapture.startIfEnabled());var n=[];i.tracingHeaders&&n.push((()=>{new i.tracingHeaders(this).startIfEnabledOrStop()})),i.siteApps&&n.push((()=>{var r;this.siteApps=new i.siteApps(this),(r=this.siteApps)==null||r.init()})),!e&&i.sessionRecording&&n.push((()=>{this.sessionRecording=new i.sessionRecording(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||n.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),i.autocapture&&n.push((()=>{this.autocapture=new i.autocapture(this),this.autocapture.startIfEnabled()})),n.push((()=>{this.surveys.loadIfEnabled()})),n.push((()=>{this.logs.loadIfEnabled()})),n.push((()=>{this.conversations.loadIfEnabled()})),i.productTours&&n.push((()=>{this.productTours=new i.productTours(this),this.productTours.loadIfEnabled()})),i.heatmaps&&n.push((()=>{this.heatmaps=new i.heatmaps(this),this.heatmaps.startIfEnabled()})),i.webVitalsAutocapture&&n.push((()=>{this.webVitalsAutocapture=new i.webVitalsAutocapture(this)})),i.exceptionObserver&&n.push((()=>{this.exceptionObserver=new i.exceptionObserver(this),this.exceptionObserver.startIfEnabledOrStop()})),i.deadClicksAutocapture&&n.push((()=>{this.deadClicksAutocapture=new i.deadClicksAutocapture(this,kb),this.deadClicksAutocapture.startIfEnabledOrStop()})),n.push((()=>{if(this.sr){var r=this.sr;this.sr=void 0,this.Bi(r)}})),this.nr(n,t)}nr(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.nr(e,t)}),0);var i=e.shift();if(i)try{i()}catch(r){A.error("Error initializing extension:",r)}}var n=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:n}),this.config.__preview_deferred_init_extensions&&A.info("PostHog extensions initialized ("+n+"ms)")}Bi(e){var t,i,n,r,o,a,l,c,u;if(!S||!S.body)return A.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Bi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.sr=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=F(e.supportedCompression,yt.GZipJS)?yt.GZipJS:F(e.supportedCompression,yt.Base64)?yt.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ge?this.Ge:"identified_only"}),(i=this.siteApps)==null||i.onRemoteConfig(e),(n=this.sessionRecording)==null||n.onRemoteConfig(e),(r=this.autocapture)==null||r.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}rr(){try{this.config.loaded(this)}catch(i){A.critical("`loaded` function failed",i)}if(this.ar(),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.lr()}),1),this.ur=new nr(this),this.ur.load()}ar(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Qe)==null||e.enable())}_dom_loaded(){this.is_capturing()&&$t(this.__request_queue,(e=>this.Ze(e))),this.__request_queue=[],this.ar()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.hr()&&this.capture("$pageleave"),(e=this.Qe)==null||e.unload(),(t=this.tr)==null||t.unload()):this.hr()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(jh?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=sr(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 i,n,r,o=k({},t);o.timeout=o.timeout||6e4,o.url=sr(o.url,{_:new Date().getTime().toString(),ver:vt.LIB_VERSION,compression:o.compression});var a=(i=o.transport)!==null&&i!==void 0?i:"fetch",l=Bn.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(n=(r=yh(l,(u=>u.transport===a)))==null?void 0:r.method)!==null&&n!==void 0?n:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(k({},e,{callback:t=>{var i,n;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((i=(n=this.config).on_request_error)==null||i.call(n,t)),e.callback==null||e.callback(t)}}))))}Ze(e){this.tr?this.tr.retriableRequest(e):this._send_request(e)}_execute_array(e){zo++;try{var t,i=[],n=[],r=[];$t(e,(a=>{a&&(t=a[0],q(t)?r.push(a):bt(a)?a.call(this):q(a)&&t==="alias"?i.push(a):q(a)&&t.indexOf("capture")!==-1&&bt(this[t])?r.push(a):n.push(a))}));var o=function(a,l){$t(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(i,this),o(n,this),o(r,this)}finally{zo--}}er(){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(zo>0&&q(e)&&he(e[0])){var t=s.prototype[e[0]];bt(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,i){var n;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Qe){if(this.is_capturing())if(!w(e)&&he(e)){var r=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(r&&!this.config.__preview_capture_bot_pageviews)){var o=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!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"||i!=null&&i.ft||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=i?.timestamp||a,c=Lt(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&r&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),i?.$set&&(u.$set=i?.$set);var h,g=e!=="$groupidentify",f=this.dr(i?.$set_once,g);if(f&&(u.$set_once=f),(u=hb(u,i!=null&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,w(i?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===ki.DISMISSED||e===ki.SENT){var p=t?.[Ho.SURVEY_ID],v=t?.[Ho.SURVEY_ITERATION];h={id:p,current_iteration:v},localStorage.getItem(Pd(h))||localStorage.setItem(Pd(h),"true"),u.$set=k({},u.$set,{[Xb({id:p,current_iteration:v},e===ki.SENT?"responded":"dismissed")]:!0})}else e===ki.SHOWN&&(u.$set=k({},u.$set,{[Ho.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Qb.SHOWN){var _=t?.[Nd.TOUR_TYPE];_&&(u.$set=k({},u.$set,{[Nd.TOUR_LAST_SEEN_DATE+"/"+_]:new Date().toISOString()}))}var b=k({},u.properties.$set,u.$set);if(Cs(b)||this.setPersonPropertiesForFlags(b),!U(this.config.before_send)){var E=this.vr(u);if(!E)return;u=E}this.Ft.emit("eventCaptured",u);var C={method:"POST",url:(n=i?._url)!==null&&n!==void 0?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:i?._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.Ze(C):this.Qe.enqueue(C),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,i,n,r){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var o=r?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)&&!St(a.distinct_id)||Zo(a.distinct_id))&&A.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=Fb(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(r,i.getTime());a.$session_id=h,a.$window_id=g}this.sessionPropsManager&&ue(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&ue(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this.tr)==null?void 0:f.length}catch(b){a.$sdk_debug_error_capturing_properties=String(b)}if(this.requestRouter.region===Si.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||r?e!=="$pageleave"||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,n),a=ue(a,c),e==="$pageview"&&S&&(a.title=S.title),!w(o)){var p=i.getTime()-o;a.$duration=parseFloat((p/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(b){delete a[b]})):A.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(A.error("sanitize_properties is deprecated. Use before_send instead"),a=v(a,e));var _=this.cr();return a.$process_person_profile=_,_&&!r&&this.pr("_calculate_event_properties"),a}dr(e,t){var i;if(t===void 0&&(t=!0),!this.persistence||!this.cr()||this.Be)return e;var n=this.persistence.get_initial_props(),r=(i=this.sessionPropsManager)==null?void 0:i.getSetOnceProps(),o=ue({},n,r||{},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.Be=!0),Cs(o)?void 0:o}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var n;(n=this.persistence)==null||n.register_once(e,t,i)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}_r(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,i){var n=i!=null&&i.merge?this.featureFlags.getFlagVariants():{},r=i!=null&&i.merge?this.featureFlags.getFlagPayloads():{},o=k({},n,e),a=k({},r,t),l={};for(var[c,u]of Object.entries(o)){var h=typeof u=="string";l[c]={key:c,enabled:!!h||!!u,variant:h?u:void 0,reason:void 0,metadata:w(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.Ft.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=Jb),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,i){if(!this.__loaded||!this.persistence)return A.uninitializedWarning("posthog.identify");if(St(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!==ai){if(this.pr("posthog.identify")){var n=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var r=n;this.register_once({$had_persisted_distinct_id:!0,$device_id:r},"")}e!==n&&e!==this.get_property(_i)&&(this.unregister(_i),this.register({distinct_id:e}));var o=(this.persistence.get_property(rt)||"anonymous")==="anonymous";e!==n&&o?(this.persistence.set_property(rt,"identified"),this.setPersonPropertiesForFlags(k({},i||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n},{$set:t||{},$set_once:i||{}}),this.Ve=Td(e,t,i),this.featureFlags.setAnonymousDistinctId(n)):(t||i)&&this.setPersonProperties(t,i),e!==n&&(this.reloadFeatureFlags(),this.unregister(qn))}}else A.critical('The string "'+ai+'" 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.pr("posthog.setPersonProperties")){var i=Td(this.get_distinct_id(),e,t);this.Ve!==i?(this.setPersonPropertiesForFlags(k({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Ve=i):A.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var n=this.getGroups();n[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:k({},n,{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),n[e]===t||i||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.pr("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,n,r,o;if(A.info("reset"),!this.__loaded)return A.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(i=this.sessionPersistence)==null||i.clear(),this.surveys.reset(),(n=this.ur)==null||n.stop(),this.featureFlags.reset(),(r=this.persistence)==null||r.set_property(rt,"anonymous"),(o=this.sessionManager)==null||o.resetSessionId(),this.Ve=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:ai,$device_id:null},"");else{var l=this.config.get_device_id(Lt());this.register_once({distinct_id:l,$device_id:e?l:a},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&i){var r,o=(r=e.timestampLookBack)!==null&&r!==void 0?r:10;if(!i)return n;n+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}return n}alias(e,t){return e===this.get_property(Eh)?(A.critical("Attempting to create alias for existing People user - aborting."),-2):this.pr("posthog.alias")?(w(t)&&(t=this.get_distinct_id()),e!==t?(this._r(_i,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 i,n,r,o,a,l,c,u;ue(this.config,$d(e));var h=this.Xe();(i=this.persistence)==null||i.update_config(this.config,t,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Ai(k({},this.config,{persistence:"sessionStorage"}),h);var g=this.Je(this.config.debug);kt(g)&&(this.config.debug=g),kt(this.config.debug)&&(this.config.debug?(vt.DEBUG=!0,ae.O()&&ae.j("ph_debug","true"),A.info("set_config",{config:e,oldConfig:t,newConfig:k({},this.config)})):(vt.DEBUG=!1,ae.O()&&ae.L("ph_debug"))),(n=this.exceptionObserver)==null||n.onConfigChange(),(r=this.sessionRecording)==null||r.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this.gr(),(u=this.externalIntegrations)==null||u.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,i={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(i).some(Boolean)){var n,r,o,a,l;(n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),i.sampling&&((r=this.sessionRecording)==null||r.overrideSampling()),i.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),i.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var i=new Error("PostHog syntheticException"),n=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(k({},n,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Os;return t!==Os&&(t=Os+"."+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"}cr(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Cs(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[_i])&&((t=this.persistence)==null||(t=t.props)==null||!t[Wn]))}hr(){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.cr()||this.pr("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.pr("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}pr(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._r(Wn,!0),!0)}Xe(){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}gr(){var e,t,i,n,r=this.Xe();return((e=this.persistence)==null?void 0:e.zt)!==r&&((i=this.persistence)==null||i.set_disabled(r)),((t=this.sessionPersistence)==null?void 0:t.zt)!==r&&((n=this.sessionPersistence)==null||n.set_disabled(r)),r}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){if(this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()){var i,n,r,o,a;this.reset(!0),(i=this.sessionManager)==null||i.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=new or(this),this.pageViewManager=new Zn(this),this.persistence&&(this.sessionPropsManager=new rr(this,this.sessionManager,this.persistence));var l=(r=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&r!==void 0?r:(a=s.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=new l(this),this.sessionRecording.startIfEnabledOrStop())}var c;this.consent.optInOut(!0),this.gr(),this.ar(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(w(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.lr()}else A.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.gr(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:ai,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(i=this.sessionRecording)==null||i.stopRecording(),this.sessionRecording=void 0,this.lr())):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.gr()}_is_bot(){return Ve?Gh(Ve,this.config.custom_blocked_useragents):void 0}lr(){S&&(S.visibilityState==="visible"?this.qe||(this.qe=!0,this.capture("$pageview",{title:S.title},{send_instantly:!0}),this.We&&(S.removeEventListener("visibilitychange",this.We),this.We=null)):this.We||(this.We=this.lr.bind(this),de(S,"visibilitychange",this.We)))}debug(e){e===!1?(m?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(m?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}At(){var e,t,i,n,r,o,a,l=this.Ke||{};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):(i="advanced_disable_decide",n=!1,r=A,o=(t="advanced_disable_flags")in(e=l)&&!U(e[t]),a=i in e&&!U(e[i]),o?e[t]:a?(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):n)}vr(e){if(U(this.config.before_send))return e;var t=q(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var n of t){if(i=n(i),U(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return Uy(e.event)?A.warn(r+". This can cause unexpected behavior."):A.info(r),null}i.properties&&!Cs(i.properties)||A.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return(e=this.pageViewManager.it)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Je(e){var t=kt(e)&&!e,i=ae.O()&&ae.A("ph_debug")==="true";return!t&&(!!i||e)}};Us.__defaultExtensionClasses={},(function(s,e){for(var t=0;t<e.length;t++)s.prototype[e[t]]=db(s.prototype[e[t]])})(Us,["identify"]);cl=["a","button","form","input","select","textarea","label"];nE=["next","previous","prev",">","<"],Bd=10,Vd=[".ph-no-rageclick",".ph-no-capture"];ul=s=>!s||Mt(s,"html")||!dr(s),Xh=(s,e)=>{if(!m||ul(s))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[s],n=s;n.parentNode&&!Mt(n,"body");)if(qh(n.parentNode))i.push(n.parentNode.host),n=n.parentNode.host;else{var r=Wh(n);if(!r)break;if(e||cl.indexOf(r.tagName.toLowerCase())>-1)t=!0;else{var o=m.getComputedStyle(r);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}i.push(r),n=r}return{parentIsUsefulElement:t,targetElementList:i}};Jh="(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})",aE=new RegExp("^(?:"+Jh+")$"),lE=new RegExp(Jh),Qh="\\d{3}-?\\d{2}-?\\d{4}",cE=new RegExp("^("+Qh+")$"),uE=new RegExp("("+Qh+")");lr=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,i){if(this.disabled)return!1;var n=this.clicks[this.clicks.length-1];if(n&&Math.abs(e-n.x)+Math.abs(t-n.y)<this.thresholdPx&&i-n.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},Ko="$copy_autocapture",jd=le("[AutoCapture]");pi=le("[ExceptionAutocapture]");vE=le("[TracingHeaders]"),Nt=le("[Web Vitals]"),qd=9e5;le("[SessionRecording]");el="[SessionRecording]",Is=le(el),_E=le("[Heatmaps]");Kd=le("[Product Tours]"),Xo="ph_product_tours",mE=["$set_once","$set"],Dt=le("[SiteApps]"),yE={sessionRecording:class{get started(){var s;return!((s=this.mr)==null||!s.isStarted)}get status(){return this.mr?this.mr.status:this.br?this.yr?"lazy_loading":"disabled":"pending_config"}constructor(s){if(this._forceAllowLocalhostNetworkCapture=!1,this.br=!1,this.wr=!1,this.$r=void 0,this._instance=s,!this._instance.sessionManager)throw Is.error("started without valid sessionManager"),new Error(el+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(el+' cannot be used with cookieless_mode="always"')}get yr(){var s,e=!((s=this._instance.get_property(xn))==null||!s.enabled),t=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return m&&e&&t&&!i}startIfEnabledOrStop(s){var e;if(this.br&&(!this.yr||(e=this.mr)==null||!e.isStarted)){var t=!w(Object.assign)&&!w(Array.from);this.yr&&t?(this.Er(s),Is.info("starting")):this.stopRecording()}}Er(s){var e,t,i;this.yr&&(O!=null&&(e=O.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=O.__PosthogExtensions__)!=null&&t.initSessionRecording?this.Sr(s):(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.kr,(n=>{if(n)return Is.error("could not load recorder",n);this.Sr(s)})))}stopRecording(){var s,e;(s=this.$r)==null||s.call(this),this.$r=void 0,(e=this.mr)==null||e.stop()}Pr(){var s;(s=this._instance.persistence)==null||s.unregister(Sh)}Tr(s){if(this._instance.persistence){var e,t,i=this._instance.persistence,n=()=>{var r=s.sessionRecording===!1?void 0:s.sessionRecording,o=r?.sampleRate,a=U(o)?null:parseFloat(o);U(a)&&this.Pr();var l=r?.minimumDurationMilliseconds;i.register({[xn]:k({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:k({capturePerformance:s.capturePerformance},r?.networkPayloadCapture),canvasRecording:{enabled:r?.recordCanvas,fps:r?.canvasFps,quality:r?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:w(l)?null:l,endpoint:r?.endpoint,triggerMatchType:r?.triggerMatchType,masking:r?.masking,urlTriggers:r?.urlTriggers})})};n(),(e=this.$r)==null||e.call(this),this.$r=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(n)}}onRemoteConfig(s){"sessionRecording"in s?s.sessionRecording!==!1?(this.wr=!1,this.Tr(s),this.br=!0,this.startIfEnabledOrStop()):this.br=!0:Is.info("skipping remote config with no sessionRecording",s)}log(s,e){var t;e===void 0&&(e="log"),(t=this.mr)!=null&&t.log?this.mr.log(s,e):Is.warn("log called before recorder was ready")}get kr(){var s,e,t=(s=this._instance)==null||(s=s.persistence)==null?void 0:s.get_property(xn);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}Cr(){var s,e=this._instance.get_property(xn);if(!e)return!1;var t=(s=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&s!==void 0?s:Date.now();return Date.now()-t<=3e5}Sr(s){var e,t;if((e=O.__PosthogExtensions__)==null||!e.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.mr||(this.mr=(t=O.__PosthogExtensions__)==null?void 0:t.initSessionRecording(this._instance),this.mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Cr()?this.mr.start(s):this.wr||(this.wr=!0,Is.info("persisted remote config is stale, requesting fresh config before starting"),new nr(this._instance).load())}onRRwebEmit(s){var e;(e=this.mr)==null||e.onRRwebEmit==null||e.onRRwebEmit(s)}overrideLinkedFlag(){var s,e;this.mr||(e=this._instance.persistence)==null||e.register({$replay_override_linked_flag:!0}),(s=this.mr)==null||s.overrideLinkedFlag()}overrideSampling(){var s,e;this.mr||(e=this._instance.persistence)==null||e.register({$replay_override_sampling:!0}),(s=this.mr)==null||s.overrideSampling()}overrideTrigger(s){var e,t;this.mr||(t=this._instance.persistence)==null||t.register({[s==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.mr)==null||e.overrideTrigger(s)}get sdkDebugProperties(){var s;return((s=this.mr)==null?void 0:s.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(s,e){var t;return!((t=this.mr)==null||!t.tryAddCustomEvent(s,e))}}},bE={autocapture:class{constructor(s){this.Ir=!1,this.Rr=null,this.Fr=!1,this.instance=s,this.rageclicks=new lr(s.config.rageclick),this.Or=null}get N(){var s,e,t=fe(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(s=t.url_allowlist)==null?void 0:s.map((i=>new RegExp(i))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((i=>new RegExp(i))),t}Mr(){if(this.isBrowserSupported()){if(m&&S){var s=t=>{t=t||m?.event;try{this.Ar(t)}catch(i){jd.error("Failed to capture event",i)}};if(de(S,"submit",s,{capture:!0}),de(S,"change",s,{capture:!0}),de(S,"click",s,{capture:!0}),this.N.capture_copied_text){var e=t=>{t=t||m?.event,this.Ar(t,Ko)};de(S,"copy",e,{capture:!0}),de(S,"cut",e,{capture:!0})}}}else jd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ir&&(this.Mr(),this.Ir=!0)}onRemoteConfig(s){s.elementsChainAsString&&(this.Fr=s.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[hd]:!!s.autocapture_opt_out}),this.Rr=!!s.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(s){this.Or=s}getElementSelectors(s){var e,t=[];return(e=this.Or)==null||e.forEach((i=>{var n=S?.querySelectorAll(i);n?.forEach((r=>{s===r&&t.push(i)}))})),t}get isEnabled(){var s,e,t=(s=this.instance.persistence)==null?void 0:s.props[hd],i=this.Rr;if(Ze(i)&&!kt(t)&&!this.instance.At())return!1;var n=(e=this.Rr)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!n}Ar(s,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,i=Ud(s);Hh(i)&&(i=i.parentNode||null),e==="$autocapture"&&s.type==="click"&&s instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,s.timeStamp||new Date().getTime())&&rE(i,this.instance.config.rageclick)&&this.Ar(s,"$rageclick");var n=e===Ko;if(i&&oE(i,s,this.N,n,n?["copy","cut"]:void 0)){var{props:r,explicitNoCapture:o}=pE(i,{e:s,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.N.element_attribute_ignorelist,elementsChainAsString:this.Fr});if(o)return!1;var a=this.getElementSelectors(i);if(a&&a.length>0&&(r.$element_selectors=a),e===Ko){var l,c=zh(m==null||(l=m.getSelection())==null?void 0:l.toString()),u=s.type||"clipboard";if(!c)return!1;r.$selected_content=c,r.$copy_type=u}return this.instance.capture(e,r),!0}}}isBrowserSupported(){return bt(S?.querySelectorAll)}},historyAutocapture:class{constructor(s){var e;this._instance=s,this.Dr=(m==null||(e=m.location)==null?void 0:e.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(A.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.jr&&this.jr(),this.jr=void 0,A.info("History API monitoring stopped")}monitorHistoryChanges(){var s,e;if(m&&m.history){var t=this;(s=m.history.pushState)!=null&&s.__posthog_wrapped__||Hd(m.history,"pushState",(i=>function(n,r,o){i.call(this,n,r,o),t.Lr("pushState")})),(e=m.history.replaceState)!=null&&e.__posthog_wrapped__||Hd(m.history,"replaceState",(i=>function(n,r,o){i.call(this,n,r,o),t.Lr("replaceState")})),this.Nr()}}Lr(s){try{var e,t=m==null||(e=m.location)==null?void 0:e.pathname;if(!t)return;t!==this.Dr&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:s}),this.Dr=t}catch(i){A.error("Error capturing "+s+" pageview",i)}}Nr(){if(!this.jr){var s=()=>{this.Lr("popstate")};de(m,"popstate",s),this.jr=()=>{m&&m.removeEventListener("popstate",s)}}}},heatmaps:class{constructor(s){var e;this.Ur=!1,this.Ir=!1,this.zr=null,this.instance=s,this.Ur=!((e=this.instance.persistence)==null||!e.props[pa]),this.rageclicks=new lr(s.config.rageclick)}get flushIntervalMilliseconds(){var s=5e3;return fe(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(s=this.instance.config.capture_heatmaps.flush_interval_milliseconds),s}get isEnabled(){return U(this.instance.config.capture_heatmaps)?U(this.instance.config.enable_heatmaps)?this.Ur:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Ir)return;_E.info("starting..."),this.Hr(),this.Br()}else{var s;clearInterval((s=this.zr)!==null&&s!==void 0?s:void 0),this.qr(),this.getAndClearBuffer()}}onRemoteConfig(s){if("heatmaps"in s){var e=!!s.heatmaps;this.instance.persistence&&this.instance.persistence.register({[pa]:e}),this.Ur=e,this.startIfEnabled()}}getAndClearBuffer(){var s=this.R;return this.R=void 0,s}Wr(s){this.Gr(s.originalEvent,"deadclick")}Br(){this.zr&&clearInterval(this.zr),this.zr=(function(s){return s?.visibilityState==="visible"})(S)?setInterval(this.se.bind(this),this.flushIntervalMilliseconds):null}Hr(){m&&S&&(this.Vr=this.se.bind(this),de(m,"beforeunload",this.Vr),this.Jr=s=>this.Gr(s||m?.event),de(S,"click",this.Jr,{capture:!0}),this.Kr=s=>this.Yr(s||m?.event),de(S,"mousemove",this.Kr,{capture:!0}),this.Xr=new Xn(this.instance,Eb,this.Wr.bind(this)),this.Xr.startIfEnabledOrStop(),this.Qr=this.Br.bind(this),de(S,"visibilitychange",this.Qr),this.Ir=!0)}qr(){var s;m&&S&&(this.Vr&&m.removeEventListener("beforeunload",this.Vr),this.Jr&&S.removeEventListener("click",this.Jr,{capture:!0}),this.Kr&&S.removeEventListener("mousemove",this.Kr,{capture:!0}),this.Qr&&S.removeEventListener("visibilitychange",this.Qr),clearTimeout(this.Zr),(s=this.Xr)==null||s.stop(),this.Ir=!1)}ts(s,e){var t=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=(function(o,a,l){for(var c=o;c&&dr(c)&&!Mt(c,"body");){if(c===l)return!1;if(F(a,m?.getComputedStyle(c).position))return!0;c=Wh(c)}return!1})(Ud(s),["fixed","sticky"],n);return{x:s.clientX+(r?0:i),y:s.clientY+(r?0:t),target_fixed:r,type:e}}Gr(s,e){var t;if(e===void 0&&(e="click"),!Md(s.target)&&zd(s)){var i=this.ts(s,e);(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,new Date().getTime())&&this.es(k({},i,{type:"rageclick"})),this.es(i)}}Yr(s){!Md(s.target)&&zd(s)&&(clearTimeout(this.Zr),this.Zr=setTimeout((()=>{this.es(this.ts(s,"mousemove"))}),500))}es(s){if(m){var e=m.location.href,t=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,n=t?$s([],Fs,i||[]):[],r=Pi(e,n,Ni);this.R=this.R||{},this.R[r]||(this.R[r]=[]),this.R[r].push(s)}}se(){this.R&&!Cs(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Xn,webVitalsAutocapture:class{constructor(s){var e;this.Ur=!1,this.Ir=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.rs=()=>{clearTimeout(this.ss),this.R.metrics.length!==0&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((t,i)=>k({},t,{["$web_vitals_"+i.name+"_event"]:k({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ns=t=>{var i,n=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(w(n))Nt.error("Could not read session ID. Dropping metrics!");else{this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.os();w(r)||(U(t?.name)||U(t?.value)?Nt.error("Invalid metric received",t):this.ls&&t.value>=this.ls?Nt.error("Ignoring metric with value >= "+this.ls,t):(this.R.url!==r&&(this.rs(),this.ss=setTimeout(this.rs,this.flushToCaptureTimeoutMs)),w(this.R.url)&&(this.R.url=r),this.R.firstMetricTimestamp=w(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0),this.R.metrics.push(k({},t,{$current_url:r,$session_id:n.sessionId,$window_id:n.windowId,timestamp:Date.now()})),this.R.metrics.length===this.allowedMetrics.length&&this.rs()))}},this.us=()=>{if(!this.Ir){var t,i,n,r,o=O.__PosthogExtensions__;w(o)||w(o.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:i,onFCP:n,onINP:r}=o.postHogWebVitalsCallbacks),t&&i&&n&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.ns.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.ns.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&n(this.ns.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.ns.bind(this)),this.Ir=!0):Nt.error("web vitals callbacks not loaded - not starting")}},this._instance=s,this.Ur=!((e=this._instance.persistence)==null||!e.props[pd]),this.startIfEnabled()}get allowedMetrics(){var s,e,t=fe(this._instance.config.capture_performance)?(s=this._instance.config.capture_performance)==null?void 0:s.web_vitals_allowed_metrics:void 0;return U(t)?((e=this._instance.persistence)==null?void 0:e.props[_d])||["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 s=fe(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return s!=null&&s}get ls(){var s=fe(this._instance.config.capture_performance)&&St(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:qd;return 0<s&&s<=6e4?qd:s}get isEnabled(){var s=be?.protocol;if(s!=="http:"&&s!=="https:")return Nt.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.Ur}startIfEnabled(){this.isEnabled&&!this.Ir&&(Nt.info("enabled, starting..."),this.V(this.us))}onRemoteConfig(s){if("capturePerformance"in s){var e=fe(s.capturePerformance)&&!!s.capturePerformance.web_vitals,t=fe(s.capturePerformance)?s.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[pd]:e}),this._instance.persistence.register({[_d]:t})),this.Ur=e,this.startIfEnabled()}}V(s){var e,t;if((e=O.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks)s();else{var i=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,i,(n=>{n?Nt.error("failed to load script",n):s()}))}}os(){var s=m?m.location.href:void 0;if(s){var e=this._instance.config.mask_personal_data_properties,t=this._instance.config.custom_personal_data_properties,i=e?$s([],Fs,t||[]):[];return Pi(s,i,Ni)}Nt.error("Could not determine current URL")}}},EE={exceptionObserver:class{constructor(s){var e,t,i;this.us=()=>{var n;if(m&&this.isEnabled&&(n=O.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var r=O.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=O.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=O.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.hs&&this.N.capture_unhandled_errors&&(this.hs=r(this.captureException.bind(this))),!this.ds&&this.N.capture_unhandled_rejections&&(this.ds=o(this.captureException.bind(this))),!this.vs&&this.N.capture_console_errors&&(this.vs=a(this.captureException.bind(this)))}catch(l){pi.error("failed to start",l),this.cs()}}},this._instance=s,this.fs=!((e=this._instance.persistence)==null||!e.props[fd]),this.ps=new ta({refillRate:(t=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&t!==void 0?t:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,h:pi}),this.N=this._s(),this.startIfEnabledOrStop()}_s(){var s=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return fe(s)?e=k({},e,s):(w(s)?this.fs:s)&&(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?(pi.info("enabled"),this.cs(),this.V(this.us)):this.cs()}V(s){var e,t;(e=O.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&s(),(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return pi.error("failed to load script",i);s()}))}cs(){var s,e,t;(s=this.hs)==null||s.call(this),this.hs=void 0,(e=this.ds)==null||e.call(this),this.ds=void 0,(t=this.vs)==null||t.call(this),this.vs=void 0}onRemoteConfig(s){if("autocaptureExceptions"in s){var e=s.autocaptureExceptions;this.fs=!!e||!1,this._instance.persistence&&this._instance.persistence.register({[fd]:this.fs}),this.N=this._s(),this.startIfEnabledOrStop()}}onConfigChange(){this.N=this._s()}captureException(s){var e,t,i=(e=s==null||(t=s.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.ps.consumeRateLimit(i)?pi.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(s)}}},kE={productTours:class{constructor(s){this.gs=null,this.bs=null,this._instance=s}onRemoteConfig(s){"productTours"in s&&(this._instance.persistence&&this._instance.persistence.register({[vd]:!!s.productTours}),this.loadIfEnabled())}loadIfEnabled(){var s,e;this.gs||(s=this._instance).config.disable_product_tours||(e=s.persistence)==null||!e.get_property(vd)||this.V((()=>this.ys()))}V(s){var e,t;(e=O.__PosthogExtensions__)!=null&&e.generateProductTours?s():(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(i=>{i?Kd.error("Could not load product tours script",i):s()}))}ys(){var s;!this.gs&&(s=O.__PosthogExtensions__)!=null&&s.generateProductTours&&(this.gs=O.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(s,e){if(e===void 0&&(e=!1),!q(this.bs)||e){var t=this._instance.persistence;if(t){var i=t.props[Xo];if(q(i)&&!e)return this.bs=i,void s(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:n=>{var r=n.statusCode;if(r!==200||!n.json){var o="Product Tours API could not be loaded, status: "+r;return Kd.error(o),void s([],{isLoaded:!1,error:o})}var a=q(n.json.product_tours)?n.json.product_tours:[];this.bs=a,t&&t.register({[Xo]:a}),s(a,{isLoaded:!0})}})}else s(this.bs,{isLoaded:!0})}getActiveProductTours(s){U(this.gs)?s([],{isLoaded:!1,error:"Product tours not loaded"}):this.gs.getActiveProductTours(s)}showProductTour(s){var e;(e=this.gs)==null||e.showTourById(s)}previewTour(s){this.gs?this.gs.previewTour(s):this.V((()=>{var e;this.ys(),(e=this.gs)==null||e.previewTour(s)}))}dismissProductTour(){var s;(s=this.gs)==null||s.dismissTour("user_clicked_skip")}nextStep(){var s;(s=this.gs)==null||s.nextStep()}previousStep(){var s;(s=this.gs)==null||s.previousStep()}clearCache(){var s;this.bs=null,(s=this._instance.persistence)==null||s.unregister(Xo)}resetTour(s){var e;(e=this.gs)==null||e.resetTour(s)}resetAllTours(){var s;(s=this.gs)==null||s.resetAllTours()}cancelPendingTour(s){var e;(e=this.gs)==null||e.cancelPendingTour(s)}}},SE={siteApps:class{constructor(s){this._instance=s,this.ws=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}xs(s,e){if(e){var t=this.globalsForEvent(e);this.ws.push(t),this.ws.length>1e3&&(this.ws=this.ws.slice(10))}}get siteAppLoaders(){var s;return(s=O._POSTHOG_REMOTE_CONFIG)==null||(s=s[this._instance.config.token])==null?void 0:s.siteApps}init(){if(this.isEnabled){var s=this._instance._addCaptureHook(this.xs.bind(this));this.$s=()=>{s(),this.ws=[],this.$s=void 0}}}globalsForEvent(s){var e,t,i,n,r,o,a;if(!s)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:p}=s;return{event:k({},Yd(s,mE),{properties:k({},s.properties,p?{$set:k({},(e=(t=s.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},p)}:{},f?{$set_once:k({},(i=(n=s.properties)==null?void 0:n.$set_once)!==null&&i!==void 0?i:{},f)}:{}),elements_chain:(r=(o=s.properties)==null?void 0:o.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(a=s.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(s){var e=this.apps[s.id],t=()=>{var o;!e.errored&&this.ws.length&&(Dt.info("Processing "+this.ws.length+" events for site app with id "+s.id),this.ws.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.$s)==null||o.call(this))},i=!1,n=o=>{e.errored=!o,e.loaded=!0,Dt.info("Site app with id "+s.id+" "+(o?"loaded":"errored")),i&&t()};try{var{processEvent:r}=s.init({posthog:this._instance,callback:o=>{n(o)}});r&&(e.processEvent=r),i=!0}catch(o){Dt.error("Error while initializing PostHog app with config id "+s.id,o),n(!1)}if(i&&e.loaded)try{t()}catch(o){Dt.error("Error while processing buffered events PostHog app with config id "+s.id,o),e.errored=!0}}Es(){var s=this.siteAppLoaders||[];for(var e of s)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of s)this.setupSiteApp(t)}Ss(s){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(s);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(i){Dt.error("Error while processing event "+s.event+" for site app "+t.id,i)}}}onRemoteConfig(s){var e,t,i,n=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.Es(),void this._instance.on("eventCaptured",(l=>this.Ss(l)))):void Dt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.$s)==null||t.call(this),(i=s.siteApps)!=null&&i.length)if(this.isEnabled){var r=function(l){var c;O["__$$ph_site_app_"+l]=n._instance,(c=O.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(n._instance,a,(u=>{if(u)return Dt.error("Error while initializing PostHog app with config id "+l,u)}))};for(var{id:o,url:a}of s.siteApps)r(o)}else Dt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},wE=k({},yE,bE,EE,kE,SE,{tracingHeaders:class{constructor(s){this.ks=void 0,this.Ps=void 0,this.us=()=>{var e,t;w(this.ks)&&((e=O.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),w(this.Ps)&&((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=s}V(s){var e,t;(e=O.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&s(),(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return vE.error("failed to load script",i);s()}))}startIfEnabledOrStop(){var s,e;this._instance.config.__add_tracing_headers?this.V(this.us):((s=this.ks)==null||s.call(this),(e=this.Ps)==null||e.call(this),this.ks=void 0,this.Ps=void 0)}}});Us.__defaultExtensionClasses=k({},wE);wt=(Wd=Ti[Os]=new Us,(function(){function s(){s.done||(s.done=!0,jh=!1,Z(Ti,(function(e){e._dom_loaded()})))}S!=null&&S.addEventListener?S.readyState==="complete"?s():de(S,"DOMContentLoaded",s,{capture:!1}):m&&A.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),Wd)});var sf={};hr(sf,{Posthog:()=>dl});var Zt,dl,nf=Re(()=>{"use strict";tf();ps();vs();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:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}let n=t||Yc();this.log("init | loading PostHog SDK",{api_host:n});let r={api_host:n,ui_host:Xc,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...i.session_recording},before_send:o=>{if(typeof window>"u")return null;let a=window.location.hostname;if(a==="localhost"||a==="127.0.0.1")return o;let l=uo.some(c=>a.endsWith(`.${c}`)||a===c);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...i};wt.init(e,r),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let i=typeof wt._isIdentified=="function"?wt._isIdentified():this.has_identified;e&&!i?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),wt.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),wt.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,country_of_residence:i})=>{if(!(!this.has_initialized||!e))try{let n=wt.get_property("$stored_person_properties")??{},r={};n.client_id||(r.client_id=e),t&&n.is_internal===void 0&&(r.is_internal=hn(t)),i&&!n.country_of_residence&&(r.country_of_residence=i),Object.keys(r).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:r}),wt.setPersonProperties(r)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e,country_of_residence:i})}catch(n){console.error("Posthog: Failed to backfill person properties",n)}};this.capture=(e,t)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:t}),wt.capture(e,t)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.options=e,this.debug=t,this.init()}};Zt.getPosthogInstance=(e,t=!1)=>(Zt._instance||(Zt._instance=new Zt(e,t)),Zt._instance);dl=Zt});var TE={};hr(TE,{Analytics:()=>rf,cacheTrackEvents:()=>_s});lo();ps();vs();var xm=2*365*24*60*60,zt=class zt{constructor(e,t,i=!1){this.analytics=new hs;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,r=["webflow.io"].some(c=>t.endsWith(c))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let c=new Uint8Array(16);crypto.getRandomValues(c),c[6]=c[6]&15|64,c[8]=c[8]&63|128;let u=Array.from(c,h=>h.toString(16).padStart(2,"0")).join("");o=`${u.slice(0,8)}-${u.slice(8,12)}-${u.slice(12,16)}-${u.slice(16,20)}-${u.slice(20)}`}else throw new Error("Crypto API not available for secure random UUID generation");let l=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${this.rudderstack_anonymous_cookie_key}=${o}; path=/; Domain=${r}; max-age=${xm}; 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:co});try{this.setCookieIfNotExists(),this.analytics.load(e,co,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.log("init | SDK loaded successfully",{userId:this.getUserId(),anonymousId:this.getAnonymousId()}),this.onLoadedCallback?.()}})}catch(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let i=this.getUserId();if(!i||i!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:t}),this.analytics.identify(e,t||{}),this.has_identified=!0}catch(n){console.error("RudderStack: Failed to identify user",n)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,t="Deriv App",i,n)=>{if(!(!this.has_initialized||e===this.current_page))try{let r={...i&&{user_id:i},...n};this.log("pageView | tracking page view",{platform:t,current_page:e,properties:r}),this.analytics.page(t,e,r),this.current_page=e}catch(r){console.error("RudderStack: Failed to track page view",r)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting RudderStack session"),this.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,t)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:t}),this.analytics.track(e,t)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=t,this.debug=i,this.init(e)}};zt.getRudderStackInstance=(e,t,i=!1)=>(zt._instance||(zt._instance=new zt(e,t,i)),zt._instance);var fn=zt;fo();ps();var gn="cached_analytics_events",pn="cached_analytics_page_views",tu=(s,e)=>{try{let t=Qs(),i=Qe.get(gn),n=i?JSON.parse(i):[];n.push({name:s,properties:e,timestamp:Date.now()});let r={expires:1};t&&(r.domain=t),Qe.set(gn,JSON.stringify(n),r)}catch(t){console.warn("Analytics: Failed to cache event",t)}},su=(s,e)=>{try{let t=Qs(),i=Qe.get(pn),n=i?JSON.parse(i):[];n.push({name:s,properties:e,timestamp:Date.now()});let r={expires:1};t&&(r.domain=t),Qe.set(pn,JSON.stringify(n),r)}catch(t){console.warn("Analytics: Failed to cache page view",t)}},iu=()=>{try{let s=Qe.get(gn);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached events",s)}return[]},nu=()=>{try{let s=Qe.get(pn);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached pages",s)}return[]},ru=()=>{let s=Qs(),e=s?{domain:s}:{};Qe.remove(gn,e)},ou=()=>{let s=Qs(),e=s?{domain:s}:{};Qe.remove(pn,e)};vs();vs();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 i=a=>{let l=2166136261;for(let c=0;c<a.length;c++)l^=a.charCodeAt(c),l=l*16777619>>>0;return l.toString(16)},n=a=>btoa(a),r=i(e),o=n(r);for(;o.length<t;)o+=n(i(o));return o.substring(0,t)}getCookies(e){let i=`; ${document.cookie}`.split(`; ${e}=`);if(i.length===2){let n=decodeURIComponent(i.pop().split(";").shift());try{return JSON.parse(n)}catch{return n}}return null}trackPageUnload(){typeof window>"u"||window.addEventListener("beforeunload",()=>{this.isPageViewSent()||this.push("cached_analytics_page_views",{name:window.location.href,properties:{url:window.location.href}})})}trackResponses(){if(typeof window>"u"||typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(i,n){return this._url=n,this._method=i,e.apply(this,arguments)},XMLHttpRequest.prototype.send=function(i){return this.addEventListener("load",function(){let n=null;if(typeof i=="string")try{n=JSON.parse(i)}catch{n=i}let r={url:this._url,method:this._method,status:this.status,headers:this.getAllResponseHeaders(),data:this.responseText,payload:n};_s.responses.push(r)}),t.apply(this,arguments)},this.isTrackingResponses=!0}getAnalyticsInstance(){return typeof window>"u"?null:window.AnalyticsInstance??window.DerivAnalytics?.Analytics??window.Analytics?.Analytics}isReady(){if(typeof window>"u")return!1;let e=this.getAnalyticsInstance();return e?!!e.getInstances?.()?.tracking:!1}parseCookies(e){if(typeof document>"u")return null;let t=document.cookie.split("; ");for(let i of t){let n=i.indexOf("=");if(n!==-1&&decodeURIComponent(i.slice(0,n))===e){let r=i.slice(n+1);try{return JSON.parse(decodeURIComponent(r))}catch{return decodeURIComponent(r)}}}return null}isPageViewSent(){return!!this.responses.find(e=>e.payload?.type==="page"&&e.payload?.anonymousId)}set(e){this.log("set | caching event to cookie",e),this.push("cached_analytics_events",e)}push(e,t){if(typeof document>"u")return;let i=[],n=this.parseCookies(e);n&&Array.isArray(n)&&(i=n),i.push(t);let r=this.getAllowedDomain(),o=365*24*60*60,a=`${e}=${encodeURIComponent(JSON.stringify(i))}; path=/; Domain=${r}; max-age=${o}; SameSite=Lax`;document.cookie=a}getAllowedDomain(){if(typeof window>"u")return"";let e=window.location.hostname;if(e==="localhost"||/^\d+\.\d+\.\d+\.\d+$/.test(e))return e;let t=e.split(".");return t.length===1?e:`.${t.slice(-2).join(".")}`}processEvent(e){let t=this.getCookies("client_information");if(t){let{email:i=null}=t;i&&(e.properties.email_hash=this.hash(i))}if(e?.properties?.email){let i=e.properties.email;delete e.properties.email,e.properties.email_hash=this.hash(i)}return e}track(e,t=!1){if(typeof window>"u")return;let i=this.processEvent(e),n=this.getAnalyticsInstance();this.isReady()&&!t?(this.log("track | analytics ready \u2014 calling trackEvent",{event:i.name,properties:i.properties}),n.trackEvent(i.name,i.properties)):(this.log("track | analytics not ready or cache=true \u2014 storing event",{event:i.name,cache:t}),this.set(i))}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:i={}},n=!1,r=null){let o=l=>{l.dataset?.clickEventTracking||(l.addEventListener("click",c=>{let u={name:t,properties:i,cache:n};if(typeof r=="function"){let h=r(c);u={...h,cache:h.cache??n}}this.track(u,u.cache??!1)}),l.dataset.clickEventTracking="true")};(e instanceof NodeList?Array.from(e):[e]).forEach(o)}addEventHandler(e){return typeof window>"u"?this:(e.forEach(({element:t,event:i={name:"",properties:{}},cache:n=!1,callback:r=null})=>{if(typeof t=="string"){let o=t;if(!this.delegatedSelectors.has(o)){let a=l=>{let c=l.target;if(!c)return;let u=c.closest(o);if(u&&!u.dataset?.clickEventTracking){let h={name:i.name,properties:i.properties,cache:n};if(typeof r=="function"){let g=r(l);h={...g,cache:g.cache??n}}u.dataset.clickEventTracking="true",this.track(h,h.cache??!1)}};document.addEventListener("click",a),this.delegatedSelectors.add(o)}}else(t instanceof NodeList?Array.from(t):[t]).forEach(a=>{a&&!a.dataset?.clickEventTracking&&this.listen(a,i,n,r)})}),this)}loadEvent(e){return this.log("loadEvent | firing load events",e.map(t=>t.event.name)),e.forEach(({event:t})=>{let{name:i,properties:n}=t;this.track({name:i,properties:n})}),this}pageLoadEvent(e){if(typeof window>"u")return this;let t=window.location.pathname.slice(1);return this.log("pageLoadEvent | checking page load events",{pathname:t}),e.forEach(({pages:i=[],excludedPages:n=[],event:r,callback:o=null})=>{let a=!1;if(i.length?i.includes(t)&&(a=!0):n.length&&n.includes(t)||(a=!0),a){let l=o?o():r;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:r.name,pages:i,excludedPages:n})}),this}clearInterval(){this.interval&&(clearInterval(this.interval),this.interval=null)}cleanup(){this.clearInterval(),this.responses=[],this.isTrackingResponses=!1}},_s=new go;typeof window<"u"&&(window.cacheTrackEvents=_s);function AE(s){let e=s?.debug??!1,t=it("",()=>e),i,n,r,o={},a={},l=[],c=[],u=!1,h=()=>{if(!u&&n?.has_initialized){u=!0;try{let T=iu();T.length>0&&(t(`processCookieCache | replaying ${T.length} cached event(s)`,T),T.forEach(M=>{let L=qt(M.properties);n?.track(M.name,L)}),ru());let x=nu();x.length>0&&(t(`processCookieCache | replaying ${x.length} cached page view(s)`,x),x.forEach(M=>{n?.pageView(M.name,"Deriv App",P(),M.properties)}),ou())}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&&n?.identifyEvent(T,x)}),c=[]},f=async({growthbookKey:T,growthbookDecryptionKey:x,rudderstackKey:M,growthbookOptions:L,posthogOptions:ge,debug:H})=>{var K,Q;H!==void 0&&(e=H),_s.setDebug(e),t("initialise | starting analytics initialization",{rudderstack:!!M,growthbook:!!T,posthog:!!ge});try{let V=L?.attributes?.country||(T?await Qc():void 0);if(M&&(t("initialise | initializing RudderStack"),n=fn.getRudderStackInstance(M,g,e)),L?.attributes&&Object.keys(L.attributes).length>0){let D=L.attributes,Ie=n?.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&&!Zs(D.user_id)&&{user_id:D.user_id},...Ie&&{anonymous_id:Ie}}}L??(L={}),L.attributes??(L.attributes={});let ie=n?.getAnonymousId();if((K=L.attributes).id??(K.id=ie),(Q=L.attributes).country??(Q.country=V),T){t("initialise | initializing GrowthBook");let{Growthbook:D}=await Promise.resolve().then(()=>(Qu(),Ju));i=D.getGrowthBookInstance(T,x,L,e),t("initialise | GrowthBook initialized");let Ie=setInterval(()=>{Object.keys(a).length>0?clearInterval(Ie):a=_("tracking-buttons-config",{})},1e3)}if(ge){t("initialise | initializing PostHog");let{Posthog:D}=await Promise.resolve().then(()=>(nf(),sf));r=D.getPosthogInstance(ge,e),t("initialise | PostHog initialized")}t("initialise | analytics initialization complete")}catch(V){console.warn("Analytics: Failed to initialize",V)}},p=({country:T,user_language:x,device_language:M,device_type:L,account_type:ge,user_id:H,anonymous_id:K,app_id:Q,utm_source:V,utm_medium:ie,utm_campaign:D,is_authorised:Ie,residence_country:Me,url:es,domain:$i,geo_location:Bs,loggedIn:Fe,network_downlink:Vs,network_rtt:ts,network_type:Ft,account_currency:ss,account_mode:is})=>{let ns=H??P();if(t("setAttributes | received attributes",{country:T,user_language:x,device_language:M,device_type:L,account_type:ge,user_id:H,anonymous_id:K,app_id:Q,utm_source:V,utm_medium:ie,utm_campaign:D,is_authorised:Ie,residence_country:Me,url:es,domain:$i,geo_location:Bs,loggedIn:Fe,network_downlink:Vs,network_rtt:ts,network_type:Ft,account_currency:ss,account_mode:is}),i){let At={country:T,residence_country:Me,user_language:x,device_language:M,device_type:L,utm_source:V,utm_medium:ie,utm_campaign:D,is_authorised:Ie,url:es,domain:$i,loggedIn:Fe,...H&&!Zs(H)&&{user_id:H},anonymous_id:K};ns&&(At.id=ns,At.user_id=ns),t("setAttributes | called GrowthBook setAttributes",At),i.setAttributes(At)}o={...o,...T!==void 0&&{country:T},...Bs!==void 0&&{geo_location:Bs},...x!==void 0&&{user_language:x},...ge!==void 0&&{account_type:ge},...Q!==void 0&&{app_id:Q},...Me!==void 0&&{residence_country:Me},...L!==void 0&&{device_type:L},...es!==void 0&&{url:es},...Fe!==void 0&&{loggedIn:Fe},...Vs!==void 0&&{network_downlink:Vs},...ts!==void 0&&{network_rtt:ts},...Ft!==void 0&&{network_type:Ft},...H!==void 0&&!Zs(H)&&{user_id:H},...K!==void 0&&{anonymous_id:K},...ss!==void 0&&{account_currency:ss},...is!==void 0&&{account_mode:is}},t("setAttributes | updated core_data",o)},v=T=>i?.getFeatureState(T)?.experimentResult?.name,_=(T,x)=>i?.getFeatureValue(T,x),b=async()=>await i?.getStatus(),E=T=>i?.isOn(T),C=T=>i?.setUrl(T),P=()=>{let T=n?.getUserId()||"";return T&&!Zs(T)?T:""},I=()=>n?.getAnonymousId()||"",z=(T,x="Deriv App",M)=>{let L=P();t("pageView | called",{current_page:T,platform:x,properties:M,userId:L}),n&&(n.has_initialized?(t("pageView | sending page view to RudderStack",{current_page:T,platform:x}),n.pageView(T,x,L,M)):(t("pageView | RudderStack not initialized \u2014 caching page view to cookie",{current_page:T}),su(T,{platform:x,...M})))},B=(T,x)=>{let M=T||P();if(!M){t("identifyEvent | skipped \u2014 no user_id available");return}t("identifyEvent | called",{user_id:M,traits:x});let L=Q=>{if(!Q)return Q;let{email:V,...ie}=Q;return{...ie,...V&&{is_internal:hn(V)}}},ge=x?.rudderstack!==void 0||x?.posthog!==void 0,H,K;if(ge){let{rudderstack:Q,posthog:V,...ie}=x;H=L({...ie,...Q}),K=L({...ie,...V})}else H=L(x),K=L(x);n&&(n.has_initialized?(t("identifyEvent | calling RudderStack identify",{user_id:M,traits:H}),n.identifyEvent(M,H)):c.some(Q=>Q.userId===M)||(t("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:M}),c.push({userId:M,traits:H}))),r?.has_initialized&&K&&(t("identifyEvent | calling PostHog identify",{user_id:M,traits:K}),r.identifyEvent(M,K))},N=()=>{t("reset | resetting all providers"),n?.has_initialized&&(t("reset | resetting RudderStack"),n.reset()),r?.has_initialized&&(t("reset | resetting PostHog"),r.reset())},ve=T=>"event_metadata"in T||"cta_information"in T||"error"in T,Ge={initialise:f,setAttributes:p,identifyEvent:B,backfillPersonProperties:({user_id:T,email:x,country_of_residence:M})=>{t("backfillPersonProperties | called",{user_id:T}),r?.has_initialized?(t("backfillPersonProperties | backfilling person properties in PostHog",{user_id:T}),r.backfillPersonProperties({user_id:T,email:x,country_of_residence:M})):t("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:v,getFeatureValue:_,getGrowthbookStatus:b,isFeatureOn:E,setUrl:C,getId:P,getAnonymousId:I,trackEvent:(T,x)=>{let M=P(),L={};if(t("trackEvent | called",{event:T,analytics_data:x,userId:M,core_data:o}),ve(x)){let K=x;L={...K,event_metadata:{...o,...M&&!o.user_id&&{user_id:M},...K.event_metadata}},t("trackEvent | built V2 payload",{event:T,final_payload:L})}else L={...o,...x,...M&&!o.user_id&&{user_id:M}},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=n?.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}),tu(T,L));else{l.length>0&&(t(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(Q=>{let V=qt(Q.payload);n?.track(Q.event,V)}),l=[]);let K=qt(L);t("trackEvent | sending event to RudderStack",{event:T,payload:K}),n?.track(T,K)}if(r?.has_initialized){let K=["page_name","user_language","form_name","version","email_hash"],Q=eu(L),V=qt(Object.fromEntries(Object.entries(Q).filter(([ie])=>!K.includes(ie))));t("trackEvent | sending event to PostHog",{event:T,payload:V}),r.capture(T,V)}},getInstances:()=>({ab:i,tracking:n,posthog:r}),pageView:z,reset:N};return typeof window<"u"&&(window.AnalyticsInstance=Ge),Ge}var rf=AE();return df(TE);})();
17
+ `)).length,n=0;n<i;n++){var o=s.charCodeAt(n),a=null;o<128?t++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Ze(a)||(t>e&&(r+=s.substring(e,t)),r+=a,e=t=n+1)}return t>e&&(r+=s.substring(e,s.length)),r},xb=!!Jo||!!Yo,Ad="text/plain",sr=function(s,e,t){var i;t===void 0&&(t=!0);var[n,r]=s.split("?"),o=k({},e),a=(i=r?.split("&").map((c=>{var u,[h,g]=c.split("="),f=t&&(u=o[h])!==null&&u!==void 0?u:g;return delete o[h],h+"="+f})))!==null&&i!==void 0?i:[],l=wb(o);return l&&a.push(l),n+"?"+a.join("&")},Ei=(s,e)=>JSON.stringify(s,((t,i)=>typeof i=="bigint"?i.toString():i),e),Bo=s=>{var{data:e,compression:t}=s;if(e){if(t===yt.GZipJS){var i=Nb((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var h=new We(l.length+(l.length>>>1)),g=0,f=function(b){h[g++]=b},p=0;p<u;++p){if(g+5>h.length){var v=new We(g+8+(u-p<<1));v.set(h),h=v}var _=l.charCodeAt(p);_<128||c?f(_):_<2048?(f(192|_>>>6),f(128|63&_)):_>55295&&_<57344?(f(240|(_=65536+(1047552&_)|1023&l.charCodeAt(++p))>>>18),f(128|_>>>12&63),f(128|_>>>6&63),f(128|63&_)):(f(224|_>>>12),f(128|_>>>6&63),f(128|63&_))}return Ph(h,0,g)})(Ei(e)),{mtime:0}),n=new Blob([i],{type:Ad});return{contentType:Ad,body:n,estimatedSize:n.size}}if(t===yt.Base64){var r=(function(l){var c,u,h,g,f,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,_=0,b="",E=[];if(!l)return l;l=Db(l);do c=(f=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=f>>12&63,h=f>>6&63,g=63&f,E[_++]=p.charAt(c)+p.charAt(u)+p.charAt(h)+p.charAt(g);while(v<l.length);switch(b=E.join(""),l.length%3){case 1:b=b.slice(0,-2)+"==";break;case 2:b=b.slice(0,-1)+"="}return b})(Ei(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Ei(l)))(r);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Ei(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Bn=[];Yo&&Bn.push({transport:"fetch",method:s=>{var e,t,{contentType:i,body:n,estimatedSize:r}=(e=Bo(s))!==null&&e!==void 0?e:{},o=new Headers;Z(s.headers,(function(u,h){o.append(h,u)})),i&&o.append("Content-Type",i);var a=s.url,l=null;if(td){var c=new td;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),s.timeout)}}Yo(a,k({method:s?.method||"GET",headers:o,keepalive:s.method==="POST"&&(r||0)<52428.8,body:n,signal:(t=l)==null?void 0:t.signal},s.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)}s.callback==null||s.callback(g)})))).catch((u=>{A.error(u),s.callback==null||s.callback({statusCode:0,error:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Jo&&Bn.push({transport:"XHR",method:s=>{var e,t=new Jo;t.open(s.method||"GET",s.url,!0);var{contentType:i,body:n}=(e=Bo(s))!==null&&e!==void 0?e:{};Z(s.headers,(function(r,o){t.setRequestHeader(o,r)})),i&&t.setRequestHeader("Content-Type",i),s.timeout&&(t.timeout=s.timeout),s.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var r={statusCode:t.status,text:t.responseText};if(t.status===200)try{r.json=JSON.parse(t.responseText)}catch{}s.callback==null||s.callback(r)}},t.send(n)}}),Ve!=null&&Ve.sendBeacon&&Bn.push({transport:"sendBeacon",method:s=>{var e=sr(s.url,{beacon:"1"});try{var t,{contentType:i,body:n}=(t=Bo(s))!==null&&t!==void 0?t:{},r=typeof n=="string"?new Blob([n],{type:i}):n;Ve.sendBeacon(e,r)}catch{}}});ir=function(s,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(s)}catch{return!1}};Nh={exact:(s,e)=>e.some((t=>s.some((i=>t===i)))),is_not:(s,e)=>e.every((t=>s.every((i=>t!==i)))),regex:(s,e)=>e.some((t=>s.some((i=>ir(t,i))))),not_regex:(s,e)=>e.every((t=>s.every((i=>!ir(t,i))))),icontains:(s,e)=>e.map(Mn).some((t=>s.map(Mn).some((i=>t.includes(i))))),not_icontains:(s,e)=>e.map(Mn).every((t=>s.map(Mn).every((i=>!t.includes(i))))),gt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((n=>i>parseFloat(n)))})),lt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((n=>i<parseFloat(n)))}))},Mn=s=>s.toLowerCase();Vo=le("[Error tracking]"),xa=class{constructor(e){var t,i;this.nt=[],this.ot=new ra([new aa,new ga,new ca,new la,new ha,new da,new ua,new fa],ab()),this._instance=e,this.nt=(t=(i=this._instance.persistence)==null?void 0:i.get_property(va))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,i,n;if("errorTracking"in e){var r=(t=(i=e.errorTracking)==null?void 0:i.suppressionRules)!==null&&t!==void 0?t:[],o=(n=e.errorTracking)==null?void 0:n.captureExtensionExceptions;this.nt=r,this._instance.persistence&&this._instance.persistence.register({[va]:this.nt,[gd]:o})}}get ut(){var e,t=!!this._instance.get_property(gd),i=this._instance.config.error_tracking.captureExtensionExceptions;return(e=i??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ot.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ht(t)){if(this.dt(t))return void Vo.info("Skipping exception capture because a suppression rule matched");if(!this.ut&&this.vt(t))return void Vo.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ct(t))return void Vo.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",ft:!0})}dt(e){if(e.length===0)return!1;var t=e.reduce(((i,n)=>{var{type:r,value:o}=n;return he(r)&&r.length>0&&i.$exception_types.push(r),he(o)&&o.length>0&&i.$exception_values.push(o),i}),{$exception_types:[],$exception_values:[]});return this.nt.some((i=>{var n=i.values.map((r=>{var o,a=Nh[r.operator],l=q(r.value)?r.value:[r.value],c=(o=t[r.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)}));return i.type==="OR"?n.some(Boolean):n.every(Boolean)}))}vt(e){return e.flatMap((t=>{var i,n;return(i=(n=t.stacktrace)==null?void 0:n.frames)!==null&&i!==void 0?i:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ct(e){if(e.length>0){var t,i,n,r,o=(t=(i=e[0].stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(n=a==null||(r=a.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&n!==void 0&&n}return!1}ht(e){return!U(e)&&q(e)}},Fn="https?://(.*)",Fs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Lb=$s(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Fs),Ni="<masked>",$b=["li_fat_id"];De=le("[FeatureFlags]"),di=le("[FeatureFlags]",{debugEnabled:!0}),Ub="errors_while_computing_flags",Bb="flag_missing",Vb="quota_limited",Gb="timeout",jb="connection_error",Hb="unknown_error",qb=s=>"api_error_"+s,Go="$active_feature_flags",As="$override_feature_flags",Rd="$feature_flag_payloads",hi="$override_feature_flag_payloads",Od="$feature_flag_request_id",Cd=s=>{var e={};for(var[t,i]of Un(s||{}))i&&(e[t]=i);return e},zb=s=>{var e=s.flags;return e?(s.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,(i=e[t].variant)!==null&&i!==void 0?i:e[t].enabled]}))),s.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return(i=e[t].metadata)==null?void 0:i.payload})).map((t=>{var i;return[t,(i=e[t].metadata)==null?void 0:i.payload]})))):De.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),s},Kb=(function(s){return s.FeatureFlags="feature_flags",s.Recordings="recordings",s})({}),La=class{constructor(e){this._t=!1,this.bt=!1,this.yt=!1,this.wt=!1,this.xt=!1,this.$t=!1,this.Et=!1,this.St=!1,this._instance=e,this.featureFlagEventHandlers=[]}kt(){var e,t;return(e=(t=this._instance.persistence)==null?void 0:t.Pt(this._instance.config.feature_flag_cache_ttl_ms))!==null&&e!==void 0&&e}Tt(){return!!this.kt()&&(this.St||this.yt||(this.St=!0,De.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Ct(){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.Et||(De.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Et=!0),t!=null&&t.length?t.filter((i=>{var n=i&&typeof i=="string"&&i.trim().length>0;return n||De.error("Invalid evaluation context found:",i,"Expected non-empty string"),n})):[]}It(){return this.Ct().length>0}get hasLoadedFlags(){return this.bt}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(_a),t=this._instance.get_property(As),i=this._instance.get_property(hi);if(!i&&!t)return e||{};var n=ue({},e||{}),r=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var o of r){var a,l,c=n[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=i?.[o],p=k({},c,{enabled:h,variant:h?g??c?.variant:void 0});h!==c?.enabled&&(p.original_enabled=c?.enabled),g!==c?.variant&&(p.original_variant=c?.variant),f&&(p.metadata=k({},c?.metadata,{payload:f,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),n[o]=p}return this._t||(De.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:n}),this._t=!0),n}getFlagVariants(){var e=this._instance.get_property(Ps),t=this._instance.get_property(As);if(!t)return e||{};for(var i=ue({},e),n=Object.keys(t),r=0;r<n.length;r++)i[n[r]]=t[n[r]];return this._t||(De.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._t=!0),i}getFlagPayloads(){var e=this._instance.get_property(Rd),t=this._instance.get_property(hi);if(!t)return e||{};for(var i=ue({},e||{}),n=Object.keys(t),r=0;r<n.length;r++)i[n[r]]=t[n[r]];return this._t||(De.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._t=!0),i}reloadFeatureFlags(){this.wt||this._instance.config.advanced_disable_feature_flags||this.Rt||(this._instance.Ft.emit("featureFlagsReloading",!0),this.Rt=setTimeout((()=>{this.Ot()}),5))}Mt(){clearTimeout(this.Rt),this.Rt=void 0}ensureFlagsLoaded(){this.bt||this.yt||this.Rt||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.wt=e}Ot(e){var t;if(this.Mt(),!this._instance.At())if(this.yt)this.xt=!0;else{var i=this._instance.config.token,n=this._instance.get_property("$device_id"),r={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:k({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(bi)||{}),group_properties:this._instance.get_property(Yt),timezone:Bh()};Ze(n)||w(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.It()&&(r.evaluation_contexts=this.Ct());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.yt=!0,this._instance._send_request({method:"POST",url:a,data:r,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.xt||(this.$anon_distinct_id=void 0),g=!1),this.yt=!1,!r.disable_flags||this.xt){this.$t=!g;var f=[];l.error?l.error instanceof Error?f.push(l.error.name==="AbortError"?Gb:jb):f.push(Hb):l.statusCode!==200&&f.push(qb(l.statusCode)),(c=l.json)!=null&&c.errorsWhileComputingFlags&&f.push(Ub);var p=!((u=l.json)==null||(u=u.quotaLimited)==null||!u.includes(Kb.FeatureFlags));if(p&&f.push(Vb),(h=this._instance.persistence)==null||h.register({[ya]:f}),p)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=l.json)!==null&&v!==void 0?v:{},g),this.xt&&(this.xt=!1,this.Ot())}}}})}}getFeatureFlag(e,t){var i;if(t===void 0&&(t={}),!t.fresh||this.$t)if(this.bt||this.getFlags()&&this.getFlags().length>0){if(!this.Tt()){var n=this.getFeatureFlagResult(e,t);return(i=n?.variant)!==null&&i!==void 0?i:n?.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.$t)if(this.bt||this.getFlags()&&this.getFlags().length>0){if(!this.Tt()){var i=this.getFlagVariants(),n=e in i,r=i[e],o=this.getFlagPayloads()[e],a=String(r),l=this._instance.get_property(Od)||void 0,c=this._instance.get_property(zn)||void 0,u=this._instance.get_property(qn)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var h,g,f,p,v,_,b,E,C,P;q(u[e])?u[e].push(a):u[e]=[a],(h=this._instance.persistence)==null||h.register({[qn]:u});var I=this.getFeatureFlagDetails(e),z=[...(g=this._instance.get_property(ya))!==null&&g!==void 0?g:[]];w(r)&&z.push(Bb);var B={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((f=this._instance.config.bootstrap)==null||(f=f.featureFlags)==null?void 0:f[e])||null,$feature_flag_bootstrapped_payload:((p=this._instance.config.bootstrap)==null||(p=p.featureFlagPayloads)==null?void 0:p[e])||null,$used_bootstrap_value:!this.$t};w(I==null||(v=I.metadata)==null?void 0:v.version)||(B.$feature_flag_version=I.metadata.version);var N,ve=(_=I==null||(b=I.reason)==null?void 0:b.description)!==null&&_!==void 0?_:I==null||(E=I.reason)==null?void 0:E.code;ve&&(B.$feature_flag_reason=ve),I!=null&&(C=I.metadata)!=null&&C.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(n){var _e=o;if(!w(o))try{_e=JSON.parse(o)}catch{}return{key:e,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:_e}}}}else De.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var i=this._instance.config.token,n={distinct_id:this._instance.get_distinct_id(),token:i};this.It()&&(n.evaluation_contexts=this.Ct()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:n,compression:this._instance.config.disable_compression?void 0:yt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:r=>{var o,a=(o=r.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.$t){if(this.bt||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return w(i)?void 0:!!i}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.bt=!0;var i=this.getFlagVariants(),n=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var h=zb(o),g=h.flags,f=h.featureFlags,p=h.featureFlagPayloads;if(f){var v=o.requestId,_=o.evaluatedAt;if(q(f)){De.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var b={};if(f)for(var E=0;E<f.length;E++)b[f[E]]=!0;a&&a.register({[Go]:f,[Ps]:b})}else{var C=f,P=p,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)})));C=k({},l,Object.fromEntries(Object.entries(C).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 C=k({},l,C),P=k({},c,P),I=k({},u,I);a&&a.register(k({[Go]:Object.keys(Cd(C)),[Ps]:C||{},[Rd]:P||{},[_a]:I||{}},v?{[Od]:v}:{},_?{[zn]:_}:{}))}}})(e,this._instance.persistence,i,n,r),t||(this.St=!1),this.Dt(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(As),this._instance.persistence.unregister(hi),this.Dt(),di.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,i=e;if(this._t=!!((t=i.suppressWarning)!==null&&t!==void 0&&t),"flags"in i){if(i.flags===!1)this._instance.persistence.unregister(As),di.info("Flag overrides cleared");else if(i.flags){if(q(i.flags)){for(var n={},r=0;r<i.flags.length;r++)n[i.flags[r]]=!0;this._instance.persistence.register({[As]:n})}else this._instance.persistence.register({[As]:i.flags});di.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this._instance.persistence.unregister(hi),di.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[hi]:i.payloads}),di.info("Payload overrides set",{payloads:i.payloads}))),void this.Dt()}this.Dt()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.bt){var{flags:t,flagVariants:i}=this.jt();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var n,r=(this._instance.get_property(yi)||[]).find((c=>c.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};r&&(a.$early_access_feature_name=r.name),i&&(a.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=k({},this.getFlagVariants(),{[e]:t});(n=this._instance.persistence)==null||n.register({[Go]:Object.keys(Cd(l)),[Ps]:l}),this.Dt()}getEarlyAccessFeatures(e,t,i){t===void 0&&(t=!1);var n=this._instance.get_property(yi),r=i?"&"+i.map((o=>"stage="+o)).join("&"):"";if(n&&!t)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+r),method:"GET",callback:o=>{var a,l;if(o.json){var c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(yi),(l=this._instance.persistence)==null||l.register({[yi]:c}),e(c)}}})}jt(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((i=>t[i])),flagVariants:Object.keys(t).filter((i=>t[i])).reduce(((i,n)=>(i[n]=t[n],i)),{})}}Dt(e){var{flags:t,flagVariants:i}=this.jt();this.featureFlagEventHandlers.forEach((n=>n(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(bi)||{};this._instance.register({[bi]:k({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(bi)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(Yt)||{};Object.keys(i).length!==0&&Object.keys(i).forEach((n=>{i[n]=k({},i[n],e[n]),delete e[n]})),this._instance.register({[Yt]:k({},i,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.bt=!1,this.yt=!1,this.wt=!1,this.xt=!1,this.$t=!1,this.$anon_distinct_id=void 0,this.Mt(),this._t=!1}},Wb=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ai=class{constructor(e,t){this.N=e,this.props={},this.Lt=!1,this.Nt=(i=>{var n="";return i.token&&(n=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+n+"_posthog"})(e),this.B=this.Ut(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.zt}Ut(e){Wb.indexOf(e.persistence.toLowerCase())===-1&&(A.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(n){n===void 0&&(n=[]);var r=[...yb,...n];return k({},ae,{D:function(o){try{var a={};try{a=ot.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,c,u,h){try{ae.j(o,a,void 0,void 0,h);var g={};r.forEach((f=>{a[f]&&(g[f]=a[f])})),Object.keys(g).length&&ot.j(o,g,l,c,u,h)}catch(f){ae.M(f)}},L:function(o,a){try{m?.localStorage.removeItem(o),ot.L(o,a)}catch(l){ae.M(l)}}})})(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return i==="localstorage"&&ae.O()?ae:i==="localstorage+cookie"&&t.O()?t:i==="sessionstorage"&&ye.O()?ye:i==="memory"?bb:i==="cookie"?ot:t.O()?t:ot}Pt(e){var t=e??this.N.feature_flag_cache_ttl_ms;if(!t||t<=0)return!1;var i=this.props[zn];return!i||typeof i!="number"||Date.now()-i>t}properties(){var e={};return Z(this.props,((t,i)=>{if(i===Ps&&fe(t)){if(!this.Pt())for(var n=Object.keys(t),r=0;r<n.length;r++)e["$feature/"+n[r]]=t[n[r]]}else a=i,l=!1,(Ze(o=pb)?l:ed&&o.indexOf===ed?o.indexOf(a)!=-1:(Z(o,(function(c){if(l||(l=c===a))return jn})),l))||(e[i]=t);var o,a,l})),e}load(){if(!this.zt){var e=this.B.D(this.Nt);e&&(this.props=ue({},e))}}save(){this.zt||this.B.j(this.Nt,this.props,this.Ht,this.Bt,this.qt,this.N.debug)}remove(){this.B.L(this.Nt,!1),this.B.L(this.Nt,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(fe(e)){w(t)&&(t="None"),this.Ht=w(i)?this.Wt:i;var n=!1;if(Z(e,((r,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=r,n=!0)})),n)return this.save(),!0}return!1}register(e,t){if(fe(e)){this.Ht=w(t)?this.Wt:t;var i=!1;if(Z(e,((n,r)=>{e.hasOwnProperty(r)&&this.props[r]!==n&&(this.props[r]=n,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Lt){var e=xh(this.N.custom_campaign_params,this.N.mask_personal_data_properties,this.N.custom_personal_data_properties);Cs(rl(e))||this.register(e),this.Lt=!0}}update_search_keyword(){var e;this.register((e=S?.referrer)?$h(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Mh(),$referring_domain:S!=null&&S.referrer&&((e=Yn(S.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[ka]||this.props[Sa]||this.register_once({[Kn]:Fh(this.N.mask_personal_data_properties,this.N.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Z([Sa,ka],(o=>{var a=this.props[o];a&&Z(a,(function(l,c){e["$initial_"+Qo(c)]=l}))}));var t,i,n=this.props[Kn];if(n){var r=(t=Uh(n),i={},Z(t,(function(o,a){i["$initial_"+Qo(a)]=o})),i);ue(e,r)}return e}safe_merge(e){return Z(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this.Wt=this.Ht=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((u,h)=>u===c[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var n=this.Ut(e),r=this.props;this.clear(),this.B=n,this.props=r,this.save()}}set_disabled(e){this.zt=e,this.zt?this.remove():this.save()}set_cross_subdomain(e){e!==this.Bt&&(this.Bt=e,this.remove(),this.save())}set_secure(e){e!==this.qt&&(this.qt=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[mi]||{};i[e]=t,this.props[mi]=i,this.save()}remove_event_timer(e){var t=(this.props[mi]||{})[e];return w(t)||(delete this.props[mi][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},fi=(function(s){return s.Activation="events",s.Cancellation="cancelEvents",s})({}),hk=(function(s){return s.Button="button",s.Tab="tab",s.Selector="selector",s})({}),fk=(function(s){return s.TopLeft="top_left",s.TopRight="top_right",s.TopCenter="top_center",s.MiddleLeft="middle_left",s.MiddleRight="middle_right",s.MiddleCenter="middle_center",s.Left="left",s.Center="center",s.Right="right",s.NextToTrigger="next_to_trigger",s})({}),gk=(function(s){return s.Top="top",s.Left="left",s.Right="right",s.Bottom="bottom",s})({}),jo=(function(s){return s.Popover="popover",s.API="api",s.Widget="widget",s.ExternalSurvey="external_survey",s})({}),pk=(function(s){return s.Open="open",s.MultipleChoice="multiple_choice",s.SingleChoice="single_choice",s.Rating="rating",s.Link="link",s})({}),vk=(function(s){return s.NextQuestion="next_question",s.End="end",s.ResponseBased="response_based",s.SpecificQuestion="specific_question",s})({}),_k=(function(s){return s.Once="once",s.Recurring="recurring",s.Always="always",s})({}),ki=(function(s){return s.SHOWN="survey shown",s.DISMISSED="survey dismissed",s.SENT="survey sent",s.ABANDONED="survey abandoned",s})({}),Ho=(function(s){return s.SURVEY_ID="$survey_id",s.SURVEY_NAME="$survey_name",s.SURVEY_RESPONSE="$survey_response",s.SURVEY_ITERATION="$survey_iteration",s.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",s.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",s.SURVEY_SUBMISSION_ID="$survey_submission_id",s.SURVEY_QUESTIONS="$survey_questions",s.SURVEY_COMPLETED="$survey_completed",s.PRODUCT_TOUR_ID="$product_tour_id",s.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",s})({}),$a=(function(s){return s.Popover="popover",s.Inline="inline",s})({}),J=le("[Surveys]"),Vh="seenSurvey_",Xb=(s,e)=>{var t="$survey_"+e+"/"+s.id;return s.current_iteration&&s.current_iteration>0&&(t="$survey_"+e+"/"+s.id+"/"+s.current_iteration),t},Pd=s=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(Vh,s),Yb=[jo.Popover,jo.Widget,jo.API],Jb={ignoreConditions:!1,ignoreDelay:!1,displayType:$a.Popover},Di=class{constructor(){this.Gt={},this.Gt={}}on(e,t){return this.Gt[e]||(this.Gt[e]=[]),this.Gt[e].push(t),()=>{this.Gt[e]=this.Gt[e].filter((i=>i!==t))}}emit(e,t){for(var i of this.Gt[e]||[])i(t);for(var n of this.Gt["*"]||[])n(e,t)}};Ma=class{constructor(e){this.Vt=new Di,this.Jt=(t,i)=>this.Kt(t,i)&&this.Yt(t,i)&&this.Xt(t,i)&&this.Qt(t,i),this.Kt=(t,i)=>i==null||!i.event||t?.event===i?.event,this._instance=e,this.Zt=new Set,this.ti=new Set}init(){var e;if(!w((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((i,n)=>{this.on(i,n)}))}}register(e){var t,i;if(!w((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.ti)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.Zt)==null||u.add(c?.event||"")}))})),(i=this._instance)!=null&&i.autocapture)){var n,r=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&r.add(l?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){var i;t!=null&&e.length!=0&&(this.Zt.has(e)||this.Zt.has(t?.event))&&this.ti&&((i=this.ti)==null?void 0:i.size)>0&&this.ti.forEach((n=>{this.ii(t,n)&&this.Vt.emit("actionCaptured",n.name)}))}ei(e){this.onAction("actionCaptured",(t=>e(t)))}ii(e,t){if(t?.steps==null)return!1;for(var i of t.steps)if(this.Jt(e,i))return!0;return!1}onAction(e,t){return this.Vt.on(e,t)}Yt(e,t){if(t!=null&&t.url){var i,n=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!n||typeof n!="string"||!Ts(n,t.url,t.url_matching||"contains"))return!1}return!0}Xt(e,t){return!!this.ri(e,t)&&!!this.si(e,t)&&!!this.ni(e,t)}ri(e,t){var i;if(t==null||!t.href)return!0;var n=this.oi(e);if(n.length>0)return n.some((a=>Ts(a.href,t.href,t.href_matching||"exact")));var r,o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!o&&Ts((r=o.match(/(?::|")href="(.*?)"/))?r[1]:"",t.href,t.href_matching||"exact")}si(e,t){var i;if(t==null||!t.text)return!0;var n=this.oi(e);if(n.length>0)return n.some((c=>Ts(c.text,t.text,t.text_matching||"exact")||Ts(c.$el_text,t.text,t.text_matching||"exact")));var r,o,a,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(r=(function(c){for(var u,h=[],g=/(?::|")text="(.*?)"/g;!U(u=g.exec(c));)h.includes(u[1])||h.push(u[1]);return h})(l),o=t.text,a=t.text_matching||"exact",r.some((c=>Ts(c,o,a))))}ni(e,t){var i,n;if(t==null||!t.selector)return!0;var r=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(r!=null&&r.includes(t.selector))return!0;var o=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}oi(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Qt(e,t){return t==null||!t.properties||t.properties.length===0||Dh(t.properties.reduce(((i,n)=>{var r=q(n.value)?n.value.map(String):n.value!=null?[String(n.value)]:[];return i[n.key]={values:r,operator:n.operator||"exact"},i}),{}),e?.properties)}},Fa=class{constructor(e){this._instance=e,this.ai=new Map,this.li=new Map,this.ui=new Map}hi(e,t){return!!e&&Dh(e.propertyFilters,t?.properties)}di(e,t){var i=new Map;return e.forEach((n=>{var r;(r=n.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((o=>{if(o!=null&&o.name){var a=i.get(o.name)||[];a.push(n.id),i.set(o.name,a)}}))})),i}vi(e,t,i){var n=(i===fi.Activation?this.ai:this.li).get(e),r=[];return this.ci((o=>{r=o.filter((a=>n?.includes(a.id)))})),r.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[i])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.hi(l,t)}))}register(e){var t;w((t=this._instance)==null?void 0:t._addCaptureHook)||(this.fi(e),this.pi(e))}pi(e){var t=e.filter((i=>{var n,r;return((n=i.conditions)==null?void 0:n.actions)&&((r=i.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0}));t.length!==0&&(this.gi==null&&(this.gi=new Ma(this._instance),this.gi.init(),this.gi.ei((i=>{this.onAction(i)}))),t.forEach((i=>{var n,r,o,a,l;i.conditions&&(n=i.conditions)!=null&&n.actions&&(r=i.conditions)!=null&&(r=r.actions)!=null&&r.values&&((o=i.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.gi)==null||a.register(i.conditions.actions.values),(l=i.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.ui.get(c.name);u&&u.push(i.id),this.ui.set(c.name,u||[i.id])}})))})))}fi(e){var t,i=e.filter((r=>{var o,a;return((o=r.conditions)==null?void 0:o.events)&&((a=r.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),n=e.filter((r=>{var o,a;return((o=r.conditions)==null?void 0:o.cancelEvents)&&((a=r.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(i.length!==0||n.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((r,o)=>{this.onEvent(r,o)})),this.ai=this.di(e,fi.Activation),this.li=this.di(e,fi.Cancellation))}onEvent(e,t){var i,n=this.mi(),r=this.bi(),o=this.yi(),a=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[r])||[];if(o===e&&t&&a.length>0){var l,c;n.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var h=a.indexOf(u);h>=0&&(a.splice(h,1),this.wi(a))}}else{if(this.li.has(e)){var g=this.vi(e,t,fi.Cancellation);g.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:g.map((p=>p.id))}),g.forEach((p=>{var v=a.indexOf(p.id);v>=0&&a.splice(v,1),this.xi(p.id)})),this.wi(a))}if(this.ai.has(e)){n.info("event name matched",{event:e,eventPayload:t,items:this.ai.get(e)});var f=this.vi(e,t,fi.Activation);this.wi(a.concat(f.map((p=>p.id))||[]))}}}onAction(e){var t,i=this.bi(),n=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[i])||[];this.ui.has(e)&&this.wi(n.concat(this.ui.get(e)||[]))}wi(e){var t,i=this.mi(),n=this.bi(),r=[...new Set(e)].filter((o=>!this.$i(o)));i.info("updating activated items",{activatedItems:r}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[n]:r})}getActivatedIds(){var e,t=this.bi(),i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return i||[]}getEventToItemsMap(){return this.ai}Ei(){return this.gi}},Ua=class extends Fa{constructor(e){super(e)}bi(){return"$surveys_activated"}yi(){return ki.SHOWN}ci(e){var t;(t=this._instance)==null||t.getSurveys(e)}xi(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}mi(){return J}$i(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ba=class{constructor(e){this.Si=void 0,this._surveyManager=null,this.ki=!1,this.Pi=[],this.Ti=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(U(t))return J.warn("Flags not loaded yet. Not loading surveys.");var i=q(t);this.Si=i?t.length>0:t,J.info("flags response received, isSurveysEnabled: "+this.Si),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(i!=null&&i.startsWith(Vh)||i!=null&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((n=>localStorage.removeItem(n)))}loadIfEnabled(){if(!this._surveyManager)if(this.ki)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 e=O?.__PosthogExtensions__;if(e){if(!w(this.Si)||this._instance.config.advanced_enable_surveys){var t=this.Si||this._instance.config.advanced_enable_surveys;this.ki=!0;try{var i=e.generateSurveys;if(i)return void this.Ci(i,t);var n=e.loadExternalDependency;if(!n)return void this.Ii("PostHog loadExternalDependency extension not found.");n(this._instance,"surveys",(r=>{r||!e.generateSurveys?this.Ii("Could not load surveys script",r):this.Ci(e.generateSurveys,t)}))}catch(r){throw this.Ii("Error initializing surveys",r),r}finally{this.ki=!1}}}else J.error("PostHog Extensions not found.")}}Ci(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ua(this._instance),J.info("Surveys loaded successfully"),this.Ri({isLoaded:!0})}Ii(e,t){J.error(e,t),this.Ri({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Pi.push(e),this._surveyManager&&this.Ri({isLoaded:!0}),()=>{this.Pi=this.Pi.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return J.info("Disabled. Not loading surveys."),e([]);var i,n=this._instance.get_property(ma);if(n&&!t)return e(n,{isLoaded:!0});typeof Promise<"u"&&this.Ti?this.Ti.then((r=>{var{surveys:o,context:a}=r;return e(o,a)})):(typeof Promise<"u"&&(this.Ti=new Promise((r=>{i=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:r=>{var o;this.Ti=null;var a=r.statusCode;if(a!==200||!r.json){var l="Surveys API could not be loaded, status: "+a;J.error(l);var c={isLoaded:!1,error:l};return e([],c),void(i==null||i({surveys:[],context:c}))}var u,h=r.json.surveys||[],g=h.filter((p=>(function(v){return!(!v.start_date||v.end_date)})(p)&&((function(v){var _;return!((_=v.conditions)==null||(_=_.events)==null||(_=_.values)==null||!_.length)})(p)||(function(v){var _;return!((_=v.conditions)==null||(_=_.actions)==null||(_=_.values)==null||!_.length)})(p))));g.length>0&&((u=this._surveyEventReceiver)==null||u.register(g)),(o=this._instance.persistence)==null||o.register({[ma]:h});var f={isLoaded:!0};e(h,f),i?.({surveys:h,context:f})}}))}Ri(e){for(var t of this.Pi)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){J.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!U(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);J.warn("init was not called")}Fi(e){var t=null;return this.getSurveys((i=>{var n;t=(n=i.find((r=>r.id===e)))!==null&&n!==void 0?n:null})),t}Oi(e){if(U(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.Fi(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(U(this._surveyManager))return J.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.Oi(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return U(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((i=>{this.getSurveys((n=>{var r,o=(r=n.find((l=>l.id===e)))!==null&&r!==void 0?r:null;if(o){var a=this.Oi(o);i({visible:a.eligible,disabledReason:a.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var n;if(U(this._surveyManager))J.warn("init was not called");else{var r=typeof e=="string"?this.Fi(e):e;if(r!=null&&r.id)if(Yb.includes(r.type)){var o=S?.querySelector(t);if(o)return(n=r.appearance)!=null&&n.surveyPopupDelaySeconds?(J.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,l;J.info("Rendering survey "+r.id+" with delay of "+((a=r.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(r,o,i),J.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,o,i);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(e,t){var i;if(U(this._surveyManager))J.warn("init was not called");else{var n=this.Fi(e);if(n){var r=n;if((i=n.appearance)!=null&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(r=k({},n,{appearance:k({},n.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==$a.Popover&&t.initialResponses&&J.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(n);if(!o.visible)return void J.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==$a.Inline?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}else J.warn("Survey not found")}}cancelPendingSurvey(e){U(this._surveyManager)?J.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},ze=le("[Conversations]"),Va=class{constructor(e){this.Mi=void 0,this._conversationsManager=null,this.Ai=!1,this.Di=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;U(t)||(kt(t)?this.Mi=t:(this.Mi=t.enabled,this.Di=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Mi=void 0,this.Di=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ai||this._instance.config.disable_conversations||bh(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=O?.__PosthogExtensions__;if(e&&!w(this.Mi)&&this.Mi)if(this.Di&&this.Di.token){this.Ai=!0;try{var t=e.initConversations;if(t)return this.ji(t),void(this.Ai=!1);var i=e.loadExternalDependency;if(!i)return void this.Li("PostHog loadExternalDependency extension not found.");i(this._instance,"conversations",(n=>{n||!e.initConversations?this.Li("Could not load conversations script",n):this.ji(e.initConversations),this.Ai=!1}))}catch(n){this.Li("Error initializing conversations",n),this.Ai=!1}}else ze.error("Conversations enabled but missing token in remote config.")}}ji(e){if(this.Di)try{this._conversationsManager=e(this.Di,this._instance),ze.info("Conversations loaded successfully")}catch(t){this.Li("Error completing conversations initialization",t)}else ze.error("Cannot complete initialization: remote config is null")}Li(e,t){ze.error(e,t),this._conversationsManager=null,this.Ai=!1}show(){this._conversationsManager?this._conversationsManager.show():ze.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Mi===!0&&!Ze(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,i){var n=this;return _t((function*(){return n._conversationsManager?n._conversationsManager.sendMessage(e,t,i):(ze.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var i=this;return _t((function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(ze.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(ze.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(ze.warn("Conversations not available yet."),null)}))()}requestRestoreLink(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(ze.warn("Conversations not available yet."),null)}))()}restoreFromToken(e){var t=this;return _t((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(ze.warn("Conversations not available yet."),null)}))()}restoreFromUrlToken(){var e=this;return _t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(ze.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},Qb=(function(s){return s.SHOWN="product tour shown",s.DISMISSED="product tour dismissed",s.COMPLETED="product tour completed",s.STEP_SHOWN="product tour step shown",s.STEP_COMPLETED="product tour step completed",s.BUTTON_CLICKED="product tour button clicked",s.STEP_SELECTOR_FAILED="product tour step selector failed",s.BANNER_CONTAINER_SELECTOR_FAILED="product tour banner container selector failed",s.BANNER_ACTION_CLICKED="product tour banner action clicked",s})({}),Nd=(function(s){return s.TOUR_ID="$product_tour_id",s.TOUR_NAME="$product_tour_name",s.TOUR_ITERATION="$product_tour_iteration",s.TOUR_RENDER_REASON="$product_tour_render_reason",s.TOUR_STEP_ID="$product_tour_step_id",s.TOUR_STEP_ORDER="$product_tour_step_order",s.TOUR_STEP_TYPE="$product_tour_step_type",s.TOUR_DISMISS_REASON="$product_tour_dismiss_reason",s.TOUR_BUTTON_TEXT="$product_tour_button_text",s.TOUR_BUTTON_ACTION="$product_tour_button_action",s.TOUR_BUTTON_LINK="$product_tour_button_link",s.TOUR_BUTTON_TOUR_ID="$product_tour_button_tour_id",s.TOUR_STEPS_COUNT="$product_tour_steps_count",s.TOUR_STEP_SELECTOR="$product_tour_step_selector",s.TOUR_STEP_SELECTOR_FOUND="$product_tour_step_selector_found",s.TOUR_STEP_ELEMENT_TAG="$product_tour_step_element_tag",s.TOUR_STEP_ELEMENT_ID="$product_tour_step_element_id",s.TOUR_STEP_ELEMENT_CLASSES="$product_tour_step_element_classes",s.TOUR_STEP_ELEMENT_TEXT="$product_tour_step_element_text",s.TOUR_ERROR="$product_tour_error",s.TOUR_MATCHES_COUNT="$product_tour_matches_count",s.TOUR_FAILURE_PHASE="$product_tour_failure_phase",s.TOUR_WAITED_FOR_ELEMENT="$product_tour_waited_for_element",s.TOUR_WAIT_DURATION_MS="$product_tour_wait_duration_ms",s.TOUR_BANNER_SELECTOR="$product_tour_banner_selector",s.TOUR_LINKED_SURVEY_ID="$product_tour_linked_survey_id",s.USE_MANUAL_SELECTOR="$use_manual_selector",s.INFERENCE_DATA_PRESENT="$inference_data_present",s.TOUR_LAST_SEEN_DATE="$product_tour_last_seen_date",s.TOUR_TYPE="$product_tour_type",s})({}),Ga=class{constructor(e){var t;this.Ni=!1,this.Ui=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Ni=!0)}onRemoteConfig(e){var t,i=(t=e.logs)==null?void 0:t.captureConsoleLogs;!U(i)&&i&&(this.Ni=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Ni&&!this.Ui){var e=le("[logs]"),t=O?.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",(n=>{var r;n||(r=t.logs)==null||!r.initializeLogs?e.error("Could not load logs script",n):(t.logs.initializeLogs(this._instance),this.Ui=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},Dd=le("[RateLimiter]"),ja=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((n=>{Dd.info((n||"events")+" is quota limited."),this.serverLimits[n]=new Date().getTime()+6e4}))}catch(n){return void Dd.warn('could not rate limit - continuing. Error: "'+n?.message+'"',{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,n;e===void 0&&(e=!1);var{captureEventsBurstLimit:r,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(Ea))!==null&&t!==void 0?t:{tokens:r,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>r&&(l.tokens=r);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(n=this.instance.persistence)==null||n.set_property(Ea,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},gi=le("[RemoteConfig]"),nr=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}zi(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Hi(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 gi.info("Using preloaded remote config",this.remoteConfig),this.Bi(this.remoteConfig),void this.qi();if(this._instance.At())return void gi.warn("Remote config is disabled. Falling back to local config.");this.zi((e=>{if(!e)return gi.info("No config found after loading remote JS config. Falling back to JSON."),void this.Hi((t=>{this.Bi(t),this.qi()}));this.Bi(e),this.qi()}))}catch(e){gi.error("Error loading remote config",e)}}stop(){this.Wi&&(clearInterval(this.Wi),this.Wi=void 0)}refresh(){this._instance.At()||S?.visibilityState==="hidden"||this._instance.featureFlags.reloadFeatureFlags()}qi(){var e;if(!this.Wi){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.Wi=setInterval((()=>{this.refresh()}),t))}}Bi(e){e||gi.error("Failed to fetch remote config from PostHog."),this._instance.Bi(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||this._instance.featureFlags.ensureFlagsLoaded())}},Ha=3e3,qa=class{constructor(e,t){this.Gi=!0,this.Vi=[],this.Ji=at(t?.flush_interval_ms||Ha,250,5e3,A.createLogger("flush interval"),Ha),this.Ki=e}enqueue(e){this.Vi.push(e),this.Yi||this.Xi()}unload(){this.Qi();var e=this.Vi.length>0?this.Zi():{},t=Object.values(e);[...t.filter((i=>i.url.indexOf("/e")===0)),...t.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.Ki(k({},i,{transport:"sendBeacon"}))}))}enable(){this.Gi=!1,this.Xi()}Xi(){var e=this;this.Gi||(this.Yi=setTimeout((()=>{if(this.Qi(),this.Vi.length>0){var t=this.Zi(),i=function(){var r=t[n],o=new Date().getTime();r.data&&q(r.data)&&Z(r.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Ki(r)};for(var n in t)i()}}),this.Ji))}Qi(){clearTimeout(this.Yi),this.Yi=void 0}Zi(){var e={};return Z(this.Vi,(t=>{var i,n=t,r=(n?n.batchKey:null)||n.url;w(e[r])&&(e[r]=k({},n,{data:[]})),(i=e[r].data)==null||i.push(n.data)})),this.Vi=[],e}},Zb=["retriesPerformedSoFar"],za=class{constructor(e){this.te=!1,this.ie=3e3,this.Vi=[],this._instance=e,this.Vi=[],this.ee=!0,!w(m)&&"onLine"in m.navigator&&(this.ee=m.navigator.onLine,this.re=()=>{this.ee=!0,this.se()},this.ne=()=>{this.ee=!1},de(m,"online",this.re),de(m,"offline",this.ne))}get length(){return this.Vi.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=Yd(e,Zb);Rs(t)&&(i.url=sr(i.url,{retry_count:t})),this._instance._send_request(k({},i,{callback:n=>{n.statusCode!==200&&(n.statusCode<400||n.statusCode>=500)&&(t??0)<10?this.oe(k({retriesPerformedSoFar:t},i)):i.callback==null||i.callback(n)}}))}oe(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(t),n=Date.now()+i;this.Vi.push({retryAt:n,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),A.warn(r),this.te||(this.te=!0,this.ae())}ae(){if(this.le&&clearTimeout(this.le),this.Vi.length===0)return this.te=!1,void(this.le=void 0);this.le=setTimeout((()=>{this.ee&&this.Vi.length>0&&this.se(),this.ae()}),this.ie)}se(){var e=Date.now(),t=[],i=this.Vi.filter((r=>r.retryAt<e||(t.push(r),!1)));if(this.Vi=t,i.length>0)for(var{requestOptions:n}of i)this.retriableRequest(n)}unload(){for(var{requestOptions:e}of(this.le&&(clearTimeout(this.le),this.le=void 0),this.te=!1,w(m)||(this.re&&(m.removeEventListener("online",this.re),this.re=void 0),this.ne&&(m.removeEventListener("offline",this.ne),this.ne=void 0)),this.Vi))try{this._instance._send_request(k({},e,{transport:"sendBeacon"}))}catch(t){A.error(t)}this.Vi=[]}},Ka=class{constructor(e){this.ue=()=>{var t,i,n,r;this.he||(this.he={});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.he.lastScrollY=Math.ceil(a),this.he.maxScrollY=Math.max(a,(t=this.he.maxScrollY)!==null&&t!==void 0?t:0),this.he.maxScrollHeight=Math.max(l,(i=this.he.maxScrollHeight)!==null&&i!==void 0?i:0),this.he.lastContentY=c,this.he.maxContentY=Math.max(c,(n=this.he.maxContentY)!==null&&n!==void 0?n:0),this.he.maxContentHeight=Math.max(u,(r=this.he.maxContentHeight)!==null&&r!==void 0?r:0)},this._instance=e}getContext(){return this.he}resetContext(){var e=this.he;return setTimeout(this.ue,0),e}startMeasuringScrollPosition(){de(m,"scroll",this.ue,{capture:!0}),de(m,"scrollend",this.ue,{capture:!0}),de(m,"resize",this.ue)}scrollElement(){if(!this._instance.config.scroll_root_selector)return m?.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 i=m?.document.querySelector(t);if(i)return i}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return m&&(m.scrollY||m.pageYOffset||m.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return m&&(m.scrollX||m.pageXOffset||m.document.documentElement.scrollLeft)||0}},eE=s=>Fh(s?.config.mask_personal_data_properties,s?.config.custom_personal_data_properties),rr=class{constructor(e,t,i,n){this.de=r=>{var o=this.ve();if(!o||o.sessionId!==r){var a={sessionId:r,props:this.ce(this._instance)};this.fe.register({[ba]:a})}},this._instance=e,this.pe=t,this.fe=i,this.ce=n||eE,this.pe.onSessionId(this.de)}ve(){return this.fe.props[ba]}getSetOnceProps(){var e,t=(e=this.ve())==null?void 0:e.props;return t?"r"in t?Uh(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(rl(this.getSetOnceProps()),((t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+Qo(i)]=t})),e}},qo=le("[SessionId]"),or=class{on(e,t){return this._e.on(e,t)}constructor(e,t,i){var n;if(this.ge=[],this.me=void 0,this._e=new Di,this.be=(u,h)=>!(!Rs(u)||!Rs(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.fe=e.persistence,this.ye=void 0,this.we=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.xe=t||Lt,this.$e=i||Lt;var r=this.N.persistence_name||this.N.token,o=this.N.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*at(o,60,36e3,qo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Ee(),this.Se="ph_"+r+"_window_id",this.ke="ph_"+r+"_primary_window_exists",this.Pe()){var a=ye.D(this.Se),l=ye.D(this.ke);a&&!l?this.ye=a:ye.L(this.Se),ye.j(this.ke,!0)}if((n=this.N.bootstrap)!=null&&n.sessionID)try{var c=(u=>{var h=u.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})(this.N.bootstrap.sessionID);this.Te(this.N.bootstrap.sessionID,new Date().getTime(),c)}catch(u){qo.error("Invalid sessionID in bootstrap",u)}this.Ce()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return w(this.ge)&&(this.ge=[]),this.ge.push(e),this.we&&e(this.we,this.ye),()=>{this.ge=this.ge.filter((t=>t!==e))}}Pe(){return this.N.persistence!=="memory"&&!this.fe.zt&&ye.O()}Ie(e){e!==this.ye&&(this.ye=e,this.Pe()&&ye.j(this.Se,e))}Re(){return this.ye?this.ye:this.Pe()?ye.D(this.Se):null}Te(e,t,i){e===this.we&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.we=e,this.fe.register({[Hn]:[t,e,i]}))}Fe(){var e=this.fe.props[Hn];return q(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Te(null,null,null)}destroy(){clearTimeout(this.Oe),this.Oe=void 0,this.me&&m&&(m.removeEventListener("beforeunload",this.me,{capture:!1}),this.me=void 0),this.ge=[]}Ce(){this.me=()=>{this.Pe()&&ye.L(this.ke)},de(m,"beforeunload",this.me,{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 i=t||new Date().getTime(),[n,r,o]=this.Fe(),a=this.Re(),l=Rs(o)&&Math.abs(i-o)>864e5,c=!1,u=!r,h=!u&&!e&&this.be(i,n);u||h||l?(r=this.xe(),a=this.$e(),qo.info("new session ID generated",{sessionId:r,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}}),o=i,c=!0):a||(a=this.$e(),c=!0);var g=Rs(n)&&e&&!l?n:i,f=Rs(o)?o:new Date().getTime();return this.Ie(a),this.Te(r,g,f),e||this.Ee(),c&&this.ge.forEach((p=>p(r,a,c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:r,windowId:a,sessionStartTimestamp:f,changeReason:c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:n}}Ee(){clearTimeout(this.Oe),this.Oe=setTimeout((()=>{var[e]=this.Fe();if(this.be(new Date().getTime(),e)){var t=this.we;this.resetSessionId(),this._e.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},Gh=function(s,e){if(!s)return!1;var t=s.userAgent;if(t&&id(t,e))return!0;try{var i=s?.userAgentData;if(i!=null&&i.brands&&i.brands.some((n=>id(n?.brand,e))))return!0}catch{}return!!s.webdriver},Si=(function(s){return s.US="us",s.EU="eu",s.CUSTOM="custom",s})({}),xd="i.posthog.com",Wa=class{constructor(e){this.Me={},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("."+xd,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Me[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Me[this.apiHost]=Si.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Me[this.apiHost]=Si.EU:this.Me[this.apiHost]=Si.CUSTOM),this.Me[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===Si.CUSTOM)return this.apiHost+t;var i=xd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}},tE={icontains:(s,e)=>!!m&&e.href.toLowerCase().indexOf(s.toLowerCase())>-1,not_icontains:(s,e)=>!!m&&e.href.toLowerCase().indexOf(s.toLowerCase())===-1,regex:(s,e)=>!!m&&ir(e.href,s),not_regex:(s,e)=>!!m&&!ir(e.href,s),exact:(s,e)=>e.href===s,is_not:(s,e)=>e.href!==s},Xa=class s{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments((n=>{s.Ae("retrieved web experiments from the server"),t.De=new Map,n.forEach((r=>{if(r.feature_flag_key){var o;t.De&&(s.Ae("setting flag key ",r.feature_flag_key," to web experiment ",r),(o=t.De)==null||o.set(r.feature_flag_key,r));var a=t._instance.getFeatureFlag(r.feature_flag_key);he(a)&&r.variants[a]&&t.je(r.name,a,r.variants[a].transforms)}else if(r.variants)for(var l in r.variants){var c=r.variants[l];s.Le(c)&&t.je(r.name,l,c.transforms)}}))}),i)},this._instance=e,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}onFeatureFlags(e){if(this._is_bot())s.Ae("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(U(this.De))return this.De=new Map,this.loadIfEnabled(),void this.previewWebExperiment();s.Ae("applying feature flags",e),e.forEach((t=>{var i;if(this.De&&(i=this.De)!=null&&i.has(t)){var n,r=this._instance.getFeatureFlag(t),o=(n=this.De)==null?void 0:n.get(t);r&&o!=null&&o.variants[r]&&this.je(o.name,r,o.variants[r].transforms)}}))}}previewWebExperiment(){var e=s.getWindowLocation();if(e!=null&&e.search){var t=Jn(e?.search,"__experiment_id"),i=Jn(e?.search,"__experiment_variant");t&&i&&(s.Ae("previewing web experiments "+t+" && "+i),this.getWebExperiments((n=>{this.Ne(parseInt(t),i,n)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._instance.config.disable_web_experiments&&!i)return e([]);var n=this._instance.get_property("$web_experiments");if(n&&!t)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:r=>{if(r.statusCode!==200||!r.json)return e([]);var o=r.json.experiments||[];return e(o)}})}Ne(e,t,i){var n=i.filter((r=>r.id===e));n&&n.length>0&&(s.Ae("Previewing web experiment ["+n[0].name+"] with variant ["+t+"]"),this.je(n[0].name,t,n[0].variants[t].transforms))}static Le(e){return!U(e.conditions)&&s.Ue(e)&&s.ze(e)}static Ue(e){var t;if(U(e.conditions)||U((t=e.conditions)==null?void 0:t.url))return!0;var i,n,r,o=s.getWindowLocation();return!!o&&((i=e.conditions)==null||!i.url||tE[(n=(r=e.conditions)==null?void 0:r.urlMatchType)!==null&&n!==void 0?n:"icontains"](e.conditions.url,o))}static getWindowLocation(){return m?.location}static ze(e){var t;if(U(e.conditions)||U((t=e.conditions)==null?void 0:t.utm))return!0;var i=xh();if(i.utm_source){var n,r,o,a,l,c,u,h,g=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==i.utm_campaign,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==i.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==i.utm_medium,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return g&&p&&v&&f}return!1}static Ae(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];A.info("[WebExperiments] "+e,i)}je(e,t,i){this._is_bot()?s.Ae("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?i.forEach((n=>{if(n.selector){var r;s.Ae("applying transform of variant "+t+" for experiment "+e+" ",n);var o=(r=document)==null?void 0:r.querySelectorAll(n.selector);o?.forEach((a=>{var l=a;n.html&&(l.innerHTML=n.html),n.css&&l.setAttribute("style",n.css)}))}})):s.Ae("Control variants leave the page unmodified.")}_is_bot(){return Ve&&this._instance?Gh(Ve,this._instance.config.custom_blocked_useragents):void 0}},sE=le("[PostHog ExternalIntegrations]"),iE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ya=class{constructor(e){this._instance=e}V(e,t){var i;(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,(n=>{if(n)return sE.error("failed to load script",n);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!n||(a=O.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.V(iE[o],(()=>{var u;(u=O.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!n&&(l=O.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=O.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[i,n]of Object.entries((r=this._instance.config.integrations)!==null&&r!==void 0?r:{})){var r;t(i)}}},Ti={},zo=0,Ja=()=>{},Os="posthog",jh=!xb&&xe?.indexOf("MSIE")===-1&&xe?.indexOf("Mozilla")===-1,Ld=s=>{var e;return k({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:gb(S?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ja,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:s??"unset",__preview_deferred_init_extensions:!1,debug: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:(m==null||(e=m.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var i="Bad HTTP status: "+t.statusCode+" "+t.text;A.error(i)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Ha},error_tracking:{},_onCapture:Ja,__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}))(s))},$d=s=>{var e={};w(s.process_person)||(e.person_profiles=s.process_person),w(s.xhr_headers)||(e.request_headers=s.xhr_headers),w(s.cookie_name)||(e.persistence_name=s.cookie_name),w(s.disable_cookie)||(e.disable_persistence=s.disable_cookie),w(s.store_google)||(e.save_campaign_params=s.store_google),w(s.verbose)||(e.debug=s.verbose);var t=ue({},e,s);return q(s.property_blacklist)&&(w(s.property_denylist)?t.property_denylist=s.property_blacklist:q(s.property_denylist)?t.property_denylist=[...s.property_blacklist,...s.property_denylist]:A.error("Invalid value for property_denylist config: "+s.property_denylist)),t},Qa=class{constructor(){this.__forceAllowLocalhost=!1}get He(){return this.__forceAllowLocalhost}set He(e){A.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Us=class s{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new Qa,this.Be=!1,this.version=vt.LIB_VERSION,this.Ft=new Di,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ld(),this.SentryIntegration=Ra,this.sentryIntegration=e=>(function(t,i){var n=Ih(t,i);return{name:Th,processEvent:r=>n(r)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.qe=!1,this.We=null,this.Ge=null,this.Ve=null,this.featureFlags=new La(this),this.toolbar=new Oa(this),this.scrollManager=new Ka(this),this.pageViewManager=new Zn(this),this.surveys=new Ba(this),this.conversations=new Va(this),this.logs=new Ga(this),this.experiments=new Xa(this),this.exceptions=new xa(this),this.rateLimiter=new ja(this),this.requestRouter=new Wa(this),this.consent=new Ia(this),this.externalIntegrations=new Ya(this),this.people={set:(e,t,i)=>{var n=he(e)?{[e]:t}:e;this.setPersonProperties(n),i?.({})},set_once:(e,t,i)=>{var n=he(e)?{[e]:t}:e;this.setPersonProperties(void 0,n),i?.({})}},this.on("eventCaptured",(e=>A.info('send "'+e?.event+'"',e)))}init(e,t,i){if(i&&i!==Os){var n,r=(n=Ti[i])!==null&&n!==void 0?n:new s;return r._init(e,t,i),Ti[i]=r,Ti[Os][i]=r,r}return this._init(e,t,i)}_init(e,t,i){var n;if(t===void 0&&(t={}),w(e)||Zo(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.Je(t.debug),this.Ke=t,this.Ye=[],t.person_profiles?this.Ge=t.person_profiles:t.process_person&&(this.Ge=t.process_person),this.set_config(ue({},Ld(t.defaults),$d(t),{name:i,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 r=this.Xe();this.persistence=new Ai(this.config,r),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Ai(k({},this.config,{persistence:"sessionStorage"}),r);var o=k({},this.persistence.props),a=k({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Qe=new qa((E=>this.Ze(E)),this.config.request_queue_config),this.tr=new za(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 or(this),this.sessionPropsManager=new rr(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(A.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.ir(l)}),0)):(A.info("Initializing extensions synchronously"),this.ir(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}),((n=t.bootstrap)==null?void 0:n.distinctID)!==void 0){var c,u,h=this.config.get_device_id(Lt()),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.er()){var f,p,v=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlags)||{}).filter((E=>{var C;return!((C=t.bootstrap)==null||(C=C.featureFlags)==null||!C[E])})).reduce(((E,C)=>{var P;return E[C]=((P=t.bootstrap)==null||(P=P.featureFlags)==null?void 0:P[C])||!1,E}),{}),_=Object.keys(((p=t.bootstrap)==null?void 0:p.featureFlagPayloads)||{}).filter((E=>v[E])).reduce(((E,C)=>{var P,I;return(P=t.bootstrap)!=null&&(P=P.featureFlagPayloads)!=null&&P[C]&&(E[C]=(I=t.bootstrap)==null||(I=I.featureFlagPayloads)==null?void 0:I[C]),E}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:_})}if(l)this.register_once({distinct_id:ai,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(Lt());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(rt,"anonymous")}return de(m,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Sb(this,(()=>this.rr())):this.rr(),bt(this.config._onCapture)&&this.config._onCapture!==Ja&&(A.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(E=>this.config._onCapture(E.event,E)))),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}ir(e){var t=performance.now(),i=k({},s.__defaultExtensionClasses,this.config.__extensionClasses);i.historyAutocapture&&(this.historyAutocapture=new i.historyAutocapture(this),this.historyAutocapture.startIfEnabled());var n=[];i.tracingHeaders&&n.push((()=>{new i.tracingHeaders(this).startIfEnabledOrStop()})),i.siteApps&&n.push((()=>{var r;this.siteApps=new i.siteApps(this),(r=this.siteApps)==null||r.init()})),!e&&i.sessionRecording&&n.push((()=>{this.sessionRecording=new i.sessionRecording(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||n.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),i.autocapture&&n.push((()=>{this.autocapture=new i.autocapture(this),this.autocapture.startIfEnabled()})),n.push((()=>{this.surveys.loadIfEnabled()})),n.push((()=>{this.logs.loadIfEnabled()})),n.push((()=>{this.conversations.loadIfEnabled()})),i.productTours&&n.push((()=>{this.productTours=new i.productTours(this),this.productTours.loadIfEnabled()})),i.heatmaps&&n.push((()=>{this.heatmaps=new i.heatmaps(this),this.heatmaps.startIfEnabled()})),i.webVitalsAutocapture&&n.push((()=>{this.webVitalsAutocapture=new i.webVitalsAutocapture(this)})),i.exceptionObserver&&n.push((()=>{this.exceptionObserver=new i.exceptionObserver(this),this.exceptionObserver.startIfEnabledOrStop()})),i.deadClicksAutocapture&&n.push((()=>{this.deadClicksAutocapture=new i.deadClicksAutocapture(this,kb),this.deadClicksAutocapture.startIfEnabledOrStop()})),n.push((()=>{if(this.sr){var r=this.sr;this.sr=void 0,this.Bi(r)}})),this.nr(n,t)}nr(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.nr(e,t)}),0);var i=e.shift();if(i)try{i()}catch(r){A.error("Error initializing extension:",r)}}var n=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:n}),this.config.__preview_deferred_init_extensions&&A.info("PostHog extensions initialized ("+n+"ms)")}Bi(e){var t,i,n,r,o,a,l,c,u;if(!S||!S.body)return A.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Bi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.sr=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=F(e.supportedCompression,yt.GZipJS)?yt.GZipJS:F(e.supportedCompression,yt.Base64)?yt.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ge?this.Ge:"identified_only"}),(i=this.siteApps)==null||i.onRemoteConfig(e),(n=this.sessionRecording)==null||n.onRemoteConfig(e),(r=this.autocapture)==null||r.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}rr(){try{this.config.loaded(this)}catch(i){A.critical("`loaded` function failed",i)}if(this.ar(),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.lr()}),1),this.ur=new nr(this),this.ur.load()}ar(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Qe)==null||e.enable())}_dom_loaded(){this.is_capturing()&&$t(this.__request_queue,(e=>this.Ze(e))),this.__request_queue=[],this.ar()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.hr()&&this.capture("$pageleave"),(e=this.Qe)==null||e.unload(),(t=this.tr)==null||t.unload()):this.hr()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(jh?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=sr(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 i,n,r,o=k({},t);o.timeout=o.timeout||6e4,o.url=sr(o.url,{_:new Date().getTime().toString(),ver:vt.LIB_VERSION,compression:o.compression});var a=(i=o.transport)!==null&&i!==void 0?i:"fetch",l=Bn.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(n=(r=yh(l,(u=>u.transport===a)))==null?void 0:r.method)!==null&&n!==void 0?n:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(k({},e,{callback:t=>{var i,n;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((i=(n=this.config).on_request_error)==null||i.call(n,t)),e.callback==null||e.callback(t)}}))))}Ze(e){this.tr?this.tr.retriableRequest(e):this._send_request(e)}_execute_array(e){zo++;try{var t,i=[],n=[],r=[];$t(e,(a=>{a&&(t=a[0],q(t)?r.push(a):bt(a)?a.call(this):q(a)&&t==="alias"?i.push(a):q(a)&&t.indexOf("capture")!==-1&&bt(this[t])?r.push(a):n.push(a))}));var o=function(a,l){$t(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(i,this),o(n,this),o(r,this)}finally{zo--}}er(){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(zo>0&&q(e)&&he(e[0])){var t=s.prototype[e[0]];bt(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,i){var n;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Qe){if(this.is_capturing())if(!w(e)&&he(e)){var r=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(r&&!this.config.__preview_capture_bot_pageviews)){var o=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!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"||i!=null&&i.ft||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=i?.timestamp||a,c=Lt(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&r&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),i?.$set&&(u.$set=i?.$set);var h,g=e!=="$groupidentify",f=this.dr(i?.$set_once,g);if(f&&(u.$set_once=f),(u=hb(u,i!=null&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,w(i?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===ki.DISMISSED||e===ki.SENT){var p=t?.[Ho.SURVEY_ID],v=t?.[Ho.SURVEY_ITERATION];h={id:p,current_iteration:v},localStorage.getItem(Pd(h))||localStorage.setItem(Pd(h),"true"),u.$set=k({},u.$set,{[Xb({id:p,current_iteration:v},e===ki.SENT?"responded":"dismissed")]:!0})}else e===ki.SHOWN&&(u.$set=k({},u.$set,{[Ho.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Qb.SHOWN){var _=t?.[Nd.TOUR_TYPE];_&&(u.$set=k({},u.$set,{[Nd.TOUR_LAST_SEEN_DATE+"/"+_]:new Date().toISOString()}))}var b=k({},u.properties.$set,u.$set);if(Cs(b)||this.setPersonPropertiesForFlags(b),!U(this.config.before_send)){var E=this.vr(u);if(!E)return;u=E}this.Ft.emit("eventCaptured",u);var C={method:"POST",url:(n=i?._url)!==null&&n!==void 0?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:i?._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.Ze(C):this.Qe.enqueue(C),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,i,n,r){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var o=r?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)&&!St(a.distinct_id)||Zo(a.distinct_id))&&A.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=Fb(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(r,i.getTime());a.$session_id=h,a.$window_id=g}this.sessionPropsManager&&ue(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&ue(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this.tr)==null?void 0:f.length}catch(b){a.$sdk_debug_error_capturing_properties=String(b)}if(this.requestRouter.region===Si.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||r?e!=="$pageleave"||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,n),a=ue(a,c),e==="$pageview"&&S&&(a.title=S.title),!w(o)){var p=i.getTime()-o;a.$duration=parseFloat((p/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(b){delete a[b]})):A.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(A.error("sanitize_properties is deprecated. Use before_send instead"),a=v(a,e));var _=this.cr();return a.$process_person_profile=_,_&&!r&&this.pr("_calculate_event_properties"),a}dr(e,t){var i;if(t===void 0&&(t=!0),!this.persistence||!this.cr()||this.Be)return e;var n=this.persistence.get_initial_props(),r=(i=this.sessionPropsManager)==null?void 0:i.getSetOnceProps(),o=ue({},n,r||{},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.Be=!0),Cs(o)?void 0:o}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var n;(n=this.persistence)==null||n.register_once(e,t,i)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}_r(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,i){var n=i!=null&&i.merge?this.featureFlags.getFlagVariants():{},r=i!=null&&i.merge?this.featureFlags.getFlagPayloads():{},o=k({},n,e),a=k({},r,t),l={};for(var[c,u]of Object.entries(o)){var h=typeof u=="string";l[c]={key:c,enabled:!!h||!!u,variant:h?u:void 0,reason:void 0,metadata:w(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.Ft.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=Jb),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,i){if(!this.__loaded||!this.persistence)return A.uninitializedWarning("posthog.identify");if(St(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!==ai){if(this.pr("posthog.identify")){var n=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var r=n;this.register_once({$had_persisted_distinct_id:!0,$device_id:r},"")}e!==n&&e!==this.get_property(_i)&&(this.unregister(_i),this.register({distinct_id:e}));var o=(this.persistence.get_property(rt)||"anonymous")==="anonymous";e!==n&&o?(this.persistence.set_property(rt,"identified"),this.setPersonPropertiesForFlags(k({},i||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n},{$set:t||{},$set_once:i||{}}),this.Ve=Td(e,t,i),this.featureFlags.setAnonymousDistinctId(n)):(t||i)&&this.setPersonProperties(t,i),e!==n&&(this.reloadFeatureFlags(),this.unregister(qn))}}else A.critical('The string "'+ai+'" 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.pr("posthog.setPersonProperties")){var i=Td(this.get_distinct_id(),e,t);this.Ve!==i?(this.setPersonPropertiesForFlags(k({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Ve=i):A.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var n=this.getGroups();n[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:k({},n,{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),n[e]===t||i||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.pr("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,n,r,o;if(A.info("reset"),!this.__loaded)return A.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(i=this.sessionPersistence)==null||i.clear(),this.surveys.reset(),(n=this.ur)==null||n.stop(),this.featureFlags.reset(),(r=this.persistence)==null||r.set_property(rt,"anonymous"),(o=this.sessionManager)==null||o.resetSessionId(),this.Ve=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:ai,$device_id:null},"");else{var l=this.config.get_device_id(Lt());this.register_once({distinct_id:l,$device_id:e?l:a},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&i){var r,o=(r=e.timestampLookBack)!==null&&r!==void 0?r:10;if(!i)return n;n+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}return n}alias(e,t){return e===this.get_property(Eh)?(A.critical("Attempting to create alias for existing People user - aborting."),-2):this.pr("posthog.alias")?(w(t)&&(t=this.get_distinct_id()),e!==t?(this._r(_i,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 i,n,r,o,a,l,c,u;ue(this.config,$d(e));var h=this.Xe();(i=this.persistence)==null||i.update_config(this.config,t,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Ai(k({},this.config,{persistence:"sessionStorage"}),h);var g=this.Je(this.config.debug);kt(g)&&(this.config.debug=g),kt(this.config.debug)&&(this.config.debug?(vt.DEBUG=!0,ae.O()&&ae.j("ph_debug","true"),A.info("set_config",{config:e,oldConfig:t,newConfig:k({},this.config)})):(vt.DEBUG=!1,ae.O()&&ae.L("ph_debug"))),(n=this.exceptionObserver)==null||n.onConfigChange(),(r=this.sessionRecording)==null||r.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this.gr(),(u=this.externalIntegrations)==null||u.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,i={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(i).some(Boolean)){var n,r,o,a,l;(n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),i.sampling&&((r=this.sessionRecording)==null||r.overrideSampling()),i.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),i.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var i=new Error("PostHog syntheticException"),n=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(k({},n,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Os;return t!==Os&&(t=Os+"."+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"}cr(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Cs(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[_i])&&((t=this.persistence)==null||(t=t.props)==null||!t[Wn]))}hr(){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.cr()||this.pr("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.pr("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}pr(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._r(Wn,!0),!0)}Xe(){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}gr(){var e,t,i,n,r=this.Xe();return((e=this.persistence)==null?void 0:e.zt)!==r&&((i=this.persistence)==null||i.set_disabled(r)),((t=this.sessionPersistence)==null?void 0:t.zt)!==r&&((n=this.sessionPersistence)==null||n.set_disabled(r)),r}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){if(this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()){var i,n,r,o,a;this.reset(!0),(i=this.sessionManager)==null||i.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=new or(this),this.pageViewManager=new Zn(this),this.persistence&&(this.sessionPropsManager=new rr(this,this.sessionManager,this.persistence));var l=(r=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&r!==void 0?r:(a=s.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=new l(this),this.sessionRecording.startIfEnabledOrStop())}var c;this.consent.optInOut(!0),this.gr(),this.ar(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(w(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.lr()}else A.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.gr(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:ai,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(i=this.sessionRecording)==null||i.stopRecording(),this.sessionRecording=void 0,this.lr())):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.gr()}_is_bot(){return Ve?Gh(Ve,this.config.custom_blocked_useragents):void 0}lr(){S&&(S.visibilityState==="visible"?this.qe||(this.qe=!0,this.capture("$pageview",{title:S.title},{send_instantly:!0}),this.We&&(S.removeEventListener("visibilitychange",this.We),this.We=null)):this.We||(this.We=this.lr.bind(this),de(S,"visibilitychange",this.We)))}debug(e){e===!1?(m?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(m?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}At(){var e,t,i,n,r,o,a,l=this.Ke||{};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):(i="advanced_disable_decide",n=!1,r=A,o=(t="advanced_disable_flags")in(e=l)&&!U(e[t]),a=i in e&&!U(e[i]),o?e[t]:a?(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):n)}vr(e){if(U(this.config.before_send))return e;var t=q(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var n of t){if(i=n(i),U(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return Uy(e.event)?A.warn(r+". This can cause unexpected behavior."):A.info(r),null}i.properties&&!Cs(i.properties)||A.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return(e=this.pageViewManager.it)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Je(e){var t=kt(e)&&!e,i=ae.O()&&ae.A("ph_debug")==="true";return!t&&(!!i||e)}};Us.__defaultExtensionClasses={},(function(s,e){for(var t=0;t<e.length;t++)s.prototype[e[t]]=db(s.prototype[e[t]])})(Us,["identify"]);cl=["a","button","form","input","select","textarea","label"];nE=["next","previous","prev",">","<"],Bd=10,Vd=[".ph-no-rageclick",".ph-no-capture"];ul=s=>!s||Mt(s,"html")||!dr(s),Xh=(s,e)=>{if(!m||ul(s))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[s],n=s;n.parentNode&&!Mt(n,"body");)if(qh(n.parentNode))i.push(n.parentNode.host),n=n.parentNode.host;else{var r=Wh(n);if(!r)break;if(e||cl.indexOf(r.tagName.toLowerCase())>-1)t=!0;else{var o=m.getComputedStyle(r);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}i.push(r),n=r}return{parentIsUsefulElement:t,targetElementList:i}};Jh="(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})",aE=new RegExp("^(?:"+Jh+")$"),lE=new RegExp(Jh),Qh="\\d{3}-?\\d{2}-?\\d{4}",cE=new RegExp("^("+Qh+")$"),uE=new RegExp("("+Qh+")");lr=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,i){if(this.disabled)return!1;var n=this.clicks[this.clicks.length-1];if(n&&Math.abs(e-n.x)+Math.abs(t-n.y)<this.thresholdPx&&i-n.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},Ko="$copy_autocapture",jd=le("[AutoCapture]");pi=le("[ExceptionAutocapture]");vE=le("[TracingHeaders]"),Nt=le("[Web Vitals]"),qd=9e5;le("[SessionRecording]");el="[SessionRecording]",Is=le(el),_E=le("[Heatmaps]");Kd=le("[Product Tours]"),Xo="ph_product_tours",mE=["$set_once","$set"],Dt=le("[SiteApps]"),yE={sessionRecording:class{get started(){var s;return!((s=this.mr)==null||!s.isStarted)}get status(){return this.mr?this.mr.status:this.br?this.yr?"lazy_loading":"disabled":"pending_config"}constructor(s){if(this._forceAllowLocalhostNetworkCapture=!1,this.br=!1,this.wr=!1,this.$r=void 0,this._instance=s,!this._instance.sessionManager)throw Is.error("started without valid sessionManager"),new Error(el+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(el+' cannot be used with cookieless_mode="always"')}get yr(){var s,e=!((s=this._instance.get_property(xn))==null||!s.enabled),t=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return m&&e&&t&&!i}startIfEnabledOrStop(s){var e;if(this.br&&(!this.yr||(e=this.mr)==null||!e.isStarted)){var t=!w(Object.assign)&&!w(Array.from);this.yr&&t?(this.Er(s),Is.info("starting")):this.stopRecording()}}Er(s){var e,t,i;this.yr&&(O!=null&&(e=O.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=O.__PosthogExtensions__)!=null&&t.initSessionRecording?this.Sr(s):(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.kr,(n=>{if(n)return Is.error("could not load recorder",n);this.Sr(s)})))}stopRecording(){var s,e;(s=this.$r)==null||s.call(this),this.$r=void 0,(e=this.mr)==null||e.stop()}Pr(){var s;(s=this._instance.persistence)==null||s.unregister(Sh)}Tr(s){if(this._instance.persistence){var e,t,i=this._instance.persistence,n=()=>{var r=s.sessionRecording===!1?void 0:s.sessionRecording,o=r?.sampleRate,a=U(o)?null:parseFloat(o);U(a)&&this.Pr();var l=r?.minimumDurationMilliseconds;i.register({[xn]:k({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:k({capturePerformance:s.capturePerformance},r?.networkPayloadCapture),canvasRecording:{enabled:r?.recordCanvas,fps:r?.canvasFps,quality:r?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:w(l)?null:l,endpoint:r?.endpoint,triggerMatchType:r?.triggerMatchType,masking:r?.masking,urlTriggers:r?.urlTriggers})})};n(),(e=this.$r)==null||e.call(this),this.$r=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(n)}}onRemoteConfig(s){"sessionRecording"in s?s.sessionRecording!==!1?(this.wr=!1,this.Tr(s),this.br=!0,this.startIfEnabledOrStop()):this.br=!0:Is.info("skipping remote config with no sessionRecording",s)}log(s,e){var t;e===void 0&&(e="log"),(t=this.mr)!=null&&t.log?this.mr.log(s,e):Is.warn("log called before recorder was ready")}get kr(){var s,e,t=(s=this._instance)==null||(s=s.persistence)==null?void 0:s.get_property(xn);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}Cr(){var s,e=this._instance.get_property(xn);if(!e)return!1;var t=(s=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&s!==void 0?s:Date.now();return Date.now()-t<=3e5}Sr(s){var e,t;if((e=O.__PosthogExtensions__)==null||!e.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.mr||(this.mr=(t=O.__PosthogExtensions__)==null?void 0:t.initSessionRecording(this._instance),this.mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Cr()?this.mr.start(s):this.wr||(this.wr=!0,Is.info("persisted remote config is stale, requesting fresh config before starting"),new nr(this._instance).load())}onRRwebEmit(s){var e;(e=this.mr)==null||e.onRRwebEmit==null||e.onRRwebEmit(s)}overrideLinkedFlag(){var s,e;this.mr||(e=this._instance.persistence)==null||e.register({$replay_override_linked_flag:!0}),(s=this.mr)==null||s.overrideLinkedFlag()}overrideSampling(){var s,e;this.mr||(e=this._instance.persistence)==null||e.register({$replay_override_sampling:!0}),(s=this.mr)==null||s.overrideSampling()}overrideTrigger(s){var e,t;this.mr||(t=this._instance.persistence)==null||t.register({[s==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.mr)==null||e.overrideTrigger(s)}get sdkDebugProperties(){var s;return((s=this.mr)==null?void 0:s.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(s,e){var t;return!((t=this.mr)==null||!t.tryAddCustomEvent(s,e))}}},bE={autocapture:class{constructor(s){this.Ir=!1,this.Rr=null,this.Fr=!1,this.instance=s,this.rageclicks=new lr(s.config.rageclick),this.Or=null}get N(){var s,e,t=fe(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(s=t.url_allowlist)==null?void 0:s.map((i=>new RegExp(i))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((i=>new RegExp(i))),t}Mr(){if(this.isBrowserSupported()){if(m&&S){var s=t=>{t=t||m?.event;try{this.Ar(t)}catch(i){jd.error("Failed to capture event",i)}};if(de(S,"submit",s,{capture:!0}),de(S,"change",s,{capture:!0}),de(S,"click",s,{capture:!0}),this.N.capture_copied_text){var e=t=>{t=t||m?.event,this.Ar(t,Ko)};de(S,"copy",e,{capture:!0}),de(S,"cut",e,{capture:!0})}}}else jd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ir&&(this.Mr(),this.Ir=!0)}onRemoteConfig(s){s.elementsChainAsString&&(this.Fr=s.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[hd]:!!s.autocapture_opt_out}),this.Rr=!!s.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(s){this.Or=s}getElementSelectors(s){var e,t=[];return(e=this.Or)==null||e.forEach((i=>{var n=S?.querySelectorAll(i);n?.forEach((r=>{s===r&&t.push(i)}))})),t}get isEnabled(){var s,e,t=(s=this.instance.persistence)==null?void 0:s.props[hd],i=this.Rr;if(Ze(i)&&!kt(t)&&!this.instance.At())return!1;var n=(e=this.Rr)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!n}Ar(s,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,i=Ud(s);Hh(i)&&(i=i.parentNode||null),e==="$autocapture"&&s.type==="click"&&s instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,s.timeStamp||new Date().getTime())&&rE(i,this.instance.config.rageclick)&&this.Ar(s,"$rageclick");var n=e===Ko;if(i&&oE(i,s,this.N,n,n?["copy","cut"]:void 0)){var{props:r,explicitNoCapture:o}=pE(i,{e:s,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.N.element_attribute_ignorelist,elementsChainAsString:this.Fr});if(o)return!1;var a=this.getElementSelectors(i);if(a&&a.length>0&&(r.$element_selectors=a),e===Ko){var l,c=zh(m==null||(l=m.getSelection())==null?void 0:l.toString()),u=s.type||"clipboard";if(!c)return!1;r.$selected_content=c,r.$copy_type=u}return this.instance.capture(e,r),!0}}}isBrowserSupported(){return bt(S?.querySelectorAll)}},historyAutocapture:class{constructor(s){var e;this._instance=s,this.Dr=(m==null||(e=m.location)==null?void 0:e.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(A.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.jr&&this.jr(),this.jr=void 0,A.info("History API monitoring stopped")}monitorHistoryChanges(){var s,e;if(m&&m.history){var t=this;(s=m.history.pushState)!=null&&s.__posthog_wrapped__||Hd(m.history,"pushState",(i=>function(n,r,o){i.call(this,n,r,o),t.Lr("pushState")})),(e=m.history.replaceState)!=null&&e.__posthog_wrapped__||Hd(m.history,"replaceState",(i=>function(n,r,o){i.call(this,n,r,o),t.Lr("replaceState")})),this.Nr()}}Lr(s){try{var e,t=m==null||(e=m.location)==null?void 0:e.pathname;if(!t)return;t!==this.Dr&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:s}),this.Dr=t}catch(i){A.error("Error capturing "+s+" pageview",i)}}Nr(){if(!this.jr){var s=()=>{this.Lr("popstate")};de(m,"popstate",s),this.jr=()=>{m&&m.removeEventListener("popstate",s)}}}},heatmaps:class{constructor(s){var e;this.Ur=!1,this.Ir=!1,this.zr=null,this.instance=s,this.Ur=!((e=this.instance.persistence)==null||!e.props[pa]),this.rageclicks=new lr(s.config.rageclick)}get flushIntervalMilliseconds(){var s=5e3;return fe(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(s=this.instance.config.capture_heatmaps.flush_interval_milliseconds),s}get isEnabled(){return U(this.instance.config.capture_heatmaps)?U(this.instance.config.enable_heatmaps)?this.Ur:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Ir)return;_E.info("starting..."),this.Hr(),this.Br()}else{var s;clearInterval((s=this.zr)!==null&&s!==void 0?s:void 0),this.qr(),this.getAndClearBuffer()}}onRemoteConfig(s){if("heatmaps"in s){var e=!!s.heatmaps;this.instance.persistence&&this.instance.persistence.register({[pa]:e}),this.Ur=e,this.startIfEnabled()}}getAndClearBuffer(){var s=this.R;return this.R=void 0,s}Wr(s){this.Gr(s.originalEvent,"deadclick")}Br(){this.zr&&clearInterval(this.zr),this.zr=(function(s){return s?.visibilityState==="visible"})(S)?setInterval(this.se.bind(this),this.flushIntervalMilliseconds):null}Hr(){m&&S&&(this.Vr=this.se.bind(this),de(m,"beforeunload",this.Vr),this.Jr=s=>this.Gr(s||m?.event),de(S,"click",this.Jr,{capture:!0}),this.Kr=s=>this.Yr(s||m?.event),de(S,"mousemove",this.Kr,{capture:!0}),this.Xr=new Xn(this.instance,Eb,this.Wr.bind(this)),this.Xr.startIfEnabledOrStop(),this.Qr=this.Br.bind(this),de(S,"visibilitychange",this.Qr),this.Ir=!0)}qr(){var s;m&&S&&(this.Vr&&m.removeEventListener("beforeunload",this.Vr),this.Jr&&S.removeEventListener("click",this.Jr,{capture:!0}),this.Kr&&S.removeEventListener("mousemove",this.Kr,{capture:!0}),this.Qr&&S.removeEventListener("visibilitychange",this.Qr),clearTimeout(this.Zr),(s=this.Xr)==null||s.stop(),this.Ir=!1)}ts(s,e){var t=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=(function(o,a,l){for(var c=o;c&&dr(c)&&!Mt(c,"body");){if(c===l)return!1;if(F(a,m?.getComputedStyle(c).position))return!0;c=Wh(c)}return!1})(Ud(s),["fixed","sticky"],n);return{x:s.clientX+(r?0:i),y:s.clientY+(r?0:t),target_fixed:r,type:e}}Gr(s,e){var t;if(e===void 0&&(e="click"),!Md(s.target)&&zd(s)){var i=this.ts(s,e);(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,new Date().getTime())&&this.es(k({},i,{type:"rageclick"})),this.es(i)}}Yr(s){!Md(s.target)&&zd(s)&&(clearTimeout(this.Zr),this.Zr=setTimeout((()=>{this.es(this.ts(s,"mousemove"))}),500))}es(s){if(m){var e=m.location.href,t=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,n=t?$s([],Fs,i||[]):[],r=Pi(e,n,Ni);this.R=this.R||{},this.R[r]||(this.R[r]=[]),this.R[r].push(s)}}se(){this.R&&!Cs(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Xn,webVitalsAutocapture:class{constructor(s){var e;this.Ur=!1,this.Ir=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.rs=()=>{clearTimeout(this.ss),this.R.metrics.length!==0&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((t,i)=>k({},t,{["$web_vitals_"+i.name+"_event"]:k({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ns=t=>{var i,n=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(w(n))Nt.error("Could not read session ID. Dropping metrics!");else{this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.os();w(r)||(U(t?.name)||U(t?.value)?Nt.error("Invalid metric received",t):this.ls&&t.value>=this.ls?Nt.error("Ignoring metric with value >= "+this.ls,t):(this.R.url!==r&&(this.rs(),this.ss=setTimeout(this.rs,this.flushToCaptureTimeoutMs)),w(this.R.url)&&(this.R.url=r),this.R.firstMetricTimestamp=w(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0),this.R.metrics.push(k({},t,{$current_url:r,$session_id:n.sessionId,$window_id:n.windowId,timestamp:Date.now()})),this.R.metrics.length===this.allowedMetrics.length&&this.rs()))}},this.us=()=>{if(!this.Ir){var t,i,n,r,o=O.__PosthogExtensions__;w(o)||w(o.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:i,onFCP:n,onINP:r}=o.postHogWebVitalsCallbacks),t&&i&&n&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.ns.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.ns.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&n(this.ns.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.ns.bind(this)),this.Ir=!0):Nt.error("web vitals callbacks not loaded - not starting")}},this._instance=s,this.Ur=!((e=this._instance.persistence)==null||!e.props[pd]),this.startIfEnabled()}get allowedMetrics(){var s,e,t=fe(this._instance.config.capture_performance)?(s=this._instance.config.capture_performance)==null?void 0:s.web_vitals_allowed_metrics:void 0;return U(t)?((e=this._instance.persistence)==null?void 0:e.props[_d])||["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 s=fe(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return s!=null&&s}get ls(){var s=fe(this._instance.config.capture_performance)&&St(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:qd;return 0<s&&s<=6e4?qd:s}get isEnabled(){var s=be?.protocol;if(s!=="http:"&&s!=="https:")return Nt.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.Ur}startIfEnabled(){this.isEnabled&&!this.Ir&&(Nt.info("enabled, starting..."),this.V(this.us))}onRemoteConfig(s){if("capturePerformance"in s){var e=fe(s.capturePerformance)&&!!s.capturePerformance.web_vitals,t=fe(s.capturePerformance)?s.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[pd]:e}),this._instance.persistence.register({[_d]:t})),this.Ur=e,this.startIfEnabled()}}V(s){var e,t;if((e=O.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks)s();else{var i=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,i,(n=>{n?Nt.error("failed to load script",n):s()}))}}os(){var s=m?m.location.href:void 0;if(s){var e=this._instance.config.mask_personal_data_properties,t=this._instance.config.custom_personal_data_properties,i=e?$s([],Fs,t||[]):[];return Pi(s,i,Ni)}Nt.error("Could not determine current URL")}}},EE={exceptionObserver:class{constructor(s){var e,t,i;this.us=()=>{var n;if(m&&this.isEnabled&&(n=O.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var r=O.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=O.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=O.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.hs&&this.N.capture_unhandled_errors&&(this.hs=r(this.captureException.bind(this))),!this.ds&&this.N.capture_unhandled_rejections&&(this.ds=o(this.captureException.bind(this))),!this.vs&&this.N.capture_console_errors&&(this.vs=a(this.captureException.bind(this)))}catch(l){pi.error("failed to start",l),this.cs()}}},this._instance=s,this.fs=!((e=this._instance.persistence)==null||!e.props[fd]),this.ps=new ta({refillRate:(t=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&t!==void 0?t:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,h:pi}),this.N=this._s(),this.startIfEnabledOrStop()}_s(){var s=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return fe(s)?e=k({},e,s):(w(s)?this.fs:s)&&(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?(pi.info("enabled"),this.cs(),this.V(this.us)):this.cs()}V(s){var e,t;(e=O.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&s(),(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return pi.error("failed to load script",i);s()}))}cs(){var s,e,t;(s=this.hs)==null||s.call(this),this.hs=void 0,(e=this.ds)==null||e.call(this),this.ds=void 0,(t=this.vs)==null||t.call(this),this.vs=void 0}onRemoteConfig(s){if("autocaptureExceptions"in s){var e=s.autocaptureExceptions;this.fs=!!e||!1,this._instance.persistence&&this._instance.persistence.register({[fd]:this.fs}),this.N=this._s(),this.startIfEnabledOrStop()}}onConfigChange(){this.N=this._s()}captureException(s){var e,t,i=(e=s==null||(t=s.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.ps.consumeRateLimit(i)?pi.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(s)}}},kE={productTours:class{constructor(s){this.gs=null,this.bs=null,this._instance=s}onRemoteConfig(s){"productTours"in s&&(this._instance.persistence&&this._instance.persistence.register({[vd]:!!s.productTours}),this.loadIfEnabled())}loadIfEnabled(){var s,e;this.gs||(s=this._instance).config.disable_product_tours||(e=s.persistence)==null||!e.get_property(vd)||this.V((()=>this.ys()))}V(s){var e,t;(e=O.__PosthogExtensions__)!=null&&e.generateProductTours?s():(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(i=>{i?Kd.error("Could not load product tours script",i):s()}))}ys(){var s;!this.gs&&(s=O.__PosthogExtensions__)!=null&&s.generateProductTours&&(this.gs=O.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(s,e){if(e===void 0&&(e=!1),!q(this.bs)||e){var t=this._instance.persistence;if(t){var i=t.props[Xo];if(q(i)&&!e)return this.bs=i,void s(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:n=>{var r=n.statusCode;if(r!==200||!n.json){var o="Product Tours API could not be loaded, status: "+r;return Kd.error(o),void s([],{isLoaded:!1,error:o})}var a=q(n.json.product_tours)?n.json.product_tours:[];this.bs=a,t&&t.register({[Xo]:a}),s(a,{isLoaded:!0})}})}else s(this.bs,{isLoaded:!0})}getActiveProductTours(s){U(this.gs)?s([],{isLoaded:!1,error:"Product tours not loaded"}):this.gs.getActiveProductTours(s)}showProductTour(s){var e;(e=this.gs)==null||e.showTourById(s)}previewTour(s){this.gs?this.gs.previewTour(s):this.V((()=>{var e;this.ys(),(e=this.gs)==null||e.previewTour(s)}))}dismissProductTour(){var s;(s=this.gs)==null||s.dismissTour("user_clicked_skip")}nextStep(){var s;(s=this.gs)==null||s.nextStep()}previousStep(){var s;(s=this.gs)==null||s.previousStep()}clearCache(){var s;this.bs=null,(s=this._instance.persistence)==null||s.unregister(Xo)}resetTour(s){var e;(e=this.gs)==null||e.resetTour(s)}resetAllTours(){var s;(s=this.gs)==null||s.resetAllTours()}cancelPendingTour(s){var e;(e=this.gs)==null||e.cancelPendingTour(s)}}},SE={siteApps:class{constructor(s){this._instance=s,this.ws=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}xs(s,e){if(e){var t=this.globalsForEvent(e);this.ws.push(t),this.ws.length>1e3&&(this.ws=this.ws.slice(10))}}get siteAppLoaders(){var s;return(s=O._POSTHOG_REMOTE_CONFIG)==null||(s=s[this._instance.config.token])==null?void 0:s.siteApps}init(){if(this.isEnabled){var s=this._instance._addCaptureHook(this.xs.bind(this));this.$s=()=>{s(),this.ws=[],this.$s=void 0}}}globalsForEvent(s){var e,t,i,n,r,o,a;if(!s)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:p}=s;return{event:k({},Yd(s,mE),{properties:k({},s.properties,p?{$set:k({},(e=(t=s.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},p)}:{},f?{$set_once:k({},(i=(n=s.properties)==null?void 0:n.$set_once)!==null&&i!==void 0?i:{},f)}:{}),elements_chain:(r=(o=s.properties)==null?void 0:o.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(a=s.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(s){var e=this.apps[s.id],t=()=>{var o;!e.errored&&this.ws.length&&(Dt.info("Processing "+this.ws.length+" events for site app with id "+s.id),this.ws.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.$s)==null||o.call(this))},i=!1,n=o=>{e.errored=!o,e.loaded=!0,Dt.info("Site app with id "+s.id+" "+(o?"loaded":"errored")),i&&t()};try{var{processEvent:r}=s.init({posthog:this._instance,callback:o=>{n(o)}});r&&(e.processEvent=r),i=!0}catch(o){Dt.error("Error while initializing PostHog app with config id "+s.id,o),n(!1)}if(i&&e.loaded)try{t()}catch(o){Dt.error("Error while processing buffered events PostHog app with config id "+s.id,o),e.errored=!0}}Es(){var s=this.siteAppLoaders||[];for(var e of s)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of s)this.setupSiteApp(t)}Ss(s){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(s);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(i){Dt.error("Error while processing event "+s.event+" for site app "+t.id,i)}}}onRemoteConfig(s){var e,t,i,n=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.Es(),void this._instance.on("eventCaptured",(l=>this.Ss(l)))):void Dt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.$s)==null||t.call(this),(i=s.siteApps)!=null&&i.length)if(this.isEnabled){var r=function(l){var c;O["__$$ph_site_app_"+l]=n._instance,(c=O.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(n._instance,a,(u=>{if(u)return Dt.error("Error while initializing PostHog app with config id "+l,u)}))};for(var{id:o,url:a}of s.siteApps)r(o)}else Dt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},wE=k({},yE,bE,EE,kE,SE,{tracingHeaders:class{constructor(s){this.ks=void 0,this.Ps=void 0,this.us=()=>{var e,t;w(this.ks)&&((e=O.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),w(this.Ps)&&((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=s}V(s){var e,t;(e=O.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&s(),(t=O.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return vE.error("failed to load script",i);s()}))}startIfEnabledOrStop(){var s,e;this._instance.config.__add_tracing_headers?this.V(this.us):((s=this.ks)==null||s.call(this),(e=this.Ps)==null||e.call(this),this.ks=void 0,this.Ps=void 0)}}});Us.__defaultExtensionClasses=k({},wE);wt=(Wd=Ti[Os]=new Us,(function(){function s(){s.done||(s.done=!0,jh=!1,Z(Ti,(function(e){e._dom_loaded()})))}S!=null&&S.addEventListener?S.readyState==="complete"?s():de(S,"DOMContentLoaded",s,{capture:!1}):m&&A.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),Wd)});var sf={};hr(sf,{Posthog:()=>dl});var Zt,dl,nf=Re(()=>{"use strict";tf();ps();vs();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:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}let n=t||Yc();this.log("init | loading PostHog SDK",{api_host:n});let r={api_host:n,ui_host:Xc,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...i.session_recording},before_send:o=>{if(typeof window>"u")return null;let a=window.location.hostname;if(a==="localhost"||a==="127.0.0.1")return o;let l=uo.some(c=>a.endsWith(`.${c}`)||a===c);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...i};wt.init(e,r),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let i=typeof wt._isIdentified=="function"?wt._isIdentified():this.has_identified;e&&!i?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),wt.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),wt.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,country_of_residence:i})=>{if(!(!this.has_initialized||!e))try{let n=wt.get_property("$stored_person_properties")??{},r={};n.client_id||(r.client_id=e),t&&n.is_internal===void 0&&(r.is_internal=hn(t)),i&&!n.country_of_residence&&(r.country_of_residence=i),Object.keys(r).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:r}),wt.setPersonProperties(r)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e,country_of_residence:i})}catch(n){console.error("Posthog: Failed to backfill person properties",n)}};this.capture=(e,t)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:t}),wt.capture(e,t)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.options=e,this.debug=t,this.init()}};Zt.getPosthogInstance=(e,t=!1)=>(Zt._instance||(Zt._instance=new Zt(e,t)),Zt._instance);dl=Zt});var TE={};hr(TE,{Analytics:()=>rf,cacheTrackEvents:()=>_s});lo();ps();vs();var xm=2*365*24*60*60,zt=class zt{constructor(e,t,i=!1){this.analytics=new hs;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,r=["webflow.io"].some(c=>t.endsWith(c))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let c=new Uint8Array(16);crypto.getRandomValues(c),c[6]=c[6]&15|64,c[8]=c[8]&63|128;let u=Array.from(c,h=>h.toString(16).padStart(2,"0")).join("");o=`${u.slice(0,8)}-${u.slice(8,12)}-${u.slice(12,16)}-${u.slice(16,20)}-${u.slice(20)}`}else throw new Error("Crypto API not available for secure random UUID generation");let l=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${this.rudderstack_anonymous_cookie_key}=${o}; path=/; Domain=${r}; max-age=${xm}; 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:co});try{this.setCookieIfNotExists(),this.analytics.load(e,co,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.log("init | SDK loaded successfully",{userId:this.getUserId(),anonymousId:this.getAnonymousId()}),this.onLoadedCallback?.()}})}catch(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let i=this.getUserId();if(!i||i!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:t}),this.analytics.identify(e,t||{}),this.has_identified=!0}catch(n){console.error("RudderStack: Failed to identify user",n)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,t="Deriv App",i,n)=>{if(!(!this.has_initialized||e===this.current_page))try{let r={...i&&{user_id:i},...n};this.log("pageView | tracking page view",{platform:t,current_page:e,properties:r}),this.analytics.page(t,e,r),this.current_page=e}catch(r){console.error("RudderStack: Failed to track page view",r)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting RudderStack session"),this.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,t)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:t}),this.analytics.track(e,t)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=t,this.debug=i,this.init(e)}};zt.getRudderStackInstance=(e,t,i=!1)=>(zt._instance||(zt._instance=new zt(e,t,i)),zt._instance);var fn=zt;fo();ps();var gn="cached_analytics_events",pn="cached_analytics_page_views",tu=(s,e)=>{try{let t=Qs(),i=Qe.get(gn),n=i?JSON.parse(i):[];n.push({name:s,properties:e,timestamp:Date.now()});let r={expires:1};t&&(r.domain=t),Qe.set(gn,JSON.stringify(n),r)}catch(t){console.warn("Analytics: Failed to cache event",t)}},su=(s,e)=>{try{let t=Qs(),i=Qe.get(pn),n=i?JSON.parse(i):[];n.push({name:s,properties:e,timestamp:Date.now()});let r={expires:1};t&&(r.domain=t),Qe.set(pn,JSON.stringify(n),r)}catch(t){console.warn("Analytics: Failed to cache page view",t)}},iu=()=>{try{let s=Qe.get(gn);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached events",s)}return[]},nu=()=>{try{let s=Qe.get(pn);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached pages",s)}return[]},ru=()=>{let s=Qs(),e=s?{domain:s}:{};Qe.remove(gn,e)},ou=()=>{let s=Qs(),e=s?{domain:s}:{};Qe.remove(pn,e)};vs();vs();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 i=a=>{let l=2166136261;for(let c=0;c<a.length;c++)l^=a.charCodeAt(c),l=l*16777619>>>0;return l.toString(16)},n=a=>btoa(a),r=i(e),o=n(r);for(;o.length<t;)o+=n(i(o));return o.substring(0,t)}getCookies(e){let i=`; ${document.cookie}`.split(`; ${e}=`);if(i.length===2){let n=decodeURIComponent(i.pop().split(";").shift());try{return JSON.parse(n)}catch{return n}}return null}trackPageUnload(){typeof window>"u"||window.addEventListener("beforeunload",()=>{this.isPageViewSent()||this.push("cached_analytics_page_views",{name:window.location.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(i,n){return this._url=n,this._method=i,e.apply(this,arguments)},XMLHttpRequest.prototype.send=function(i){return this.addEventListener("load",function(){let n=null;if(typeof i=="string")try{n=JSON.parse(i)}catch{n=i}let r={url:this._url,method:this._method,status:this.status,headers:this.getAllResponseHeaders(),data:this.responseText,payload:n};_s.responses.push(r)}),t.apply(this,arguments)},this.isTrackingResponses=!0}getAnalyticsInstance(){return typeof window>"u"?null:window.AnalyticsInstance??window.DerivAnalytics?.Analytics??window.Analytics?.Analytics}isReady(){if(typeof window>"u")return!1;let e=this.getAnalyticsInstance();return e?!!e.getInstances?.()?.tracking:!1}parseCookies(e){if(typeof document>"u")return null;let t=document.cookie.split("; ");for(let i of t){let n=i.indexOf("=");if(n!==-1&&decodeURIComponent(i.slice(0,n))===e){let r=i.slice(n+1);try{return JSON.parse(decodeURIComponent(r))}catch{return decodeURIComponent(r)}}}return null}isPageViewSent(){return!!this.responses.find(e=>e.payload?.type==="page"&&e.payload?.anonymousId)}set(e){this.log("set | caching event to cookie",e),this.push("cached_analytics_events",e)}push(e,t){if(typeof document>"u")return;let i=[],n=this.parseCookies(e);n&&Array.isArray(n)&&(i=n),i.push(t);let r=this.getAllowedDomain(),o=365*24*60*60,a=`${e}=${encodeURIComponent(JSON.stringify(i))}; path=/; Domain=${r}; max-age=${o}; SameSite=Lax`;document.cookie=a}getAllowedDomain(){if(typeof window>"u")return"";let e=window.location.hostname;if(e==="localhost"||/^\d+\.\d+\.\d+\.\d+$/.test(e))return e;let t=e.split(".");return t.length===1?e:`.${t.slice(-2).join(".")}`}processEvent(e){let t=this.getCookies("client_information");if(t){let{email:i=null}=t;i&&(e.properties.email_hash=this.hash(i))}if(e?.properties?.email){let i=e.properties.email;delete e.properties.email,e.properties.email_hash=this.hash(i)}return e}track(e,t=!1){if(typeof window>"u")return;let i=this.processEvent(e),n=this.getAnalyticsInstance();this.isReady()&&!t?(this.log("track | analytics ready \u2014 calling trackEvent",{event:i.name,properties:i.properties}),n.trackEvent(i.name,i.properties)):(this.log("track | analytics not ready or cache=true \u2014 storing event",{event:i.name,cache:t}),this.set(i))}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:i={}},n=!1,r=null){let o=l=>{l.dataset?.clickEventTracking||(l.addEventListener("click",c=>{let u={name:t,properties:i,cache:n};if(typeof r=="function"){let h=r(c);u={...h,cache:h.cache??n}}this.track(u,u.cache??!1)}),l.dataset.clickEventTracking="true")};(e instanceof NodeList?Array.from(e):[e]).forEach(o)}addEventHandler(e){return typeof window>"u"?this:(e.forEach(({element:t,event:i={name:"",properties:{}},cache:n=!1,callback:r=null})=>{if(typeof t=="string"){let o=t;if(!this.delegatedSelectors.has(o)){let a=l=>{let c=l.target;if(!c)return;let u=c.closest(o);if(u&&!u.dataset?.clickEventTracking){let h={name:i.name,properties:i.properties,cache:n};if(typeof r=="function"){let g=r(l);h={...g,cache:g.cache??n}}u.dataset.clickEventTracking="true",this.track(h,h.cache??!1)}};document.addEventListener("click",a),this.delegatedSelectors.add(o)}}else(t instanceof NodeList?Array.from(t):[t]).forEach(a=>{a&&!a.dataset?.clickEventTracking&&this.listen(a,i,n,r)})}),this)}loadEvent(e){return this.log("loadEvent | firing load events",e.map(t=>t.event.name)),e.forEach(({event:t})=>{let{name:i,properties:n}=t;this.track({name:i,properties:n})}),this}pageLoadEvent(e){if(typeof window>"u")return this;let t=window.location.pathname.slice(1);return this.log("pageLoadEvent | checking page load events",{pathname:t}),e.forEach(({pages:i=[],excludedPages:n=[],event:r,callback:o=null})=>{let a=!1;if(i.length?i.includes(t)&&(a=!0):n.length&&n.includes(t)||(a=!0),a){let l=o?o():r;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:r.name,pages:i,excludedPages:n})}),this}clearInterval(){this.interval&&(clearInterval(this.interval),this.interval=null)}cleanup(){this.clearInterval(),this.responses=[],this.isTrackingResponses=!1}},_s=new go;typeof window<"u"&&(window.cacheTrackEvents=_s);function AE(s){let e=s?.debug??!1,t=it("",()=>e),i,n,r,o={},a={},l=[],c=[],u=!1,h=()=>{if(!u&&n?.has_initialized){u=!0;try{let T=iu();T.length>0&&(t(`processCookieCache | replaying ${T.length} cached event(s)`,T),T.forEach(M=>{let L=qt(M.properties);n?.track(M.name,L)}),ru());let x=nu();x.length>0&&(t(`processCookieCache | replaying ${x.length} cached page view(s)`,x),x.forEach(M=>{n?.pageView(M.name,"Deriv App",P(),M.properties)}),ou())}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&&n?.identifyEvent(T,x)}),c=[]},f=async({growthbookKey:T,growthbookDecryptionKey:x,rudderstackKey:M,growthbookOptions:L,posthogOptions:ge,debug:H})=>{var K,Q;H!==void 0&&(e=H),_s.setDebug(e),t("initialise | starting analytics initialization",{rudderstack:!!M,growthbook:!!T,posthog:!!ge});try{let V=L?.attributes?.country||(T?await Qc():void 0);if(M&&(t("initialise | initializing RudderStack"),n=fn.getRudderStackInstance(M,g,e)),L?.attributes&&Object.keys(L.attributes).length>0){let D=L.attributes,Ie=n?.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&&!Zs(D.user_id)&&{user_id:D.user_id},...Ie&&{anonymous_id:Ie}}}L??(L={}),L.attributes??(L.attributes={});let ie=n?.getAnonymousId();if((K=L.attributes).id??(K.id=ie),(Q=L.attributes).country??(Q.country=V),T){t("initialise | initializing GrowthBook");let{Growthbook:D}=await Promise.resolve().then(()=>(Qu(),Ju));i=D.getGrowthBookInstance(T,x,L,e),t("initialise | GrowthBook initialized");let Ie=setInterval(()=>{Object.keys(a).length>0?clearInterval(Ie):a=_("tracking-buttons-config",{})},1e3)}if(ge){t("initialise | initializing PostHog");let{Posthog:D}=await Promise.resolve().then(()=>(nf(),sf));r=D.getPosthogInstance(ge,e),t("initialise | PostHog initialized")}t("initialise | analytics initialization complete")}catch(V){console.warn("Analytics: Failed to initialize",V)}},p=({country:T,user_language:x,device_language:M,device_type:L,account_type:ge,user_id:H,anonymous_id:K,app_id:Q,utm_source:V,utm_medium:ie,utm_campaign:D,is_authorised:Ie,residence_country:Me,url:es,domain:$i,geo_location:Bs,loggedIn:Fe,network_downlink:Vs,network_rtt:ts,network_type:Ft,account_currency:ss,account_mode:is})=>{let ns=H??P();if(t("setAttributes | received attributes",{country:T,user_language:x,device_language:M,device_type:L,account_type:ge,user_id:H,anonymous_id:K,app_id:Q,utm_source:V,utm_medium:ie,utm_campaign:D,is_authorised:Ie,residence_country:Me,url:es,domain:$i,geo_location:Bs,loggedIn:Fe,network_downlink:Vs,network_rtt:ts,network_type:Ft,account_currency:ss,account_mode:is}),i){let At={country:T,residence_country:Me,user_language:x,device_language:M,device_type:L,utm_source:V,utm_medium:ie,utm_campaign:D,is_authorised:Ie,url:es,domain:$i,loggedIn:Fe,...H&&!Zs(H)&&{user_id:H},anonymous_id:K};ns&&(At.id=ns,At.user_id=ns),t("setAttributes | called GrowthBook setAttributes",At),i.setAttributes(At)}o={...o,...T!==void 0&&{country:T},...Bs!==void 0&&{geo_location:Bs},...x!==void 0&&{user_language:x},...ge!==void 0&&{account_type:ge},...Q!==void 0&&{app_id:Q},...Me!==void 0&&{residence_country:Me},...L!==void 0&&{device_type:L},...es!==void 0&&{url:es},...Fe!==void 0&&{loggedIn:Fe},...Vs!==void 0&&{network_downlink:Vs},...ts!==void 0&&{network_rtt:ts},...Ft!==void 0&&{network_type:Ft},...H!==void 0&&!Zs(H)&&{user_id:H},...K!==void 0&&{anonymous_id:K},...ss!==void 0&&{account_currency:ss},...is!==void 0&&{account_mode:is}},t("setAttributes | updated core_data",o)},v=T=>i?.getFeatureState(T)?.experimentResult?.name,_=(T,x)=>i?.getFeatureValue(T,x),b=async()=>await i?.getStatus(),E=T=>i?.isOn(T),C=T=>i?.setUrl(T),P=()=>{let T=n?.getUserId()||"";return T&&!Zs(T)?T:""},I=()=>n?.getAnonymousId()||"",z=(T,x="Deriv App",M)=>{let L=P();t("pageView | called",{current_page:T,platform:x,properties:M,userId:L}),n&&(n.has_initialized?(t("pageView | sending page view to RudderStack",{current_page:T,platform:x}),n.pageView(T,x,L,M)):(t("pageView | RudderStack not initialized \u2014 caching page view to cookie",{current_page:T}),su(T,{platform:x,...M})))},B=(T,x)=>{let M=T||P();if(!M){t("identifyEvent | skipped \u2014 no user_id available");return}t("identifyEvent | called",{user_id:M,traits:x});let L=Q=>{if(!Q)return Q;let{email:V,...ie}=Q;return{...ie,...V&&{is_internal:hn(V)}}},ge=x?.rudderstack!==void 0||x?.posthog!==void 0,H,K;if(ge){let{rudderstack:Q,posthog:V,...ie}=x;H=L({...ie,...Q}),K=L({...ie,...V})}else H=L(x),K=L(x);n&&(n.has_initialized?(t("identifyEvent | calling RudderStack identify",{user_id:M,traits:H}),n.identifyEvent(M,H)):c.some(Q=>Q.userId===M)||(t("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:M}),c.push({userId:M,traits:H}))),r?.has_initialized&&K&&(t("identifyEvent | calling PostHog identify",{user_id:M,traits:K}),r.identifyEvent(M,K))},N=()=>{t("reset | resetting all providers"),n?.has_initialized&&(t("reset | resetting RudderStack"),n.reset()),r?.has_initialized&&(t("reset | resetting PostHog"),r.reset())},ve=T=>"event_metadata"in T||"cta_information"in T||"error"in T,Ge={initialise:f,setAttributes:p,identifyEvent:B,backfillPersonProperties:({user_id:T,email:x,country_of_residence:M})=>{t("backfillPersonProperties | called",{user_id:T}),r?.has_initialized?(t("backfillPersonProperties | backfilling person properties in PostHog",{user_id:T}),r.backfillPersonProperties({user_id:T,email:x,country_of_residence:M})):t("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:v,getFeatureValue:_,getGrowthbookStatus:b,isFeatureOn:E,setUrl:C,getId:P,getAnonymousId:I,trackEvent:(T,x)=>{let M=P(),L={};if(t("trackEvent | called",{event:T,analytics_data:x,userId:M,core_data:o}),ve(x)){let K=x;L={...K,event_metadata:{...o,...M&&!o.user_id&&{user_id:M},...K.event_metadata}},t("trackEvent | built V2 payload",{event:T,final_payload:L})}else L={...o,...x,...M&&!o.user_id&&{user_id:M}},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=n?.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}),tu(T,L));else{l.length>0&&(t(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(Q=>{let V=qt(Q.payload);n?.track(Q.event,V)}),l=[]);let K=qt(L);t("trackEvent | sending event to RudderStack",{event:T,payload:K}),n?.track(T,K)}if(r?.has_initialized){let K=["page_name","user_language","form_name","version","email_hash"],Q=eu(L),V=qt(Object.fromEntries(Object.entries(Q).filter(([ie])=>!K.includes(ie))));t("trackEvent | sending event to PostHog",{event:T,payload:V}),r.capture(T,V)}},getInstances:()=>({ab:i,tracking:n,posthog:r}),pageView:z,reset:N};return typeof window<"u"&&(window.AnalyticsInstance=Ge),Ge}var rf=AE();return df(TE);})();
18
18
  /*! Bundled license information:
19
19
 
20
20
  js-cookie/dist/js.cookie.mjs: