import{r as xt,R as We}from"./chunk-EPOLDU6W-COUfDpEH.js";var d=typeof window<"u"?window:void 0,U=typeof globalThis<"u"?globalThis:d;typeof self>"u"&&(U.self=U),typeof File>"u"&&(U.File=function(){});var vs=Array.prototype,vr=vs.forEach,gr=vs.indexOf,Z=U==null?void 0:U.navigator,m=U==null?void 0:U.document,z=U==null?void 0:U.location,$i=U==null?void 0:U.fetch,Ii=U!=null&&U.XMLHttpRequest&&"withCredentials"in new U.XMLHttpRequest?U.XMLHttpRequest:void 0,_r=U==null?void 0:U.AbortController,W=Z==null?void 0:Z.userAgent,x=d??{},ge={DEBUG:!1,LIB_VERSION:"1.334.0"};function mr(r,e,t,i,s,n,a){try{var o=r[n](a),l=o.value}catch(u){return void t(u)}o.done?e(l):Promise.resolve(l).then(i,s)}function Ke(r){return function(){var e=this,t=arguments;return new Promise((function(i,s){var n=r.apply(e,t);function a(l){mr(n,i,s,a,o,"next",l)}function o(l){mr(n,i,s,a,o,"throw",l)}a(void 0)}))}}function b(){return b=Object.assign?Object.assign.bind():function(r){for(var e=1;e{var s=i.toLowerCase();return t.indexOf(s)!==-1}))},On=["$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"];function S(r,e){return r.indexOf(e)!==-1}var ii=function(r){return r.trim()},Fi=function(r){return r.replace(/^\$/,"")},Tn=Array.isArray,_s=Object.prototype,ms=_s.hasOwnProperty,ri=_s.toString,R=Tn||function(r){return ri.call(r)==="[object Array]"},Oe=r=>typeof r=="function",q=r=>r===Object(r)&&!R(r),Xe=r=>{if(q(r)){for(var e in r)if(ms.call(r,e))return!1;return!0}return!1},_=r=>r===void 0,H=r=>ri.call(r)=="[object String]",Ri=r=>H(r)&&r.trim().length===0,ae=r=>r===null,F=r=>_(r)||ae(r),Ee=r=>ri.call(r)=="[object Number]"&&r==r,ze=r=>Ee(r)&&r>0,we=r=>ri.call(r)==="[object Boolean]",Cn=r=>r instanceof FormData,Mn=r=>S(On,r);function Oi(r){return r===null||typeof r!="object"}function jt(r,e){return Object.prototype.toString.call(r)==="[object "+e+"]"}function ys(r){return!_(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(r,Event)}var An=[!0,"true",1,"1","yes"],li=r=>S(An,r),Dn=[!1,"false",0,"0","no"];function de(r,e,t,i,s){return e>t&&(i.warn("min cannot be greater than max."),e=t),Ee(r)?r>t?(i.warn(" cannot be greater than max: "+t+". Using max value instead."),t):r0){var n=s*this.m;e.tokens=Math.min(e.tokens+n,this.o),e.lastAccess=e.lastAccess+s*this.$}}consumeRateLimit(e){var t,i=Date.now(),s=String(e),n=this.t[s];return n?this.S(n,i):(n={tokens:this.o,lastAccess:i},this.t[s]=n),n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.i)==null||t.call(this,e)),n.tokens===0)}stop(){this.t={}}}var ie="Mobile",Ut="iOS",be="Android",Pt="Tablet",bs=be+" "+Pt,ws="iPad",Es="Apple",xs=Es+" Watch",$t="Safari",tt="BlackBerry",ks="Samsung",Ss=ks+"Browser",Ps=ks+" Internet",He="Chrome",Nn=He+" OS",$s=He+" "+Ut,Qi="Internet Explorer",Is=Qi+" "+ie,er="Opera",Hn=er+" Mini",tr="Edge",Fs="Microsoft "+tr,Qe="Firefox",Rs=Qe+" "+Ut,It="Nintendo",Ft="PlayStation",et="Xbox",Os=be+" "+ie,Ts=ie+" "+$t,vt="Windows",Ti=vt+" Phone",br="Nokia",Ci="Ouya",Cs="Generic",qn=Cs+" "+ie.toLowerCase(),Ms=Cs+" "+Pt.toLowerCase(),Mi="Konqueror",G="(\\d+(\\.\\d+)?)",ui=new RegExp("Version/"+G),jn=new RegExp(et,"i"),Un=new RegExp(Ft+" \\w+","i"),Bn=new RegExp(It+" \\w+","i"),ir=new RegExp(tt+"|PlayBook|BB10","i"),Vn={"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"},Mt,wr,ci,Gn=(r,e)=>e&&S(e,Es)||(function(t){return S(t,$t)&&!S(t,He)&&!S(t,be)})(r),As=function(r,e){return e=e||"",S(r," OPR/")&&S(r,"Mini")?Hn:S(r," OPR/")?er:ir.test(r)?tt:S(r,"IE"+ie)||S(r,"WPDesktop")?Is:S(r,Ss)?Ps:S(r,tr)||S(r,"Edg/")?Fs:S(r,"FBIOS")?"Facebook "+ie:S(r,"UCWEB")||S(r,"UCBrowser")?"UC Browser":S(r,"CriOS")?$s:S(r,"CrMo")||S(r,He)?He:S(r,be)&&S(r,$t)?Os:S(r,"FxiOS")?Rs:S(r.toLowerCase(),Mi.toLowerCase())?Mi:Gn(r,e)?S(r,ie)?Ts:$t:S(r,Qe)?Qe:S(r,"MSIE")||S(r,"Trident/")?Qi:S(r,"Gecko")?Qe:""},Wn={[Is]:[new RegExp("rv:"+G)],[Fs]:[new RegExp(tr+"?\\/"+G)],[He]:[new RegExp("("+He+"|CrMo)\\/"+G)],[$s]:[new RegExp("CriOS\\/"+G)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+G)],[$t]:[ui],[Ts]:[ui],[er]:[new RegExp("(Opera|OPR)\\/"+G)],[Qe]:[new RegExp(Qe+"\\/"+G)],[Rs]:[new RegExp("FxiOS\\/"+G)],[Mi]:[new RegExp("Konqueror[:/]?"+G,"i")],[tt]:[new RegExp(tt+" "+G),ui],[Os]:[new RegExp("android\\s"+G,"i")],[Ps]:[new RegExp(Ss+"\\/"+G)],[Qi]:[new RegExp("(rv:|MSIE )"+G)],Mozilla:[new RegExp("rv:"+G)]},zn=function(r,e){var t=As(r,e),i=Wn[t];if(_(i))return null;for(var s=0;s[et,r&&r[1]||""]],[new RegExp(It,"i"),[It,""]],[new RegExp(Ft,"i"),[Ft,""]],[ir,[tt,""]],[new RegExp(vt,"i"),(r,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Ti,""];if(new RegExp(ie).test(e)&&!/IEMobile\b/.test(e))return[vt+" "+ie,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var i=t[1],s=Vn[i]||"";return/arm/i.test(e)&&(s="RT"),[vt,s]}return[vt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,r=>{if(r&&r[3]){var e=[r[3],r[4],r[5]||"0"];return[Ut,e.join(".")]}return[Ut,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,r=>{var e="";return r&&r.length>=3&&(e=_(r[2])?r[3]:r[2]),["watchOS",e]}],[new RegExp("("+be+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+be+")","i"),r=>{if(r&&r[2]){var e=[r[2],r[3],r[4]||"0"];return[be,e.join(".")]}return[be,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,r=>{var e=["Mac OS X",""];if(r&&r[1]){var t=[r[1],r[2],r[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Nn,""]],[/Linux|debian/i,["Linux",""]]],xr=function(r){return Bn.test(r)?It:Un.test(r)?Ft:jn.test(r)?et:new RegExp(Ci,"i").test(r)?Ci:new RegExp("("+Ti+"|WPDesktop)","i").test(r)?Ti:/iPad/.test(r)?ws:/iPod/.test(r)?"iPod Touch":/iPhone/.test(r)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(r)?xs:ir.test(r)?tt:/(kobo)\s(ereader|touch)/i.test(r)?"Kobo":new RegExp(br,"i").test(r)?br:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(r)||/(kf[a-z]+)( bui|\)).+silk\//i.test(r)?"Kindle Fire":/(Android|ZTE)/i.test(r)?new RegExp(ie).test(r)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(r)||/pixel[\daxl ]{1,6}/i.test(r)&&!/pixel c/i.test(r)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(r)||/lmy47v/i.test(r)&&!/QTAQZ3/i.test(r)?be:bs:new RegExp("(pda|"+ie+")","i").test(r)?qn:new RegExp(Pt,"i").test(r)&&!new RegExp(Pt+" pc","i").test(r)?Ms:""},Yn=r=>r instanceof Error;function Jn(r){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return ci&&t.length===wr||(wr=t.length,ci=t.reduce(((i,s)=>{Mt||(Mt={});var n=Mt[s];if(n)i[n[0]]=n[1];else for(var a=r(s),o=a.length-1;o>=0;o--){var l=a[o],u=l==null?void 0:l.filename,c=e[s];if(u&&c){i[u]=c,Mt[s]=[u,c];break}}return i}),{})),ci}}class Kn{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(),a=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(a,i),$exception_level:"error"}}modifyFrames(e){var t=this;return Ke((function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&R(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,s;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),b({},e,{cause:i,stack:s})}applyChunkIds(e,t){return e.map((i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Ke((function*(){var i=e;for(var s of t.modifiers)i=yield s(i);return i}))()}convertToExceptionList(e,t){var i,s,n,a={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(s=t.handled)===null||s===void 0||s,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(a.stacktrace={type:"raw",frames:e.stack});var o=[a];return e.cause!=null&&o.push(...this.convertToExceptionList(e.cause,b({},t,{handled:!0}))),o}buildParsingContext(){return{chunkIdMap:Jn(this.stackParser)}}buildCoercingContext(e,t,i){i===void 0&&(i=0);var s=(n,a)=>{if(a<=4){var o=this.buildCoercingContext(e,t,a);return this.applyCoercers(n,o)}};return b({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:n=>s(n,i),next:n=>s(n,i+1)})}}var it="?";function Ai(r,e,t,i,s){var n={platform:r,filename:e,function:t===""?it:t,in_app:!0};return _(i)||(n.lineno=i),_(s)||(n.colno=s),n}var Ds=(r,e)=>{var t=r.indexOf("safari-extension")!==-1,i=r.indexOf("safari-web-extension")!==-1;return t||i?[r.indexOf("@")!==-1?r.split("@")[0]:it,t?"safari-extension:"+e:"safari-web-extension:"+e]:[r,e]},Xn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Zn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Qn=/\((\S*)(?::(\d+))(?::(\d+))\)/,ea=(r,e)=>{var t=Xn.exec(r);if(t){var[,i,s,n]=t;return Ai(e,i,it,+s,+n)}var a=Zn.exec(r);if(a){if(a[2]&&a[2].indexOf("eval")===0){var o=Qn.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,u]=Ds(a[1]||it,a[2]);return Ai(e,u,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},ta=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ia=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ra=(r,e)=>{var t=ta.exec(r);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=ia.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var s=t[3],n=t[1]||it;return[n,s]=Ds(n,s),Ai(e,s,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},kr=/\(error: (.*)\)/,Sr=50;function sa(){return(function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i1024)){var c=kr.test(u)?u.replace(kr,"$1"):u;if(!c.match(/\S*Error: /)){for(var h of t){var p=h(c,r);if(p){a.push(p);break}}if(a.length>=Sr)break}}}return(function(f){if(!f.length)return[];var v=Array.from(f);return v.reverse(),v.slice(0,Sr).map((g=>{return b({},g,{filename:g.filename||(w=v,w[w.length-1]||{}).filename,function:g.function||it});var w}))})(a)}})("web:javascript",ea,ra)}class na{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=H(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 jt(e,"DOMException")}isDOMError(e){return jt(e,"DOMError")}}class aa{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}}class oa{constructor(){}match(e){return jt(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var i,s=t.apply(e.error);return s||{type:"ErrorEvent",value:e.message,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}}var la=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ua{match(e){return typeof e=="string"}coerce(e,t){var i,[s,n]=this.getInfos(e);return{type:s??"Error",value:n??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(la);return s&&(t=s[1],i=s[2]),[t,i]}}var ca=["fatal","error","warning","log","info","debug"];function Ls(r,e){e===void 0&&(e=40);var t=Object.keys(r);if(t.sort(),!t.length)return"[object has no keys]";for(var i=t.length;i>0;i--){var s=t.slice(0,i).join(", ");if(!(s.length>e))return i===t.length||s.length<=e?s:s.slice(0,e)+"..."}return""}class ha{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:(i=t.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return ys(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: "+Ls(e)}isSeverityLevel(e){return H(e)&&!Ri(e)&&ca.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Yn(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}}class da{match(e){return ys(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+Ls(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}}class pa{match(e){return Oi(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}}}class fa{match(e){return jt(e,"PromiseRejectionEvent")}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return Oi(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){if(Oi(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}}var Ns=function(r,e){var{debugEnabled:t}=e===void 0?{}:e,i={k:function(s){if(d&&(ge.DEBUG||x.POSTHOG_DEBUG||t)&&!_(d.console)&&d.console){for(var n=("__rrweb_original__"in d.console[s])?d.console[s].__rrweb_original__:d.console[s],a=arguments.length,o=new Array(a>1?a-1:0),l=1;l{i.error("You must initialize PostHog before calling "+s)},createLogger:(s,n)=>Ns(r+" "+s,n)};return i},y=Ns("[PostHog.js]"),D=y.createLogger,va=D("[ExternalScriptsLoader]"),Pr=(r,e,t)=>{if(r.config.disable_external_dependency_loading)return va.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var i=m==null?void 0:m.querySelectorAll("script");if(i){for(var s,n=function(){if(i[a].src===e){var l=i[a];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(u=>{l.__posthog_loading_callback_fired=!0,t(void 0,u)})),l.onerror=u=>t(u),{v:void 0})}},a=0;a{if(!m)return t("document not found");var l=m.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),r.config.prepare_external_dependency_script&&(l=r.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(r.config.external_scripts_inject_target==="head")m.head.appendChild(l);else{var u,c=m.querySelectorAll("body > script");c.length>0?(u=c[0].parentNode)==null||u.insertBefore(l,c[0]):m.body.appendChild(l)}};m!=null&&m.body?o():m==null||m.addEventListener("DOMContentLoaded",o)};x.__PosthogExtensions__=x.__PosthogExtensions__||{},x.__PosthogExtensions__.loadExternalDependency=(r,e,t)=>{var i="/static/"+e+".js?v="+r.version;if(e==="remote-config"&&(i="/array/"+r.config.token+"/config.js"),e==="toolbar"){var s=3e5;i=i+"&t="+Math.floor(Date.now()/s)*s}var n=r.requestRouter.endpointFor("assets",i);Pr(r,n,t)},x.__PosthogExtensions__.loadSiteApp=(r,e,t)=>{var i=r.requestRouter.endpointFor("api",e);Pr(r,i,t)};var Bt={};function Te(r,e,t){if(R(r)){if(vr&&r.forEach===vr)r.forEach(e,t);else if("length"in r&&r.length===+r.length){for(var i=0,s=r.length;i1?e-1:0),i=1;i1?e-1:0),i=1;i0||Ee(t))&&(e[i]=t)})),e};function _a(r,e){return t=r,i=n=>H(n)&&!ae(e)?n.slice(0,e):n,s=new Set,(function n(a,o){return a!==Object(a)?i?i(a,o):a:s.has(a)?void 0:(s.add(a),R(a)?(l=[],Te(a,(u=>{l.push(n(u))}))):(l={},T(a,((u,c)=>{s.has(u)||(l[c]=n(u,c))}))),l);var l})(t);var t,i,s}var ma=["herokuapp.com","vercel.app","netlify.app"];function ya(r){var e=r==null?void 0:r.hostname;if(!H(e))return!1;var t=e.split(".").slice(-2).join(".");for(var i of ma)if(t===i)return!1;return!0}function Hs(r,e){for(var t=0;te.match(t))))}function Yt(r){var e="";switch(typeof r.className){case"string":e=r.className;break;case"object":e=(r.className&&"baseVal"in r.className?r.className.baseVal:null)||r.getAttribute("class")||"";break;default:e=""}return sr(e)}function Ws(r){return F(r)?null:ii(r).split(/(\s+)/).filter((e=>Rt(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ot(r){var e="";return Vi(r)&&!Xs(r)&&r.childNodes&&r.childNodes.length&&T(r.childNodes,(function(t){var i;Vs(t)&&t.textContent&&(e+=(i=Ws(t.textContent))!==null&&i!==void 0?i:"")})),ii(e)}function zs(r){return _(r.target)?r.srcElement||null:(e=r.target)!=null&&e.shadowRoot?r.composedPath()[0]||null:r.target||null;var e}var nr=["a","button","form","input","select","textarea","label"];function Ys(r,e){if(_(e))return!0;var t,i=function(n){if(e.some((a=>n.matches(a))))return{v:!0}};for(var s of r)if(t=i(s))return t.v;return!1}function Js(r){var e=r.parentNode;return!(!e||!si(e))&&e}var wa=["next","previous","prev",">","<"],Dr=10,Lr=[".ph-no-rageclick",".ph-no-capture"];function Ea(r,e){if(!d||ar(r))return!1;var t,i,s;if(we(e)?(t=!!e&&Lr,i=void 0):(t=(s=e==null?void 0:e.css_selector_ignorelist)!==null&&s!==void 0?s:Lr,i=e==null?void 0:e.content_ignorelist),t===!1)return!1;var{targetElementList:n}=Ks(r,!1);return!(function(a,o){if(a===!1||_(a))return!1;var l;if(a===!0)l=wa;else{if(!R(a))return!1;if(a.length>Dr)return y.error("[PostHog] content_ignorelist array cannot exceed "+Dr+" items. Use css_selector_ignorelist for more complex matching."),!1;l=a.map((u=>u.toLowerCase()))}return o.some((u=>{var{safeText:c,ariaLabel:h}=u;return l.some((p=>c.includes(p)||h.includes(p)))}))})(i,n.map((a=>{var o;return{safeText:Ot(a).toLowerCase(),ariaLabel:((o=a.getAttribute("aria-label"))==null?void 0:o.toLowerCase().trim())||""}})))&&!Ys(n,t)}var ar=r=>!r||Ce(r,"html")||!si(r),Ks=(r,e)=>{if(!d||ar(r))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[r],s=r;s.parentNode&&!Ce(s,"body");)if(Gs(s.parentNode))i.push(s.parentNode.host),s=s.parentNode.host;else{var n=Js(s);if(!n)break;if(e||nr.indexOf(n.tagName.toLowerCase())>-1)t=!0;else{var a=d.getComputedStyle(n);a&&a.getPropertyValue("cursor")==="pointer"&&(t=!0)}i.push(n),s=n}return{parentIsUsefulElement:t,targetElementList:i}};function xa(r,e,t,i,s){var n,a,o,l;if(t===void 0&&(t=void 0),!d||ar(r)||(n=t)!=null&&n.url_allowlist&&!Ar(t.url_allowlist)||(a=t)!=null&&a.url_ignorelist&&Ar(t.url_ignorelist))return!1;if((o=t)!=null&&o.dom_event_allowlist){var u=t.dom_event_allowlist;if(u&&!u.some((v=>e.type===v)))return!1}var{parentIsUsefulElement:c,targetElementList:h}=Ks(r,i);if(!(function(v,g){var w=g==null?void 0:g.element_allowlist;if(_(w))return!0;var E,k=function(P){if(w.some((C=>P.tagName.toLowerCase()===C)))return{v:!0}};for(var I of v)if(E=k(I))return E.v;return!1})(h,t)||!Ys(h,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var p=d.getComputedStyle(r);if(p&&p.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var f=r.tagName.toLowerCase();switch(f){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return c?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(nr.indexOf(f)>-1||r.getAttribute("contenteditable")==="true")}}function Vi(r){for(var e=r;e.parentNode&&!Ce(e,"body");e=e.parentNode){var t=Yt(e);if(S(t,"ph-sensitive")||S(t,"ph-no-capture"))return!1}if(S(Yt(r),"ph-include"))return!0;var i=r.type||"";if(H(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var s=r.name||r.id||"";return!(H(s)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,"")))}function Xs(r){return!!(Ce(r,"input")&&!["button","checkbox","submit","reset"].includes(r.type)||Ce(r,"select")||Ce(r,"textarea")||r.getAttribute("contenteditable")==="true")}var Zs="(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})",ka=new RegExp("^(?:"+Zs+")$"),Sa=new RegExp(Zs),Qs="\\d{3}-?\\d{2}-?\\d{4}",Pa=new RegExp("^("+Qs+")$"),$a=new RegExp("("+Qs+")");function Rt(r,e){return e===void 0&&(e=!0),!(F(r)||H(r)&&(r=ii(r),(e?ka:Sa).test((r||"").replace(/[- ]/g,""))||(e?Pa:$a).test(r)))}function en(r){var e=Ot(r);return Rt(e=(e+" "+tn(r)).trim())?e:""}function tn(r){var e="";return r&&r.childNodes&&r.childNodes.length&&T(r.childNodes,(function(t){var i;if(t&&((i=t.tagName)==null?void 0:i.toLowerCase())==="span")try{var s=Ot(t);e=(e+" "+s).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+tn(t)).trim())}catch(n){y.error("[AutoCapture]",n)}})),e}function Ia(r){return(function(e){var t=e.map((i=>{var s,n,a="";if(i.tag_name&&(a+=i.tag_name),i.attr_class)for(var o of(i.attr_class.sort(),i.attr_class))a+="."+o.replace(/"/g,"");var l=b({},i.text?{text:i.text}:{},{"nth-child":(s=i.nth_child)!==null&&s!==void 0?s:0,"nth-of-type":(n=i.nth_of_type)!==null&&n!==void 0?n:0},i.href?{href:i.href}:{},i.attr_id?{attr_id:i.attr_id}:{},i.attributes),u={};return Ht(l).sort(((c,h)=>{var[p]=c,[f]=h;return p.localeCompare(f)})).forEach((c=>{var[h,p]=c;return u[Nr(h.toString())]=Nr(p.toString())})),a+=":",a+=Ht(u).map((c=>{var[h,p]=c;return h+'="'+p+'"'})).join("")}));return t.join(";")})((function(e){return e.map((t=>{var i,s,n={text:(i=t.$el_text)==null?void 0:i.slice(0,400),tag_name:t.tag_name,href:(s=t.attr__href)==null?void 0:s.slice(0,2048),attr_class:Fa(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ht(t).filter((a=>{var[o]=a;return o.indexOf("attr__")===0})).forEach((a=>{var[o,l]=a;return n.attributes[o]=l})),n}))})(r))}function Nr(r){return r.replace(/"|\\"/g,'\\"')}function Fa(r){var e=r.attr__class;return e?R(e)?e:sr(e):void 0}class rn{constructor(e){this.disabled=e===!1;var t=q(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y){var e=m==null?void 0:m.createElement("a");return _(e)?null:(e.href=r,e)},Ra=function(r,e){var t,i;e===void 0&&(e="&");var s=[];return T(r,(function(n,a){_(n)||_(a)||a==="undefined"||(t=encodeURIComponent((o=>o instanceof File)(n)?n.name:n.toString()),i=encodeURIComponent(a),s[s.length]=i+"="+t)})),s.join(e)},Kt=function(r,e){for(var t,i=((r.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;sr?e.slice(0,r)+"...":e}function Oa(r){if(r.previousElementSibling)return r.previousElementSibling;var e=r;do e=e.previousSibling;while(e&&!si(e));return e}function Ta(r,e,t,i){var s=r.tagName.toLowerCase(),n={tag_name:s};nr.indexOf(s)>-1&&!t&&(s.toLowerCase()==="a"||s.toLowerCase()==="button"?n.$el_text=pi(1024,en(r)):n.$el_text=pi(1024,Ot(r)));var a=Yt(r);a.length>0&&(n.classes=a.filter((function(c){return c!==""}))),T(r.attributes,(function(c){var h;if((!Xs(r)||["name","id","class","aria-label"].indexOf(c.name)!==-1)&&(i==null||!i.includes(c.name))&&!e&&Rt(c.value)&&(h=c.name,!H(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var p=c.value;c.name==="class"&&(p=sr(p).join(" ")),n["attr__"+c.name]=pi(1024,p)}}));for(var o=1,l=1,u=r;u=Oa(u);)o++,u.tagName===r.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}function Ca(r,e){for(var t,i,{e:s,maskAllElementAttributes:n,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:l}=e,u=[r],c=r;c.parentNode&&!Ce(c,"body");)Gs(c.parentNode)?(u.push(c.parentNode.host),c=c.parentNode.host):(u.push(c.parentNode),c=c.parentNode);var h,p=[],f={},v=!1,g=!1;if(T(u,(P=>{var C=Vi(P);P.tagName.toLowerCase()==="a"&&(v=P.getAttribute("href"),v=C&&v&&Rt(v)&&v),S(Yt(P),"ph-no-capture")&&(g=!0),p.push(Ta(P,n,a,o));var se=(function(J){if(!Vi(J))return{};var $={};return T(J.attributes,(function(oe){if(oe.name&&oe.name.indexOf("data-ph-capture-attribute")===0){var K=oe.name.replace("data-ph-capture-attribute-",""),ne=oe.value;K&&ne&&Rt(ne)&&($[K]=ne)}})),$})(P);L(f,se)})),g)return{props:{},explicitNoCapture:g};if(a||(r.tagName.toLowerCase()==="a"||r.tagName.toLowerCase()==="button"?p[0].$el_text=en(r):p[0].$el_text=Ot(r)),v){var w,E;p[0].attr__href=v;var k=(w=Jt(v))==null?void 0:w.host,I=d==null||(E=d.location)==null?void 0:E.host;k&&I&&k!==I&&(h=v)}return{props:L({$event_type:s.type,$ce_version:1},l?{}:{$elements:p},{$elements_chain:Ia(p)},(t=p[0])!=null&&t.$el_text?{$el_text:(i=p[0])==null?void 0:i.$el_text}:{},h&&s.type==="click"?{$external_click_url:h}:{},f)}}class Ma{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new rn(e.config.rageclick),this.C=null}get R(){var e,t,i=q(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=(e=i.url_allowlist)==null?void 0:e.map((s=>new RegExp(s))),i.url_ignorelist=(t=i.url_ignorelist)==null?void 0:t.map((s=>new RegExp(s))),i}F(){if(this.isBrowserSupported()){if(d&&m){var e=i=>{i=i||(d==null?void 0:d.event);try{this.M(i)}catch(s){Hr.error("Failed to capture event",s)}};if(N(m,"submit",e,{capture:!0}),N(m,"change",e,{capture:!0}),N(m,"click",e,{capture:!0}),this.R.capture_copied_text){var t=i=>{i=i||(d==null?void 0:d.event),this.M(i,di)};N(m,"copy",t,{capture:!0}),N(m,"cut",t,{capture:!0})}}}else Hr.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ir]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,i=[];return(t=this.C)==null||t.forEach((s=>{var n=m==null?void 0:m.querySelectorAll(s);n==null||n.forEach((a=>{e===a&&i.push(s)}))})),i}get isEnabled(){var e,t,i=(e=this.instance.persistence)==null?void 0:e.props[Ir],s=this.T;if(ae(s)&&!we(i)&&!this.instance.O())return!1;var n=(t=this.T)!==null&&t!==void 0?t:!!i;return!!this.instance.config.autocapture&&!n}M(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var i,s=zs(e);Vs(s)&&(s=s.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(i=this.rageclicks)!=null&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&Ea(s,this.instance.config.rageclick)&&this.M(e,"$rageclick");var n=t===di;if(s&&xa(s,e,this.R,n,n?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=Ca(s,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(o)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(a.$element_selectors=l),t===di){var u,c=Ws(d==null||(u=d.getSelection())==null?void 0:u.toString()),h=e.type||"clipboard";if(!c)return!1;a.$selected_content=c,a.$copy_type=h}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return Oe(m==null?void 0:m.querySelectorAll)}}Math.trunc||(Math.trunc=function(r){return r<0?Math.ceil(r):Math.floor(r)}),Number.isInteger||(Number.isInteger=function(r){return Ee(r)&&isFinite(r)&&Math.floor(r)===r});var qr="0123456789abcdef";class Zt{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,s){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||e<0||t<0||i<0||s<0||e>0xffffffffffff||t>4095||i>1073741823||s>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=s>>>24,n[13]=s>>>16,n[14]=s>>>8,n[15]=s,new Zt(n)}toString(){for(var e="",t=0;t>>4)+qr.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 Zt(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}}class Aa{constructor(){this.A=0,this.D=0,this.j=new Da}generate(){var e=this.generateOrAbort();if(_(e)){this.A=0;var t=this.generateOrAbort();if(_(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.D++,this.D>4398046511103&&(this.A++,this.L())}return Zt.fromFieldsV7(this.A,Math.trunc(this.D/Math.pow(2,30)),this.D&Math.pow(2,30)-1,this.j.nextUint32())}L(){this.D=1024*this.j.nextUint32()+(1023&this.j.nextUint32())}}var jr,sn=r=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;ecrypto.getRandomValues(r));class Da{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(sn(this.N),this.U=0),this.N[this.U++]}}var Re=()=>La().toString(),La=()=>(jr||(jr=new Aa)).generate(),ot="",Na=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ha(r,e){if(e){var t=(function(s,n){if(n===void 0&&(n=m),ot)return ot;if(!n||["localhost","127.0.0.1"].includes(s))return"";for(var a=s.split("."),o=Math.min(a.length,8),l="dmn_chk_"+Re();!ot&&o--;){var u=a.slice(o).join("."),c=l+"=1;domain=."+u+";path=/";n.cookie=c+";max-age=3",n.cookie.includes(l)&&(n.cookie=c+";max-age=0",ot=u)}return ot})(r);if(!t){var i=(s=>{var n=s.match(Na);return n?n[0]:""})(r);i!==t&&y.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}var he={H:()=>!!m,B:function(r){y.error("cookieStore error: "+r)},q:function(r){if(m){try{for(var e=r+"=",t=m.cookie.split(";").filter((n=>n.length)),i=0;i3686.4&&y.warn("cookieStore warning: large cookie, len="+u.length),m.cookie=u,u}catch{return}},V:function(r,e){if(m!=null&&m.cookie)try{he.G(r,"",-1,e)}catch{return}}},fi=null,A={H:function(){if(!ae(fi))return fi;var r=!0;if(_(d))r=!1;else try{var e="__mplssupport__";A.G(e,"xyz"),A.q(e)!=='"xyz"'&&(r=!1),A.V(e)}catch{r=!1}return r||y.error("localStorage unsupported; falling back to cookie store"),fi=r,r},B:function(r){y.error("localStorage error: "+r)},q:function(r){try{return d==null?void 0:d.localStorage.getItem(r)}catch(e){A.B(e)}return null},W:function(r){try{return JSON.parse(A.q(r))||{}}catch{}return null},G:function(r,e){try{d==null||d.localStorage.setItem(r,JSON.stringify(e))}catch(t){A.B(t)}},V:function(r){try{d==null||d.localStorage.removeItem(r)}catch(e){A.B(e)}}},qa=["$device_id","distinct_id",Vt,Us,zt,Wt],At={},ja={H:function(){return!0},B:function(r){y.error("memoryStorage error: "+r)},q:function(r){return At[r]||null},W:function(r){return At[r]||null},G:function(r,e){At[r]=e},V:function(r){delete At[r]}},Ae=null,j={H:function(){if(!ae(Ae))return Ae;if(Ae=!0,_(d))Ae=!1;else try{var r="__support__";j.G(r,"xyz"),j.q(r)!=='"xyz"'&&(Ae=!1),j.V(r)}catch{Ae=!1}return Ae},B:function(r){y.error("sessionStorage error: ",r)},q:function(r){try{return d==null?void 0:d.sessionStorage.getItem(r)}catch(e){j.B(e)}return null},W:function(r){try{return JSON.parse(j.q(r))||null}catch{}return null},G:function(r,e){try{d==null||d.sessionStorage.setItem(r,JSON.stringify(e))}catch(t){j.B(t)}},V:function(r){try{d==null||d.sessionStorage.removeItem(r)}catch(e){j.B(e)}}},me=(function(r){return r[r.PENDING=-1]="PENDING",r[r.DENIED=0]="DENIED",r[r.GRANTED=1]="GRANTED",r})({});class Ua{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?me.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===me.DENIED||this.consent===me.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===me.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return li(e)?me.GRANTED:S(Dn,e)?me.DENIED:me.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?A:he;var t=e==="localStorage"?he:A;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(li(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!Hs([Z==null?void 0:Z.doNotTrack,Z==null?void 0:Z.msDoNotTrack,x.doNotTrack],(e=>li(e)))}}var Dt=D("[Dead Clicks]"),Ba=()=>!0,Va=r=>{var e,t=!((e=r.instance.persistence)==null||!e.get_property(js)),i=r.instance.config.capture_dead_clicks;return we(i)?i:!!q(i)||t};class nn{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[js]:e==null?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it((()=>{this.et()}))}it(e){var t,i;(t=x.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(i=x.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(s=>{s?Dt.error("failed to load script",s):e()}))}et(){var e;if(m){if(!this.tt&&(e=x.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=q(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=x.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(m),Dt.info("starting...")}}else Dt.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Dt.info("stopping..."))}}var lt=D("[ExceptionAutocapture]");class Ga{constructor(e){var t,i,s;this.rt=()=>{var n;if(d&&this.isEnabled&&(n=x.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var a=x.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=x.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=x.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=a(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=o(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(u){lt.error("failed to start",u),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[Fr]),this.dt=new Ln({refillRate:(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,h:lt}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return q(e)?t=b({},t,e):(_(e)?this.ht:e)&&(t=b({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(lt.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,i;(t=x.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(i=x.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return lt.error("failed to load script",s);e()}))}ut(){var e,t,i;(e=this.st)==null||e.call(this),this.st=void 0,(t=this.nt)==null||t.call(this),this.nt=void 0,(i=this.ot)==null||i.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[Fr]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,i,s=(t=e==null||(i=e.$exception_list)==null||(i=i[0])==null?void 0:i.type)!==null&&t!==void 0?t:"Exception";this.dt.consumeRateLimit(s)?lt.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}}function Ur(r,e,t){try{if(!(e in r))return()=>{};var i=r[e],s=t(i);return Oe(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),r[e]=s,()=>{r[e]=i}}catch{return()=>{}}}class Wa{constructor(e){var t;this._instance=e,this.ct=(d==null||(t=d.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(y.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,y.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(d&&d.history){var i=this;(e=d.history.pushState)!=null&&e.__posthog_wrapped__||Ur(d.history,"pushState",(s=>function(n,a,o){s.call(this,n,a,o),i._t("pushState")})),(t=d.history.replaceState)!=null&&t.__posthog_wrapped__||Ur(d.history,"replaceState",(s=>function(n,a,o){s.call(this,n,a,o),i._t("replaceState")})),this.yt()}}_t(e){try{var t,i=d==null||(t=d.location)==null?void 0:t.pathname;if(!i)return;i!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=i}catch(s){y.error("Error capturing "+e+" pageview",s)}}yt(){if(!this.ft){var e=()=>{this._t("popstate")};N(d,"popstate",e),this.ft=()=>{d&&d.removeEventListener("popstate",e)}}}}var vi=D("[SegmentIntegration]");function za(r,e){var t=r.config.segment;if(!t)return e();(function(i,s){var n=i.config.segment;if(!n)return s();var a=l=>{var u=()=>l.anonymousId()||Re();i.config.get_device_id=u,l.id()&&(i.register({distinct_id:l.id(),$device_id:u()}),i.persistence.set_property(_e,"identified")),s()},o=n.user();"then"in o&&Oe(o.then)?o.then(a):a(o)})(r,(()=>{t.register((i=>{Promise&&Promise.resolve||vi.warn("This browser does not have Promise support, and can not use the segment integration");var s=(n,a)=>{if(!a)return n;n.event.userId||n.event.anonymousId===i.get_distinct_id()||(vi.info("No userId set, resetting PostHog"),i.reset()),n.event.userId&&n.event.userId!==i.get_distinct_id()&&(vi.info("UserId set, identifying with PostHog"),i.identify(n.event.userId));var o=i.calculateEventProperties(a,n.event.properties);return n.event.properties=Object.assign({},o,n.event.properties),n};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:n=>s(n,n.event.event),page:n=>s(n,"$pageview"),identify:n=>s(n,"$identify"),screen:n=>s(n,"$screen")}})(r)).then((()=>{e()}))}))}var an="posthog-js";function on(r,e){var{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:a=!0}=e===void 0?{}:e;return o=>{var l,u,c,h,p;if(!(n==="*"||n.includes(o.level))||!r.__loaded)return o;o.tags||(o.tags={});var f=r.requestRouter.endpointFor("ui","/project/"+r.config.token+"/person/"+r.get_distinct_id());o.tags["PostHog Person URL"]=f,r.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=r.get_session_replay_url({withTimestamp:!0}));var v=((l=o.exception)==null?void 0:l.values)||[],g=v.map((E=>b({},E,{stacktrace:E.stacktrace?b({},E.stacktrace,{type:"raw",frames:(E.stacktrace.frames||[]).map((k=>b({},k,{platform:"web:javascript"})))}):void 0}))),w={$exception_message:((u=v[0])==null?void 0:u.value)||o.message,$exception_type:(c=v[0])==null?void 0:c.type,$exception_level:o.level,$exception_list:g,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((h=v[0])==null?void 0:h.value)||o.message,$sentry_exception_type:(p=v[0])==null?void 0:p.type,$sentry_tags:o.tags};return t&&i&&(w.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),a&&r.exceptions.sendExceptionEvent(w),o}}class Ya{constructor(e,t,i,s,n,a){this.name=an,this.setupOnce=function(o){o(on(e,{organization:t,projectId:i,prefix:s,severityAllowList:n,sendExceptionsToPostHog:a==null||a}))}}}var Ja=d!=null&&d.location?Xt(d.location.hash,"__posthog")||Xt(location.hash,"state"):null,Br="_postHogToolbarParams",Vr=D("[Toolbar]"),Fe=(function(r){return r[r.UNINITIALIZED=0]="UNINITIALIZED",r[r.LOADING=1]="LOADING",r[r.LOADED=2]="LOADED",r})(Fe||{});class Ka{constructor(e){this.instance=e}bt(e){x.ph_toolbar_state=e}wt(){var e;return(e=x.ph_toolbar_state)!==null&&e!==void 0?e:Fe.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),!d||!m)return!1;e=e??d.location,i=i??d.history;try{if(!t){try{d.localStorage.setItem("test","test"),d.localStorage.removeItem("test")}catch{return!1}t=d==null?void 0:d.localStorage}var s,n=Ja||Xt(e.hash,"__posthog")||Xt(e.hash,"state"),a=n?$r((()=>JSON.parse(atob(decodeURIComponent(n)))))||$r((()=>JSON.parse(decodeURIComponent(n)))):null;return a&&a.action==="ph_authorize"?((s=a).source="url",s&&Object.keys(s).length>0&&(a.desiredHash?e.hash=a.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(Br)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch{return!1}}xt(e){var t=x.ph_load_toolbar||x.ph_load_editor;!F(t)&&Oe(t)?t(e,this.instance):Vr.warn("No toolbar load function found")}loadToolbar(e){var t=!(m==null||!m.getElementById(Bs));if(!d||t)return!1;var i=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=b({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(d.localStorage.setItem(Br,JSON.stringify(b({},s,{source:void 0}))),this.wt()===Fe.LOADED)this.xt(s);else if(this.wt()===Fe.UNINITIALIZED){var n;this.bt(Fe.LOADING),(n=x.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,"toolbar",(a=>{if(a)return Vr.error("[Toolbar] Failed to load",a),void this.bt(Fe.UNINITIALIZED);this.bt(Fe.LOADED),this.xt(s)})),N(d,"turbolinks:load",(()=>{this.bt(Fe.UNINITIALIZED),this.loadToolbar(s)}))}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Xa=D("[TracingHeaders]");class Za{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,i;_(this.$t)&&((t=x.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),_(this.St)&&((i=x.__PosthogExtensions__)==null||(i=i.tracingHeadersPatchFns)==null||i._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,i;(t=x.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(i=x.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return Xa.error("failed to load script",s);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.$t)==null||e.call(this),(t=this.St)==null||t.call(this),this.$t=void 0,this.St=void 0)}}var Lt="https?://(.*)",nt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Qa=st(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],nt),Ct="",eo=["li_fat_id"];function ln(r,e,t){if(!m)return{};var i,s=e?st([],nt,t||[]):[],n=un(Tt(m.URL,s,Ct),r),a=(i={},T(eo,(function(o){var l=he.q(o);i[o]=l||null})),i);return L(a,n)}function un(r,e){var t=Qa.concat(e||[]),i={};return T(t,(function(s){var n=Kt(r,s);i[s]=n||null})),i}function cn(r){var e=(function(n){return n?n.search(Lt+"google.([^/?]*)")===0?"google":n.search(Lt+"bing.com")===0?"bing":n.search(Lt+"yahoo.com")===0?"yahoo":n.search(Lt+"duckduckgo.com")===0?"duckduckgo":null:null})(r),t=e!="yahoo"?"q":"p",i={};if(!ae(e)){i.$search_engine=e;var s=m?Kt(m.referrer,t):"";s.length&&(i.ph_keyword=s)}return i}function Gr(){return navigator.language||navigator.userLanguage}function hn(){return(m==null?void 0:m.referrer)||"$direct"}function dn(r,e){var t=r?st([],nt,e||[]):[],i=z==null?void 0:z.href.substring(0,1e3);return{r:hn().substring(0,1e3),u:i?Tt(i,t,Ct):void 0}}function pn(r){var e,{r:t,u:i}=r,s={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Jt(t))==null?void 0:e.host};if(i){s.$current_url=i;var n=Jt(i);s.$host=n==null?void 0:n.host,s.$pathname=n==null?void 0:n.pathname;var a=un(i);L(s,a)}if(t){var o=cn(t);L(s,o)}return s}function fn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function to(){try{return new Date().getTimezoneOffset()}catch{return}}function io(r,e){if(!W)return{};var t,i,s,n=r?st([],nt,e||[]):[],[a,o]=(function(l){for(var u=0;u1e3?W.substring(0,997)+"...":W,$browser_version:zn(W,navigator.vendor),$browser_language:Gr(),$browser_language_prefix:(t=Gr(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:d==null?void 0:d.screen.height,$screen_width:d==null?void 0:d.screen.width,$viewport_height:d==null?void 0:d.innerHeight,$viewport_width:d==null?void 0:d.innerWidth,$lib:"web",$lib_version:ge.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var $e=D("[Web Vitals]"),Wr=9e5;class ro{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce(((i,s)=>b({},i,{["$web_vitals_"+s.name+"_event"]:b({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=i=>{var s,n=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(_(n))$e.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var a=this.Ct();_(a)||(F(i==null?void 0:i.name)||F(i==null?void 0:i.value)?$e.error("Invalid metric received",i):this.Rt&&i.value>=this.Rt?$e.error("Ignoring metric with value >= "+this.Rt,i):(this.N.url!==a&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),_(this.N.url)&&(this.N.url=a),this.N.firstMetricTimestamp=_(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,i.attribution&&i.attribution.interactionTargetElement&&(i.attribution.interactionTargetElement=void 0),this.N.metrics.push(b({},i,{$current_url:a,$session_id:n.sessionId,$window_id:n.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var i,s,n,a,o=x.__PosthogExtensions__;_(o)||_(o.postHogWebVitalsCallbacks)||({onLCP:i,onCLS:s,onFCP:n,onINP:a}=o.postHogWebVitalsCallbacks),i&&s&&n&&a?(this.allowedMetrics.indexOf("LCP")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&n(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&a(this.It.bind(this)),this.P=!0):$e.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[Or]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=q(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return _(i)?((t=this._instance.persistence)==null?void 0:t.props[Cr])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(q(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get Rt(){var e=q(this._instance.config.capture_performance)&&Ee(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Wr;return 0{s?$e.error("failed to load script",s):e()}))}Ct(){var e=d?d.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,i=this._instance.config.custom_personal_data_properties,s=t?st([],nt,i||[]):[];return Tt(e,s,Ct)}$e.error("Could not determine current URL")}}var so=D("[Heatmaps]");function zr(r){return q(r)&&"clientX"in r&&"clientY"in r&&Ee(r.clientX)&&Ee(r.clientY)}class no{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!((t=this.instance.persistence)==null||!t.props[Di]),this.rageclicks=new rn(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return q(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return _(this.instance.config.capture_heatmaps)?_(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;so.info("starting..."),this.Mt(),this.Ot()}else{var e;clearInterval((e=this.Ft)!==null&&e!==void 0?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Di]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}Dt(e){this.jt(e.originalEvent,"deadclick")}Ot(){this.Ft&&clearInterval(this.Ft),this.Ft=(function(e){return(e==null?void 0:e.visibilityState)==="visible"})(m)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Mt(){d&&m&&(this.Nt=this.Lt.bind(this),N(d,"beforeunload",this.Nt),this.Ut=e=>this.jt(e||(d==null?void 0:d.event)),N(m,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||(d==null?void 0:d.event)),N(m,"mousemove",this.zt,{capture:!0}),this.Bt=new nn(this.instance,Ba,this.Dt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Ot.bind(this),N(m,"visibilitychange",this.qt),this.P=!0)}At(){var e;d&&m&&(this.Nt&&d.removeEventListener("beforeunload",this.Nt),this.Ut&&m.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&m.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&m.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(e=this.Bt)==null||e.stop(),this.P=!1)}Gt(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=(function(o,l,u){for(var c=o;c&&si(c)&&!Ce(c,"body");){if(c===u)return!1;if(S(l,d==null?void 0:d.getComputedStyle(c).position))return!0;c=Js(c)}return!1})(zs(e),["fixed","sticky"],n);return{x:e.clientX+(a?0:s),y:e.clientY+(a?0:i),target_fixed:a,type:t}}jt(e,t){var i;if(t===void 0&&(t="click"),!Mr(e.target)&&zr(e)){var s=this.Gt(e,t);(i=this.rageclicks)!=null&&i.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(b({},s,{type:"rageclick"})),this.Vt(s)}}Ht(e){!Mr(e.target)&&zr(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout((()=>{this.Vt(this.Gt(e,"mousemove"))}),500))}Vt(e){if(d){var t=d.location.href,i=this.instance.config.mask_personal_data_properties,s=this.instance.config.custom_personal_data_properties,n=i?st([],nt,s||[]):[],a=Tt(t,n,Ct);this.N=this.N||{},this.N[a]||(this.N[a]=[]),this.N[a].push(e)}}Lt(){this.N&&!Xe(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Yr{constructor(e){this.Jt=(t,i,s)=>{s&&(s.noSessionId||s.activityTimeout||s.sessionPastMaximumLength)&&(y.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:s}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Jt)}destroy(){var e;(e=this.Xt)==null||e.call(this),this.Xt=void 0}doPageView(e,t){var i,s=this.Qt(e,t);return this.Kt={pathname:(i=d==null?void 0:d.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this.Qt(e,(t=this.Kt)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Kt)==null?void 0:e.pageViewId}}Qt(e,t){var i=this.Kt;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:l,maxContentHeight:u,lastContentY:c,maxContentY:h}=n;if(!(_(a)||_(o)||_(l)||_(u)||_(c)||_(h))){a=Math.ceil(a),o=Math.ceil(o),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),h=Math.ceil(h);var p=a<=1?1:de(o/a,0,1,y),f=a<=1?1:de(l/a,0,1,y),v=u<=1?1:de(c/u,0,1,y),g=u<=1?1:de(h/u,0,1,y);s=L(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:p,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:v,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:g})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}}var ye=(function(r){return r.GZipJS="gzip-js",r.Base64="base64",r})({}),re=Uint8Array,Y=Uint16Array,rt=Uint32Array,or=new re([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]),lr=new re([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]),Jr=new re([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),vn=function(r,e){for(var t=new Y(31),i=0;i<31;++i)t[i]=e+=1<>>1|(21845&M)<<1;De=(61680&(De=(52428&De)>>>2|(13107&De)<<2))>>>4|(3855&De)<<4,_n[M]=((65280&De)>>>8|(255&De)<<8)>>>1}var kt=function(r,e,t){for(var i=r.length,s=0,n=new Y(e);s>>15-r[s];return a},qe=new re(288);for(M=0;M<144;++M)qe[M]=8;for(M=144;M<256;++M)qe[M]=9;for(M=256;M<280;++M)qe[M]=7;for(M=280;M<288;++M)qe[M]=8;var Qt=new re(32);for(M=0;M<32;++M)Qt[M]=5;var oo=kt(qe,9),lo=kt(Qt,5),mn=function(r){return(r/8>>0)+(7&r&&1)},yn=function(r,e,t){(t==null||t>r.length)&&(t=r.length);var i=new(r instanceof Y?Y:r instanceof rt?rt:re)(t-e);return i.set(r.subarray(e,t)),i},fe=function(r,e,t){t<<=7&e;var i=e/8>>0;r[i]|=t,r[i+1]|=t>>>8},ut=function(r,e,t){t<<=7&e;var i=e/8>>0;r[i]|=t,r[i+1]|=t>>>8,r[i+2]|=t>>>16},gi=function(r,e){for(var t=[],i=0;ip&&(p=n[i].s);var f=new Y(p+1),v=Wi(t[c-1],f,0);if(v>e){i=0;var g=0,w=v-e,E=1<e))break;g+=E-(1<>>=w;g>0;){var I=n[i].s;f[I]=0&&g;--i){var P=n[i].s;f[P]==e&&(--f[P],++g)}v=e}return[new re(f),v]},Wi=function(r,e,t){return r.s==-1?Math.max(Wi(r.l,e,t+1),Wi(r.r,e,t+1)):e[r.s]=t},Xr=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new Y(++e),i=0,s=r[0],n=1,a=function(l){t[i++]=l},o=1;o<=e;++o)if(r[o]==s&&o!=e)++n;else{if(!s&&n>2){for(;n>138;n-=138)a(32754);n>2&&(a(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(a(s),--n;n>6;n-=6)a(8304);n>2&&(a(n-3<<5|8208),n=0)}for(;n--;)a(s);n=1,s=r[o]}return[t.subarray(0,i),e]},ct=function(r,e){for(var t=0,i=0;i>>8,r[s+2]=255^r[s],r[s+3]=255^r[s+1];for(var n=0;n4&&!K[Jr[Q-1]];--Q);var pe,le,ue,je,xe=u+5<<3,Me=ct(s,qe)+ct(n,Qt)+a,ce=ct(s,p)+ct(n,g)+a+14+3*Q+ct(J,K)+(2*J[16]+3*J[17]+7*J[18]);if(xe<=Me&&xe<=ce)return zi(e,c,r.subarray(l,l+u));if(fe(e,c,1+(ce15&&(fe(e,c,ee[$]>>>5&127),c+=ee[$]>>>12)}}}else pe=oo,le=qe,ue=lo,je=Qt;for($=0;$255){X=i[$]>>>18&31,ut(e,c,pe[X+257]),c+=le[X+257],X>7&&(fe(e,c,i[$]>>>23&31),c+=or[X]);var Be=31&i[$];ut(e,c,ue[Be]),c+=je[Be],Be>3&&(ut(e,c,i[$]>>>5&8191),c+=lr[Be])}else ut(e,c,pe[i[$]]),c+=le[i[$]];return ut(e,c,pe[256]),c+le[256]},uo=new rt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),co=(function(){for(var r=new rt(256),e=0;e<256;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;r[e]=t}return r})(),ho=function(r,e,t,i,s){return(function(n,a,o,l,u,c){var h=n.length,p=new re(l+h+5*(1+Math.floor(h/7e3))+u),f=p.subarray(l,p.length-u),v=0;if(!a||h<8)for(var g=0;g<=h;g+=65535){var w=g+65535;w>>13,I=8191&E,P=(1<7e3||ue>24576)&&Ue>423){v=Zr(n,f,0,K,ne,Q,le,ue,xe,g-xe,v),ue=pe=le=0,xe=g;for(var V=0;V<286;++V)ne[V]=0;for(V=0;V<30;++V)Q[V]=0}var ee=2,X=0,Be=I,Se=ce-ke&32767;if(Ue>2&&Me==oe(g-Se))for(var Pn=Math.min(k,Ue)-1,$n=Math.min(32767,g),In=Math.min(258,Ue);Se<=$n&&--Be&&ce!=ke;){if(n[g+ee]==n[g+ee-Se]){for(var Pe=0;Peee){if(ee=Pe,X=Se,Pe>Pn)break;var Fn=Math.min(Se,Pe-2),hr=0;for(V=0;Vhr&&(hr=dr,ke=ai)}}}Se+=(ce=ke)-(ke=C[ce])+32768&32767}if(X){K[ue++]=268435456|Gi[ee]<<18|Kr[X];var pr=31&Gi[ee],fr=31&Kr[X];le+=or[pr]+lr[fr],++ne[257+pr],++Q[fr],je=g+ee,++pe}else K[ue++]=n[g],++ne[n[g]]}}v=Zr(n,f,c,K,ne,Q,le,ue,xe,g-xe,v)}return yn(p,0,l+mn(v)+u)})(r,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+e.mem,t,i,!0)},_i=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8};function po(r,e){e===void 0&&(e={});var t=(function(){var o=4294967295;return{p:function(l){for(var u=o,c=0;c>>8;o=u},d:function(){return 4294967295^o}}})(),i=r.length;t.p(r);var s,n=ho(r,e,10+((s=e).filename&&s.filename.length+1||0),8),a=n.length;return(function(o,l){var u=l.filename;if(o[0]=31,o[1]=139,o[2]=8,o[8]=l.level<2?4:l.level==9?2:0,o[9]=3,l.mtime!=0&&_i(o,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),u){o[3]=8;for(var c=0;c<=u.length;++c)o[c+10]=u.charCodeAt(c)}})(n,e),_i(n,a-8,t.d()),_i(n,a-4,i),n}var fo=function(r){var e,t,i,s,n="";for(e=t=0,i=(r=(r+"").replace(/\r\n/g,` `).replace(/\r/g,` `)).length,s=0;s127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),ae(o)||(t>e&&(n+=r.substring(e,t)),n+=o,e=t=s+1)}return t>e&&(n+=r.substring(e,r.length)),n},vo=!!Ii||!!$i,Qr="text/plain",ei=function(r,e,t){var i;t===void 0&&(t=!0);var[s,n]=r.split("?"),a=b({},e),o=(i=n==null?void 0:n.split("&").map((u=>{var c,[h,p]=u.split("="),f=t&&(c=a[h])!==null&&c!==void 0?c:p;return delete a[h],h+"="+f})))!==null&&i!==void 0?i:[],l=Ra(a);return l&&o.push(l),s+"?"+o.join("&")},bt=(r,e)=>JSON.stringify(r,((t,i)=>typeof i=="bigint"?i.toString():i),e),mi=r=>{var{data:e,compression:t}=r;if(e){if(t===ye.GZipJS){var i=po((function(l,u){var c=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var h=new re(l.length+(l.length>>>1)),p=0,f=function(E){h[p++]=E},v=0;vh.length){var g=new re(p+8+(c-v<<1));g.set(h),h=g}var w=l.charCodeAt(v);w<128||u?f(w):w<2048?(f(192|w>>>6),f(128|63&w)):w>55295&&w<57344?(f(240|(w=65536+(1047552&w)|1023&l.charCodeAt(++v))>>>18),f(128|w>>>12&63),f(128|w>>>6&63),f(128|63&w)):(f(224|w>>>12),f(128|w>>>6&63),f(128|63&w))}return yn(h,0,p)})(bt(e)),{mtime:0}),s=new Blob([i],{type:Qr});return{contentType:Qr,body:s,estimatedSize:s.size}}if(t===ye.Base64){var n=(function(l){var u,c,h,p,f,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g=0,w=0,E="",k=[];if(!l)return l;l=fo(l);do u=(f=l.charCodeAt(g++)<<16|l.charCodeAt(g++)<<8|l.charCodeAt(g++))>>18&63,c=f>>12&63,h=f>>6&63,p=63&f,k[w++]=v.charAt(u)+v.charAt(c)+v.charAt(h)+v.charAt(p);while(g"data="+encodeURIComponent(typeof l=="string"?l:bt(l)))(n);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var o=bt(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},qt=[];$i&&qt.push({transport:"fetch",method:r=>{var e,t,{contentType:i,body:s,estimatedSize:n}=(e=mi(r))!==null&&e!==void 0?e:{},a=new Headers;T(r.headers,(function(c,h){a.append(h,c)})),i&&a.append("Content-Type",i);var o=r.url,l=null;if(_r){var u=new _r;l={signal:u.signal,timeout:setTimeout((()=>u.abort()),r.timeout)}}$i(o,b({method:(r==null?void 0:r.method)||"GET",headers:a,keepalive:r.method==="POST"&&(n||0)<52428.8,body:s,signal:(t=l)==null?void 0:t.signal},r.fetchOptions)).then((c=>c.text().then((h=>{var p={statusCode:c.status,text:h};if(c.status===200)try{p.json=JSON.parse(h)}catch(f){y.error(f)}r.callback==null||r.callback(p)})))).catch((c=>{y.error(c),r.callback==null||r.callback({statusCode:0,text:c})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Ii&&qt.push({transport:"XHR",method:r=>{var e,t=new Ii;t.open(r.method||"GET",r.url,!0);var{contentType:i,body:s}=(e=mi(r))!==null&&e!==void 0?e:{};T(r.headers,(function(n,a){t.setRequestHeader(a,n)})),i&&t.setRequestHeader("Content-Type",i),r.timeout&&(t.timeout=r.timeout),r.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}r.callback==null||r.callback(n)}},t.send(s)}}),Z!=null&&Z.sendBeacon&&qt.push({transport:"sendBeacon",method:r=>{var e=ei(r.url,{beacon:"1"});try{var t,{contentType:i,body:s}=(t=mi(r))!==null&&t!==void 0?t:{},n=typeof s=="string"?new Blob([s],{type:i}):s;Z.sendBeacon(e,n)}catch{}}});var ti=function(r,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(r)}catch{return!1}};function es(r,e,t){return bt({distinct_id:r,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var bn={exact:(r,e)=>e.some((t=>r.some((i=>t===i)))),is_not:(r,e)=>e.every((t=>r.every((i=>t!==i)))),regex:(r,e)=>e.some((t=>r.some((i=>ti(t,i))))),not_regex:(r,e)=>e.every((t=>r.every((i=>!ti(t,i))))),icontains:(r,e)=>e.map(Nt).some((t=>r.map(Nt).some((i=>t.includes(i))))),not_icontains:(r,e)=>e.map(Nt).every((t=>r.map(Nt).every((i=>!t.includes(i))))),gt:(r,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&r.some((s=>i>parseFloat(s)))})),lt:(r,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&r.some((s=>ir.toLowerCase();function wn(r,e){return!r||Object.entries(r).every((t=>{var[i,s]=t,n=e==null?void 0:e[i];if(_(n)||ae(n))return!1;var a=[String(n)],o=bn[s.operator];return!!o&&o(s.values,a)}))}var yi=D("[Error tracking]");class go{constructor(e){var t,i;this.Zt=[],this.ti=new Kn([new na,new fa,new oa,new aa,new da,new ha,new ua,new pa],sa()),this._instance=e,this.Zt=(t=(i=this._instance.persistence)==null?void 0:i.get_property(Li))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,i,s,n=(t=(i=e.errorTracking)==null?void 0:i.suppressionRules)!==null&&t!==void 0?t:[],a=(s=e.errorTracking)==null?void 0:s.captureExtensionExceptions;this.Zt=n,this._instance.persistence&&this._instance.persistence.register({[Li]:this.Zt,[Rr]:a})}get ii(){var e,t=!!this._instance.get_property(Rr),i=this._instance.config.error_tracking.captureExtensionExceptions;return(e=i??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t==null?void 0:t.syntheticException,mechanism:{handled:t==null?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void yi.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void yi.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void yi.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(e.length===0)return!1;var t=e.reduce(((i,s)=>{var{type:n,value:a}=s;return H(n)&&n.length>0&&i.$exception_types.push(n),H(a)&&a.length>0&&i.$exception_values.push(a),i}),{$exception_types:[],$exception_values:[]});return this.Zt.some((i=>{var s=i.values.map((n=>{var a,o=bn[n.operator],l=R(n.value)?n.value:[n.value],u=(a=t[n.key])!==null&&a!==void 0?a:[];return l.length>0&&o(l,u)}));return i.type==="OR"?s.some(Boolean):s.every(Boolean)}))}si(e){return e.flatMap((t=>{var i,s;return(i=(s=t.stacktrace)==null?void 0:s.frames)!==null&&i!==void 0?i:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ni(e){if(e.length>0){var t,i,s,n,a=(t=(i=e[0].stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[],o=a[a.length-1];return(s=o==null||(n=o.filename)==null?void 0:n.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}ei(e){return!F(e)&&R(e)}}var te=D("[FeatureFlags]"),ht=D("[FeatureFlags]",{debugEnabled:!0}),bi="$active_feature_flags",Ve="$override_feature_flags",ts="$feature_flag_payloads",dt="$override_feature_flag_payloads",is="$feature_flag_request_id",rs="$feature_flag_evaluated_at",ss=r=>{var e={};for(var[t,i]of Ht(r||{}))i&&(e[t]=i);return e},_o=r=>{var e=r.flags;return e?(r.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,(i=e[t].variant)!==null&&i!==void 0?i:e[t].enabled]}))),r.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]})))):te.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),r},mo=(function(r){return r.FeatureFlags="feature_flags",r.Recordings="recordings",r})({});class yo{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(te.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter((i=>{var s=i&&typeof i=="string"&&i.trim().length>0;return s||te.error("Invalid evaluation context found:",i,"Expected non-empty string"),s})):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Ni),t=this._instance.get_property(Ve),i=this._instance.get_property(dt);if(!i&&!t)return e||{};var s=L({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var a of n){var o,l,u=s[a],c=t==null?void 0:t[a],h=_(c)?(o=u==null?void 0:u.enabled)!==null&&o!==void 0&&o:!!c,p=_(c)?u.variant:typeof c=="string"?c:void 0,f=i==null?void 0:i[a],v=b({},u,{enabled:h,variant:h?p??(u==null?void 0:u.variant):void 0});h!==(u==null?void 0:u.enabled)&&(v.original_enabled=u==null?void 0:u.enabled),p!==(u==null?void 0:u.variant)&&(v.original_variant=u==null?void 0:u.variant),f&&(v.metadata=b({},u==null?void 0:u.metadata,{payload:f,original_payload:u==null||(l=u.metadata)==null?void 0:l.payload})),s[a]=v}return this.oi||(te.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this.oi=!0),s}getFlagVariants(){var e=this._instance.get_property(Ze),t=this._instance.get_property(Ve);if(!t)return e||{};for(var i=L({},e),s=Object.keys(t),n=0;n{this.mi()}),5))}yi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.yi(),!this._instance.O())if(this.li)this.hi=!0;else{var i=this._instance.config.token,s=this._instance.get_property("$device_id"),n={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:b({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(yt)||{}),group_properties:this._instance.get_property(Ne)};ae(s)||_(s)||(n.$device_id=s),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.pi()&&(n.evaluation_contexts=this.fi());var a=this._instance.config.__preview_remote_config,o=a?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",u=this._instance.requestRouter.endpointFor("flags",o+l);a&&(n.timezone=fn()),this.li=!0,this._instance._send_request({method:"POST",url:u,data:n,compression:this._instance.config.disable_compression?void 0:ye.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:c=>{var h,p,f=!0;if(c.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),f=!1),this.li=!1,this.di||(this.di=!0,this._instance.bi((p=c.json)!==null&&p!==void 0?p:{})),!n.disable_flags||this.hi)if(this.vi=!f,c.json&&(h=c.json.quotaLimited)!=null&&h.includes(mo.FeatureFlags))te.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;n.disable_flags||this.receivedFeatureFlags((v=c.json)!==null&&v!==void 0?v:{},f),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants()[e],s=""+i,n=this._instance.get_property(is)||void 0,a=this._instance.get_property(rs)||void 0,o=this._instance.get_property(Gt)||{};if((t.send_event||!("send_event"in t))&&(!(e in o)||!o[e].includes(s))){var l,u,c,h,p,f,v,g,w;R(o[e])?o[e].push(s):o[e]=[s],(l=this._instance.persistence)==null||l.register({[Gt]:o});var E=this.getFeatureFlagDetails(e),k={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:n,$feature_flag_evaluated_at:a,$feature_flag_bootstrapped_response:((u=this._instance.config.bootstrap)==null||(u=u.featureFlags)==null?void 0:u[e])||null,$feature_flag_bootstrapped_payload:((c=this._instance.config.bootstrap)==null||(c=c.featureFlagPayloads)==null?void 0:c[e])||null,$used_bootstrap_value:!this.vi};_(E==null||(h=E.metadata)==null?void 0:h.version)||(k.$feature_flag_version=E.metadata.version);var I,P=(p=E==null||(f=E.reason)==null?void 0:f.description)!==null&&p!==void 0?p:E==null||(v=E.reason)==null?void 0:v.code;P&&(k.$feature_flag_reason=P),E!=null&&(g=E.metadata)!=null&&g.id&&(k.$feature_flag_id=E.metadata.id),_(E==null?void 0:E.original_variant)&&_(E==null?void 0:E.original_enabled)||(k.$feature_flag_original_response=_(E.original_variant)?E.original_enabled:E.original_variant),E!=null&&(w=E.metadata)!=null&&w.original_payload&&(k.$feature_flag_original_payload=E==null||(I=E.metadata)==null?void 0:I.original_payload),this._instance.capture("$feature_flag_called",k)}return i}te.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var i=this._instance.config.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this.pi()&&(s.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:s,compression:this._instance.config.disable_compression?void 0:ye.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:n=>{var a,o=(a=n.json)==null?void 0:a.featureFlagPayloads;t((o==null?void 0:o[e])||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return _(i)?void 0:!!i}te.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var i=this.getFlagVariants(),s=this.getFlagPayloads(),n=this.getFlagsWithDetails();(function(a,o,l,u,c){l===void 0&&(l={}),u===void 0&&(u={}),c===void 0&&(c={});var h=_o(a),p=h.flags,f=h.featureFlags,v=h.featureFlagPayloads;if(f){var g=a.requestId,w=a.evaluatedAt;if(R(f)){te.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var E={};if(f)for(var k=0;kthis.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s,n=(this._instance.get_property(mt)||[]).find((u=>u.flagKey===e)),a={["$feature_enrollment/"+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};n&&(o.$early_access_feature_name=n.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=b({},this.getFlagVariants(),{[e]:t});(s=this._instance.persistence)==null||s.register({[bi]:Object.keys(ss(l)),[Ze]:l}),this.wi()}getEarlyAccessFeatures(e,t,i){t===void 0&&(t=!1);var s=this._instance.get_property(mt),n=i?"&"+i.map((a=>"stage="+a)).join("&"):"";if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+n),method:"GET",callback:a=>{var o,l;if(a.json){var u=a.json.earlyAccessFeatures;return(o=this._instance.persistence)==null||o.unregister(mt),(l=this._instance.persistence)==null||l.register({[mt]:u}),e(u)}}})}xi(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((i=>t[i])),flagVariants:Object.keys(t).filter((i=>t[i])).reduce(((i,s)=>(i[s]=t[s],i)),{})}}wi(e){var{flags:t,flagVariants:i}=this.xi();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(yt)||{};this._instance.register({[yt]:b({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(yt)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(Ne)||{};Object.keys(i).length!==0&&Object.keys(i).forEach((s=>{i[s]=b({},i[s],e[s]),delete e[s]})),this._instance.register({[Ne]:b({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Ne)||{};this._instance.register({[Ne]:b({},t,{[e]:{}})})}else this._instance.unregister(Ne)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.yi(),this.oi=!1}}var bo=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class wi{constructor(e,t){this.R=e,this.props={},this.Ei=!1,this.$i=(i=>{var s="";return i.token&&(s=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+s+"_posthog"})(e),this.Y=this.Si(e),this.load(),e.debug&&y.info("Persistence loaded",e.persistence,b({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){bo.indexOf(e.persistence.toLowerCase())===-1&&(y.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(s){s===void 0&&(s=[]);var n=[...qa,...s];return b({},A,{W:function(a){try{var o={};try{o=he.W(a)||{}}catch{}var l=L(o,JSON.parse(A.q(a)||"{}"));return A.G(a,l),l}catch{}return null},G:function(a,o,l,u,c,h){try{A.G(a,o,void 0,void 0,h);var p={};n.forEach((f=>{o[f]&&(p[f]=o[f])})),Object.keys(p).length&&he.G(a,p,l,u,c,h)}catch(f){A.B(f)}},V:function(a,o){try{d==null||d.localStorage.removeItem(a),he.V(a,o)}catch(l){A.B(l)}}})})(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return i==="localstorage"&&A.H()?A:i==="localstorage+cookie"&&t.H()?t:i==="sessionstorage"&&j.H()?j:i==="memory"?ja:i==="cookie"?he:t.H()?t:he}properties(){var e={};return T(this.props,(function(t,i){if(i===Ze&&q(t))for(var s=Object.keys(t),n=0;n{this.props.hasOwnProperty(a)&&this.props[a]!==t||(this.props[a]=n,s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(q(e)){this.Pi=_(t)?this.Ci:t;var i=!1;if(T(e,((s,n)=>{e.hasOwnProperty(n)&&this.props[n]!==s&&(this.props[n]=s,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Ei){var e=ln(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);Xe(rr(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=m==null?void 0:m.referrer)?cn(e):{})}update_referrer_info(){var e;this.register_once({$referrer:hn(),$referring_domain:m!=null&&m.referrer&&((e=Jt(m.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Ui]||this.props[Bi]||this.register_once({[Wt]:dn(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};T([Bi,Ui],(a=>{var o=this.props[a];o&&T(o,(function(l,u){e["$initial_"+Fi(u)]=l}))}));var t,i,s=this.props[Wt];if(s){var n=(t=pn(s),i={},T(t,(function(a,o){i["$initial_"+Fi(o)]=a})),i);L(e,n)}return e}safe_merge(e){return T(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this.Ci=this.Pi=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||!((a,o)=>{if(a.length!==o.length)return!1;var l=[...a].sort(),u=[...o].sort();return l.every(((c,h)=>c===u[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var s=this.Si(e),n=this.props;this.clear(),this.Y=s,this.props=n,this.save()}}set_disabled(e){this.ki=e,this.ki?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ti&&(this.Ti=e,this.remove(),this.save())}set_secure(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[_t]||{};i[e]=t,this.props[_t]=i,this.save()}remove_event_timer(e){var t=(this.props[_t]||{})[e];return _(t)||(delete this.props[_t][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var ns=D("[Product Tours]"),Ei="ph_product_tours";class wo{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Tr]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Ri||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Tr)||this.it((()=>this.Mi()))}it(e){var t,i;(t=x.__PosthogExtensions__)!=null&&t.generateProductTours?e():(i=x.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"product-tours",(s=>{s?ns.error("Could not load product tours script",s):e()}))}Mi(){var e;!this.Ri&&(e=x.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=x.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!R(this.Fi)||t){var i=this._instance.persistence;if(i){var s=i.props[Ei];if(R(s)&&!t)return this.Fi=s,void e(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:n=>{var a=n.statusCode;if(a!==200||!n.json){var o="Product Tours API could not be loaded, status: "+a;return ns.error(o),void e([],{isLoaded:!1,error:o})}var l=R(n.json.product_tours)?n.json.product_tours:[];this.Fi=l,i&&i.register({[Ei]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){F(this.Ri)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ri.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ri)==null||t.showTourById(e)}previewTour(e){this.Ri?this.Ri.previewTour(e):this.it((()=>{var t;this.Mi(),(t=this.Ri)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Ri)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Ri)==null||e.nextStep()}previousStep(){var e;(e=this.Ri)==null||e.previousStep()}clearCache(){var e;this.Fi=null,(e=this._instance.persistence)==null||e.unregister(Ei)}resetTour(e){var t;(t=this.Ri)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ri)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ri)==null||t.cancelPendingTour(e)}}var pt=(function(r){return r.Activation="events",r.Cancellation="cancelEvents",r})({});(function(r){return r.Button="button",r.Tab="tab",r.Selector="selector",r})({});(function(r){return r.TopLeft="top_left",r.TopRight="top_right",r.TopCenter="top_center",r.MiddleLeft="middle_left",r.MiddleRight="middle_right",r.MiddleCenter="middle_center",r.Left="left",r.Center="center",r.Right="right",r.NextToTrigger="next_to_trigger",r})({});(function(r){return r.Top="top",r.Left="left",r.Right="right",r.Bottom="bottom",r})({});var xi=(function(r){return r.Popover="popover",r.API="api",r.Widget="widget",r.ExternalSurvey="external_survey",r})({});(function(r){return r.Open="open",r.MultipleChoice="multiple_choice",r.SingleChoice="single_choice",r.Rating="rating",r.Link="link",r})({});(function(r){return r.NextQuestion="next_question",r.End="end",r.ResponseBased="response_based",r.SpecificQuestion="specific_question",r})({});(function(r){return r.Once="once",r.Recurring="recurring",r.Always="always",r})({});var wt=(function(r){return r.SHOWN="survey shown",r.DISMISSED="survey dismissed",r.SENT="survey sent",r.ABANDONED="survey abandoned",r})({}),ki=(function(r){return r.SURVEY_ID="$survey_id",r.SURVEY_NAME="$survey_name",r.SURVEY_RESPONSE="$survey_response",r.SURVEY_ITERATION="$survey_iteration",r.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",r.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",r.SURVEY_SUBMISSION_ID="$survey_submission_id",r.SURVEY_QUESTIONS="$survey_questions",r.SURVEY_COMPLETED="$survey_completed",r.PRODUCT_TOUR_ID="$product_tour_id",r.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",r})({}),Yi=(function(r){return r.Popover="popover",r.Inline="inline",r})({}),O=D("[Surveys]"),En="seenSurvey_",Eo=(r,e)=>{var t="$survey_"+e+"/"+r.id;return r.current_iteration&&r.current_iteration>0&&(t="$survey_"+e+"/"+r.id+"/"+r.current_iteration),t},as=r=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(En,r),xo=[xi.Popover,xi.Widget,xi.API],ko={ignoreConditions:!1,ignoreDelay:!1,displayType:Yi.Popover};class ur{constructor(){this.Oi={},this.Oi={}}on(e,t){return this.Oi[e]||(this.Oi[e]=[]),this.Oi[e].push(t),()=>{this.Oi[e]=this.Oi[e].filter((i=>i!==t))}}emit(e,t){for(var i of this.Oi[e]||[])i(t);for(var s of this.Oi["*"]||[])s(e,t)}}function Ge(r,e,t){if(F(r))return!1;switch(t){case"exact":return r===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(r);case"regex":try{return new RegExp(e).test(r)}catch{return!1}default:return!1}}class So{constructor(e){this.Ai=new ur,this.Di=(t,i)=>this.ji(t,i)&&this.Li(t,i)&&this.Ni(t,i)&&this.Ui(t,i),this.ji=(t,i)=>i==null||!i.event||(t==null?void 0:t.event)===(i==null?void 0:i.event),this._instance=e,this.zi=new Set,this.Hi=new Set}init(){var e;if(!_((e=this._instance)==null?void 0:e.Bi)){var t;(t=this._instance)==null||t.Bi(((i,s)=>{this.on(i,s)}))}}register(e){var t,i;if(!_((t=this._instance)==null?void 0:t.Bi)&&(e.forEach((a=>{var o,l;(o=this.Hi)==null||o.add(a),(l=a.steps)==null||l.forEach((u=>{var c;(c=this.zi)==null||c.add((u==null?void 0:u.event)||"")}))})),(i=this._instance)!=null&&i.autocapture)){var s,n=new Set;e.forEach((a=>{var o;(o=a.steps)==null||o.forEach((l=>{l!=null&&l.selector&&n.add(l==null?void 0:l.selector)}))})),(s=this._instance)==null||s.autocapture.setElementSelectors(n)}}on(e,t){var i;t!=null&&e.length!=0&&(this.zi.has(e)||this.zi.has(t==null?void 0:t.event))&&this.Hi&&((i=this.Hi)==null?void 0:i.size)>0&&this.Hi.forEach((s=>{this.qi(t,s)&&this.Ai.emit("actionCaptured",s.name)}))}Wi(e){this.onAction("actionCaptured",(t=>e(t)))}qi(e,t){if((t==null?void 0:t.steps)==null)return!1;for(var i of t.steps)if(this.Di(e,i))return!0;return!1}onAction(e,t){return this.Ai.on(e,t)}Li(e,t){if(t!=null&&t.url){var i,s=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!s||typeof s!="string"||!Ge(s,t.url,t.url_matching||"contains"))return!1}return!0}Ni(e,t){return!!this.Gi(e,t)&&!!this.Vi(e,t)&&!!this.Ji(e,t)}Gi(e,t){var i;if(t==null||!t.href)return!0;var s=this.Ki(e);if(s.length>0)return s.some((o=>Ge(o.href,t.href,t.href_matching||"exact")));var n,a=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!a&&Ge((n=a.match(/(?::|")href="proxy.php?url=https%3A%2F%2Fbejamas.com%2F%28.%2A%3F%29"/))?n[1]:"",t.href,t.href_matching||"exact")}Vi(e,t){var i;if(t==null||!t.text)return!0;var s=this.Ki(e);if(s.length>0)return s.some((u=>Ge(u.text,t.text,t.text_matching||"exact")||Ge(u.$el_text,t.text,t.text_matching||"exact")));var n,a,o,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(n=(function(u){for(var c,h=[],p=/(?::|")text="(.*?)"/g;!F(c=p.exec(u));)h.includes(c[1])||h.push(c[1]);return h})(l),a=t.text,o=t.text_matching||"exact",n.some((u=>Ge(u,a,o))))}Ji(e,t){var i,s;if(t==null||!t.selector)return!0;var n=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var a=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}Ki(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e==null?void 0:e.properties.$elements}Ui(e,t){return t==null||!t.properties||t.properties.length===0||wn(t.properties.reduce(((i,s)=>{var n=R(s.value)?s.value.map(String):s.value!=null?[String(s.value)]:[];return i[s.key]={values:n,operator:s.operator||"exact"},i}),{}),e==null?void 0:e.properties)}}class Po{constructor(e){this._instance=e,this.Yi=new Map,this.Xi=new Map,this.Qi=new Map}Zi(e,t){return!!e&&wn(e.propertyFilters,t==null?void 0:t.properties)}te(e,t){var i=new Map;return e.forEach((s=>{var n;(n=s.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((a=>{if(a!=null&&a.name){var o=i.get(a.name)||[];o.push(s.id),i.set(a.name,o)}}))})),i}ie(e,t,i){var s=(i===pt.Activation?this.Yi:this.Xi).get(e),n=[];return this.ee((a=>{n=a.filter((o=>s==null?void 0:s.includes(o.id)))})),n.filter((a=>{var o,l=(o=a.conditions)==null||(o=o[i])==null||(o=o.values)==null?void 0:o.find((u=>u.name===e));return this.Zi(l,t)}))}register(e){var t;_((t=this._instance)==null?void 0:t.Bi)||(this.re(e),this.se(e))}se(e){var t=e.filter((i=>{var s,n;return((s=i.conditions)==null?void 0:s.actions)&&((n=i.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.ne==null&&(this.ne=new So(this._instance),this.ne.init(),this.ne.Wi((i=>{this.onAction(i)}))),t.forEach((i=>{var s,n,a,o,l;i.conditions&&(s=i.conditions)!=null&&s.actions&&(n=i.conditions)!=null&&(n=n.actions)!=null&&n.values&&((a=i.conditions)==null||(a=a.actions)==null||(a=a.values)==null?void 0:a.length)>0&&((o=this.ne)==null||o.register(i.conditions.actions.values),(l=i.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((u=>{if(u&&u.name){var c=this.Qi.get(u.name);c&&c.push(i.id),this.Qi.set(u.name,c||[i.id])}})))})))}re(e){var t,i=e.filter((n=>{var a,o;return((a=n.conditions)==null?void 0:a.events)&&((o=n.conditions)==null||(o=o.events)==null||(o=o.values)==null?void 0:o.length)>0})),s=e.filter((n=>{var a,o;return((a=n.conditions)==null?void 0:a.cancelEvents)&&((o=n.conditions)==null||(o=o.cancelEvents)==null||(o=o.values)==null?void 0:o.length)>0}));(i.length!==0||s.length!==0)&&((t=this._instance)==null||t.Bi(((n,a)=>{this.onEvent(n,a)})),this.Yi=this.te(e,pt.Activation),this.Xi=this.te(e,pt.Cancellation))}onEvent(e,t){var i,s=this.oe(),n=this.ae(),a=this.le(),o=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[n])||[];if(a===e&&t&&o.length>0){var l,u;s.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:o});var c=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(u=t.properties)==null?void 0:u.$product_tour_id);if(c){var h=o.indexOf(c);h>=0&&(o.splice(h,1),this.ue(o))}}else{if(this.Xi.has(e)){var p=this.ie(e,t,pt.Cancellation);p.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:p.map((v=>v.id))}),p.forEach((v=>{var g=o.indexOf(v.id);g>=0&&o.splice(g,1),this.he(v.id)})),this.ue(o))}if(this.Yi.has(e)){s.info("event name matched",{event:e,eventPayload:t,items:this.Yi.get(e)});var f=this.ie(e,t,pt.Activation);this.ue(o.concat(f.map((v=>v.id))||[]))}}}onAction(e){var t,i=this.ae(),s=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[i])||[];this.Qi.has(e)&&this.ue(s.concat(this.Qi.get(e)||[]))}ue(e){var t,i=this.oe(),s=this.ae(),n=[...new Set(e)].filter((a=>!this.de(a)));i.info("updating activated items",{activatedItems:n}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[s]:n})}getActivatedIds(){var e,t=this.ae(),i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return i||[]}getEventToItemsMap(){return this.Yi}ve(){return this.ne}}class $o extends Po{constructor(e){super(e)}ae(){return"$surveys_activated"}le(){return wt.SHOWN}ee(e){var t;(t=this._instance)==null||t.getSurveys(e)}he(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}oe(){return O}de(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class Io{constructor(e){this.ce=void 0,this._surveyManager=null,this.fe=!1,this.pe=[],this.ge=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(F(t))return O.warn("Flags not loaded yet. Not loading surveys.");var i=R(t);this.ce=i?t.length>0:t,O.info("flags response received, isSurveysEnabled: "+this.ce),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;tlocalStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.fe)O.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)O.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())O.info("Not loading surveys in cookieless mode without consent.");else{var e=x==null?void 0:x.__PosthogExtensions__;if(e){if(!_(this.ce)||this._instance.config.advanced_enable_surveys){var t=this.ce||this._instance.config.advanced_enable_surveys;this.fe=!0;try{var i=e.generateSurveys;if(i)return void this._e(i,t);var s=e.loadExternalDependency;if(!s)return void this.me("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",(n=>{n||!e.generateSurveys?this.me("Could not load surveys script",n):this._e(e.generateSurveys,t)}))}catch(n){throw this.me("Error initializing surveys",n),n}finally{this.fe=!1}}}else O.error("PostHog Extensions not found.")}}_e(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new $o(this._instance),O.info("Surveys loaded successfully"),this.ye({isLoaded:!0})}me(e,t){O.error(e,t),this.ye({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.pe.push(e),this._surveyManager&&this.ye({isLoaded:!0}),()=>{this.pe=this.pe.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return O.info("Disabled. Not loading surveys."),e([]);var i,s=this._instance.get_property(Hi);if(s&&!t)return e(s,{isLoaded:!0});typeof Promise<"u"&&this.ge?this.ge.then((n=>{var{surveys:a,context:o}=n;return e(a,o)})):(typeof Promise<"u"&&(this.ge=new Promise((n=>{i=n}))),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:n=>{var a;this.ge=null;var o=n.statusCode;if(o!==200||!n.json){var l="Surveys API could not be loaded, status: "+o;O.error(l);var u={isLoaded:!1,error:l};return e([],u),void(i==null||i({surveys:[],context:u}))}var c,h=n.json.surveys||[],p=h.filter((v=>(function(g){return!(!g.start_date||g.end_date)})(v)&&((function(g){var w;return!((w=g.conditions)==null||(w=w.events)==null||(w=w.values)==null||!w.length)})(v)||(function(g){var w;return!((w=g.conditions)==null||(w=w.actions)==null||(w=w.values)==null||!w.length)})(v))));p.length>0&&((c=this._surveyEventReceiver)==null||c.register(p)),(a=this._instance.persistence)==null||a.register({[Hi]:h});var f={isLoaded:!0};e(h,f),i==null||i({surveys:h,context:f})}}))}ye(e){for(var t of this.pe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){O.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!F(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);O.warn("init was not called")}be(e){var t=null;return this.getSurveys((i=>{var s;t=(s=i.find((n=>n.id===e)))!==null&&s!==void 0?s:null})),t}we(e){if(F(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.be(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(F(this._surveyManager))return O.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.we(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return F(this._surveyManager)?(O.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((i=>{this.getSurveys((s=>{var n,a=(n=s.find((l=>l.id===e)))!==null&&n!==void 0?n:null;if(a){var o=this.we(a);i({visible:o.eligible,disabledReason:o.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var s;if(F(this._surveyManager))O.warn("init was not called");else{var n=typeof e=="string"?this.be(e):e;if(n!=null&&n.id)if(xo.includes(n.type)){var a=m==null?void 0:m.querySelector(t);if(a)return(s=n.appearance)!=null&&s.surveyPopupDelaySeconds?(O.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,l;O.info("Rendering survey "+n.id+" with delay of "+((o=n.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(n,a,i),O.info("Survey "+n.id+" rendered")}),1e3*n.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(n,a,i);O.warn("Survey element not found")}else O.warn("Surveys of type "+n.type+" cannot be rendered in the app");else O.warn("Survey not found")}}displaySurvey(e,t){var i;if(F(this._surveyManager))O.warn("init was not called");else{var s=this.be(e);if(s){var n=s;if((i=s.appearance)!=null&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=b({},s,{appearance:b({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Yi.Popover&&t.initialResponses&&O.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var a=this.canRenderSurvey(s);if(!a.visible)return void O.warn("Survey is not eligible to be displayed: ",a.disabledReason)}t.displayType!==Yi.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else O.warn("Survey not found")}}cancelPendingSurvey(e){F(this._surveyManager)?O.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}var ve=D("[Conversations]");class Fo{constructor(e){this.xe=void 0,this._conversationsManager=null,this.Ee=!1,this.$e=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;F(t)||(we(t)?this.xe=t:(this.xe=t.enabled,this.$e=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.xe=void 0,this.$e=null}loadIfEnabled(){if(!this._conversationsManager&&!this.Ee&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=x==null?void 0:x.__PosthogExtensions__;if(e&&!_(this.xe)&&this.xe)if(this.$e&&this.$e.token){this.Ee=!0;try{var t=e.initConversations;if(t)return this.Se(t),void(this.Ee=!1);var i=e.loadExternalDependency;if(!i)return void this.ke("PostHog loadExternalDependency extension not found.");i(this._instance,"conversations",(s=>{s||!e.initConversations?this.ke("Could not load conversations script",s):this.Se(e.initConversations),this.Ee=!1}))}catch(s){this.ke("Error initializing conversations",s),this.Ee=!1}}else ve.error("Conversations enabled but missing token in remote config.")}}Se(e){if(this.$e)try{this._conversationsManager=e(this.$e,this._instance),ve.info("Conversations loaded successfully")}catch(t){this.ke("Error completing conversations initialization",t)}else ve.error("Cannot complete initialization: remote config is null")}ke(e,t){ve.error(e,t),this._conversationsManager=null,this.Ee=!1}show(){this._conversationsManager?this._conversationsManager.show():ve.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.xe===!0&&!ae(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,i){var s=this;return Ke((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(ve.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var i=this;return Ke((function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(ve.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return Ke((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(ve.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return Ke((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(ve.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}}class Ro{constructor(e){var t;this.Pe=!1,this.Te=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Pe=!0)}onRemoteConfig(e){var t,i=(t=e.logs)==null?void 0:t.captureConsoleLogs;!F(i)&&i&&(this.Pe=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Pe&&!this.Te){var e=D("[logs]"),t=x==null?void 0:x.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",(s=>{var n;s||(n=t.logs)==null||!n.initializeLogs?e.error("Could not load logs script",s):(t.logs.initializeLogs(this._instance),this.Te=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}}var os=D("[RateLimiter]");class Oo{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((s=>{os.info((s||"events")+" is quota limited."),this.serverLimits[s]=new Date().getTime()+6e4}))}catch(s){return void os.warn('could not rate limit - continuing. Error: "'+(s==null?void 0:s.message)+'"',{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:a}=this,o=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(ji))!==null&&t!==void 0?t:{tokens:n,last:o};l.tokens+=(o-l.last)/1e3*a,l.last=o,l.tokens>n&&(l.tokens=n);var u=l.tokens<1;return u||e||(l.tokens=Math.max(0,l.tokens-1)),!u||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+a+" events per second and "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=u,(s=this.instance.persistence)==null||s.set_property(ji,l),{isRateLimited:u,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()e(this.remoteConfig))):(Le.error("PostHog Extensions not found. Cannot load remote config."),e())}Ce(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return Le.info("Using preloaded remote config",this.remoteConfig),void this.bi(this.remoteConfig);if(this._instance.O())return void Le.warn("Remote config is disabled. Falling back to local config.");this.Ie((e=>{if(!e)return Le.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ce((t=>{this.bi(t)}));this.bi(e)}))}catch(e){Le.error("Error loading remote config",e)}}bi(e){e?this._instance.config.__preview_remote_config?(this._instance.bi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Le.info("__preview_remote_config is disabled. Logging config instead",e):Le.error("Failed to fetch remote config from PostHog.")}}var Ji=3e3;class Co{constructor(e,t){this.Re=!0,this.Fe=[],this.Me=de((t==null?void 0:t.flush_interval_ms)||Ji,250,5e3,y.createLogger("flush interval"),Ji),this.Oe=e}enqueue(e){this.Fe.push(e),this.Ae||this.De()}unload(){this.je();var e=this.Fe.length>0?this.Le():{},t=Object.values(e);[...t.filter((i=>i.url.indexOf("/e")===0)),...t.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.Oe(b({},i,{transport:"sendBeacon"}))}))}enable(){this.Re=!1,this.De()}De(){var e=this;this.Re||(this.Ae=setTimeout((()=>{if(this.je(),this.Fe.length>0){var t=this.Le(),i=function(){var n=t[s],a=new Date().getTime();n.data&&R(n.data)&&T(n.data,(o=>{o.offset=Math.abs(o.timestamp-a),delete o.timestamp})),e.Oe(n)};for(var s in t)i()}}),this.Me))}je(){clearTimeout(this.Ae),this.Ae=void 0}Le(){var e={};return T(this.Fe,(t=>{var i,s=t,n=(s?s.batchKey:null)||s.url;_(e[n])&&(e[n]=b({},s,{data:[]})),(i=e[n].data)==null||i.push(s.data)})),this.Fe=[],e}}var Mo=["retriesPerformedSoFar"];class Ao{constructor(e){this.Ne=!1,this.Ue=3e3,this.Fe=[],this._instance=e,this.Fe=[],this.ze=!0,!_(d)&&"onLine"in d.navigator&&(this.ze=d.navigator.onLine,this.He=()=>{this.ze=!0,this.Lt()},this.Be=()=>{this.ze=!1},N(d,"online",this.He),N(d,"offline",this.Be))}get length(){return this.Fe.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=gs(e,Mo);ze(t)&&(i.url=ei(i.url,{retry_count:t})),this._instance._send_request(b({},i,{callback:s=>{s.statusCode!==200&&(s.statusCode<400||s.statusCode>=500)&&(t??0)<10?this.qe(b({retriesPerformedSoFar:t},i)):i.callback==null||i.callback(s)}}))}qe(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(a){var o=3e3*Math.pow(2,a),l=o/2,u=Math.min(18e5,o),c=(Math.random()-.5)*(u-l);return Math.ceil(u+c)})(t),s=Date.now()+i;this.Fe.push({retryAt:s,requestOptions:e});var n="Enqueued failed request for retry in "+i;navigator.onLine||(n+=" (Browser is offline)"),y.warn(n),this.Ne||(this.Ne=!0,this.We())}We(){if(this.Ge&&clearTimeout(this.Ge),this.Fe.length===0)return this.Ne=!1,void(this.Ge=void 0);this.Ge=setTimeout((()=>{this.ze&&this.Fe.length>0&&this.Lt(),this.We()}),this.Ue)}Lt(){var e=Date.now(),t=[],i=this.Fe.filter((n=>n.retryAt0)for(var{requestOptions:s}of i)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this.Ge&&(clearTimeout(this.Ge),this.Ge=void 0),this.Ne=!1,_(d)||(this.He&&(d.removeEventListener("online",this.He),this.He=void 0),this.Be&&(d.removeEventListener("offline",this.Be),this.Be=void 0)),this.Fe))try{this._instance._send_request(b({},e,{transport:"sendBeacon"}))}catch(t){y.error(t)}this.Fe=[]}}class Do{constructor(e){this.Ve=()=>{var t,i,s,n;this.Je||(this.Je={});var a=this.scrollElement(),o=this.scrollY(),l=a?Math.max(0,a.scrollHeight-a.clientHeight):0,u=o+((a==null?void 0:a.clientHeight)||0),c=(a==null?void 0:a.scrollHeight)||0;this.Je.lastScrollY=Math.ceil(o),this.Je.maxScrollY=Math.max(o,(t=this.Je.maxScrollY)!==null&&t!==void 0?t:0),this.Je.maxScrollHeight=Math.max(l,(i=this.Je.maxScrollHeight)!==null&&i!==void 0?i:0),this.Je.lastContentY=u,this.Je.maxContentY=Math.max(u,(s=this.Je.maxContentY)!==null&&s!==void 0?s:0),this.Je.maxContentHeight=Math.max(c,(n=this.Je.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}getContext(){return this.Je}resetContext(){var e=this.Je;return setTimeout(this.Ve,0),e}startMeasuringScrollPosition(){N(d,"scroll",this.Ve,{capture:!0}),N(d,"scrollend",this.Ve,{capture:!0}),N(d,"resize",this.Ve)}scrollElement(){if(!this._instance.config.scroll_root_selector)return d==null?void 0:d.document.documentElement;var e=R(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=d==null?void 0:d.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 d&&(d.scrollY||d.pageYOffset||d.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return d&&(d.scrollX||d.pageXOffset||d.document.documentElement.scrollLeft)||0}}var Lo=r=>dn(r==null?void 0:r.config.mask_personal_data_properties,r==null?void 0:r.config.custom_personal_data_properties);class ls{constructor(e,t,i,s){this.Ke=n=>{var a=this.Ye();if(!a||a.sessionId!==n){var o={sessionId:n,props:this.Xe(this._instance)};this.Qe.register({[qi]:o})}},this._instance=e,this.Ze=t,this.Qe=i,this.Xe=s||Lo,this.Ze.onSessionId(this.Ke)}Ye(){return this.Qe.props[qi]}getSetOnceProps(){var e,t=(e=this.Ye())==null?void 0:e.props;return t?"r"in t?pn(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 T(rr(this.getSetOnceProps()),((t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+Fi(i)]=t})),e}}var Si=D("[SessionId]");class us{on(e,t){return this.tr.on(e,t)}constructor(e,t,i){var s;if(this.ir=[],this.er=void 0,this.tr=new ur,this.rr=(c,h)=>!(!ze(c)||!ze(h))&&Math.abs(c-h)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Qe=e.persistence,this.sr=void 0,this.nr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ar=t||Re,this.lr=i||Re;var n=this.R.persistence_name||this.R.token,a=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*de(a,60,36e3,Si.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ur(),this.hr="ph_"+n+"_window_id",this.dr="ph_"+n+"_primary_window_exists",this.vr()){var o=j.W(this.hr),l=j.W(this.dr);o&&!l?this.sr=o:j.V(this.hr),j.G(this.dr,!0)}if((s=this.R.bootstrap)!=null&&s.sessionID)try{var u=(c=>{var h=c.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})(this.R.bootstrap.sessionID);this.cr(this.R.bootstrap.sessionID,new Date().getTime(),u)}catch(c){Si.error("Invalid sessionID in bootstrap",c)}this.pr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return _(this.ir)&&(this.ir=[]),this.ir.push(e),this.nr&&e(this.nr,this.sr),()=>{this.ir=this.ir.filter((t=>t!==e))}}vr(){return this.R.persistence!=="memory"&&!this.Qe.ki&&j.H()}gr(e){e!==this.sr&&(this.sr=e,this.vr()&&j.G(this.hr,e))}_r(){return this.sr?this.sr:this.vr()?j.W(this.hr):null}cr(e,t,i){e===this.nr&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.nr=e,this.Qe.register({[Vt]:[t,e,i]}))}mr(){var e=this.Qe.props[Vt];return R(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.cr(null,null,null)}destroy(){clearTimeout(this.yr),this.yr=void 0,this.er&&d&&(d.removeEventListener("beforeunload",this.er,{capture:!1}),this.er=void 0),this.ir=[]}pr(){this.er=()=>{this.vr()&&j.V(this.dr)},N(d,"beforeunload",this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||new Date().getTime(),[s,n,a]=this.mr(),o=this._r(),l=ze(a)&&Math.abs(i-a)>864e5,u=!1,c=!n,h=!c&&!e&&this.rr(i,s);c||h||l?(n=this.ar(),o=this.lr(),Si.info("new session ID generated",{sessionId:n,windowId:o,changeReason:{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}}),a=i,u=!0):o||(o=this.lr(),u=!0);var p=ze(s)&&e&&!l?s:i,f=ze(a)?a:new Date().getTime();return this.gr(o),this.cr(n,p,f),e||this.ur(),u&&this.ir.forEach((v=>v(n,o,u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:o,sessionStartTimestamp:f,changeReason:u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:s}}ur(){clearTimeout(this.yr),this.yr=setTimeout((()=>{var[e]=this.mr();if(this.rr(new Date().getTime(),e)){var t=this.nr;this.resetSessionId(),this.tr.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}}var No=["$set_once","$set"],Ie=D("[SiteApps]");class Ho{constructor(e){this._instance=e,this.br=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}wr(e,t){if(t){var i=this.globalsForEvent(t);this.br.push(i),this.br.length>1e3&&(this.br=this.br.slice(10))}}get siteAppLoaders(){var e;return(e=x._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Bi(this.wr.bind(this));this.Er=()=>{e(),this.br=[],this.Er=void 0}}}globalsForEvent(e){var t,i,s,n,a,o,l;if(!e)throw new Error("Event payload is required");var u={},c=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var[p,f]of Object.entries(h))u[p]={id:c[p],type:p,properties:f};var{$set_once:v,$set:g}=e;return{event:b({},gs(e,No),{properties:b({},e.properties,g?{$set:b({},(t=(i=e.properties)==null?void 0:i.$set)!==null&&t!==void 0?t:{},g)}:{},v?{$set_once:b({},(s=(n=e.properties)==null?void 0:n.$set_once)!==null&&s!==void 0?s:{},v)}:{}),elements_chain:(a=(o=e.properties)==null?void 0:o.$elements_chain)!==null&&a!==void 0?a:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var o;!t.errored&&this.br.length&&(Ie.info("Processing "+this.br.length+" events for site app with id "+e.id),this.br.forEach((l=>t.processEvent==null?void 0:t.processEvent(l))),t.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((o=this.Er)==null||o.call(this))},s=!1,n=o=>{t.errored=!o,t.loaded=!0,Ie.info("Site app with id "+e.id+" "+(o?"loaded":"errored")),s&&i()};try{var{processEvent:a}=e.init({posthog:this._instance,callback:o=>{n(o)}});a&&(t.processEvent=a),s=!0}catch(o){Ie.error("Error while initializing PostHog app with config id "+e.id,o),n(!1)}if(s&&t.loaded)try{i()}catch(o){Ie.error("Error while processing buffered events PostHog app with config id "+e.id,o),t.errored=!0}}$r(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}Sr(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{i.processEvent==null||i.processEvent(t)}catch(s){Ie.error("Error while processing event "+e.event+" for site app "+i.id,s)}}}onRemoteConfig(e){var t,i,s,n=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.$r(),void this._instance.on("eventCaptured",(u=>this.Sr(u)))):void Ie.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((i=this.Er)==null||i.call(this),(s=e.siteApps)!=null&&s.length)if(this.isEnabled){var a=function(u){var c;x["__$$ph_site_app_"+u]=n._instance,(c=x.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(n._instance,l,(h=>{if(h)return Ie.error("Error while initializing PostHog app with config id "+u,h)}))};for(var{id:o,url:l}of e.siteApps)a(o)}else Ie.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var xn=function(r,e){if(!r)return!1;var t=r.userAgent;if(t&&yr(t,e))return!0;try{var i=r==null?void 0:r.userAgentData;if(i!=null&&i.brands&&i.brands.some((s=>yr(s==null?void 0:s.brand,e))))return!0}catch{}return!!r.webdriver},Et=(function(r){return r.US="us",r.EU="eu",r.CUSTOM="custom",r})({}),cs="i.posthog.com";class qo{constructor(e){this.kr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+cs,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.kr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=Et.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=Et.EU:this.kr[this.apiHost]=Et.CUSTOM),this.kr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===Et.CUSTOM)return this.apiHost+t;var i=cs+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var jo={icontains:(r,e)=>!!d&&e.href.toLowerCase().indexOf(r.toLowerCase())>-1,not_icontains:(r,e)=>!!d&&e.href.toLowerCase().indexOf(r.toLowerCase())===-1,regex:(r,e)=>!!d&&ti(e.href,r),not_regex:(r,e)=>!!d&&!ti(e.href,r),exact:(r,e)=>e.href===r,is_not:(r,e)=>e.href!==r};class B{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments((s=>{B.Pr("retrieved web experiments from the server"),t.Tr=new Map,s.forEach((n=>{if(n.feature_flag_key){var a;t.Tr&&(B.Pr("setting flag key ",n.feature_flag_key," to web experiment ",n),(a=t.Tr)==null||a.set(n.feature_flag_key,n));var o=t._instance.getFeatureFlag(n.feature_flag_key);H(o)&&n.variants[o]&&t.Ir(n.name,o,n.variants[o].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];B.Cr(u)&&t.Ir(n.name,l,u.transforms)}}))}),i)},this._instance=e,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}onFeatureFlags(e){if(this._is_bot())B.Pr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(F(this.Tr))return this.Tr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();B.Pr("applying feature flags",e),e.forEach((t=>{var i;if(this.Tr&&(i=this.Tr)!=null&&i.has(t)){var s,n=this._instance.getFeatureFlag(t),a=(s=this.Tr)==null?void 0:s.get(t);n&&a!=null&&a.variants[n]&&this.Ir(a.name,n,a.variants[n].transforms)}}))}}previewWebExperiment(){var e=B.getWindowLocation();if(e!=null&&e.search){var t=Kt(e==null?void 0:e.search,"__experiment_id"),i=Kt(e==null?void 0:e.search,"__experiment_variant");t&&i&&(B.Pr("previewing web experiments "+t+" && "+i),this.getWebExperiments((s=>{this.Rr(parseInt(t),i,s)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._instance.config.disable_web_experiments&&!i)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:n=>{if(n.statusCode!==200||!n.json)return e([]);var a=n.json.experiments||[];return e(a)}})}Rr(e,t,i){var s=i.filter((n=>n.id===e));s&&s.length>0&&(B.Pr("Previewing web experiment ["+s[0].name+"] with variant ["+t+"]"),this.Ir(s[0].name,t,s[0].variants[t].transforms))}static Cr(e){return!F(e.conditions)&&B.Fr(e)&&B.Mr(e)}static Fr(e){var t;if(F(e.conditions)||F((t=e.conditions)==null?void 0:t.url))return!0;var i,s,n,a=B.getWindowLocation();return!!a&&((i=e.conditions)==null||!i.url||jo[(s=(n=e.conditions)==null?void 0:n.urlMatchType)!==null&&s!==void 0?s:"icontains"](e.conditions.url,a))}static getWindowLocation(){return d==null?void 0:d.location}static Mr(e){var t;if(F(e.conditions)||F((t=e.conditions)==null?void 0:t.utm))return!0;var i=ln();if(i.utm_source){var s,n,a,o,l,u,c,h,p=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==i.utm_campaign,f=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_source||((o=e.conditions)==null||(o=o.utm)==null?void 0:o.utm_source)==i.utm_source,v=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==i.utm_medium,g=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return p&&v&&g&&f}return!1}static Pr(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s{if(s.selector){var n;B.Pr("applying transform of variant "+t+" for experiment "+e+" ",s);var a=(n=document)==null?void 0:n.querySelectorAll(s.selector);a==null||a.forEach((o=>{var l=o;s.html&&(l.innerHTML=s.html),s.css&&l.setAttribute("style",s.css)}))}})):B.Pr("Control variants leave the page unmodified.")}_is_bot(){return Z&&this._instance?xn(Z,this._instance.config.custom_blocked_useragents):void 0}}var Uo=D("[PostHog ExternalIntegrations]"),Bo={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Vo{constructor(e){this._instance=e}it(e,t){var i;(i=x.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,(s=>{if(s)return Uo.error("failed to load script",s);t()}))}startIfEnabledOrStop(){var e=this,t=function(a){var o,l,u;!s||(o=x.__PosthogExtensions__)!=null&&(o=o.integrations)!=null&&o[a]||e.it(Bo[a],(()=>{var c;(c=x.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[a])==null||c.start(e._instance)})),!s&&(l=x.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[a]&&((u=x.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[a])==null||u.stop())};for(var[i,s]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;t(i)}}}var Ki="[SessionRecording]",ft=D(Ki);class hs{get started(){var e;return!((e=this.Or)==null||!e.isStarted)}get status(){return this.Or?this.Or.status:this.Ar&&!this.Dr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ar=!1,this.jr=void 0,this._instance=e,!this._instance.sessionManager)throw ft.error("started without valid sessionManager"),new Error(Ki+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Ki+' cannot be used with cookieless_mode="always"')}get Dr(){var e,t=!((e=this._instance.get_property(hi))==null||!e.enabled),i=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return d&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!this.Dr||(t=this.Or)==null||!t.isStarted){var i=!_(Object.assign)&&!_(Array.from);this.Dr&&i?(this.Lr(e),ft.info("starting")):this.stopRecording()}}Lr(e){var t,i,s;this.Dr&&(x!=null&&(t=x.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(i=x.__PosthogExtensions__)!=null&&i.initSessionRecording?this.Nr(e):(s=x.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.Ur,(n=>{if(n)return ft.error("could not load recorder",n);this.Nr(e)})))}stopRecording(){var e,t;(e=this.jr)==null||e.call(this),this.jr=void 0,(t=this.Or)==null||t.stop()}zr(){var e;(e=this._instance.persistence)==null||e.unregister(Us)}Hr(e){if(this._instance.persistence){var t,i,s=this._instance.persistence,n=()=>{var a=e.sessionRecording===!1?void 0:e.sessionRecording,o=a==null?void 0:a.sampleRate,l=F(o)?null:parseFloat(o);F(l)&&this.zr();var u=a==null?void 0:a.minimumDurationMilliseconds;s.register({[hi]:b({enabled:!!a},a,{networkPayloadCapture:b({capturePerformance:e.capturePerformance},a==null?void 0:a.networkPayloadCapture),canvasRecording:{enabled:a==null?void 0:a.recordCanvas,fps:a==null?void 0:a.canvasFps,quality:a==null?void 0:a.canvasQuality},sampleRate:l,minimumDurationMilliseconds:_(u)?null:u,endpoint:a==null?void 0:a.endpoint,triggerMatchType:a==null?void 0:a.triggerMatchType,masking:a==null?void 0:a.masking,urlTriggers:a==null?void 0:a.urlTriggers})})};n(),(t=this.jr)==null||t.call(this),this.jr=(i=this._instance.sessionManager)==null?void 0:i.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.Hr(e),this.Ar=!0,this.startIfEnabledOrStop()):this.Ar=!0:ft.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;t===void 0&&(t="log"),(i=this.Or)!=null&&i.log?this.Or.log(e,t):ft.warn("log called before recorder was ready")}get Ur(){var e,t,i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(hi);return(i==null||(t=i.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Nr(e){var t,i;if((t=x.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(i=x.__PosthogExtensions__)==null?void 0:i.initSessionRecording(this._instance),this.Or._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Or.start(e)}onRRwebEmit(e){var t;(t=this.Or)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Or)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Or)==null||e.overrideSampling()}overrideTrigger(e){var t,i;this.Or||(i=this._instance.persistence)==null||i.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Or)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Or)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!((i=this.Or)==null||!i.tryAddCustomEvent(e,t))}}var St={},Xi=()=>{},Ye="posthog",kn=!vo&&(W==null?void 0:W.indexOf("MSIE"))===-1&&(W==null?void 0:W.indexOf("Mozilla"))===-1,ds=r=>{var e;return b({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:ya(m==null?void 0:m.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Xi,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:r??"unset",__preview_deferred_init_extensions:!1,debug:z&&H(z==null?void 0:z.search)&&z.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(d==null||(e=d.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;y.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:Ji},error_tracking:{},_onCapture:Xi,__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"}))(r))},ps=r=>{var e={};_(r.process_person)||(e.person_profiles=r.process_person),_(r.xhr_headers)||(e.request_headers=r.xhr_headers),_(r.cookie_name)||(e.persistence_name=r.cookie_name),_(r.disable_cookie)||(e.disable_persistence=r.disable_cookie),_(r.store_google)||(e.save_campaign_params=r.store_google),_(r.verbose)||(e.debug=r.verbose);var t=L({},e,r);return R(r.property_blacklist)&&(_(r.property_denylist)?t.property_denylist=r.property_blacklist:R(r.property_denylist)?t.property_denylist=[...r.property_blacklist,...r.property_denylist]:y.error("Invalid value for property_denylist config: "+r.property_denylist)),t};class Go{constructor(){this.__forceAllowLocalhost=!1}get Br(){return this.__forceAllowLocalhost}set Br(e){y.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class ni{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 Go,this.qr=!1,this.version=ge.LIB_VERSION,this.Wr=new ur,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=ds(),this.SentryIntegration=Ya,this.sentryIntegration=e=>(function(t,i){var s=on(t,i);return{name:an,processEvent:n=>s(n)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Gr=!1,this.Vr=null,this.Jr=null,this.Kr=null,this.featureFlags=new yo(this),this.toolbar=new Ka(this),this.scrollManager=new Do(this),this.pageViewManager=new Yr(this),this.surveys=new Io(this),this.conversations=new Fo(this),this.logs=new Ro(this),this.experiments=new B(this),this.exceptions=new go(this),this.rateLimiter=new Oo(this),this.requestRouter=new qo(this),this.consent=new Ua(this),this.externalIntegrations=new Vo(this),this.people={set:(e,t,i)=>{var s=H(e)?{[e]:t}:e;this.setPersonProperties(s),i==null||i({})},set_once:(e,t,i)=>{var s=H(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),i==null||i({})}},this.on("eventCaptured",(e=>y.info('send "'+(e==null?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Ye){var s,n=(s=St[i])!==null&&s!==void 0?s:new ni;return n._init(e,t,i),St[i]=n,St[Ye][i]=n,n}return this._init(e,t,i)}_init(e,t,i){var s;if(t===void 0&&(t={}),_(e)||Ri(e))return y.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.Yr(t.debug),this.Xr=t,this.Qr=[],t.person_profiles&&(this.Jr=t.person_profiles),this.set_config(L({},ds(t.defaults),ps(t),{name:i,token:e})),this.config.on_xhr_error&&y.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ye.GZipJS;var n=this.Zr();this.persistence=new wi(this.config,n),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wi(b({},this.config,{persistence:"sessionStorage"}),n);var a=b({},this.persistence.props),o=b({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.ts=new Co((k=>this.es(k)),this.config.request_queue_config),this.rs=new Ao(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 us(this),this.sessionPropsManager=new ls(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(y.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.ss(l)}),0)):(y.info("Initializing extensions synchronously"),this.ss(l)),ge.DEBUG=ge.DEBUG||this.config.debug,ge.DEBUG&&y.info("Starting in debug mode",{this:this,config:t,thisC:b({},this.config),p:a,s:o}),((s=t.bootstrap)==null?void 0:s.distinctID)!==void 0){var u,c,h=this.config.get_device_id(Re()),p=(u=t.bootstrap)!=null&&u.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(_e,(c=t.bootstrap)!=null&&c.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:p})}if(this.ns()){var f,v,g=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlags)||{}).filter((k=>{var I;return!((I=t.bootstrap)==null||(I=I.featureFlags)==null||!I[k])})).reduce(((k,I)=>{var P;return k[I]=((P=t.bootstrap)==null||(P=P.featureFlags)==null?void 0:P[I])||!1,k}),{}),w=Object.keys(((v=t.bootstrap)==null?void 0:v.featureFlagPayloads)||{}).filter((k=>g[k])).reduce(((k,I)=>{var P,C;return(P=t.bootstrap)!=null&&(P=P.featureFlagPayloads)!=null&&P[I]&&(k[I]=(C=t.bootstrap)==null||(C=C.featureFlagPayloads)==null?void 0:C[I]),k}),{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:w})}if(l)this.register_once({distinct_id:at,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id(Re());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(_e,"anonymous")}return N(d,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?za(this,(()=>this.os())):this.os(),Oe(this.config._onCapture)&&this.config._onCapture!==Xi&&(y.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(k=>this.config._onCapture(k.event,k)))),this.config.ip&&y.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}ss(e){var t=performance.now();this.historyAutocapture=new Wa(this),this.historyAutocapture.startIfEnabled();var i=[];i.push((()=>{new Za(this).startIfEnabledOrStop()})),i.push((()=>{var s;this.siteApps=new Ho(this),(s=this.siteApps)==null||s.init()})),e||i.push((()=>{this.sessionRecording=new hs(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),i.push((()=>{this.autocapture=new Ma(this),this.autocapture.startIfEnabled()})),i.push((()=>{this.surveys.loadIfEnabled()})),i.push((()=>{this.logs.loadIfEnabled()})),i.push((()=>{this.conversations.loadIfEnabled()})),i.push((()=>{this.productTours=new wo(this),this.productTours.loadIfEnabled()})),i.push((()=>{this.heatmaps=new no(this),this.heatmaps.startIfEnabled()})),i.push((()=>{this.webVitalsAutocapture=new ro(this)})),i.push((()=>{this.exceptionObserver=new Ga(this),this.exceptionObserver.startIfEnabledOrStop()})),i.push((()=>{this.deadClicksAutocapture=new nn(this,Va),this.deadClicksAutocapture.startIfEnabled()})),i.push((()=>{if(this.ls){var s=this.ls;this.ls=void 0,this.bi(s)}})),this.us(i,t)}us(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.us(e,t)}),0);var i=e.shift();if(i)try{i()}catch(n){y.error("Error initializing extension:",n)}}var s=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:s}),this.config.__preview_deferred_init_extensions&&y.info("PostHog extensions initialized ("+s+"ms)")}bi(e){var t,i,s,n,a,o,l,u,c;if(!m||!m.body)return y.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.bi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.ls=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=S(e.supportedCompression,ye.GZipJS)?ye.GZipJS:S(e.supportedCompression,ye.Base64)?ye.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Jr?this.Jr:"identified_only"}),(i=this.siteApps)==null||i.onRemoteConfig(e),(s=this.sessionRecording)==null||s.onRemoteConfig(e),(n=this.autocapture)==null||n.onRemoteConfig(e),(a=this.heatmaps)==null||a.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(o=this.productTours)==null||o.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(u=this.exceptionObserver)==null||u.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(c=this.deadClicksAutocapture)==null||c.onRemoteConfig(e)}os(){try{this.config.loaded(this)}catch(e){y.critical("`loaded` function failed",e)}this.hs(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.ds()}),1),new To(this).load(),this.featureFlags.flags()}hs(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.ts)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Te(this.__request_queue,(e=>this.es(e))),this.__request_queue=[],this.hs()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.vs()&&this.capture("$pageleave"),(e=this.ts)==null||e.unload(),(t=this.rs)==null||t.unload()):this.vs()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(kn?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=ei(e.url,{ip:this.config.ip?1:0}),e.headers=b({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var i,s,n,a=b({},t);a.timeout=a.timeout||6e4,a.url=ei(a.url,{_:new Date().getTime().toString(),ver:ge.LIB_VERSION,compression:a.compression});var o=(i=a.transport)!==null&&i!==void 0?i:"fetch",l=qt.filter((c=>!a.disableTransport||!c.transport||!a.disableTransport.includes(c.transport))),u=(s=(n=Hs(l,(c=>c.transport===o)))==null?void 0:n.method)!==null&&s!==void 0?s:l[0].method;if(!u)throw new Error("No available transport method");u(a)})(b({},e,{callback:t=>{var i,s;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((i=(s=this.config).on_request_error)==null||i.call(s,t)),e.callback==null||e.callback(t)}}))))}es(e){this.rs?this.rs.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],s=[],n=[];Te(e,(o=>{o&&(t=o[0],R(t)?n.push(o):Oe(o)?o.call(this):R(o)&&t==="alias"?i.push(o):R(o)&&t.indexOf("capture")!==-1&&Oe(this[t])?n.push(o):s.push(o))}));var a=function(o,l){Te(o,(function(u){if(R(u[0])){var c=l;T(u,(function(h){c=c[h[0]].apply(c,h.slice(1))}))}else this[u[0]].apply(this,u.slice(1))}),l)};a(i,this),a(s,this),a(n,this)}ns(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,i){var s;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.ts){if(this.is_capturing())if(!_(e)&&H(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(n&&!this.config.__preview_capture_bot_pageviews)){var a=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a==null||!a.isRateLimited){t!=null&&t.$current_url&&!H(t==null?void 0:t.$current_url)&&(y.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,l=(i==null?void 0:i.timestamp)||o,u=Re(),c={uuid:u,event:e,properties:this.calculateEventProperties(e,t||{},l,u)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&n&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),a&&(c.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens),i!=null&&i.$set&&(c.$set=i==null?void 0:i.$set);var h,p=e!=="$groupidentify",f=this.cs(i==null?void 0:i.$set_once,p);if(f&&(c.$set_once=f),(c=_a(c,i!=null&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,_(i==null?void 0:i.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=o),e===wt.DISMISSED||e===wt.SENT){var v=t==null?void 0:t[ki.SURVEY_ID],g=t==null?void 0:t[ki.SURVEY_ITERATION];h={id:v,current_iteration:g},localStorage.getItem(as(h))||localStorage.setItem(as(h),"true"),c.$set=b({},c.$set,{[Eo({id:v,current_iteration:g},e===wt.SENT?"responded":"dismissed")]:!0})}else e===wt.SHOWN&&(c.$set=b({},c.$set,{[ki.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var w=b({},c.properties.$set,c.$set);if(Xe(w)||this.setPersonPropertiesForFlags(w),!F(this.config.before_send)){var E=this.fs(c);if(!E)return;c=E}this.Wr.emit("eventCaptured",c);var k={method:"POST",url:(s=i==null?void 0:i._url)!==null&&s!==void 0?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:i==null?void 0:i._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.es(k):this.ts.enqueue(k),c}y.critical("This capture call is ignored due to client rate limiting.")}}else y.error("No event name provided to posthog.capture")}else y.uninitializedWarning("posthog.capture")}Bi(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,i,s,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var a=n?void 0:this.persistence.remove_event_timer(e),o=b({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(o.$cookieless_mode=!0),e==="$snapshot"){var l=b({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=l.distinct_id,(!H(o.distinct_id)&&!Ee(o.distinct_id)||Ri(o.distinct_id))&&y.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),o}var u,c=io(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:p}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime());o.$session_id=h,o.$window_id=p}this.sessionPropsManager&&L(o,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&L(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=(f=this.rs)==null?void 0:f.length}catch(E){o.$sdk_debug_error_capturing_properties=String(E)}if(this.requestRouter.region===Et.CUSTOM&&(o.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||n?e!=="$pageleave"||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,s),o=L(o,u),e==="$pageview"&&m&&(o.title=m.title),!_(a)){var v=i.getTime()-a;o.$duration=parseFloat((v/1e3).toFixed(3))}W&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?"bot":"browser"),(o=L({},c,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),R(this.config.property_denylist)?T(this.config.property_denylist,(function(E){delete o[E]})):y.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var g=this.config.sanitize_properties;g&&(y.error("sanitize_properties is deprecated. Use before_send instead"),o=g(o,e));var w=this.ps();return o.$process_person_profile=w,w&&!n&&this.gs("_calculate_event_properties"),o}cs(e,t){var i;if(t===void 0&&(t=!0),!this.persistence||!this.ps()||this.qr)return e;var s=this.persistence.get_initial_props(),n=(i=this.sessionPropsManager)==null?void 0:i.getSetOnceProps(),a=L({},s,n||{},e||{}),o=this.config.sanitize_properties;return o&&(y.error("sanitize_properties is deprecated. Use before_send instead"),a=o(a,"$set_once")),t&&(this.qr=!0),Xe(a)?void 0:a}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var s;(s=this.persistence)==null||s.register_once(e,t,i)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}_s(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch{return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,i){var s=i!=null&&i.merge?this.featureFlags.getFlagVariants():{},n=i!=null&&i.merge?this.featureFlags.getFlagPayloads():{},a=b({},s,e),o=b({},n,t),l={};for(var[u,c]of Object.entries(a)){var h=typeof c=="string";l[u]={key:u,enabled:!!h||!!c,variant:h?c:void 0,reason:void 0,metadata:_(o==null?void 0:o[u])?void 0:{id:0,version:void 0,description:void 0,payload:o[u]}}}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.Wr.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=ko),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 y.uninitializedWarning("posthog.identify");if(Ee(e)&&(e=e.toString(),y.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()))y.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!==at){if(this.gs("posthog.identify")){var s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==s&&e!==this.get_property(gt)&&(this.unregister(gt),this.register({distinct_id:e}));var a=(this.persistence.get_property(_e)||"anonymous")==="anonymous";e!==s&&a?(this.persistence.set_property(_e,"identified"),this.setPersonPropertiesForFlags(b({},i||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:i||{}}),this.Kr=es(e,t,i),this.featureFlags.setAnonymousDistinctId(s)):(t||i)&&this.setPersonProperties(t,i),e!==s&&(this.reloadFeatureFlags(),this.unregister(Gt))}}else y.critical('The string "'+at+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else y.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.gs("posthog.setPersonProperties")){var i=es(this.get_distinct_id(),e,t);this.Kr!==i?(this.setPersonPropertiesForFlags(b({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Kr=i):y.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var s=this.getGroups();s[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:b({},s,{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),s[e]===t||i||this.reloadFeatureFlags()}else y.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.gs("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,n;if(y.info("reset"),!this.__loaded)return y.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(),this.featureFlags.reset(),(s=this.persistence)==null||s.set_property(_e,"anonymous"),(n=this.sessionManager)==null||n.resetSessionId(),this.Kr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:at,$device_id:null},"");else{var o=this.config.get_device_id(Re());this.register_once({distinct_id:o,$device_id:e?o: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),s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&i){var n,a=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!i)return s;s+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-a,0)}return s}alias(e,t){return e===this.get_property(qs)?(y.critical("Attempting to create alias for existing People user - aborting."),-2):this.gs("posthog.alias")?(_(t)&&(t=this.get_distinct_id()),e!==t?(this._s(gt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(y.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=b({},this.config);if(q(e)){var i,s,n,a,o,l,u;L(this.config,ps(e));var c=this.Zr();(i=this.persistence)==null||i.update_config(this.config,t,c),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wi(b({},this.config,{persistence:"sessionStorage"}),c);var h=this.Yr(this.config.debug);we(h)&&(this.config.debug=h),we(this.config.debug)&&(this.config.debug?(ge.DEBUG=!0,A.H()&&A.G("ph_debug","true"),y.info("set_config",{config:e,oldConfig:t,newConfig:b({},this.config)})):(ge.DEBUG=!1,A.H()&&A.V("ph_debug"))),(s=this.exceptionObserver)==null||s.onConfigChange(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this.ys(),(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 s,n,a,o,l;(s=this.sessionManager)==null||s.checkAndGetSessionAndWindowId(),i.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),i.linked_flag&&((a=this.sessionRecording)==null||a.overrideLinkedFlag()),i.url_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var i=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(b({},s,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Ye;return t!==Ye&&(t=Ye+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(_e))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(_e))==="identified"}ps(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Xe(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[gt])&&((t=this.persistence)==null||(t=t.props)==null||!t[zt]))}vs(){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.ps()||this.gs("posthog.createPersonProfile")&&this.setPersonProperties({},{})}gs(e){return this.config.person_profiles==="never"?(y.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._s(zt,!0),!0)}Zr(){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}ys(){var e,t,i,s,n=this.Zr();return((e=this.persistence)==null?void 0:e.ki)!==n&&((i=this.persistence)==null||i.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.ki)!==n&&((s=this.sessionPersistence)==null||s.set_disabled(n)),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var i,s,n;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(i=this.sessionManager)==null||i.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=new us(this),this.pageViewManager=new Yr(this),this.persistence&&(this.sessionPropsManager=new ls(this,this.sessionManager,this.persistence)),this.sessionRecording=new hs(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.ys(),this.hs(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(_(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((n=e==null?void 0:e.captureEventName)!==null&&n!==void 0?n:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.ds()}else y.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.ys(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:at,$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.ds())):y.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===me.GRANTED?"granted":e===me.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.ys()}_is_bot(){return Z?xn(Z,this.config.custom_blocked_useragents):void 0}ds(){m&&(m.visibilityState==="visible"?this.Gr||(this.Gr=!0,this.capture("$pageview",{title:m.title},{send_instantly:!0}),this.Vr&&(m.removeEventListener("visibilitychange",this.Vr),this.Vr=null)):this.Vr||(this.Vr=this.ds.bind(this),N(m,"visibilitychange",this.Vr)))}debug(e){e===!1?(d==null||d.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(d==null||d.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}))}O(){var e,t,i,s,n,a,o,l=this.Xr||{};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?(y.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",s=!1,n=y,a=(t="advanced_disable_flags")in(e=l)&&!_(e[t]),o=i in e&&!_(e[i]),a?e[t]:o?(n&&n.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):s)}fs(e){if(F(this.config.before_send))return e;var t=R(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),F(i)){var n="Event '"+e.event+"' was rejected in beforeSend function";return Mn(e.event)?y.warn(n+". This can cause unexpected behavior."):y.info(n),null}i.properties&&!Xe(i.properties)||y.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Yr(e){var t=we(e)&&!e,i=A.H()&&A.q("ph_debug")==="true";return!t&&(!!i||e)}}(function(r,e){for(var t=0;t