posthog-js 1.285.0 → 1.285.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.js +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/lazy-recorder.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.js +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/posthog-recorder.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js +29 -2
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";function e(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function t(t){return function(){var i=this,s=arguments;return new Promise((function(r,n){var o=t.apply(i,s);function a(t){e(o,r,n,a,l,"next",t)}function l(t){e(o,r,n,a,l,"throw",t)}a(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},i.apply(null,arguments)}function s(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;i[s]=e[s]}return i}var r="undefined"!=typeof window?window:void 0,n="undefined"!=typeof globalThis?globalThis:r,o=Array.prototype,a=o.forEach,l=o.indexOf,c=null==n?void 0:n.navigator,u=null==n?void 0:n.document,d=null==n?void 0:n.location,_=null==n?void 0:n.fetch,h=null!=n&&n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest?n.XMLHttpRequest:void 0,p=null==n?void 0:n.AbortController,g=null==c?void 0:c.userAgent,v=null!=r?r:{},f={DEBUG:!1,LIB_VERSION:"1.285.0"},m=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],y=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return m.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},b=["$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 w(e,t){return-1!==e.indexOf(t)}var E=function(e){return e.trim()},S=function(e){return e.replace(/^\$/,"")};var k=Array.isArray,x=Object.prototype,P=x.hasOwnProperty,I=x.toString,C=k||function(e){return"[object Array]"===I.call(e)},F=e=>"function"==typeof e,R=e=>e===Object(e)&&!C(e),T=e=>{if(R(e)){for(var t in e)if(P.call(e,t))return!1;return!0}return!1},L=e=>void 0===e,O=e=>"[object String]"==I.call(e),M=e=>O(e)&&0===e.trim().length,A=e=>null===e,D=e=>L(e)||A(e),N=e=>"[object Number]"==I.call(e),q=e=>"[object Boolean]"===I.call(e),H=e=>e instanceof FormData,j=e=>w(b,e);function U(e){return null===e||"object"!=typeof e}function z(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function B(e){return!L(Event)&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var V=[!0,"true",1,"1","yes"],W=e=>w(V,e),G=[!1,"false",0,"0","no"];function Y(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),N(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),Y(r||i,t,i,s))}class J{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Y(e.bucketSize,0,100,e._logger),this._refillRate=Y(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Y(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=t-e.lastAccess,s=Math.floor(i/this._refillInterval);if(s>0){var r=s*this._refillRate;e.tokens=Math.min(e.tokens+r,this._bucketSize),e.lastAccess=e.lastAccess+s*this._refillInterval}}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this._buckets[s];return r?this._applyRefill(r,i):(r={tokens:this._bucketSize,lastAccess:i},this._buckets[s]=r),0===r.tokens||(r.tokens--,0===r.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===r.tokens)}stop(){this._buckets={}}}var K,X,Q,Z=e=>e instanceof Error;function ee(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Q&&i.length===X||(X=i.length,Q=i.reduce(((i,s)=>{K||(K={});var r=K[s];if(r)i[r[0]]=r[1];else for(var n=e(s),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,c=t[s];if(l&&c){i[l]=c,K[s]=[l,c];break}}return i}),{})),Q}}var te="?";function ie(e,t,i,s){var r={platform:"web:javascript",filename:e,function:"<anonymous>"===t?te:t,in_app:!0};return L(i)||(r.lineno=i),L(s)||(r.colno=s),r}var se=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return i||s?[-1!==e.indexOf("@")?e.split("@")[0]:te,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},re=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ne=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,oe=/\((\S*)(?::(\d+))(?::(\d+))\)/,ae=e=>{var t=re.exec(e);if(t){var[,i,s,r]=t;return ie(i,te,+s,+r)}var n=ne.exec(e);if(n){if(n[2]&&0===n[2].indexOf("eval")){var o=oe.exec(n[2]);o&&(n[2]=o[1],n[3]=o[2],n[4]=o[3])}var[a,l]=se(n[1]||te,n[2]);return ie(l,a,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},le=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ce=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ue=e=>{var t=le.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=ce.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var s=t[3],r=t[1]||te;return[r,s]=se(r,s),ie(s,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},de=/\(error: (.*)\)/,_e=50;function he(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var r=[],n=e.split("\n"),o=s;o<n.length;o++){var a=n[o];if(!(a.length>1024)){var l=de.test(a)?a.replace(de,"$1"):a;if(!l.match(/\S*Error: /)){for(var c of t){var u=c(l);if(u){r.push(u);break}}if(r.length>=_e)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,_e).map((e=>{return i({},e,{filename:e.filename||(s=t,s[s.length-1]||{}).filename,function:e.function||te});var s}))}(r)}}class pe{constructor(e,t,i){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===i&&(i=[]),this.coercers=e,this.modifiers=i,this.stackParser=he(...t)}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),r=this.buildParsingContext(),n=this.parseStacktrace(s,r);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&C(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var s,r;return null!=e.cause&&(s=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),i({},e,{cause:s,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}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 i=this;return t((function*(){var t=e;for(var s of i.modifiers)t=yield s(t);return t}))()}convertToExceptionList(e,t){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:null!==(s=t.type)&&void 0!==s?s:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:ee(this.stackParser)}}buildCoercingContext(e,t,s){void 0===s&&(s=0);var r=(i,s)=>{if(s<=4){var r=this.buildCoercingContext(e,t,s);return this.applyCoercers(i,r)}};return i({},t,{syntheticException:0==s?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,s),next:e=>r(e,s+1)})}}class ge{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=O(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 z(e,"DOMException")}isDOMError(e){return z(e,"DOMError")}}class ve{match(e){return(e=>e 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&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class fe{constructor(){}match(e){return z(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i,s=t.apply(e.error);return s||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var me=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ye{match(e){return"string"==typeof e}coerce(e,t){var i,[s,r]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=r?r:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(me);return s&&(t=s[1],i=s[2]),[t,i]}}var be=["fatal","error","warning","log","info","debug"];function we(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(!(r.length>t))return s===i.length||r.length<=t?r:r.slice(0,t)+"..."}return""}class Ee{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return B(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+we(e)}isSeverityLevel(e){return O(e)&&!M(e)&&be.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Z(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class Se{match(e){return B(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+we(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class ke{match(e){return U(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class xe{match(e){return z(e,"PromiseRejectionEvent")}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return U(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){if(U(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var Pe=e=>{var t={_log:function(t){if(r&&(f.DEBUG||v.POSTHOG_DEBUG)&&!L(r.console)&&r.console){for(var i=("__rrweb_original__"in r.console[t]?r.console[t].__rrweb_original__:r.console[t]),s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];i(e,...n)}},info:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("log",...i)},warn:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("warn",...i)},error:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("error",...i)},critical:function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning:e=>{t.error("You must initialize PostHog before calling "+e)},createLogger:t=>Pe(e+" "+t)};return t},Ie=Pe("[PostHog.js]"),Ce=Ie.createLogger,Fe={};function Re(e,t,i){if(C(e))if(a&&e.forEach===a)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var s=0,r=e.length;s<r;s++)if(s in e&&t.call(i,e[s],s)===Fe)return}function Te(e,t,i){if(!D(e)){if(C(e))return Re(e,t,i);if(H(e)){for(var s of e.entries())if(t.call(i,s[1],s[0])===Fe)return}else for(var r in e)if(P.call(e,r)&&t.call(i,e[r],r)===Fe)return}}var $e=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return Re(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},Le=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return Re(i,(function(t){Re(t,(function(t){e.push(t)}))})),e};function Oe(e){for(var t=Object.keys(e),i=t.length,s=new Array(i);i--;)s[i]=[t[i],e[t[i]]];return s}var Me=function(e){try{return e()}catch(e){return}},Ae=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){Ie.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ie.critical(e)}}},De=function(e){var t={};return Te(e,(function(e,i){(O(e)&&e.length>0||N(e))&&(t[i]=e)})),t};function Ne(e,t){return i=e,s=e=>O(e)&&!A(t)?e.slice(0,t):e,r=new Set,function e(t,i){return t!==Object(t)?s?s(t,i):t:r.has(t)?void 0:(r.add(t),C(t)?(n=[],Re(t,(t=>{n.push(e(t))}))):(n={},Te(t,((t,i)=>{r.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,s,r}var qe=["herokuapp.com","vercel.app","netlify.app"];function He(e){var t=null==e?void 0:e.hostname;if(!O(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of qe)if(i===s)return!1;return!0}function je(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Ue(e,t,i,s){var{capture:r=!1,passive:n=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:r,passive:n})}var ze="$people_distinct_id",Be="__alias",Ve="__timers",We="$autocapture_disabled_server_side",Ge="$heatmaps_enabled_server_side",Ye="$exception_capture_enabled_server_side",Je="$error_tracking_suppression_rules",Ke="$error_tracking_capture_extension_exceptions",Xe="$web_vitals_enabled_server_side",Qe="$dead_clicks_enabled_server_side",Ze="$web_vitals_allowed_metrics",et="$session_recording_remote_config",tt="$sesid",it="$session_is_sampled",st="$enabled_feature_flags",rt="$early_access_features",nt="$feature_flag_details",ot="$stored_person_properties",at="$stored_group_properties",lt="$surveys",ct="$surveys_activated",ut="$flag_call_reported",dt="$user_state",_t="$client_session_props",ht="$capture_rate_limit",pt="$initial_campaign_params",gt="$initial_referrer_info",vt="$initial_person_info",ft="$epp",mt="__POSTHOG_TOOLBAR__",yt="$posthog_cookieless",bt=[ze,Be,"__cmpns",Ve,"$session_recording_enabled_server_side",Ge,tt,st,Je,dt,rt,nt,at,ot,lt,ut,_t,ht,pt,gt,ft,vt];function wt(e){return e instanceof Element&&(e.id===mt||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function Et(e){return!!e&&1===e.nodeType}function St(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function kt(e){return!!e&&3===e.nodeType}function xt(e){return!!e&&11===e.nodeType}function Pt(e){return e?E(e).split(/\s+/):[]}function It(e){var t=null==r?void 0:r.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Ct(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Pt(t)}function Ft(e){return D(e)?null:E(e).split(/(\s+)/).filter((e=>Gt(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Rt(e){var t="";return qt(e)&&!Ht(e)&&e.childNodes&&e.childNodes.length&&Te(e.childNodes,(function(e){var i;kt(e)&&e.textContent&&(t+=null!==(i=Ft(e.textContent))&&void 0!==i?i:"")})),E(t)}function Tt(e){return L(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var $t=["a","button","form","input","select","textarea","label"];function Lt(e,t){if(L(t))return!0;var i,s=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var r of e)if(i=s(r))return i.v;return!1}function Ot(e){var t=e.parentNode;return!(!t||!Et(t))&&t}var Mt=[".ph-no-rageclick",".ph-no-capture"];var At=e=>!e||St(e,"html")||!Et(e),Dt=(e,t)=>{if(!r||At(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],n=e;n.parentNode&&!St(n,"body");)if(xt(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=Ot(n);if(!o)break;if(t||$t.indexOf(o.tagName.toLowerCase())>-1)i=!0;else{var a=r.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}s.push(o),n=o}return{parentIsUsefulElement:i,targetElementList:s}};function Nt(e,t,i,s,n){var o,a,l,c;if(void 0===i&&(i=void 0),!r||At(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!It(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&It(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:d,targetElementList:_}=Dt(e,s);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(L(i))return!0;var s,r=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(s=r(n))return s.v;return!1}(_,i))return!1;if(!Lt(_,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var h=r.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var p=e.tagName.toLowerCase();switch(p){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return d?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&($t.indexOf(p)>-1||"true"===e.getAttribute("contenteditable"))}}function qt(e){for(var t=e;t.parentNode&&!St(t,"body");t=t.parentNode){var i=Ct(t);if(w(i,"ph-sensitive")||w(i,"ph-no-capture"))return!1}if(w(Ct(e),"ph-include"))return!0;var s=e.type||"";if(O(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(O(r)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function Ht(e){return!!(St(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||St(e,"select")||St(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var jt="(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})",Ut=new RegExp("^(?:"+jt+")$"),zt=new RegExp(jt),Bt="\\d{3}-?\\d{2}-?\\d{4}",Vt=new RegExp("^("+Bt+")$"),Wt=new RegExp("("+Bt+")");function Gt(e,t){if(void 0===t&&(t=!0),D(e))return!1;if(O(e)){if(e=E(e),(t?Ut:zt).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Vt:Wt).test(e))return!1}return!0}function Yt(e){var t=Rt(e);return Gt(t=(t+" "+Jt(e)).trim())?t:""}function Jt(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Te(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=Rt(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Jt(e)).trim())}catch(e){Ie.error("[AutoCapture]",e)}})),t}function Kt(e){return function(e){var t=e.map((e=>{var t,s,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+="."+n.replace(/"/g,"");var o=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(s=e.nth_of_type)&&void 0!==s?s:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return Oe(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[Xt(t.toString())]=Xt(i.toString())})),r+=":",r+=Oe(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,i,s={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Qt(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Oe(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return s.attributes[t]=i})),s}))}(e))}function Xt(e){return e.replace(/"|\\"/g,'\\"')}function Qt(e){var t=e.attr__class;return t?C(t)?t:Pt(t):void 0}class Zt{constructor(){this.clicks=[]}isRageClick(e,t,i){var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<30&&i-s.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:i}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var ei="$copy_autocapture",ti=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ii=e=>{var t=null==u?void 0:u.createElement("a");return L(t)?null:(t.href=e,t)},si=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return Te(e,(function(e,t){L(e)||L(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),r[r.length]=s+"="+i)})),r.join(t)},ri=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!C(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){Ie.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},ni=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[0]||"",n=s[1],o=r.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var _=c[d].split("=");C(_)&&(t.includes(_[0])?u.push(_[0]+"="+i):u.push(c[d]))}var h=l;return null!=a&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},oi=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},ai=Ce("[AutoCapture]");function li(e,t){return t.length>e?t.slice(0,e)+"...":t}function ci(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Et(t));return t}function ui(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};$t.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?n.$el_text=li(1024,Yt(e)):n.$el_text=li(1024,Rt(e)));var o=Ct(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),Te(e.attributes,(function(i){var r;if((!Ht(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==s||!s.includes(i.name))&&!t&&Gt(i.value)&&(r=i.name,!O(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Pt(o).join(" ")),n["attr__"+i.name]=li(1024,o)}}));for(var a=1,l=1,c=e;c=ci(c);)a++,c.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function di(e,t){for(var i,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!St(d,"body");)xt(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var _,h=[],p={},g=!1,v=!1;if(Te(u,(e=>{var t=qt(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&Gt(g)&&g),w(Ct(e),"ph-no-capture")&&(v=!0),h.push(ui(e,o,a,l));var i=function(e){if(!qt(e))return{};var t={};return Te(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&Gt(s)&&(t[i]=s)}})),t}(e);$e(p,i)})),v)return{props:{},explicitNoCapture:v};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=Yt(e):h[0].$el_text=Rt(e)),g){var f,m;h[0].attr__href=g;var y=null==(f=ii(g))?void 0:f.host,b=null==r||null==(m=r.location)?void 0:m.host;y&&b&&y!==b&&(_=g)}return{props:$e({$event_type:n.type,$ce_version:1},c?{}:{$elements:h},{$elements_chain:Kt(h)},null!=(i=h[0])&&i.$el_text?{$el_text:null==(s=h[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},p)}}class _i{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this.rageclicks=new Zt,this._elementsChainAsString=!1,this.instance=e,this._elementSelectors=null}get _config(){var e,t,i=R(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(r&&u){var e=e=>{e=e||(null==r?void 0:r.event);try{this._captureEvent(e)}catch(e){ai.error("Failed to capture event",e)}};if(Ue(u,"submit",e,{capture:!0}),Ue(u,"change",e,{capture:!0}),Ue(u,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==r?void 0:r.event),this._captureEvent(e,ei)};Ue(u,"copy",t,{capture:!0}),Ue(u,"cut",t,{capture:!0})}}}else ai.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[We]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var s=null==u?void 0:u.querySelectorAll(t);null==s||s.forEach((s=>{e===s&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[We],s=this._isDisabledServerSide;if(A(s)&&!q(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,s=Tt(e);if(kt(s)&&(s=s.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&function(e,t){if(!r||At(e))return!1;var i,s;if(!1===(i=q(t)?!!t&&Mt:null!==(s=null==t?void 0:t.css_selector_ignorelist)&&void 0!==s?s:Mt))return!1;var{targetElementList:n}=Dt(e,!1);return!Lt(n,i)}(s,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var n=t===ei;if(s&&Nt(s,e,this._config,n,n?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=di(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(a)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(o.$element_selectors=l),t===ei){var c,u=Ft(null==r||null==(c=r.getSelection())?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=d}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return F(null==u?void 0:u.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return N(e)&&isFinite(e)&&Math.floor(e)===e});var hi="0123456789abcdef";class pi{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,s){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||e<0||t<0||i<0||s<0||e>0xffffffffffff||t>4095||i>1073741823||s>4294967295)throw new RangeError("invalid field value");var r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=s>>>24,r[13]=s>>>16,r[14]=s>>>8,r[15]=s,new pi(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+hi.charAt(this.bytes[t]>>>4)+hi.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new pi(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class gi{constructor(){this._timestamp=0,this._counter=0,this._random=new mi}generate(){var e=this.generateOrAbort();if(L(e)){this._timestamp=0;var t=this.generateOrAbort();if(L(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(!(e+1e4>this._timestamp))return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return pi.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}}var vi,fi=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};r&&!L(r.crypto)&&crypto.getRandomValues&&(fi=e=>crypto.getRandomValues(e));class mi{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(fi(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var yi=()=>bi().toString(),bi=()=>(vi||(vi=new gi)).generate(),wi="";var Ei=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Si(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=u),wi)return wi;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+yi();!wi&&s--;){var n=i.slice(s).join("."),o=r+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(r)&&(t.cookie=o+";max-age=0",wi=n)}return wi}(e);if(!i){var s=(e=>{var t=e.match(Ei);return t?t[0]:""})(e);s!==i&&Ie.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}var ki={_is_supported:()=>!!u,_error:function(e){Ie.error("cookieStore error: "+e)},_get:function(e){if(u){try{for(var t=e+"=",i=u.cookie.split(";").filter((e=>e.length)),s=0;s<i.length;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}},_parse:function(e){var t;try{t=JSON.parse(ki._get(e))||{}}catch(e){}return t},_set:function(e,t,i,s,r){if(u)try{var n="",o="",a=Si(u.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&Ie.warn("cookieStore warning: large cookie, len="+c.length),u.cookie=c,c}catch(e){return}},_remove:function(e,t){if(null!=u&&u.cookie)try{ki._set(e,"",-1,t)}catch(e){return}}},xi=null,Pi={_is_supported:function(){if(!A(xi))return xi;var e=!0;if(L(r))e=!1;else try{var t="__mplssupport__";Pi._set(t,"xyz"),'"xyz"'!==Pi._get(t)&&(e=!1),Pi._remove(t)}catch(t){e=!1}return e||Ie.error("localStorage unsupported; falling back to cookie store"),xi=e,e},_error:function(e){Ie.error("localStorage error: "+e)},_get:function(e){try{return null==r?void 0:r.localStorage.getItem(e)}catch(e){Pi._error(e)}return null},_parse:function(e){try{return JSON.parse(Pi._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==r||r.localStorage.setItem(e,JSON.stringify(t))}catch(e){Pi._error(e)}},_remove:function(e){try{null==r||r.localStorage.removeItem(e)}catch(e){Pi._error(e)}}},Ii=["distinct_id",tt,it,ft,vt],Ci=i({},Pi,{_parse:function(e){try{var t={};try{t=ki._parse(e)||{}}catch(e){}var i=$e(t,JSON.parse(Pi._get(e)||"{}"));return Pi._set(e,i),i}catch(e){}return null},_set:function(e,t,i,s,r,n){try{Pi._set(e,t,void 0,void 0,n);var o={};Ii.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&ki._set(e,o,i,s,r,n)}catch(e){Pi._error(e)}},_remove:function(e,t){try{null==r||r.localStorage.removeItem(e),ki._remove(e,t)}catch(e){Pi._error(e)}}}),Fi={},Ri={_is_supported:function(){return!0},_error:function(e){Ie.error("memoryStorage error: "+e)},_get:function(e){return Fi[e]||null},_parse:function(e){return Fi[e]||null},_set:function(e,t){Fi[e]=t},_remove:function(e){delete Fi[e]}},Ti=null,$i={_is_supported:function(){if(!A(Ti))return Ti;if(Ti=!0,L(r))Ti=!1;else try{var e="__support__";$i._set(e,"xyz"),'"xyz"'!==$i._get(e)&&(Ti=!1),$i._remove(e)}catch(e){Ti=!1}return Ti},_error:function(e){Ie.error("sessionStorage error: ",e)},_get:function(e){try{return null==r?void 0:r.sessionStorage.getItem(e)}catch(e){$i._error(e)}return null},_parse:function(e){try{return JSON.parse($i._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==r||r.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){$i._error(e)}},_remove:function(e){try{null==r||r.sessionStorage.removeItem(e)}catch(e){$i._error(e)}}},Li=function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e}({});class Oi{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?Li.DENIED:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||(this.consent===Li.DENIED||this.consent===Li.PENDING&&(this._config.opt_out_capturing_by_default||"on_reject"===this._config.cookieless_mode))}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Li.DENIED}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){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 _storedConsent(){var e=this._storage._get(this._storageKey);return W(e)?Li.GRANTED:w(G,e)?Li.DENIED:Li.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?Pi:ki;var t="localStorage"===e?ki:Pi;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(W(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!je([null==c?void 0:c.doNotTrack,null==c?void 0:c.msDoNotTrack,v.doNotTrack],(e=>W(e)))}}var Mi=Ce("[Dead Clicks]"),Ai=()=>!0,Di=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Qe)),s=e.instance.config.capture_dead_clicks;return q(s)?s:i};class Ni{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Qe]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this._loadScript((()=>{this._start()}))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Mi.error("failed to load script",t):e()}))}_start(){var e;if(u){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=R(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(u),Mi.info("starting...")}}else Mi.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Mi.info("stopping..."))}}var qi=Ce("[ExceptionAutocapture]");class Hi{constructor(e){var t,i,s;this._startCapturing=()=>{var e;if(r&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){qi.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[Ye]),this._config=this._requiredConfig(),this._rateLimiter=new J({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10,refillInterval:1e4,_logger:qi}),this.startIfEnabled()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return R(e)?t=i({},t,e):(L(e)?this._remoteEnabled:e)&&(t=i({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(qi.info("enabled"),this._loadScript(this._startCapturing))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return qi.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this._remoteEnabled=!!t||!1,this._config=this._requiredConfig(),this._instance.persistence&&this._instance.persistence.register({[Ye]:this._remoteEnabled}),this.startIfEnabled()}captureException(e){var t,i,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?qi.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}}function ji(e,t,i){try{if(!(t in e))return()=>{};var s=e[t],r=i(s);return F(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=r,()=>{e[t]=s}}catch(e){return()=>{}}}class Ui{constructor(e){var t;this._instance=e,this._lastPathname=(null==r||null==(t=r.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Ie.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,Ie.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(r&&r.history){var i=this;null!=(e=r.history.pushState)&&e.__posthog_wrapped__||ji(r.history,"pushState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("pushState")})),null!=(t=r.history.replaceState)&&t.__posthog_wrapped__||ji(r.history,"replaceState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("replaceState")})),this._setupPopstateListener()}}_capturePageview(e){try{var t,i=null==r||null==(t=r.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this._lastPathname=i}catch(t){Ie.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Ue(r,"popstate",e),this._popstateListener=()=>{r&&r.removeEventListener("popstate",e)}}}}var zi=Ce("[SegmentIntegration]");function Bi(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var s=i=>{var s=()=>i.anonymousId()||yi();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(dt,"identified")),t()},r=i.user();"then"in r&&F(r.then)?r.then((e=>s(e))):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||zi.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(zi.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(zi.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var s=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},s,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}var Vi="posthog-js";function Wi(e,t){var{organization:s,projectId:r,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,c,u,d,_;if(!("*"===o||o.includes(t.level))||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(l=t.exception)?void 0:l.values)||[],g=p.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),v={$exception_message:(null==(c=p[0])?void 0:c.value)||t.message,$exception_type:null==(u=p[0])?void 0:u.type,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=p[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=p[0])?void 0:_.type,$sentry_tags:t.tags};return s&&r&&(v.$sentry_url=(n||"https://sentry.io/organizations/")+s+"/issues/?project="+r+"&query="+t.event_id),a&&e.exceptions.sendExceptionEvent(v),t}}class Gi{constructor(e,t,i,s,r,n){this.name=Vi,this.setupOnce=function(o){o(Wi(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}}var Yi=null!=r&&r.location?oi(r.location.hash,"__posthog")||oi(location.hash,"state"):null,Ji="_postHogToolbarParams",Ki=Ce("[Toolbar]"),Xi=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Xi||{});class Qi{constructor(e){this.instance=e}_setToolbarState(e){v.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=v.ph_toolbar_state)&&void 0!==e?e:Xi.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!r||!u)return!1;e=null!=e?e:r.location,i=null!=i?i:r.history;try{if(!t){try{r.localStorage.setItem("test","test"),r.localStorage.removeItem("test")}catch(e){return!1}t=null==r?void 0:r.localStorage}var s,n=Yi||oi(e.hash,"__posthog")||oi(e.hash,"state"),o=n?Me((()=>JSON.parse(atob(decodeURIComponent(n)))))||Me((()=>JSON.parse(decodeURIComponent(n)))):null;return o&&"ph_authorize"===o.action?((s=o).source="url",s&&Object.keys(s).length>0&&(o.desiredHash?e.hash=o.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(Ji)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch(e){return!1}}_callLoadToolbar(e){var t=v.ph_load_toolbar||v.ph_load_editor;!D(t)&&F(t)?t(e,this.instance):Ki.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==u||!u.getElementById(mt));if(!r||t)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(r.localStorage.setItem(Ji,JSON.stringify(i({},n,{source:void 0}))),this._getToolbarState()===Xi.LOADED)this._callLoadToolbar(n);else if(this._getToolbarState()===Xi.UNINITIALIZED){var o;this._setToolbarState(Xi.LOADING),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Ki.error("[Toolbar] Failed to load",e),void this._setToolbarState(Xi.UNINITIALIZED);this._setToolbarState(Xi.LOADED),this._callLoadToolbar(n)})),Ue(r,"turbolinks:load",(()=>{this._setToolbarState(Xi.UNINITIALIZED),this.loadToolbar(n)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Zi=Ce("[TracingHeaders]");class es{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t;L(this._restoreXHRPatch)&&(null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager));L(this._restoreFetchPatch)&&(null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Zi.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var ts="Mobile",is="iOS",ss="Android",rs="Tablet",ns=ss+" "+rs,os="iPad",as="Apple",ls=as+" Watch",cs="Safari",us="BlackBerry",ds="Samsung",_s=ds+"Browser",hs=ds+" Internet",ps="Chrome",gs=ps+" OS",vs=ps+" "+is,fs="Internet Explorer",ms=fs+" "+ts,ys="Opera",bs=ys+" Mini",ws="Edge",Es="Microsoft "+ws,Ss="Firefox",ks=Ss+" "+is,xs="Nintendo",Ps="PlayStation",Is="Xbox",Cs=ss+" "+ts,Fs=ts+" "+cs,Rs="Windows",Ts=Rs+" Phone",$s="Nokia",Ls="Ouya",Os="Generic",Ms=Os+" "+ts.toLowerCase(),As=Os+" "+rs.toLowerCase(),Ds="Konqueror",Ns="(\\d+(\\.\\d+)?)",qs=new RegExp("Version/"+Ns),Hs=new RegExp(Is,"i"),js=new RegExp(Ps+" \\w+","i"),Us=new RegExp(xs+" \\w+","i"),zs=new RegExp(us+"|PlayBook|BB10","i"),Bs={"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"};var Vs=(e,t)=>t&&w(t,as)||function(e){return w(e,cs)&&!w(e,ps)&&!w(e,ss)}(e),Ws=function(e,t){return t=t||"",w(e," OPR/")&&w(e,"Mini")?bs:w(e," OPR/")?ys:zs.test(e)?us:w(e,"IE"+ts)||w(e,"WPDesktop")?ms:w(e,_s)?hs:w(e,ws)||w(e,"Edg/")?Es:w(e,"FBIOS")?"Facebook "+ts:w(e,"UCWEB")||w(e,"UCBrowser")?"UC Browser":w(e,"CriOS")?vs:w(e,"CrMo")||w(e,ps)?ps:w(e,ss)&&w(e,cs)?Cs:w(e,"FxiOS")?ks:w(e.toLowerCase(),Ds.toLowerCase())?Ds:Vs(e,t)?w(e,ts)?Fs:cs:w(e,Ss)?Ss:w(e,"MSIE")||w(e,"Trident/")?fs:w(e,"Gecko")?Ss:""},Gs={[ms]:[new RegExp("rv:"+Ns)],[Es]:[new RegExp(ws+"?\\/"+Ns)],[ps]:[new RegExp("("+ps+"|CrMo)\\/"+Ns)],[vs]:[new RegExp("CriOS\\/"+Ns)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ns)],[cs]:[qs],[Fs]:[qs],[ys]:[new RegExp("(Opera|OPR)\\/"+Ns)],[Ss]:[new RegExp(Ss+"\\/"+Ns)],[ks]:[new RegExp("FxiOS\\/"+Ns)],[Ds]:[new RegExp("Konqueror[:/]?"+Ns,"i")],[us]:[new RegExp(us+" "+Ns),qs],[Cs]:[new RegExp("android\\s"+Ns,"i")],[hs]:[new RegExp(_s+"\\/"+Ns)],[fs]:[new RegExp("(rv:|MSIE )"+Ns)],Mozilla:[new RegExp("rv:"+Ns)]},Ys=function(e,t){var i=Ws(e,t),s=Gs[i];if(L(s))return null;for(var r=0;r<s.length;r++){var n=s[r],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},Js=[[new RegExp(Is+"; "+Is+" (.*?)[);]","i"),e=>[Is,e&&e[1]||""]],[new RegExp(xs,"i"),[xs,""]],[new RegExp(Ps,"i"),[Ps,""]],[zs,[us,""]],[new RegExp(Rs,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Ts,""];if(new RegExp(ts).test(t)&&!/IEMobile\b/.test(t))return[Rs+" "+ts,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=i[1],r=Bs[s]||"";return/arm/i.test(t)&&(r="RT"),[Rs,r]}return[Rs,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[is,t.join(".")]}return[is,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=L(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ss+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ss+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[ss,t.join(".")]}return[ss,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[gs,""]],[/Linux|debian/i,["Linux",""]]],Ks=function(e){return Us.test(e)?xs:js.test(e)?Ps:Hs.test(e)?Is:new RegExp(Ls,"i").test(e)?Ls:new RegExp("("+Ts+"|WPDesktop)","i").test(e)?Ts:/iPad/.test(e)?os:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ls:zs.test(e)?us:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp($s,"i").test(e)?$s:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(ts).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?ss:ns:ss:new RegExp("(pda|"+ts+")","i").test(e)?Ms:new RegExp(rs,"i").test(e)&&!new RegExp(rs+" pc","i").test(e)?As:""},Xs="https?://(.*)",Qs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Zs=Le(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Qs),er="<masked>",tr=["li_fat_id"];function ir(e,t,i){if(!u)return{};var s,r=t?Le([],Qs,i||[]):[],n=sr(ni(u.URL,r,er),e),o=(s={},Te(tr,(function(e){var t=ki._get(e);s[e]=t||null})),s);return $e(o,n)}function sr(e,t){var i=Zs.concat(t||[]),s={};return Te(i,(function(t){var i=ri(e,t);s[t]=i||null})),s}function rr(e){var t=function(e){return e?0===e.search(Xs+"google.([^/?]*)")?"google":0===e.search(Xs+"bing.com")?"bing":0===e.search(Xs+"yahoo.com")?"yahoo":0===e.search(Xs+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!A(t)){s.$search_engine=t;var r=u?ri(u.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function nr(){return navigator.language||navigator.userLanguage}function or(){return(null==u?void 0:u.referrer)||"$direct"}function ar(e,t){var i=e?Le([],Qs,t||[]):[],s=null==d?void 0:d.href.substring(0,1e3);return{r:or().substring(0,1e3),u:s?ni(s,i,er):void 0}}function lr(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=ii(i))?void 0:t.host};if(s){r.$current_url=s;var n=ii(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=sr(s);$e(r,o)}if(i){var a=rr(i);$e(r,a)}return r}function cr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function ur(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function dr(e,t){if(!g)return{};var i,s,n,o=e?Le([],Qs,t||[]):[],[a,l]=function(e){for(var t=0;t<Js.length;t++){var[i,s]=Js[t],r=i.exec(e),n=r&&(F(s)?s(r,e):s);if(n)return n}return["",""]}(g);return $e(De({$os:a,$os_version:l,$browser:Ws(g,navigator.vendor),$device:Ks(g),$device_type:(s=g,n=Ks(s),n===os||n===ns||"Kobo"===n||"Kindle Fire"===n||n===As?rs:n===xs||n===Is||n===Ps||n===Ls?"Console":n===ls?"Wearable":n?ts:"Desktop"),$timezone:cr(),$timezone_offset:ur()}),{$current_url:ni(null==d?void 0:d.href,o,er),$host:null==d?void 0:d.host,$pathname:null==d?void 0:d.pathname,$raw_user_agent:g.length>1e3?g.substring(0,997)+"...":g,$browser_version:Ys(g,navigator.vendor),$browser_language:nr(),$browser_language_prefix:(i=nr(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==r?void 0:r.screen.height,$screen_width:null==r?void 0:r.screen.width,$viewport_height:null==r?void 0:r.innerHeight,$viewport_width:null==r?void 0:r.innerWidth,$lib:"web",$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var _r=Ce("[Web Vitals]"),hr=9e5;class pr{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t,s=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(L(s))_r.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!L(r))if(D(null==e?void 0:e.name)||D(null==e?void 0:e.value))_r.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)_r.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),L(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=L(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this._buffer.metrics.push(i({},e,{$current_url:r,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}},this._startCapturing=()=>{var e,t,i,s,r=v.__PosthogExtensions__;L(r)||L(r.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:s}=r.postHogWebVitalsCallbacks),e&&t&&i&&s?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this)),this._initialized=!0):_r.error("web vitals callbacks not loaded - not starting")},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[Xe]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=R(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return L(i)?(null==(t=this._instance.persistence)?void 0:t.props[Ze])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(R(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=R(this._instance.config.capture_performance)&&N(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:hr;return 0<e&&e<=6e4?hr:e}get isEnabled(){var e=null==d?void 0:d.protocol;if("http:"!==e&&"https:"!==e)return _r.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=R(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:q(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return q(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(_r.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){var t=R(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=R(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xe]:t}),this._instance.persistence.register({[Ze]:i})),this._enabledServerSide=t,this.startIfEnabled()}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"web-vitals",(t=>{t?_r.error("failed to load script",t):e()}))}_currentURL(){var e=r?r.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?Le([],Qs,i||[]):[];return ni(e,s,er)}_r.error("Could not determine current URL")}}var gr=Ce("[Heatmaps]");function vr(e){return R(e)&&"clientX"in e&&"clientY"in e&&N(e.clientX)&&N(e.clientY)}class fr{constructor(e){var t;this.rageclicks=new Zt,this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[Ge])}get flushIntervalMilliseconds(){var e=5e3;return R(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 L(this.instance.config.capture_heatmaps)?L(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;gr.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ge]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(u)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){r&&u&&(this._flushHandler=this._flush.bind(this),Ue(r,"beforeunload",this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==r?void 0:r.event)),Ue(u,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==r?void 0:r.event)),Ue(u,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new Ni(this.instance,Ai,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabled(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Ue(u,"visibilitychange",this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;r&&u&&(this._flushHandler&&r.removeEventListener("beforeunload",this._flushHandler),this._onClickHandler&&u.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&u.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&u.removeEventListener("visibilitychange",this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(e,t,i){for(var s=e;s&&Et(s)&&!St(s,"body");){if(s===i)return!1;if(w(t,null==r?void 0:r.getComputedStyle(s).position))return!0;s=Ot(s)}return!1}(Tt(e),["fixed","sticky"],n);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:i),target_fixed:o,type:t}}_onClick(e,t){var s;if(void 0===t&&(t="click"),!wt(e.target)&&vr(e)){var r=this._getProperties(e,t);null!=(s=this.rageclicks)&&s.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(i({},r,{type:"rageclick"})),this._capture(r)}}_onMouseMove(e){!wt(e.target)&&vr(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(r){var t=r.location.href,i=this.instance.config.mask_personal_data_properties,s=this.instance.config.custom_personal_data_properties,n=i?Le([],Qs,s||[]):[],o=ni(t,n,er);this._buffer=this._buffer||{},this._buffer[o]||(this._buffer[o]=[]),this._buffer[o].push(e)}}_flush(){this._buffer&&!T(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class mr{constructor(e){this._instance=e}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==r?void 0:r.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=r;if(!(L(n)||L(o)||L(a)||L(l)||L(c)||L(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=n<=1?1:Y(o/n,0,1,Ie),_=n<=1?1:Y(a/n,0,1,Ie),h=l<=1?1:Y(c/l,0,1,Ie),p=l<=1?1:Y(u/l,0,1,Ie);s=$e(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}}var yr=Uint8Array,br=Uint16Array,wr=Uint32Array,Er=new yr([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]),Sr=new yr([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]),kr=new yr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xr=function(e,t){for(var i=new br(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var r=new wr(i[30]);for(s=1;s<30;++s)for(var n=i[s];n<i[s+1];++n)r[n]=n-i[s]<<5|s;return[i,r]},Pr=xr(Er,2),Ir=Pr[0],Cr=Pr[1];Ir[28]=258,Cr[258]=28;for(var Fr=xr(Sr,0)[1],Rr=new br(32768),Tr=0;Tr<32768;++Tr){var $r=(43690&Tr)>>>1|(21845&Tr)<<1;$r=(61680&($r=(52428&$r)>>>2|(13107&$r)<<2))>>>4|(3855&$r)<<4,Rr[Tr]=((65280&$r)>>>8|(255&$r)<<8)>>>1}var Lr=function(e,t,i){for(var s=e.length,r=0,n=new br(t);r<s;++r)++n[e[r]-1];var o,a=new br(t);for(r=0;r<t;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new br(1<<t);var l=15-t;for(r=0;r<s;++r)if(e[r])for(var c=r<<4|e[r],u=t-e[r],d=a[e[r]-1]++<<u,_=d|(1<<u)-1;d<=_;++d)o[Rr[d]>>>l]=c}else for(o=new br(s),r=0;r<s;++r)o[r]=Rr[a[e[r]-1]++]>>>15-e[r];return o},Or=new yr(288);for(Tr=0;Tr<144;++Tr)Or[Tr]=8;for(Tr=144;Tr<256;++Tr)Or[Tr]=9;for(Tr=256;Tr<280;++Tr)Or[Tr]=7;for(Tr=280;Tr<288;++Tr)Or[Tr]=8;var Mr=new yr(32);for(Tr=0;Tr<32;++Tr)Mr[Tr]=5;var Ar=Lr(Or,9,0),Dr=Lr(Mr,5,0),Nr=function(e){return(e/8>>0)+(7&e&&1)},qr=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof br?br:e instanceof wr?wr:yr)(i-t);return s.set(e.subarray(t,i)),s},Hr=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},jr=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8,e[s+2]|=i>>>16},Ur=function(e,t){for(var i=[],s=0;s<e.length;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new yr(0),0];if(1==r){var o=new yr(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var _=n[0].s;for(s=1;s<r;++s)n[s].s>_&&(_=n[s].s);var h=new br(_+1),p=zr(i[u-1],h,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s<r;++s){var m=n[s].s;if(!(h[m]>t))break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[s].s;h[y]<t?g-=1<<t-h[y]++-1:++s}for(;s>=0&&g;--s){var b=n[s].s;h[b]==t&&(--h[b],++g)}p=t}return[new yr(h),p]},zr=function(e,t,i){return-1==e.s?Math.max(zr(e.l,t,i+1),zr(e.r,t,i+1)):t[e.s]=i},Br=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new br(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},Vr=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Wr=function(e,t,i){var s=i.length,r=Nr(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;n<s;++n)e[r+n+4]=i[n];return 8*(r+4+s)},Gr=function(e,t,i,s,r,n,o,a,l,c,u){Hr(t,u++,i),++r[256];for(var d=Ur(r,15),_=d[0],h=d[1],p=Ur(n,15),g=p[0],v=p[1],f=Br(_),m=f[0],y=f[1],b=Br(g),w=b[0],E=b[1],S=new br(19),k=0;k<m.length;++k)S[31&m[k]]++;for(k=0;k<w.length;++k)S[31&w[k]]++;for(var x=Ur(S,7),P=x[0],I=x[1],C=19;C>4&&!P[kr[C-1]];--C);var F,R,T,L,O=c+5<<3,M=Vr(r,Or)+Vr(n,Mr)+o,A=Vr(r,_)+Vr(n,g)+o+14+3*C+Vr(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(O<=M&&O<=A)return Wr(t,u,e.subarray(l,l+c));if(Hr(t,u,1+(A<M)),u+=2,A<M){F=Lr(_,h,0),R=_,T=Lr(g,v,0),L=g;var D=Lr(P,I,0);Hr(t,u,y-257),Hr(t,u+5,E-1),Hr(t,u+10,C-4),u+=14;for(k=0;k<C;++k)Hr(t,u+3*k,P[kr[k]]);u+=3*C;for(var N=[m,w],q=0;q<2;++q){var H=N[q];for(k=0;k<H.length;++k){var j=31&H[k];Hr(t,u,D[j]),u+=P[j],j>15&&(Hr(t,u,H[k]>>>5&127),u+=H[k]>>>12)}}}else F=Ar,R=Or,T=Dr,L=Mr;for(k=0;k<a;++k)if(s[k]>255){j=s[k]>>>18&31;jr(t,u,F[j+257]),u+=R[j+257],j>7&&(Hr(t,u,s[k]>>>23&31),u+=Er[j]);var U=31&s[k];jr(t,u,T[U]),u+=L[U],U>3&&(jr(t,u,s[k]>>>5&8191),u+=Sr[U])}else jr(t,u,F[s[k]]),u+=R[s[k]];return jr(t,u,F[256]),u+R[256]},Yr=new wr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Jr=function(){for(var e=new wr(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Kr=function(e,t,i,s,r){return function(e,t,i,s,r,n){var o=e.length,a=new yr(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),c=0;if(!t||o<8)for(var u=0;u<=o;u+=65535){var d=u+65535;d<o?c=Wr(l,c,e.subarray(u,d)):(l[u]=n,c=Wr(l,c,e.subarray(u,o)))}else{for(var _=Yr[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new br(32768),f=new br(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new wr(25e3),E=new br(288),S=new br(32),k=0,x=0,P=(u=0,0),I=0,C=0;u<o;++u){var F=b(u),R=32767&u,T=f[F];if(v[R]=T,f[F]=R,I<=u){var L=o-u;if((k>7e3||P>24576)&&L>423){c=Gr(e,l,0,w,E,S,x,P,C,u-C,c),P=k=x=0,C=u;for(var O=0;O<286;++O)E[O]=0;for(O=0;O<30;++O)S[O]=0}var M=2,A=0,D=p,N=R-T&32767;if(L>2&&F==b(u-N))for(var q=Math.min(h,L)-1,H=Math.min(32767,u),j=Math.min(258,L);N<=H&&--D&&R!=T;){if(e[u+M]==e[u+M-N]){for(var U=0;U<j&&e[u+U]==e[u+U-N];++U);if(U>M){if(M=U,A=N,U>q)break;var z=Math.min(N,U-2),B=0;for(O=0;O<z;++O){var V=u-N+O+32768&32767,W=V-v[V]+32768&32767;W>B&&(B=W,T=V)}}}N+=(R=T)-(T=v[R])+32768&32767}if(A){w[P++]=268435456|Cr[M]<<18|Fr[A];var G=31&Cr[M],Y=31&Fr[A];x+=Er[G]+Sr[Y],++E[257+G],++S[Y],I=u+M,++k}else w[P++]=e[u],++E[e[u]]}}c=Gr(e,l,n,w,E,S,x,P,C,u-C,c)}return qr(a,0,s+Nr(c)+r)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,s,!0)},Xr=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Qr(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=Jr[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n=Kr(e,t,10+((r=t).filename&&r.filename.length+1||0),8),o=n.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Xr(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;s<=i.length;++s)e[s+10]=i.charCodeAt(s)}}(n,t),Xr(n,o-8,i.d()),Xr(n,o-4,s),n}var Zr=function(e){var t,i,s,r,n="";for(t=i=0,s=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,r=0;r<s;r++){var o=e.charCodeAt(r),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),A(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=r+1)}return i>t&&(n+=e.substring(t,e.length)),n},en=!!h||!!_,tn="text/plain",sn=function(e,t,s){var r;void 0===s&&(s=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(r=null==o?void 0:o.split("&").map((e=>{var t,[i,r]=e.split("="),n=s&&null!==(t=a[i])&&void 0!==t?t:r;return delete a[i],i+"="+n})))&&void 0!==r?r:[],c=si(a);return c&&l.push(c),n+"?"+l.join("&")},rn=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),nn=e=>{var{data:t,compression:i}=e;if(t){if(i===ti.GZipJS){var s=Qr(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new yr(e.length+(e.length>>>1)),r=0,n=function(e){s[r++]=e},o=0;o<i;++o){if(r+5>s.length){var a=new yr(r+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);l<128||t?n(l):l<2048?(n(192|l>>>6),n(128|63&l)):l>55295&&l<57344?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return qr(s,0,r)}(rn(t)),{mtime:0}),r=new Blob([s],{type:tn});return{contentType:tn,body:r,estimatedSize:r.size}}if(i===ti.Base64){var n=function(e){var t,i,s,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=Zr(e);do{t=(n=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=n>>12&63,s=n>>6&63,r=63&n,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(s)+o.charAt(r)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(rn(t)),o=(e=>"data="+encodeURIComponent("string"==typeof e?e:rn(e)))(n);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=rn(t);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},on=[];_&&on.push({transport:"fetch",method:e=>{var t,s,{contentType:r,body:n,estimatedSize:o}=null!==(t=nn(e))&&void 0!==t?t:{},a=new Headers;Te(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,c=null;if(p){var u=new p;c={signal:u.signal,timeout:setTimeout((()=>u.abort()),e.timeout)}}_(l,i({method:(null==e?void 0:e.method)||"GET",headers:a,keepalive:"POST"===e.method&&(o||0)<52428.8,body:n,signal:null==(s=c)?void 0:s.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){Ie.error(e)}null==e.callback||e.callback(s)})))).catch((t=>{Ie.error(t),null==e.callback||e.callback({statusCode:0,text:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}),h&&on.push({transport:"XHR",method:e=>{var t,i=new h;i.open(e.method||"GET",e.url,!0);var{contentType:s,body:r}=null!==(t=nn(e))&&void 0!==t?t:{};Te(e.headers,(function(e,t){i.setRequestHeader(t,e)})),s&&i.setRequestHeader("Content-Type",s),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(r)}}),null!=c&&c.sendBeacon&&on.push({transport:"sendBeacon",method:e=>{var t=sn(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=nn(e))&&void 0!==i?i:{},n="string"==typeof r?new Blob([r],{type:s}):r;c.sendBeacon(t,n)}catch(e){}}});var an=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};function ln(e,t,i){return rn({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var cn={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>an(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!an(t,e))))),icontains:(e,t)=>t.map(un).some((t=>e.map(un).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(un).every((t=>e.map(un).every((e=>!t.includes(e)))))},un=e=>e.toLowerCase(),dn=Ce("[Error tracking]");class _n{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new pe([new ge,new xe,new fe,new ve,new Se,new Ee,new ye,new ke],[ae,ue]),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Je))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,s,r=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(s=e.errorTracking)?void 0:s.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[Je]:this._suppressionRules,[Ke]:n})}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(Ke),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return void dn.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return void dn.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return void dn.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}_matchesSuppressionRule(e){if(0===e.length)return!1;var t=e.reduce(((e,t)=>{var{type:i,value:s}=t;return O(i)&&i.length>0&&e.$exception_types.push(i),O(s)&&s.length>0&&e.$exception_values.push(s),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i,s=cn[e.operator],r=C(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return r.length>0&&s(r,n)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}_isExtensionException(e){return e.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}_isPostHogException(e){if(e.length>0){var t,i,s,r,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(s=null==o||null==(r=o.filename)?void 0:r.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!D(e)&&C(e)}}var hn=Ce("[FeatureFlags]"),pn="$active_feature_flags",gn="$override_feature_flags",vn="$feature_flag_payloads",fn="$override_feature_flag_payloads",mn="$feature_flag_request_id",yn=e=>{var t={};for(var[i,s]of Oe(e||{}))s&&(t[i]=s);return t},bn=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):hn.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e},wn=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class En{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this._instance=e,this.featureFlagEventHandlers=[]}_getValidEvaluationEnvironments(){var e=this._instance.config.evaluation_environments;return null!=e&&e.length?e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||hn.error("Invalid evaluation environment found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}flags(){if(this._instance.config.__preview_remote_config)this._flagsCalled=!0;else{var e=!this._reloadDebouncer&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this._callFlagsEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(nt),t=this._instance.get_property(gn),s=this._instance.get_property(fn);if(!s&&!t)return e||{};var r=$e({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(var o of n){var a,l,c=r[o],u=null==t?void 0:t[o],d=L(u)?null!==(a=null==c?void 0:c.enabled)&&void 0!==a&&a:!!u,_=L(u)?c.variant:"string"==typeof u?u:void 0,h=null==s?void 0:s[o],p=i({},c,{enabled:d,variant:d?null!=_?_:null==c?void 0:c.variant:void 0});if(d!==(null==c?void 0:c.enabled)&&(p.original_enabled=null==c?void 0:c.enabled),_!==(null==c?void 0:c.variant)&&(p.original_variant=null==c?void 0:c.variant),h)p.metadata=i({},null==c?void 0:c.metadata,{payload:h,original_payload:null==c||null==(l=c.metadata)?void 0:l.payload});r[o]=p}return this._override_warning||(hn.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var e=this._instance.get_property(st),t=this._instance.get_property(gn);if(!t)return e||{};for(var i=$e({},e),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(hn.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._instance.get_property(vn),t=this._instance.get_property(fn);if(!t)return e||{};for(var i=$e({},e||{}),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(hn.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var s={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(ot)||{}),group_properties:this._instance.get_property(at)};(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(s.evaluation_environments=this._getValidEvaluationEnvironments());var r=this._instance.config.__preview_remote_config,n=r?"/flags/?v=2":"/flags/?v=2&config=true",o=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",a=this._instance.requestRouter.endpointFor("api",n+o);r&&(s.timezone=cr()),this._requestInFlight=!0,this._instance._send_request({method:"POST",url:a,data:s,compression:this._instance.config.disable_compression?void 0:ti.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r=!0;(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),r=!1),this._requestInFlight=!1,this._flagsCalled)||(this._flagsCalled=!0,this._instance._onRemoteConfig(null!==(i=e.json)&&void 0!==i?i:{}));if(!s.disable_flags||this._additionalReloadRequested)if(this._flagsLoadedFromRemote=!r,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(wn.FeatureFlags))hn.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 n;if(!s.disable_flags)this.receivedFeatureFlags(null!==(n=e.json)&&void 0!==n?n:{},r);this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants()[e],s=""+i,r=this._instance.get_property(mn)||void 0,n=this._instance.get_property(ut)||{};if((t.send_event||!("send_event"in t))&&(!(e in n)||!n[e].includes(s))){var o,a,l,c,u,d,_,h,p;C(n[e])?n[e].push(s):n[e]=[s],null==(o=this._instance.persistence)||o.register({[ut]:n});var g=this.getFeatureFlagDetails(e),v={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:r,$feature_flag_bootstrapped_response:(null==(a=this._instance.config.bootstrap)||null==(a=a.featureFlags)?void 0:a[e])||null,$feature_flag_bootstrapped_payload:(null==(l=this._instance.config.bootstrap)||null==(l=l.featureFlagPayloads)?void 0:l[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};L(null==g||null==(c=g.metadata)?void 0:c.version)||(v.$feature_flag_version=g.metadata.version);var f,m=null!==(u=null==g||null==(d=g.reason)?void 0:d.description)&&void 0!==u?u:null==g||null==(_=g.reason)?void 0:_.code;if(m&&(v.$feature_flag_reason=m),null!=g&&null!=(h=g.metadata)&&h.id&&(v.$feature_flag_id=g.metadata.id),L(null==g?void 0:g.original_variant)&&L(null==g?void 0:g.original_enabled)||(v.$feature_flag_original_response=L(g.original_variant)?g.original_enabled:g.original_variant),null!=g&&null!=(p=g.metadata)&&p.original_payload)v.$feature_flag_original_payload=null==g||null==(f=g.metadata)?void 0:f.original_payload;this._instance.capture("$feature_flag_called",v)}return i}hn.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._shouldIncludeEvaluationEnvironments()&&(s.evaluation_environments=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:s,compression:this._instance.config.disable_compression?void 0:ti.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var s,r=null==(s=i.json)?void 0:s.featureFlagPayloads;t((null==r?void 0:r[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return L(i)?void 0:!!i}hn.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._hasLoadedFlags=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(e,t,s,r,n){void 0===s&&(s={}),void 0===r&&(r={}),void 0===n&&(n={});var o=bn(e),a=o.flags,l=o.featureFlags,c=o.featureFlagPayloads;if(l){var u=e.requestId;if(C(l)){hn.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var d={};if(l)for(var _=0;_<l.length;_++)d[l[_]]=!0;t&&t.register({[pn]:l,[st]:d})}else{var h=l,p=c,g=a;e.errorsWhileComputingFlags&&(h=i({},s,h),p=i({},r,p),g=i({},n,g)),t&&t.register(i({[pn]:Object.keys(yn(h)),[st]:h||{},[vn]:p||{},[nt]:g||{}},u?{[mn]:u}:{}))}}}(e,this._instance.persistence,s,r,n),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),hn.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return hn.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(gn),this._instance.persistence.unregister(fn),void this._fireFeatureFlagsCallbacks();if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(gn);else if(i.flags)if(C(i.flags)){for(var s={},r=0;r<i.flags.length;r++)s[i.flags[r]]=!0;this._instance.persistence.register({[gn]:s})}else this._instance.persistence.register({[gn]:i.flags});return"payloads"in i&&(!1===i.payloads?this._instance.persistence.unregister(fn):i.payloads&&this._instance.persistence.register({[fn]:i.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var r,n=(this._instance.get_property(rt)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),s&&(a.$feature_enrollment_stage=s),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(r=this._instance.persistence)||r.register({[pn]:Object.keys(yn(l)),[st]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._instance.get_property(rt),r=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+r),method:"GET",callback:t=>{var i,s;if(t.json){var r=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(rt),null==(s=this._instance.persistence)||s.register({[rt]:r}),e(r)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(ot)||{};this._instance.register({[ot]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(ot)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(at)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((t=>{s[t]=i({},s[t],e[t]),delete e[t]})),this._instance.register({[at]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(at)||{};this._instance.register({[at]:i({},t,{[e]:{}})})}else this._instance.unregister(at)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}var Sn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class kn{constructor(e,t){this._config=e,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this.load(),e.debug&&Ie.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Sn.indexOf(e.persistence.toLowerCase())&&(Ie.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&Pi._is_supported()?Pi:"localstorage+cookie"===t&&Ci._is_supported()?Ci:"sessionstorage"===t&&$i._is_supported()?$i:"memory"===t?Ri:"cookie"===t?ki:Ci._is_supported()?Ci:ki}properties(){var e={};return Te(this.props,(function(t,i){if(i===st&&R(t))for(var s=Object.keys(t),r=0;r<s.length;r++)e["$feature/"+s[r]]=t[s[r]];else o=i,a=!1,(A(n=bt)?a:l&&n.indexOf===l?-1!=n.indexOf(o):(Te(n,(function(e){if(a||(a=e===o))return Fe})),a))||(e[i]=t);var n,o,a})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=$e({},e))}}save(){this._disabled||this._storage._set(this._name,this.props,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)}remove(){this._storage._remove(this._name,!1),this._storage._remove(this._name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(R(e)){L(t)&&(t="None"),this._expire_days=L(i)?this._default_expiry:i;var s=!1;if(Te(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(R(e)){this._expire_days=L(t)?this._default_expiry:t;var i=!1;if(Te(e,((t,s)=>{e.hasOwnProperty(s)&&this.props[s]!==t&&(this.props[s]=t,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._campaign_params_saved){var e=ir(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);T(De(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==u?void 0:u.referrer)?rr(e):{})}update_referrer_info(){var e;this.register_once({$referrer:or(),$referring_domain:null!=u&&u.referrer&&(null==(e=ii(u.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[pt]||this.props[gt]||this.register_once({[vt]:ar(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Te([gt,pt],(t=>{var i=this.props[t];i&&Te(i,(function(t,i){e["$initial_"+S(i)]=t}))}));var t,i,s=this.props[vt];if(s){var r=(t=lr(s),i={},Te(t,(function(e,t){i["$initial_"+S(t)]=e})),i);$e(e,r)}return e}safe_merge(e){return Te(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this._default_expiry=this._expire_days=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){var s=this._buildStorage(e),r=this.props;this.clear(),this._storage=s,this.props=r,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove(),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[Ve]||{};i[e]=t,this.props[Ve]=i,this.save()}remove_event_timer(e){var t=(this.props[Ve]||{})[e];return L(t)||(delete this.props[Ve][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var xn=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({}),Pn=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e}({}),In=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e}({}),Cn=function(e){return e.Popover="popover",e.Inline="inline",e}({});class Fn{constructor(){this._events={},this._events={}}on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var s of this._events["*"]||[])s(e,t)}}class Rn{constructor(e){this._debugEventEmitter=new Fn,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e;if(!L(null==(e=this._instance)?void 0:e._addCaptureHook)){var t;null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!L(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var s,r=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&r.add(null==e?void 0:e.selector)}))})),null==(s=this._instance)||s.autocapture.setElementSelectors(r)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(null==t?void 0:t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&this._actionRegistry.forEach((e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,s=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!Rn._matchString(s,null==t?void 0:t.url,(null==t?void 0:t.url_matching)||"contains"))return!1}return!0}static _matchString(e,t,i){switch(i){case"regex":return!!r&&an(e,t);case"exact":return t===e;case"contains":var s=Rn._escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return an(e,s);default:return!1}}static _escapeStringRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}_checkStepElement(e,t){if((null!=t&&t.href||null!=t&&t.tag_name||null!=t&&t.text)&&!this._getElementsList(e).some((e=>!(null!=t&&t.href&&!Rn._matchString(e.href||"",null==t?void 0:t.href,(null==t?void 0:t.href_matching)||"exact"))&&((null==t||!t.tag_name||e.tag_name===(null==t?void 0:t.tag_name))&&!(null!=t&&t.text&&!Rn._matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!Rn._matchString(e.$el_text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact"))))))return!1;if(null!=t&&t.selector){var i,s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(!s)return!1;if(!s.includes(null==t?void 0:t.selector))return!1}return!0}_getElementsList(e){return null==(null==e?void 0:e.properties.$elements)?[]:null==e?void 0:e.properties.$elements}}var Tn=Ce("[Surveys]");var $n="seenSurvey_",Ln=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},On=e=>{var t=""+$n+e.id;return e.current_iteration&&e.current_iteration>0&&(t=""+$n+e.id+"_"+e.current_iteration),t},Mn=[xn.Popover,xn.Widget,xn.API],An={ignoreConditions:!1,ignoreDelay:!1,displayType:Cn.Popover};class Dn{constructor(e){this._instance=e,this._eventToSurveys=new Map,this._actionToSurveys=new Map}register(e){var t;L(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedSurveys(e),this._setupActionBasedSurveys(e))}_setupActionBasedSurveys(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));if(0!==t.length){if(null==this._actionMatcher){this._actionMatcher=new Rn(this._instance),this._actionMatcher.init();this._actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,s,r,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(s=e.conditions)||null==(s=s.actions)||null==(s=s.values)?void 0:s.length)>0&&(null==(r=this._actionMatcher)||r.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToSurveys.get(t.name);i&&i.push(e.id),this._actionToSurveys.set(t.name,i||[e.id])}})))}))}}_setupEventBasedSurveys(e){var t;if(0!==e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})).length){null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t;null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||t.forEach((t=>{if(t&&t.name){var i=this._eventToSurveys.get(t.name);i&&i.push(e.id),this._eventToSurveys.set(t.name,i||[e.id])}}))}))}}onEvent(e,t){var i,s,r=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[ct])||[];if(Pn.SHOWN===e&&t&&r.length>0){var n;Tn.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:t,existingActivatedSurveys:r});var o=null==t||null==(n=t.properties)?void 0:n.$survey_id;if(o){var a=r.indexOf(o);a>=0&&(r.splice(a,1),this._updateActivatedSurveys(r))}}else if(this._eventToSurveys.has(e)){Tn.info("survey event name matched",{event:e,eventPayload:t,surveys:this._eventToSurveys.get(e)});var l=[];null==(s=this._instance)||s.getSurveys((t=>{l=t.filter((t=>{var i;return null==(i=this._eventToSurveys.get(e))?void 0:i.includes(t.id)}))}));var c=l.filter((i=>{var s,r=null==(s=i.conditions)||null==(s=s.events)||null==(s=s.values)?void 0:s.find((t=>t.name===e));return!!r&&(!r.propertyFilters||Object.entries(r.propertyFilters).every((e=>{var i,[s,r]=e,n=null==t||null==(i=t.properties)?void 0:i[s];if(L(n)||A(n))return!1;var o=[String(n)],a=cn[r.operator];return a?a(r.values,o):(Tn.warn("Unknown property comparison operator: "+r.operator),!1)})))}));this._updateActivatedSurveys(r.concat(c.map((e=>e.id))||[]))}}onAction(e){var t,i=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[ct])||[];this._actionToSurveys.has(e)&&this._updateActivatedSurveys(i.concat(this._actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t;Tn.info("updating activated surveys",{activatedSurveys:e}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[ct]:[...new Set(e)]})}getSurveys(){var e,t=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[ct];return t||[]}getEventToSurveys(){return this._eventToSurveys}_getActionMatcher(){return this._actionMatcher}}class Nn{constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isFetchingSurveys=!1,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(D(t))return Tn.warn("Flags not loaded yet. Not loading surveys.");var i=C(t);this._isSurveysEnabled=i?t.length>0:t,Tn.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(null!=i&&i.startsWith($n)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Tn.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Tn.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Tn.info("Not loading surveys in cookieless mode without consent.");else{var e=null==v?void 0:v.__PosthogExtensions__;if(e){if(!L(this._isSurveysEnabled)||this._instance.config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._instance.config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var s=e.loadExternalDependency;if(!s)return void this._handleSurveyLoadError("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else Tn.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Dn(this._instance),Tn.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){Tn.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter((t=>t!==e))}}getSurveys(e,t){if(void 0===t&&(t=!1),this._instance.config.disable_surveys)return Tn.info("Disabled. Not loading surveys."),e([]);var i=this._instance.get_property(lt);if(i&&!t)return e(i,{isLoaded:!0});if(this._isFetchingSurveys)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this._isFetchingSurveys=!0,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:t=>{var i;this._isFetchingSurveys=!1;var s=t.statusCode;if(200!==s||!t.json){var r="Surveys API could not be loaded, status: "+s;return Tn.error(r),e([],{isLoaded:!1,error:r})}var n,o=t.json.surveys||[],a=o.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));a.length>0&&(null==(n=this._surveyEventReceiver)||n.register(a));return null==(i=this._instance.persistence)||i.register({[lt]:o}),e(o,{isLoaded:!0})}})}catch(e){throw this._isFetchingSurveys=!1,e}}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Tn.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!D(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Tn.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var s;t=null!==(s=i.find((t=>t.id===e)))&&void 0!==s?s:null})),t}_checkSurveyEligibility(e){if(D(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(D(this._surveyManager))return Tn.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return D(this._surveyManager)?(Tn.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((t=>{var s,r=null!==(s=t.find((t=>t.id===e)))&&void 0!==s?s:null;if(r){var n=this._checkSurveyEligibility(r);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t){var i;if(D(this._surveyManager))Tn.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(Mn.includes(s.type)){var r=null==u?void 0:u.querySelector(t);if(r)return null!=(i=s.appearance)&&i.surveyPopupDelaySeconds?(Tn.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;Tn.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,r),Tn.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,r);Tn.warn("Survey element not found")}else Tn.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Tn.warn("Survey not found")}}displaySurvey(e,t){var s;if(D(this._surveyManager))Tn.warn("init was not called");else{var r=this._getSurveyById(e);if(r){var n=r;if(null!=(s=r.appearance)&&s.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},r,{appearance:i({},r.appearance,{surveyPopupDelaySeconds:0})})),!1===t.ignoreConditions){var o=this.canRenderSurvey(r);if(!o.visible)return void Tn.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==Cn.Inline?this._surveyManager.handlePopoverSurvey(n):this.renderSurvey(n,t.selector)}else Tn.warn("Survey not found")}}}var qn=Ce("[RateLimiter]");class Hn{constructor(e){var t,i;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{qn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void qn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.captureEventsPerSecond=(null==(t=e.config.rate_limiting)?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null==(i=e.config.rate_limiting)?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var r=(new Date).getTime(),n=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(ht))&&void 0!==t?t:{tokens:this.captureEventsBurstLimit,last:r};n.tokens+=(r-n.last)/1e3*this.captureEventsPerSecond,n.last=r,n.tokens>this.captureEventsBurstLimit&&(n.tokens=this.captureEventsBurstLimit);var o=n.tokens<1;return o||e||(n.tokens=Math.max(0,n.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,null==(s=this.instance.persistence)||s.set_property(ht,n),{isRateLimited:o,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var jn=Ce("[RemoteConfig]");class Un{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(jn.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(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 jn.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void jn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return jn.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e)}));this._onRemoteConfig(e)}))}catch(e){jn.error("Error loading remote config",e)}}_onRemoteConfig(e){e?this._instance.config.__preview_remote_config?(this._instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):jn.info("__preview_remote_config is disabled. Logging config instead",e):jn.error("Failed to fetch remote config from PostHog.")}}var zn=3e3;class Bn{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Y((null==t?void 0:t.flush_interval_ms)||zn,250,5e3,Ie.createLogger("flush interval"),zn),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequest(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[s],r=(new Date).getTime();i.data&&C(i.data)&&Te(i.data,(e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp})),e._sendRequest(i)};for(var s in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Te(this._queue,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;L(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)})),this._queue=[],e}}var Vn=["retriesPerformedSoFar"];class Wn{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!L(r)&&"onLine"in r.navigator&&(this._areWeOnline=r.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Ue(r,"online",this._onlineListener),Ue(r,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=s(e,Vn);N(t)&&t>0&&(r.url=sn(r.url,{retry_count:t})),this._instance._send_request(i({},r,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this._enqueue(i({retriesPerformedSoFar:t},r)):null==r.callback||r.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(t),s=Date.now()+i;this._queue.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),Ie.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var{requestOptions:s}of i)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,L(r)||(this._onlineListener&&(r.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(r.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){Ie.error(e)}this._queue=[]}}class Gn{constructor(e){this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)},this._instance=e}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Ue(r,"scroll",this._updateScrollData,{capture:!0}),Ue(r,"scrollend",this._updateScrollData,{capture:!0}),Ue(r,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==r?void 0:r.document.documentElement;var e=C(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=null==r?void 0:r.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 r&&(r.scrollY||r.pageYOffset||r.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return r&&(r.scrollX||r.pageXOffset||r.document.documentElement.scrollLeft)||0}}var Yn=e=>ar(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Jn{constructor(e,t,i,s){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[_t]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Yn,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[_t]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?lr(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 Te(De(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+S(i)]=t})),e}}var Kn=Ce("[SessionId]");class Xn{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._eventEmitter=new Fn,this._sessionHasBeenIdleTooLong=(e,t)=>Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||yi,this._windowIdGenerator=i||yi;var r=this._config.persistence_name||this._config.token,n=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Y(n,60,36e3,Kn.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var o=$i._parse(this._window_id_storage_key),a=$i._parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:$i._remove(this._window_id_storage_key),$i._set(this._primary_window_exists_storage_key,!0)}if(null!=(s=this._config.bootstrap)&&s.sessionID)try{var l=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this._config.bootstrap.sessionID);this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),l)}catch(e){Kn.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return L(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&$i._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&$i._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?$i._parse(this._window_id_storage_key):null}_setSessionId(e,t,i){e===this._sessionId&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,this._persistence.register({[tt]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this._persistence.props[tt];return C(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}destroy(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&r&&(r.removeEventListener("beforeunload",this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._canUseSessionStorage()&&$i._remove(this._primary_window_exists_storage_key)},Ue(r,"beforeunload",this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[s,r,n]=this._getSessionId(),o=this._getWindowId(),a=N(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,c=!r,u=!c&&!e&&this._sessionHasBeenIdleTooLong(i,s);c||u||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),Kn.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=0===s||!e||a?i:s,_=0===n?(new Date).getTime():n;return this._setWindowId(o),this._setSessionId(r,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:s}}_resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{var[e]=this._getSessionId();if(this._sessionHasBeenIdleTooLong((new Date).getTime(),e)){var t=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}}var Qn=["$set_once","$set"],Zn=Ce("[SiteApps]");class eo{constructor(e){this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,r,n,o,a,l,c;if(!e)throw new Error("Event payload is required");var u={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))u[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},s(e,Qn),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(r=e.properties)?void 0:r.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(o=e.properties)?void 0:o.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(a=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(c=e.properties)?void 0:c.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this._bufferedInvocations.length&&(Zn.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>null==t.processEvent?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored)))&&(null==(i=this._stopBuffering)||i.call(this))},s=!1,r=r=>{t.errored=!r,t.loaded=!0,Zn.info("Site app with id "+e.id+" "+(r?"loaded":"errored")),s&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback:e=>{r(e)}});n&&(t.processEvent=n),s=!0}catch(t){Zn.error("Error while initializing PostHog app with config id "+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){Zn.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){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)}_onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(t){Zn.error("Error while processing event "+e.event+" for site app "+i.id,t)}}}onRemoteConfig(e){var t,i,s,r=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void Zn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(s=e.siteApps)&&s.length)if(this.isEnabled){var n=function(e){var t;v["__$$ph_site_app_"+e]=r._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(r._instance,a,(t=>{if(t)return Zn.error("Error while initializing PostHog app with config id "+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else Zn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var to=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&y(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>y(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},io=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),so="i.posthog.com";class ro{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+so,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=io.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=io.EU:this._regionCache[this.apiHost]=io.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if(this.region===io.CUSTOM)return this.apiHost+t;var i=so+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var no={icontains:(e,t)=>!!r&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!r&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!r&&an(t.href,e),not_regex:(e,t)=>!!r&&!an(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class oo{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{oo._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)oo._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e);var s=t._instance.getFeatureFlag(e.feature_flag_key);O(s)&&e.variants[s]&&t._applyTransforms(e.name,s,e.variants[s].transforms)}else if(e.variants)for(var r in e.variants){var n=e.variants[r];oo._matchesTestVariant(n)&&t._applyTransforms(e.name,r,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())oo._logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(D(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();oo._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,s=this._instance.getFeatureFlag(e),r=null==(i=this._flagToExperiments)?void 0:i.get(e);s&&null!=r&&r.variants[s]&&this._applyTransforms(r.name,s,r.variants[s].transforms)}}))}}previewWebExperiment(){var e=oo.getWindowLocation();if(null!=e&&e.search){var t=ri(null==e?void 0:e.search,"__experiment_id"),i=ri(null==e?void 0:e.search,"__experiment_variant");t&&i&&(oo._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!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:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}_showPreviewWebExperiment(e,t,i){var s=i.filter((t=>t.id===e));s&&s.length>0&&(oo._logInfo("Previewing web experiment ["+s[0].name+"] with variant ["+t+"]"),this._applyTransforms(s[0].name,t,s[0].variants[t].transforms))}static _matchesTestVariant(e){return!D(e.conditions)&&(oo._matchUrlConditions(e)&&oo._matchUTMConditions(e))}static _matchUrlConditions(e){var t;if(D(e.conditions)||D(null==(t=e.conditions)?void 0:t.url))return!0;var i,s,r,n=oo.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||no[null!==(s=null==(r=e.conditions)?void 0:r.urlMatchType)&&void 0!==s?s:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==r?void 0:r.location}static _matchUTMConditions(e){var t;if(D(e.conditions)||D(null==(t=e.conditions)?void 0:t.utm))return!0;var i=ir();if(i.utm_source){var s,r,n,o,a,l,c,u,d=null==(s=e.conditions)||null==(s=s.utm)||!s.utm_campaign||(null==(r=e.conditions)||null==(r=r.utm)?void 0:r.utm_campaign)==i.utm_campaign,_=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,h=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return d&&h&&p&&_}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];Ie.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?oo._logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var s;oo._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var r=null==(s=document)?void 0:s.querySelectorAll(i.selector);null==r||r.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):oo._logInfo("Control variants leave the page unmodified.")}_is_bot(){return c&&this._instance?to(c,this._instance.config.custom_blocked_useragents):void 0}}var ao=Ce("[PostHog ExternalIntegrations]"),lo={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class co{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return ao.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,r,n;(!s||null!=(i=v.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(lo[t],(()=>{var i;null==(i=v.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!s&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[t])&&(null==(n=v.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,s]of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;t(i)}}}var uo="[SessionRecording]",_o=Ce(uo);class ho{get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){return this._lazyLoadedSessionRecording?this._lazyLoadedSessionRecording.status:this._receivedFlags&&!this._isRecordingEnabled?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._receivedFlags=!1,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw _o.error("started without valid sessionManager"),new Error(uo+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(uo+' cannot be used with cookieless_mode="always"')}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(et))||!e.enabled),i=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return r&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!L(Object.assign)&&!L(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),_o.info("starting")):this.stopRecording()}}_lazyLoadAndStart(e){var t,i,s;this._isRecordingEnabled&&(null!=v&&null!=(t=v.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(s=v.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return _o.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(it)}_persistRemoteConfig(e){if(this._instance.persistence){var t,s,r=this._instance.persistence,n=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,s=null==t?void 0:t.sampleRate,n=D(s)?null:parseFloat(s);D(n)&&this._resetSampling();var o=null==t?void 0:t.minimumDurationMilliseconds;r.register({[et]:i({enabled:!!t},t,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:n,minimumDurationMilliseconds:L(o)?null:o,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(s=this._instance.sessionManager)?void 0:s.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this._persistRemoteConfig(e),this._receivedFlags=!0,this.startIfEnabledOrStop()):this._receivedFlags=!0:_o.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):_o.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(et);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_onScriptLoaded(e){var t,i;if(null==(t=v.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=v.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture);this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e;null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e;null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t;null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}var po={},go=()=>{},vo="posthog",fo=!en&&-1===(null==g?void 0:g.indexOf("MSIE"))&&-1===(null==g?void 0:g.indexOf("Mozilla")),mo=e=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:He(null==u?void 0:u.location),persistence:"localStorage+cookie",persistence_name:"",loaded:go,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:"2025-05-24"!==e||"history_change",capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",debug:d&&O(null==d?void 0:d.search)&&-1!==d.search.indexOf("__posthog_debug=true")||!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_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==r||null==(t=r.location)?void 0:t.protocol),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,session_recording:{},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:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;Ie.error(t)},get_device_id:e=>e,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:zn},error_tracking:{},_onCapture:go,__preview_eager_load_replay:!1}},yo=e=>{var t={};L(e.process_person)||(t.person_profiles=e.process_person),L(e.xhr_headers)||(t.request_headers=e.xhr_headers),L(e.cookie_name)||(t.persistence_name=e.cookie_name),L(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),L(e.store_google)||(t.save_campaign_params=e.store_google),L(e.verbose)||(t.debug=e.verbose);var i=$e({},t,e);return C(e.property_blacklist)&&(L(e.property_denylist)?i.property_denylist=e.property_blacklist:C(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ie.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class bo{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Ie.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class wo{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new bo,this._personProcessingSetOncePropertiesSent=!1,this.version=f.LIB_VERSION,this._internalEventEmitter=new Fn,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=mo(),this.SentryIntegration=Gi,this.sentryIntegration=e=>function(e,t){var i=Wi(e,t);return{name:Vi,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.featureFlags=new En(this),this.toolbar=new Qi(this),this.scrollManager=new Gn(this),this.pageViewManager=new mr(this),this.surveys=new Nn(this),this.experiments=new oo(this),this.exceptions=new _n(this),this.rateLimiter=new Hn(this),this.requestRouter=new ro(this),this.consent=new Oi(this),this.externalIntegrations=new co(this),this.people={set:(e,t,i)=>{var s=O(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=O(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>Ie.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==vo){var s,r=null!==(s=po[i])&&void 0!==s?s:new wo;return r._init(e,t,i),po[i]=r,po[vo][i]=r,r}return this._init(e,t,i)}_init(e,t,s){var n,o;if(void 0===t&&(t={}),L(e)||M(e))return Ie.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._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles&&(this._initialPersonProfilesConfig=t.person_profiles),this.set_config($e({},mo(t.defaults),yo(t),{name:s,token:e})),this.config.on_xhr_error&&Ie.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ti.GZipJS;var a=this._is_persistence_disabled();this.persistence=new kn(this.config,a),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new kn(i({},this.config,{persistence:"sessionStorage"}),a);var l=i({},this.persistence.props),c=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Bn((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Wn(this),this.__request_queue=[];var u="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(u||(this.sessionManager=new Xn(this),this.sessionPropsManager=new Jn(this,this.sessionManager,this.persistence)),new es(this).startIfEnabledOrStop(),this.siteApps=new eo(this),null==(n=this.siteApps)||n.init(),u||(this.sessionRecording=new ho(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new _i(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new fr(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new pr(this),this.exceptionObserver=new Hi(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Ni(this,Di),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new Ui(this),this.historyAutocapture.startIfEnabled(),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&Ie.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:c}),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var d,_,h=this.config.get_device_id(yi()),p=null!=(d=t.bootstrap)&&d.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(dt,null!=(_=t.bootstrap)&&_.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:p})}if(this._hasBootstrappedFeatureFlags()){var g,v,m=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlags)||{}).filter((e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])})).reduce(((e,i)=>{var s;return e[i]=(null==(s=t.bootstrap)||null==(s=s.featureFlags)?void 0:s[i])||!1,e}),{}),y=Object.keys((null==(v=t.bootstrap)?void 0:v.featureFlagPayloads)||{}).filter((e=>m[e])).reduce(((e,i)=>{var s,r;null!=(s=t.bootstrap)&&null!=(s=s.featureFlagPayloads)&&s[i]&&(e[i]=null==(r=t.bootstrap)||null==(r=r.featureFlagPayloads)?void 0:r[i]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:m,featureFlagPayloads:y})}if(u)this.register_once({distinct_id:yt,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(yi());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(dt,"anonymous")}return Ue(r,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Bi(this,(()=>this._loaded())):this._loaded(),F(this.config._onCapture)&&this.config._onCapture!==go&&(Ie.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&Ie.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}_onRemoteConfig(e){var t,i,s,r,n,o,a,l;if(!u||!u.body)return Ie.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=w(e.supportedCompression,ti.GZipJS)?ti.GZipJS:w(e.supportedCompression,ti.Base64)?ti.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(s=this.sessionRecording)||s.onRemoteConfig(e),null==(r=this.autocapture)||r.onRemoteConfig(e),null==(n=this.heatmaps)||n.onRemoteConfig(e),this.surveys.onRemoteConfig(e),null==(o=this.webVitalsAutocapture)||o.onRemoteConfig(e),null==(a=this.exceptionObserver)||a.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(l=this.deadClicksAutocapture)||l.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){Ie.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this._captureInitialPageview()}),1),new Un(this).load(),this.featureFlags.flags()}_start_queue_if_opted_in(){var e;this.is_capturing()&&(this.config.request_batching&&(null==(e=this._requestQueue)||e.enable()))}_dom_loaded(){this.is_capturing()&&Re(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),null==(e=this._requestQueue)||e.unload(),null==(t=this._retryQueue)||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(fo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=sn(e.url,{ip:this.config.ip?1:0}),e.headers=i({},this.config.request_headers),e.compression="best-available"===e.compression?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,(e=>{var t,s,r,n=i({},e);n.timeout=n.timeout||6e4,n.url=sn(n.url,{_:(new Date).getTime().toString(),ver:f.LIB_VERSION,compression:n.compression});var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=on.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(s=null==(r=je(a,(e=>e.transport===o)))?void 0:r.method)&&void 0!==s?s:a[0].method;if(!l)throw new Error("No available transport method");l(n)})(i({},e,{callback:t=>{var i,s;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null==(i=(s=this.config).on_request_error)||i.call(s,t));null==e.callback||e.callback(t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],s=[],r=[];Re(e,(e=>{e&&(t=e[0],C(t)?r.push(e):F(e)?e.call(this):C(e)&&"alias"===t?i.push(e):C(e)&&-1!==t.indexOf("capture")&&F(this[t])?r.push(e):s.push(e))}));var n=function(e,t){Re(e,(function(e){if(C(e[0])){var i=t;Te(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};n(i,this),n(s,this),n(r,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,s){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!L(e)&&O(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(n&&!this.config.__preview_capture_bot_pageviews)){var o=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==o||!o.isRateLimited){null!=t&&t.$current_url&&!O(null==t?void 0:t.$current_url)&&(Ie.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=(null==s?void 0:s.timestamp)||a,c=yi(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&n&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),(null==s?void 0:s.$set)&&(u.$set=null==s?void 0:s.$set);var d,_=this._calculate_set_once_properties(null==s?void 0:s.$set_once);if(_&&(u.$set_once=_),(u=Ne(u,null!=s&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,L(null==s?void 0:s.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===Pn.DISMISSED||e===Pn.SENT){var h=null==t?void 0:t[In.SURVEY_ID],p=null==t?void 0:t[In.SURVEY_ITERATION];d={id:h,current_iteration:p},localStorage.getItem(On(d))||localStorage.setItem(On(d),"true"),u.$set=i({},u.$set,{[Ln({id:h,current_iteration:p},e===Pn.SENT?"responded":"dismissed")]:!0})}var g=i({},u.properties.$set,u.$set);if(T(g)||this.setPersonPropertiesForFlags(g),!D(this.config.before_send)){var v=this._runBeforeSend(u);if(!v)return;u=v}this._internalEventEmitter.emit("eventCaptured",u);var f={method:"POST",url:null!==(r=null==s?void 0:s._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:null==s?void 0:s._batchKey};return!this.config.request_batching||s&&(null==s||!s._batchKey)||null!=s&&s.send_instantly?this._send_retriable_request(f):this._requestQueue.enqueue(f),u}Ie.critical("This capture call is ignored due to client rate limiting.")}}else Ie.error("No event name provided to posthog.capture")}else Ie.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=i({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),"$snapshot"===e){var l=i({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!O(a.distinct_id)&&!N(a.distinct_id)||M(a.distinct_id))&&Ie.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,d=dr(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime());a.$session_id=_,a.$window_id=h}this.sessionPropsManager&&$e(a,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&$e(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){a.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===io.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=$e(a,c),"$pageview"===e&&u&&(a.title=u.title),!L(o)){var v=s.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}g&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=$e({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),C(this.config.property_denylist)?Te(this.config.property_denylist,(function(e){delete a[e]})):Ie.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(Ie.error("sanitize_properties is deprecated. Use before_send instead"),a=f(a,e));var m=this._hasPersonProcessing();return a.$process_person_profile=m,m&&!n&&this._requirePersonProcessing("_calculate_event_properties"),a}_calculate_set_once_properties(e){var t;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent)return e;var i=this.persistence.get_initial_props(),s=null==(t=this.sessionPropsManager)?void 0:t.getSetOnceProps(),r=$e({},i,s||{},e||{}),n=this.config.sanitize_properties;return n&&(Ie.error("sanitize_properties is deprecated. Use before_send instead"),r=n(r,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,T(r)?void 0:r}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var s;null==(s=this.persistence)||s.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(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(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=An),this.surveys.displaySurvey(e,t)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,s){if(!this.__loaded||!this.persistence)return Ie.uninitializedWarning("posthog.identify");if(N(e)&&(e=e.toString(),Ie.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()))Ie.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!==yt){if(this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(Be)&&(this.unregister(Be),this.register({distinct_id:e}));var o="anonymous"===(this.persistence.get_property(dt)||"anonymous");e!==r&&o?(this.persistence.set_property(dt,"identified"),this.setPersonPropertiesForFlags(i({},s||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:s||{}}),this._cachedPersonProperties=ln(e,t,s),this.featureFlags.setAnonymousDistinctId(r)):(t||s)&&this.setPersonProperties(t,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(ut))}}else Ie.critical('The string "'+yt+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else Ie.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var s=ln(this.get_distinct_id(),e,t);this._cachedPersonProperties!==s?(this.setPersonPropertiesForFlags(i({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=s):Ie.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,s){if(e&&t){if(this._requirePersonProcessing("posthog.group")){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},r,{[e]:t})}),s&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s}),this.setGroupPropertiesForFlags({[e]:s})),r[e]===t||s||this.reloadFeatureFlags()}}else Ie.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,r;if(Ie.info("reset"),!this.__loaded)return Ie.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(s=this.persistence)||s.set_property(dt,"anonymous"),null==(r=this.sessionManager)||r.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:yt,$device_id:null},"");else{var o=this.config.get_device_id(yi());this.register_once({distinct_id:o,$device_id:e?o:n},"")}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 null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?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(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;s+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return s}alias(e,t){return e===this.get_property(ze)?(Ie.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(L(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Be,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Ie.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(R(e)){var s,r,n,o,a;$e(this.config,yo(e));var l=this._is_persistence_disabled();null==(s=this.persistence)||s.update_config(this.config,t,l),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new kn(i({},this.config,{persistence:"sessionStorage"}),l);var c=this._checkLocalStorageForDebug(this.config.debug);q(c)&&(this.config.debug=c),q(this.config.debug)&&(this.config.debug?(f.DEBUG=!0,Pi._is_supported()&&Pi._set("ph_debug","true"),Ie.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(f.DEBUG=!1,Pi._is_supported()&&Pi._remove("ph_debug"))),null==(r=this.sessionRecording)||r.startIfEnabledOrStop(),null==(n=this.autocapture)||n.startIfEnabled(),null==(o=this.heatmaps)||o.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(a=this.externalIntegrations)||a.startIfEnabledOrStop()}}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var s,r,n,o,a;if(null==(s=this.sessionManager)||s.checkAndGetSessionAndWindowId(),i.sampling)null==(r=this.sessionRecording)||r.overrideSampling();if(i.linked_flag)null==(n=this.sessionRecording)||n.overrideLinkedFlag();if(i.url_trigger)null==(o=this.sessionRecording)||o.overrideTrigger("url");if(i.event_trigger)null==(a=this.sessionRecording)||a.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(i({},r,t))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:vo;return t!==vo&&(t=vo+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(dt))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(dt))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&T(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[Be])&&(null==(t=this.persistence)||null==(t=t.props)||!t[ft]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(Ie.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(ft,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_sync_opt_out_with_persistence(){var e,t,i,s,r=this._is_persistence_disabled();(null==(e=this.persistence)?void 0:e._disabled)!==r&&(null==(i=this.persistence)||i.set_disabled(r));(null==(t=this.sessionPersistence)?void 0:t._disabled)!==r&&(null==(s=this.sessionPersistence)||s.set_disabled(r));return r}opt_in_capturing(e){if("always"!==this.config.cookieless_mode){var t,i;if("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())this.reset(!0),null==(t=this.sessionManager)||t.destroy(),this.sessionManager=new Xn(this),this.persistence&&(this.sessionPropsManager=new Jn(this,this.sessionManager,this.persistence)),this.sessionRecording=new ho(this),this.sessionRecording.startIfEnabledOrStop();if(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),L(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)this.capture(null!==(i=null==e?void 0:e.captureEventName)&&void 0!==i?i:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}else Ie.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:yt,$device_id:null}),null==(e=this.sessionManager)||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(t=this.sessionRecording)||t.stopRecording(),this.sessionRecording=void 0,this._captureInitialPageview())):Ie.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===Li.GRANTED?"granted":e===Li.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return c?to(c,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){u&&("visible"===u.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:u.title},{send_instantly:!0}),this._visibilityStateListener&&(u.removeEventListener("visibilitychange",this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Ue(u,"visibilitychange",this._visibilityStateListener)))}debug(e){!1===e?(null==r||r.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==r||r.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}))}_shouldDisableFlags(){var e,t,i,s,r,n,o,a=this._originalUserConfig||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ie.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",s=!1,r=Ie,n=(t="advanced_disable_flags")in(e=a)&&!L(e[t]),o=i in e&&!L(e[i]),n?e[t]:o?(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):s)}_runBeforeSend(e){if(D(this.config.before_send))return e;var t=C(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),D(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return j(e.event)?Ie.warn(r+". This can cause unexpected behavior."):Ie.info(r),null}i.properties&&!T(i.properties)||Ie.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?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)})}_checkLocalStorageForDebug(e){var t=q(e)&&!e,i=Pi._is_supported()&&"true"===Pi._get("ph_debug");return!t&&(!!i||e)}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Ae(e.prototype[t[i]])}(wo,["identify"]);var Eo,So;Eo=po[vo]=new wo,(So=v.posthog)&&Te(So._i,(function(e){if(e&&C(e)){var t=Eo.init(e[0],e[1],e[2]),i=So[e[2]]||So;t&&(t._execute_array.call(t.people,i.people),t._execute_array(i))}})),v.posthog=Eo,function(){function e(){e.done||(e.done=!0,fo=!1,Te(po,(function(e){e._dom_loaded()})))}null!=u&&u.addEventListener?"complete"===u.readyState?e():Ue(u,"DOMContentLoaded",e,{capture:!1}):r&&Ie.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}();
|
|
1
|
+
!function(){"use strict";function e(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function t(t){return function(){var i=this,s=arguments;return new Promise((function(r,n){var o=t.apply(i,s);function a(t){e(o,r,n,a,l,"next",t)}function l(t){e(o,r,n,a,l,"throw",t)}a(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},i.apply(null,arguments)}function s(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;i[s]=e[s]}return i}var r="undefined"!=typeof window?window:void 0,n="undefined"!=typeof globalThis?globalThis:r,o=Array.prototype,a=o.forEach,l=o.indexOf,c=null==n?void 0:n.navigator,u=null==n?void 0:n.document,d=null==n?void 0:n.location,_=null==n?void 0:n.fetch,h=null!=n&&n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest?n.XMLHttpRequest:void 0,p=null==n?void 0:n.AbortController,g=null==c?void 0:c.userAgent,v=null!=r?r:{},f={DEBUG:!1,LIB_VERSION:"1.285.2"},m=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],y=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return m.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},b=["$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 w(e,t){return-1!==e.indexOf(t)}var E=function(e){return e.trim()},S=function(e){return e.replace(/^\$/,"")};var k=Array.isArray,x=Object.prototype,P=x.hasOwnProperty,I=x.toString,C=k||function(e){return"[object Array]"===I.call(e)},F=e=>"function"==typeof e,R=e=>e===Object(e)&&!C(e),T=e=>{if(R(e)){for(var t in e)if(P.call(e,t))return!1;return!0}return!1},L=e=>void 0===e,O=e=>"[object String]"==I.call(e),M=e=>O(e)&&0===e.trim().length,A=e=>null===e,D=e=>L(e)||A(e),N=e=>"[object Number]"==I.call(e),q=e=>"[object Boolean]"===I.call(e),H=e=>e instanceof FormData,j=e=>w(b,e);function U(e){return null===e||"object"!=typeof e}function z(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function B(e){return!L(Event)&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var V=[!0,"true",1,"1","yes"],W=e=>w(V,e),G=[!1,"false",0,"0","no"];function Y(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),N(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),Y(r||i,t,i,s))}class J{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Y(e.bucketSize,0,100,e._logger),this._refillRate=Y(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Y(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=t-e.lastAccess,s=Math.floor(i/this._refillInterval);if(s>0){var r=s*this._refillRate;e.tokens=Math.min(e.tokens+r,this._bucketSize),e.lastAccess=e.lastAccess+s*this._refillInterval}}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this._buckets[s];return r?this._applyRefill(r,i):(r={tokens:this._bucketSize,lastAccess:i},this._buckets[s]=r),0===r.tokens||(r.tokens--,0===r.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===r.tokens)}stop(){this._buckets={}}}var K,X,Q,Z=e=>e instanceof Error;function ee(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Q&&i.length===X||(X=i.length,Q=i.reduce(((i,s)=>{K||(K={});var r=K[s];if(r)i[r[0]]=r[1];else for(var n=e(s),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,c=t[s];if(l&&c){i[l]=c,K[s]=[l,c];break}}return i}),{})),Q}}var te="?";function ie(e,t,i,s){var r={platform:"web:javascript",filename:e,function:"<anonymous>"===t?te:t,in_app:!0};return L(i)||(r.lineno=i),L(s)||(r.colno=s),r}var se=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return i||s?[-1!==e.indexOf("@")?e.split("@")[0]:te,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},re=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ne=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,oe=/\((\S*)(?::(\d+))(?::(\d+))\)/,ae=e=>{var t=re.exec(e);if(t){var[,i,s,r]=t;return ie(i,te,+s,+r)}var n=ne.exec(e);if(n){if(n[2]&&0===n[2].indexOf("eval")){var o=oe.exec(n[2]);o&&(n[2]=o[1],n[3]=o[2],n[4]=o[3])}var[a,l]=se(n[1]||te,n[2]);return ie(l,a,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},le=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ce=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ue=e=>{var t=le.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=ce.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var s=t[3],r=t[1]||te;return[r,s]=se(r,s),ie(s,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},de=/\(error: (.*)\)/,_e=50;function he(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var r=[],n=e.split("\n"),o=s;o<n.length;o++){var a=n[o];if(!(a.length>1024)){var l=de.test(a)?a.replace(de,"$1"):a;if(!l.match(/\S*Error: /)){for(var c of t){var u=c(l);if(u){r.push(u);break}}if(r.length>=_e)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,_e).map((e=>{return i({},e,{filename:e.filename||(s=t,s[s.length-1]||{}).filename,function:e.function||te});var s}))}(r)}}class pe{constructor(e,t,i){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===i&&(i=[]),this.coercers=e,this.modifiers=i,this.stackParser=he(...t)}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),r=this.buildParsingContext(),n=this.parseStacktrace(s,r);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&C(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var s,r;return null!=e.cause&&(s=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),i({},e,{cause:s,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}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 i=this;return t((function*(){var t=e;for(var s of i.modifiers)t=yield s(t);return t}))()}convertToExceptionList(e,t){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:null!==(s=t.type)&&void 0!==s?s:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:ee(this.stackParser)}}buildCoercingContext(e,t,s){void 0===s&&(s=0);var r=(i,s)=>{if(s<=4){var r=this.buildCoercingContext(e,t,s);return this.applyCoercers(i,r)}};return i({},t,{syntheticException:0==s?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,s),next:e=>r(e,s+1)})}}class ge{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=O(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 z(e,"DOMException")}isDOMError(e){return z(e,"DOMError")}}class ve{match(e){return(e=>e 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&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class fe{constructor(){}match(e){return z(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i,s=t.apply(e.error);return s||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var me=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ye{match(e){return"string"==typeof e}coerce(e,t){var i,[s,r]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=r?r:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(me);return s&&(t=s[1],i=s[2]),[t,i]}}var be=["fatal","error","warning","log","info","debug"];function we(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(!(r.length>t))return s===i.length||r.length<=t?r:r.slice(0,t)+"..."}return""}class Ee{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return B(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+we(e)}isSeverityLevel(e){return O(e)&&!M(e)&&be.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Z(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class Se{match(e){return B(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+we(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class ke{match(e){return U(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class xe{match(e){return z(e,"PromiseRejectionEvent")}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return U(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){if(U(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var Pe=e=>{var t={_log:function(t){if(r&&(f.DEBUG||v.POSTHOG_DEBUG)&&!L(r.console)&&r.console){for(var i=("__rrweb_original__"in r.console[t]?r.console[t].__rrweb_original__:r.console[t]),s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];i(e,...n)}},info:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("log",...i)},warn:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("warn",...i)},error:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("error",...i)},critical:function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning:e=>{t.error("You must initialize PostHog before calling "+e)},createLogger:t=>Pe(e+" "+t)};return t},Ie=Pe("[PostHog.js]"),Ce=Ie.createLogger,Fe={};function Re(e,t,i){if(C(e))if(a&&e.forEach===a)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var s=0,r=e.length;s<r;s++)if(s in e&&t.call(i,e[s],s)===Fe)return}function Te(e,t,i){if(!D(e)){if(C(e))return Re(e,t,i);if(H(e)){for(var s of e.entries())if(t.call(i,s[1],s[0])===Fe)return}else for(var r in e)if(P.call(e,r)&&t.call(i,e[r],r)===Fe)return}}var $e=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return Re(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},Le=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return Re(i,(function(t){Re(t,(function(t){e.push(t)}))})),e};function Oe(e){for(var t=Object.keys(e),i=t.length,s=new Array(i);i--;)s[i]=[t[i],e[t[i]]];return s}var Me=function(e){try{return e()}catch(e){return}},Ae=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){Ie.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ie.critical(e)}}},De=function(e){var t={};return Te(e,(function(e,i){(O(e)&&e.length>0||N(e))&&(t[i]=e)})),t};function Ne(e,t){return i=e,s=e=>O(e)&&!A(t)?e.slice(0,t):e,r=new Set,function e(t,i){return t!==Object(t)?s?s(t,i):t:r.has(t)?void 0:(r.add(t),C(t)?(n=[],Re(t,(t=>{n.push(e(t))}))):(n={},Te(t,((t,i)=>{r.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,s,r}var qe=["herokuapp.com","vercel.app","netlify.app"];function He(e){var t=null==e?void 0:e.hostname;if(!O(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of qe)if(i===s)return!1;return!0}function je(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Ue(e,t,i,s){var{capture:r=!1,passive:n=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:r,passive:n})}var ze="$people_distinct_id",Be="__alias",Ve="__timers",We="$autocapture_disabled_server_side",Ge="$heatmaps_enabled_server_side",Ye="$exception_capture_enabled_server_side",Je="$error_tracking_suppression_rules",Ke="$error_tracking_capture_extension_exceptions",Xe="$web_vitals_enabled_server_side",Qe="$dead_clicks_enabled_server_side",Ze="$web_vitals_allowed_metrics",et="$session_recording_remote_config",tt="$sesid",it="$session_is_sampled",st="$enabled_feature_flags",rt="$early_access_features",nt="$feature_flag_details",ot="$stored_person_properties",at="$stored_group_properties",lt="$surveys",ct="$surveys_activated",ut="$flag_call_reported",dt="$user_state",_t="$client_session_props",ht="$capture_rate_limit",pt="$initial_campaign_params",gt="$initial_referrer_info",vt="$initial_person_info",ft="$epp",mt="__POSTHOG_TOOLBAR__",yt="$posthog_cookieless",bt=[ze,Be,"__cmpns",Ve,"$session_recording_enabled_server_side",Ge,tt,st,Je,dt,rt,nt,at,ot,lt,ut,_t,ht,pt,gt,ft,vt];function wt(e){return e instanceof Element&&(e.id===mt||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function Et(e){return!!e&&1===e.nodeType}function St(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function kt(e){return!!e&&3===e.nodeType}function xt(e){return!!e&&11===e.nodeType}function Pt(e){return e?E(e).split(/\s+/):[]}function It(e){var t=null==r?void 0:r.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Ct(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Pt(t)}function Ft(e){return D(e)?null:E(e).split(/(\s+)/).filter((e=>Gt(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Rt(e){var t="";return qt(e)&&!Ht(e)&&e.childNodes&&e.childNodes.length&&Te(e.childNodes,(function(e){var i;kt(e)&&e.textContent&&(t+=null!==(i=Ft(e.textContent))&&void 0!==i?i:"")})),E(t)}function Tt(e){return L(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var $t=["a","button","form","input","select","textarea","label"];function Lt(e,t){if(L(t))return!0;var i,s=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var r of e)if(i=s(r))return i.v;return!1}function Ot(e){var t=e.parentNode;return!(!t||!Et(t))&&t}var Mt=[".ph-no-rageclick",".ph-no-capture"];var At=e=>!e||St(e,"html")||!Et(e),Dt=(e,t)=>{if(!r||At(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],n=e;n.parentNode&&!St(n,"body");)if(xt(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=Ot(n);if(!o)break;if(t||$t.indexOf(o.tagName.toLowerCase())>-1)i=!0;else{var a=r.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}s.push(o),n=o}return{parentIsUsefulElement:i,targetElementList:s}};function Nt(e,t,i,s,n){var o,a,l,c;if(void 0===i&&(i=void 0),!r||At(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!It(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&It(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:d,targetElementList:_}=Dt(e,s);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(L(i))return!0;var s,r=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(s=r(n))return s.v;return!1}(_,i))return!1;if(!Lt(_,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var h=r.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var p=e.tagName.toLowerCase();switch(p){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return d?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&($t.indexOf(p)>-1||"true"===e.getAttribute("contenteditable"))}}function qt(e){for(var t=e;t.parentNode&&!St(t,"body");t=t.parentNode){var i=Ct(t);if(w(i,"ph-sensitive")||w(i,"ph-no-capture"))return!1}if(w(Ct(e),"ph-include"))return!0;var s=e.type||"";if(O(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(O(r)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function Ht(e){return!!(St(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||St(e,"select")||St(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var jt="(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})",Ut=new RegExp("^(?:"+jt+")$"),zt=new RegExp(jt),Bt="\\d{3}-?\\d{2}-?\\d{4}",Vt=new RegExp("^("+Bt+")$"),Wt=new RegExp("("+Bt+")");function Gt(e,t){if(void 0===t&&(t=!0),D(e))return!1;if(O(e)){if(e=E(e),(t?Ut:zt).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Vt:Wt).test(e))return!1}return!0}function Yt(e){var t=Rt(e);return Gt(t=(t+" "+Jt(e)).trim())?t:""}function Jt(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Te(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=Rt(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Jt(e)).trim())}catch(e){Ie.error("[AutoCapture]",e)}})),t}function Kt(e){return function(e){var t=e.map((e=>{var t,s,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+="."+n.replace(/"/g,"");var o=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(s=e.nth_of_type)&&void 0!==s?s:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return Oe(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[Xt(t.toString())]=Xt(i.toString())})),r+=":",r+=Oe(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,i,s={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Qt(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Oe(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return s.attributes[t]=i})),s}))}(e))}function Xt(e){return e.replace(/"|\\"/g,'\\"')}function Qt(e){var t=e.attr__class;return t?C(t)?t:Pt(t):void 0}class Zt{constructor(){this.clicks=[]}isRageClick(e,t,i){var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<30&&i-s.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:i}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var ei="$copy_autocapture",ti=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ii=e=>{var t=null==u?void 0:u.createElement("a");return L(t)?null:(t.href=e,t)},si=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return Te(e,(function(e,t){L(e)||L(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),r[r.length]=s+"="+i)})),r.join(t)},ri=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!C(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){Ie.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},ni=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[0]||"",n=s[1],o=r.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var _=c[d].split("=");C(_)&&(t.includes(_[0])?u.push(_[0]+"="+i):u.push(c[d]))}var h=l;return null!=a&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},oi=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},ai=Ce("[AutoCapture]");function li(e,t){return t.length>e?t.slice(0,e)+"...":t}function ci(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Et(t));return t}function ui(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};$t.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?n.$el_text=li(1024,Yt(e)):n.$el_text=li(1024,Rt(e)));var o=Ct(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),Te(e.attributes,(function(i){var r;if((!Ht(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==s||!s.includes(i.name))&&!t&&Gt(i.value)&&(r=i.name,!O(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Pt(o).join(" ")),n["attr__"+i.name]=li(1024,o)}}));for(var a=1,l=1,c=e;c=ci(c);)a++,c.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function di(e,t){for(var i,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!St(d,"body");)xt(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var _,h=[],p={},g=!1,v=!1;if(Te(u,(e=>{var t=qt(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&Gt(g)&&g),w(Ct(e),"ph-no-capture")&&(v=!0),h.push(ui(e,o,a,l));var i=function(e){if(!qt(e))return{};var t={};return Te(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&Gt(s)&&(t[i]=s)}})),t}(e);$e(p,i)})),v)return{props:{},explicitNoCapture:v};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=Yt(e):h[0].$el_text=Rt(e)),g){var f,m;h[0].attr__href=g;var y=null==(f=ii(g))?void 0:f.host,b=null==r||null==(m=r.location)?void 0:m.host;y&&b&&y!==b&&(_=g)}return{props:$e({$event_type:n.type,$ce_version:1},c?{}:{$elements:h},{$elements_chain:Kt(h)},null!=(i=h[0])&&i.$el_text?{$el_text:null==(s=h[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},p)}}class _i{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this.rageclicks=new Zt,this._elementsChainAsString=!1,this.instance=e,this._elementSelectors=null}get _config(){var e,t,i=R(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(r&&u){var e=e=>{e=e||(null==r?void 0:r.event);try{this._captureEvent(e)}catch(e){ai.error("Failed to capture event",e)}};if(Ue(u,"submit",e,{capture:!0}),Ue(u,"change",e,{capture:!0}),Ue(u,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==r?void 0:r.event),this._captureEvent(e,ei)};Ue(u,"copy",t,{capture:!0}),Ue(u,"cut",t,{capture:!0})}}}else ai.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[We]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var s=null==u?void 0:u.querySelectorAll(t);null==s||s.forEach((s=>{e===s&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[We],s=this._isDisabledServerSide;if(A(s)&&!q(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,s=Tt(e);if(kt(s)&&(s=s.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&function(e,t){if(!r||At(e))return!1;var i,s;if(!1===(i=q(t)?!!t&&Mt:null!==(s=null==t?void 0:t.css_selector_ignorelist)&&void 0!==s?s:Mt))return!1;var{targetElementList:n}=Dt(e,!1);return!Lt(n,i)}(s,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var n=t===ei;if(s&&Nt(s,e,this._config,n,n?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=di(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(a)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(o.$element_selectors=l),t===ei){var c,u=Ft(null==r||null==(c=r.getSelection())?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=d}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return F(null==u?void 0:u.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return N(e)&&isFinite(e)&&Math.floor(e)===e});var hi="0123456789abcdef";class pi{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,s){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||e<0||t<0||i<0||s<0||e>0xffffffffffff||t>4095||i>1073741823||s>4294967295)throw new RangeError("invalid field value");var r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=s>>>24,r[13]=s>>>16,r[14]=s>>>8,r[15]=s,new pi(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+hi.charAt(this.bytes[t]>>>4)+hi.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new pi(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class gi{constructor(){this._timestamp=0,this._counter=0,this._random=new mi}generate(){var e=this.generateOrAbort();if(L(e)){this._timestamp=0;var t=this.generateOrAbort();if(L(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(!(e+1e4>this._timestamp))return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return pi.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}}var vi,fi=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};r&&!L(r.crypto)&&crypto.getRandomValues&&(fi=e=>crypto.getRandomValues(e));class mi{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(fi(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var yi=()=>bi().toString(),bi=()=>(vi||(vi=new gi)).generate(),wi="";var Ei=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Si(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=u),wi)return wi;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+yi();!wi&&s--;){var n=i.slice(s).join("."),o=r+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(r)&&(t.cookie=o+";max-age=0",wi=n)}return wi}(e);if(!i){var s=(e=>{var t=e.match(Ei);return t?t[0]:""})(e);s!==i&&Ie.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}var ki={_is_supported:()=>!!u,_error:function(e){Ie.error("cookieStore error: "+e)},_get:function(e){if(u){try{for(var t=e+"=",i=u.cookie.split(";").filter((e=>e.length)),s=0;s<i.length;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}},_parse:function(e){var t;try{t=JSON.parse(ki._get(e))||{}}catch(e){}return t},_set:function(e,t,i,s,r){if(u)try{var n="",o="",a=Si(u.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&Ie.warn("cookieStore warning: large cookie, len="+c.length),u.cookie=c,c}catch(e){return}},_remove:function(e,t){if(null!=u&&u.cookie)try{ki._set(e,"",-1,t)}catch(e){return}}},xi=null,Pi={_is_supported:function(){if(!A(xi))return xi;var e=!0;if(L(r))e=!1;else try{var t="__mplssupport__";Pi._set(t,"xyz"),'"xyz"'!==Pi._get(t)&&(e=!1),Pi._remove(t)}catch(t){e=!1}return e||Ie.error("localStorage unsupported; falling back to cookie store"),xi=e,e},_error:function(e){Ie.error("localStorage error: "+e)},_get:function(e){try{return null==r?void 0:r.localStorage.getItem(e)}catch(e){Pi._error(e)}return null},_parse:function(e){try{return JSON.parse(Pi._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==r||r.localStorage.setItem(e,JSON.stringify(t))}catch(e){Pi._error(e)}},_remove:function(e){try{null==r||r.localStorage.removeItem(e)}catch(e){Pi._error(e)}}},Ii=["distinct_id",tt,it,ft,vt],Ci=i({},Pi,{_parse:function(e){try{var t={};try{t=ki._parse(e)||{}}catch(e){}var i=$e(t,JSON.parse(Pi._get(e)||"{}"));return Pi._set(e,i),i}catch(e){}return null},_set:function(e,t,i,s,r,n){try{Pi._set(e,t,void 0,void 0,n);var o={};Ii.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&ki._set(e,o,i,s,r,n)}catch(e){Pi._error(e)}},_remove:function(e,t){try{null==r||r.localStorage.removeItem(e),ki._remove(e,t)}catch(e){Pi._error(e)}}}),Fi={},Ri={_is_supported:function(){return!0},_error:function(e){Ie.error("memoryStorage error: "+e)},_get:function(e){return Fi[e]||null},_parse:function(e){return Fi[e]||null},_set:function(e,t){Fi[e]=t},_remove:function(e){delete Fi[e]}},Ti=null,$i={_is_supported:function(){if(!A(Ti))return Ti;if(Ti=!0,L(r))Ti=!1;else try{var e="__support__";$i._set(e,"xyz"),'"xyz"'!==$i._get(e)&&(Ti=!1),$i._remove(e)}catch(e){Ti=!1}return Ti},_error:function(e){Ie.error("sessionStorage error: ",e)},_get:function(e){try{return null==r?void 0:r.sessionStorage.getItem(e)}catch(e){$i._error(e)}return null},_parse:function(e){try{return JSON.parse($i._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==r||r.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){$i._error(e)}},_remove:function(e){try{null==r||r.sessionStorage.removeItem(e)}catch(e){$i._error(e)}}},Li=function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e}({});class Oi{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?Li.DENIED:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||(this.consent===Li.DENIED||this.consent===Li.PENDING&&(this._config.opt_out_capturing_by_default||"on_reject"===this._config.cookieless_mode))}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Li.DENIED}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){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 _storedConsent(){var e=this._storage._get(this._storageKey);return W(e)?Li.GRANTED:w(G,e)?Li.DENIED:Li.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?Pi:ki;var t="localStorage"===e?ki:Pi;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(W(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!je([null==c?void 0:c.doNotTrack,null==c?void 0:c.msDoNotTrack,v.doNotTrack],(e=>W(e)))}}var Mi=Ce("[Dead Clicks]"),Ai=()=>!0,Di=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Qe)),s=e.instance.config.capture_dead_clicks;return q(s)?s:i};class Ni{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Qe]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this._loadScript((()=>{this._start()}))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Mi.error("failed to load script",t):e()}))}_start(){var e;if(u){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=R(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(u),Mi.info("starting...")}}else Mi.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Mi.info("stopping..."))}}var qi=Ce("[ExceptionAutocapture]");class Hi{constructor(e){var t,i,s;this._startCapturing=()=>{var e;if(r&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){qi.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[Ye]),this._config=this._requiredConfig(),this._rateLimiter=new J({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10,refillInterval:1e4,_logger:qi}),this.startIfEnabled()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return R(e)?t=i({},t,e):(L(e)?this._remoteEnabled:e)&&(t=i({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(qi.info("enabled"),this._loadScript(this._startCapturing))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return qi.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this._remoteEnabled=!!t||!1,this._config=this._requiredConfig(),this._instance.persistence&&this._instance.persistence.register({[Ye]:this._remoteEnabled}),this.startIfEnabled()}captureException(e){var t,i,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?qi.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}}function ji(e,t,i){try{if(!(t in e))return()=>{};var s=e[t],r=i(s);return F(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=r,()=>{e[t]=s}}catch(e){return()=>{}}}class Ui{constructor(e){var t;this._instance=e,this._lastPathname=(null==r||null==(t=r.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Ie.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,Ie.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(r&&r.history){var i=this;null!=(e=r.history.pushState)&&e.__posthog_wrapped__||ji(r.history,"pushState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("pushState")})),null!=(t=r.history.replaceState)&&t.__posthog_wrapped__||ji(r.history,"replaceState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("replaceState")})),this._setupPopstateListener()}}_capturePageview(e){try{var t,i=null==r||null==(t=r.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this._lastPathname=i}catch(t){Ie.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Ue(r,"popstate",e),this._popstateListener=()=>{r&&r.removeEventListener("popstate",e)}}}}var zi=Ce("[SegmentIntegration]");function Bi(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var s=i=>{var s=()=>i.anonymousId()||yi();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(dt,"identified")),t()},r=i.user();"then"in r&&F(r.then)?r.then((e=>s(e))):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||zi.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(zi.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(zi.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var s=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},s,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}var Vi="posthog-js";function Wi(e,t){var{organization:s,projectId:r,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,c,u,d,_;if(!("*"===o||o.includes(t.level))||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(l=t.exception)?void 0:l.values)||[],g=p.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),v={$exception_message:(null==(c=p[0])?void 0:c.value)||t.message,$exception_type:null==(u=p[0])?void 0:u.type,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=p[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=p[0])?void 0:_.type,$sentry_tags:t.tags};return s&&r&&(v.$sentry_url=(n||"https://sentry.io/organizations/")+s+"/issues/?project="+r+"&query="+t.event_id),a&&e.exceptions.sendExceptionEvent(v),t}}class Gi{constructor(e,t,i,s,r,n){this.name=Vi,this.setupOnce=function(o){o(Wi(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}}var Yi=null!=r&&r.location?oi(r.location.hash,"__posthog")||oi(location.hash,"state"):null,Ji="_postHogToolbarParams",Ki=Ce("[Toolbar]"),Xi=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Xi||{});class Qi{constructor(e){this.instance=e}_setToolbarState(e){v.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=v.ph_toolbar_state)&&void 0!==e?e:Xi.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!r||!u)return!1;e=null!=e?e:r.location,i=null!=i?i:r.history;try{if(!t){try{r.localStorage.setItem("test","test"),r.localStorage.removeItem("test")}catch(e){return!1}t=null==r?void 0:r.localStorage}var s,n=Yi||oi(e.hash,"__posthog")||oi(e.hash,"state"),o=n?Me((()=>JSON.parse(atob(decodeURIComponent(n)))))||Me((()=>JSON.parse(decodeURIComponent(n)))):null;return o&&"ph_authorize"===o.action?((s=o).source="url",s&&Object.keys(s).length>0&&(o.desiredHash?e.hash=o.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(Ji)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch(e){return!1}}_callLoadToolbar(e){var t=v.ph_load_toolbar||v.ph_load_editor;!D(t)&&F(t)?t(e,this.instance):Ki.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==u||!u.getElementById(mt));if(!r||t)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(r.localStorage.setItem(Ji,JSON.stringify(i({},n,{source:void 0}))),this._getToolbarState()===Xi.LOADED)this._callLoadToolbar(n);else if(this._getToolbarState()===Xi.UNINITIALIZED){var o;this._setToolbarState(Xi.LOADING),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Ki.error("[Toolbar] Failed to load",e),void this._setToolbarState(Xi.UNINITIALIZED);this._setToolbarState(Xi.LOADED),this._callLoadToolbar(n)})),Ue(r,"turbolinks:load",(()=>{this._setToolbarState(Xi.UNINITIALIZED),this.loadToolbar(n)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Zi=Ce("[TracingHeaders]");class es{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t;L(this._restoreXHRPatch)&&(null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager));L(this._restoreFetchPatch)&&(null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Zi.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var ts="Mobile",is="iOS",ss="Android",rs="Tablet",ns=ss+" "+rs,os="iPad",as="Apple",ls=as+" Watch",cs="Safari",us="BlackBerry",ds="Samsung",_s=ds+"Browser",hs=ds+" Internet",ps="Chrome",gs=ps+" OS",vs=ps+" "+is,fs="Internet Explorer",ms=fs+" "+ts,ys="Opera",bs=ys+" Mini",ws="Edge",Es="Microsoft "+ws,Ss="Firefox",ks=Ss+" "+is,xs="Nintendo",Ps="PlayStation",Is="Xbox",Cs=ss+" "+ts,Fs=ts+" "+cs,Rs="Windows",Ts=Rs+" Phone",$s="Nokia",Ls="Ouya",Os="Generic",Ms=Os+" "+ts.toLowerCase(),As=Os+" "+rs.toLowerCase(),Ds="Konqueror",Ns="(\\d+(\\.\\d+)?)",qs=new RegExp("Version/"+Ns),Hs=new RegExp(Is,"i"),js=new RegExp(Ps+" \\w+","i"),Us=new RegExp(xs+" \\w+","i"),zs=new RegExp(us+"|PlayBook|BB10","i"),Bs={"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"};var Vs=(e,t)=>t&&w(t,as)||function(e){return w(e,cs)&&!w(e,ps)&&!w(e,ss)}(e),Ws=function(e,t){return t=t||"",w(e," OPR/")&&w(e,"Mini")?bs:w(e," OPR/")?ys:zs.test(e)?us:w(e,"IE"+ts)||w(e,"WPDesktop")?ms:w(e,_s)?hs:w(e,ws)||w(e,"Edg/")?Es:w(e,"FBIOS")?"Facebook "+ts:w(e,"UCWEB")||w(e,"UCBrowser")?"UC Browser":w(e,"CriOS")?vs:w(e,"CrMo")||w(e,ps)?ps:w(e,ss)&&w(e,cs)?Cs:w(e,"FxiOS")?ks:w(e.toLowerCase(),Ds.toLowerCase())?Ds:Vs(e,t)?w(e,ts)?Fs:cs:w(e,Ss)?Ss:w(e,"MSIE")||w(e,"Trident/")?fs:w(e,"Gecko")?Ss:""},Gs={[ms]:[new RegExp("rv:"+Ns)],[Es]:[new RegExp(ws+"?\\/"+Ns)],[ps]:[new RegExp("("+ps+"|CrMo)\\/"+Ns)],[vs]:[new RegExp("CriOS\\/"+Ns)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ns)],[cs]:[qs],[Fs]:[qs],[ys]:[new RegExp("(Opera|OPR)\\/"+Ns)],[Ss]:[new RegExp(Ss+"\\/"+Ns)],[ks]:[new RegExp("FxiOS\\/"+Ns)],[Ds]:[new RegExp("Konqueror[:/]?"+Ns,"i")],[us]:[new RegExp(us+" "+Ns),qs],[Cs]:[new RegExp("android\\s"+Ns,"i")],[hs]:[new RegExp(_s+"\\/"+Ns)],[fs]:[new RegExp("(rv:|MSIE )"+Ns)],Mozilla:[new RegExp("rv:"+Ns)]},Ys=function(e,t){var i=Ws(e,t),s=Gs[i];if(L(s))return null;for(var r=0;r<s.length;r++){var n=s[r],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},Js=[[new RegExp(Is+"; "+Is+" (.*?)[);]","i"),e=>[Is,e&&e[1]||""]],[new RegExp(xs,"i"),[xs,""]],[new RegExp(Ps,"i"),[Ps,""]],[zs,[us,""]],[new RegExp(Rs,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Ts,""];if(new RegExp(ts).test(t)&&!/IEMobile\b/.test(t))return[Rs+" "+ts,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=i[1],r=Bs[s]||"";return/arm/i.test(t)&&(r="RT"),[Rs,r]}return[Rs,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[is,t.join(".")]}return[is,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=L(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ss+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ss+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[ss,t.join(".")]}return[ss,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[gs,""]],[/Linux|debian/i,["Linux",""]]],Ks=function(e){return Us.test(e)?xs:js.test(e)?Ps:Hs.test(e)?Is:new RegExp(Ls,"i").test(e)?Ls:new RegExp("("+Ts+"|WPDesktop)","i").test(e)?Ts:/iPad/.test(e)?os:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ls:zs.test(e)?us:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp($s,"i").test(e)?$s:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(ts).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?ss:ns:ss:new RegExp("(pda|"+ts+")","i").test(e)?Ms:new RegExp(rs,"i").test(e)&&!new RegExp(rs+" pc","i").test(e)?As:""},Xs="https?://(.*)",Qs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Zs=Le(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Qs),er="<masked>",tr=["li_fat_id"];function ir(e,t,i){if(!u)return{};var s,r=t?Le([],Qs,i||[]):[],n=sr(ni(u.URL,r,er),e),o=(s={},Te(tr,(function(e){var t=ki._get(e);s[e]=t||null})),s);return $e(o,n)}function sr(e,t){var i=Zs.concat(t||[]),s={};return Te(i,(function(t){var i=ri(e,t);s[t]=i||null})),s}function rr(e){var t=function(e){return e?0===e.search(Xs+"google.([^/?]*)")?"google":0===e.search(Xs+"bing.com")?"bing":0===e.search(Xs+"yahoo.com")?"yahoo":0===e.search(Xs+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!A(t)){s.$search_engine=t;var r=u?ri(u.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function nr(){return navigator.language||navigator.userLanguage}function or(){return(null==u?void 0:u.referrer)||"$direct"}function ar(e,t){var i=e?Le([],Qs,t||[]):[],s=null==d?void 0:d.href.substring(0,1e3);return{r:or().substring(0,1e3),u:s?ni(s,i,er):void 0}}function lr(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=ii(i))?void 0:t.host};if(s){r.$current_url=s;var n=ii(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=sr(s);$e(r,o)}if(i){var a=rr(i);$e(r,a)}return r}function cr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function ur(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function dr(e,t){if(!g)return{};var i,s,n,o=e?Le([],Qs,t||[]):[],[a,l]=function(e){for(var t=0;t<Js.length;t++){var[i,s]=Js[t],r=i.exec(e),n=r&&(F(s)?s(r,e):s);if(n)return n}return["",""]}(g);return $e(De({$os:a,$os_version:l,$browser:Ws(g,navigator.vendor),$device:Ks(g),$device_type:(s=g,n=Ks(s),n===os||n===ns||"Kobo"===n||"Kindle Fire"===n||n===As?rs:n===xs||n===Is||n===Ps||n===Ls?"Console":n===ls?"Wearable":n?ts:"Desktop"),$timezone:cr(),$timezone_offset:ur()}),{$current_url:ni(null==d?void 0:d.href,o,er),$host:null==d?void 0:d.host,$pathname:null==d?void 0:d.pathname,$raw_user_agent:g.length>1e3?g.substring(0,997)+"...":g,$browser_version:Ys(g,navigator.vendor),$browser_language:nr(),$browser_language_prefix:(i=nr(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==r?void 0:r.screen.height,$screen_width:null==r?void 0:r.screen.width,$viewport_height:null==r?void 0:r.innerHeight,$viewport_width:null==r?void 0:r.innerWidth,$lib:"web",$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var _r=Ce("[Web Vitals]"),hr=9e5;class pr{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t,s=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(L(s))_r.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!L(r))if(D(null==e?void 0:e.name)||D(null==e?void 0:e.value))_r.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)_r.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),L(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=L(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this._buffer.metrics.push(i({},e,{$current_url:r,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}},this._startCapturing=()=>{var e,t,i,s,r=v.__PosthogExtensions__;L(r)||L(r.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:s}=r.postHogWebVitalsCallbacks),e&&t&&i&&s?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this)),this._initialized=!0):_r.error("web vitals callbacks not loaded - not starting")},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[Xe]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=R(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return L(i)?(null==(t=this._instance.persistence)?void 0:t.props[Ze])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(R(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=R(this._instance.config.capture_performance)&&N(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:hr;return 0<e&&e<=6e4?hr:e}get isEnabled(){var e=null==d?void 0:d.protocol;if("http:"!==e&&"https:"!==e)return _r.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=R(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:q(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return q(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(_r.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){var t=R(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=R(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xe]:t}),this._instance.persistence.register({[Ze]:i})),this._enabledServerSide=t,this.startIfEnabled()}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"web-vitals",(t=>{t?_r.error("failed to load script",t):e()}))}_currentURL(){var e=r?r.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?Le([],Qs,i||[]):[];return ni(e,s,er)}_r.error("Could not determine current URL")}}var gr=Ce("[Heatmaps]");function vr(e){return R(e)&&"clientX"in e&&"clientY"in e&&N(e.clientX)&&N(e.clientY)}class fr{constructor(e){var t;this.rageclicks=new Zt,this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[Ge])}get flushIntervalMilliseconds(){var e=5e3;return R(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 L(this.instance.config.capture_heatmaps)?L(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;gr.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ge]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(u)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){r&&u&&(this._flushHandler=this._flush.bind(this),Ue(r,"beforeunload",this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==r?void 0:r.event)),Ue(u,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==r?void 0:r.event)),Ue(u,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new Ni(this.instance,Ai,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabled(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Ue(u,"visibilitychange",this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;r&&u&&(this._flushHandler&&r.removeEventListener("beforeunload",this._flushHandler),this._onClickHandler&&u.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&u.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&u.removeEventListener("visibilitychange",this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(e,t,i){for(var s=e;s&&Et(s)&&!St(s,"body");){if(s===i)return!1;if(w(t,null==r?void 0:r.getComputedStyle(s).position))return!0;s=Ot(s)}return!1}(Tt(e),["fixed","sticky"],n);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:i),target_fixed:o,type:t}}_onClick(e,t){var s;if(void 0===t&&(t="click"),!wt(e.target)&&vr(e)){var r=this._getProperties(e,t);null!=(s=this.rageclicks)&&s.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(i({},r,{type:"rageclick"})),this._capture(r)}}_onMouseMove(e){!wt(e.target)&&vr(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(r){var t=r.location.href,i=this.instance.config.mask_personal_data_properties,s=this.instance.config.custom_personal_data_properties,n=i?Le([],Qs,s||[]):[],o=ni(t,n,er);this._buffer=this._buffer||{},this._buffer[o]||(this._buffer[o]=[]),this._buffer[o].push(e)}}_flush(){this._buffer&&!T(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class mr{constructor(e){this._instance=e}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==r?void 0:r.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=r;if(!(L(n)||L(o)||L(a)||L(l)||L(c)||L(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=n<=1?1:Y(o/n,0,1,Ie),_=n<=1?1:Y(a/n,0,1,Ie),h=l<=1?1:Y(c/l,0,1,Ie),p=l<=1?1:Y(u/l,0,1,Ie);s=$e(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}}var yr=Uint8Array,br=Uint16Array,wr=Uint32Array,Er=new yr([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]),Sr=new yr([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]),kr=new yr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xr=function(e,t){for(var i=new br(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var r=new wr(i[30]);for(s=1;s<30;++s)for(var n=i[s];n<i[s+1];++n)r[n]=n-i[s]<<5|s;return[i,r]},Pr=xr(Er,2),Ir=Pr[0],Cr=Pr[1];Ir[28]=258,Cr[258]=28;for(var Fr=xr(Sr,0)[1],Rr=new br(32768),Tr=0;Tr<32768;++Tr){var $r=(43690&Tr)>>>1|(21845&Tr)<<1;$r=(61680&($r=(52428&$r)>>>2|(13107&$r)<<2))>>>4|(3855&$r)<<4,Rr[Tr]=((65280&$r)>>>8|(255&$r)<<8)>>>1}var Lr=function(e,t,i){for(var s=e.length,r=0,n=new br(t);r<s;++r)++n[e[r]-1];var o,a=new br(t);for(r=0;r<t;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new br(1<<t);var l=15-t;for(r=0;r<s;++r)if(e[r])for(var c=r<<4|e[r],u=t-e[r],d=a[e[r]-1]++<<u,_=d|(1<<u)-1;d<=_;++d)o[Rr[d]>>>l]=c}else for(o=new br(s),r=0;r<s;++r)o[r]=Rr[a[e[r]-1]++]>>>15-e[r];return o},Or=new yr(288);for(Tr=0;Tr<144;++Tr)Or[Tr]=8;for(Tr=144;Tr<256;++Tr)Or[Tr]=9;for(Tr=256;Tr<280;++Tr)Or[Tr]=7;for(Tr=280;Tr<288;++Tr)Or[Tr]=8;var Mr=new yr(32);for(Tr=0;Tr<32;++Tr)Mr[Tr]=5;var Ar=Lr(Or,9,0),Dr=Lr(Mr,5,0),Nr=function(e){return(e/8>>0)+(7&e&&1)},qr=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof br?br:e instanceof wr?wr:yr)(i-t);return s.set(e.subarray(t,i)),s},Hr=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},jr=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8,e[s+2]|=i>>>16},Ur=function(e,t){for(var i=[],s=0;s<e.length;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new yr(0),0];if(1==r){var o=new yr(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var _=n[0].s;for(s=1;s<r;++s)n[s].s>_&&(_=n[s].s);var h=new br(_+1),p=zr(i[u-1],h,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s<r;++s){var m=n[s].s;if(!(h[m]>t))break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[s].s;h[y]<t?g-=1<<t-h[y]++-1:++s}for(;s>=0&&g;--s){var b=n[s].s;h[b]==t&&(--h[b],++g)}p=t}return[new yr(h),p]},zr=function(e,t,i){return-1==e.s?Math.max(zr(e.l,t,i+1),zr(e.r,t,i+1)):t[e.s]=i},Br=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new br(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},Vr=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Wr=function(e,t,i){var s=i.length,r=Nr(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;n<s;++n)e[r+n+4]=i[n];return 8*(r+4+s)},Gr=function(e,t,i,s,r,n,o,a,l,c,u){Hr(t,u++,i),++r[256];for(var d=Ur(r,15),_=d[0],h=d[1],p=Ur(n,15),g=p[0],v=p[1],f=Br(_),m=f[0],y=f[1],b=Br(g),w=b[0],E=b[1],S=new br(19),k=0;k<m.length;++k)S[31&m[k]]++;for(k=0;k<w.length;++k)S[31&w[k]]++;for(var x=Ur(S,7),P=x[0],I=x[1],C=19;C>4&&!P[kr[C-1]];--C);var F,R,T,L,O=c+5<<3,M=Vr(r,Or)+Vr(n,Mr)+o,A=Vr(r,_)+Vr(n,g)+o+14+3*C+Vr(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(O<=M&&O<=A)return Wr(t,u,e.subarray(l,l+c));if(Hr(t,u,1+(A<M)),u+=2,A<M){F=Lr(_,h,0),R=_,T=Lr(g,v,0),L=g;var D=Lr(P,I,0);Hr(t,u,y-257),Hr(t,u+5,E-1),Hr(t,u+10,C-4),u+=14;for(k=0;k<C;++k)Hr(t,u+3*k,P[kr[k]]);u+=3*C;for(var N=[m,w],q=0;q<2;++q){var H=N[q];for(k=0;k<H.length;++k){var j=31&H[k];Hr(t,u,D[j]),u+=P[j],j>15&&(Hr(t,u,H[k]>>>5&127),u+=H[k]>>>12)}}}else F=Ar,R=Or,T=Dr,L=Mr;for(k=0;k<a;++k)if(s[k]>255){j=s[k]>>>18&31;jr(t,u,F[j+257]),u+=R[j+257],j>7&&(Hr(t,u,s[k]>>>23&31),u+=Er[j]);var U=31&s[k];jr(t,u,T[U]),u+=L[U],U>3&&(jr(t,u,s[k]>>>5&8191),u+=Sr[U])}else jr(t,u,F[s[k]]),u+=R[s[k]];return jr(t,u,F[256]),u+R[256]},Yr=new wr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Jr=function(){for(var e=new wr(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Kr=function(e,t,i,s,r){return function(e,t,i,s,r,n){var o=e.length,a=new yr(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),c=0;if(!t||o<8)for(var u=0;u<=o;u+=65535){var d=u+65535;d<o?c=Wr(l,c,e.subarray(u,d)):(l[u]=n,c=Wr(l,c,e.subarray(u,o)))}else{for(var _=Yr[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new br(32768),f=new br(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new wr(25e3),E=new br(288),S=new br(32),k=0,x=0,P=(u=0,0),I=0,C=0;u<o;++u){var F=b(u),R=32767&u,T=f[F];if(v[R]=T,f[F]=R,I<=u){var L=o-u;if((k>7e3||P>24576)&&L>423){c=Gr(e,l,0,w,E,S,x,P,C,u-C,c),P=k=x=0,C=u;for(var O=0;O<286;++O)E[O]=0;for(O=0;O<30;++O)S[O]=0}var M=2,A=0,D=p,N=R-T&32767;if(L>2&&F==b(u-N))for(var q=Math.min(h,L)-1,H=Math.min(32767,u),j=Math.min(258,L);N<=H&&--D&&R!=T;){if(e[u+M]==e[u+M-N]){for(var U=0;U<j&&e[u+U]==e[u+U-N];++U);if(U>M){if(M=U,A=N,U>q)break;var z=Math.min(N,U-2),B=0;for(O=0;O<z;++O){var V=u-N+O+32768&32767,W=V-v[V]+32768&32767;W>B&&(B=W,T=V)}}}N+=(R=T)-(T=v[R])+32768&32767}if(A){w[P++]=268435456|Cr[M]<<18|Fr[A];var G=31&Cr[M],Y=31&Fr[A];x+=Er[G]+Sr[Y],++E[257+G],++S[Y],I=u+M,++k}else w[P++]=e[u],++E[e[u]]}}c=Gr(e,l,n,w,E,S,x,P,C,u-C,c)}return qr(a,0,s+Nr(c)+r)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,s,!0)},Xr=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Qr(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=Jr[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n=Kr(e,t,10+((r=t).filename&&r.filename.length+1||0),8),o=n.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Xr(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;s<=i.length;++s)e[s+10]=i.charCodeAt(s)}}(n,t),Xr(n,o-8,i.d()),Xr(n,o-4,s),n}var Zr=function(e){var t,i,s,r,n="";for(t=i=0,s=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,r=0;r<s;r++){var o=e.charCodeAt(r),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),A(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=r+1)}return i>t&&(n+=e.substring(t,e.length)),n},en=!!h||!!_,tn="text/plain",sn=function(e,t,s){var r;void 0===s&&(s=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(r=null==o?void 0:o.split("&").map((e=>{var t,[i,r]=e.split("="),n=s&&null!==(t=a[i])&&void 0!==t?t:r;return delete a[i],i+"="+n})))&&void 0!==r?r:[],c=si(a);return c&&l.push(c),n+"?"+l.join("&")},rn=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),nn=e=>{var{data:t,compression:i}=e;if(t){if(i===ti.GZipJS){var s=Qr(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new yr(e.length+(e.length>>>1)),r=0,n=function(e){s[r++]=e},o=0;o<i;++o){if(r+5>s.length){var a=new yr(r+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);l<128||t?n(l):l<2048?(n(192|l>>>6),n(128|63&l)):l>55295&&l<57344?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return qr(s,0,r)}(rn(t)),{mtime:0}),r=new Blob([s],{type:tn});return{contentType:tn,body:r,estimatedSize:r.size}}if(i===ti.Base64){var n=function(e){var t,i,s,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=Zr(e);do{t=(n=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=n>>12&63,s=n>>6&63,r=63&n,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(s)+o.charAt(r)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(rn(t)),o=(e=>"data="+encodeURIComponent("string"==typeof e?e:rn(e)))(n);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=rn(t);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},on=[];_&&on.push({transport:"fetch",method:e=>{var t,s,{contentType:r,body:n,estimatedSize:o}=null!==(t=nn(e))&&void 0!==t?t:{},a=new Headers;Te(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,c=null;if(p){var u=new p;c={signal:u.signal,timeout:setTimeout((()=>u.abort()),e.timeout)}}_(l,i({method:(null==e?void 0:e.method)||"GET",headers:a,keepalive:"POST"===e.method&&(o||0)<52428.8,body:n,signal:null==(s=c)?void 0:s.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){Ie.error(e)}null==e.callback||e.callback(s)})))).catch((t=>{Ie.error(t),null==e.callback||e.callback({statusCode:0,text:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}),h&&on.push({transport:"XHR",method:e=>{var t,i=new h;i.open(e.method||"GET",e.url,!0);var{contentType:s,body:r}=null!==(t=nn(e))&&void 0!==t?t:{};Te(e.headers,(function(e,t){i.setRequestHeader(t,e)})),s&&i.setRequestHeader("Content-Type",s),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(r)}}),null!=c&&c.sendBeacon&&on.push({transport:"sendBeacon",method:e=>{var t=sn(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=nn(e))&&void 0!==i?i:{},n="string"==typeof r?new Blob([r],{type:s}):r;c.sendBeacon(t,n)}catch(e){}}});var an=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};function ln(e,t,i){return rn({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var cn={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>an(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!an(t,e))))),icontains:(e,t)=>t.map(un).some((t=>e.map(un).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(un).every((t=>e.map(un).every((e=>!t.includes(e)))))},un=e=>e.toLowerCase(),dn=Ce("[Error tracking]");class _n{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new pe([new ge,new xe,new fe,new ve,new Se,new Ee,new ye,new ke],[ae,ue]),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Je))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,s,r=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(s=e.errorTracking)?void 0:s.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[Je]:this._suppressionRules,[Ke]:n})}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(Ke),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return void dn.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return void dn.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return void dn.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}_matchesSuppressionRule(e){if(0===e.length)return!1;var t=e.reduce(((e,t)=>{var{type:i,value:s}=t;return O(i)&&i.length>0&&e.$exception_types.push(i),O(s)&&s.length>0&&e.$exception_values.push(s),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i,s=cn[e.operator],r=C(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return r.length>0&&s(r,n)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}_isExtensionException(e){return e.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}_isPostHogException(e){if(e.length>0){var t,i,s,r,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(s=null==o||null==(r=o.filename)?void 0:r.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!D(e)&&C(e)}}var hn=Ce("[FeatureFlags]"),pn="$active_feature_flags",gn="$override_feature_flags",vn="$feature_flag_payloads",fn="$override_feature_flag_payloads",mn="$feature_flag_request_id",yn=e=>{var t={};for(var[i,s]of Oe(e||{}))s&&(t[i]=s);return t},bn=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):hn.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e},wn=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class En{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this._instance=e,this.featureFlagEventHandlers=[]}_getValidEvaluationEnvironments(){var e=this._instance.config.evaluation_environments;return null!=e&&e.length?e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||hn.error("Invalid evaluation environment found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}flags(){if(this._instance.config.__preview_remote_config)this._flagsCalled=!0;else{var e=!this._reloadDebouncer&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this._callFlagsEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(nt),t=this._instance.get_property(gn),s=this._instance.get_property(fn);if(!s&&!t)return e||{};var r=$e({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(var o of n){var a,l,c=r[o],u=null==t?void 0:t[o],d=L(u)?null!==(a=null==c?void 0:c.enabled)&&void 0!==a&&a:!!u,_=L(u)?c.variant:"string"==typeof u?u:void 0,h=null==s?void 0:s[o],p=i({},c,{enabled:d,variant:d?null!=_?_:null==c?void 0:c.variant:void 0});if(d!==(null==c?void 0:c.enabled)&&(p.original_enabled=null==c?void 0:c.enabled),_!==(null==c?void 0:c.variant)&&(p.original_variant=null==c?void 0:c.variant),h)p.metadata=i({},null==c?void 0:c.metadata,{payload:h,original_payload:null==c||null==(l=c.metadata)?void 0:l.payload});r[o]=p}return this._override_warning||(hn.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var e=this._instance.get_property(st),t=this._instance.get_property(gn);if(!t)return e||{};for(var i=$e({},e),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(hn.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._instance.get_property(vn),t=this._instance.get_property(fn);if(!t)return e||{};for(var i=$e({},e||{}),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(hn.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var s={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(ot)||{}),group_properties:this._instance.get_property(at)};(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(s.evaluation_environments=this._getValidEvaluationEnvironments());var r=this._instance.config.__preview_remote_config,n=r?"/flags/?v=2":"/flags/?v=2&config=true",o=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",a=this._instance.requestRouter.endpointFor("api",n+o);r&&(s.timezone=cr()),this._requestInFlight=!0,this._instance._send_request({method:"POST",url:a,data:s,compression:this._instance.config.disable_compression?void 0:ti.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r=!0;(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),r=!1),this._requestInFlight=!1,this._flagsCalled)||(this._flagsCalled=!0,this._instance._onRemoteConfig(null!==(i=e.json)&&void 0!==i?i:{}));if(!s.disable_flags||this._additionalReloadRequested)if(this._flagsLoadedFromRemote=!r,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(wn.FeatureFlags))hn.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 n;if(!s.disable_flags)this.receivedFeatureFlags(null!==(n=e.json)&&void 0!==n?n:{},r);this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants()[e],s=""+i,r=this._instance.get_property(mn)||void 0,n=this._instance.get_property(ut)||{};if((t.send_event||!("send_event"in t))&&(!(e in n)||!n[e].includes(s))){var o,a,l,c,u,d,_,h,p;C(n[e])?n[e].push(s):n[e]=[s],null==(o=this._instance.persistence)||o.register({[ut]:n});var g=this.getFeatureFlagDetails(e),v={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:r,$feature_flag_bootstrapped_response:(null==(a=this._instance.config.bootstrap)||null==(a=a.featureFlags)?void 0:a[e])||null,$feature_flag_bootstrapped_payload:(null==(l=this._instance.config.bootstrap)||null==(l=l.featureFlagPayloads)?void 0:l[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};L(null==g||null==(c=g.metadata)?void 0:c.version)||(v.$feature_flag_version=g.metadata.version);var f,m=null!==(u=null==g||null==(d=g.reason)?void 0:d.description)&&void 0!==u?u:null==g||null==(_=g.reason)?void 0:_.code;if(m&&(v.$feature_flag_reason=m),null!=g&&null!=(h=g.metadata)&&h.id&&(v.$feature_flag_id=g.metadata.id),L(null==g?void 0:g.original_variant)&&L(null==g?void 0:g.original_enabled)||(v.$feature_flag_original_response=L(g.original_variant)?g.original_enabled:g.original_variant),null!=g&&null!=(p=g.metadata)&&p.original_payload)v.$feature_flag_original_payload=null==g||null==(f=g.metadata)?void 0:f.original_payload;this._instance.capture("$feature_flag_called",v)}return i}hn.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._shouldIncludeEvaluationEnvironments()&&(s.evaluation_environments=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:s,compression:this._instance.config.disable_compression?void 0:ti.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var s,r=null==(s=i.json)?void 0:s.featureFlagPayloads;t((null==r?void 0:r[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return L(i)?void 0:!!i}hn.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._hasLoadedFlags=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(e,t,s,r,n){void 0===s&&(s={}),void 0===r&&(r={}),void 0===n&&(n={});var o=bn(e),a=o.flags,l=o.featureFlags,c=o.featureFlagPayloads;if(l){var u=e.requestId;if(C(l)){hn.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var d={};if(l)for(var _=0;_<l.length;_++)d[l[_]]=!0;t&&t.register({[pn]:l,[st]:d})}else{var h=l,p=c,g=a;e.errorsWhileComputingFlags&&(h=i({},s,h),p=i({},r,p),g=i({},n,g)),t&&t.register(i({[pn]:Object.keys(yn(h)),[st]:h||{},[vn]:p||{},[nt]:g||{}},u?{[mn]:u}:{}))}}}(e,this._instance.persistence,s,r,n),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),hn.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return hn.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(gn),this._instance.persistence.unregister(fn),void this._fireFeatureFlagsCallbacks();if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(gn);else if(i.flags)if(C(i.flags)){for(var s={},r=0;r<i.flags.length;r++)s[i.flags[r]]=!0;this._instance.persistence.register({[gn]:s})}else this._instance.persistence.register({[gn]:i.flags});return"payloads"in i&&(!1===i.payloads?this._instance.persistence.unregister(fn):i.payloads&&this._instance.persistence.register({[fn]:i.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var r,n=(this._instance.get_property(rt)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),s&&(a.$feature_enrollment_stage=s),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(r=this._instance.persistence)||r.register({[pn]:Object.keys(yn(l)),[st]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._instance.get_property(rt),r=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+r),method:"GET",callback:t=>{var i,s;if(t.json){var r=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(rt),null==(s=this._instance.persistence)||s.register({[rt]:r}),e(r)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(ot)||{};this._instance.register({[ot]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(ot)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(at)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((t=>{s[t]=i({},s[t],e[t]),delete e[t]})),this._instance.register({[at]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(at)||{};this._instance.register({[at]:i({},t,{[e]:{}})})}else this._instance.unregister(at)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}var Sn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class kn{constructor(e,t){this._config=e,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this.load(),e.debug&&Ie.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Sn.indexOf(e.persistence.toLowerCase())&&(Ie.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&Pi._is_supported()?Pi:"localstorage+cookie"===t&&Ci._is_supported()?Ci:"sessionstorage"===t&&$i._is_supported()?$i:"memory"===t?Ri:"cookie"===t?ki:Ci._is_supported()?Ci:ki}properties(){var e={};return Te(this.props,(function(t,i){if(i===st&&R(t))for(var s=Object.keys(t),r=0;r<s.length;r++)e["$feature/"+s[r]]=t[s[r]];else o=i,a=!1,(A(n=bt)?a:l&&n.indexOf===l?-1!=n.indexOf(o):(Te(n,(function(e){if(a||(a=e===o))return Fe})),a))||(e[i]=t);var n,o,a})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=$e({},e))}}save(){this._disabled||this._storage._set(this._name,this.props,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)}remove(){this._storage._remove(this._name,!1),this._storage._remove(this._name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(R(e)){L(t)&&(t="None"),this._expire_days=L(i)?this._default_expiry:i;var s=!1;if(Te(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(R(e)){this._expire_days=L(t)?this._default_expiry:t;var i=!1;if(Te(e,((t,s)=>{e.hasOwnProperty(s)&&this.props[s]!==t&&(this.props[s]=t,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._campaign_params_saved){var e=ir(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);T(De(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==u?void 0:u.referrer)?rr(e):{})}update_referrer_info(){var e;this.register_once({$referrer:or(),$referring_domain:null!=u&&u.referrer&&(null==(e=ii(u.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[pt]||this.props[gt]||this.register_once({[vt]:ar(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Te([gt,pt],(t=>{var i=this.props[t];i&&Te(i,(function(t,i){e["$initial_"+S(i)]=t}))}));var t,i,s=this.props[vt];if(s){var r=(t=lr(s),i={},Te(t,(function(e,t){i["$initial_"+S(t)]=e})),i);$e(e,r)}return e}safe_merge(e){return Te(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this._default_expiry=this._expire_days=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){var s=this._buildStorage(e),r=this.props;this.clear(),this._storage=s,this.props=r,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove(),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[Ve]||{};i[e]=t,this.props[Ve]=i,this.save()}remove_event_timer(e){var t=(this.props[Ve]||{})[e];return L(t)||(delete this.props[Ve][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var xn=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({}),Pn=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e}({}),In=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e}({}),Cn=function(e){return e.Popover="popover",e.Inline="inline",e}({});class Fn{constructor(){this._events={},this._events={}}on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var s of this._events["*"]||[])s(e,t)}}class Rn{constructor(e){this._debugEventEmitter=new Fn,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e;if(!L(null==(e=this._instance)?void 0:e._addCaptureHook)){var t;null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!L(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var s,r=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&r.add(null==e?void 0:e.selector)}))})),null==(s=this._instance)||s.autocapture.setElementSelectors(r)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(null==t?void 0:t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&this._actionRegistry.forEach((e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,s=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!Rn._matchString(s,null==t?void 0:t.url,(null==t?void 0:t.url_matching)||"contains"))return!1}return!0}static _matchString(e,t,i){switch(i){case"regex":return!!r&&an(e,t);case"exact":return t===e;case"contains":var s=Rn._escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return an(e,s);default:return!1}}static _escapeStringRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}_checkStepElement(e,t){if((null!=t&&t.href||null!=t&&t.tag_name||null!=t&&t.text)&&!this._getElementsList(e).some((e=>!(null!=t&&t.href&&!Rn._matchString(e.href||"",null==t?void 0:t.href,(null==t?void 0:t.href_matching)||"exact"))&&((null==t||!t.tag_name||e.tag_name===(null==t?void 0:t.tag_name))&&!(null!=t&&t.text&&!Rn._matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!Rn._matchString(e.$el_text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact"))))))return!1;if(null!=t&&t.selector){var i,s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(!s)return!1;if(!s.includes(null==t?void 0:t.selector))return!1}return!0}_getElementsList(e){return null==(null==e?void 0:e.properties.$elements)?[]:null==e?void 0:e.properties.$elements}}var Tn=Ce("[Surveys]");var $n="seenSurvey_",Ln=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},On=e=>{var t=""+$n+e.id;return e.current_iteration&&e.current_iteration>0&&(t=""+$n+e.id+"_"+e.current_iteration),t},Mn=[xn.Popover,xn.Widget,xn.API],An={ignoreConditions:!1,ignoreDelay:!1,displayType:Cn.Popover};class Dn{constructor(e){this._instance=e,this._eventToSurveys=new Map,this._actionToSurveys=new Map}register(e){var t;L(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedSurveys(e),this._setupActionBasedSurveys(e))}_setupActionBasedSurveys(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));if(0!==t.length){if(null==this._actionMatcher){this._actionMatcher=new Rn(this._instance),this._actionMatcher.init();this._actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,s,r,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(s=e.conditions)||null==(s=s.actions)||null==(s=s.values)?void 0:s.length)>0&&(null==(r=this._actionMatcher)||r.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToSurveys.get(t.name);i&&i.push(e.id),this._actionToSurveys.set(t.name,i||[e.id])}})))}))}}_setupEventBasedSurveys(e){var t;if(0!==e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})).length){null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t;null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||t.forEach((t=>{if(t&&t.name){var i=this._eventToSurveys.get(t.name);i&&i.push(e.id),this._eventToSurveys.set(t.name,i||[e.id])}}))}))}}onEvent(e,t){var i,s,r=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[ct])||[];if(Pn.SHOWN===e&&t&&r.length>0){var n;Tn.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:t,existingActivatedSurveys:r});var o=null==t||null==(n=t.properties)?void 0:n.$survey_id;if(o){var a=r.indexOf(o);a>=0&&(r.splice(a,1),this._updateActivatedSurveys(r))}}else if(this._eventToSurveys.has(e)){Tn.info("survey event name matched",{event:e,eventPayload:t,surveys:this._eventToSurveys.get(e)});var l=[];null==(s=this._instance)||s.getSurveys((t=>{l=t.filter((t=>{var i;return null==(i=this._eventToSurveys.get(e))?void 0:i.includes(t.id)}))}));var c=l.filter((i=>{var s,r=null==(s=i.conditions)||null==(s=s.events)||null==(s=s.values)?void 0:s.find((t=>t.name===e));return!!r&&(!r.propertyFilters||Object.entries(r.propertyFilters).every((e=>{var i,[s,r]=e,n=null==t||null==(i=t.properties)?void 0:i[s];if(L(n)||A(n))return!1;var o=[String(n)],a=cn[r.operator];return a?a(r.values,o):(Tn.warn("Unknown property comparison operator: "+r.operator),!1)})))}));this._updateActivatedSurveys(r.concat(c.map((e=>e.id))||[]))}}onAction(e){var t,i=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[ct])||[];this._actionToSurveys.has(e)&&this._updateActivatedSurveys(i.concat(this._actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t;Tn.info("updating activated surveys",{activatedSurveys:e}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[ct]:[...new Set(e)]})}getSurveys(){var e,t=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[ct];return t||[]}getEventToSurveys(){return this._eventToSurveys}_getActionMatcher(){return this._actionMatcher}}class Nn{constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isFetchingSurveys=!1,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(D(t))return Tn.warn("Flags not loaded yet. Not loading surveys.");var i=C(t);this._isSurveysEnabled=i?t.length>0:t,Tn.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(null!=i&&i.startsWith($n)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Tn.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Tn.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Tn.info("Not loading surveys in cookieless mode without consent.");else{var e=null==v?void 0:v.__PosthogExtensions__;if(e){if(!L(this._isSurveysEnabled)||this._instance.config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._instance.config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var s=e.loadExternalDependency;if(!s)return void this._handleSurveyLoadError("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else Tn.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Dn(this._instance),Tn.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){Tn.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter((t=>t!==e))}}getSurveys(e,t){if(void 0===t&&(t=!1),this._instance.config.disable_surveys)return Tn.info("Disabled. Not loading surveys."),e([]);var i=this._instance.get_property(lt);if(i&&!t)return e(i,{isLoaded:!0});if(this._isFetchingSurveys)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this._isFetchingSurveys=!0,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:t=>{var i;this._isFetchingSurveys=!1;var s=t.statusCode;if(200!==s||!t.json){var r="Surveys API could not be loaded, status: "+s;return Tn.error(r),e([],{isLoaded:!1,error:r})}var n,o=t.json.surveys||[],a=o.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));a.length>0&&(null==(n=this._surveyEventReceiver)||n.register(a));return null==(i=this._instance.persistence)||i.register({[lt]:o}),e(o,{isLoaded:!0})}})}catch(e){throw this._isFetchingSurveys=!1,e}}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Tn.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!D(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Tn.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var s;t=null!==(s=i.find((t=>t.id===e)))&&void 0!==s?s:null})),t}_checkSurveyEligibility(e){if(D(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(D(this._surveyManager))return Tn.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return D(this._surveyManager)?(Tn.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((t=>{var s,r=null!==(s=t.find((t=>t.id===e)))&&void 0!==s?s:null;if(r){var n=this._checkSurveyEligibility(r);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t){var i;if(D(this._surveyManager))Tn.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(Mn.includes(s.type)){var r=null==u?void 0:u.querySelector(t);if(r)return null!=(i=s.appearance)&&i.surveyPopupDelaySeconds?(Tn.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;Tn.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,r),Tn.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,r);Tn.warn("Survey element not found")}else Tn.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Tn.warn("Survey not found")}}displaySurvey(e,t){var s;if(D(this._surveyManager))Tn.warn("init was not called");else{var r=this._getSurveyById(e);if(r){var n=r;if(null!=(s=r.appearance)&&s.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},r,{appearance:i({},r.appearance,{surveyPopupDelaySeconds:0})})),!1===t.ignoreConditions){var o=this.canRenderSurvey(r);if(!o.visible)return void Tn.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==Cn.Inline?this._surveyManager.handlePopoverSurvey(n):this.renderSurvey(n,t.selector)}else Tn.warn("Survey not found")}}}var qn=Ce("[RateLimiter]");class Hn{constructor(e){var t,i;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{qn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void qn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.captureEventsPerSecond=(null==(t=e.config.rate_limiting)?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null==(i=e.config.rate_limiting)?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var r=(new Date).getTime(),n=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(ht))&&void 0!==t?t:{tokens:this.captureEventsBurstLimit,last:r};n.tokens+=(r-n.last)/1e3*this.captureEventsPerSecond,n.last=r,n.tokens>this.captureEventsBurstLimit&&(n.tokens=this.captureEventsBurstLimit);var o=n.tokens<1;return o||e||(n.tokens=Math.max(0,n.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,null==(s=this.instance.persistence)||s.set_property(ht,n),{isRateLimited:o,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var jn=Ce("[RemoteConfig]");class Un{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(jn.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(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 jn.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void jn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return jn.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e)}));this._onRemoteConfig(e)}))}catch(e){jn.error("Error loading remote config",e)}}_onRemoteConfig(e){e?this._instance.config.__preview_remote_config?(this._instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):jn.info("__preview_remote_config is disabled. Logging config instead",e):jn.error("Failed to fetch remote config from PostHog.")}}var zn=3e3;class Bn{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Y((null==t?void 0:t.flush_interval_ms)||zn,250,5e3,Ie.createLogger("flush interval"),zn),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequest(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[s],r=(new Date).getTime();i.data&&C(i.data)&&Te(i.data,(e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp})),e._sendRequest(i)};for(var s in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Te(this._queue,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;L(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)})),this._queue=[],e}}var Vn=["retriesPerformedSoFar"];class Wn{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!L(r)&&"onLine"in r.navigator&&(this._areWeOnline=r.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Ue(r,"online",this._onlineListener),Ue(r,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=s(e,Vn);N(t)&&t>0&&(r.url=sn(r.url,{retry_count:t})),this._instance._send_request(i({},r,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this._enqueue(i({retriesPerformedSoFar:t},r)):null==r.callback||r.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(t),s=Date.now()+i;this._queue.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),Ie.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var{requestOptions:s}of i)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,L(r)||(this._onlineListener&&(r.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(r.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){Ie.error(e)}this._queue=[]}}class Gn{constructor(e){this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)},this._instance=e}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Ue(r,"scroll",this._updateScrollData,{capture:!0}),Ue(r,"scrollend",this._updateScrollData,{capture:!0}),Ue(r,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==r?void 0:r.document.documentElement;var e=C(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=null==r?void 0:r.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 r&&(r.scrollY||r.pageYOffset||r.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return r&&(r.scrollX||r.pageXOffset||r.document.documentElement.scrollLeft)||0}}var Yn=e=>ar(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Jn{constructor(e,t,i,s){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[_t]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Yn,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[_t]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?lr(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 Te(De(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+S(i)]=t})),e}}var Kn=Ce("[SessionId]");class Xn{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._eventEmitter=new Fn,this._sessionHasBeenIdleTooLong=(e,t)=>Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||yi,this._windowIdGenerator=i||yi;var r=this._config.persistence_name||this._config.token,n=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Y(n,60,36e3,Kn.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var o=$i._parse(this._window_id_storage_key),a=$i._parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:$i._remove(this._window_id_storage_key),$i._set(this._primary_window_exists_storage_key,!0)}if(null!=(s=this._config.bootstrap)&&s.sessionID)try{var l=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this._config.bootstrap.sessionID);this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),l)}catch(e){Kn.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return L(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&$i._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&$i._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?$i._parse(this._window_id_storage_key):null}_setSessionId(e,t,i){e===this._sessionId&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,this._persistence.register({[tt]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this._persistence.props[tt];return C(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}destroy(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&r&&(r.removeEventListener("beforeunload",this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._canUseSessionStorage()&&$i._remove(this._primary_window_exists_storage_key)},Ue(r,"beforeunload",this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[s,r,n]=this._getSessionId(),o=this._getWindowId(),a=N(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,c=!r,u=!c&&!e&&this._sessionHasBeenIdleTooLong(i,s);c||u||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),Kn.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=0===s||!e||a?i:s,_=0===n?(new Date).getTime():n;return this._setWindowId(o),this._setSessionId(r,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:s}}_resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{var[e]=this._getSessionId();if(this._sessionHasBeenIdleTooLong((new Date).getTime(),e)){var t=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}}var Qn=["$set_once","$set"],Zn=Ce("[SiteApps]");class eo{constructor(e){this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,r,n,o,a,l,c;if(!e)throw new Error("Event payload is required");var u={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))u[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},s(e,Qn),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(r=e.properties)?void 0:r.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(o=e.properties)?void 0:o.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(a=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(c=e.properties)?void 0:c.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this._bufferedInvocations.length&&(Zn.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>null==t.processEvent?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored)))&&(null==(i=this._stopBuffering)||i.call(this))},s=!1,r=r=>{t.errored=!r,t.loaded=!0,Zn.info("Site app with id "+e.id+" "+(r?"loaded":"errored")),s&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback:e=>{r(e)}});n&&(t.processEvent=n),s=!0}catch(t){Zn.error("Error while initializing PostHog app with config id "+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){Zn.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){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)}_onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(t){Zn.error("Error while processing event "+e.event+" for site app "+i.id,t)}}}onRemoteConfig(e){var t,i,s,r=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void Zn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(s=e.siteApps)&&s.length)if(this.isEnabled){var n=function(e){var t;v["__$$ph_site_app_"+e]=r._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(r._instance,a,(t=>{if(t)return Zn.error("Error while initializing PostHog app with config id "+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else Zn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var to=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&y(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>y(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},io=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),so="i.posthog.com";class ro{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+so,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=io.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=io.EU:this._regionCache[this.apiHost]=io.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if(this.region===io.CUSTOM)return this.apiHost+t;var i=so+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var no={icontains:(e,t)=>!!r&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!r&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!r&&an(t.href,e),not_regex:(e,t)=>!!r&&!an(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class oo{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{oo._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)oo._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e);var s=t._instance.getFeatureFlag(e.feature_flag_key);O(s)&&e.variants[s]&&t._applyTransforms(e.name,s,e.variants[s].transforms)}else if(e.variants)for(var r in e.variants){var n=e.variants[r];oo._matchesTestVariant(n)&&t._applyTransforms(e.name,r,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())oo._logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(D(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();oo._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,s=this._instance.getFeatureFlag(e),r=null==(i=this._flagToExperiments)?void 0:i.get(e);s&&null!=r&&r.variants[s]&&this._applyTransforms(r.name,s,r.variants[s].transforms)}}))}}previewWebExperiment(){var e=oo.getWindowLocation();if(null!=e&&e.search){var t=ri(null==e?void 0:e.search,"__experiment_id"),i=ri(null==e?void 0:e.search,"__experiment_variant");t&&i&&(oo._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!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:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}_showPreviewWebExperiment(e,t,i){var s=i.filter((t=>t.id===e));s&&s.length>0&&(oo._logInfo("Previewing web experiment ["+s[0].name+"] with variant ["+t+"]"),this._applyTransforms(s[0].name,t,s[0].variants[t].transforms))}static _matchesTestVariant(e){return!D(e.conditions)&&(oo._matchUrlConditions(e)&&oo._matchUTMConditions(e))}static _matchUrlConditions(e){var t;if(D(e.conditions)||D(null==(t=e.conditions)?void 0:t.url))return!0;var i,s,r,n=oo.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||no[null!==(s=null==(r=e.conditions)?void 0:r.urlMatchType)&&void 0!==s?s:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==r?void 0:r.location}static _matchUTMConditions(e){var t;if(D(e.conditions)||D(null==(t=e.conditions)?void 0:t.utm))return!0;var i=ir();if(i.utm_source){var s,r,n,o,a,l,c,u,d=null==(s=e.conditions)||null==(s=s.utm)||!s.utm_campaign||(null==(r=e.conditions)||null==(r=r.utm)?void 0:r.utm_campaign)==i.utm_campaign,_=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,h=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return d&&h&&p&&_}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];Ie.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?oo._logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var s;oo._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var r=null==(s=document)?void 0:s.querySelectorAll(i.selector);null==r||r.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):oo._logInfo("Control variants leave the page unmodified.")}_is_bot(){return c&&this._instance?to(c,this._instance.config.custom_blocked_useragents):void 0}}var ao=Ce("[PostHog ExternalIntegrations]"),lo={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class co{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return ao.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,r,n;(!s||null!=(i=v.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(lo[t],(()=>{var i;null==(i=v.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!s&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[t])&&(null==(n=v.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,s]of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;t(i)}}}var uo="[SessionRecording]",_o=Ce(uo);class ho{get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){return this._lazyLoadedSessionRecording?this._lazyLoadedSessionRecording.status:this._receivedFlags&&!this._isRecordingEnabled?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._receivedFlags=!1,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw _o.error("started without valid sessionManager"),new Error(uo+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(uo+' cannot be used with cookieless_mode="always"')}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(et))||!e.enabled),i=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return r&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!L(Object.assign)&&!L(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),_o.info("starting")):this.stopRecording()}}_lazyLoadAndStart(e){var t,i,s;this._isRecordingEnabled&&(null!=v&&null!=(t=v.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(s=v.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return _o.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(it)}_persistRemoteConfig(e){if(this._instance.persistence){var t,s,r=this._instance.persistence,n=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,s=null==t?void 0:t.sampleRate,n=D(s)?null:parseFloat(s);D(n)&&this._resetSampling();var o=null==t?void 0:t.minimumDurationMilliseconds;r.register({[et]:i({enabled:!!t},t,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:n,minimumDurationMilliseconds:L(o)?null:o,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(s=this._instance.sessionManager)?void 0:s.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this._persistRemoteConfig(e),this._receivedFlags=!0,this.startIfEnabledOrStop()):this._receivedFlags=!0:_o.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):_o.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(et);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_onScriptLoaded(e){var t,i;if(null==(t=v.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=v.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture);this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e;null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e;null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t;null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}var po={},go=()=>{},vo="posthog",fo=!en&&-1===(null==g?void 0:g.indexOf("MSIE"))&&-1===(null==g?void 0:g.indexOf("Mozilla")),mo=e=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:He(null==u?void 0:u.location),persistence:"localStorage+cookie",persistence_name:"",loaded:go,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:"2025-05-24"!==e||"history_change",capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",debug:d&&O(null==d?void 0:d.search)&&-1!==d.search.indexOf("__posthog_debug=true")||!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_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==r||null==(t=r.location)?void 0:t.protocol),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,session_recording:{},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:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;Ie.error(t)},get_device_id:e=>e,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:zn},error_tracking:{},_onCapture:go,__preview_eager_load_replay:!1}},yo=e=>{var t={};L(e.process_person)||(t.person_profiles=e.process_person),L(e.xhr_headers)||(t.request_headers=e.xhr_headers),L(e.cookie_name)||(t.persistence_name=e.cookie_name),L(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),L(e.store_google)||(t.save_campaign_params=e.store_google),L(e.verbose)||(t.debug=e.verbose);var i=$e({},t,e);return C(e.property_blacklist)&&(L(e.property_denylist)?i.property_denylist=e.property_blacklist:C(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ie.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class bo{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Ie.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class wo{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new bo,this._personProcessingSetOncePropertiesSent=!1,this.version=f.LIB_VERSION,this._internalEventEmitter=new Fn,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=mo(),this.SentryIntegration=Gi,this.sentryIntegration=e=>function(e,t){var i=Wi(e,t);return{name:Vi,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.featureFlags=new En(this),this.toolbar=new Qi(this),this.scrollManager=new Gn(this),this.pageViewManager=new mr(this),this.surveys=new Nn(this),this.experiments=new oo(this),this.exceptions=new _n(this),this.rateLimiter=new Hn(this),this.requestRouter=new ro(this),this.consent=new Oi(this),this.externalIntegrations=new co(this),this.people={set:(e,t,i)=>{var s=O(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=O(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>Ie.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==vo){var s,r=null!==(s=po[i])&&void 0!==s?s:new wo;return r._init(e,t,i),po[i]=r,po[vo][i]=r,r}return this._init(e,t,i)}_init(e,t,s){var n,o;if(void 0===t&&(t={}),L(e)||M(e))return Ie.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._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles&&(this._initialPersonProfilesConfig=t.person_profiles),this.set_config($e({},mo(t.defaults),yo(t),{name:s,token:e})),this.config.on_xhr_error&&Ie.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ti.GZipJS;var a=this._is_persistence_disabled();this.persistence=new kn(this.config,a),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new kn(i({},this.config,{persistence:"sessionStorage"}),a);var l=i({},this.persistence.props),c=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Bn((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Wn(this),this.__request_queue=[];var u="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(u||(this.sessionManager=new Xn(this),this.sessionPropsManager=new Jn(this,this.sessionManager,this.persistence)),new es(this).startIfEnabledOrStop(),this.siteApps=new eo(this),null==(n=this.siteApps)||n.init(),u||(this.sessionRecording=new ho(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new _i(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new fr(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new pr(this),this.exceptionObserver=new Hi(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Ni(this,Di),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new Ui(this),this.historyAutocapture.startIfEnabled(),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&Ie.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:c}),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var d,_,h=this.config.get_device_id(yi()),p=null!=(d=t.bootstrap)&&d.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(dt,null!=(_=t.bootstrap)&&_.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:p})}if(this._hasBootstrappedFeatureFlags()){var g,v,m=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlags)||{}).filter((e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])})).reduce(((e,i)=>{var s;return e[i]=(null==(s=t.bootstrap)||null==(s=s.featureFlags)?void 0:s[i])||!1,e}),{}),y=Object.keys((null==(v=t.bootstrap)?void 0:v.featureFlagPayloads)||{}).filter((e=>m[e])).reduce(((e,i)=>{var s,r;null!=(s=t.bootstrap)&&null!=(s=s.featureFlagPayloads)&&s[i]&&(e[i]=null==(r=t.bootstrap)||null==(r=r.featureFlagPayloads)?void 0:r[i]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:m,featureFlagPayloads:y})}if(u)this.register_once({distinct_id:yt,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(yi());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(dt,"anonymous")}return Ue(r,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Bi(this,(()=>this._loaded())):this._loaded(),F(this.config._onCapture)&&this.config._onCapture!==go&&(Ie.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&Ie.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}_onRemoteConfig(e){var t,i,s,r,n,o,a,l;if(!u||!u.body)return Ie.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=w(e.supportedCompression,ti.GZipJS)?ti.GZipJS:w(e.supportedCompression,ti.Base64)?ti.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(s=this.sessionRecording)||s.onRemoteConfig(e),null==(r=this.autocapture)||r.onRemoteConfig(e),null==(n=this.heatmaps)||n.onRemoteConfig(e),this.surveys.onRemoteConfig(e),null==(o=this.webVitalsAutocapture)||o.onRemoteConfig(e),null==(a=this.exceptionObserver)||a.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(l=this.deadClicksAutocapture)||l.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){Ie.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this._captureInitialPageview()}),1),new Un(this).load(),this.featureFlags.flags()}_start_queue_if_opted_in(){var e;this.is_capturing()&&(this.config.request_batching&&(null==(e=this._requestQueue)||e.enable()))}_dom_loaded(){this.is_capturing()&&Re(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),null==(e=this._requestQueue)||e.unload(),null==(t=this._retryQueue)||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(fo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=sn(e.url,{ip:this.config.ip?1:0}),e.headers=i({},this.config.request_headers),e.compression="best-available"===e.compression?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,(e=>{var t,s,r,n=i({},e);n.timeout=n.timeout||6e4,n.url=sn(n.url,{_:(new Date).getTime().toString(),ver:f.LIB_VERSION,compression:n.compression});var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=on.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(s=null==(r=je(a,(e=>e.transport===o)))?void 0:r.method)&&void 0!==s?s:a[0].method;if(!l)throw new Error("No available transport method");l(n)})(i({},e,{callback:t=>{var i,s;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null==(i=(s=this.config).on_request_error)||i.call(s,t));null==e.callback||e.callback(t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],s=[],r=[];Re(e,(e=>{e&&(t=e[0],C(t)?r.push(e):F(e)?e.call(this):C(e)&&"alias"===t?i.push(e):C(e)&&-1!==t.indexOf("capture")&&F(this[t])?r.push(e):s.push(e))}));var n=function(e,t){Re(e,(function(e){if(C(e[0])){var i=t;Te(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};n(i,this),n(s,this),n(r,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,s){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!L(e)&&O(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(n&&!this.config.__preview_capture_bot_pageviews)){var o=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==o||!o.isRateLimited){null!=t&&t.$current_url&&!O(null==t?void 0:t.$current_url)&&(Ie.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=(null==s?void 0:s.timestamp)||a,c=yi(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&n&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),(null==s?void 0:s.$set)&&(u.$set=null==s?void 0:s.$set);var d,_=this._calculate_set_once_properties(null==s?void 0:s.$set_once);if(_&&(u.$set_once=_),(u=Ne(u,null!=s&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,L(null==s?void 0:s.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===Pn.DISMISSED||e===Pn.SENT){var h=null==t?void 0:t[In.SURVEY_ID],p=null==t?void 0:t[In.SURVEY_ITERATION];d={id:h,current_iteration:p},localStorage.getItem(On(d))||localStorage.setItem(On(d),"true"),u.$set=i({},u.$set,{[Ln({id:h,current_iteration:p},e===Pn.SENT?"responded":"dismissed")]:!0})}var g=i({},u.properties.$set,u.$set);if(T(g)||this.setPersonPropertiesForFlags(g),!D(this.config.before_send)){var v=this._runBeforeSend(u);if(!v)return;u=v}this._internalEventEmitter.emit("eventCaptured",u);var f={method:"POST",url:null!==(r=null==s?void 0:s._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:null==s?void 0:s._batchKey};return!this.config.request_batching||s&&(null==s||!s._batchKey)||null!=s&&s.send_instantly?this._send_retriable_request(f):this._requestQueue.enqueue(f),u}Ie.critical("This capture call is ignored due to client rate limiting.")}}else Ie.error("No event name provided to posthog.capture")}else Ie.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=i({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),"$snapshot"===e){var l=i({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!O(a.distinct_id)&&!N(a.distinct_id)||M(a.distinct_id))&&Ie.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,d=dr(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime());a.$session_id=_,a.$window_id=h}this.sessionPropsManager&&$e(a,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&$e(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){a.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===io.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=$e(a,c),"$pageview"===e&&u&&(a.title=u.title),!L(o)){var v=s.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}g&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=$e({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),C(this.config.property_denylist)?Te(this.config.property_denylist,(function(e){delete a[e]})):Ie.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(Ie.error("sanitize_properties is deprecated. Use before_send instead"),a=f(a,e));var m=this._hasPersonProcessing();return a.$process_person_profile=m,m&&!n&&this._requirePersonProcessing("_calculate_event_properties"),a}_calculate_set_once_properties(e){var t;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent)return e;var i=this.persistence.get_initial_props(),s=null==(t=this.sessionPropsManager)?void 0:t.getSetOnceProps(),r=$e({},i,s||{},e||{}),n=this.config.sanitize_properties;return n&&(Ie.error("sanitize_properties is deprecated. Use before_send instead"),r=n(r,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,T(r)?void 0:r}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var s;null==(s=this.persistence)||s.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(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(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=An),this.surveys.displaySurvey(e,t)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,s){if(!this.__loaded||!this.persistence)return Ie.uninitializedWarning("posthog.identify");if(N(e)&&(e=e.toString(),Ie.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()))Ie.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!==yt){if(this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(Be)&&(this.unregister(Be),this.register({distinct_id:e}));var o="anonymous"===(this.persistence.get_property(dt)||"anonymous");e!==r&&o?(this.persistence.set_property(dt,"identified"),this.setPersonPropertiesForFlags(i({},s||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:s||{}}),this._cachedPersonProperties=ln(e,t,s),this.featureFlags.setAnonymousDistinctId(r)):(t||s)&&this.setPersonProperties(t,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(ut))}}else Ie.critical('The string "'+yt+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else Ie.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var s=ln(this.get_distinct_id(),e,t);this._cachedPersonProperties!==s?(this.setPersonPropertiesForFlags(i({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=s):Ie.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,s){if(e&&t){if(this._requirePersonProcessing("posthog.group")){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},r,{[e]:t})}),s&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s}),this.setGroupPropertiesForFlags({[e]:s})),r[e]===t||s||this.reloadFeatureFlags()}}else Ie.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,r;if(Ie.info("reset"),!this.__loaded)return Ie.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(s=this.persistence)||s.set_property(dt,"anonymous"),null==(r=this.sessionManager)||r.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:yt,$device_id:null},"");else{var o=this.config.get_device_id(yi());this.register_once({distinct_id:o,$device_id:e?o:n},"")}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 null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?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(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;s+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return s}alias(e,t){return e===this.get_property(ze)?(Ie.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(L(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Be,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Ie.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(R(e)){var s,r,n,o,a;$e(this.config,yo(e));var l=this._is_persistence_disabled();null==(s=this.persistence)||s.update_config(this.config,t,l),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new kn(i({},this.config,{persistence:"sessionStorage"}),l);var c=this._checkLocalStorageForDebug(this.config.debug);q(c)&&(this.config.debug=c),q(this.config.debug)&&(this.config.debug?(f.DEBUG=!0,Pi._is_supported()&&Pi._set("ph_debug","true"),Ie.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(f.DEBUG=!1,Pi._is_supported()&&Pi._remove("ph_debug"))),null==(r=this.sessionRecording)||r.startIfEnabledOrStop(),null==(n=this.autocapture)||n.startIfEnabled(),null==(o=this.heatmaps)||o.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(a=this.externalIntegrations)||a.startIfEnabledOrStop()}}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var s,r,n,o,a;if(null==(s=this.sessionManager)||s.checkAndGetSessionAndWindowId(),i.sampling)null==(r=this.sessionRecording)||r.overrideSampling();if(i.linked_flag)null==(n=this.sessionRecording)||n.overrideLinkedFlag();if(i.url_trigger)null==(o=this.sessionRecording)||o.overrideTrigger("url");if(i.event_trigger)null==(a=this.sessionRecording)||a.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(i({},r,t))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:vo;return t!==vo&&(t=vo+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(dt))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(dt))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&T(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[Be])&&(null==(t=this.persistence)||null==(t=t.props)||!t[ft]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(Ie.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(ft,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_sync_opt_out_with_persistence(){var e,t,i,s,r=this._is_persistence_disabled();(null==(e=this.persistence)?void 0:e._disabled)!==r&&(null==(i=this.persistence)||i.set_disabled(r));(null==(t=this.sessionPersistence)?void 0:t._disabled)!==r&&(null==(s=this.sessionPersistence)||s.set_disabled(r));return r}opt_in_capturing(e){if("always"!==this.config.cookieless_mode){var t,i;if("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())this.reset(!0),null==(t=this.sessionManager)||t.destroy(),this.sessionManager=new Xn(this),this.persistence&&(this.sessionPropsManager=new Jn(this,this.sessionManager,this.persistence)),this.sessionRecording=new ho(this),this.sessionRecording.startIfEnabledOrStop();if(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),L(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)this.capture(null!==(i=null==e?void 0:e.captureEventName)&&void 0!==i?i:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}else Ie.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:yt,$device_id:null}),null==(e=this.sessionManager)||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(t=this.sessionRecording)||t.stopRecording(),this.sessionRecording=void 0,this._captureInitialPageview())):Ie.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===Li.GRANTED?"granted":e===Li.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return c?to(c,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){u&&("visible"===u.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:u.title},{send_instantly:!0}),this._visibilityStateListener&&(u.removeEventListener("visibilitychange",this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Ue(u,"visibilitychange",this._visibilityStateListener)))}debug(e){!1===e?(null==r||r.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==r||r.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}))}_shouldDisableFlags(){var e,t,i,s,r,n,o,a=this._originalUserConfig||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ie.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",s=!1,r=Ie,n=(t="advanced_disable_flags")in(e=a)&&!L(e[t]),o=i in e&&!L(e[i]),n?e[t]:o?(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):s)}_runBeforeSend(e){if(D(this.config.before_send))return e;var t=C(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),D(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return j(e.event)?Ie.warn(r+". This can cause unexpected behavior."):Ie.info(r),null}i.properties&&!T(i.properties)||Ie.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?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)})}_checkLocalStorageForDebug(e){var t=q(e)&&!e,i=Pi._is_supported()&&"true"===Pi._get("ph_debug");return!t&&(!!i||e)}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Ae(e.prototype[t[i]])}(wo,["identify"]);var Eo,So;Eo=po[vo]=new wo,(So=v.posthog)&&Te(So._i,(function(e){if(e&&C(e)){var t=Eo.init(e[0],e[1],e[2]),i=So[e[2]]||So;t&&(t._execute_array.call(t.people,i.people),t._execute_array(i))}})),v.posthog=Eo,function(){function e(){e.done||(e.done=!0,fo=!1,Te(po,(function(e){e._dom_loaded()})))}null!=u&&u.addEventListener?"complete"===u.readyState?e():Ue(u,"DOMContentLoaded",e,{capture:!1}):r&&Ie.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}();
|
|
2
2
|
//# sourceMappingURL=array.no-external.js.map
|