posthog-js 1.272.1 → 1.273.0
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/dist/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/lib/package.json +1 -1
- package/lib/src/posthog-core.js +2 -0
- package/lib/src/posthog-core.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
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,u=null==n?void 0:n.navigator,c=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==u?void 0:u.userAgent,v=null!=r?r:{},f={DEBUG:!1,LIB_VERSION:"1.272.1"},m=["$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 y(e,t){return-1!==e.indexOf(t)}var b=function(e){return e.trim()},w=function(e){return e.replace(/^\$/,"")};var S=Array.isArray,E=Object.prototype,k=E.hasOwnProperty,x=E.toString,I=S||function(e){return"[object Array]"===x.call(e)},R=e=>"function"==typeof e,C=e=>e===Object(e)&&!I(e),P=e=>{if(C(e)){for(var t in e)if(k.call(e,t))return!1;return!0}return!1},T=e=>void 0===e,F=e=>"[object String]"==x.call(e),M=e=>F(e)&&0===e.trim().length,L=e=>null===e,O=e=>T(e)||L(e),A=e=>"[object Number]"==x.call(e),D=e=>"[object Boolean]"===x.call(e),N=e=>e instanceof FormData,q=e=>y(m,e);function B(e){return null===e||"object"!=typeof e}function H(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function z(e){return!T(Event)&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var U=[!0,"true",1,"1","yes"],j=e=>y(U,e),W=[!1,"false",0,"0","no"];function V(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),A(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),V(r||i,t,i,s))}class G{constructor(e){this._options=e,this._buckets={},this._refillBuckets=()=>{Object.keys(this._buckets).forEach((e=>{var t=this._getBucket(e)+this._refillRate;t>=this._bucketSize?delete this._buckets[e]:this._setBucket(e,t)}))},this._getBucket=e=>this._buckets[String(e)],this._setBucket=(e,t)=>{this._buckets[String(e)]=t},this.consumeRateLimit=e=>{var t,i,s=null!==(t=this._getBucket(e))&&void 0!==t?t:this._bucketSize;if(0===(s=Math.max(s-1,0)))return!0;this._setBucket(e,s);var r=0===s;return r&&(null==(i=this._onBucketRateLimited)||i.call(this,e)),r},this._onBucketRateLimited=this._options._onBucketRateLimited,this._bucketSize=V(this._options.bucketSize,0,100,this._options._logger),this._refillRate=V(this._options.refillRate,0,this._bucketSize,this._options._logger),this._refillInterval=V(this._options.refillInterval,0,864e5,this._options._logger),this._removeInterval=setInterval((()=>{this._refillBuckets()}),this._refillInterval)}stop(){this._removeInterval&&(clearInterval(this._removeInterval),this._removeInterval=void 0)}}var Y,J,K,X=e=>e instanceof Error;function Q(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return K&&i.length===J||(J=i.length,K=i.reduce(((i,s)=>{Y||(Y={});var r=Y[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,u=t[s];if(l&&u){i[l]=u,Y[s]=[l,u];break}}return i}),{})),K}}var Z="?";function ee(e,t,i,s){var r={platform:"web:javascript",filename:e,function:"<anonymous>"===t?Z:t,in_app:!0};return T(i)||(r.lineno=i),T(s)||(r.colno=s),r}var te=(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]:Z,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},ie=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,se=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,re=/\((\S*)(?::(\d+))(?::(\d+))\)/,ne=e=>{var t=ie.exec(e);if(t){var[,i,s,r]=t;return ee(i,Z,+s,+r)}var n=se.exec(e);if(n){if(n[2]&&0===n[2].indexOf("eval")){var o=re.exec(n[2]);o&&(n[2]=o[1],n[3]=o[2],n[4]=o[3])}var[a,l]=te(n[1]||Z,n[2]);return ee(l,a,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},oe=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ae=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,le=e=>{var t=oe.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=ae.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]||Z;return[r,s]=te(r,s),ee(s,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},ue=/\(error: (.*)\)/,ce=50;function de(){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=ue.test(a)?a.replace(ue,"$1"):a;if(!l.match(/\S*Error: /)){for(var u of t){var c=u(l);if(c){r.push(c);break}}if(r.length>=ce)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,ce).map((e=>{return i({},e,{filename:e.filename||(s=t,s[s.length-1]||{}).filename,function:e.function||Z});var s}))}(r)}}class _e{constructor(e,t,i){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===i&&(i=[]),this.coercers=e,this.modifiers=i,this.stackParser=de(...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&&I(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:Q(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 he{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=F(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 H(e,"DOMException")}isDOMError(e){return H(e,"DOMError")}}class pe{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 ge{constructor(){}match(e){return H(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 ve=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class fe{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(ve);return s&&(t=s[1],i=s[2]),[t,i]}}var me=["fatal","error","warning","log","info","debug"];function ye(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 be{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 z(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: "+ye(e)}isSeverityLevel(e){return F(e)&&!M(e)&&me.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(X(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class we{match(e){return z(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+ye(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Se{match(e){return B(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 Ee{match(e){return H(e,"PromiseRejectionEvent")}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return B(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(B(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 ke=e=>{var t={_log:function(t){if(r&&(f.DEBUG||v.POSTHOG_DEBUG)&&!T(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=>ke(e+" "+t)};return t},xe=ke("[PostHog.js]"),Ie=xe.createLogger,Re={};function Ce(e,t,i){if(I(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)===Re)return}function Pe(e,t,i){if(!O(e)){if(I(e))return Ce(e,t,i);if(N(e)){for(var s of e.entries())if(t.call(i,s[1],s[0])===Re)return}else for(var r in e)if(k.call(e,r)&&t.call(i,e[r],r)===Re)return}}var Te=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 Ce(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},Fe=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 Ce(i,(function(t){Ce(t,(function(t){e.push(t)}))})),e};function Me(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 $e=function(e){try{return e()}catch(e){return}},Le=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){xe.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),xe.critical(e)}}},Oe=function(e){var t={};return Pe(e,(function(e,i){(F(e)&&e.length>0||A(e))&&(t[i]=e)})),t};function Ae(e,t){return i=e,s=e=>F(e)&&!L(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),I(t)?(n=[],Ce(t,(t=>{n.push(e(t))}))):(n={},Pe(t,((t,i)=>{r.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,s,r}var De=["herokuapp.com","vercel.app","netlify.app"];function Ne(e){var t=null==e?void 0:e.hostname;if(!F(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of De)if(i===s)return!1;return!0}function qe(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Be(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 He="$people_distinct_id",ze="__alias",Ue="__timers",je="$autocapture_disabled_server_side",We="$heatmaps_enabled_server_side",Ve="$exception_capture_enabled_server_side",Ge="$error_tracking_suppression_rules",Ye="$error_tracking_capture_extension_exceptions",Je="$web_vitals_enabled_server_side",Ke="$dead_clicks_enabled_server_side",Xe="$web_vitals_allowed_metrics",Qe="$session_recording_remote_config",Ze="$session_recording_enabled_server_side",et="$console_log_recording_enabled_server_side",tt="$session_recording_network_payload_capture",it="$session_recording_masking",st="$session_recording_canvas_recording",rt="$replay_sample_rate",nt="$replay_minimum_duration",ot="$replay_script_config",at="$sesid",lt="$session_is_sampled",ut="$session_recording_url_trigger_activated_session",ct="$session_recording_event_trigger_activated_session",dt="$enabled_feature_flags",_t="$early_access_features",ht="$feature_flag_details",pt="$stored_person_properties",gt="$stored_group_properties",vt="$surveys",ft="$surveys_activated",mt="$flag_call_reported",yt="$user_state",bt="$client_session_props",wt="$capture_rate_limit",St="$initial_campaign_params",Et="$initial_referrer_info",kt="$initial_person_info",xt="$epp",It="__POSTHOG_TOOLBAR__",Rt="$posthog_cookieless",Ct=[He,ze,"__cmpns",Ue,Ze,We,at,dt,Ge,yt,_t,ht,gt,pt,vt,mt,bt,wt,St,Et,xt,kt];function Pt(e){return e instanceof Element&&(e.id===It||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function Tt(e){return!!e&&1===e.nodeType}function Ft(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Mt(e){return!!e&&3===e.nodeType}function $t(e){return!!e&&11===e.nodeType}function Lt(e){return e?b(e).split(/\s+/):[]}function Ot(e){var t=null==r?void 0:r.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function At(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 Lt(t)}function Dt(e){return O(e)?null:b(e).split(/(\s+)/).filter((e=>ti(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Nt(e){var t="";return Gt(e)&&!Yt(e)&&e.childNodes&&e.childNodes.length&&Pe(e.childNodes,(function(e){var i;Mt(e)&&e.textContent&&(t+=null!==(i=Dt(e.textContent))&&void 0!==i?i:"")})),b(t)}function qt(e){return T(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Bt=["a","button","form","input","select","textarea","label"];function Ht(e,t){if(T(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 zt(e){var t=e.parentNode;return!(!t||!Tt(t))&&t}var Ut=[".ph-no-rageclick",".ph-no-capture"];var jt=e=>!e||Ft(e,"html")||!Tt(e),Wt=(e,t)=>{if(!r||jt(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],n=e;n.parentNode&&!Ft(n,"body");)if($t(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=zt(n);if(!o)break;if(t||Bt.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 Vt(e,t,i,s,n){var o,a,l,u;if(void 0===i&&(i=void 0),!r||jt(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!Ot(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&Ot(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var c=i.dom_event_allowlist;if(c&&!c.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:d,targetElementList:_}=Wt(e,s);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(T(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(!Ht(_,null==(u=i)?void 0:u.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&&(Bt.indexOf(p)>-1||"true"===e.getAttribute("contenteditable"))}}function Gt(e){for(var t=e;t.parentNode&&!Ft(t,"body");t=t.parentNode){var i=At(t);if(y(i,"ph-sensitive")||y(i,"ph-no-capture"))return!1}if(y(At(e),"ph-include"))return!0;var s=e.type||"";if(F(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(F(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 Yt(e){return!!(Ft(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ft(e,"select")||Ft(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})",Kt=new RegExp("^(?:"+Jt+")$"),Xt=new RegExp(Jt),Qt="\\d{3}-?\\d{2}-?\\d{4}",Zt=new RegExp("^("+Qt+")$"),ei=new RegExp("("+Qt+")");function ti(e,t){if(void 0===t&&(t=!0),O(e))return!1;if(F(e)){if(e=b(e),(t?Kt:Xt).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Zt:ei).test(e))return!1}return!0}function ii(e){var t=Nt(e);return ti(t=(t+" "+si(e)).trim())?t:""}function si(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Pe(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=Nt(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+si(e)).trim())}catch(e){xe.error("[AutoCapture]",e)}})),t}function ri(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 Me(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[ni(t.toString())]=ni(i.toString())})),r+=":",r+=Me(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:oi(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Me(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 ni(e){return e.replace(/"|\\"/g,'\\"')}function oi(e){var t=e.attr__class;return t?I(t)?t:Lt(t):void 0}class ai{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 li="$copy_autocapture",ui=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ci=["fatal","error","warning","log","info","debug"],di=["localhost","127.0.0.1"],_i=e=>{var t=null==c?void 0:c.createElement("a");return T(t)?null:(t.href=e,t)},hi=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return Pe(e,(function(e,t){T(e)||T(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)},pi=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(!I(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){xe.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},gi=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],u=(a||"").split("&"),c=[],d=0;d<u.length;d++){var _=u[d].split("=");I(_)&&(t.includes(_[0])?c.push(_[0]+"="+i):c.push(u[d]))}var h=l;return null!=a&&(h+="?"+c.join("&")),null!=n&&(h+="#"+n),h},vi=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},fi=Ie("[AutoCapture]");function mi(e,t){return t.length>e?t.slice(0,e)+"...":t}function yi(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Tt(t));return t}function bi(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};Bt.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?n.$el_text=mi(1024,ii(e)):n.$el_text=mi(1024,Nt(e)));var o=At(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),Pe(e.attributes,(function(i){var r;if((!Yt(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==s||!s.includes(i.name))&&!t&&ti(i.value)&&(r=i.name,!F(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Lt(o).join(" ")),n["attr__"+i.name]=mi(1024,o)}}));for(var a=1,l=1,u=e;u=yi(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function wi(e,t){for(var i,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=t,c=[e],d=e;d.parentNode&&!Ft(d,"body");)$t(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var _,h=[],p={},g=!1,v=!1;if(Pe(c,(e=>{var t=Gt(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&ti(g)&&g),y(At(e),"ph-no-capture")&&(v=!0),h.push(bi(e,o,a,l));var i=function(e){if(!Gt(e))return{};var t={};return Pe(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&&ti(s)&&(t[i]=s)}})),t}(e);Te(p,i)})),v)return{props:{},explicitNoCapture:v};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=ii(e):h[0].$el_text=Nt(e)),g){var f,m;h[0].attr__href=g;var b=null==(f=_i(g))?void 0:f.host,w=null==r||null==(m=r.location)?void 0:m.host;b&&w&&b!==w&&(_=g)}return{props:Te({$event_type:n.type,$ce_version:1},u?{}:{$elements:h},{$elements_chain:ri(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 Si{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this.rageclicks=new ai,this._elementsChainAsString=!1,this.instance=e,this._elementSelectors=null}get _config(){var e,t,i=C(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&&c){var e=e=>{e=e||(null==r?void 0:r.event);try{this._captureEvent(e)}catch(e){fi.error("Failed to capture event",e)}};if(Be(c,"submit",e,{capture:!0}),Be(c,"change",e,{capture:!0}),Be(c,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==r?void 0:r.event),this._captureEvent(e,li)};Be(c,"copy",t,{capture:!0}),Be(c,"cut",t,{capture:!0})}}}else fi.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({[je]:!!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==c?void 0:c.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[je],s=this._isDisabledServerSide;if(L(s)&&!D(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=qt(e);if(Mt(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||jt(e))return!1;var i,s;if(!1===(i=D(t)?!!t&&Ut:null!==(s=null==t?void 0:t.css_selector_ignorelist)&&void 0!==s?s:Ut))return!1;var{targetElementList:n}=Wt(e,!1);return!Ht(n,i)}(s,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var n=t===li;if(s&&Vt(s,e,this._config,n,n?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=wi(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===li){var u,c=Dt(null==r||null==(u=r.getSelection())?void 0:u.toString()),d=e.type||"clipboard";if(!c)return!1;o.$selected_content=c,o.$copy_type=d}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return R(null==c?void 0:c.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return A(e)&&isFinite(e)&&Math.floor(e)===e});var Ei="0123456789abcdef";class ki{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 ki(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Ei.charAt(this.bytes[t]>>>4)+Ei.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 ki(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 xi{constructor(){this._timestamp=0,this._counter=0,this._random=new Ci}generate(){var e=this.generateOrAbort();if(T(e)){this._timestamp=0;var t=this.generateOrAbort();if(T(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 ki.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 Ii,Ri=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&&!T(r.crypto)&&crypto.getRandomValues&&(Ri=e=>crypto.getRandomValues(e));class Ci{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(Ri(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var Pi=()=>Ti().toString(),Ti=()=>(Ii||(Ii=new xi)).generate(),Fi="";var Mi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function $i(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=c),Fi)return Fi;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_"+Pi();!Fi&&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",Fi=n)}return Fi}(e);if(!i){var s=(e=>{var t=e.match(Mi);return t?t[0]:""})(e);s!==i&&xe.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}var Li={_is_supported:()=>!!c,_error:function(e){xe.error("cookieStore error: "+e)},_get:function(e){if(c){try{for(var t=e+"=",i=c.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(Li._get(e))||{}}catch(e){}return t},_set:function(e,t,i,s,r){if(c)try{var n="",o="",a=$i(c.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 u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&xe.warn("cookieStore warning: large cookie, len="+u.length),c.cookie=u,u}catch(e){return}},_remove:function(e,t){if(null!=c&&c.cookie)try{Li._set(e,"",-1,t)}catch(e){return}}},Oi=null,Ai={_is_supported:function(){if(!L(Oi))return Oi;var e=!0;if(T(r))e=!1;else try{var t="__mplssupport__";Ai._set(t,"xyz"),'"xyz"'!==Ai._get(t)&&(e=!1),Ai._remove(t)}catch(t){e=!1}return e||xe.error("localStorage unsupported; falling back to cookie store"),Oi=e,e},_error:function(e){xe.error("localStorage error: "+e)},_get:function(e){try{return null==r?void 0:r.localStorage.getItem(e)}catch(e){Ai._error(e)}return null},_parse:function(e){try{return JSON.parse(Ai._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==r||r.localStorage.setItem(e,JSON.stringify(t))}catch(e){Ai._error(e)}},_remove:function(e){try{null==r||r.localStorage.removeItem(e)}catch(e){Ai._error(e)}}},Di=["distinct_id",at,lt,xt,kt],Ni=i({},Ai,{_parse:function(e){try{var t={};try{t=Li._parse(e)||{}}catch(e){}var i=Te(t,JSON.parse(Ai._get(e)||"{}"));return Ai._set(e,i),i}catch(e){}return null},_set:function(e,t,i,s,r,n){try{Ai._set(e,t,void 0,void 0,n);var o={};Di.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&Li._set(e,o,i,s,r,n)}catch(e){Ai._error(e)}},_remove:function(e,t){try{null==r||r.localStorage.removeItem(e),Li._remove(e,t)}catch(e){Ai._error(e)}}}),qi={},Bi={_is_supported:function(){return!0},_error:function(e){xe.error("memoryStorage error: "+e)},_get:function(e){return qi[e]||null},_parse:function(e){return qi[e]||null},_set:function(e,t){qi[e]=t},_remove:function(e){delete qi[e]}},Hi=null,zi={_is_supported:function(){if(!L(Hi))return Hi;if(Hi=!0,T(r))Hi=!1;else try{var e="__support__";zi._set(e,"xyz"),'"xyz"'!==zi._get(e)&&(Hi=!1),zi._remove(e)}catch(e){Hi=!1}return Hi},_error:function(e){xe.error("sessionStorage error: ",e)},_get:function(e){try{return null==r?void 0:r.sessionStorage.getItem(e)}catch(e){zi._error(e)}return null},_parse:function(e){try{return JSON.parse(zi._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==r||r.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){zi._error(e)}},_remove:function(e){try{null==r||r.sessionStorage.removeItem(e)}catch(e){zi._error(e)}}},Ui=function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e}({});class ji{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?Ui.DENIED:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||(this.consent===Ui.DENIED||this.consent===Ui.PENDING&&(this._config.opt_out_capturing_by_default||"on_reject"===this._config.cookieless_mode))}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Ui.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 j(e)?Ui.GRANTED:y(W,e)?Ui.DENIED:Ui.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?Ai:Li;var t="localStorage"===e?Li:Ai;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(j(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!qe([null==u?void 0:u.doNotTrack,null==u?void 0:u.msDoNotTrack,v.doNotTrack],(e=>j(e)))}}var Wi=Ie("[Dead Clicks]"),Vi=()=>!0,Gi=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Ke)),s=e.instance.config.capture_dead_clicks;return D(s)?s:i};class Yi{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({[Ke]: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?Wi.error("failed to load script",t):e()}))}_start(){var e;if(c){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=C(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(c),Wi.info("starting...")}}else Wi.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Wi.info("stopping..."))}}var Ji=Ie("[ExceptionAutocapture]");class Ki{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){Ji.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[Ve]),this._config=this._requiredConfig(),this._rateLimiter=new G({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:Ji}),this.startIfEnabled()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return C(e)?t=i({},t,e):(T(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&&(Ji.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 Ji.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({[Ve]: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)?Ji.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}}function Xi(e,t,i){try{if(!(t in e))return()=>{};var s=e[t],r=i(s);return R(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=r,()=>{e[t]=s}}catch(e){return()=>{}}}class Qi{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&&(xe.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,xe.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(r&&r.history){var i=this;null!=(e=r.history.pushState)&&e.__posthog_wrapped__||Xi(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__||Xi(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){xe.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Be(r,"popstate",e),this._popstateListener=()=>{r&&r.removeEventListener("popstate",e)}}}}function Zi(e){var t,i;return(null==(t=JSON.stringify(e,(i=[],function(e,t){if(C(t)){for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(t)?"[Circular]":(i.push(t),t)}return t})))?void 0:t.length)||0}function es(e,t){if(void 0===t&&(t=6606028.8),e.size>=t&&e.data.length>1){var i=Math.floor(e.data.length/2),s=e.data.slice(0,i),r=e.data.slice(i);return[es({size:Zi(s),data:s,sessionId:e.sessionId,windowId:e.windowId}),es({size:Zi(r),data:r,sessionId:e.sessionId,windowId:e.windowId})].flatMap((e=>e))}return[e]}var ts=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(ts||{}),is=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(is||{}),ss="[SessionRecording]",rs="redacted",ns={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com","bam.nr-data.net"]},os=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],as=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],ls=["/s/","/e/","/i/"];function us(e,t,i,s){if(O(e))return e;var r=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return F(r)&&(r=parseInt(r)),r>i?ss+" "+s+" body too large to record ("+r+" bytes)":e}function cs(e,t){if(O(e))return e;var i=e;return ti(i,!1)||(i=ss+" "+t+" body "+rs),Pe(as,(e=>{var s,r;null!=(s=i)&&s.length&&-1!==(null==(r=i)?void 0:r.indexOf(e))&&(i=ss+" "+t+" body "+rs+" as might contain: "+e)})),i}var ds=(e,t)=>{var s,r,n,o={payloadSizeLimitBytes:ns.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...ns.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...ns.payloadHostDenyList]},a=!1!==e.session_recording.recordHeaders&&t.recordHeaders,l=!1!==e.session_recording.recordBody&&t.recordBody,u=!1!==e.capture_performance&&t.recordPerformance,c=(s=o,n=Math.min(1e6,null!==(r=s.payloadSizeLimitBytes)&&void 0!==r?r:1e6),e=>(null!=e&&e.requestBody&&(e.requestBody=us(e.requestBody,e.requestHeaders,n,"Request")),null!=e&&e.responseBody&&(e.responseBody=us(e.responseBody,e.responseHeaders,n,"Response")),e)),d=t=>{return c(((e,t)=>{var i,s=_i(e.name),r=0===t.indexOf("http")?null==(i=_i(t))?void 0:i.pathname:t;"/"===r&&(r="");var n=null==s?void 0:s.pathname.replace(r||"","");if(!(s&&n&&ls.some((e=>0===n.indexOf(e)))))return e})((s=(i=t).requestHeaders,O(s)||Pe(Object.keys(null!=s?s:{}),(e=>{os.includes(e.toLowerCase())&&(s[e]=rs)})),i),e.api_host));var i,s},_=R(e.session_recording.maskNetworkRequestFn);return _&&R(e.session_recording.maskCapturedNetworkRequestFn)&&xe.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),_&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{var s=e.session_recording.maskNetworkRequestFn({url:t.name});return i({},t,{name:null==s?void 0:s.url})}),o.maskRequestFn=R(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,s=d(t);return s&&null!==(i=null==e.session_recording.maskCapturedNetworkRequestFn?void 0:e.session_recording.maskCapturedNetworkRequestFn(s))&&void 0!==i?i:void 0}:e=>function(e){if(!T(e))return e.requestBody=cs(e.requestBody,"Request"),e.responseBody=cs(e.responseBody,"Response"),e}(d(e)),i({},ns,o,{recordHeaders:a,recordBody:l,recordPerformance:u,recordInitialRequests:u})};class _s{constructor(e,t){var i,s;void 0===t&&(t={}),this._loggedTracker={},this._onNodeRateLimited=e=>{if(!this._loggedTracker[e]){var t,i;this._loggedTracker[e]=!0;var s=this._getNode(e);null==(t=(i=this._options).onBlockedNode)||t.call(i,e,s)}},this._getNodeOrRelevantParent=e=>{var t=this._getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){var i=t.closest("svg");if(i)return[this._rrweb.mirror.getId(i),i]}return[e,t]},this._getNode=e=>this._rrweb.mirror.getNode(e),this._numberOfChanges=e=>{var t,i,s,r,n,o,a,l;return(null!==(t=null==(i=e.removes)?void 0:i.length)&&void 0!==t?t:0)+(null!==(s=null==(r=e.attributes)?void 0:r.length)&&void 0!==s?s:0)+(null!==(n=null==(o=e.texts)?void 0:o.length)&&void 0!==n?n:0)+(null!==(a=null==(l=e.adds)?void 0:l.length)&&void 0!==a?a:0)},this.throttleMutations=e=>{if(3!==e.type||0!==e.data.source)return e;var t=e.data,i=this._numberOfChanges(t);t.attributes&&(t.attributes=t.attributes.filter((e=>{var[t]=this._getNodeOrRelevantParent(e.id);return!this._rateLimiter.consumeRateLimit(t)&&e})));var s=this._numberOfChanges(t);return 0!==s||i===s?e:void 0},this._rrweb=e,this._options=t,this._rateLimiter=new G({bucketSize:null!==(i=this._options.bucketSize)&&void 0!==i?i:100,refillRate:null!==(s=this._options.refillRate)&&void 0!==s?s:10,refillInterval:1e3,_onBucketRateLimited:this._onNodeRateLimited,_logger:xe})}}var hs=Uint8Array,ps=Uint16Array,gs=Uint32Array,vs=new hs([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]),fs=new hs([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]),ms=new hs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ys=function(e,t){for(var i=new ps(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var r=new gs(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]},bs=ys(vs,2),ws=bs[0],Ss=bs[1];ws[28]=258,Ss[258]=28;for(var Es=ys(fs,0)[1],ks=new ps(32768),xs=0;xs<32768;++xs){var Is=(43690&xs)>>>1|(21845&xs)<<1;Is=(61680&(Is=(52428&Is)>>>2|(13107&Is)<<2))>>>4|(3855&Is)<<4,ks[xs]=((65280&Is)>>>8|(255&Is)<<8)>>>1}var Rs=function(e,t,i){for(var s=e.length,r=0,n=new ps(t);r<s;++r)++n[e[r]-1];var o,a=new ps(t);for(r=0;r<t;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new ps(1<<t);var l=15-t;for(r=0;r<s;++r)if(e[r])for(var u=r<<4|e[r],c=t-e[r],d=a[e[r]-1]++<<c,_=d|(1<<c)-1;d<=_;++d)o[ks[d]>>>l]=u}else for(o=new ps(s),r=0;r<s;++r)o[r]=ks[a[e[r]-1]++]>>>15-e[r];return o},Cs=new hs(288);for(xs=0;xs<144;++xs)Cs[xs]=8;for(xs=144;xs<256;++xs)Cs[xs]=9;for(xs=256;xs<280;++xs)Cs[xs]=7;for(xs=280;xs<288;++xs)Cs[xs]=8;var Ps=new hs(32);for(xs=0;xs<32;++xs)Ps[xs]=5;var Ts=Rs(Cs,9,0),Fs=Rs(Ps,5,0),Ms=function(e){return(e/8>>0)+(7&e&&1)},$s=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof ps?ps:e instanceof gs?gs:hs)(i-t);return s.set(e.subarray(t,i)),s},Ls=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},Os=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},As=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 hs(0),0];if(1==r){var o=new hs(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],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[u].f<i[d].f?u++:d++],l=i[u!=c&&i[u].f<i[d].f?u++:d++],i[c++]={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 ps(_+1),p=Ds(i[c-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 hs(h),p]},Ds=function(e,t,i){return-1==e.s?Math.max(Ds(e.l,t,i+1),Ds(e.r,t,i+1)):t[e.s]=i},Ns=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new ps(++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]},qs=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Bs=function(e,t,i){var s=i.length,r=Ms(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)},Hs=function(e,t,i,s,r,n,o,a,l,u,c){Ls(t,c++,i),++r[256];for(var d=As(r,15),_=d[0],h=d[1],p=As(n,15),g=p[0],v=p[1],f=Ns(_),m=f[0],y=f[1],b=Ns(g),w=b[0],S=b[1],E=new ps(19),k=0;k<m.length;++k)E[31&m[k]]++;for(k=0;k<w.length;++k)E[31&w[k]]++;for(var x=As(E,7),I=x[0],R=x[1],C=19;C>4&&!I[ms[C-1]];--C);var P,T,F,M,L=u+5<<3,O=qs(r,Cs)+qs(n,Ps)+o,A=qs(r,_)+qs(n,g)+o+14+3*C+qs(E,I)+(2*E[16]+3*E[17]+7*E[18]);if(L<=O&&L<=A)return Bs(t,c,e.subarray(l,l+u));if(Ls(t,c,1+(A<O)),c+=2,A<O){P=Rs(_,h,0),T=_,F=Rs(g,v,0),M=g;var D=Rs(I,R,0);Ls(t,c,y-257),Ls(t,c+5,S-1),Ls(t,c+10,C-4),c+=14;for(k=0;k<C;++k)Ls(t,c+3*k,I[ms[k]]);c+=3*C;for(var N=[m,w],q=0;q<2;++q){var B=N[q];for(k=0;k<B.length;++k){var H=31&B[k];Ls(t,c,D[H]),c+=I[H],H>15&&(Ls(t,c,B[k]>>>5&127),c+=B[k]>>>12)}}}else P=Ts,T=Cs,F=Fs,M=Ps;for(k=0;k<a;++k)if(s[k]>255){H=s[k]>>>18&31;Os(t,c,P[H+257]),c+=T[H+257],H>7&&(Ls(t,c,s[k]>>>23&31),c+=vs[H]);var z=31&s[k];Os(t,c,F[z]),c+=M[z],z>3&&(Os(t,c,s[k]>>>5&8191),c+=fs[z])}else Os(t,c,P[s[k]]),c+=T[s[k]];return Os(t,c,P[256]),c+T[256]},zs=new gs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Us=function(){for(var e=new gs(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),js=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=Us[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}},Ws=function(e,t,i,s,r){return function(e,t,i,s,r,n){var o=e.length,a=new hs(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),u=0;if(!t||o<8)for(var c=0;c<=o;c+=65535){var d=c+65535;d<o?u=Bs(l,u,e.subarray(c,d)):(l[c]=n,u=Bs(l,u,e.subarray(c,o)))}else{for(var _=zs[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new ps(32768),f=new ps(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 gs(25e3),S=new ps(288),E=new ps(32),k=0,x=0,I=(c=0,0),R=0,C=0;c<o;++c){var P=b(c),T=32767&c,F=f[P];if(v[T]=F,f[P]=T,R<=c){var M=o-c;if((k>7e3||I>24576)&&M>423){u=Hs(e,l,0,w,S,E,x,I,C,c-C,u),I=k=x=0,C=c;for(var L=0;L<286;++L)S[L]=0;for(L=0;L<30;++L)E[L]=0}var O=2,A=0,D=p,N=T-F&32767;if(M>2&&P==b(c-N))for(var q=Math.min(h,M)-1,B=Math.min(32767,c),H=Math.min(258,M);N<=B&&--D&&T!=F;){if(e[c+O]==e[c+O-N]){for(var z=0;z<H&&e[c+z]==e[c+z-N];++z);if(z>O){if(O=z,A=N,z>q)break;var U=Math.min(N,z-2),j=0;for(L=0;L<U;++L){var W=c-N+L+32768&32767,V=W-v[W]+32768&32767;V>j&&(j=V,F=W)}}}N+=(T=F)-(F=v[T])+32768&32767}if(A){w[I++]=268435456|Ss[O]<<18|Es[A];var G=31&Ss[O],Y=31&Es[A];x+=vs[G]+fs[Y],++S[257+G],++E[Y],R=c+O,++k}else w[I++]=e[c],++S[e[c]]}}u=Hs(e,l,n,w,S,E,x,I,C,c-C,u)}return $s(a,0,s+Ms(u)+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)},Vs=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},Gs=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&&Vs(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)}},Ys=function(e){return 10+(e.filename&&e.filename.length+1||0)};function Js(e,t){void 0===t&&(t={});var i=js(),s=e.length;i.p(e);var r=Ws(e,t,Ys(t),8),n=r.length;return Gs(r,t),Vs(r,n-8,i.d()),Vs(r,n-4,s),r}function Ks(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new hs(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 hs(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 $s(s,0,r)}function Xs(e,t){return function(e){for(var t=0,i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t)}(e)%100<V(100*t,0,100,xe)}var Qs="disabled",Zs="sampled",er="active",tr="buffering",ir="paused",sr="trigger",rr=sr+"_activated",nr=sr+"_pending",or=sr+"_"+Qs;function ar(e,t){return t.some((t=>"regex"===t.matching&&new RegExp(t.url).test(e)))}class lr{constructor(e){this._matchers=e}triggerStatus(e){var t=this._matchers.map((t=>t.triggerStatus(e)));return t.includes(rr)?rr:t.includes(nr)?nr:or}stop(){this._matchers.forEach((e=>e.stop()))}}class ur{constructor(e){this._matchers=e}triggerStatus(e){var t=new Set;for(var i of this._matchers)t.add(i.triggerStatus(e));switch(t.delete(or),t.size){case 0:return or;case 1:return Array.from(t)[0];default:return nr}}stop(){this._matchers.forEach((e=>e.stop()))}}class cr{triggerStatus(){return nr}stop(){}}var dr=e=>"sessionRecording"in e;class _r{constructor(e){this._urlTriggers=[],this._urlBlocklist=[],this.urlBlocked=!1,this._instance=e}onConfig(e){var t,i;this._urlTriggers=(dr(e)?C(e.sessionRecording)?null==(t=e.sessionRecording)?void 0:t.urlTriggers:[]:null==e?void 0:e.urlTriggers)||[],this._urlBlocklist=(dr(e)?C(e.sessionRecording)?null==(i=e.sessionRecording)?void 0:i.urlBlocklist:[]:null==e?void 0:e.urlBlocklist)||[]}onRemoteConfig(e){this.onConfig(e)}_urlTriggerStatus(e){var t;return 0===this._urlTriggers.length?or:(null==(t=this._instance)?void 0:t.get_property(ut))===e?rr:nr}triggerStatus(e){var t=this._urlTriggerStatus(e),i=t===rr?rr:t===nr?nr:or;return this._instance.register_for_session({$sdk_debug_replay_url_trigger_status:i}),i}checkUrlTriggerConditions(e,t,i){if(void 0!==r&&r.location.href){var s=r.location.href,n=this.urlBlocked,o=ar(s,this._urlBlocklist);n&&o||(o&&!n?e():!o&&n&&t(),ar(s,this._urlTriggers)&&i("url"))}}stop(){}}class hr{constructor(e){this.linkedFlag=null,this.linkedFlagSeen=!1,this._flagListenerCleanup=()=>{},this._instance=e}triggerStatus(){var e=nr;return O(this.linkedFlag)&&(e=or),this.linkedFlagSeen&&(e=rr),this._instance.register_for_session({$sdk_debug_replay_linked_flag_trigger_status:e}),e}onConfig(e,t){var i;if(this.linkedFlag=(dr(e)?C(e.sessionRecording)?null==(i=e.sessionRecording)?void 0:i.linkedFlag:null:null==e?void 0:e.linkedFlag)||null,!O(this.linkedFlag)&&!this.linkedFlagSeen){var s=F(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,r=F(this.linkedFlag)?null:this.linkedFlag.variant;this._flagListenerCleanup=this._instance.onFeatureFlags(((e,i)=>{var n=!1;if(C(i)&&s in i){var o=i[s];n=D(o)?!0===o:r?o===r:!!o}this.linkedFlagSeen=n,n&&t(s,r)}))}}onRemoteConfig(e,t){this.onConfig(e,t)}stop(){this._flagListenerCleanup()}}class pr{constructor(e){this._eventTriggers=[],this._instance=e}onConfig(e){var t;this._eventTriggers=(dr(e)?C(e.sessionRecording)?null==(t=e.sessionRecording)?void 0:t.eventTriggers:[]:null==e?void 0:e.eventTriggers)||[]}onRemoteConfig(e){this.onConfig(e)}_eventTriggerStatus(e){var t;return 0===this._eventTriggers.length?or:(null==(t=this._instance)?void 0:t.get_property(ct))===e?rr:nr}triggerStatus(e){var t=this._eventTriggerStatus(e),i=t===rr?rr:t===nr?nr:or;return this._instance.register_for_session({$sdk_debug_replay_event_trigger_status:i}),i}stop(){}}function gr(e){return e.isRecordingEnabled?tr:Qs}function vr(e){if(!e.receivedFlags)return tr;if(!e.isRecordingEnabled)return Qs;if(e.urlTriggerMatching.urlBlocked)return ir;var t=!0===e.isSampled,i=new lr([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId);return t?Zs:i===rr?er:i===nr?tr:!1===e.isSampled?Qs:er}function fr(e){if(!e.receivedFlags)return tr;if(!e.isRecordingEnabled)return Qs;if(e.urlTriggerMatching.urlBlocked)return ir;var t=new ur([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId),i=t!==or,s=D(e.isSampled);return i&&t===nr?tr:i&&t===or||s&&!e.isSampled?Qs:!0===e.isSampled?Zs:er}var mr="[SessionRecording]",yr=Ie(mr);function br(){var e;return null==v||null==(e=v.__PosthogExtensions__)||null==(e=e.rrweb)?void 0:e.record}var wr=3e5,Sr=[is.MouseMove,is.MouseInteraction,is.Scroll,is.ViewportResize,is.Input,is.TouchMove,is.MediaInteraction,is.Drag],Er=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function kr(e){return function(e,t){for(var i="",s=0;s<e.length;){var r=e[s++];i+=String.fromCharCode(r)}return i}(Js(Ks(JSON.stringify(e))))}function xr(e){return e.type===ts.Custom&&"sessionIdle"===e.data.tag}class Ir{get sessionId(){return this._sessionId}get _sessionIdleThresholdMilliseconds(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this._captureStarted}get _sessionManager(){if(!this._instance.sessionManager)throw new Error(mr+" must be started with a valid sessionManager.");return this._instance.sessionManager}get _fullSnapshotIntervalMillis(){var e,t;return this._triggerMatching.triggerStatus(this.sessionId)===nr?6e4:null!==(e=null==(t=this._instance.config.session_recording)?void 0:t.full_snapshot_interval_millis)&&void 0!==e?e:wr}get _isSampled(){var e=this._instance.get_property(lt);return D(e)?e:null}get _sessionDuration(){var e,t,i=null==(e=this._buffer)?void 0:e.data[(null==(t=this._buffer)?void 0:t.data.length)-1],{sessionStartTimestamp:s}=this._sessionManager.checkAndGetSessionAndWindowId(!0);return i?i.timestamp-s:null}get _isRecordingEnabled(){var e=!!this._instance.get_property(Ze),t=!this._instance.config.disable_session_recording;return r&&e&&t}get _isConsoleLogCaptureEnabled(){var e=!!this._instance.get_property(et),t=this._instance.config.enable_recording_console_log;return null!=t?t:e}get _canvasRecording(){var e,t,i,s,r,n,o=this._instance.config.session_recording.captureCanvas,a=this._instance.get_property(st),l=null!==(e=null!==(t=null==o?void 0:o.recordCanvas)&&void 0!==t?t:null==a?void 0:a.enabled)&&void 0!==e&&e,u=null!==(i=null!==(s=null==o?void 0:o.canvasFps)&&void 0!==s?s:null==a?void 0:a.fps)&&void 0!==i?i:4,c=null!==(r=null!==(n=null==o?void 0:o.canvasQuality)&&void 0!==n?n:null==a?void 0:a.quality)&&void 0!==r?r:.4;if("string"==typeof c){var d=parseFloat(c);c=isNaN(d)?.4:d}return{enabled:l,fps:V(u,0,12,yr.createLogger("canvas recording fps"),4),quality:V(c,0,1,yr.createLogger("canvas recording quality"),.4)}}get _networkPayloadCapture(){var e,t,i=this._instance.get_property(tt),s={recordHeaders:null==(e=this._instance.config.session_recording)?void 0:e.recordHeaders,recordBody:null==(t=this._instance.config.session_recording)?void 0:t.recordBody},r=(null==s?void 0:s.recordHeaders)||(null==i?void 0:i.recordHeaders),n=(null==s?void 0:s.recordBody)||(null==i?void 0:i.recordBody),o=C(this._instance.config.capture_performance)?this._instance.config.capture_performance.network_timing:this._instance.config.capture_performance,a=!!(D(o)?o:null==i?void 0:i.capturePerformance);return r||n||a?{recordHeaders:r,recordBody:n,recordPerformance:a}:void 0}get _masking(){var e,t,i,s,r,n,o=this._instance.get_property(it),a={maskAllInputs:null==(e=this._instance.config.session_recording)?void 0:e.maskAllInputs,maskTextSelector:null==(t=this._instance.config.session_recording)?void 0:t.maskTextSelector,blockSelector:null==(i=this._instance.config.session_recording)?void 0:i.blockSelector},l=null!==(s=null==a?void 0:a.maskAllInputs)&&void 0!==s?s:null==o?void 0:o.maskAllInputs,u=null!==(r=null==a?void 0:a.maskTextSelector)&&void 0!==r?r:null==o?void 0:o.maskTextSelector,c=null!==(n=null==a?void 0:a.blockSelector)&&void 0!==n?n:null==o?void 0:o.blockSelector;return T(l)&&T(u)&&T(c)?void 0:{maskAllInputs:null==l||l,maskTextSelector:u,blockSelector:c}}get _sampleRate(){var e=this._instance.get_property(rt);return A(e)?e:null}get _minimumDuration(){var e=this._instance.get_property(nt);return A(e)?e:null}get status(){return this._receivedFlags?this._statusMatcher({receivedFlags:this._receivedFlags,isRecordingEnabled:this._isRecordingEnabled,isSampled:this._isSampled,urlTriggerMatching:this._urlTriggerMatching,eventTriggerMatching:this._eventTriggerMatching,linkedFlagMatching:this._linkedFlagMatching,sessionId:this.sessionId}):tr}constructor(e){if(this._statusMatcher=gr,this._receivedFlags=!1,this._queuedRRWebEvents=[],this._isIdle="unknown",this._lastActivityTimestamp=Date.now(),this._triggerMatching=new cr,this._removePageViewCaptureHook=void 0,this._onSessionIdListener=void 0,this._persistFlagsOnSessionListener=void 0,this._samplingSessionListener=void 0,this._removeEventTriggerCaptureHook=void 0,this._forceAllowLocalhostNetworkCapture=!1,this._onBeforeUnload=()=>{this._flushBuffer()},this._onOffline=()=>{this.tryAddCustomEvent("browser offline",{})},this._onOnline=()=>{this.tryAddCustomEvent("browser online",{})},this._onVisibilityChange=()=>{if(null!=c&&c.visibilityState){var e="window "+c.visibilityState;this.tryAddCustomEvent(e,{})}},this._instance=e,this._captureStarted=!1,this._endpoint="/s/",this._stopRrweb=void 0,this._receivedFlags=!1,!this._instance.sessionManager)throw yr.error("started without valid sessionManager"),new Error(mr+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(mr+' cannot be used with cookieless_mode="always"');this._linkedFlagMatching=new hr(this._instance),this._urlTriggerMatching=new _r(this._instance),this._eventTriggerMatching=new pr(this._instance);var{sessionId:t,windowId:i}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=t,this._windowId=i,this._buffer=this._clearBuffer(),this._sessionIdleThresholdMilliseconds>=this._sessionManager.sessionTimeoutMs&&yr.warn("session_idle_threshold_ms ("+this._sessionIdleThresholdMilliseconds+") is greater than the session timeout ("+this._sessionManager.sessionTimeoutMs+"). Session will never be detected as idle")}startIfEnabledOrStop(e){this._isRecordingEnabled?(this._startCapture(e),Be(r,"beforeunload",this._onBeforeUnload),Be(r,"offline",this._onOffline),Be(r,"online",this._onOnline),Be(r,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),O(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this._instance.on("eventCaptured",(e=>{try{if("$pageview"===e.event){var t=null!=e&&e.properties.$current_url?this._maskUrl(null==e?void 0:e.properties.$current_url):"";if(!t)return;this.tryAddCustomEvent("$pageview",{href:t})}}catch(e){yr.error("Could not add $pageview to rrweb session",e)}}))),this._onSessionIdListener||(this._onSessionIdListener=this._sessionManager.onSessionId(((e,t,i)=>{var s,r;i&&(this.tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),null==(s=this._instance)||null==(s=s.persistence)||s.unregister(ct),null==(r=this._instance)||null==(r=r.persistence)||r.unregister(ut))})))):this.stopRecording()}stopRecording(){var e,t,i,s;this._captureStarted&&this._stopRrweb&&(this._stopRrweb(),this._stopRrweb=void 0,this._captureStarted=!1,null==r||r.removeEventListener("beforeunload",this._onBeforeUnload),null==r||r.removeEventListener("offline",this._onOffline),null==r||r.removeEventListener("online",this._onOnline),null==r||r.removeEventListener("visibilitychange",this._onVisibilityChange),this._clearBuffer(),clearInterval(this._fullSnapshotTimer),null==(e=this._removePageViewCaptureHook)||e.call(this),this._removePageViewCaptureHook=void 0,null==(t=this._removeEventTriggerCaptureHook)||t.call(this),this._removeEventTriggerCaptureHook=void 0,null==(i=this._onSessionIdListener)||i.call(this),this._onSessionIdListener=void 0,null==(s=this._samplingSessionListener)||s.call(this),this._samplingSessionListener=void 0,this._eventTriggerMatching.stop(),this._urlTriggerMatching.stop(),this._linkedFlagMatching.stop(),yr.info("stopped"))}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(lt)}_makeSamplingDecision(e){var t,i=this._sessionId!==e,s=this._sampleRate;if(A(s)){var r=this._isSampled,n=i||!D(r),o=n?Xs(e,s):r;n&&(o?this._reportStarted(Zs):yr.warn("Sample rate ("+s+") has determined that this sessionId ("+e+") will not be sent to the server."),this.tryAddCustomEvent("samplingDecisionMade",{sampleRate:s,isSampled:o})),null==(t=this._instance.persistence)||t.register({[lt]:o})}else this._resetSampling()}onRemoteConfig(e){if(this.tryAddCustomEvent("$remote_config_received",e),this._receivedFlags=!0,this._persistRemoteConfig(e),e.sessionRecording){var t,i,s,r;if(null!=(t=e.sessionRecording)&&t.endpoint)this._endpoint=null==(r=e.sessionRecording)?void 0:r.endpoint;this._setupSampling(),"any"===(null==(i=e.sessionRecording)?void 0:i.triggerMatchType)?(this._statusMatcher=vr,this._triggerMatching=new lr([this._eventTriggerMatching,this._urlTriggerMatching])):(this._statusMatcher=fr,this._triggerMatching=new ur([this._eventTriggerMatching,this._urlTriggerMatching])),this._instance.register_for_session({$sdk_debug_replay_remote_trigger_matching_config:null==(s=e.sessionRecording)?void 0:s.triggerMatchType}),this._urlTriggerMatching.onConfig(e),this._eventTriggerMatching.onConfig(e),this._linkedFlagMatching.onConfig(e,((e,t)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:t})}))}this.startIfEnabledOrStop()}_setupSampling(){A(this._sampleRate)&&O(this._samplingSessionListener)&&(this._samplingSessionListener=this._sessionManager.onSessionId((e=>{this._makeSamplingDecision(e)})))}_persistRemoteConfig(e){if(this._instance.persistence){var t,s=this._instance.persistence,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=null==t?void 0:t.sampleRate,n=O(r)?null:parseFloat(r);O(n)&&this._resetSampling();var o=null==t?void 0:t.minimumDurationMilliseconds;s.register({[Ze]:!!e.sessionRecording,[et]:null==t?void 0:t.consoleLogRecordingEnabled,[tt]:i({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),[it]:null==t?void 0:t.masking,[st]:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},[rt]:n,[nt]:T(o)?null:o,[ot]:null==t?void 0:t.scriptConfig})};r(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=this._sessionManager.onSessionId(r)}}log(e,t){var i;void 0===t&&(t="log"),null==(i=this._instance.sessionRecording)||i.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:t,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}_startCapture(e){if(!T(Object.assign)&&!T(Array.from)&&!(this._captureStarted||this._instance.config.disable_session_recording||this._instance.consent.isOptedOut())){var t;if(this._captureStarted=!0,this._sessionManager.checkAndGetSessionAndWindowId(),br())this._onScriptLoaded();else null==(t=v.__PosthogExtensions__)||null==t.loadExternalDependency||t.loadExternalDependency(this._instance,this._scriptName,(e=>{if(e)return yr.error("could not load recorder",e);this._onScriptLoaded()}));yr.info("starting"),this.status===er&&this._reportStarted(e||"recording_initialized")}}get _scriptName(){var e;return(null==(e=this._instance)||null==(e=e.persistence)||null==(e=e.get_property(ot))?void 0:e.script)||"recorder"}_isInteractiveEvent(e){var t;return 3===e.type&&-1!==Sr.indexOf(null==(t=e.data)?void 0:t.source)}_updateWindowAndSessionIds(e){var t=this._isInteractiveEvent(e);t||this._isIdle||e.timestamp-this._lastActivityTimestamp>this._sessionIdleThresholdMilliseconds&&(this._isIdle=!0,clearInterval(this._fullSnapshotTimer),this.tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this._sessionIdleThresholdMilliseconds,bufferLength:this._buffer.data.length,bufferSize:this._buffer.size}),this._flushBuffer());var i=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this._isIdle)){var s="unknown"===this._isIdle;this._isIdle=!1,s||(this.tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)}if(!this._isIdle){var{windowId:r,sessionId:n}=this._sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),o=this._sessionId!==n,a=this._windowId!==r;this._windowId=r,this._sessionId=n,o||a?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):i&&this._scheduleFullSnapshot()}}_tryRRWebMethod(e){try{return e.rrwebMethod(),!0}catch(t){return this._queuedRRWebEvents.length<10?this._queuedRRWebEvents.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt++,rrwebMethod:e.rrwebMethod}):yr.warn("could not emit queued rrweb event.",t,e),!1}}tryAddCustomEvent(e,t){return this._tryRRWebMethod(Er((()=>br().addCustomEvent(e,t))))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(Er((()=>br().takeFullSnapshot())))}_onScriptLoaded(){var e,t,s,r,n={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},o=this._instance.config.session_recording;for(var[a,l]of Object.entries(o||{}))a in n&&("maskInputOptions"===a?n.maskInputOptions=i({password:!0},l):n[a]=l);(this._canvasRecording&&this._canvasRecording.enabled&&(n.recordCanvas=!0,n.sampling={canvas:this._canvasRecording.fps},n.dataURLOptions={type:"image/webp",quality:this._canvasRecording.quality}),this._masking)&&(n.maskAllInputs=null===(t=this._masking.maskAllInputs)||void 0===t||t,n.maskTextSelector=null!==(s=this._masking.maskTextSelector)&&void 0!==s?s:void 0,n.blockSelector=null!==(r=this._masking.blockSelector)&&void 0!==r?r:void 0);var u=br();if(u){this._mutationThrottler=null!==(e=this._mutationThrottler)&&void 0!==e?e:new _s(u,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(e,t)=>{var i="Too many mutations on node '"+e+"'. Rate limiting. This could be due to SVG animations or something similar";yr.info(i,{node:t}),this.log(mr+" "+i,"warn")}});var c=this._gatherRRWebPlugins();this._stopRrweb=u(i({emit:e=>{this.onRRwebEmit(e)},plugins:c},n)),this._lastActivityTimestamp=Date.now(),this._isIdle=D(this._isIdle)?this._isIdle:"unknown",this.tryAddCustomEvent("$session_options",{sessionRecordingOptions:n,activePlugins:c.map((e=>null==e?void 0:e.name))}),this.tryAddCustomEvent("$posthog_config",{config:this._instance.config})}else yr.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!0!==this._isIdle){var e=this._fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval((()=>{this._tryTakeFullSnapshot()}),e))}}_gatherRRWebPlugins(){var e,t,i=[],s=null==(e=v.__PosthogExtensions__)||null==(e=e.rrwebPlugins)?void 0:e.getRecordConsolePlugin;s&&this._isConsoleLogCaptureEnabled&&i.push(s());var r=null==(t=v.__PosthogExtensions__)||null==(t=t.rrwebPlugins)?void 0:t.getRecordNetworkPlugin;this._networkPayloadCapture&&R(r)&&(!di.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?i.push(r(ds(this._instance.config,this._networkPayloadCapture))):yr.info("NetworkCapture not started because we are on localhost."));return i}onRRwebEmit(e){var t;if(this._processQueuedEvents(),e&&C(e)){if(e.type===ts.Meta){var s=this._maskUrl(e.data.href);if(this._lastHref=s,!s)return;e.data.href=s}else this._pageViewFallBack();if(this._urlTriggerMatching.checkUrlTriggerConditions((()=>this._pauseRecording()),(()=>this._resumeRecording()),(e=>this._activateTrigger(e))),!this._urlTriggerMatching.urlBlocked||(r=e).type===ts.Custom&&"recording paused"===r.data.tag){var r;e.type===ts.FullSnapshot&&this._scheduleFullSnapshot(),e.type===ts.FullSnapshot&&this._receivedFlags&&this._triggerMatching.triggerStatus(this.sessionId)===nr&&this._clearBufferBeforeMostRecentMeta();var n=this._mutationThrottler?this._mutationThrottler.throttleMutations(e):e;if(n){var o=function(e){var t=e;if(t&&C(t)&&6===t.type&&C(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));for(var i=[],s=0;s<t.data.payload.payload.length;s++)t.data.payload.payload[s]&&t.data.payload.payload[s].length>2e3?i.push(t.data.payload.payload[s].slice(0,2e3)+"...[truncated]"):i.push(t.data.payload.payload[s]);return t.data.payload.payload=i,e}return e}(n);if(this._updateWindowAndSessionIds(o),!0!==this._isIdle||xr(o)){if(xr(o)){var a=o.data.payload;if(a){var l=a.lastActivityTimestamp,u=a.threshold;o.timestamp=l+u}}var c=null===(t=this._instance.config.session_recording.compress_events)||void 0===t||t?function(e){try{if(e.type===ts.FullSnapshot)return i({},e,{data:kr(e.data),cv:"2024-10"});if(e.type===ts.IncrementalSnapshot&&e.data.source===is.Mutation)return i({},e,{cv:"2024-10",data:i({},e.data,{texts:kr(e.data.texts),attributes:kr(e.data.attributes),removes:kr(e.data.removes),adds:kr(e.data.adds)})});if(e.type===ts.IncrementalSnapshot&&e.data.source===is.StyleSheetRule)return i({},e,{cv:"2024-10",data:i({},e.data,{adds:e.data.adds?kr(e.data.adds):void 0,removes:e.data.removes?kr(e.data.removes):void 0})})}catch(e){yr.error("could not compress event - will use uncompressed event",e)}return e}(o):o,d={$snapshot_bytes:Zi(c),$snapshot_data:c,$session_id:this._sessionId,$window_id:this._windowId};this.status!==Qs?this._captureSnapshotBuffered(d):this._clearBuffer()}}}}}_pageViewFallBack(){if(!this._instance.config.capture_pageview&&r){var e=this._maskUrl(r.location.href);this._lastHref!==e&&(this.tryAddCustomEvent("$url_changed",{href:e}),this._lastHref=e)}}_processQueuedEvents(){if(this._queuedRRWebEvents.length){var e=[...this._queuedRRWebEvents];this._queuedRRWebEvents=[],e.forEach((e=>{Date.now()-e.enqueuedAt<=2e3&&this._tryRRWebMethod(e)}))}}_maskUrl(e){var t=this._instance.config.session_recording;if(t.maskNetworkRequestFn){var i,s={url:e};return null==(i=s=t.maskNetworkRequestFn(s))?void 0:i.url}return e}_clearBufferBeforeMostRecentMeta(){if(!this._buffer||0===this._buffer.data.length)return this._clearBuffer();for(var e=-1,t=this._buffer.data.length-1;t>=0;t--)if(this._buffer.data[t].type===ts.Meta){e=t;break}return e>=0?(this._buffer.data=this._buffer.data.slice(e),this._buffer.size=this._buffer.data.reduce(((e,t)=>e+Zi(t)),0),this._buffer):this._clearBuffer()}_clearBuffer(){return this._buffer={size:0,data:[],sessionId:this._sessionId,windowId:this._windowId},this._buffer}_flushBuffer(){this._flushBufferTimer&&(clearTimeout(this._flushBufferTimer),this._flushBufferTimer=void 0);var e=this._minimumDuration,t=this._sessionDuration,i=A(t)&&t>=0,s=A(e)&&i&&t<e;if(this.status===tr||this.status===ir||this.status===Qs||s)return this._flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3),this._buffer;this._buffer.data.length>0&&es(this._buffer).forEach((e=>{this._captureSnapshot({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId,$lib:"web",$lib_version:f.LIB_VERSION})}));return this._clearBuffer()}_captureSnapshotBuffered(e){var t,i=2+((null==(t=this._buffer)?void 0:t.data.length)||0);!this._isIdle&&(this._buffer.size+e.$snapshot_bytes+i>943718.4||this._buffer.sessionId!==this._sessionId)&&(this._buffer=this._flushBuffer()),this._buffer.size+=e.$snapshot_bytes,this._buffer.data.push(e.$snapshot_data),this._flushBufferTimer||this._isIdle||(this._flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3))}_captureSnapshot(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}_activateTrigger(e){var t;this._triggerMatching.triggerStatus(this.sessionId)===nr&&(null==(t=this._instance)||null==(t=t.persistence)||t.register({["url"===e?ut:ct]:this._sessionId}),this._flushBuffer(),this._reportStarted(e+"_trigger_matched"))}_pauseRecording(){this._urlTriggerMatching.urlBlocked||(this._urlTriggerMatching.urlBlocked=!0,clearInterval(this._fullSnapshotTimer),yr.info("recording paused due to URL blocker"),this.tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){this._urlTriggerMatching.urlBlocked&&(this._urlTriggerMatching.urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this.tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),yr.info("recording resumed"))}_addEventTriggerListener(){0!==this._eventTriggerMatching._eventTriggers.length&&O(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this._instance.on("eventCaptured",(e=>{try{this._eventTriggerMatching._eventTriggers.includes(e.event)&&this._activateTrigger("event")}catch(e){yr.error("Could not activate event trigger",e)}})))}overrideLinkedFlag(){this._linkedFlagMatching.linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null==(e=this._instance.persistence)||e.register({[lt]:!0}),this._tryTakeFullSnapshot(),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e)}_reportStarted(e,t){this._instance.register_for_session({$session_recording_start_reason:e}),yr.info(e.replace("_"," "),t),y(["recording_initialized","session_id_changed"],e)||this.tryAddCustomEvent(e,t)}get sdkDebugProperties(){var{sessionStartTimestamp:e}=this._sessionManager.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this._buffer.data.length,$sdk_debug_replay_internal_buffer_size:this._buffer.size,$sdk_debug_current_session_duration:this._sessionDuration,$sdk_debug_session_start:e}}}var Rr=Ie("[SegmentIntegration]");function Cr(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()||Pi();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(yt,"identified")),t()},r=i.user();"then"in r&&R(r.then)?r.then((e=>s(e))):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||Rr.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()||(Rr.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Rr.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 Pr="posthog-js";function Tr(e,t){var{organization:s,projectId:r,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,u,c,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==(u=p[0])?void 0:u.value)||t.message,$exception_type:null==(c=p[0])?void 0:c.type,$exception_personURL:h,$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 Fr{constructor(e,t,i,s,r,n){this.name=Pr,this.setupOnce=function(o){o(Tr(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}}var Mr=null!=r&&r.location?vi(r.location.hash,"__posthog")||vi(location.hash,"state"):null,$r="_postHogToolbarParams",Lr=Ie("[Toolbar]"),Or=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Or||{});class Ar{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:Or.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||!c)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=Mr||vi(e.hash,"__posthog")||vi(e.hash,"state"),o=n?$e((()=>JSON.parse(atob(decodeURIComponent(n)))))||$e((()=>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($r)||"{}")).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;!O(t)&&R(t)?t(e,this.instance):Lr.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==c||!c.getElementById(It));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($r,JSON.stringify(i({},n,{source:void 0}))),this._getToolbarState()===Or.LOADED)this._callLoadToolbar(n);else if(this._getToolbarState()===Or.UNINITIALIZED){var o;this._setToolbarState(Or.LOADING),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Lr.error("[Toolbar] Failed to load",e),void this._setToolbarState(Or.UNINITIALIZED);this._setToolbarState(Or.LOADED),this._callLoadToolbar(n)})),Be(r,"turbolinks:load",(()=>{this._setToolbarState(Or.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 Dr=Ie("[TracingHeaders]");class Nr{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t;T(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));T(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 Dr.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 qr=Ie("[Web Vitals]"),Br=9e5;class Hr{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(T(s))qr.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(!T(r))if(O(null==e?void 0:e.name)||O(null==e?void 0:e.value))qr.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)qr.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),T(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=T(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__;T(r)||T(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):qr.error("web vitals callbacks not loaded - not starting")},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[Je]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=C(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return T(i)?(null==(t=this._instance.persistence)?void 0:t.props[Xe])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(C(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=C(this._instance.config.capture_performance)&&A(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Br;return 0<e&&e<=6e4?Br:e}get isEnabled(){var e=null==d?void 0:d.protocol;if("http:"!==e&&"https:"!==e)return qr.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=C(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:D(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return D(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(qr.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){var t=C(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=C(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Je]:t}),this._instance.persistence.register({[Xe]: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?qr.error("failed to load script",t):e()}))}_currentURL(){var e=r?r.location.href:void 0;return e||qr.error("Could not determine current URL"),e}}var zr=Ie("[Heatmaps]");function Ur(e){return C(e)&&"clientX"in e&&"clientY"in e&&A(e.clientX)&&A(e.clientY)}class jr{constructor(e){var t;this.rageclicks=new ai,this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[We])}get flushIntervalMilliseconds(){var e=5e3;return C(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 T(this.instance.config.capture_heatmaps)?T(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;zr.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this._flush.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),null==(t=this._deadClicksCapture)||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[We]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_setupListeners(){r&&c&&(Be(r,"beforeunload",this._flush.bind(this)),Be(c,"click",(e=>this._onClick(e||(null==r?void 0:r.event))),{capture:!0}),Be(c,"mousemove",(e=>this._onMouseMove(e||(null==r?void 0:r.event))),{capture:!0}),this._deadClicksCapture=new Yi(this.instance,Vi,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabled(),this._initialized=!0)}_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&&Tt(s)&&!Ft(s,"body");){if(s===i)return!1;if(y(t,null==r?void 0:r.getComputedStyle(s).position))return!0;s=zt(s)}return!1}(qt(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"),!Pt(e.target)&&Ur(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){!Pt(e.target)&&Ur(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(r){var t=r.location.href;this._buffer=this._buffer||{},this._buffer[t]||(this._buffer[t]=[]),this._buffer[t].push(e)}}_flush(){this._buffer&&!P(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Wr{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:u,maxContentY:c}=r;if(!(T(n)||T(o)||T(a)||T(l)||T(u)||T(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n<=1?1:V(o/n,0,1,xe),_=n<=1?1:V(a/n,0,1,xe),h=l<=1?1:V(u/l,0,1,xe),p=l<=1?1:V(c/l,0,1,xe);s=Te(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:u,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:c,$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 Vr=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),L(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=r+1)}return i>t&&(n+=e.substring(t,e.length)),n},Gr=!!h||!!_,Yr="text/plain",Jr=(e,t)=>{var[s,r]=e.split("?"),n=i({},t);null==r||r.split("&").forEach((e=>{var[t]=e.split("=");delete n[t]}));var o=hi(n);return s+"?"+(o=o?(r?r+"&":"")+o:r)},Kr=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Xr=e=>{var{data:t,compression:i}=e;if(t){if(i===ui.GZipJS){var s=Js(Ks(Kr(t)),{mtime:0}),r=new Blob([s],{type:Yr});return{contentType:Yr,body:r,estimatedSize:r.size}}if(i===ui.Base64){var n=function(e){var t,i,s,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,u="",c=[];if(!e)return e;e=Vr(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,c[l++]=o.charAt(t)+o.charAt(i)+o.charAt(s)+o.charAt(r)}while(a<e.length);switch(u=c.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u}(Kr(t)),o=(e=>"data="+encodeURIComponent("string"==typeof e?e:Kr(e)))(n);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Kr(t);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Qr=[];_&&Qr.push({transport:"fetch",method:e=>{var t,s,{contentType:r,body:n,estimatedSize:o}=null!==(t=Xr(e))&&void 0!==t?t:{},a=new Headers;Pe(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,u=null;if(p){var c=new p;u={signal:c.signal,timeout:setTimeout((()=>c.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=u)?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){xe.error(e)}null==e.callback||e.callback(s)})))).catch((t=>{xe.error(t),null==e.callback||e.callback({statusCode:0,text:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),h&&Qr.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=Xr(e))&&void 0!==t?t:{};Pe(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!=u&&u.sendBeacon&&Qr.push({transport:"sendBeacon",method:e=>{var t=Jr(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=Xr(e))&&void 0!==i?i:{},n="string"==typeof r?new Blob([r],{type:s}):r;u.sendBeacon(t,n)}catch(e){}}});var Zr=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 en(e,t,i){return Kr({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var tn={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=>Zr(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Zr(t,e))))),icontains:(e,t)=>t.map(sn).some((t=>e.map(sn).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(sn).every((t=>e.map(sn).every((e=>!t.includes(e)))))},sn=e=>e.toLowerCase(),rn=Ie("[Error tracking]");class nn{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new _e([new he,new Ee,new ge,new pe,new we,new be,new fe,new Se],[ne,le]),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Ge))&&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({[Ge]:this._suppressionRules,[Ye]:n})}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(Ye),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){if(this._matchesSuppressionRule(e))rn.info("Skipping exception capture because a suppression rule matched");else{if(this._captureExtensionExceptions||!this._isExtensionException(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});rn.info("Skipping exception capture because it was thrown by an extension")}}_matchesSuppressionRule(e){var t=e.$exception_list;if(!t||!I(t)||0===t.length)return!1;var i=t.reduce(((e,t)=>{var{type:i,value:s}=t;return F(i)&&i.length>0&&e.$exception_types.push(i),F(s)&&s.length>0&&e.$exception_values.push(s),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var t=e.values.map((e=>{var t,s=tn[e.operator],r=I(e.value)?e.value:[e.value],n=null!==(t=i[e.key])&&void 0!==t?t:[];return r.length>0&&s(r,n)}));return"OR"===e.type?t.some(Boolean):t.every(Boolean)}))}_isExtensionException(e){var t=e.$exception_list;return!(!t||!I(t))&&t.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://")))}}var on="Mobile",an="iOS",ln="Android",un="Tablet",cn=ln+" "+un,dn="iPad",_n="Apple",hn=_n+" Watch",pn="Safari",gn="BlackBerry",vn="Samsung",fn=vn+"Browser",mn=vn+" Internet",yn="Chrome",bn=yn+" OS",wn=yn+" "+an,Sn="Internet Explorer",En=Sn+" "+on,kn="Opera",xn=kn+" Mini",In="Edge",Rn="Microsoft "+In,Cn="Firefox",Pn=Cn+" "+an,Tn="Nintendo",Fn="PlayStation",Mn="Xbox",$n=ln+" "+on,Ln=on+" "+pn,On="Windows",An=On+" Phone",Dn="Nokia",Nn="Ouya",qn="Generic",Bn=qn+" "+on.toLowerCase(),Hn=qn+" "+un.toLowerCase(),zn="Konqueror",Un="(\\d+(\\.\\d+)?)",jn=new RegExp("Version/"+Un),Wn=new RegExp(Mn,"i"),Vn=new RegExp(Fn+" \\w+","i"),Gn=new RegExp(Tn+" \\w+","i"),Yn=new RegExp(gn+"|PlayBook|BB10","i"),Jn={"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 Kn=(e,t)=>t&&y(t,_n)||function(e){return y(e,pn)&&!y(e,yn)&&!y(e,ln)}(e),Xn=function(e,t){return t=t||"",y(e," OPR/")&&y(e,"Mini")?xn:y(e," OPR/")?kn:Yn.test(e)?gn:y(e,"IE"+on)||y(e,"WPDesktop")?En:y(e,fn)?mn:y(e,In)||y(e,"Edg/")?Rn:y(e,"FBIOS")?"Facebook "+on:y(e,"UCWEB")||y(e,"UCBrowser")?"UC Browser":y(e,"CriOS")?wn:y(e,"CrMo")||y(e,yn)?yn:y(e,ln)&&y(e,pn)?$n:y(e,"FxiOS")?Pn:y(e.toLowerCase(),zn.toLowerCase())?zn:Kn(e,t)?y(e,on)?Ln:pn:y(e,Cn)?Cn:y(e,"MSIE")||y(e,"Trident/")?Sn:y(e,"Gecko")?Cn:""},Qn={[En]:[new RegExp("rv:"+Un)],[Rn]:[new RegExp(In+"?\\/"+Un)],[yn]:[new RegExp("("+yn+"|CrMo)\\/"+Un)],[wn]:[new RegExp("CriOS\\/"+Un)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Un)],[pn]:[jn],[Ln]:[jn],[kn]:[new RegExp("(Opera|OPR)\\/"+Un)],[Cn]:[new RegExp(Cn+"\\/"+Un)],[Pn]:[new RegExp("FxiOS\\/"+Un)],[zn]:[new RegExp("Konqueror[:/]?"+Un,"i")],[gn]:[new RegExp(gn+" "+Un),jn],[$n]:[new RegExp("android\\s"+Un,"i")],[mn]:[new RegExp(fn+"\\/"+Un)],[Sn]:[new RegExp("(rv:|MSIE )"+Un)],Mozilla:[new RegExp("rv:"+Un)]},Zn=function(e,t){var i=Xn(e,t),s=Qn[i];if(T(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},eo=[[new RegExp(Mn+"; "+Mn+" (.*?)[);]","i"),e=>[Mn,e&&e[1]||""]],[new RegExp(Tn,"i"),[Tn,""]],[new RegExp(Fn,"i"),[Fn,""]],[Yn,[gn,""]],[new RegExp(On,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[An,""];if(new RegExp(on).test(t)&&!/IEMobile\b/.test(t))return[On+" "+on,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=i[1],r=Jn[s]||"";return/arm/i.test(t)&&(r="RT"),[On,r]}return[On,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[an,t.join(".")]}return[an,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=T(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ln+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ln+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[ln,t.join(".")]}return[ln,""]}],[/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/,[bn,""]],[/Linux|debian/i,["Linux",""]]],to=function(e){return Gn.test(e)?Tn:Vn.test(e)?Fn:Wn.test(e)?Mn:new RegExp(Nn,"i").test(e)?Nn:new RegExp("("+An+"|WPDesktop)","i").test(e)?An:/iPad/.test(e)?dn:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?hn:Yn.test(e)?gn:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Dn,"i").test(e)?Dn:/(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(on).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)?ln:cn:ln:new RegExp("(pda|"+on+")","i").test(e)?Bn:new RegExp(un,"i").test(e)&&!new RegExp(un+" pc","i").test(e)?Hn:""},io="https?://(.*)",so=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ro=Fe(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],so),no="<masked>",oo=["li_fat_id"];function ao(e,t,i){if(!c)return{};var s,r=t?Fe([],so,i||[]):[],n=lo(gi(c.URL,r,no),e),o=(s={},Pe(oo,(function(e){var t=Li._get(e);s[e]=t||null})),s);return Te(o,n)}function lo(e,t){var i=ro.concat(t||[]),s={};return Pe(i,(function(t){var i=pi(e,t);s[t]=i||null})),s}function uo(e){var t=function(e){return e?0===e.search(io+"google.([^/?]*)")?"google":0===e.search(io+"bing.com")?"bing":0===e.search(io+"yahoo.com")?"yahoo":0===e.search(io+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!L(t)){s.$search_engine=t;var r=c?pi(c.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function co(){return navigator.language||navigator.userLanguage}function _o(){return(null==c?void 0:c.referrer)||"$direct"}function ho(e,t){var i=e?Fe([],so,t||[]):[],s=null==d?void 0:d.href.substring(0,1e3);return{r:_o().substring(0,1e3),u:s?gi(s,i,no):void 0}}function po(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=_i(i))?void 0:t.host};if(s){r.$current_url=s;var n=_i(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=lo(s);Te(r,o)}if(i){var a=uo(i);Te(r,a)}return r}function go(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function vo(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function fo(e,t){if(!g)return{};var i,s,n,o=e?Fe([],so,t||[]):[],[a,l]=function(e){for(var t=0;t<eo.length;t++){var[i,s]=eo[t],r=i.exec(e),n=r&&(R(s)?s(r,e):s);if(n)return n}return["",""]}(g);return Te(Oe({$os:a,$os_version:l,$browser:Xn(g,navigator.vendor),$device:to(g),$device_type:(s=g,n=to(s),n===dn||n===cn||"Kobo"===n||"Kindle Fire"===n||n===Hn?un:n===Tn||n===Mn||n===Fn||n===Nn?"Console":n===hn?"Wearable":n?on:"Desktop"),$timezone:go(),$timezone_offset:vo()}),{$current_url:gi(null==d?void 0:d.href,o,no),$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:Zn(g,navigator.vendor),$browser_language:co(),$browser_language_prefix:(i=co(),"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 mo=Ie("[FeatureFlags]"),yo="$active_feature_flags",bo="$override_feature_flags",wo="$feature_flag_payloads",So="$override_feature_flag_payloads",Eo="$feature_flag_request_id",ko=e=>{var t={};for(var[i,s]of Me(e||{}))s&&(t[i]=s);return t},xo=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]})))):mo.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e},Io=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class Ro{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||mo.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(ht),t=this._instance.get_property(bo),s=this._instance.get_property(So);if(!s&&!t)return e||{};var r=Te({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=r[o],c=null==t?void 0:t[o],d=T(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=T(c)?u.variant:"string"==typeof c?c:void 0,h=null==s?void 0:s[o],p=i({},u,{enabled:d,variant:d?null!=_?_:null==u?void 0:u.variant:void 0});if(d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),_!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),h)p.metadata=i({},null==u?void 0:u.metadata,{payload:h,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload});r[o]=p}return this._override_warning||(mo.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var e=this._instance.get_property(dt),t=this._instance.get_property(bo);if(!t)return e||{};for(var i=Te({},e),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(mo.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._instance.get_property(wo),t=this._instance.get_property(So);if(!t)return e||{};for(var i=Te({},e||{}),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(mo.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(pt)||{}),group_properties:this._instance.get_property(gt)};(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=go()),this._requestInFlight=!0,this._instance._send_request({method:"POST",url:a,data:s,compression:this._instance.config.disable_compression?void 0:ui.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(Io.FeatureFlags))mo.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(Eo)||void 0,n=this._instance.get_property(mt)||{};if((t.send_event||!("send_event"in t))&&(!(e in n)||!n[e].includes(s))){var o,a,l,u,c,d,_,h,p;I(n[e])?n[e].push(s):n[e]=[s],null==(o=this._instance.persistence)||o.register({[mt]: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};T(null==g||null==(u=g.metadata)?void 0:u.version)||(v.$feature_flag_version=g.metadata.version);var f,m=null!==(c=null==g||null==(d=g.reason)?void 0:d.description)&&void 0!==c?c: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),T(null==g?void 0:g.original_variant)&&T(null==g?void 0:g.original_enabled)||(v.$feature_flag_original_response=T(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}mo.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:ui.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 T(i)?void 0:!!i}mo.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=xo(e),a=o.flags,l=o.featureFlags,u=o.featureFlagPayloads;if(l){var c=e.requestId;if(I(l)){mo.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({[yo]:l,[dt]:d})}else{var h=l,p=u,g=a;e.errorsWhileComputingFlags&&(h=i({},s,h),p=i({},r,p),g=i({},n,g)),t&&t.register(i({[yo]:Object.keys(ko(h)),[dt]:h||{},[wo]:p||{},[ht]:g||{}},c?{[Eo]:c}:{}))}}}(e,this._instance.persistence,s,r,n),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),mo.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return mo.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(bo),this._instance.persistence.unregister(So),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(bo);else if(i.flags)if(I(i.flags)){for(var s={},r=0;r<i.flags.length;r++)s[i.flags[r]]=!0;this._instance.persistence.register({[bo]:s})}else this._instance.persistence.register({[bo]:i.flags});return"payloads"in i&&(!1===i.payloads?this._instance.persistence.unregister(So):i.payloads&&this._instance.persistence.register({[So]: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(_t)||[]).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({[yo]:Object.keys(ko(l)),[dt]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._instance.get_property(_t),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(_t),null==(s=this._instance.persistence)||s.register({[_t]: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(pt)||{};this._instance.register({[pt]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(pt)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(gt)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((t=>{s[t]=i({},s[t],e[t]),delete e[t]})),this._instance.register({[gt]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(gt)||{};this._instance.register({[gt]:i({},t,{[e]:{}})})}else this._instance.unregister(gt)}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 Co=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Po{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&&xe.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Co.indexOf(e.persistence.toLowerCase())&&(xe.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&Ai._is_supported()?Ai:"localstorage+cookie"===t&&Ni._is_supported()?Ni:"sessionstorage"===t&&zi._is_supported()?zi:"memory"===t?Bi:"cookie"===t?Li:Ni._is_supported()?Ni:Li}properties(){var e={};return Pe(this.props,(function(t,i){if(i===dt&&C(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,(L(n=Ct)?a:l&&n.indexOf===l?-1!=n.indexOf(o):(Pe(n,(function(e){if(a||(a=e===o))return Re})),a))||(e[i]=t);var n,o,a})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=Te({},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(C(e)){T(t)&&(t="None"),this._expire_days=T(i)?this._default_expiry:i;var s=!1;if(Pe(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(C(e)){this._expire_days=T(t)?this._default_expiry:t;var i=!1;if(Pe(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=ao(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);P(Oe(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==c?void 0:c.referrer)?uo(e):{})}update_referrer_info(){var e;this.register_once({$referrer:_o(),$referring_domain:null!=c&&c.referrer&&(null==(e=_i(c.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[St]||this.props[Et]||this.register_once({[kt]:ho(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Pe([Et,St],(t=>{var i=this.props[t];i&&Pe(i,(function(t,i){e["$initial_"+w(i)]=t}))}));var t,i,s=this.props[kt];if(s){var r=(t=po(s),i={},Pe(t,(function(e,t){i["$initial_"+w(t)]=e})),i);Te(e,r)}return e}safe_merge(e){return Pe(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[Ue]||{};i[e]=t,this.props[Ue]=i,this.save()}remove_event_timer(e){var t=(this.props[Ue]||{})[e];return T(t)||(delete this.props[Ue][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var To=function(e){return e.Button="button",e.Tab="tab",e.Selector="selector",e}({}),Fo=function(e){return e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger",e}({}),Mo=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({}),$o=function(e){return e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link",e}({}),Lo=function(e){return e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question",e}({}),Oo=function(e){return e.Once="once",e.Recurring="recurring",e.Always="always",e}({}),Ao=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e}({}),Do=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}({}),No=function(e){return e.Popover="popover",e.Inline="inline",e}({});class qo{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 Bo{constructor(e){this._debugEventEmitter=new qo,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(!T(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(!T(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(!Bo._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&&Zr(e,t);case"exact":return t===e;case"contains":var s=Bo._escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return Zr(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&&!Bo._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&&!Bo._matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!Bo._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 Ho=Ie("[Surveys]");var zo="seenSurvey_",Uo=(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},jo=e=>{var t=""+zo+e.id;return e.current_iteration&&e.current_iteration>0&&(t=""+zo+e.id+"_"+e.current_iteration),t},Wo=[Mo.Popover,Mo.Widget,Mo.API],Vo={ignoreConditions:!1,ignoreDelay:!1,displayType:No.Popover};class Go{constructor(e){this._instance=e,this._eventToSurveys=new Map,this._actionToSurveys=new Map}register(e){var t;T(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 Bo(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[ft])||[];if(Ao.SHOWN===e&&t&&r.length>0){var n;Ho.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)){Ho.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 u=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(T(n)||L(n))return!1;var o=[String(n)],a=tn[r.operator];return a?a(r.values,o):(Ho.warn("Unknown property comparison operator: "+r.operator),!1)})))}));this._updateActivatedSurveys(r.concat(u.map((e=>e.id))||[]))}}onAction(e){var t,i=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[ft])||[];this._actionToSurveys.has(e)&&this._updateActivatedSurveys(i.concat(this._actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t;Ho.info("updating activated surveys",{activatedSurveys:e}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[ft]:[...new Set(e)]})}getSurveys(){var e,t=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[ft];return t||[]}getEventToSurveys(){return this._eventToSurveys}_getActionMatcher(){return this._actionMatcher}}class Yo{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(O(t))return Ho.warn("Flags not loaded yet. Not loading surveys.");var i=I(t);this._isSurveysEnabled=i?t.length>0:t,Ho.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(zo)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Ho.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Ho.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Ho.info("Not loading surveys in cookieless mode without consent.");else{var e=null==v?void 0:v.__PosthogExtensions__;if(e){if(!T(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 Ho.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Go(this._instance),Ho.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){Ho.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 Ho.info("Disabled. Not loading surveys."),e([]);var i=this._instance.get_property(vt);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 Ho.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({[vt]: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){Ho.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!O(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Ho.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(O(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(O(this._surveyManager))return Ho.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 O(this._surveyManager)?(Ho.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(O(this._surveyManager))Ho.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(Wo.includes(s.type)){var r=null==c?void 0:c.querySelector(t);if(r)return null!=(i=s.appearance)&&i.surveyPopupDelaySeconds?(Ho.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;Ho.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),Ho.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,r);Ho.warn("Survey element not found")}else Ho.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Ho.warn("Survey not found")}}displaySurvey(e,t){var s;if(O(this._surveyManager))Ho.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 Ho.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==No.Inline?this._surveyManager.handlePopoverSurvey(n):this.renderSurvey(n,t.selector)}else Ho.warn("Survey not found")}}}var Jo=Ie("[RateLimiter]");class Ko{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=>{Jo.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Jo.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(wt))&&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(wt,n),{isRateLimited:o,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Xo=Ie("[RemoteConfig]");class Qo{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))):(Xo.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 Xo.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Xo.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Xo.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){Xo.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()):Xo.info("__preview_remote_config is disabled. Logging config instead",e):Xo.error("Failed to fetch remote config from PostHog.")}}var Zo=3e3;class ea{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=V((null==t?void 0:t.flush_interval_ms)||Zo,250,5e3,xe.createLogger("flush interval"),Zo),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&&I(i.data)&&Pe(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 Pe(this._queue,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;T(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)})),this._queue=[],e}}var ta=["retriesPerformedSoFar"];class ia{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!T(r)&&"onLine"in r.navigator&&(this._areWeOnline=r.navigator.onLine,Be(r,"online",(()=>{this._areWeOnline=!0,this._flush()})),Be(r,"offline",(()=>{this._areWeOnline=!1})))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=s(e,ta);A(t)&&t>0&&(r.url=Jr(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)"),xe.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){this._poller&&clearTimeout(this._poller),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._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){xe.error(e)}this._queue=[]}}class sa{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(){Be(r,"scroll",this._updateScrollData,{capture:!0}),Be(r,"scrollend",this._updateScrollData,{capture:!0}),Be(r,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==r?void 0:r.document.documentElement;var e=I(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 ra=e=>ho(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class na{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({[bt]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||ra,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[bt]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?po(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 Pe(Oe(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+w(i)]=t})),e}}var oa=Ie("[SessionId]");class aa{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._sessionIdChangedHandlers=[],this._eventEmitter=new qo,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||Pi,this._windowIdGenerator=i||Pi;var r=this._config.persistence_name||this._config.token,n=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*V(n,60,36e3,oa.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=zi._parse(this._window_id_storage_key),a=zi._parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:zi._remove(this._window_id_storage_key),zi._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){oa.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return T(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&&zi._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&zi._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?zi._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({[at]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this._persistence.props[at];return I(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){Be(r,"beforeunload",(()=>{this._canUseSessionStorage()&&zi._remove(this._primary_window_exists_storage_key)}),{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=A(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,u=!r,c=!e&&this._sessionHasBeenIdleTooLong(i,s);u||c||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),oa.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:u,activityTimeout:c,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:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:u,activityTimeout:c,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 la=["$set_once","$set"],ua=Ie("[SiteApps]");class ca{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,u;if(!e)throw new Error("Event payload is required");var c={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))c[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},s(e,la),{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==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this._bufferedInvocations.length&&(ua.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,ua.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){ua.error("Error while initializing PostHog app with config id "+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){ua.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){ua.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 ua.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 ua.error("Error while initializing PostHog app with config id "+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else ua.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var da=["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"],_a=function(e,t){if(!e)return!1;var i=e.toLowerCase();return da.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},ha=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&_a(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>_a(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},pa=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),ga="i.posthog.com";class va{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("."+ga,".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]=pa.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=pa.EU:this._regionCache[this.apiHost]=pa.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===pa.CUSTOM)return this.apiHost+t;var i=ga+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var fa={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&&Zr(t.href,e),not_regex:(e,t)=>!!r&&!Zr(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class ma{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{ma._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)ma._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);F(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];ma._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())ma._logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(O(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ma._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=ma.getWindowLocation();if(null!=e&&e.search){var t=pi(null==e?void 0:e.search,"__experiment_id"),i=pi(null==e?void 0:e.search,"__experiment_variant");t&&i&&(ma._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&&(ma._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!O(e.conditions)&&(ma._matchUrlConditions(e)&&ma._matchUTMConditions(e))}static _matchUrlConditions(e){var t;if(O(e.conditions)||O(null==(t=e.conditions)?void 0:t.url))return!0;var i,s,r,n=ma.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||fa[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(O(e.conditions)||O(null==(t=e.conditions)?void 0:t.utm))return!0;var i=ao();if(i.utm_source){var s,r,n,o,a,l,u,c,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==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.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];xe.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?ma._logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var s;ma._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)}))}})):ma._logInfo("Control variants leave the page unmodified.")}_is_bot(){return u&&this._instance?ha(u,this._instance.config.custom_blocked_useragents):void 0}}var ya=Ie("[PostHog ExternalIntegrations]"),ba={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class wa{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 ya.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(ba[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 Sa="[SessionRecording]",Ea=Ie(Sa);class ka{get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e;return this._receivedFlags&&!this._isRecordingEnabled?Qs:(null==(e=this._lazyLoadedSessionRecording)?void 0:e.status)||"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._receivedFlags=!1,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Ea.error("started without valid sessionManager"),new Error(Sa+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(Sa+' cannot be used with cookieless_mode="always"')}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(Qe))||!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=!T(Object.assign)&&!T(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Ea.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 Ea.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e;null==(e=this._lazyLoadedSessionRecording)||e.stop()}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(lt)}_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=O(s)?null:parseFloat(s);O(n)&&this._resetSampling();var o=null==t?void 0:t.minimumDurationMilliseconds;r.register({[Qe]: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:T(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:Ea.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):Ea.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(Qe);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 xa={},Ia=()=>{},Ra="posthog",Ca=!Gr&&-1===(null==g?void 0:g.indexOf("MSIE"))&&-1===(null==g?void 0:g.indexOf("Mozilla")),Pa=e=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:Ne(null==c?void 0:c.location),persistence:"localStorage+cookie",persistence_name:"",loaded:Ia,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&&F(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;xe.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:Zo},error_tracking:{},_onCapture:Ia,__preview_eager_load_replay:!1}},Ta=e=>{var t={};T(e.process_person)||(t.person_profiles=e.process_person),T(e.xhr_headers)||(t.request_headers=e.xhr_headers),T(e.cookie_name)||(t.persistence_name=e.cookie_name),T(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),T(e.store_google)||(t.save_campaign_params=e.store_google),T(e.verbose)||(t.debug=e.verbose);var i=Te({},t,e);return I(e.property_blacklist)&&(T(e.property_denylist)?i.property_denylist=e.property_blacklist:I(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:xe.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class Fa{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){xe.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Ma{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 Fa,this._personProcessingSetOncePropertiesSent=!1,this.version=f.LIB_VERSION,this._internalEventEmitter=new qo,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Pa(),this.SentryIntegration=Fr,this.sentryIntegration=e=>function(e,t){var i=Tr(e,t);return{name:Pr,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 Ro(this),this.toolbar=new Ar(this),this.scrollManager=new sa(this),this.pageViewManager=new Wr(this),this.surveys=new Yo(this),this.experiments=new ma(this),this.exceptions=new nn(this),this.rateLimiter=new Ko(this),this.requestRouter=new va(this),this.consent=new ji(this),this.externalIntegrations=new wa(this),this.people={set:(e,t,i)=>{var s=F(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=F(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>xe.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Ra){var s,r=null!==(s=xa[i])&&void 0!==s?s:new Ma;return r._init(e,t,i),xa[i]=r,xa[Ra][i]=r,r}return this._init(e,t,i)}_init(e,t,s){var n,o;if(void 0===t&&(t={}),T(e)||M(e))return xe.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 xe.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles&&(this._initialPersonProfilesConfig=t.person_profiles),this.set_config(Te({},Pa(t.defaults),Ta(t),{name:s,token:e})),this.config.on_xhr_error&&xe.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ui.GZipJS;var a=this._is_persistence_disabled();this.persistence=new Po(this.config,a),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Po(i({},this.config,{persistence:"sessionStorage"}),a);var l=i({},this.persistence.props),u=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new ea((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new ia(this),this.__request_queue=[];var c="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(c||(this.sessionManager=new aa(this),this.sessionPropsManager=new na(this,this.sessionManager,this.persistence)),new Nr(this).startIfEnabledOrStop(),this.siteApps=new ca(this),null==(n=this.siteApps)||n.init(),c||(this.config.__preview_eager_load_replay?this.sessionRecording=new Ir(this):this.sessionRecording=new ka(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Si(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new jr(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Hr(this),this.exceptionObserver=new Ki(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Yi(this,Gi),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new Qi(this),this.historyAutocapture.startIfEnabled(),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&xe.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:u}),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var d,_,h=this.config.get_device_id(Pi()),p=null!=(d=t.bootstrap)&&d.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(yt,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(c)this.register_once({distinct_id:Rt,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(Pi());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(yt,"anonymous")}return Be(r,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Cr(this,(()=>this._loaded())):this._loaded(),R(this.config._onCapture)&&this.config._onCapture!==Ia&&(xe.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&xe.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(!c||!c.body)return xe.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=y(e.supportedCompression,ui.GZipJS)?ui.GZipJS:y(e.supportedCompression,ui.Base64)?ui.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){xe.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 Qo(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()&&Ce(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&&(Ca?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Jr(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=Jr(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=Qr.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(s=null==(r=qe(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=[];Ce(e,(e=>{e&&(t=e[0],I(t)?r.push(e):R(e)?e.call(this):I(e)&&"alias"===t?i.push(e):I(e)&&-1!==t.indexOf("capture")&&R(this[t])?r.push(e):s.push(e))}));var n=function(e,t){Ce(e,(function(e){if(I(e[0])){var i=t;Pe(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(!T(e)&&F(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var n=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==n||!n.isRateLimited){null!=t&&t.$current_url&&!F(null==t?void 0:t.$current_url)&&(xe.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 o=new Date,a=(null==s?void 0:s.timestamp)||o,l=Pi(),u={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},a,l)};n&&(u.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens),(null==s?void 0:s.$set)&&(u.$set=null==s?void 0:s.$set);var c,d=this._calculate_set_once_properties(null==s?void 0:s.$set_once);if(d&&(u.$set_once=d),(u=Ae(u,null!=s&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,T(null==s?void 0:s.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=o),e===Ao.DISMISSED||e===Ao.SENT){var _=null==t?void 0:t[Do.SURVEY_ID],h=null==t?void 0:t[Do.SURVEY_ITERATION];c={id:_,current_iteration:h},localStorage.getItem(jo(c))||localStorage.setItem(jo(c),"true"),u.$set=i({},u.$set,{[Uo({id:_,current_iteration:h},e===Ao.SENT?"responded":"dismissed")]:!0})}var p=i({},u.properties.$set,u.$set);if(P(p)||this.setPersonPropertiesForFlags(p),!O(this.config.before_send)){var g=this._runBeforeSend(u);if(!g)return;u=g}this._internalEventEmitter.emit("eventCaptured",u);var v={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(v):this._requestQueue.enqueue(v),u}xe.critical("This capture call is ignored due to client rate limiting.")}}else xe.error("No event name provided to posthog.capture")}else xe.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,(!F(a.distinct_id)&&!A(a.distinct_id)||M(a.distinct_id))&&xe.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,d=fo(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&&Te(a,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Te(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===pa.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),u="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=Te(a,u),"$pageview"===e&&c&&(a.title=c.title),!T(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=Te({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),I(this.config.property_denylist)?Pe(this.config.property_denylist,(function(e){delete a[e]})):xe.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&&(xe.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=Te({},i,s||{},e||{}),n=this.config.sanitize_properties;return n&&(xe.error("sanitize_properties is deprecated. Use before_send instead"),r=n(r,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,P(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=Vo),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 xe.uninitializedWarning("posthog.identify");if(A(e)&&(e=e.toString(),xe.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()))xe.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!==Rt){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(ze)&&(this.unregister(ze),this.register({distinct_id:e}));var o="anonymous"===(this.persistence.get_property(yt)||"anonymous");e!==r&&o?(this.persistence.set_property(yt,"identified"),this.setPersonPropertiesForFlags(i({},s||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:s||{}}),this._cachedPersonProperties=en(e,t,s),this.featureFlags.setAnonymousDistinctId(r)):(t||s)&&this.setPersonProperties(t,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(mt))}}else xe.critical('The string "'+Rt+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else xe.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var s=en(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):xe.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 xe.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(xe.info("reset"),!this.__loaded)return xe.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(yt,"anonymous"),null==(r=this.sessionManager)||r.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Rt,$device_id:null},"");else{var o=this.config.get_device_id(Pi());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(He)?(xe.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(T(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(ze,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(xe.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(C(e)){var s,r,n,o,a;Te(this.config,Ta(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 Po(i({},this.config,{persistence:"sessionStorage"}),l),Ai._is_supported()&&"true"===Ai._get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(f.DEBUG=!0,xe.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})),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:Ra;return t!==Ra&&(t=Ra+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(yt))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(yt))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&P(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[ze])&&(null==(t=this.persistence)||null==(t=t.props)||!t[xt]))}_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?(xe.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(xt,!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;if("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),this.sessionManager=new aa(this),this.persistence&&(this.sessionPropsManager=new na(this,this.sessionManager,this.persistence)),this.sessionRecording=new Ir(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),T(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)this.capture(null!==(t=null==e?void 0:e.captureEventName)&&void 0!==t?t:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}else xe.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e;"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:Rt,$device_id:null}),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(e=this.sessionRecording)||e.stopRecording(),this.sessionRecording=void 0,this._captureInitialPageview())):xe.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===Ui.GRANTED?"granted":e===Ui.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 u?ha(u,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){c&&("visible"===c.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:c.title},{send_instantly:!0}),this._visibilityStateListener&&(c.removeEventListener("visibilitychange",this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Be(c,"visibilitychange",this._visibilityStateListener)))}debug(e){!1===e?(null==r||r.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),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)`."),localStorage&&localStorage.setItem("ph_debug","true"),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?(xe.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=xe,n=(t="advanced_disable_flags")in(e=a)&&!T(e[t]),o=i in e&&!T(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(O(this.config.before_send))return e;var t=I(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),O(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return q(e.event)?xe.warn(r+". This can cause unexpected behavior."):xe.info(r),null}i.properties&&!P(i.properties)||xe.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)})}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Le(e.prototype[t[i]])}(Ma,["identify"]);var $a,La=($a=xa[Ra]=new Ma,function(){function e(){e.done||(e.done=!0,Ca=!1,Pe(xa,(function(e){e._dom_loaded()})))}null!=c&&c.addEventListener?"complete"===c.readyState?e():Be(c,"DOMContentLoaded",e,{capture:!1}):r&&xe.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),$a);export{li as COPY_AUTOCAPTURE_EVENT,ui as Compression,No as DisplaySurveyType,Ma as PostHog,Ao as SurveyEventName,Do as SurveyEventProperties,Fo as SurveyPosition,Lo as SurveyQuestionBranchingType,$o as SurveyQuestionType,Oo as SurveySchedule,Mo as SurveyType,To as SurveyWidgetType,La as default,La as posthog,ci as severityLevels};
|
|
1
|
+
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,u=null==n?void 0:n.navigator,c=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==u?void 0:u.userAgent,v=null!=r?r:{},f={DEBUG:!1,LIB_VERSION:"1.273.0"},m=["$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 y(e,t){return-1!==e.indexOf(t)}var b=function(e){return e.trim()},w=function(e){return e.replace(/^\$/,"")};var S=Array.isArray,E=Object.prototype,k=E.hasOwnProperty,x=E.toString,I=S||function(e){return"[object Array]"===x.call(e)},R=e=>"function"==typeof e,C=e=>e===Object(e)&&!I(e),P=e=>{if(C(e)){for(var t in e)if(k.call(e,t))return!1;return!0}return!1},T=e=>void 0===e,F=e=>"[object String]"==x.call(e),M=e=>F(e)&&0===e.trim().length,L=e=>null===e,O=e=>T(e)||L(e),A=e=>"[object Number]"==x.call(e),D=e=>"[object Boolean]"===x.call(e),N=e=>e instanceof FormData,q=e=>y(m,e);function B(e){return null===e||"object"!=typeof e}function H(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function z(e){return!T(Event)&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var U=[!0,"true",1,"1","yes"],j=e=>y(U,e),W=[!1,"false",0,"0","no"];function V(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),A(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),V(r||i,t,i,s))}class G{constructor(e){this._options=e,this._buckets={},this._refillBuckets=()=>{Object.keys(this._buckets).forEach((e=>{var t=this._getBucket(e)+this._refillRate;t>=this._bucketSize?delete this._buckets[e]:this._setBucket(e,t)}))},this._getBucket=e=>this._buckets[String(e)],this._setBucket=(e,t)=>{this._buckets[String(e)]=t},this.consumeRateLimit=e=>{var t,i,s=null!==(t=this._getBucket(e))&&void 0!==t?t:this._bucketSize;if(0===(s=Math.max(s-1,0)))return!0;this._setBucket(e,s);var r=0===s;return r&&(null==(i=this._onBucketRateLimited)||i.call(this,e)),r},this._onBucketRateLimited=this._options._onBucketRateLimited,this._bucketSize=V(this._options.bucketSize,0,100,this._options._logger),this._refillRate=V(this._options.refillRate,0,this._bucketSize,this._options._logger),this._refillInterval=V(this._options.refillInterval,0,864e5,this._options._logger),this._removeInterval=setInterval((()=>{this._refillBuckets()}),this._refillInterval)}stop(){this._removeInterval&&(clearInterval(this._removeInterval),this._removeInterval=void 0)}}var Y,J,K,X=e=>e instanceof Error;function Q(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return K&&i.length===J||(J=i.length,K=i.reduce(((i,s)=>{Y||(Y={});var r=Y[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,u=t[s];if(l&&u){i[l]=u,Y[s]=[l,u];break}}return i}),{})),K}}var Z="?";function ee(e,t,i,s){var r={platform:"web:javascript",filename:e,function:"<anonymous>"===t?Z:t,in_app:!0};return T(i)||(r.lineno=i),T(s)||(r.colno=s),r}var te=(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]:Z,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},ie=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,se=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,re=/\((\S*)(?::(\d+))(?::(\d+))\)/,ne=e=>{var t=ie.exec(e);if(t){var[,i,s,r]=t;return ee(i,Z,+s,+r)}var n=se.exec(e);if(n){if(n[2]&&0===n[2].indexOf("eval")){var o=re.exec(n[2]);o&&(n[2]=o[1],n[3]=o[2],n[4]=o[3])}var[a,l]=te(n[1]||Z,n[2]);return ee(l,a,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},oe=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ae=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,le=e=>{var t=oe.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=ae.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]||Z;return[r,s]=te(r,s),ee(s,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},ue=/\(error: (.*)\)/,ce=50;function de(){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=ue.test(a)?a.replace(ue,"$1"):a;if(!l.match(/\S*Error: /)){for(var u of t){var c=u(l);if(c){r.push(c);break}}if(r.length>=ce)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,ce).map((e=>{return i({},e,{filename:e.filename||(s=t,s[s.length-1]||{}).filename,function:e.function||Z});var s}))}(r)}}class _e{constructor(e,t,i){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===i&&(i=[]),this.coercers=e,this.modifiers=i,this.stackParser=de(...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&&I(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:Q(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 he{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=F(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 H(e,"DOMException")}isDOMError(e){return H(e,"DOMError")}}class pe{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 ge{constructor(){}match(e){return H(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 ve=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class fe{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(ve);return s&&(t=s[1],i=s[2]),[t,i]}}var me=["fatal","error","warning","log","info","debug"];function ye(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 be{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 z(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: "+ye(e)}isSeverityLevel(e){return F(e)&&!M(e)&&me.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(X(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class we{match(e){return z(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+ye(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Se{match(e){return B(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 Ee{match(e){return H(e,"PromiseRejectionEvent")}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return B(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(B(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 ke=e=>{var t={_log:function(t){if(r&&(f.DEBUG||v.POSTHOG_DEBUG)&&!T(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=>ke(e+" "+t)};return t},xe=ke("[PostHog.js]"),Ie=xe.createLogger,Re={};function Ce(e,t,i){if(I(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)===Re)return}function Pe(e,t,i){if(!O(e)){if(I(e))return Ce(e,t,i);if(N(e)){for(var s of e.entries())if(t.call(i,s[1],s[0])===Re)return}else for(var r in e)if(k.call(e,r)&&t.call(i,e[r],r)===Re)return}}var Te=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 Ce(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},Fe=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 Ce(i,(function(t){Ce(t,(function(t){e.push(t)}))})),e};function Me(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 $e=function(e){try{return e()}catch(e){return}},Le=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){xe.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),xe.critical(e)}}},Oe=function(e){var t={};return Pe(e,(function(e,i){(F(e)&&e.length>0||A(e))&&(t[i]=e)})),t};function Ae(e,t){return i=e,s=e=>F(e)&&!L(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),I(t)?(n=[],Ce(t,(t=>{n.push(e(t))}))):(n={},Pe(t,((t,i)=>{r.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,s,r}var De=["herokuapp.com","vercel.app","netlify.app"];function Ne(e){var t=null==e?void 0:e.hostname;if(!F(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of De)if(i===s)return!1;return!0}function qe(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Be(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 He="$people_distinct_id",ze="__alias",Ue="__timers",je="$autocapture_disabled_server_side",We="$heatmaps_enabled_server_side",Ve="$exception_capture_enabled_server_side",Ge="$error_tracking_suppression_rules",Ye="$error_tracking_capture_extension_exceptions",Je="$web_vitals_enabled_server_side",Ke="$dead_clicks_enabled_server_side",Xe="$web_vitals_allowed_metrics",Qe="$session_recording_remote_config",Ze="$session_recording_enabled_server_side",et="$console_log_recording_enabled_server_side",tt="$session_recording_network_payload_capture",it="$session_recording_masking",st="$session_recording_canvas_recording",rt="$replay_sample_rate",nt="$replay_minimum_duration",ot="$replay_script_config",at="$sesid",lt="$session_is_sampled",ut="$session_recording_url_trigger_activated_session",ct="$session_recording_event_trigger_activated_session",dt="$enabled_feature_flags",_t="$early_access_features",ht="$feature_flag_details",pt="$stored_person_properties",gt="$stored_group_properties",vt="$surveys",ft="$surveys_activated",mt="$flag_call_reported",yt="$user_state",bt="$client_session_props",wt="$capture_rate_limit",St="$initial_campaign_params",Et="$initial_referrer_info",kt="$initial_person_info",xt="$epp",It="__POSTHOG_TOOLBAR__",Rt="$posthog_cookieless",Ct=[He,ze,"__cmpns",Ue,Ze,We,at,dt,Ge,yt,_t,ht,gt,pt,vt,mt,bt,wt,St,Et,xt,kt];function Pt(e){return e instanceof Element&&(e.id===It||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function Tt(e){return!!e&&1===e.nodeType}function Ft(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Mt(e){return!!e&&3===e.nodeType}function $t(e){return!!e&&11===e.nodeType}function Lt(e){return e?b(e).split(/\s+/):[]}function Ot(e){var t=null==r?void 0:r.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function At(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 Lt(t)}function Dt(e){return O(e)?null:b(e).split(/(\s+)/).filter((e=>ti(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Nt(e){var t="";return Gt(e)&&!Yt(e)&&e.childNodes&&e.childNodes.length&&Pe(e.childNodes,(function(e){var i;Mt(e)&&e.textContent&&(t+=null!==(i=Dt(e.textContent))&&void 0!==i?i:"")})),b(t)}function qt(e){return T(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Bt=["a","button","form","input","select","textarea","label"];function Ht(e,t){if(T(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 zt(e){var t=e.parentNode;return!(!t||!Tt(t))&&t}var Ut=[".ph-no-rageclick",".ph-no-capture"];var jt=e=>!e||Ft(e,"html")||!Tt(e),Wt=(e,t)=>{if(!r||jt(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],n=e;n.parentNode&&!Ft(n,"body");)if($t(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=zt(n);if(!o)break;if(t||Bt.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 Vt(e,t,i,s,n){var o,a,l,u;if(void 0===i&&(i=void 0),!r||jt(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!Ot(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&Ot(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var c=i.dom_event_allowlist;if(c&&!c.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:d,targetElementList:_}=Wt(e,s);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(T(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(!Ht(_,null==(u=i)?void 0:u.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&&(Bt.indexOf(p)>-1||"true"===e.getAttribute("contenteditable"))}}function Gt(e){for(var t=e;t.parentNode&&!Ft(t,"body");t=t.parentNode){var i=At(t);if(y(i,"ph-sensitive")||y(i,"ph-no-capture"))return!1}if(y(At(e),"ph-include"))return!0;var s=e.type||"";if(F(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(F(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 Yt(e){return!!(Ft(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ft(e,"select")||Ft(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})",Kt=new RegExp("^(?:"+Jt+")$"),Xt=new RegExp(Jt),Qt="\\d{3}-?\\d{2}-?\\d{4}",Zt=new RegExp("^("+Qt+")$"),ei=new RegExp("("+Qt+")");function ti(e,t){if(void 0===t&&(t=!0),O(e))return!1;if(F(e)){if(e=b(e),(t?Kt:Xt).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Zt:ei).test(e))return!1}return!0}function ii(e){var t=Nt(e);return ti(t=(t+" "+si(e)).trim())?t:""}function si(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Pe(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=Nt(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+si(e)).trim())}catch(e){xe.error("[AutoCapture]",e)}})),t}function ri(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 Me(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[ni(t.toString())]=ni(i.toString())})),r+=":",r+=Me(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:oi(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Me(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 ni(e){return e.replace(/"|\\"/g,'\\"')}function oi(e){var t=e.attr__class;return t?I(t)?t:Lt(t):void 0}class ai{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 li="$copy_autocapture",ui=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ci=["fatal","error","warning","log","info","debug"],di=["localhost","127.0.0.1"],_i=e=>{var t=null==c?void 0:c.createElement("a");return T(t)?null:(t.href=e,t)},hi=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return Pe(e,(function(e,t){T(e)||T(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)},pi=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(!I(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){xe.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},gi=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],u=(a||"").split("&"),c=[],d=0;d<u.length;d++){var _=u[d].split("=");I(_)&&(t.includes(_[0])?c.push(_[0]+"="+i):c.push(u[d]))}var h=l;return null!=a&&(h+="?"+c.join("&")),null!=n&&(h+="#"+n),h},vi=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},fi=Ie("[AutoCapture]");function mi(e,t){return t.length>e?t.slice(0,e)+"...":t}function yi(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Tt(t));return t}function bi(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};Bt.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?n.$el_text=mi(1024,ii(e)):n.$el_text=mi(1024,Nt(e)));var o=At(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),Pe(e.attributes,(function(i){var r;if((!Yt(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==s||!s.includes(i.name))&&!t&&ti(i.value)&&(r=i.name,!F(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Lt(o).join(" ")),n["attr__"+i.name]=mi(1024,o)}}));for(var a=1,l=1,u=e;u=yi(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function wi(e,t){for(var i,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=t,c=[e],d=e;d.parentNode&&!Ft(d,"body");)$t(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var _,h=[],p={},g=!1,v=!1;if(Pe(c,(e=>{var t=Gt(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&ti(g)&&g),y(At(e),"ph-no-capture")&&(v=!0),h.push(bi(e,o,a,l));var i=function(e){if(!Gt(e))return{};var t={};return Pe(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&&ti(s)&&(t[i]=s)}})),t}(e);Te(p,i)})),v)return{props:{},explicitNoCapture:v};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=ii(e):h[0].$el_text=Nt(e)),g){var f,m;h[0].attr__href=g;var b=null==(f=_i(g))?void 0:f.host,w=null==r||null==(m=r.location)?void 0:m.host;b&&w&&b!==w&&(_=g)}return{props:Te({$event_type:n.type,$ce_version:1},u?{}:{$elements:h},{$elements_chain:ri(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 Si{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this.rageclicks=new ai,this._elementsChainAsString=!1,this.instance=e,this._elementSelectors=null}get _config(){var e,t,i=C(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&&c){var e=e=>{e=e||(null==r?void 0:r.event);try{this._captureEvent(e)}catch(e){fi.error("Failed to capture event",e)}};if(Be(c,"submit",e,{capture:!0}),Be(c,"change",e,{capture:!0}),Be(c,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==r?void 0:r.event),this._captureEvent(e,li)};Be(c,"copy",t,{capture:!0}),Be(c,"cut",t,{capture:!0})}}}else fi.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({[je]:!!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==c?void 0:c.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[je],s=this._isDisabledServerSide;if(L(s)&&!D(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=qt(e);if(Mt(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||jt(e))return!1;var i,s;if(!1===(i=D(t)?!!t&&Ut:null!==(s=null==t?void 0:t.css_selector_ignorelist)&&void 0!==s?s:Ut))return!1;var{targetElementList:n}=Wt(e,!1);return!Ht(n,i)}(s,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var n=t===li;if(s&&Vt(s,e,this._config,n,n?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=wi(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===li){var u,c=Dt(null==r||null==(u=r.getSelection())?void 0:u.toString()),d=e.type||"clipboard";if(!c)return!1;o.$selected_content=c,o.$copy_type=d}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return R(null==c?void 0:c.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return A(e)&&isFinite(e)&&Math.floor(e)===e});var Ei="0123456789abcdef";class ki{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 ki(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Ei.charAt(this.bytes[t]>>>4)+Ei.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 ki(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 xi{constructor(){this._timestamp=0,this._counter=0,this._random=new Ci}generate(){var e=this.generateOrAbort();if(T(e)){this._timestamp=0;var t=this.generateOrAbort();if(T(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 ki.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 Ii,Ri=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&&!T(r.crypto)&&crypto.getRandomValues&&(Ri=e=>crypto.getRandomValues(e));class Ci{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(Ri(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var Pi=()=>Ti().toString(),Ti=()=>(Ii||(Ii=new xi)).generate(),Fi="";var Mi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function $i(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=c),Fi)return Fi;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_"+Pi();!Fi&&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",Fi=n)}return Fi}(e);if(!i){var s=(e=>{var t=e.match(Mi);return t?t[0]:""})(e);s!==i&&xe.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}var Li={_is_supported:()=>!!c,_error:function(e){xe.error("cookieStore error: "+e)},_get:function(e){if(c){try{for(var t=e+"=",i=c.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(Li._get(e))||{}}catch(e){}return t},_set:function(e,t,i,s,r){if(c)try{var n="",o="",a=$i(c.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 u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&xe.warn("cookieStore warning: large cookie, len="+u.length),c.cookie=u,u}catch(e){return}},_remove:function(e,t){if(null!=c&&c.cookie)try{Li._set(e,"",-1,t)}catch(e){return}}},Oi=null,Ai={_is_supported:function(){if(!L(Oi))return Oi;var e=!0;if(T(r))e=!1;else try{var t="__mplssupport__";Ai._set(t,"xyz"),'"xyz"'!==Ai._get(t)&&(e=!1),Ai._remove(t)}catch(t){e=!1}return e||xe.error("localStorage unsupported; falling back to cookie store"),Oi=e,e},_error:function(e){xe.error("localStorage error: "+e)},_get:function(e){try{return null==r?void 0:r.localStorage.getItem(e)}catch(e){Ai._error(e)}return null},_parse:function(e){try{return JSON.parse(Ai._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==r||r.localStorage.setItem(e,JSON.stringify(t))}catch(e){Ai._error(e)}},_remove:function(e){try{null==r||r.localStorage.removeItem(e)}catch(e){Ai._error(e)}}},Di=["distinct_id",at,lt,xt,kt],Ni=i({},Ai,{_parse:function(e){try{var t={};try{t=Li._parse(e)||{}}catch(e){}var i=Te(t,JSON.parse(Ai._get(e)||"{}"));return Ai._set(e,i),i}catch(e){}return null},_set:function(e,t,i,s,r,n){try{Ai._set(e,t,void 0,void 0,n);var o={};Di.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&Li._set(e,o,i,s,r,n)}catch(e){Ai._error(e)}},_remove:function(e,t){try{null==r||r.localStorage.removeItem(e),Li._remove(e,t)}catch(e){Ai._error(e)}}}),qi={},Bi={_is_supported:function(){return!0},_error:function(e){xe.error("memoryStorage error: "+e)},_get:function(e){return qi[e]||null},_parse:function(e){return qi[e]||null},_set:function(e,t){qi[e]=t},_remove:function(e){delete qi[e]}},Hi=null,zi={_is_supported:function(){if(!L(Hi))return Hi;if(Hi=!0,T(r))Hi=!1;else try{var e="__support__";zi._set(e,"xyz"),'"xyz"'!==zi._get(e)&&(Hi=!1),zi._remove(e)}catch(e){Hi=!1}return Hi},_error:function(e){xe.error("sessionStorage error: ",e)},_get:function(e){try{return null==r?void 0:r.sessionStorage.getItem(e)}catch(e){zi._error(e)}return null},_parse:function(e){try{return JSON.parse(zi._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==r||r.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){zi._error(e)}},_remove:function(e){try{null==r||r.sessionStorage.removeItem(e)}catch(e){zi._error(e)}}},Ui=function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e}({});class ji{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?Ui.DENIED:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||(this.consent===Ui.DENIED||this.consent===Ui.PENDING&&(this._config.opt_out_capturing_by_default||"on_reject"===this._config.cookieless_mode))}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Ui.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 j(e)?Ui.GRANTED:y(W,e)?Ui.DENIED:Ui.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?Ai:Li;var t="localStorage"===e?Li:Ai;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(j(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!qe([null==u?void 0:u.doNotTrack,null==u?void 0:u.msDoNotTrack,v.doNotTrack],(e=>j(e)))}}var Wi=Ie("[Dead Clicks]"),Vi=()=>!0,Gi=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Ke)),s=e.instance.config.capture_dead_clicks;return D(s)?s:i};class Yi{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({[Ke]: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?Wi.error("failed to load script",t):e()}))}_start(){var e;if(c){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=C(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(c),Wi.info("starting...")}}else Wi.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Wi.info("stopping..."))}}var Ji=Ie("[ExceptionAutocapture]");class Ki{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){Ji.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[Ve]),this._config=this._requiredConfig(),this._rateLimiter=new G({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:Ji}),this.startIfEnabled()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return C(e)?t=i({},t,e):(T(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&&(Ji.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 Ji.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({[Ve]: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)?Ji.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}}function Xi(e,t,i){try{if(!(t in e))return()=>{};var s=e[t],r=i(s);return R(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=r,()=>{e[t]=s}}catch(e){return()=>{}}}class Qi{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&&(xe.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,xe.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(r&&r.history){var i=this;null!=(e=r.history.pushState)&&e.__posthog_wrapped__||Xi(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__||Xi(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){xe.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Be(r,"popstate",e),this._popstateListener=()=>{r&&r.removeEventListener("popstate",e)}}}}function Zi(e){var t,i;return(null==(t=JSON.stringify(e,(i=[],function(e,t){if(C(t)){for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(t)?"[Circular]":(i.push(t),t)}return t})))?void 0:t.length)||0}function es(e,t){if(void 0===t&&(t=6606028.8),e.size>=t&&e.data.length>1){var i=Math.floor(e.data.length/2),s=e.data.slice(0,i),r=e.data.slice(i);return[es({size:Zi(s),data:s,sessionId:e.sessionId,windowId:e.windowId}),es({size:Zi(r),data:r,sessionId:e.sessionId,windowId:e.windowId})].flatMap((e=>e))}return[e]}var ts=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(ts||{}),is=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(is||{}),ss="[SessionRecording]",rs="redacted",ns={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com","bam.nr-data.net"]},os=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],as=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],ls=["/s/","/e/","/i/"];function us(e,t,i,s){if(O(e))return e;var r=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return F(r)&&(r=parseInt(r)),r>i?ss+" "+s+" body too large to record ("+r+" bytes)":e}function cs(e,t){if(O(e))return e;var i=e;return ti(i,!1)||(i=ss+" "+t+" body "+rs),Pe(as,(e=>{var s,r;null!=(s=i)&&s.length&&-1!==(null==(r=i)?void 0:r.indexOf(e))&&(i=ss+" "+t+" body "+rs+" as might contain: "+e)})),i}var ds=(e,t)=>{var s,r,n,o={payloadSizeLimitBytes:ns.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...ns.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...ns.payloadHostDenyList]},a=!1!==e.session_recording.recordHeaders&&t.recordHeaders,l=!1!==e.session_recording.recordBody&&t.recordBody,u=!1!==e.capture_performance&&t.recordPerformance,c=(s=o,n=Math.min(1e6,null!==(r=s.payloadSizeLimitBytes)&&void 0!==r?r:1e6),e=>(null!=e&&e.requestBody&&(e.requestBody=us(e.requestBody,e.requestHeaders,n,"Request")),null!=e&&e.responseBody&&(e.responseBody=us(e.responseBody,e.responseHeaders,n,"Response")),e)),d=t=>{return c(((e,t)=>{var i,s=_i(e.name),r=0===t.indexOf("http")?null==(i=_i(t))?void 0:i.pathname:t;"/"===r&&(r="");var n=null==s?void 0:s.pathname.replace(r||"","");if(!(s&&n&&ls.some((e=>0===n.indexOf(e)))))return e})((s=(i=t).requestHeaders,O(s)||Pe(Object.keys(null!=s?s:{}),(e=>{os.includes(e.toLowerCase())&&(s[e]=rs)})),i),e.api_host));var i,s},_=R(e.session_recording.maskNetworkRequestFn);return _&&R(e.session_recording.maskCapturedNetworkRequestFn)&&xe.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),_&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{var s=e.session_recording.maskNetworkRequestFn({url:t.name});return i({},t,{name:null==s?void 0:s.url})}),o.maskRequestFn=R(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,s=d(t);return s&&null!==(i=null==e.session_recording.maskCapturedNetworkRequestFn?void 0:e.session_recording.maskCapturedNetworkRequestFn(s))&&void 0!==i?i:void 0}:e=>function(e){if(!T(e))return e.requestBody=cs(e.requestBody,"Request"),e.responseBody=cs(e.responseBody,"Response"),e}(d(e)),i({},ns,o,{recordHeaders:a,recordBody:l,recordPerformance:u,recordInitialRequests:u})};class _s{constructor(e,t){var i,s;void 0===t&&(t={}),this._loggedTracker={},this._onNodeRateLimited=e=>{if(!this._loggedTracker[e]){var t,i;this._loggedTracker[e]=!0;var s=this._getNode(e);null==(t=(i=this._options).onBlockedNode)||t.call(i,e,s)}},this._getNodeOrRelevantParent=e=>{var t=this._getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){var i=t.closest("svg");if(i)return[this._rrweb.mirror.getId(i),i]}return[e,t]},this._getNode=e=>this._rrweb.mirror.getNode(e),this._numberOfChanges=e=>{var t,i,s,r,n,o,a,l;return(null!==(t=null==(i=e.removes)?void 0:i.length)&&void 0!==t?t:0)+(null!==(s=null==(r=e.attributes)?void 0:r.length)&&void 0!==s?s:0)+(null!==(n=null==(o=e.texts)?void 0:o.length)&&void 0!==n?n:0)+(null!==(a=null==(l=e.adds)?void 0:l.length)&&void 0!==a?a:0)},this.throttleMutations=e=>{if(3!==e.type||0!==e.data.source)return e;var t=e.data,i=this._numberOfChanges(t);t.attributes&&(t.attributes=t.attributes.filter((e=>{var[t]=this._getNodeOrRelevantParent(e.id);return!this._rateLimiter.consumeRateLimit(t)&&e})));var s=this._numberOfChanges(t);return 0!==s||i===s?e:void 0},this._rrweb=e,this._options=t,this._rateLimiter=new G({bucketSize:null!==(i=this._options.bucketSize)&&void 0!==i?i:100,refillRate:null!==(s=this._options.refillRate)&&void 0!==s?s:10,refillInterval:1e3,_onBucketRateLimited:this._onNodeRateLimited,_logger:xe})}}var hs=Uint8Array,ps=Uint16Array,gs=Uint32Array,vs=new hs([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]),fs=new hs([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]),ms=new hs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ys=function(e,t){for(var i=new ps(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var r=new gs(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]},bs=ys(vs,2),ws=bs[0],Ss=bs[1];ws[28]=258,Ss[258]=28;for(var Es=ys(fs,0)[1],ks=new ps(32768),xs=0;xs<32768;++xs){var Is=(43690&xs)>>>1|(21845&xs)<<1;Is=(61680&(Is=(52428&Is)>>>2|(13107&Is)<<2))>>>4|(3855&Is)<<4,ks[xs]=((65280&Is)>>>8|(255&Is)<<8)>>>1}var Rs=function(e,t,i){for(var s=e.length,r=0,n=new ps(t);r<s;++r)++n[e[r]-1];var o,a=new ps(t);for(r=0;r<t;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new ps(1<<t);var l=15-t;for(r=0;r<s;++r)if(e[r])for(var u=r<<4|e[r],c=t-e[r],d=a[e[r]-1]++<<c,_=d|(1<<c)-1;d<=_;++d)o[ks[d]>>>l]=u}else for(o=new ps(s),r=0;r<s;++r)o[r]=ks[a[e[r]-1]++]>>>15-e[r];return o},Cs=new hs(288);for(xs=0;xs<144;++xs)Cs[xs]=8;for(xs=144;xs<256;++xs)Cs[xs]=9;for(xs=256;xs<280;++xs)Cs[xs]=7;for(xs=280;xs<288;++xs)Cs[xs]=8;var Ps=new hs(32);for(xs=0;xs<32;++xs)Ps[xs]=5;var Ts=Rs(Cs,9,0),Fs=Rs(Ps,5,0),Ms=function(e){return(e/8>>0)+(7&e&&1)},$s=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof ps?ps:e instanceof gs?gs:hs)(i-t);return s.set(e.subarray(t,i)),s},Ls=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},Os=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},As=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 hs(0),0];if(1==r){var o=new hs(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],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[u].f<i[d].f?u++:d++],l=i[u!=c&&i[u].f<i[d].f?u++:d++],i[c++]={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 ps(_+1),p=Ds(i[c-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 hs(h),p]},Ds=function(e,t,i){return-1==e.s?Math.max(Ds(e.l,t,i+1),Ds(e.r,t,i+1)):t[e.s]=i},Ns=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new ps(++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]},qs=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Bs=function(e,t,i){var s=i.length,r=Ms(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)},Hs=function(e,t,i,s,r,n,o,a,l,u,c){Ls(t,c++,i),++r[256];for(var d=As(r,15),_=d[0],h=d[1],p=As(n,15),g=p[0],v=p[1],f=Ns(_),m=f[0],y=f[1],b=Ns(g),w=b[0],S=b[1],E=new ps(19),k=0;k<m.length;++k)E[31&m[k]]++;for(k=0;k<w.length;++k)E[31&w[k]]++;for(var x=As(E,7),I=x[0],R=x[1],C=19;C>4&&!I[ms[C-1]];--C);var P,T,F,M,L=u+5<<3,O=qs(r,Cs)+qs(n,Ps)+o,A=qs(r,_)+qs(n,g)+o+14+3*C+qs(E,I)+(2*E[16]+3*E[17]+7*E[18]);if(L<=O&&L<=A)return Bs(t,c,e.subarray(l,l+u));if(Ls(t,c,1+(A<O)),c+=2,A<O){P=Rs(_,h,0),T=_,F=Rs(g,v,0),M=g;var D=Rs(I,R,0);Ls(t,c,y-257),Ls(t,c+5,S-1),Ls(t,c+10,C-4),c+=14;for(k=0;k<C;++k)Ls(t,c+3*k,I[ms[k]]);c+=3*C;for(var N=[m,w],q=0;q<2;++q){var B=N[q];for(k=0;k<B.length;++k){var H=31&B[k];Ls(t,c,D[H]),c+=I[H],H>15&&(Ls(t,c,B[k]>>>5&127),c+=B[k]>>>12)}}}else P=Ts,T=Cs,F=Fs,M=Ps;for(k=0;k<a;++k)if(s[k]>255){H=s[k]>>>18&31;Os(t,c,P[H+257]),c+=T[H+257],H>7&&(Ls(t,c,s[k]>>>23&31),c+=vs[H]);var z=31&s[k];Os(t,c,F[z]),c+=M[z],z>3&&(Os(t,c,s[k]>>>5&8191),c+=fs[z])}else Os(t,c,P[s[k]]),c+=T[s[k]];return Os(t,c,P[256]),c+T[256]},zs=new gs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Us=function(){for(var e=new gs(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),js=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=Us[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}},Ws=function(e,t,i,s,r){return function(e,t,i,s,r,n){var o=e.length,a=new hs(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),u=0;if(!t||o<8)for(var c=0;c<=o;c+=65535){var d=c+65535;d<o?u=Bs(l,u,e.subarray(c,d)):(l[c]=n,u=Bs(l,u,e.subarray(c,o)))}else{for(var _=zs[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new ps(32768),f=new ps(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 gs(25e3),S=new ps(288),E=new ps(32),k=0,x=0,I=(c=0,0),R=0,C=0;c<o;++c){var P=b(c),T=32767&c,F=f[P];if(v[T]=F,f[P]=T,R<=c){var M=o-c;if((k>7e3||I>24576)&&M>423){u=Hs(e,l,0,w,S,E,x,I,C,c-C,u),I=k=x=0,C=c;for(var L=0;L<286;++L)S[L]=0;for(L=0;L<30;++L)E[L]=0}var O=2,A=0,D=p,N=T-F&32767;if(M>2&&P==b(c-N))for(var q=Math.min(h,M)-1,B=Math.min(32767,c),H=Math.min(258,M);N<=B&&--D&&T!=F;){if(e[c+O]==e[c+O-N]){for(var z=0;z<H&&e[c+z]==e[c+z-N];++z);if(z>O){if(O=z,A=N,z>q)break;var U=Math.min(N,z-2),j=0;for(L=0;L<U;++L){var W=c-N+L+32768&32767,V=W-v[W]+32768&32767;V>j&&(j=V,F=W)}}}N+=(T=F)-(F=v[T])+32768&32767}if(A){w[I++]=268435456|Ss[O]<<18|Es[A];var G=31&Ss[O],Y=31&Es[A];x+=vs[G]+fs[Y],++S[257+G],++E[Y],R=c+O,++k}else w[I++]=e[c],++S[e[c]]}}u=Hs(e,l,n,w,S,E,x,I,C,c-C,u)}return $s(a,0,s+Ms(u)+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)},Vs=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},Gs=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&&Vs(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)}},Ys=function(e){return 10+(e.filename&&e.filename.length+1||0)};function Js(e,t){void 0===t&&(t={});var i=js(),s=e.length;i.p(e);var r=Ws(e,t,Ys(t),8),n=r.length;return Gs(r,t),Vs(r,n-8,i.d()),Vs(r,n-4,s),r}function Ks(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new hs(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 hs(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 $s(s,0,r)}function Xs(e,t){return function(e){for(var t=0,i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t)}(e)%100<V(100*t,0,100,xe)}var Qs="disabled",Zs="sampled",er="active",tr="buffering",ir="paused",sr="trigger",rr=sr+"_activated",nr=sr+"_pending",or=sr+"_"+Qs;function ar(e,t){return t.some((t=>"regex"===t.matching&&new RegExp(t.url).test(e)))}class lr{constructor(e){this._matchers=e}triggerStatus(e){var t=this._matchers.map((t=>t.triggerStatus(e)));return t.includes(rr)?rr:t.includes(nr)?nr:or}stop(){this._matchers.forEach((e=>e.stop()))}}class ur{constructor(e){this._matchers=e}triggerStatus(e){var t=new Set;for(var i of this._matchers)t.add(i.triggerStatus(e));switch(t.delete(or),t.size){case 0:return or;case 1:return Array.from(t)[0];default:return nr}}stop(){this._matchers.forEach((e=>e.stop()))}}class cr{triggerStatus(){return nr}stop(){}}var dr=e=>"sessionRecording"in e;class _r{constructor(e){this._urlTriggers=[],this._urlBlocklist=[],this.urlBlocked=!1,this._instance=e}onConfig(e){var t,i;this._urlTriggers=(dr(e)?C(e.sessionRecording)?null==(t=e.sessionRecording)?void 0:t.urlTriggers:[]:null==e?void 0:e.urlTriggers)||[],this._urlBlocklist=(dr(e)?C(e.sessionRecording)?null==(i=e.sessionRecording)?void 0:i.urlBlocklist:[]:null==e?void 0:e.urlBlocklist)||[]}onRemoteConfig(e){this.onConfig(e)}_urlTriggerStatus(e){var t;return 0===this._urlTriggers.length?or:(null==(t=this._instance)?void 0:t.get_property(ut))===e?rr:nr}triggerStatus(e){var t=this._urlTriggerStatus(e),i=t===rr?rr:t===nr?nr:or;return this._instance.register_for_session({$sdk_debug_replay_url_trigger_status:i}),i}checkUrlTriggerConditions(e,t,i){if(void 0!==r&&r.location.href){var s=r.location.href,n=this.urlBlocked,o=ar(s,this._urlBlocklist);n&&o||(o&&!n?e():!o&&n&&t(),ar(s,this._urlTriggers)&&i("url"))}}stop(){}}class hr{constructor(e){this.linkedFlag=null,this.linkedFlagSeen=!1,this._flagListenerCleanup=()=>{},this._instance=e}triggerStatus(){var e=nr;return O(this.linkedFlag)&&(e=or),this.linkedFlagSeen&&(e=rr),this._instance.register_for_session({$sdk_debug_replay_linked_flag_trigger_status:e}),e}onConfig(e,t){var i;if(this.linkedFlag=(dr(e)?C(e.sessionRecording)?null==(i=e.sessionRecording)?void 0:i.linkedFlag:null:null==e?void 0:e.linkedFlag)||null,!O(this.linkedFlag)&&!this.linkedFlagSeen){var s=F(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,r=F(this.linkedFlag)?null:this.linkedFlag.variant;this._flagListenerCleanup=this._instance.onFeatureFlags(((e,i)=>{var n=!1;if(C(i)&&s in i){var o=i[s];n=D(o)?!0===o:r?o===r:!!o}this.linkedFlagSeen=n,n&&t(s,r)}))}}onRemoteConfig(e,t){this.onConfig(e,t)}stop(){this._flagListenerCleanup()}}class pr{constructor(e){this._eventTriggers=[],this._instance=e}onConfig(e){var t;this._eventTriggers=(dr(e)?C(e.sessionRecording)?null==(t=e.sessionRecording)?void 0:t.eventTriggers:[]:null==e?void 0:e.eventTriggers)||[]}onRemoteConfig(e){this.onConfig(e)}_eventTriggerStatus(e){var t;return 0===this._eventTriggers.length?or:(null==(t=this._instance)?void 0:t.get_property(ct))===e?rr:nr}triggerStatus(e){var t=this._eventTriggerStatus(e),i=t===rr?rr:t===nr?nr:or;return this._instance.register_for_session({$sdk_debug_replay_event_trigger_status:i}),i}stop(){}}function gr(e){return e.isRecordingEnabled?tr:Qs}function vr(e){if(!e.receivedFlags)return tr;if(!e.isRecordingEnabled)return Qs;if(e.urlTriggerMatching.urlBlocked)return ir;var t=!0===e.isSampled,i=new lr([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId);return t?Zs:i===rr?er:i===nr?tr:!1===e.isSampled?Qs:er}function fr(e){if(!e.receivedFlags)return tr;if(!e.isRecordingEnabled)return Qs;if(e.urlTriggerMatching.urlBlocked)return ir;var t=new ur([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId),i=t!==or,s=D(e.isSampled);return i&&t===nr?tr:i&&t===or||s&&!e.isSampled?Qs:!0===e.isSampled?Zs:er}var mr="[SessionRecording]",yr=Ie(mr);function br(){var e;return null==v||null==(e=v.__PosthogExtensions__)||null==(e=e.rrweb)?void 0:e.record}var wr=3e5,Sr=[is.MouseMove,is.MouseInteraction,is.Scroll,is.ViewportResize,is.Input,is.TouchMove,is.MediaInteraction,is.Drag],Er=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function kr(e){return function(e,t){for(var i="",s=0;s<e.length;){var r=e[s++];i+=String.fromCharCode(r)}return i}(Js(Ks(JSON.stringify(e))))}function xr(e){return e.type===ts.Custom&&"sessionIdle"===e.data.tag}class Ir{get sessionId(){return this._sessionId}get _sessionIdleThresholdMilliseconds(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this._captureStarted}get _sessionManager(){if(!this._instance.sessionManager)throw new Error(mr+" must be started with a valid sessionManager.");return this._instance.sessionManager}get _fullSnapshotIntervalMillis(){var e,t;return this._triggerMatching.triggerStatus(this.sessionId)===nr?6e4:null!==(e=null==(t=this._instance.config.session_recording)?void 0:t.full_snapshot_interval_millis)&&void 0!==e?e:wr}get _isSampled(){var e=this._instance.get_property(lt);return D(e)?e:null}get _sessionDuration(){var e,t,i=null==(e=this._buffer)?void 0:e.data[(null==(t=this._buffer)?void 0:t.data.length)-1],{sessionStartTimestamp:s}=this._sessionManager.checkAndGetSessionAndWindowId(!0);return i?i.timestamp-s:null}get _isRecordingEnabled(){var e=!!this._instance.get_property(Ze),t=!this._instance.config.disable_session_recording;return r&&e&&t}get _isConsoleLogCaptureEnabled(){var e=!!this._instance.get_property(et),t=this._instance.config.enable_recording_console_log;return null!=t?t:e}get _canvasRecording(){var e,t,i,s,r,n,o=this._instance.config.session_recording.captureCanvas,a=this._instance.get_property(st),l=null!==(e=null!==(t=null==o?void 0:o.recordCanvas)&&void 0!==t?t:null==a?void 0:a.enabled)&&void 0!==e&&e,u=null!==(i=null!==(s=null==o?void 0:o.canvasFps)&&void 0!==s?s:null==a?void 0:a.fps)&&void 0!==i?i:4,c=null!==(r=null!==(n=null==o?void 0:o.canvasQuality)&&void 0!==n?n:null==a?void 0:a.quality)&&void 0!==r?r:.4;if("string"==typeof c){var d=parseFloat(c);c=isNaN(d)?.4:d}return{enabled:l,fps:V(u,0,12,yr.createLogger("canvas recording fps"),4),quality:V(c,0,1,yr.createLogger("canvas recording quality"),.4)}}get _networkPayloadCapture(){var e,t,i=this._instance.get_property(tt),s={recordHeaders:null==(e=this._instance.config.session_recording)?void 0:e.recordHeaders,recordBody:null==(t=this._instance.config.session_recording)?void 0:t.recordBody},r=(null==s?void 0:s.recordHeaders)||(null==i?void 0:i.recordHeaders),n=(null==s?void 0:s.recordBody)||(null==i?void 0:i.recordBody),o=C(this._instance.config.capture_performance)?this._instance.config.capture_performance.network_timing:this._instance.config.capture_performance,a=!!(D(o)?o:null==i?void 0:i.capturePerformance);return r||n||a?{recordHeaders:r,recordBody:n,recordPerformance:a}:void 0}get _masking(){var e,t,i,s,r,n,o=this._instance.get_property(it),a={maskAllInputs:null==(e=this._instance.config.session_recording)?void 0:e.maskAllInputs,maskTextSelector:null==(t=this._instance.config.session_recording)?void 0:t.maskTextSelector,blockSelector:null==(i=this._instance.config.session_recording)?void 0:i.blockSelector},l=null!==(s=null==a?void 0:a.maskAllInputs)&&void 0!==s?s:null==o?void 0:o.maskAllInputs,u=null!==(r=null==a?void 0:a.maskTextSelector)&&void 0!==r?r:null==o?void 0:o.maskTextSelector,c=null!==(n=null==a?void 0:a.blockSelector)&&void 0!==n?n:null==o?void 0:o.blockSelector;return T(l)&&T(u)&&T(c)?void 0:{maskAllInputs:null==l||l,maskTextSelector:u,blockSelector:c}}get _sampleRate(){var e=this._instance.get_property(rt);return A(e)?e:null}get _minimumDuration(){var e=this._instance.get_property(nt);return A(e)?e:null}get status(){return this._receivedFlags?this._statusMatcher({receivedFlags:this._receivedFlags,isRecordingEnabled:this._isRecordingEnabled,isSampled:this._isSampled,urlTriggerMatching:this._urlTriggerMatching,eventTriggerMatching:this._eventTriggerMatching,linkedFlagMatching:this._linkedFlagMatching,sessionId:this.sessionId}):tr}constructor(e){if(this._statusMatcher=gr,this._receivedFlags=!1,this._queuedRRWebEvents=[],this._isIdle="unknown",this._lastActivityTimestamp=Date.now(),this._triggerMatching=new cr,this._removePageViewCaptureHook=void 0,this._onSessionIdListener=void 0,this._persistFlagsOnSessionListener=void 0,this._samplingSessionListener=void 0,this._removeEventTriggerCaptureHook=void 0,this._forceAllowLocalhostNetworkCapture=!1,this._onBeforeUnload=()=>{this._flushBuffer()},this._onOffline=()=>{this.tryAddCustomEvent("browser offline",{})},this._onOnline=()=>{this.tryAddCustomEvent("browser online",{})},this._onVisibilityChange=()=>{if(null!=c&&c.visibilityState){var e="window "+c.visibilityState;this.tryAddCustomEvent(e,{})}},this._instance=e,this._captureStarted=!1,this._endpoint="/s/",this._stopRrweb=void 0,this._receivedFlags=!1,!this._instance.sessionManager)throw yr.error("started without valid sessionManager"),new Error(mr+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(mr+' cannot be used with cookieless_mode="always"');this._linkedFlagMatching=new hr(this._instance),this._urlTriggerMatching=new _r(this._instance),this._eventTriggerMatching=new pr(this._instance);var{sessionId:t,windowId:i}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=t,this._windowId=i,this._buffer=this._clearBuffer(),this._sessionIdleThresholdMilliseconds>=this._sessionManager.sessionTimeoutMs&&yr.warn("session_idle_threshold_ms ("+this._sessionIdleThresholdMilliseconds+") is greater than the session timeout ("+this._sessionManager.sessionTimeoutMs+"). Session will never be detected as idle")}startIfEnabledOrStop(e){this._isRecordingEnabled?(this._startCapture(e),Be(r,"beforeunload",this._onBeforeUnload),Be(r,"offline",this._onOffline),Be(r,"online",this._onOnline),Be(r,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),O(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this._instance.on("eventCaptured",(e=>{try{if("$pageview"===e.event){var t=null!=e&&e.properties.$current_url?this._maskUrl(null==e?void 0:e.properties.$current_url):"";if(!t)return;this.tryAddCustomEvent("$pageview",{href:t})}}catch(e){yr.error("Could not add $pageview to rrweb session",e)}}))),this._onSessionIdListener||(this._onSessionIdListener=this._sessionManager.onSessionId(((e,t,i)=>{var s,r;i&&(this.tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),null==(s=this._instance)||null==(s=s.persistence)||s.unregister(ct),null==(r=this._instance)||null==(r=r.persistence)||r.unregister(ut))})))):this.stopRecording()}stopRecording(){var e,t,i,s;this._captureStarted&&this._stopRrweb&&(this._stopRrweb(),this._stopRrweb=void 0,this._captureStarted=!1,null==r||r.removeEventListener("beforeunload",this._onBeforeUnload),null==r||r.removeEventListener("offline",this._onOffline),null==r||r.removeEventListener("online",this._onOnline),null==r||r.removeEventListener("visibilitychange",this._onVisibilityChange),this._clearBuffer(),clearInterval(this._fullSnapshotTimer),null==(e=this._removePageViewCaptureHook)||e.call(this),this._removePageViewCaptureHook=void 0,null==(t=this._removeEventTriggerCaptureHook)||t.call(this),this._removeEventTriggerCaptureHook=void 0,null==(i=this._onSessionIdListener)||i.call(this),this._onSessionIdListener=void 0,null==(s=this._samplingSessionListener)||s.call(this),this._samplingSessionListener=void 0,this._eventTriggerMatching.stop(),this._urlTriggerMatching.stop(),this._linkedFlagMatching.stop(),yr.info("stopped"))}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(lt)}_makeSamplingDecision(e){var t,i=this._sessionId!==e,s=this._sampleRate;if(A(s)){var r=this._isSampled,n=i||!D(r),o=n?Xs(e,s):r;n&&(o?this._reportStarted(Zs):yr.warn("Sample rate ("+s+") has determined that this sessionId ("+e+") will not be sent to the server."),this.tryAddCustomEvent("samplingDecisionMade",{sampleRate:s,isSampled:o})),null==(t=this._instance.persistence)||t.register({[lt]:o})}else this._resetSampling()}onRemoteConfig(e){if(this.tryAddCustomEvent("$remote_config_received",e),this._receivedFlags=!0,this._persistRemoteConfig(e),e.sessionRecording){var t,i,s,r;if(null!=(t=e.sessionRecording)&&t.endpoint)this._endpoint=null==(r=e.sessionRecording)?void 0:r.endpoint;this._setupSampling(),"any"===(null==(i=e.sessionRecording)?void 0:i.triggerMatchType)?(this._statusMatcher=vr,this._triggerMatching=new lr([this._eventTriggerMatching,this._urlTriggerMatching])):(this._statusMatcher=fr,this._triggerMatching=new ur([this._eventTriggerMatching,this._urlTriggerMatching])),this._instance.register_for_session({$sdk_debug_replay_remote_trigger_matching_config:null==(s=e.sessionRecording)?void 0:s.triggerMatchType}),this._urlTriggerMatching.onConfig(e),this._eventTriggerMatching.onConfig(e),this._linkedFlagMatching.onConfig(e,((e,t)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:t})}))}this.startIfEnabledOrStop()}_setupSampling(){A(this._sampleRate)&&O(this._samplingSessionListener)&&(this._samplingSessionListener=this._sessionManager.onSessionId((e=>{this._makeSamplingDecision(e)})))}_persistRemoteConfig(e){if(this._instance.persistence){var t,s=this._instance.persistence,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=null==t?void 0:t.sampleRate,n=O(r)?null:parseFloat(r);O(n)&&this._resetSampling();var o=null==t?void 0:t.minimumDurationMilliseconds;s.register({[Ze]:!!e.sessionRecording,[et]:null==t?void 0:t.consoleLogRecordingEnabled,[tt]:i({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),[it]:null==t?void 0:t.masking,[st]:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},[rt]:n,[nt]:T(o)?null:o,[ot]:null==t?void 0:t.scriptConfig})};r(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=this._sessionManager.onSessionId(r)}}log(e,t){var i;void 0===t&&(t="log"),null==(i=this._instance.sessionRecording)||i.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:t,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}_startCapture(e){if(!T(Object.assign)&&!T(Array.from)&&!(this._captureStarted||this._instance.config.disable_session_recording||this._instance.consent.isOptedOut())){var t;if(this._captureStarted=!0,this._sessionManager.checkAndGetSessionAndWindowId(),br())this._onScriptLoaded();else null==(t=v.__PosthogExtensions__)||null==t.loadExternalDependency||t.loadExternalDependency(this._instance,this._scriptName,(e=>{if(e)return yr.error("could not load recorder",e);this._onScriptLoaded()}));yr.info("starting"),this.status===er&&this._reportStarted(e||"recording_initialized")}}get _scriptName(){var e;return(null==(e=this._instance)||null==(e=e.persistence)||null==(e=e.get_property(ot))?void 0:e.script)||"recorder"}_isInteractiveEvent(e){var t;return 3===e.type&&-1!==Sr.indexOf(null==(t=e.data)?void 0:t.source)}_updateWindowAndSessionIds(e){var t=this._isInteractiveEvent(e);t||this._isIdle||e.timestamp-this._lastActivityTimestamp>this._sessionIdleThresholdMilliseconds&&(this._isIdle=!0,clearInterval(this._fullSnapshotTimer),this.tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this._sessionIdleThresholdMilliseconds,bufferLength:this._buffer.data.length,bufferSize:this._buffer.size}),this._flushBuffer());var i=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this._isIdle)){var s="unknown"===this._isIdle;this._isIdle=!1,s||(this.tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)}if(!this._isIdle){var{windowId:r,sessionId:n}=this._sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),o=this._sessionId!==n,a=this._windowId!==r;this._windowId=r,this._sessionId=n,o||a?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):i&&this._scheduleFullSnapshot()}}_tryRRWebMethod(e){try{return e.rrwebMethod(),!0}catch(t){return this._queuedRRWebEvents.length<10?this._queuedRRWebEvents.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt++,rrwebMethod:e.rrwebMethod}):yr.warn("could not emit queued rrweb event.",t,e),!1}}tryAddCustomEvent(e,t){return this._tryRRWebMethod(Er((()=>br().addCustomEvent(e,t))))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(Er((()=>br().takeFullSnapshot())))}_onScriptLoaded(){var e,t,s,r,n={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},o=this._instance.config.session_recording;for(var[a,l]of Object.entries(o||{}))a in n&&("maskInputOptions"===a?n.maskInputOptions=i({password:!0},l):n[a]=l);(this._canvasRecording&&this._canvasRecording.enabled&&(n.recordCanvas=!0,n.sampling={canvas:this._canvasRecording.fps},n.dataURLOptions={type:"image/webp",quality:this._canvasRecording.quality}),this._masking)&&(n.maskAllInputs=null===(t=this._masking.maskAllInputs)||void 0===t||t,n.maskTextSelector=null!==(s=this._masking.maskTextSelector)&&void 0!==s?s:void 0,n.blockSelector=null!==(r=this._masking.blockSelector)&&void 0!==r?r:void 0);var u=br();if(u){this._mutationThrottler=null!==(e=this._mutationThrottler)&&void 0!==e?e:new _s(u,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(e,t)=>{var i="Too many mutations on node '"+e+"'. Rate limiting. This could be due to SVG animations or something similar";yr.info(i,{node:t}),this.log(mr+" "+i,"warn")}});var c=this._gatherRRWebPlugins();this._stopRrweb=u(i({emit:e=>{this.onRRwebEmit(e)},plugins:c},n)),this._lastActivityTimestamp=Date.now(),this._isIdle=D(this._isIdle)?this._isIdle:"unknown",this.tryAddCustomEvent("$session_options",{sessionRecordingOptions:n,activePlugins:c.map((e=>null==e?void 0:e.name))}),this.tryAddCustomEvent("$posthog_config",{config:this._instance.config})}else yr.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!0!==this._isIdle){var e=this._fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval((()=>{this._tryTakeFullSnapshot()}),e))}}_gatherRRWebPlugins(){var e,t,i=[],s=null==(e=v.__PosthogExtensions__)||null==(e=e.rrwebPlugins)?void 0:e.getRecordConsolePlugin;s&&this._isConsoleLogCaptureEnabled&&i.push(s());var r=null==(t=v.__PosthogExtensions__)||null==(t=t.rrwebPlugins)?void 0:t.getRecordNetworkPlugin;this._networkPayloadCapture&&R(r)&&(!di.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?i.push(r(ds(this._instance.config,this._networkPayloadCapture))):yr.info("NetworkCapture not started because we are on localhost."));return i}onRRwebEmit(e){var t;if(this._processQueuedEvents(),e&&C(e)){if(e.type===ts.Meta){var s=this._maskUrl(e.data.href);if(this._lastHref=s,!s)return;e.data.href=s}else this._pageViewFallBack();if(this._urlTriggerMatching.checkUrlTriggerConditions((()=>this._pauseRecording()),(()=>this._resumeRecording()),(e=>this._activateTrigger(e))),!this._urlTriggerMatching.urlBlocked||(r=e).type===ts.Custom&&"recording paused"===r.data.tag){var r;e.type===ts.FullSnapshot&&this._scheduleFullSnapshot(),e.type===ts.FullSnapshot&&this._receivedFlags&&this._triggerMatching.triggerStatus(this.sessionId)===nr&&this._clearBufferBeforeMostRecentMeta();var n=this._mutationThrottler?this._mutationThrottler.throttleMutations(e):e;if(n){var o=function(e){var t=e;if(t&&C(t)&&6===t.type&&C(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));for(var i=[],s=0;s<t.data.payload.payload.length;s++)t.data.payload.payload[s]&&t.data.payload.payload[s].length>2e3?i.push(t.data.payload.payload[s].slice(0,2e3)+"...[truncated]"):i.push(t.data.payload.payload[s]);return t.data.payload.payload=i,e}return e}(n);if(this._updateWindowAndSessionIds(o),!0!==this._isIdle||xr(o)){if(xr(o)){var a=o.data.payload;if(a){var l=a.lastActivityTimestamp,u=a.threshold;o.timestamp=l+u}}var c=null===(t=this._instance.config.session_recording.compress_events)||void 0===t||t?function(e){try{if(e.type===ts.FullSnapshot)return i({},e,{data:kr(e.data),cv:"2024-10"});if(e.type===ts.IncrementalSnapshot&&e.data.source===is.Mutation)return i({},e,{cv:"2024-10",data:i({},e.data,{texts:kr(e.data.texts),attributes:kr(e.data.attributes),removes:kr(e.data.removes),adds:kr(e.data.adds)})});if(e.type===ts.IncrementalSnapshot&&e.data.source===is.StyleSheetRule)return i({},e,{cv:"2024-10",data:i({},e.data,{adds:e.data.adds?kr(e.data.adds):void 0,removes:e.data.removes?kr(e.data.removes):void 0})})}catch(e){yr.error("could not compress event - will use uncompressed event",e)}return e}(o):o,d={$snapshot_bytes:Zi(c),$snapshot_data:c,$session_id:this._sessionId,$window_id:this._windowId};this.status!==Qs?this._captureSnapshotBuffered(d):this._clearBuffer()}}}}}_pageViewFallBack(){if(!this._instance.config.capture_pageview&&r){var e=this._maskUrl(r.location.href);this._lastHref!==e&&(this.tryAddCustomEvent("$url_changed",{href:e}),this._lastHref=e)}}_processQueuedEvents(){if(this._queuedRRWebEvents.length){var e=[...this._queuedRRWebEvents];this._queuedRRWebEvents=[],e.forEach((e=>{Date.now()-e.enqueuedAt<=2e3&&this._tryRRWebMethod(e)}))}}_maskUrl(e){var t=this._instance.config.session_recording;if(t.maskNetworkRequestFn){var i,s={url:e};return null==(i=s=t.maskNetworkRequestFn(s))?void 0:i.url}return e}_clearBufferBeforeMostRecentMeta(){if(!this._buffer||0===this._buffer.data.length)return this._clearBuffer();for(var e=-1,t=this._buffer.data.length-1;t>=0;t--)if(this._buffer.data[t].type===ts.Meta){e=t;break}return e>=0?(this._buffer.data=this._buffer.data.slice(e),this._buffer.size=this._buffer.data.reduce(((e,t)=>e+Zi(t)),0),this._buffer):this._clearBuffer()}_clearBuffer(){return this._buffer={size:0,data:[],sessionId:this._sessionId,windowId:this._windowId},this._buffer}_flushBuffer(){this._flushBufferTimer&&(clearTimeout(this._flushBufferTimer),this._flushBufferTimer=void 0);var e=this._minimumDuration,t=this._sessionDuration,i=A(t)&&t>=0,s=A(e)&&i&&t<e;if(this.status===tr||this.status===ir||this.status===Qs||s)return this._flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3),this._buffer;this._buffer.data.length>0&&es(this._buffer).forEach((e=>{this._captureSnapshot({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId,$lib:"web",$lib_version:f.LIB_VERSION})}));return this._clearBuffer()}_captureSnapshotBuffered(e){var t,i=2+((null==(t=this._buffer)?void 0:t.data.length)||0);!this._isIdle&&(this._buffer.size+e.$snapshot_bytes+i>943718.4||this._buffer.sessionId!==this._sessionId)&&(this._buffer=this._flushBuffer()),this._buffer.size+=e.$snapshot_bytes,this._buffer.data.push(e.$snapshot_data),this._flushBufferTimer||this._isIdle||(this._flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3))}_captureSnapshot(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}_activateTrigger(e){var t;this._triggerMatching.triggerStatus(this.sessionId)===nr&&(null==(t=this._instance)||null==(t=t.persistence)||t.register({["url"===e?ut:ct]:this._sessionId}),this._flushBuffer(),this._reportStarted(e+"_trigger_matched"))}_pauseRecording(){this._urlTriggerMatching.urlBlocked||(this._urlTriggerMatching.urlBlocked=!0,clearInterval(this._fullSnapshotTimer),yr.info("recording paused due to URL blocker"),this.tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){this._urlTriggerMatching.urlBlocked&&(this._urlTriggerMatching.urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this.tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),yr.info("recording resumed"))}_addEventTriggerListener(){0!==this._eventTriggerMatching._eventTriggers.length&&O(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this._instance.on("eventCaptured",(e=>{try{this._eventTriggerMatching._eventTriggers.includes(e.event)&&this._activateTrigger("event")}catch(e){yr.error("Could not activate event trigger",e)}})))}overrideLinkedFlag(){this._linkedFlagMatching.linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null==(e=this._instance.persistence)||e.register({[lt]:!0}),this._tryTakeFullSnapshot(),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e)}_reportStarted(e,t){this._instance.register_for_session({$session_recording_start_reason:e}),yr.info(e.replace("_"," "),t),y(["recording_initialized","session_id_changed"],e)||this.tryAddCustomEvent(e,t)}get sdkDebugProperties(){var{sessionStartTimestamp:e}=this._sessionManager.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this._buffer.data.length,$sdk_debug_replay_internal_buffer_size:this._buffer.size,$sdk_debug_current_session_duration:this._sessionDuration,$sdk_debug_session_start:e}}}var Rr=Ie("[SegmentIntegration]");function Cr(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()||Pi();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(yt,"identified")),t()},r=i.user();"then"in r&&R(r.then)?r.then((e=>s(e))):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||Rr.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()||(Rr.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Rr.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 Pr="posthog-js";function Tr(e,t){var{organization:s,projectId:r,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,u,c,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==(u=p[0])?void 0:u.value)||t.message,$exception_type:null==(c=p[0])?void 0:c.type,$exception_personURL:h,$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 Fr{constructor(e,t,i,s,r,n){this.name=Pr,this.setupOnce=function(o){o(Tr(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}}var Mr=null!=r&&r.location?vi(r.location.hash,"__posthog")||vi(location.hash,"state"):null,$r="_postHogToolbarParams",Lr=Ie("[Toolbar]"),Or=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Or||{});class Ar{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:Or.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||!c)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=Mr||vi(e.hash,"__posthog")||vi(e.hash,"state"),o=n?$e((()=>JSON.parse(atob(decodeURIComponent(n)))))||$e((()=>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($r)||"{}")).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;!O(t)&&R(t)?t(e,this.instance):Lr.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==c||!c.getElementById(It));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($r,JSON.stringify(i({},n,{source:void 0}))),this._getToolbarState()===Or.LOADED)this._callLoadToolbar(n);else if(this._getToolbarState()===Or.UNINITIALIZED){var o;this._setToolbarState(Or.LOADING),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Lr.error("[Toolbar] Failed to load",e),void this._setToolbarState(Or.UNINITIALIZED);this._setToolbarState(Or.LOADED),this._callLoadToolbar(n)})),Be(r,"turbolinks:load",(()=>{this._setToolbarState(Or.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 Dr=Ie("[TracingHeaders]");class Nr{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t;T(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));T(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 Dr.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 qr=Ie("[Web Vitals]"),Br=9e5;class Hr{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(T(s))qr.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(!T(r))if(O(null==e?void 0:e.name)||O(null==e?void 0:e.value))qr.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)qr.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),T(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=T(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__;T(r)||T(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):qr.error("web vitals callbacks not loaded - not starting")},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[Je]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=C(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return T(i)?(null==(t=this._instance.persistence)?void 0:t.props[Xe])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(C(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=C(this._instance.config.capture_performance)&&A(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Br;return 0<e&&e<=6e4?Br:e}get isEnabled(){var e=null==d?void 0:d.protocol;if("http:"!==e&&"https:"!==e)return qr.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=C(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:D(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return D(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(qr.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){var t=C(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=C(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Je]:t}),this._instance.persistence.register({[Xe]: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?qr.error("failed to load script",t):e()}))}_currentURL(){var e=r?r.location.href:void 0;return e||qr.error("Could not determine current URL"),e}}var zr=Ie("[Heatmaps]");function Ur(e){return C(e)&&"clientX"in e&&"clientY"in e&&A(e.clientX)&&A(e.clientY)}class jr{constructor(e){var t;this.rageclicks=new ai,this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[We])}get flushIntervalMilliseconds(){var e=5e3;return C(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 T(this.instance.config.capture_heatmaps)?T(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;zr.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this._flush.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),null==(t=this._deadClicksCapture)||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[We]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_setupListeners(){r&&c&&(Be(r,"beforeunload",this._flush.bind(this)),Be(c,"click",(e=>this._onClick(e||(null==r?void 0:r.event))),{capture:!0}),Be(c,"mousemove",(e=>this._onMouseMove(e||(null==r?void 0:r.event))),{capture:!0}),this._deadClicksCapture=new Yi(this.instance,Vi,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabled(),this._initialized=!0)}_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&&Tt(s)&&!Ft(s,"body");){if(s===i)return!1;if(y(t,null==r?void 0:r.getComputedStyle(s).position))return!0;s=zt(s)}return!1}(qt(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"),!Pt(e.target)&&Ur(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){!Pt(e.target)&&Ur(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(r){var t=r.location.href;this._buffer=this._buffer||{},this._buffer[t]||(this._buffer[t]=[]),this._buffer[t].push(e)}}_flush(){this._buffer&&!P(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Wr{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:u,maxContentY:c}=r;if(!(T(n)||T(o)||T(a)||T(l)||T(u)||T(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n<=1?1:V(o/n,0,1,xe),_=n<=1?1:V(a/n,0,1,xe),h=l<=1?1:V(u/l,0,1,xe),p=l<=1?1:V(c/l,0,1,xe);s=Te(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:u,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:c,$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 Vr=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),L(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=r+1)}return i>t&&(n+=e.substring(t,e.length)),n},Gr=!!h||!!_,Yr="text/plain",Jr=(e,t)=>{var[s,r]=e.split("?"),n=i({},t);null==r||r.split("&").forEach((e=>{var[t]=e.split("=");delete n[t]}));var o=hi(n);return s+"?"+(o=o?(r?r+"&":"")+o:r)},Kr=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Xr=e=>{var{data:t,compression:i}=e;if(t){if(i===ui.GZipJS){var s=Js(Ks(Kr(t)),{mtime:0}),r=new Blob([s],{type:Yr});return{contentType:Yr,body:r,estimatedSize:r.size}}if(i===ui.Base64){var n=function(e){var t,i,s,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,u="",c=[];if(!e)return e;e=Vr(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,c[l++]=o.charAt(t)+o.charAt(i)+o.charAt(s)+o.charAt(r)}while(a<e.length);switch(u=c.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u}(Kr(t)),o=(e=>"data="+encodeURIComponent("string"==typeof e?e:Kr(e)))(n);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Kr(t);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Qr=[];_&&Qr.push({transport:"fetch",method:e=>{var t,s,{contentType:r,body:n,estimatedSize:o}=null!==(t=Xr(e))&&void 0!==t?t:{},a=new Headers;Pe(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,u=null;if(p){var c=new p;u={signal:c.signal,timeout:setTimeout((()=>c.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=u)?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){xe.error(e)}null==e.callback||e.callback(s)})))).catch((t=>{xe.error(t),null==e.callback||e.callback({statusCode:0,text:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),h&&Qr.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=Xr(e))&&void 0!==t?t:{};Pe(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!=u&&u.sendBeacon&&Qr.push({transport:"sendBeacon",method:e=>{var t=Jr(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=Xr(e))&&void 0!==i?i:{},n="string"==typeof r?new Blob([r],{type:s}):r;u.sendBeacon(t,n)}catch(e){}}});var Zr=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 en(e,t,i){return Kr({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var tn={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=>Zr(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Zr(t,e))))),icontains:(e,t)=>t.map(sn).some((t=>e.map(sn).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(sn).every((t=>e.map(sn).every((e=>!t.includes(e)))))},sn=e=>e.toLowerCase(),rn=Ie("[Error tracking]");class nn{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new _e([new he,new Ee,new ge,new pe,new we,new be,new fe,new Se],[ne,le]),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Ge))&&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({[Ge]:this._suppressionRules,[Ye]:n})}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(Ye),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){if(this._matchesSuppressionRule(e))rn.info("Skipping exception capture because a suppression rule matched");else{if(this._captureExtensionExceptions||!this._isExtensionException(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});rn.info("Skipping exception capture because it was thrown by an extension")}}_matchesSuppressionRule(e){var t=e.$exception_list;if(!t||!I(t)||0===t.length)return!1;var i=t.reduce(((e,t)=>{var{type:i,value:s}=t;return F(i)&&i.length>0&&e.$exception_types.push(i),F(s)&&s.length>0&&e.$exception_values.push(s),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var t=e.values.map((e=>{var t,s=tn[e.operator],r=I(e.value)?e.value:[e.value],n=null!==(t=i[e.key])&&void 0!==t?t:[];return r.length>0&&s(r,n)}));return"OR"===e.type?t.some(Boolean):t.every(Boolean)}))}_isExtensionException(e){var t=e.$exception_list;return!(!t||!I(t))&&t.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://")))}}var on="Mobile",an="iOS",ln="Android",un="Tablet",cn=ln+" "+un,dn="iPad",_n="Apple",hn=_n+" Watch",pn="Safari",gn="BlackBerry",vn="Samsung",fn=vn+"Browser",mn=vn+" Internet",yn="Chrome",bn=yn+" OS",wn=yn+" "+an,Sn="Internet Explorer",En=Sn+" "+on,kn="Opera",xn=kn+" Mini",In="Edge",Rn="Microsoft "+In,Cn="Firefox",Pn=Cn+" "+an,Tn="Nintendo",Fn="PlayStation",Mn="Xbox",$n=ln+" "+on,Ln=on+" "+pn,On="Windows",An=On+" Phone",Dn="Nokia",Nn="Ouya",qn="Generic",Bn=qn+" "+on.toLowerCase(),Hn=qn+" "+un.toLowerCase(),zn="Konqueror",Un="(\\d+(\\.\\d+)?)",jn=new RegExp("Version/"+Un),Wn=new RegExp(Mn,"i"),Vn=new RegExp(Fn+" \\w+","i"),Gn=new RegExp(Tn+" \\w+","i"),Yn=new RegExp(gn+"|PlayBook|BB10","i"),Jn={"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 Kn=(e,t)=>t&&y(t,_n)||function(e){return y(e,pn)&&!y(e,yn)&&!y(e,ln)}(e),Xn=function(e,t){return t=t||"",y(e," OPR/")&&y(e,"Mini")?xn:y(e," OPR/")?kn:Yn.test(e)?gn:y(e,"IE"+on)||y(e,"WPDesktop")?En:y(e,fn)?mn:y(e,In)||y(e,"Edg/")?Rn:y(e,"FBIOS")?"Facebook "+on:y(e,"UCWEB")||y(e,"UCBrowser")?"UC Browser":y(e,"CriOS")?wn:y(e,"CrMo")||y(e,yn)?yn:y(e,ln)&&y(e,pn)?$n:y(e,"FxiOS")?Pn:y(e.toLowerCase(),zn.toLowerCase())?zn:Kn(e,t)?y(e,on)?Ln:pn:y(e,Cn)?Cn:y(e,"MSIE")||y(e,"Trident/")?Sn:y(e,"Gecko")?Cn:""},Qn={[En]:[new RegExp("rv:"+Un)],[Rn]:[new RegExp(In+"?\\/"+Un)],[yn]:[new RegExp("("+yn+"|CrMo)\\/"+Un)],[wn]:[new RegExp("CriOS\\/"+Un)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Un)],[pn]:[jn],[Ln]:[jn],[kn]:[new RegExp("(Opera|OPR)\\/"+Un)],[Cn]:[new RegExp(Cn+"\\/"+Un)],[Pn]:[new RegExp("FxiOS\\/"+Un)],[zn]:[new RegExp("Konqueror[:/]?"+Un,"i")],[gn]:[new RegExp(gn+" "+Un),jn],[$n]:[new RegExp("android\\s"+Un,"i")],[mn]:[new RegExp(fn+"\\/"+Un)],[Sn]:[new RegExp("(rv:|MSIE )"+Un)],Mozilla:[new RegExp("rv:"+Un)]},Zn=function(e,t){var i=Xn(e,t),s=Qn[i];if(T(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},eo=[[new RegExp(Mn+"; "+Mn+" (.*?)[);]","i"),e=>[Mn,e&&e[1]||""]],[new RegExp(Tn,"i"),[Tn,""]],[new RegExp(Fn,"i"),[Fn,""]],[Yn,[gn,""]],[new RegExp(On,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[An,""];if(new RegExp(on).test(t)&&!/IEMobile\b/.test(t))return[On+" "+on,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=i[1],r=Jn[s]||"";return/arm/i.test(t)&&(r="RT"),[On,r]}return[On,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[an,t.join(".")]}return[an,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=T(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ln+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ln+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[ln,t.join(".")]}return[ln,""]}],[/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/,[bn,""]],[/Linux|debian/i,["Linux",""]]],to=function(e){return Gn.test(e)?Tn:Vn.test(e)?Fn:Wn.test(e)?Mn:new RegExp(Nn,"i").test(e)?Nn:new RegExp("("+An+"|WPDesktop)","i").test(e)?An:/iPad/.test(e)?dn:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?hn:Yn.test(e)?gn:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Dn,"i").test(e)?Dn:/(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(on).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)?ln:cn:ln:new RegExp("(pda|"+on+")","i").test(e)?Bn:new RegExp(un,"i").test(e)&&!new RegExp(un+" pc","i").test(e)?Hn:""},io="https?://(.*)",so=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ro=Fe(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],so),no="<masked>",oo=["li_fat_id"];function ao(e,t,i){if(!c)return{};var s,r=t?Fe([],so,i||[]):[],n=lo(gi(c.URL,r,no),e),o=(s={},Pe(oo,(function(e){var t=Li._get(e);s[e]=t||null})),s);return Te(o,n)}function lo(e,t){var i=ro.concat(t||[]),s={};return Pe(i,(function(t){var i=pi(e,t);s[t]=i||null})),s}function uo(e){var t=function(e){return e?0===e.search(io+"google.([^/?]*)")?"google":0===e.search(io+"bing.com")?"bing":0===e.search(io+"yahoo.com")?"yahoo":0===e.search(io+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!L(t)){s.$search_engine=t;var r=c?pi(c.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function co(){return navigator.language||navigator.userLanguage}function _o(){return(null==c?void 0:c.referrer)||"$direct"}function ho(e,t){var i=e?Fe([],so,t||[]):[],s=null==d?void 0:d.href.substring(0,1e3);return{r:_o().substring(0,1e3),u:s?gi(s,i,no):void 0}}function po(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=_i(i))?void 0:t.host};if(s){r.$current_url=s;var n=_i(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=lo(s);Te(r,o)}if(i){var a=uo(i);Te(r,a)}return r}function go(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function vo(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function fo(e,t){if(!g)return{};var i,s,n,o=e?Fe([],so,t||[]):[],[a,l]=function(e){for(var t=0;t<eo.length;t++){var[i,s]=eo[t],r=i.exec(e),n=r&&(R(s)?s(r,e):s);if(n)return n}return["",""]}(g);return Te(Oe({$os:a,$os_version:l,$browser:Xn(g,navigator.vendor),$device:to(g),$device_type:(s=g,n=to(s),n===dn||n===cn||"Kobo"===n||"Kindle Fire"===n||n===Hn?un:n===Tn||n===Mn||n===Fn||n===Nn?"Console":n===hn?"Wearable":n?on:"Desktop"),$timezone:go(),$timezone_offset:vo()}),{$current_url:gi(null==d?void 0:d.href,o,no),$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:Zn(g,navigator.vendor),$browser_language:co(),$browser_language_prefix:(i=co(),"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 mo=Ie("[FeatureFlags]"),yo="$active_feature_flags",bo="$override_feature_flags",wo="$feature_flag_payloads",So="$override_feature_flag_payloads",Eo="$feature_flag_request_id",ko=e=>{var t={};for(var[i,s]of Me(e||{}))s&&(t[i]=s);return t},xo=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]})))):mo.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e},Io=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class Ro{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||mo.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(ht),t=this._instance.get_property(bo),s=this._instance.get_property(So);if(!s&&!t)return e||{};var r=Te({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=r[o],c=null==t?void 0:t[o],d=T(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=T(c)?u.variant:"string"==typeof c?c:void 0,h=null==s?void 0:s[o],p=i({},u,{enabled:d,variant:d?null!=_?_:null==u?void 0:u.variant:void 0});if(d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),_!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),h)p.metadata=i({},null==u?void 0:u.metadata,{payload:h,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload});r[o]=p}return this._override_warning||(mo.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var e=this._instance.get_property(dt),t=this._instance.get_property(bo);if(!t)return e||{};for(var i=Te({},e),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(mo.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._instance.get_property(wo),t=this._instance.get_property(So);if(!t)return e||{};for(var i=Te({},e||{}),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(mo.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(pt)||{}),group_properties:this._instance.get_property(gt)};(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=go()),this._requestInFlight=!0,this._instance._send_request({method:"POST",url:a,data:s,compression:this._instance.config.disable_compression?void 0:ui.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(Io.FeatureFlags))mo.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(Eo)||void 0,n=this._instance.get_property(mt)||{};if((t.send_event||!("send_event"in t))&&(!(e in n)||!n[e].includes(s))){var o,a,l,u,c,d,_,h,p;I(n[e])?n[e].push(s):n[e]=[s],null==(o=this._instance.persistence)||o.register({[mt]: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};T(null==g||null==(u=g.metadata)?void 0:u.version)||(v.$feature_flag_version=g.metadata.version);var f,m=null!==(c=null==g||null==(d=g.reason)?void 0:d.description)&&void 0!==c?c: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),T(null==g?void 0:g.original_variant)&&T(null==g?void 0:g.original_enabled)||(v.$feature_flag_original_response=T(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}mo.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:ui.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 T(i)?void 0:!!i}mo.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=xo(e),a=o.flags,l=o.featureFlags,u=o.featureFlagPayloads;if(l){var c=e.requestId;if(I(l)){mo.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({[yo]:l,[dt]:d})}else{var h=l,p=u,g=a;e.errorsWhileComputingFlags&&(h=i({},s,h),p=i({},r,p),g=i({},n,g)),t&&t.register(i({[yo]:Object.keys(ko(h)),[dt]:h||{},[wo]:p||{},[ht]:g||{}},c?{[Eo]:c}:{}))}}}(e,this._instance.persistence,s,r,n),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),mo.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return mo.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(bo),this._instance.persistence.unregister(So),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(bo);else if(i.flags)if(I(i.flags)){for(var s={},r=0;r<i.flags.length;r++)s[i.flags[r]]=!0;this._instance.persistence.register({[bo]:s})}else this._instance.persistence.register({[bo]:i.flags});return"payloads"in i&&(!1===i.payloads?this._instance.persistence.unregister(So):i.payloads&&this._instance.persistence.register({[So]: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(_t)||[]).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({[yo]:Object.keys(ko(l)),[dt]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._instance.get_property(_t),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(_t),null==(s=this._instance.persistence)||s.register({[_t]: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(pt)||{};this._instance.register({[pt]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(pt)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(gt)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((t=>{s[t]=i({},s[t],e[t]),delete e[t]})),this._instance.register({[gt]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(gt)||{};this._instance.register({[gt]:i({},t,{[e]:{}})})}else this._instance.unregister(gt)}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 Co=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Po{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&&xe.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Co.indexOf(e.persistence.toLowerCase())&&(xe.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&Ai._is_supported()?Ai:"localstorage+cookie"===t&&Ni._is_supported()?Ni:"sessionstorage"===t&&zi._is_supported()?zi:"memory"===t?Bi:"cookie"===t?Li:Ni._is_supported()?Ni:Li}properties(){var e={};return Pe(this.props,(function(t,i){if(i===dt&&C(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,(L(n=Ct)?a:l&&n.indexOf===l?-1!=n.indexOf(o):(Pe(n,(function(e){if(a||(a=e===o))return Re})),a))||(e[i]=t);var n,o,a})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=Te({},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(C(e)){T(t)&&(t="None"),this._expire_days=T(i)?this._default_expiry:i;var s=!1;if(Pe(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(C(e)){this._expire_days=T(t)?this._default_expiry:t;var i=!1;if(Pe(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=ao(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);P(Oe(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==c?void 0:c.referrer)?uo(e):{})}update_referrer_info(){var e;this.register_once({$referrer:_o(),$referring_domain:null!=c&&c.referrer&&(null==(e=_i(c.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[St]||this.props[Et]||this.register_once({[kt]:ho(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Pe([Et,St],(t=>{var i=this.props[t];i&&Pe(i,(function(t,i){e["$initial_"+w(i)]=t}))}));var t,i,s=this.props[kt];if(s){var r=(t=po(s),i={},Pe(t,(function(e,t){i["$initial_"+w(t)]=e})),i);Te(e,r)}return e}safe_merge(e){return Pe(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[Ue]||{};i[e]=t,this.props[Ue]=i,this.save()}remove_event_timer(e){var t=(this.props[Ue]||{})[e];return T(t)||(delete this.props[Ue][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var To=function(e){return e.Button="button",e.Tab="tab",e.Selector="selector",e}({}),Fo=function(e){return e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger",e}({}),Mo=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({}),$o=function(e){return e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link",e}({}),Lo=function(e){return e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question",e}({}),Oo=function(e){return e.Once="once",e.Recurring="recurring",e.Always="always",e}({}),Ao=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e}({}),Do=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}({}),No=function(e){return e.Popover="popover",e.Inline="inline",e}({});class qo{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 Bo{constructor(e){this._debugEventEmitter=new qo,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(!T(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(!T(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(!Bo._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&&Zr(e,t);case"exact":return t===e;case"contains":var s=Bo._escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return Zr(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&&!Bo._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&&!Bo._matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!Bo._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 Ho=Ie("[Surveys]");var zo="seenSurvey_",Uo=(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},jo=e=>{var t=""+zo+e.id;return e.current_iteration&&e.current_iteration>0&&(t=""+zo+e.id+"_"+e.current_iteration),t},Wo=[Mo.Popover,Mo.Widget,Mo.API],Vo={ignoreConditions:!1,ignoreDelay:!1,displayType:No.Popover};class Go{constructor(e){this._instance=e,this._eventToSurveys=new Map,this._actionToSurveys=new Map}register(e){var t;T(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 Bo(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[ft])||[];if(Ao.SHOWN===e&&t&&r.length>0){var n;Ho.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)){Ho.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 u=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(T(n)||L(n))return!1;var o=[String(n)],a=tn[r.operator];return a?a(r.values,o):(Ho.warn("Unknown property comparison operator: "+r.operator),!1)})))}));this._updateActivatedSurveys(r.concat(u.map((e=>e.id))||[]))}}onAction(e){var t,i=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[ft])||[];this._actionToSurveys.has(e)&&this._updateActivatedSurveys(i.concat(this._actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t;Ho.info("updating activated surveys",{activatedSurveys:e}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[ft]:[...new Set(e)]})}getSurveys(){var e,t=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[ft];return t||[]}getEventToSurveys(){return this._eventToSurveys}_getActionMatcher(){return this._actionMatcher}}class Yo{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(O(t))return Ho.warn("Flags not loaded yet. Not loading surveys.");var i=I(t);this._isSurveysEnabled=i?t.length>0:t,Ho.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(zo)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Ho.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Ho.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Ho.info("Not loading surveys in cookieless mode without consent.");else{var e=null==v?void 0:v.__PosthogExtensions__;if(e){if(!T(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 Ho.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Go(this._instance),Ho.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){Ho.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 Ho.info("Disabled. Not loading surveys."),e([]);var i=this._instance.get_property(vt);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 Ho.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({[vt]: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){Ho.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!O(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Ho.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(O(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(O(this._surveyManager))return Ho.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 O(this._surveyManager)?(Ho.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(O(this._surveyManager))Ho.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(Wo.includes(s.type)){var r=null==c?void 0:c.querySelector(t);if(r)return null!=(i=s.appearance)&&i.surveyPopupDelaySeconds?(Ho.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;Ho.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),Ho.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,r);Ho.warn("Survey element not found")}else Ho.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Ho.warn("Survey not found")}}displaySurvey(e,t){var s;if(O(this._surveyManager))Ho.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 Ho.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==No.Inline?this._surveyManager.handlePopoverSurvey(n):this.renderSurvey(n,t.selector)}else Ho.warn("Survey not found")}}}var Jo=Ie("[RateLimiter]");class Ko{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=>{Jo.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Jo.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(wt))&&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(wt,n),{isRateLimited:o,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Xo=Ie("[RemoteConfig]");class Qo{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))):(Xo.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 Xo.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Xo.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Xo.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){Xo.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()):Xo.info("__preview_remote_config is disabled. Logging config instead",e):Xo.error("Failed to fetch remote config from PostHog.")}}var Zo=3e3;class ea{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=V((null==t?void 0:t.flush_interval_ms)||Zo,250,5e3,xe.createLogger("flush interval"),Zo),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&&I(i.data)&&Pe(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 Pe(this._queue,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;T(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)})),this._queue=[],e}}var ta=["retriesPerformedSoFar"];class ia{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!T(r)&&"onLine"in r.navigator&&(this._areWeOnline=r.navigator.onLine,Be(r,"online",(()=>{this._areWeOnline=!0,this._flush()})),Be(r,"offline",(()=>{this._areWeOnline=!1})))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=s(e,ta);A(t)&&t>0&&(r.url=Jr(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)"),xe.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){this._poller&&clearTimeout(this._poller),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._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){xe.error(e)}this._queue=[]}}class sa{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(){Be(r,"scroll",this._updateScrollData,{capture:!0}),Be(r,"scrollend",this._updateScrollData,{capture:!0}),Be(r,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==r?void 0:r.document.documentElement;var e=I(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 ra=e=>ho(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class na{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({[bt]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||ra,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[bt]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?po(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 Pe(Oe(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+w(i)]=t})),e}}var oa=Ie("[SessionId]");class aa{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._sessionIdChangedHandlers=[],this._eventEmitter=new qo,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||Pi,this._windowIdGenerator=i||Pi;var r=this._config.persistence_name||this._config.token,n=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*V(n,60,36e3,oa.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=zi._parse(this._window_id_storage_key),a=zi._parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:zi._remove(this._window_id_storage_key),zi._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){oa.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return T(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&&zi._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&zi._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?zi._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({[at]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this._persistence.props[at];return I(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){Be(r,"beforeunload",(()=>{this._canUseSessionStorage()&&zi._remove(this._primary_window_exists_storage_key)}),{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=A(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,u=!r,c=!e&&this._sessionHasBeenIdleTooLong(i,s);u||c||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),oa.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:u,activityTimeout:c,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:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:u,activityTimeout:c,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 la=["$set_once","$set"],ua=Ie("[SiteApps]");class ca{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,u;if(!e)throw new Error("Event payload is required");var c={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))c[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},s(e,la),{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==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this._bufferedInvocations.length&&(ua.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,ua.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){ua.error("Error while initializing PostHog app with config id "+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){ua.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){ua.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 ua.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 ua.error("Error while initializing PostHog app with config id "+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else ua.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var da=["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"],_a=function(e,t){if(!e)return!1;var i=e.toLowerCase();return da.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},ha=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&_a(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>_a(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},pa=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),ga="i.posthog.com";class va{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("."+ga,".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]=pa.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=pa.EU:this._regionCache[this.apiHost]=pa.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===pa.CUSTOM)return this.apiHost+t;var i=ga+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var fa={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&&Zr(t.href,e),not_regex:(e,t)=>!!r&&!Zr(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class ma{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{ma._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)ma._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);F(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];ma._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())ma._logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(O(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ma._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=ma.getWindowLocation();if(null!=e&&e.search){var t=pi(null==e?void 0:e.search,"__experiment_id"),i=pi(null==e?void 0:e.search,"__experiment_variant");t&&i&&(ma._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&&(ma._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!O(e.conditions)&&(ma._matchUrlConditions(e)&&ma._matchUTMConditions(e))}static _matchUrlConditions(e){var t;if(O(e.conditions)||O(null==(t=e.conditions)?void 0:t.url))return!0;var i,s,r,n=ma.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||fa[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(O(e.conditions)||O(null==(t=e.conditions)?void 0:t.utm))return!0;var i=ao();if(i.utm_source){var s,r,n,o,a,l,u,c,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==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.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];xe.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?ma._logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var s;ma._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)}))}})):ma._logInfo("Control variants leave the page unmodified.")}_is_bot(){return u&&this._instance?ha(u,this._instance.config.custom_blocked_useragents):void 0}}var ya=Ie("[PostHog ExternalIntegrations]"),ba={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class wa{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 ya.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(ba[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 Sa="[SessionRecording]",Ea=Ie(Sa);class ka{get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e;return this._receivedFlags&&!this._isRecordingEnabled?Qs:(null==(e=this._lazyLoadedSessionRecording)?void 0:e.status)||"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._receivedFlags=!1,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Ea.error("started without valid sessionManager"),new Error(Sa+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(Sa+' cannot be used with cookieless_mode="always"')}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(Qe))||!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=!T(Object.assign)&&!T(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Ea.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 Ea.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e;null==(e=this._lazyLoadedSessionRecording)||e.stop()}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(lt)}_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=O(s)?null:parseFloat(s);O(n)&&this._resetSampling();var o=null==t?void 0:t.minimumDurationMilliseconds;r.register({[Qe]: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:T(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:Ea.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):Ea.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(Qe);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 xa={},Ia=()=>{},Ra="posthog",Ca=!Gr&&-1===(null==g?void 0:g.indexOf("MSIE"))&&-1===(null==g?void 0:g.indexOf("Mozilla")),Pa=e=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:Ne(null==c?void 0:c.location),persistence:"localStorage+cookie",persistence_name:"",loaded:Ia,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&&F(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;xe.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:Zo},error_tracking:{},_onCapture:Ia,__preview_eager_load_replay:!1}},Ta=e=>{var t={};T(e.process_person)||(t.person_profiles=e.process_person),T(e.xhr_headers)||(t.request_headers=e.xhr_headers),T(e.cookie_name)||(t.persistence_name=e.cookie_name),T(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),T(e.store_google)||(t.save_campaign_params=e.store_google),T(e.verbose)||(t.debug=e.verbose);var i=Te({},t,e);return I(e.property_blacklist)&&(T(e.property_denylist)?i.property_denylist=e.property_blacklist:I(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:xe.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class Fa{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){xe.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Ma{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 Fa,this._personProcessingSetOncePropertiesSent=!1,this.version=f.LIB_VERSION,this._internalEventEmitter=new qo,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Pa(),this.SentryIntegration=Fr,this.sentryIntegration=e=>function(e,t){var i=Tr(e,t);return{name:Pr,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 Ro(this),this.toolbar=new Ar(this),this.scrollManager=new sa(this),this.pageViewManager=new Wr(this),this.surveys=new Yo(this),this.experiments=new ma(this),this.exceptions=new nn(this),this.rateLimiter=new Ko(this),this.requestRouter=new va(this),this.consent=new ji(this),this.externalIntegrations=new wa(this),this.people={set:(e,t,i)=>{var s=F(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=F(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>xe.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Ra){var s,r=null!==(s=xa[i])&&void 0!==s?s:new Ma;return r._init(e,t,i),xa[i]=r,xa[Ra][i]=r,r}return this._init(e,t,i)}_init(e,t,s){var n,o;if(void 0===t&&(t={}),T(e)||M(e))return xe.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 xe.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles&&(this._initialPersonProfilesConfig=t.person_profiles),this.set_config(Te({},Pa(t.defaults),Ta(t),{name:s,token:e})),this.config.on_xhr_error&&xe.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ui.GZipJS;var a=this._is_persistence_disabled();this.persistence=new Po(this.config,a),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Po(i({},this.config,{persistence:"sessionStorage"}),a);var l=i({},this.persistence.props),u=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new ea((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new ia(this),this.__request_queue=[];var c="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(c||(this.sessionManager=new aa(this),this.sessionPropsManager=new na(this,this.sessionManager,this.persistence)),new Nr(this).startIfEnabledOrStop(),this.siteApps=new ca(this),null==(n=this.siteApps)||n.init(),c||(this.config.__preview_eager_load_replay?this.sessionRecording=new Ir(this):this.sessionRecording=new ka(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Si(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new jr(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Hr(this),this.exceptionObserver=new Ki(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Yi(this,Gi),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new Qi(this),this.historyAutocapture.startIfEnabled(),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&xe.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:u}),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var d,_,h=this.config.get_device_id(Pi()),p=null!=(d=t.bootstrap)&&d.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(yt,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(c)this.register_once({distinct_id:Rt,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(Pi());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(yt,"anonymous")}return Be(r,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Cr(this,(()=>this._loaded())):this._loaded(),R(this.config._onCapture)&&this.config._onCapture!==Ia&&(xe.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&xe.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(!c||!c.body)return xe.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=y(e.supportedCompression,ui.GZipJS)?ui.GZipJS:y(e.supportedCompression,ui.Base64)?ui.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){xe.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 Qo(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()&&Ce(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&&(Ca?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Jr(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=Jr(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=Qr.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(s=null==(r=qe(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=[];Ce(e,(e=>{e&&(t=e[0],I(t)?r.push(e):R(e)?e.call(this):I(e)&&"alias"===t?i.push(e):I(e)&&-1!==t.indexOf("capture")&&R(this[t])?r.push(e):s.push(e))}));var n=function(e,t){Ce(e,(function(e){if(I(e[0])){var i=t;Pe(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(!T(e)&&F(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var n=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==n||!n.isRateLimited){null!=t&&t.$current_url&&!F(null==t?void 0:t.$current_url)&&(xe.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 o=new Date,a=(null==s?void 0:s.timestamp)||o,l=Pi(),u={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},a,l)};n&&(u.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens),(null==s?void 0:s.$set)&&(u.$set=null==s?void 0:s.$set);var c,d=this._calculate_set_once_properties(null==s?void 0:s.$set_once);if(d&&(u.$set_once=d),(u=Ae(u,null!=s&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,T(null==s?void 0:s.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=o),e===Ao.DISMISSED||e===Ao.SENT){var _=null==t?void 0:t[Do.SURVEY_ID],h=null==t?void 0:t[Do.SURVEY_ITERATION];c={id:_,current_iteration:h},localStorage.getItem(jo(c))||localStorage.setItem(jo(c),"true"),u.$set=i({},u.$set,{[Uo({id:_,current_iteration:h},e===Ao.SENT?"responded":"dismissed")]:!0})}var p=i({},u.properties.$set,u.$set);if(P(p)||this.setPersonPropertiesForFlags(p),!O(this.config.before_send)){var g=this._runBeforeSend(u);if(!g)return;u=g}this._internalEventEmitter.emit("eventCaptured",u);var v={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(v):this._requestQueue.enqueue(v),u}xe.critical("This capture call is ignored due to client rate limiting.")}}else xe.error("No event name provided to posthog.capture")}else xe.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,(!F(a.distinct_id)&&!A(a.distinct_id)||M(a.distinct_id))&&xe.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,d=fo(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&&Te(a,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Te(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===pa.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),u="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=Te(a,u),"$pageview"===e&&c&&(a.title=c.title),!T(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=Te({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),I(this.config.property_denylist)?Pe(this.config.property_denylist,(function(e){delete a[e]})):xe.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&&(xe.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=Te({},i,s||{},e||{}),n=this.config.sanitize_properties;return n&&(xe.error("sanitize_properties is deprecated. Use before_send instead"),r=n(r,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,P(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=Vo),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 xe.uninitializedWarning("posthog.identify");if(A(e)&&(e=e.toString(),xe.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()))xe.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!==Rt){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(ze)&&(this.unregister(ze),this.register({distinct_id:e}));var o="anonymous"===(this.persistence.get_property(yt)||"anonymous");e!==r&&o?(this.persistence.set_property(yt,"identified"),this.setPersonPropertiesForFlags(i({},s||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:s||{}}),this._cachedPersonProperties=en(e,t,s),this.featureFlags.setAnonymousDistinctId(r)):(t||s)&&this.setPersonProperties(t,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(mt))}}else xe.critical('The string "'+Rt+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else xe.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var s=en(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):xe.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 xe.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(xe.info("reset"),!this.__loaded)return xe.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(yt,"anonymous"),null==(r=this.sessionManager)||r.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Rt,$device_id:null},"");else{var o=this.config.get_device_id(Pi());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(He)?(xe.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(T(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(ze,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(xe.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(C(e)){var s,r,n,o,a;Te(this.config,Ta(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 Po(i({},this.config,{persistence:"sessionStorage"}),l),Ai._is_supported()&&"true"===Ai._get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(f.DEBUG=!0,xe.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})),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:Ra;return t!==Ra&&(t=Ra+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(yt))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(yt))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&P(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[ze])&&(null==(t=this.persistence)||null==(t=t.props)||!t[xt]))}_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?(xe.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(xt,!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;if("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),this.sessionManager=new aa(this),this.persistence&&(this.sessionPropsManager=new na(this,this.sessionManager,this.persistence)),this.sessionRecording=new Ir(this),this.sessionRecording.startIfEnabledOrStop()),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(),T(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)this.capture(null!==(t=null==e?void 0:e.captureEventName)&&void 0!==t?t:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}else xe.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e;"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:Rt,$device_id:null}),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(e=this.sessionRecording)||e.stopRecording(),this.sessionRecording=void 0,this._captureInitialPageview())):xe.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===Ui.GRANTED?"granted":e===Ui.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 u?ha(u,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){c&&("visible"===c.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:c.title},{send_instantly:!0}),this._visibilityStateListener&&(c.removeEventListener("visibilitychange",this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Be(c,"visibilitychange",this._visibilityStateListener)))}debug(e){!1===e?(null==r||r.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),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)`."),localStorage&&localStorage.setItem("ph_debug","true"),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?(xe.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=xe,n=(t="advanced_disable_flags")in(e=a)&&!T(e[t]),o=i in e&&!T(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(O(this.config.before_send))return e;var t=I(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),O(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return q(e.event)?xe.warn(r+". This can cause unexpected behavior."):xe.info(r),null}i.properties&&!P(i.properties)||xe.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)})}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Le(e.prototype[t[i]])}(Ma,["identify"]);var $a,La=($a=xa[Ra]=new Ma,function(){function e(){e.done||(e.done=!0,Ca=!1,Pe(xa,(function(e){e._dom_loaded()})))}null!=c&&c.addEventListener?"complete"===c.readyState?e():Be(c,"DOMContentLoaded",e,{capture:!1}):r&&xe.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),$a);export{li as COPY_AUTOCAPTURE_EVENT,ui as Compression,No as DisplaySurveyType,Ma as PostHog,Ao as SurveyEventName,Do as SurveyEventProperties,Fo as SurveyPosition,Lo as SurveyQuestionBranchingType,$o as SurveyQuestionType,Oo as SurveySchedule,Mo as SurveyType,To as SurveyWidgetType,La as default,La as posthog,ci as severityLevels};
|
|
2
2
|
//# sourceMappingURL=module.no-external.js.map
|