posthog-js 1.174.2 → 1.174.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/all-external-dependencies.js +1 -15
  2. package/dist/all-external-dependencies.js.map +1 -1
  3. package/dist/array.full.es5.js +1 -1
  4. package/dist/array.full.es5.js.map +1 -1
  5. package/dist/array.full.js +2 -16
  6. package/dist/array.full.js.map +1 -1
  7. package/dist/array.full.no-external.js +2 -16
  8. package/dist/array.full.no-external.js.map +1 -1
  9. package/dist/array.js +2 -2
  10. package/dist/array.js.map +1 -1
  11. package/dist/array.no-external.js +2 -2
  12. package/dist/array.no-external.js.map +1 -1
  13. package/dist/main.js +2 -2
  14. package/dist/main.js.map +1 -1
  15. package/dist/module.d.ts +1 -0
  16. package/dist/module.full.d.ts +1 -0
  17. package/dist/module.full.js +2 -16
  18. package/dist/module.full.js.map +1 -1
  19. package/dist/module.full.no-external.d.ts +1 -0
  20. package/dist/module.full.no-external.js +2 -16
  21. package/dist/module.full.no-external.js.map +1 -1
  22. package/dist/module.js +2 -2
  23. package/dist/module.js.map +1 -1
  24. package/dist/module.no-external.d.ts +1 -0
  25. package/dist/module.no-external.js +2 -2
  26. package/dist/module.no-external.js.map +1 -1
  27. package/dist/recorder-v2.js +1 -15
  28. package/dist/recorder-v2.js.map +1 -1
  29. package/dist/recorder.js +1 -15
  30. package/dist/recorder.js.map +1 -1
  31. package/dist/src/entrypoints/recorder.d.ts +2 -2
  32. package/dist/src/sessionid.d.ts +1 -0
  33. package/lib/package.json +6 -5
  34. package/lib/src/entrypoints/recorder.d.ts +2 -2
  35. package/lib/src/entrypoints/recorder.js +6 -5
  36. package/lib/src/entrypoints/recorder.js.map +1 -1
  37. package/lib/src/sessionid.d.ts +1 -0
  38. package/lib/src/sessionid.js +1 -0
  39. package/lib/src/sessionid.js.map +1 -1
  40. package/package.json +6 -5
@@ -1,4 +1,4 @@
1
- !function(){"use strict";const e={DEBUG:!1,LIB_VERSION:"1.174.2"},t=Array.isArray,i=Object.prototype,s=i.hasOwnProperty,n=i.toString,r=t||function(e){return"[object Array]"===n.call(e)},o=function(e){return"function"==typeof e},a=function(e){return e===Object(e)&&!r(e)},l=function(e){if(a(e)){for(const t in e)if(s.call(e,t))return!1;return!0}return!1},c=function(e){return void 0===e},u=function(e){return"[object String]"==n.call(e)},d=function(e){return u(e)&&0===e.trim().length},h=function(e){return null===e},p=function(e){return c(e)||h(e)},g=function(e){return"[object Number]"==n.call(e)},_=function(e){return"[object Boolean]"===n.call(e)},f=e=>e instanceof FormData,v="undefined"!=typeof window?window:void 0,m="undefined"!=typeof globalThis?globalThis:v,b=Array.prototype,y=b.forEach,w=b.indexOf,S=null==m?void 0:m.navigator,E=null==m?void 0:m.document,x=null==m?void 0:m.location,k=null==m?void 0:m.fetch,I=null!=m&&m.XMLHttpRequest&&"withCredentials"in new m.XMLHttpRequest?m.XMLHttpRequest:void 0,F=null==m?void 0:m.AbortController,R=null==S?void 0:S.userAgent,P=null!=v?v:{},$="[PostHog.js]",T={_log:function(t){if(v&&(e.DEBUG||P.POSTHOG_DEBUG)&&!c(v.console)&&v.console){const e="__rrweb_original__"in v.console[t]?v.console[t].__rrweb_original__:v.console[t];for(var i=arguments.length,s=new Array(i>1?i-1:0),n=1;n<i;n++)s[n-1]=arguments[n];e($,...s)}},info:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];T._log("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];T._log("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];T._log("error",...t)},critical:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];console.error($,...t)},uninitializedWarning:e=>{T.error(`You must initialize PostHog before calling ${e}`)}},C={},M=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function A(e,t,i){if(r(e))if(y&&e.forEach===y)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(let s=0,n=e.length;s<n;s++)if(s in e&&t.call(i,e[s],s)===C)return}function L(e,t,i){if(!p(e)){if(r(e))return A(e,t,i);if(f(e)){for(const s of e.entries())if(t.call(i,s[1],s[0])===C)return}else for(const n in e)if(s.call(e,n)&&t.call(i,e[n],n)===C)return}}const O=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 A(i,(function(t){for(const i in t)void 0!==t[i]&&(e[i]=t[i])})),e};function D(e,t){return-1!==e.indexOf(t)}function N(e){const t=Object.keys(e);let i=t.length;const s=new Array(i);for(;i--;)s[i]=[t[i],e[t[i]]];return s}const q=function(e){try{return e()}catch{return}},B=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){T.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),T.critical(e)}}},H=function(e){const t={};return L(e,(function(e,i){u(e)&&e.length>0&&(t[i]=e)})),t},U=function(e){return e.replace(/^\$/,"")};function W(e,t){return function(e,t){const i=new Set;return function e(s,n){if(s!==Object(s))return t?t(s,n):s;if(i.has(s))return;let o;return i.add(s),r(s)?(o=[],A(s,(t=>{o.push(e(t))}))):(o={},L(s,((t,s)=>{i.has(t)||(o[s]=e(t,s))}))),o}(e)}(e,(e=>u(e)&&!h(t)?e.slice(0,t):e))}const z=function(e){let t,i,s,n="",r=0;for(t=i=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s<r;s++){const r=e.charCodeAt(s);let o=null;r<128?i++:o=r>127&&r<2048?String.fromCharCode(r>>6|192,63&r|128):String.fromCharCode(r>>12|224,r>>6&63|128,63&r|128),h(o)||(i>t&&(n+=e.substring(t,i)),n+=o,t=i=s+1)}return i>t&&(n+=e.substring(t,e.length)),n},V=function(){function e(t){return t&&(t.preventDefault=e.preventDefault,t.stopPropagation=e.stopPropagation),t}return e.preventDefault=function(){this.returnValue=!1},e.stopPropagation=function(){this.cancelBubble=!0},function(t,i,s,n,r){if(t)if(t.addEventListener&&!n)t.addEventListener(i,s,!!r);else{const n="on"+i,r=t[n];t[n]=function(t,i,s){return function(n){if(!(n=n||e(null==v?void 0:v.event)))return;let r,a=!0;o(s)&&(r=s(n));const l=i.call(t,n);return!1!==r&&!1!==l||(a=!1),a}}(t,s,r)}else T.error("No valid element provided to register_event")}}();function G(e){const t=null==e?void 0:e.hostname;return!!u(t)&&"herokuapp.com"!==t.split(".").slice(-2).join(".")}function j(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return e[i]}let Q;!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(Q||(Q={}));const J="$people_distinct_id",Y="__alias",X="__timers",K="$autocapture_disabled_server_side",Z="$heatmaps_enabled_server_side",ee="$exception_capture_enabled_server_side",te="$exception_capture_endpoint_suffix",ie="$web_vitals_enabled_server_side",se="$web_vitals_allowed_metrics",ne="$session_recording_enabled_server_side",re="$console_log_recording_enabled_server_side",oe="$session_recording_network_payload_capture",ae="$session_recording_canvas_recording",le="$replay_sample_rate",ce="$replay_minimum_duration",ue="$sesid",de="$session_is_sampled",he="$session_recording_url_trigger_activated_session",pe="$session_recording_url_trigger_status",ge="$enabled_feature_flags",_e="$early_access_features",fe="$stored_person_properties",ve="$stored_group_properties",me="$surveys",be="$surveys_activated",ye="$flag_call_reported",we="$user_state",Se="$client_session_props",Ee="$capture_rate_limit",xe="$initial_campaign_params",ke="$initial_referrer_info",Ie="$initial_person_info",Fe="$epp",Re="__POSTHOG_TOOLBAR__",Pe=[J,Y,"__cmpns",X,ne,Z,ue,ge,we,_e,ve,fe,me,ye,Se,Ee,xe,ke,Fe],$e="$active_feature_flags",Te="$override_feature_flags",Ce="$feature_flag_payloads",Me=e=>{const t={};for(const[i,s]of N(e||{}))s&&(t[i]=s);return t};class Ae{constructor(e){this.instance=e,this._override_warning=!1,this.featureFlagEventHandlers=[],this.reloadFeatureFlagsQueued=!1,this.reloadFeatureFlagsInAction=!1}getFlags(){return Object.keys(this.getFlagVariants())}getFlagVariants(){const e=this.instance.get_property(ge),t=this.instance.get_property(Te);if(!t)return e||{};const i=O({},e),s=Object.keys(t);for(let e=0;e<s.length;e++)i[s[e]]=t[s[e]];return this._override_warning||(T.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){return this.instance.get_property(Ce)||{}}reloadFeatureFlags(){this.reloadFeatureFlagsQueued||(this.reloadFeatureFlagsQueued=!0,this._startReloadTimer())}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.reloadFeatureFlagsInAction=e}resetRequestQueue(){this.reloadFeatureFlagsQueued=!1}_startReloadTimer(){this.reloadFeatureFlagsQueued&&!this.reloadFeatureFlagsInAction&&setTimeout((()=>{!this.reloadFeatureFlagsInAction&&this.reloadFeatureFlagsQueued&&(this.reloadFeatureFlagsQueued=!1,this._reloadFeatureFlagsRequest())}),5)}_reloadFeatureFlagsRequest(){if(this.instance.config.advanced_disable_feature_flags)return;this.setReloadingPaused(!0);const e=this.instance.config.token,t=this.instance.get_property(fe),i=this.instance.get_property(ve),s={token:e,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:t,group_properties:i,disable_flags:this.instance.config.advanced_disable_feature_flags||void 0};this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:s,compression:this.instance.config.disable_compression?void 0:Q.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:e=>{var t;this.setReloadingPaused(!1);let i=!0;200===e.statusCode&&(this.$anon_distinct_id=void 0,i=!1),this.receivedFeatureFlags(null!==(t=e.json)&&void 0!==t?t:{},i),this._startReloadTimer()}})}getFeatureFlag(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0))return void T.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.");const i=this.getFlagVariants()[e],s=`${i}`,n=this.instance.get_property(ye)||{};var o;!t.send_event&&"send_event"in t||(e in n&&n[e].includes(s)||(r(n[e])?n[e].push(s):n[e]=[s],null===(o=this.instance.persistence)||void 0===o||o.register({[ye]:n}),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:i})));return i}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}isFeatureEnabled(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,t);T.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)return;this.instance.decideEndpointWasHit=!0;const i=this.getFlagVariants(),s=this.getFlagPayloads();!function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const n=e.featureFlags,o=e.featureFlagPayloads;if(!n)return;if(r(n)){const e={};if(n)for(let t=0;t<n.length;t++)e[n[t]]=!0;return void(t&&t.register({[$e]:n,[ge]:e}))}let a=n,l=o;e.errorsWhileComputingFlags&&(a={...i,...a},l={...s,...l}),t&&t.register({[$e]:Object.keys(Me(a)),[ge]:a||{},[Ce]:l||{}})}(e,this.instance.persistence,i,s),this._fireFeatureFlagsCallbacks(t)}override(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.instance.__loaded||!this.instance.persistence)return T.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=t,!1===e)this.instance.persistence.unregister(Te);else if(r(e)){const t={};for(let i=0;i<e.length;i++)t[e[i]]=!0;this.instance.persistence.register({[Te]:t})}else this.instance.persistence.register({[Te]:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.instance.decideEndpointWasHit){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t){var i;const s={[`$feature_enrollment/${e}`]:t};this.instance.capture("$feature_enrollment_update",{$feature_flag:e,$feature_enrollment:t,$set:s}),this.setPersonPropertiesForFlags(s,!1);const n={...this.getFlagVariants(),[e]:t};null===(i=this.instance.persistence)||void 0===i||i.register({[$e]:Object.keys(Me(n)),[ge]:n}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.instance.get_property(_e);if(i&&!t)return e(i);this.instance._send_request({transport:"XHR",url:this.instance.requestRouter.endpointFor("api",`/api/early_access_features/?token=${this.instance.config.token}`),method:"GET",callback:t=>{var i;if(!t.json)return;const s=t.json.earlyAccessFeatures;return null===(i=this.instance.persistence)||void 0===i||i.register({[_e]:s}),e(s)}})}_prepareFeatureFlagsForCallbacks(){const 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){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const i=this.instance.get_property(fe)||{};this.instance.register({[fe]:{...i,...e}}),t&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(fe)}setGroupPropertiesForFlags(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const i=this.instance.get_property(ve)||{};0!==Object.keys(i).length&&Object.keys(i).forEach((t=>{i[t]={...i[t],...e[t]},delete e[t]})),this.instance.register({[ve]:{...i,...e}}),t&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.instance.get_property(ve)||{};this.instance.register({[ve]:{...t,[e]:{}}})}else this.instance.unregister(ve)}}
1
+ !function(){"use strict";const e={DEBUG:!1,LIB_VERSION:"1.174.4"},t=Array.isArray,i=Object.prototype,s=i.hasOwnProperty,n=i.toString,r=t||function(e){return"[object Array]"===n.call(e)},o=function(e){return"function"==typeof e},a=function(e){return e===Object(e)&&!r(e)},l=function(e){if(a(e)){for(const t in e)if(s.call(e,t))return!1;return!0}return!1},c=function(e){return void 0===e},u=function(e){return"[object String]"==n.call(e)},d=function(e){return u(e)&&0===e.trim().length},h=function(e){return null===e},p=function(e){return c(e)||h(e)},g=function(e){return"[object Number]"==n.call(e)},_=function(e){return"[object Boolean]"===n.call(e)},f=e=>e instanceof FormData,v="undefined"!=typeof window?window:void 0,m="undefined"!=typeof globalThis?globalThis:v,b=Array.prototype,y=b.forEach,w=b.indexOf,S=null==m?void 0:m.navigator,E=null==m?void 0:m.document,x=null==m?void 0:m.location,k=null==m?void 0:m.fetch,I=null!=m&&m.XMLHttpRequest&&"withCredentials"in new m.XMLHttpRequest?m.XMLHttpRequest:void 0,F=null==m?void 0:m.AbortController,R=null==S?void 0:S.userAgent,P=null!=v?v:{},$="[PostHog.js]",T={_log:function(t){if(v&&(e.DEBUG||P.POSTHOG_DEBUG)&&!c(v.console)&&v.console){const e="__rrweb_original__"in v.console[t]?v.console[t].__rrweb_original__:v.console[t];for(var i=arguments.length,s=new Array(i>1?i-1:0),n=1;n<i;n++)s[n-1]=arguments[n];e($,...s)}},info:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];T._log("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];T._log("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];T._log("error",...t)},critical:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];console.error($,...t)},uninitializedWarning:e=>{T.error(`You must initialize PostHog before calling ${e}`)}},C={},M=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function A(e,t,i){if(r(e))if(y&&e.forEach===y)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(let s=0,n=e.length;s<n;s++)if(s in e&&t.call(i,e[s],s)===C)return}function L(e,t,i){if(!p(e)){if(r(e))return A(e,t,i);if(f(e)){for(const s of e.entries())if(t.call(i,s[1],s[0])===C)return}else for(const n in e)if(s.call(e,n)&&t.call(i,e[n],n)===C)return}}const O=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 A(i,(function(t){for(const i in t)void 0!==t[i]&&(e[i]=t[i])})),e};function D(e,t){return-1!==e.indexOf(t)}function N(e){const t=Object.keys(e);let i=t.length;const s=new Array(i);for(;i--;)s[i]=[t[i],e[t[i]]];return s}const q=function(e){try{return e()}catch{return}},B=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){T.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),T.critical(e)}}},H=function(e){const t={};return L(e,(function(e,i){u(e)&&e.length>0&&(t[i]=e)})),t},U=function(e){return e.replace(/^\$/,"")};function W(e,t){return function(e,t){const i=new Set;return function e(s,n){if(s!==Object(s))return t?t(s,n):s;if(i.has(s))return;let o;return i.add(s),r(s)?(o=[],A(s,(t=>{o.push(e(t))}))):(o={},L(s,((t,s)=>{i.has(t)||(o[s]=e(t,s))}))),o}(e)}(e,(e=>u(e)&&!h(t)?e.slice(0,t):e))}const z=function(e){let t,i,s,n="",r=0;for(t=i=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s<r;s++){const r=e.charCodeAt(s);let o=null;r<128?i++:o=r>127&&r<2048?String.fromCharCode(r>>6|192,63&r|128):String.fromCharCode(r>>12|224,r>>6&63|128,63&r|128),h(o)||(i>t&&(n+=e.substring(t,i)),n+=o,t=i=s+1)}return i>t&&(n+=e.substring(t,e.length)),n},V=function(){function e(t){return t&&(t.preventDefault=e.preventDefault,t.stopPropagation=e.stopPropagation),t}return e.preventDefault=function(){this.returnValue=!1},e.stopPropagation=function(){this.cancelBubble=!0},function(t,i,s,n,r){if(t)if(t.addEventListener&&!n)t.addEventListener(i,s,!!r);else{const n="on"+i,r=t[n];t[n]=function(t,i,s){return function(n){if(!(n=n||e(null==v?void 0:v.event)))return;let r,a=!0;o(s)&&(r=s(n));const l=i.call(t,n);return!1!==r&&!1!==l||(a=!1),a}}(t,s,r)}else T.error("No valid element provided to register_event")}}();function G(e){const t=null==e?void 0:e.hostname;return!!u(t)&&"herokuapp.com"!==t.split(".").slice(-2).join(".")}function j(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return e[i]}let Q;!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(Q||(Q={}));const J="$people_distinct_id",Y="__alias",X="__timers",K="$autocapture_disabled_server_side",Z="$heatmaps_enabled_server_side",ee="$exception_capture_enabled_server_side",te="$exception_capture_endpoint_suffix",ie="$web_vitals_enabled_server_side",se="$web_vitals_allowed_metrics",ne="$session_recording_enabled_server_side",re="$console_log_recording_enabled_server_side",oe="$session_recording_network_payload_capture",ae="$session_recording_canvas_recording",le="$replay_sample_rate",ce="$replay_minimum_duration",ue="$sesid",de="$session_is_sampled",he="$session_recording_url_trigger_activated_session",pe="$session_recording_url_trigger_status",ge="$enabled_feature_flags",_e="$early_access_features",fe="$stored_person_properties",ve="$stored_group_properties",me="$surveys",be="$surveys_activated",ye="$flag_call_reported",we="$user_state",Se="$client_session_props",Ee="$capture_rate_limit",xe="$initial_campaign_params",ke="$initial_referrer_info",Ie="$initial_person_info",Fe="$epp",Re="__POSTHOG_TOOLBAR__",Pe=[J,Y,"__cmpns",X,ne,Z,ue,ge,we,_e,ve,fe,me,ye,Se,Ee,xe,ke,Fe],$e="$active_feature_flags",Te="$override_feature_flags",Ce="$feature_flag_payloads",Me=e=>{const t={};for(const[i,s]of N(e||{}))s&&(t[i]=s);return t};class Ae{constructor(e){this.instance=e,this._override_warning=!1,this.featureFlagEventHandlers=[],this.reloadFeatureFlagsQueued=!1,this.reloadFeatureFlagsInAction=!1}getFlags(){return Object.keys(this.getFlagVariants())}getFlagVariants(){const e=this.instance.get_property(ge),t=this.instance.get_property(Te);if(!t)return e||{};const i=O({},e),s=Object.keys(t);for(let e=0;e<s.length;e++)i[s[e]]=t[s[e]];return this._override_warning||(T.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){return this.instance.get_property(Ce)||{}}reloadFeatureFlags(){this.reloadFeatureFlagsQueued||(this.reloadFeatureFlagsQueued=!0,this._startReloadTimer())}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.reloadFeatureFlagsInAction=e}resetRequestQueue(){this.reloadFeatureFlagsQueued=!1}_startReloadTimer(){this.reloadFeatureFlagsQueued&&!this.reloadFeatureFlagsInAction&&setTimeout((()=>{!this.reloadFeatureFlagsInAction&&this.reloadFeatureFlagsQueued&&(this.reloadFeatureFlagsQueued=!1,this._reloadFeatureFlagsRequest())}),5)}_reloadFeatureFlagsRequest(){if(this.instance.config.advanced_disable_feature_flags)return;this.setReloadingPaused(!0);const e=this.instance.config.token,t=this.instance.get_property(fe),i=this.instance.get_property(ve),s={token:e,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:t,group_properties:i,disable_flags:this.instance.config.advanced_disable_feature_flags||void 0};this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:s,compression:this.instance.config.disable_compression?void 0:Q.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:e=>{var t;this.setReloadingPaused(!1);let i=!0;200===e.statusCode&&(this.$anon_distinct_id=void 0,i=!1),this.receivedFeatureFlags(null!==(t=e.json)&&void 0!==t?t:{},i),this._startReloadTimer()}})}getFeatureFlag(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0))return void T.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.");const i=this.getFlagVariants()[e],s=`${i}`,n=this.instance.get_property(ye)||{};var o;!t.send_event&&"send_event"in t||(e in n&&n[e].includes(s)||(r(n[e])?n[e].push(s):n[e]=[s],null===(o=this.instance.persistence)||void 0===o||o.register({[ye]:n}),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:i})));return i}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}isFeatureEnabled(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,t);T.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)return;this.instance.decideEndpointWasHit=!0;const i=this.getFlagVariants(),s=this.getFlagPayloads();!function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const n=e.featureFlags,o=e.featureFlagPayloads;if(!n)return;if(r(n)){const e={};if(n)for(let t=0;t<n.length;t++)e[n[t]]=!0;return void(t&&t.register({[$e]:n,[ge]:e}))}let a=n,l=o;e.errorsWhileComputingFlags&&(a={...i,...a},l={...s,...l}),t&&t.register({[$e]:Object.keys(Me(a)),[ge]:a||{},[Ce]:l||{}})}(e,this.instance.persistence,i,s),this._fireFeatureFlagsCallbacks(t)}override(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.instance.__loaded||!this.instance.persistence)return T.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=t,!1===e)this.instance.persistence.unregister(Te);else if(r(e)){const t={};for(let i=0;i<e.length;i++)t[e[i]]=!0;this.instance.persistence.register({[Te]:t})}else this.instance.persistence.register({[Te]:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.instance.decideEndpointWasHit){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t){var i;const s={[`$feature_enrollment/${e}`]:t};this.instance.capture("$feature_enrollment_update",{$feature_flag:e,$feature_enrollment:t,$set:s}),this.setPersonPropertiesForFlags(s,!1);const n={...this.getFlagVariants(),[e]:t};null===(i=this.instance.persistence)||void 0===i||i.register({[$e]:Object.keys(Me(n)),[ge]:n}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.instance.get_property(_e);if(i&&!t)return e(i);this.instance._send_request({transport:"XHR",url:this.instance.requestRouter.endpointFor("api",`/api/early_access_features/?token=${this.instance.config.token}`),method:"GET",callback:t=>{var i;if(!t.json)return;const s=t.json.earlyAccessFeatures;return null===(i=this.instance.persistence)||void 0===i||i.register({[_e]:s}),e(s)}})}_prepareFeatureFlagsForCallbacks(){const 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){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const i=this.instance.get_property(fe)||{};this.instance.register({[fe]:{...i,...e}}),t&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(fe)}setGroupPropertiesForFlags(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const i=this.instance.get_property(ve)||{};0!==Object.keys(i).length&&Object.keys(i).forEach((t=>{i[t]={...i[t],...e[t]},delete e[t]})),this.instance.register({[ve]:{...i,...e}}),t&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.instance.get_property(ve)||{};this.instance.register({[ve]:{...t,[e]:{}}})}else this.instance.unregister(ve)}}
2
2
  /**
3
3
  * uuidv7: An experimental implementation of the proposed UUID Version 7
4
4
  *
@@ -7,5 +7,5 @@
7
7
  * @packageDocumentation
8
8
  *
9
9
  * from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts
10
- */Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return g(e)&&isFinite(e)&&Math.floor(e)===e});const Le="0123456789abcdef";class Oe{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");const n=new Uint8Array(16);return n[0]=e/2**40,n[1]=e/2**32,n[2]=e/2**24,n[3]=e/65536,n[4]=e/256,n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=s>>>24,n[13]=s>>>16,n[14]=s>>>8,n[15]=s,new Oe(n)}toString(){let e="";for(let t=0;t<this.bytes.length;t++)e=e+Le.charAt(this.bytes[t]>>>4)+Le.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 Oe(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(let t=0;t<16;t++){const i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class De{timestamp=0;counter=0;random=new Be;generate(){const e=this.generateOrAbort();if(c(e)){this.timestamp=0;const e=this.generateOrAbort();if(c(e))throw new Error("Could not generate UUID after timestamp reset");return e}return e}generateOrAbort(){const 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 Oe.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}let Ne,qe=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};v&&!c(v.crypto)&&crypto.getRandomValues&&(qe=e=>crypto.getRandomValues(e));class Be{buffer=new Uint32Array(8);cursor=1/0;nextUint32(){return this.cursor>=this.buffer.length&&(qe(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}const He=()=>Ue().toString(),Ue=()=>(Ne||(Ne=new De)).generate(),We="Thu, 01 Jan 1970 00:00:00 GMT";let ze="";const Ve=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ge(e,t){if(t){let t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E;if(ze)return ze;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";const i=e.split(".");let s=Math.min(i.length,8);const n="dmn_chk_"+He(),r=new RegExp("(^|;)\\s*"+n+"=1");for(;!ze&&s--;){const e=i.slice(s).join("."),o=n+"=1;domain=."+e;t.cookie=o,r.test(t.cookie)&&(t.cookie=o+";expires="+We,ze=e)}return ze}(e);if(!t){const i=(e=>{const t=e.match(Ve);return t?t[0]:""})(e);i!==t&&T.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}const je={is_supported:()=>!!E,error:function(e){T.error("cookieStore error: "+e)},get:function(e){if(E){try{const t=e+"=",i=E.cookie.split(";").filter((e=>e.length));for(let e=0;e<i.length;e++){let s=i[e];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch{}return null}},parse:function(e){let t;try{t=JSON.parse(je.get(e))||{}}catch{}return t},set:function(e,t,i,s,n){if(E)try{let r="",o="";const a=Ge(E.location.hostname,s);if(i){const e=new Date;e.setTime(e.getTime()+24*i*60*60*1e3),r="; expires="+e.toUTCString()}n&&(o="; secure");const l=e+"="+encodeURIComponent(JSON.stringify(t))+r+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&T.warn("cookieStore warning: large cookie, len="+l.length),E.cookie=l,l}catch{return}},remove:function(e,t){try{je.set(e,"",-1,t)}catch{return}}};let Qe=null;const Je={is_supported:function(){if(!h(Qe))return Qe;let e=!0;if(c(v))e=!1;else try{const t="__mplssupport__",i="xyz";Je.set(t,i),'"xyz"'!==Je.get(t)&&(e=!1),Je.remove(t)}catch{e=!1}return e||T.error("localStorage unsupported; falling back to cookie store"),Qe=e,e},error:function(e){T.error("localStorage error: "+e)},get:function(e){try{return null==v?void 0:v.localStorage.getItem(e)}catch(e){Je.error(e)}return null},parse:function(e){try{return JSON.parse(Je.get(e))||{}}catch{}return null},set:function(e,t){try{null==v||v.localStorage.setItem(e,JSON.stringify(t))}catch(e){Je.error(e)}},remove:function(e){try{null==v||v.localStorage.removeItem(e)}catch(e){Je.error(e)}}},Ye=["distinct_id",ue,de,Fe],Xe={...Je,parse:function(e){try{let t={};try{t=je.parse(e)||{}}catch{}const i=O(t,JSON.parse(Je.get(e)||"{}"));return Je.set(e,i),i}catch{}return null},set:function(e,t,i,s,n,r){try{Je.set(e,t,void 0,void 0,r);const o={};Ye.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&je.set(e,o,i,s,n,r)}catch(e){Je.error(e)}},remove:function(e,t){try{null==v||v.localStorage.removeItem(e),je.remove(e,t)}catch(e){Je.error(e)}}},Ke={},Ze={is_supported:function(){return!0},error:function(e){T.error("memoryStorage error: "+e)},get:function(e){return Ke[e]||null},parse:function(e){return Ke[e]||null},set:function(e,t){Ke[e]=t},remove:function(e){delete Ke[e]}};let et=null;const tt={is_supported:function(){if(!h(et))return et;if(et=!0,c(v))et=!1;else try{const e="__support__",t="xyz";tt.set(e,t),'"xyz"'!==tt.get(e)&&(et=!1),tt.remove(e)}catch{et=!1}return et},error:function(e){T.error("sessionStorage error: ",e)},get:function(e){try{return null==v?void 0:v.sessionStorage.getItem(e)}catch(e){tt.error(e)}return null},parse:function(e){try{return JSON.parse(tt.get(e))||null}catch{}return null},set:function(e,t){try{null==v||v.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){tt.error(e)}},remove:function(e){try{null==v||v.sessionStorage.removeItem(e)}catch(e){tt.error(e)}}},it=["localhost","127.0.0.1"],st=e=>{const t=null==E?void 0:E.createElement("a");return c(t)?null:(t.href=e,t)},nt=function(e,t){return!!function(e){try{new RegExp(e)}catch{return!1}return!0}(t)&&new RegExp(t).test(e)},rt=function(e){let t,i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"&";const n=[];return L(e,(function(e,s){c(e)||c(s)||"undefined"===s||(t=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),i=encodeURIComponent(s),n[n.length]=i+"="+t)})),n.join(s)},ot=function(e,t){const i=((e.split("#")[0]||"").split("?")[1]||"").split("&");let s;for(let e=0;e<i.length;e++){const n=i[e].split("=");if(n[0]===t){s=n;break}}if(!r(s)||s.length<2)return"";{let e=s[1];try{e=decodeURIComponent(e)}catch{T.error("Skipping decoding for malformed query param: "+e)}return e.replace(/\+/g," ")}},at=function(e,t){const i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},lt="Mobile",ct="iOS",ut="Android",dt="Tablet",ht=ut+" "+dt,pt="iPad",gt="Apple",_t=gt+" Watch",ft="Safari",vt="BlackBerry",mt="Samsung",bt=mt+"Browser",yt=mt+" Internet",wt="Chrome",St=wt+" OS",Et=wt+" "+ct,xt="Internet Explorer",kt=xt+" "+lt,It="Opera",Ft=It+" Mini",Rt="Edge",Pt="Microsoft "+Rt,$t="Firefox",Tt=$t+" "+ct,Ct="Nintendo",Mt="PlayStation",At="Xbox",Lt=ut+" "+lt,Ot=lt+" "+ft,Dt="Windows",Nt=Dt+" Phone",qt="Nokia",Bt="Ouya",Ht="Generic",Ut=Ht+" "+lt.toLowerCase(),Wt=Ht+" "+dt.toLowerCase(),zt="Konqueror",Vt="(\\d+(\\.\\d+)?)",Gt=new RegExp("Version/"+Vt),jt=new RegExp(At,"i"),Qt=new RegExp(Mt+" \\w+","i"),Jt=new RegExp(Ct+" \\w+","i"),Yt=new RegExp(vt+"|PlayBook|BB10","i"),Xt={"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"};const Kt=(e,t)=>t&&D(t,gt)||function(e){return D(e,ft)&&!D(e,wt)&&!D(e,ut)}(e),Zt=function(e,t){return t=t||"",D(e," OPR/")&&D(e,"Mini")?Ft:D(e," OPR/")?It:Yt.test(e)?vt:D(e,"IE"+lt)||D(e,"WPDesktop")?kt:D(e,bt)?yt:D(e,Rt)||D(e,"Edg/")?Pt:D(e,"FBIOS")?"Facebook "+lt:D(e,"UCWEB")||D(e,"UCBrowser")?"UC Browser":D(e,"CriOS")?Et:D(e,"CrMo")?wt:D(e,ut)&&D(e,ft)?Lt:D(e,wt)?wt:D(e,"FxiOS")?Tt:D(e.toLowerCase(),zt.toLowerCase())?zt:Kt(e,t)?D(e,lt)?Ot:ft:D(e,$t)?$t:D(e,"MSIE")||D(e,"Trident/")?xt:D(e,"Gecko")?$t:""},ei={[kt]:[new RegExp("rv:"+Vt)],[Pt]:[new RegExp(Rt+"?\\/"+Vt)],[wt]:[new RegExp("("+wt+"|CrMo)\\/"+Vt)],[Et]:[new RegExp("CriOS\\/"+Vt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Vt)],[ft]:[Gt],[Ot]:[Gt],[It]:[new RegExp("(Opera|OPR)\\/"+Vt)],[$t]:[new RegExp($t+"\\/"+Vt)],[Tt]:[new RegExp("FxiOS\\/"+Vt)],[zt]:[new RegExp("Konqueror[:/]?"+Vt,"i")],[vt]:[new RegExp(vt+" "+Vt),Gt],[Lt]:[new RegExp("android\\s"+Vt,"i")],[yt]:[new RegExp(bt+"\\/"+Vt)],[xt]:[new RegExp("(rv:|MSIE )"+Vt)],Mozilla:[new RegExp("rv:"+Vt)]},ti=[[new RegExp(At+"; "+At+" (.*?)[);]","i"),e=>[At,e&&e[1]||""]],[new RegExp(Ct,"i"),[Ct,""]],[new RegExp(Mt,"i"),[Mt,""]],[Yt,[vt,""]],[new RegExp(Dt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Nt,""];if(new RegExp(lt).test(t)&&!/IEMobile\b/.test(t))return[Dt+" "+lt,""];const i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){const e=i[1];let s=Xt[e]||"";return/arm/i.test(t)&&(s="RT"),[Dt,s]}return[Dt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){const t=[e[3],e[4],e[5]||"0"];return[ct,t.join(".")]}return[ct,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=c(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ut+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ut+")","i"),e=>{if(e&&e[2]){const t=[e[2],e[3],e[4]||"0"];return[ut,t.join(".")]}return[ut,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];if(e&&e[1]){const i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[St,""]],[/Linux|debian/i,["Linux",""]]],ii=function(e){return Jt.test(e)?Ct:Qt.test(e)?Mt:jt.test(e)?At:new RegExp(Bt,"i").test(e)?Bt:new RegExp("("+Nt+"|WPDesktop)","i").test(e)?Nt:/iPad/.test(e)?pt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?_t:Yt.test(e)?vt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(qt,"i").test(e)?qt:/(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(lt).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)?ut:ht:ut:new RegExp("(pda|"+lt+")","i").test(e)?Ut:new RegExp(dt,"i").test(e)&&!new RegExp(dt+" pc","i").test(e)?Wt:""},si="https?://(.*)",ni=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","mc_cid","igshid","ttclid","rdt_cid"],ri={campaignParams:function(e){return E?this._campaignParamsFromUrl(E.URL,e):{}},_campaignParamsFromUrl:function(e,t){const i=ni.concat(t||[]),s={};return L(i,(function(t){const i=ot(e,t);s[t]=i||null})),s},_searchEngine:function(e){return e?0===e.search(si+"google.([^/?]*)")?"google":0===e.search(si+"bing.com")?"bing":0===e.search(si+"yahoo.com")?"yahoo":0===e.search(si+"duckduckgo.com")?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){const t=ri._searchEngine(e),i="yahoo"!=t?"q":"p",s={};if(!h(t)){s.$search_engine=t;const e=E?ot(E.referrer,i):"";e.length&&(s.ph_keyword=e)}return s},searchInfo:function(){const e=null==E?void 0:E.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:Zt,browserVersion:function(e,t){const i=Zt(e,t),s=ei[i];if(c(s))return null;for(let t=0;t<s.length;t++){const i=s[t],n=e.match(i);if(n)return parseFloat(n[n.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},os:function(e){for(let t=0;t<ti.length;t++){const[i,s]=ti[t],n=i.exec(e),r=n&&(o(s)?s(n,e):s);if(r)return r}return["",""]},device:ii,deviceType:function(e){const t=ii(e);return t===pt||t===ht||"Kobo"===t||"Kindle Fire"===t||t===Wt?dt:t===Ct||t===At||t===Mt||t===Bt?"Console":t===_t?"Wearable":t?lt:"Desktop"},referrer:function(){return(null==E?void 0:E.referrer)||"$direct"},referringDomain:function(){var e;return null!=E&&E.referrer&&(null===(e=st(E.referrer))||void 0===e?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},initialPersonInfo:function(){return{r:this.referrer(),u:null==x?void 0:x.href}},initialPersonPropsFromInfo:function(e){var t;const{r:i,u:s}=e,n={$initial_referrer:i,$initial_referring_domain:null==i?void 0:"$direct"==i?"$direct":null===(t=st(i))||void 0===t?void 0:t.host};if(s){n.$initial_current_url=s;const e=st(s);n.$initial_host=null==e?void 0:e.host,n.$initial_pathname=null==e?void 0:e.pathname;L(this._campaignParamsFromUrl(s),(function(e,t){n["$initial_"+U(t)]=e}))}if(i){L(this._searchInfoFromReferrer(i),(function(e,t){n["$initial_"+U(t)]=e}))}return n},properties:function(){if(!R)return{};const[t,i]=ri.os(R);return O(H({$os:t,$os_version:i,$browser:ri.browser(R,navigator.vendor),$device:ri.device(R),$device_type:ri.deviceType(R)}),{$current_url:null==x?void 0:x.href,$host:null==x?void 0:x.host,$pathname:null==x?void 0:x.pathname,$raw_user_agent:R.length>1e3?R.substring(0,997)+"...":R,$browser_version:ri.browserVersion(R,navigator.vendor),$browser_language:ri.browserLanguage(),$screen_height:null==v?void 0:v.screen.height,$screen_width:null==v?void 0:v.screen.width,$viewport_height:null==v?void 0:v.innerHeight,$viewport_width:null==v?void 0:v.innerWidth,$lib:"web",$lib_version:e.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!R)return{};const[e,t]=ri.os(R);return O(H({$os:e,$os_version:t,$browser:ri.browser(R,navigator.vendor)}),{$browser_version:ri.browserVersion(R,navigator.vendor)})}},oi=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class ai{constructor(e){this.config=e,this.props={},this.campaign_params_saved=!1,this.name=(e=>{let 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&&T.info("Persistence loaded",e.persistence,{...this.props}),this.update_config(e,e),this.save()}buildStorage(e){let t;-1===oi.indexOf(e.persistence.toLowerCase())&&(T.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const i=e.persistence.toLowerCase();return t="localstorage"===i&&Je.is_supported()?Je:"localstorage+cookie"===i&&Xe.is_supported()?Xe:"sessionstorage"===i&&tt.is_supported()?tt:"memory"===i?Ze:"cookie"===i?je:Xe.is_supported()?Xe:je,t}properties(){const e={};return L(this.props,(function(t,i){if(i===ge&&a(t)){const i=Object.keys(t);for(let s=0;s<i.length;s++)e[`$feature/${i[s]}`]=t[i[s]]}else(function(e,t){let i=!1;return h(e)?i:w&&e.indexOf===w?-1!=e.indexOf(t):(L(e,(function(e){if(i||(i=e===t))return C})),i)})(Pe,i)||(e[i]=t)})),e}load(){if(this.disabled)return;const e=this.storage.parse(this.name);e&&(this.props=O({},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(a(e)){c(t)&&(t="None"),this.expire_days=c(i)?this.default_expiry:i;let s=!1;if(L(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(a(e)){this.expire_days=c(t)?this.default_expiry:t;let i=!1;if(L(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(){this.campaign_params_saved||(this.register(ri.campaignParams(this.config.custom_campaign_params)),this.campaign_params_saved=!0)}update_search_keyword(){this.register(ri.searchInfo())}update_referrer_info(){this.register_once(ri.referrerInfo(),void 0)}set_initial_person_info(){this.props[xe]||this.props[ke]||this.register_once({[Ie]:ri.initialPersonInfo()},void 0)}get_referrer_info(){return H({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){const e={};L([ke,xe],(t=>{const i=this.props[t];i&&L(i,(function(t,i){e["$initial_"+U(i)]=t}))}));const t=this.props[Ie];if(t){const i=ri.initialPersonPropsFromInfo(t);O(e,i)}return e}safe_merge(e){return L(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t){if(this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){const t=this.buildStorage(e),i=this.props;this.clear(),this.storage=t,this.props=i,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())}get_cross_subdomain(){return!!this.cross_subdomain}set_secure(e){e!==this.secure&&(this.secure=e,this.remove(),this.save())}set_event_timer(e,t){const i=this.props[X]||{};i[e]=t,this.props[X]=i,this.save()}remove_event_timer(e){const t=(this.props[X]||{})[e];return c(t)||(delete this.props[X][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}function li(e){var t;return(null===(t=JSON.stringify(e,function(){const e=[];return function(t,i){if(a(i)){for(;e.length>0&&e.at(-1)!==this;)e.pop();return e.includes(i)?"[Circular]":(e.push(i),i)}return i}}()))||void 0===t?void 0:t.length)||0}function ci(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6606028.8;if(e.size>=t&&e.data.length>1){const t=Math.floor(e.data.length/2),i=e.data.slice(0,t),s=e.data.slice(t);return[ci({size:li(i),data:i,sessionId:e.sessionId,windowId:e.windowId}),ci({size:li(s),data:s,sessionId:e.sessionId,windowId:e.windowId})].flatMap((e=>e))}return[e]}var ui=(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))(ui||{}),di=(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))(di||{});function hi(e){return e?M(e).split(/\s+/):[]}function pi(e){const t=null==v?void 0:v.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function gi(e){let 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 hi(t)}function _i(e){return p(e)?null:M(e).split(/(\s+)/).filter((e=>Mi(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function fi(e){let t="";return ki(e)&&!Ii(e)&&e.childNodes&&e.childNodes.length&&L(e.childNodes,(function(e){var i;yi(e)&&e.textContent&&(t+=null!==(i=_i(e.textContent))&&void 0!==i?i:"")})),M(t)}function vi(e){return c(e.target)?e.srcElement||null:null!==(t=e.target)&&void 0!==t&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}function mi(e){return!!e&&1===e.nodeType}function bi(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function yi(e){return!!e&&3===e.nodeType}function wi(e){return!!e&&11===e.nodeType}const Si=["a","button","form","input","select","textarea","label"];function Ei(e){const t=e.parentNode;return!(!t||!mi(t))&&t}function xi(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;if(!v||!e||bi(e,"html")||!mi(e))return!1;if(null!=i&&i.url_allowlist&&!pi(i.url_allowlist))return!1;if(null!=i&&i.url_ignorelist&&pi(i.url_ignorelist))return!1;if(null!=i&&i.dom_event_allowlist){const e=i.dom_event_allowlist;if(e&&!e.some((e=>t.type===e)))return!1}let r=!1;const o=[e];let a=!0,l=e;for(;l.parentNode&&!bi(l,"body");)if(wi(l.parentNode))o.push(l.parentNode.host),l=l.parentNode.host;else{if(a=Ei(l),!a)break;if(s||Si.indexOf(a.tagName.toLowerCase())>-1)r=!0;else{const e=v.getComputedStyle(a);e&&"pointer"===e.getPropertyValue("cursor")&&(r=!0)}o.push(a),l=a}if(!function(e,t){const i=null==t?void 0:t.element_allowlist;if(c(i))return!0;for(const t of e)if(i.some((e=>t.tagName.toLowerCase()===e)))return!0;return!1}(o,i))return!1;if(!function(e,t){const i=null==t?void 0:t.css_selector_allowlist;if(c(i))return!0;for(const t of e)if(i.some((e=>t.matches(e))))return!0;return!1}(o,i))return!1;const u=v.getComputedStyle(e);if(u&&"pointer"===u.getPropertyValue("cursor")&&"click"===t.type)return!0;const d=e.tagName.toLowerCase();switch(d){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 r?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(Si.indexOf(d)>-1||"true"===e.getAttribute("contenteditable"))}}function ki(e){for(let t=e;t.parentNode&&!bi(t,"body");t=t.parentNode){const e=gi(t);if(D(e,"ph-sensitive")||D(e,"ph-no-capture"))return!1}if(D(gi(e),"ph-include"))return!0;const t=e.type||"";if(u(t))switch(t.toLowerCase()){case"hidden":case"password":return!1}const i=e.name||e.id||"";if(u(i)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function Ii(e){return!!(bi(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||bi(e,"select")||bi(e,"textarea")||"true"===e.getAttribute("contenteditable"))}const Fi="(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})",Ri=new RegExp(`^(?:${Fi})$`),Pi=new RegExp(Fi),$i="\\d{3}-?\\d{2}-?\\d{4}",Ti=new RegExp(`^(${$i})$`),Ci=new RegExp(`(${$i})`);function Mi(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(p(e))return!1;if(u(e)){e=M(e);if((t?Ri:Pi).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Ti:Ci).test(e))return!1}return!0}function Ai(e){let t=fi(e);return t=`${t} ${Li(e)}`.trim(),Mi(t)?t:""}function Li(e){let t="";return e&&e.childNodes&&e.childNodes.length&&L(e.childNodes,(function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{const i=fi(e);t=`${t} ${i}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${Li(e)}`.trim())}catch(e){T.error(e)}})),t}function Oi(e){return function(e){const t=e.map((e=>{var t,i;let s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class){e.attr_class.sort();for(const t of e.attr_class)s+=`.${t.replace(/"/g,"")}`}const n={...e.text?{text:e.text}:{},"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0,...e.href?{href:e.href}:{},...e.attr_id?{attr_id:e.attr_id}:{},...e.attributes},r={};return N(n).sort(((e,t)=>{let[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{let[t,i]=e;return r[Di(t.toString())]=Di(i.toString())})),s+=":",s+=N(n).map((e=>{let[t,i]=e;return`${t}="${i}"`})).join(""),s}));return t.join(";")}(function(e){return e.map((e=>{var t,i;const s={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:Ni(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return N(e).filter((e=>{let[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{let[t,i]=e;return s.attributes[t]=i})),s}))}(e))}function Di(e){return e.replace(/"|\\"/g,'\\"')}function Ni(e){const t=e.attr__class;return t?r(t)?t:hi(t):void 0}const qi="[SessionRecording]",Bi="redacted",Hi={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"]},Ui=["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"],Wi=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],zi=["/s/","/e/","/i/"];function Vi(e,t,i,s){if(p(e))return e;let n=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return u(n)&&(n=parseInt(n)),n>i?qi+` ${s} body too large to record (${n} bytes)`:e}function Gi(e,t){if(p(e))return e;let i=e;return Mi(i,!1)||(i=qi+" "+t+" body "+Bi),L(Wi,(e=>{var s,n;null!==(s=i)&&void 0!==s&&s.length&&-1!==(null===(n=i)||void 0===n?void 0:n.indexOf(e))&&(i=qi+" "+t+" body "+Bi+" as might contain: "+e)})),i}const ji=(e,t)=>{const i={payloadSizeLimitBytes:Hi.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...Hi.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...Hi.payloadHostDenyList]},s=!1!==e.session_recording.recordHeaders&&t.recordHeaders,n=!1!==e.session_recording.recordBody&&t.recordBody,r=!1!==e.capture_performance&&t.recordPerformance,a=(e=>{var t;const i=Math.min(1e6,null!==(t=e.payloadSizeLimitBytes)&&void 0!==t?t:1e6);return e=>(null!=e&&e.requestBody&&(e.requestBody=Vi(e.requestBody,e.requestHeaders,i,"Request")),null!=e&&e.responseBody&&(e.responseBody=Vi(e.responseBody,e.responseHeaders,i,"Response")),e)})(i),l=e=>a((e=>{const t=st(e.name);if(!(t&&t.pathname&&zi.some((e=>0===t.pathname.indexOf(e)))))return e})((e=>{const t=e.requestHeaders;return p(t)||L(Object.keys(null!=t?t:{}),(e=>{Ui.includes(e.toLowerCase())&&(t[e]=Bi)})),e})(e))),u=o(e.session_recording.maskNetworkRequestFn);return u&&o(e.session_recording.maskCapturedNetworkRequestFn)&&T.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),u&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{const i=e.session_recording.maskNetworkRequestFn({url:t.name});return{...t,name:null==i?void 0:i.url}}),i.maskRequestFn=o(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,s,n;const r=l(t);return r&&null!==(i=null===(s=(n=e.session_recording).maskCapturedNetworkRequestFn)||void 0===s?void 0:s.call(n,r))&&void 0!==i?i:void 0}:e=>function(e){if(!c(e))return e.requestBody=Gi(e.requestBody,"Request"),e.responseBody=Gi(e.responseBody,"Response"),e}(l(e)),{...Hi,...i,recordHeaders:s,recordBody:n,recordPerformance:r,recordInitialRequests:r}};class Qi{bucketSize=100;refillRate=10;mutationBuckets={};loggedTracker={};constructor(e){var t,i;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.rrweb=e,this.options=s,this.refillRate=null!==(t=this.options.refillRate)&&void 0!==t?t:this.refillRate,this.bucketSize=null!==(i=this.options.bucketSize)&&void 0!==i?i:this.bucketSize,setInterval((()=>{this.refillBuckets()}),1e3)}refillBuckets=()=>{Object.keys(this.mutationBuckets).forEach((e=>{this.mutationBuckets[e]=this.mutationBuckets[e]+this.refillRate,this.mutationBuckets[e]>=this.bucketSize&&delete this.mutationBuckets[e]}))};getNodeOrRelevantParent=e=>{const t=this.rrweb.mirror.getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){const e=t.closest("svg");if(e)return[this.rrweb.mirror.getId(e),e]}return[e,t]};numberOfChanges=e=>{var t,i,s,n,r,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(s=null===(n=e.attributes)||void 0===n?void 0:n.length)&&void 0!==s?s:0)+(null!==(r=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==r?r:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)};throttleMutations=e=>{if(3!==e.type||0!==e.data.source)return e;const t=e.data,i=this.numberOfChanges(t);t.attributes&&(t.attributes=t.attributes.filter((e=>{var t;const[i,s]=this.getNodeOrRelevantParent(e.id);if(0===this.mutationBuckets[i])return!1;var n,r;(this.mutationBuckets[i]=null!==(t=this.mutationBuckets[i])&&void 0!==t?t:this.bucketSize,this.mutationBuckets[i]=Math.max(this.mutationBuckets[i]-1,0),0===this.mutationBuckets[i])&&(this.loggedTracker[i]||(this.loggedTracker[i]=!0,null===(n=(r=this.options).onBlockedNode)||void 0===n||n.call(r,i,s)));return e})));const s=this.numberOfChanges(t);return 0!==s||i===s?e:void 0}}var Ji=Uint8Array,Yi=Uint16Array,Xi=Uint32Array,Ki=new Ji([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]),Zi=new Ji([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]),es=new Ji([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ts=function(e,t){for(var i=new Yi(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var n=new Xi(i[30]);for(s=1;s<30;++s)for(var r=i[s];r<i[s+1];++r)n[r]=r-i[s]<<5|s;return[i,n]},is=ts(Ki,2),ss=is[0],ns=is[1];ss[28]=258,ns[258]=28;for(var rs=ts(Zi,0)[1],os=new Yi(32768),as=0;as<32768;++as){var ls=(43690&as)>>>1|(21845&as)<<1;ls=(61680&(ls=(52428&ls)>>>2|(13107&ls)<<2))>>>4|(3855&ls)<<4,os[as]=((65280&ls)>>>8|(255&ls)<<8)>>>1}var cs=function(e,t,i){for(var s=e.length,n=0,r=new Yi(t);n<s;++n)++r[e[n]-1];var o,a=new Yi(t);for(n=0;n<t;++n)a[n]=a[n-1]+r[n-1]<<1;if(i){o=new Yi(1<<t);var l=15-t;for(n=0;n<s;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],d=a[e[n]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)o[os[d]>>>l]=c}else for(o=new Yi(s),n=0;n<s;++n)o[n]=os[a[e[n]-1]++]>>>15-e[n];return o},us=new Ji(288);for(as=0;as<144;++as)us[as]=8;for(as=144;as<256;++as)us[as]=9;for(as=256;as<280;++as)us[as]=7;for(as=280;as<288;++as)us[as]=8;var ds=new Ji(32);for(as=0;as<32;++as)ds[as]=5;var hs=cs(us,9,0),ps=cs(ds,5,0),gs=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 Yi?Yi:e instanceof Xi?Xi:Ji)(i-t);return s.set(e.subarray(t,i)),s},fs=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},vs=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},ms=function(e,t){for(var i=[],s=0;s<e.length;++s)e[s]&&i.push({s:s,f:e[s]});var n=i.length,r=i.slice();if(!n)return[new Ji(0),0];if(1==n){var o=new Ji(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=r[0].s;for(s=1;s<n;++s)r[s].s>h&&(h=r[s].s);var p=new Yi(h+1),g=bs(i[u-1],p,0);if(g>t){s=0;var _=0,f=g-t,v=1<<f;for(r.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));s<n;++s){var m=r[s].s;if(!(p[m]>t))break;_+=v-(1<<g-p[m]),p[m]=t}for(_>>>=f;_>0;){var b=r[s].s;p[b]<t?_-=1<<t-p[b]++-1:++s}for(;s>=0&&_;--s){var y=r[s].s;p[y]==t&&(--p[y],++_)}g=t}return[new Ji(p),g]},bs=function(e,t,i){return-1==e.s?Math.max(bs(e.l,t,i+1),bs(e.r,t,i+1)):t[e.s]=i},ys=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Yi(++t),s=0,n=e[0],r=1,o=function(e){i[s++]=e},a=1;a<=t;++a)if(e[a]==n&&a!=t)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=e[a]}return[i.subarray(0,s),t]},ws=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Ss=function(e,t,i){var s=i.length,n=gs(t+2);e[n]=255&s,e[n+1]=s>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var r=0;r<s;++r)e[n+r+4]=i[r];return 8*(n+4+s)},Es=function(e,t,i,s,n,r,o,a,l,c,u){fs(t,u++,i),++n[256];for(var d=ms(n,15),h=d[0],p=d[1],g=ms(r,15),_=g[0],f=g[1],v=ys(h),m=v[0],b=v[1],y=ys(_),w=y[0],S=y[1],E=new Yi(19),x=0;x<m.length;++x)E[31&m[x]]++;for(x=0;x<w.length;++x)E[31&w[x]]++;for(var k=ms(E,7),I=k[0],F=k[1],R=19;R>4&&!I[es[R-1]];--R);var P,$,T,C,M=c+5<<3,A=ws(n,us)+ws(r,ds)+o,L=ws(n,h)+ws(r,_)+o+14+3*R+ws(E,I)+(2*E[16]+3*E[17]+7*E[18]);if(M<=A&&M<=L)return Ss(t,u,e.subarray(l,l+c));if(fs(t,u,1+(L<A)),u+=2,L<A){P=cs(h,p,0),$=h,T=cs(_,f,0),C=_;var O=cs(I,F,0);fs(t,u,b-257),fs(t,u+5,S-1),fs(t,u+10,R-4),u+=14;for(x=0;x<R;++x)fs(t,u+3*x,I[es[x]]);u+=3*R;for(var D=[m,w],N=0;N<2;++N){var q=D[N];for(x=0;x<q.length;++x){var B=31&q[x];fs(t,u,O[B]),u+=I[B],B>15&&(fs(t,u,q[x]>>>5&127),u+=q[x]>>>12)}}}else P=hs,$=us,T=ps,C=ds;for(x=0;x<a;++x)if(s[x]>255){B=s[x]>>>18&31;vs(t,u,P[B+257]),u+=$[B+257],B>7&&(fs(t,u,s[x]>>>23&31),u+=Ki[B]);var H=31&s[x];vs(t,u,T[H]),u+=C[H],H>3&&(vs(t,u,s[x]>>>5&8191),u+=Zi[H])}else vs(t,u,P[s[x]]),u+=$[s[x]];return vs(t,u,P[256]),u+$[256]},xs=new Xi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ks=function(){for(var e=new Xi(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Is=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=ks[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}},Fs=function(e,t,i,s,n){return function(e,t,i,s,n,r){var o=e.length,a=new Ji(s+o+5*(1+Math.floor(o/7e3))+n),l=a.subarray(s,a.length-n),c=0;if(!t||o<8)for(var u=0;u<=o;u+=65535){var d=u+65535;d<o?c=Ss(l,c,e.subarray(u,d)):(l[u]=r,c=Ss(l,c,e.subarray(u,o)))}else{for(var h=xs[t-1],p=h>>>13,g=8191&h,_=(1<<i)-1,f=new Yi(32768),v=new Yi(_+1),m=Math.ceil(i/3),b=2*m,y=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<b)&_},w=new Xi(25e3),S=new Yi(288),E=new Yi(32),x=0,k=0,I=(u=0,0),F=0,R=0;u<o;++u){var P=y(u),$=32767&u,T=v[P];if(f[$]=T,v[P]=$,F<=u){var C=o-u;if((x>7e3||I>24576)&&C>423){c=Es(e,l,0,w,S,E,k,I,R,u-R,c),I=x=k=0,R=u;for(var M=0;M<286;++M)S[M]=0;for(M=0;M<30;++M)E[M]=0}var A=2,L=0,O=g,D=$-T&32767;if(C>2&&P==y(u-D))for(var N=Math.min(p,C)-1,q=Math.min(32767,u),B=Math.min(258,C);D<=q&&--O&&$!=T;){if(e[u+A]==e[u+A-D]){for(var H=0;H<B&&e[u+H]==e[u+H-D];++H);if(H>A){if(A=H,L=D,H>N)break;var U=Math.min(D,H-2),W=0;for(M=0;M<U;++M){var z=u-D+M+32768&32767,V=z-f[z]+32768&32767;V>W&&(W=V,T=z)}}}D+=($=T)-(T=f[$])+32768&32767}if(L){w[I++]=268435456|ns[A]<<18|rs[L];var G=31&ns[A],j=31&rs[L];k+=Ki[G]+Zi[j],++S[257+G],++E[j],F=u+A,++x}else w[I++]=e[u],++S[e[u]]}}c=Es(e,l,r,w,S,E,k,I,R,u-R,c)}return _s(a,0,s+gs(c)+n)}(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,!n)},Rs=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},Ps=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&&Rs(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)}},$s=function(e){return 10+(e.filename&&e.filename.length+1||0)};function Ts(e,t){void 0===t&&(t={});var i=Is(),s=e.length;i.p(e);var n=Fs(e,t,$s(t),8),r=n.length;return Ps(n,t),Rs(n,r-8,i.d()),Rs(n,r-4,s),n}function Cs(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new Ji(e.length+(e.length>>>1)),n=0,r=function(e){s[n++]=e},o=0;o<i;++o){if(n+5>s.length){var a=new Ji(n+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);l<128||t?r(l):l<2048?(r(192|l>>>6),r(128|63&l)):l>55295&&l<57344?(r(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),r(128|l>>>12&63),r(128|l>>>6&63),r(128|63&l)):(r(224|l>>>12),r(128|l>>>6&63),r(128|63&l))}return _s(s,0,n)}const Ms=3e5,As=[di.MouseMove,di.MouseInteraction,di.Scroll,di.ViewportResize,di.Input,di.TouchMove,di.MediaInteraction,di.Drag],Ls=["trigger_activated","trigger_pending","trigger_disabled"],Os=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1}),Ds="[SessionRecording]";function Ns(e){return function(e,t){for(var i="",s=0;s<e.length;){var n=e[s++];n<128||t?i+=String.fromCharCode(n):n<224?i+=String.fromCharCode((31&n)<<6|63&e[s++]):n<240?i+=String.fromCharCode((15&n)<<12|(63&e[s++])<<6|63&e[s++]):(n=((15&n)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536,i+=String.fromCharCode(55296|n>>10,56320|1023&n))}return i}(Ts(Cs(JSON.stringify(e))),!0)}function qs(e){return e.type===ui.Custom&&"sessionIdle"===e.data.tag}class Bs{queuedRRWebEvents=[];isIdle=!1;_linkedFlagSeen=!1;_lastActivityTimestamp=Date.now();_linkedFlag=null;_removePageViewCaptureHook=void 0;_onSessionIdListener=void 0;_persistDecideOnSessionListener=void 0;_samplingSessionListener=void 0;_urlTriggers=[];_forceAllowLocalhostNetworkCapture=!1;get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get rrwebRecord(){var e,t;return null==P||null===(e=P.__PosthogExtensions__)||void 0===e||null===(t=e.rrweb)||void 0===t?void 0:t.record}get started(){return this._captureStarted}get sessionManager(){if(!this.instance.sessionManager)throw new Error(Ds+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var e,t;return"trigger_pending"===this.urlTriggerStatus?6e4:null!==(e=null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.full_snapshot_interval_millis)&&void 0!==e?e:Ms}get isSampled(){const e=this.instance.get_property(de);return _(e)?e:null}get sessionDuration(){var e,t;const i=null===(e=this.buffer)||void 0===e?void 0:e.data[(null===(t=this.buffer)||void 0===t?void 0:t.data.length)-1],{sessionStartTimestamp:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return i?i.timestamp-s:null}get isRecordingEnabled(){const e=!!this.instance.get_property(ne),t=!this.instance.config.disable_session_recording;return v&&e&&t}get isConsoleLogCaptureEnabled(){const e=!!this.instance.get_property(re),t=this.instance.config.enable_recording_console_log;return null!=t?t:e}get canvasRecording(){const e=this.instance.get_property(ae);return e&&e.fps&&e.quality?{enabled:e.enabled,fps:e.fps,quality:e.quality}:void 0}get networkPayloadCapture(){var e,t;const i=this.instance.get_property(oe),s={recordHeaders:null===(e=this.instance.config.session_recording)||void 0===e?void 0:e.recordHeaders,recordBody:null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.recordBody},n=(null==s?void 0:s.recordHeaders)||(null==i?void 0:i.recordHeaders),r=(null==s?void 0:s.recordBody)||(null==i?void 0:i.recordBody),o=a(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,l=!!(_(o)?o:null==i?void 0:i.capturePerformance);return n||r||l?{recordHeaders:n,recordBody:r,recordPerformance:l}:void 0}get sampleRate(){const e=this.instance.get_property(le);return g(e)?e:null}get minimumDuration(){const e=this.instance.get_property(ce);return g(e)?e:null}get status(){return this.receivedDecide?this.isRecordingEnabled?p(this._linkedFlag)||this._linkedFlagSeen?"trigger_pending"===this.urlTriggerStatus?"buffering":_(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var e,t;if(this.receivedDecide&&0===this._urlTriggers.length)return"trigger_disabled";const i=null===(e=this.instance)||void 0===e?void 0:e.get_property(pe);var s,n,r,o;return(null===(t=this.instance)||void 0===t?void 0:t.get_property(he))!==this.sessionId?(null===(s=this.instance)||void 0===s||null===(n=s.persistence)||void 0===n||n.unregister(he),null===(r=this.instance)||void 0===r||null===(o=r.persistence)||void 0===o||o.unregister(pe),"trigger_pending"):Ls.includes(i)?i:"trigger_pending"}set urlTriggerStatus(e){var t,i;null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({[he]:this.sessionId,[pe]:e})}constructor(e){if(this.instance=e,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw T.error(Ds+" started without valid sessionManager"),new Error(Ds+" started without valid sessionManager. This is a bug.");const{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=t,this.windowId=i,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&T.warn(Ds+` session_idle_threshold_ms (${this.sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this.sessionManager.sessionTimeoutMs}). Session will never be detected as idle`)}_onBeforeUnload=()=>{this._flushBuffer()};_onOffline=()=>{this._tryAddCustomEvent("browser offline",{})};_onOnline=()=>{this._tryAddCustomEvent("browser online",{})};_onVisibilityChange=()=>{if(null!=E&&E.visibilityState){const e="window "+E.visibilityState;this._tryAddCustomEvent(e,{})}};startIfEnabledOrStop(e){this.isRecordingEnabled?(this._startCapture(e),null==v||v.addEventListener("beforeunload",this._onBeforeUnload),null==v||v.addEventListener("offline",this._onOffline),null==v||v.addEventListener("online",this._onOnline),null==v||v.addEventListener("visibilitychange",this._onVisibilityChange),this._setupSampling(),p(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance._addCaptureHook((e=>{try{if("$pageview"===e){const e=v?this._maskUrl(v.location.href):"";if(!e)return;this._tryAddCustomEvent("$pageview",{href:e})}}catch(e){T.error("Could not add $pageview to rrweb session",e)}}))),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId(((e,t,i)=>{var s,n,r,o;i&&(this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),null===(s=this.instance)||void 0===s||null===(n=s.persistence)||void 0===n||n.unregister(he),null===(r=this.instance)||void 0===r||null===(o=r.persistence)||void 0===o||o.unregister(pe))})))):this.stopRecording()}stopRecording(){var e,t,i;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,null==v||v.removeEventListener("beforeunload",this._onBeforeUnload),null==v||v.removeEventListener("offline",this._onOffline),null==v||v.removeEventListener("online",this._onOnline),null==v||v.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),null===(e=this._removePageViewCaptureHook)||void 0===e||e.call(this),this._removePageViewCaptureHook=void 0,null===(t=this._onSessionIdListener)||void 0===t||t.call(this),this._onSessionIdListener=void 0,null===(i=this._samplingSessionListener)||void 0===i||i.call(this),this._samplingSessionListener=void 0,T.info(Ds+" stopped"))}makeSamplingDecision(e){var t;const i=this.sessionId!==e,s=this.sampleRate;var n;if(!g(s))return void(null===(n=this.instance.persistence)||void 0===n||n.register({[de]:null}));const r=this.isSampled;let o;const a=i||!_(r);if(a){o=Math.random()<s}else o=r;a&&(o?this._reportStarted("sampling"):T.warn(Ds+` 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)||void 0===t||t.register({[de]:o})}afterDecideResponse(e){var t,i,s,n;(this._persistDecideResponse(e),this._linkedFlag=(null===(t=e.sessionRecording)||void 0===t?void 0:t.linkedFlag)||null,null!==(i=e.sessionRecording)&&void 0!==i&&i.endpoint)&&(this._endpoint=null===(n=e.sessionRecording)||void 0===n?void 0:n.endpoint);if(this._setupSampling(),!p(this._linkedFlag)&&!this._linkedFlagSeen){const e=u(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,t=u(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags(((i,s)=>{const n=a(s)&&e in s,r=t?s[e]===t:n;if(r){const i={linkedFlag:e,linkedVariant:t},s="linked flag matched";T.info(Ds+" "+s,i),this._tryAddCustomEvent(s,i),this._reportStarted("linked_flag_match")}this._linkedFlagSeen=r}))}null!==(s=e.sessionRecording)&&void 0!==s&&s.urlTriggers&&(this._urlTriggers=e.sessionRecording.urlTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){g(this.sampleRate)&&p(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId((e=>{this.makeSamplingDecision(e)})))}_persistDecideResponse(e){if(this.instance.persistence){var t;const i=this.instance.persistence,s=()=>{var t,s,n,r,o,a,l;const u=null===(t=e.sessionRecording)||void 0===t?void 0:t.sampleRate,d=p(u)?null:parseFloat(u),h=null===(s=e.sessionRecording)||void 0===s?void 0:s.minimumDurationMilliseconds;i.register({[ne]:!!e.sessionRecording,[re]:null===(n=e.sessionRecording)||void 0===n?void 0:n.consoleLogRecordingEnabled,[oe]:{capturePerformance:e.capturePerformance,...null===(r=e.sessionRecording)||void 0===r?void 0:r.networkPayloadCapture},[ae]:{enabled:null===(o=e.sessionRecording)||void 0===o?void 0:o.recordCanvas,fps:null===(a=e.sessionRecording)||void 0===a?void 0:a.canvasFps,quality:null===(l=e.sessionRecording)||void 0===l?void 0:l.canvasQuality},[le]:d,[ce]:c(h)?null:h})};s(),null===(t=this._persistDecideOnSessionListener)||void 0===t||t.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(s)}}log(e){var t;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"log";null===(t=this.instance.sessionRecording)||void 0===t||t.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:i,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}_startCapture(e){if(!c(Object.assign)&&!c(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var t,i;if(this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),this.rrwebRecord)this._onScriptLoaded();else null===(t=P.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"recorder",(e=>{if(e)return T.error(Ds+" could not load recorder",e);this._onScriptLoaded()}));T.info(Ds+" starting"),"active"===this.status&&this._reportStarted(e||"recording_initialized")}}isInteractiveEvent(e){var t;return 3===e.type&&-1!==As.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){const t=this.isInteractiveEvent(e);if(!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())}let i=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)),this.isIdle)return;const{windowId:s,sessionId:n}=this.sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),r=this.sessionId!==n,o=this.windowId!==s;this.windowId=s,this.sessionId=n,r||o?(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}):T.warn(Ds+" could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(Os((()=>this.rrwebRecord.addCustomEvent(e,t))))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(Os((()=>this.rrwebRecord.takeFullSnapshot())))}_onScriptLoaded(){var e;const t={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},i=this.instance.config.session_recording;for(const[e,s]of Object.entries(i||{}))e in t&&("maskInputOptions"===e?t.maskInputOptions={password:!0,...s}:t[e]=s);if(this.canvasRecording&&this.canvasRecording.enabled&&(t.recordCanvas=!0,t.sampling={canvas:this.canvasRecording.fps},t.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),!this.rrwebRecord)return void T.error(Ds+"onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.");this.mutationRateLimiter=null!==(e=this.mutationRateLimiter)&&void 0!==e?e:new Qi(this.rrwebRecord,{onBlockedNode:(e,t)=>{const i=`Too many mutations on node '${e}'. Rate limiting. This could be due to SVG animations or something similar`;T.info(i,{node:t}),this.log(Ds+" "+i,"warn")}});const s=this._gatherRRWebPlugins();this.stopRrweb=this.rrwebRecord({emit:e=>{this.onRRwebEmit(e)},plugins:s,...t}),this._lastActivityTimestamp=Date.now(),this.isIdle=!1,this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:t,activePlugins:s.map((e=>null==e?void 0:e.name))}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),this.isIdle)return;const e=this.fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval((()=>{this._tryTakeFullSnapshot()}),e))}_gatherRRWebPlugins(){var e,t,i,s;const n=[],r=null===(e=P.__PosthogExtensions__)||void 0===e||null===(t=e.rrwebPlugins)||void 0===t?void 0:t.getRecordConsolePlugin;r&&this.isConsoleLogCaptureEnabled&&n.push(r());const a=null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.rrwebPlugins)||void 0===s?void 0:s.getRecordNetworkPlugin;if(this.networkPayloadCapture&&o(a)){!it.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?n.push(a(ji(this.instance.config,this.networkPayloadCapture))):T.info(Ds+" NetworkCapture not started because we are on localhost.")}return n}onRRwebEmit(e){var t;if(this._processQueuedEvents(),!e||!a(e))return;if(e.type===ui.Meta){const t=this._maskUrl(e.data.href);if(this._lastHref=t,!t)return;e.data.href=t}else this._pageViewFallBack();this._checkUrlTrigger(),e.type===ui.FullSnapshot&&this._scheduleFullSnapshot(),e.type===ui.FullSnapshot&&"trigger_pending"===this.urlTriggerStatus&&this.clearBuffer();const i=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(e):e;if(!i)return;const s=function(e){const t=e;if(t&&a(t)&&6===t.type&&a(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]"));const i=[];for(let e=0;e<t.data.payload.payload.length;e++)t.data.payload.payload[e]&&t.data.payload.payload[e].length>2e3?i.push(t.data.payload.payload[e].slice(0,2e3)+"...[truncated]"):i.push(t.data.payload.payload[e]);return t.data.payload.payload=i,e}return e}(i);if(this._updateWindowAndSessionIds(s),this.isIdle&&!qs(s))return;if(qs(s)){const e=s.data.payload;if(e){const t=e.lastActivityTimestamp,i=e.threshold;s.timestamp=t+i}}const n=null===(t=this.instance.config.session_recording.compress_events)||void 0===t||t?function(e){if(li(e)<1024)return e;try{if(e.type===ui.FullSnapshot)return{...e,data:Ns(e.data),cv:"2024-10"};if(e.type===ui.IncrementalSnapshot&&e.data.source===di.Mutation)return{...e,cv:"2024-10",data:{...e.data,texts:Ns(e.data.texts),attributes:Ns(e.data.attributes),removes:Ns(e.data.removes),adds:Ns(e.data.adds)}};if(e.type===ui.IncrementalSnapshot&&e.data.source===di.StyleSheetRule)return{...e,cv:"2024-10",data:{...e.data,adds:Ns(e.data.adds),removes:Ns(e.data.removes)}}}catch(e){T.error(Ds+" could not compress event - will use uncompressed event",e)}return e}(s):s,r={$snapshot_bytes:li(n),$snapshot_data:n,$session_id:this.sessionId,$window_id:this.windowId};"disabled"!==this.status?this._captureSnapshotBuffered(r):this.clearBuffer()}_pageViewFallBack(){if(this.instance.config.capture_pageview||!v)return;const e=this._maskUrl(v.location.href);this._lastHref!==e&&(this._tryAddCustomEvent("$url_changed",{href:e}),this._lastHref=e)}_processQueuedEvents(){if(this.queuedRRWebEvents.length){const e=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],e.forEach((e=>{Date.now()-e.enqueuedAt<=2e3&&this._tryRRWebMethod(e)}))}}_maskUrl(e){const t=this.instance.config.session_recording;if(t.maskNetworkRequestFn){var i;let s={url:e};return s=t.maskNetworkRequestFn(s),null===(i=s)||void 0===i?void 0:i.url}return e}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);const e=this.minimumDuration,t=this.sessionDuration,i=g(t)&&t>=0,s=g(e)&&i&&t<e;if("buffering"===this.status||s)return this.flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3),this.buffer;if(this.buffer.data.length>0){ci(this.buffer).forEach((e=>{this._captureSnapshot({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId})}))}return this.clearBuffer()}_captureSnapshotBuffered(e){var t;const i=2+((null===(t=this.buffer)||void 0===t?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})}_checkUrlTrigger(){if(void 0===v||!v.location.href)return;const e=v.location.href;this._urlTriggers.some((t=>"regex"===t.matching&&new RegExp(t.url).test(e)))&&this._activateUrlTrigger()}_activateUrlTrigger(){"trigger_pending"===this.urlTriggerStatus&&(this.urlTriggerStatus="trigger_activated",this._tryAddCustomEvent("url trigger activated",{}),this._flushBuffer(),T.info(Ds+" recording triggered by URL pattern match"))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._reportStarted("linked_flag_override")}overrideSampling(){var e;null===(e=this.instance.persistence)||void 0===e||e.register({[de]:!0}),this._reportStarted("sampling_override")}_reportStarted(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>!0)()&&this.instance.register_for_session({$session_recording_start_reason:e})}}class Hs{constructor(e){this.instance=e,this.instance.decideEndpointWasHit=this.instance._hasBootstrappedFeatureFlags()}call(){const e={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),person_properties:this.instance.get_property(fe),group_properties:this.instance.get_property(ve),disable_flags:this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load||void 0};this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:e,compression:this.instance.config.disable_compression?void 0:Q.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:e=>this.parseDecideResponse(e.json)})}parseDecideResponse(e){this.instance.featureFlags.setReloadingPaused(!1),this.instance.featureFlags._startReloadTimer();const t=!e;if(this.instance.config.advanced_disable_feature_flags_on_first_load||this.instance.config.advanced_disable_feature_flags||this.instance.featureFlags.receivedFeatureFlags(null!=e?e:{},t),t)T.error("Failed to fetch feature flags from PostHog.");else{if(!E||!E.body)return T.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.parseDecideResponse(e)}),500);if(this.instance._afterDecideResponse(e),e.siteApps)if(this.instance.config.opt_in_site_apps)for(const{id:t,url:r}of e.siteApps){var i,s,n;P[`__$$ph_site_app_${t}`]=this.instance,null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=(n=i).loadSiteApp)||void 0===s||s.call(n,this.instance,r,(e=>{if(e)return T.error(`Error while initializing PostHog app with config id ${t}`,e)}))}else e.siteApps.length>0&&T.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}const Us=null!=v&&v.location?at(v.location.hash,"__posthog")||at(location.hash,"state"):null,Ws="_postHogToolbarParams";var zs;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"}(zs||(zs={}));class Vs{constructor(e){this.instance=e}setToolbarState(e){P.ph_toolbar_state=e}getToolbarState(){var e;return null!==(e=P.ph_toolbar_state)&&void 0!==e?e:zs.UNINITIALIZED}maybeLoadToolbar(){var e,t;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if(!v||!E)return!1;i=null!==(e=i)&&void 0!==e?e:v.location,n=null!==(t=n)&&void 0!==t?t:v.history;try{if(!s){try{v.localStorage.setItem("test","test"),v.localStorage.removeItem("test")}catch{return!1}s=null==v?void 0:v.localStorage}const e=Us||at(i.hash,"__posthog")||at(i.hash,"state");let t;const r=e?q((()=>JSON.parse(atob(decodeURIComponent(e)))))||q((()=>JSON.parse(decodeURIComponent(e)))):null;return r&&"ph_authorize"===r.action?(t=r,t.source="url",t&&Object.keys(t).length>0&&(r.desiredHash?i.hash=r.desiredHash:n?n.replaceState(n.state,"",i.pathname+i.search):i.hash="")):(t=JSON.parse(s.getItem(Ws)||"{}"),t.source="localstorage",delete t.userIntent),!(!t.token||this.instance.config.token!==t.token)&&(this.loadToolbar(t),!0)}catch{return!1}}_callLoadToolbar(e){(P.ph_load_toolbar||P.ph_load_editor)(e,this.instance)}loadToolbar(e){const t=!(null==E||!E.getElementById(Re));if(!v||t)return!1;const i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s={token:this.instance.config.token,...e,apiURL:this.instance.requestRouter.endpointFor("ui"),...i?{instrument:!1}:{}};if(v.localStorage.setItem(Ws,JSON.stringify({...s,source:void 0})),this.getToolbarState()===zs.LOADED)this._callLoadToolbar(s);else if(this.getToolbarState()===zs.UNINITIALIZED){var n,r;this.setToolbarState(zs.LOADING),null===(n=P.__PosthogExtensions__)||void 0===n||null===(r=n.loadExternalDependency)||void 0===r||r.call(n,this.instance,"toolbar",(e=>{if(e)return T.error("Failed to load toolbar",e),void this.setToolbarState(zs.UNINITIALIZED);this.setToolbarState(zs.LOADED),this._callLoadToolbar(s)})),V(v,"turbolinks:load",(()=>{this.setToolbarState(zs.UNINITIALIZED),this.loadToolbar(s)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return this.maybeLoadToolbar(e,t,i)}}class Gs{isPaused=!0;queue=[];flushTimeoutMs=3e3;constructor(e){this.sendRequest=e}enqueue(e){this.queue.push(e),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();const 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({...e,transport:"sendBeacon"})}))}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){this.isPaused||(this.flushTimeout=setTimeout((()=>{if(this.clearFlushTimeout(),this.queue.length>0){const e=this.formatQueue();for(const t in e){const i=e[t],s=(new Date).getTime();i.data&&r(i.data)&&L(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),this.sendRequest(i)}}}),this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){const e={};return L(this.queue,(t=>{var i;const s=t,n=(s?s.batchKey:null)||s.url;c(e[n])&&(e[n]={...s,data:[]}),null===(i=e[n].data)||void 0===i||i.push(s.data)})),this.queue=[],e}}const js=!!I||!!k,Qs="text/plain",Js=(e,t)=>{const[i,s]=e.split("?"),n={...t};null==s||s.split("&").forEach((e=>{const[t]=e.split("=");delete n[t]}));let r=rt(n);return r=r?(s?s+"&":"")+r:s,`${i}?${r}`},Ys=e=>{let{data:t,compression:i}=e;if(!t)return;if(i===Q.GZipJS){const e=Ts(Cs(JSON.stringify(t)),{mtime:0}),i=new Blob([e],{type:Qs});return{contentType:Qs,body:i,estimatedSize:i.size}}if(i===Q.Base64){const e=function(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let i,s,n,r,o,a,l,c,u=0,d=0,h="";const p=[];if(!e)return e;e=z(e);do{i=e.charCodeAt(u++),s=e.charCodeAt(u++),n=e.charCodeAt(u++),c=i<<16|s<<8|n,r=c>>18&63,o=c>>12&63,a=c>>6&63,l=63&c,p[d++]=t.charAt(r)+t.charAt(o)+t.charAt(a)+t.charAt(l)}while(u<e.length);switch(h=p.join(""),e.length%3){case 1:h=h.slice(0,-2)+"==";break;case 2:h=h.slice(0,-1)+"="}return h}(JSON.stringify(t)),i=(e=>"data="+encodeURIComponent("string"==typeof e?e:JSON.stringify(e)))(e);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}const s=JSON.stringify(t);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},Xs=e=>{var t;const i=new I;i.open(e.method||"GET",e.url,!0);const{contentType:s,body:n}=null!==(t=Ys(e))&&void 0!==t?t:{};L(e.headers,(function(e,t){i.setRequestHeader(t,e)})),s&&i.setRequestHeader("Content-Type",s),e.timeout&&(i.timeout=e.timeout),i.withCredentials=!0,i.onreadystatechange=()=>{if(4===i.readyState){var t;const s={statusCode:i.status,text:i.responseText};if(200===i.status)try{s.json=JSON.parse(i.responseText)}catch{}null===(t=e.callback)||void 0===t||t.call(e,s)}},i.send(n)},Ks=e=>{var t,i;const{contentType:s,body:n,estimatedSize:r}=null!==(t=Ys(e))&&void 0!==t?t:{},o=new Headers;L(e.headers,(function(e,t){o.append(t,e)})),s&&o.append("Content-Type",s);const a=e.url;let l=null;if(F){const t=new F;l={signal:t.signal,timeout:setTimeout((()=>t.abort()),e.timeout)}}k(a,{method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(r||0)<65536,body:n,signal:null===(i=l)||void 0===i?void 0:i.signal}).then((t=>t.text().then((i=>{var s;const n={statusCode:t.status,text:i};if(200===t.status)try{n.json=JSON.parse(i)}catch(e){T.error(e)}null===(s=e.callback)||void 0===s||s.call(e,n)})))).catch((t=>{var i;T.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,text:t})})).finally((()=>l?clearTimeout(l.timeout):null))},Zs=e=>{const t=Js(e.url,{beacon:"1"});try{var i;const{contentType:s,body:n}=null!==(i=Ys(e))&&void 0!==i?i:{},r="string"==typeof n?new Blob([n],{type:s}):n;S.sendBeacon(t,r)}catch{}},en=[];I&&en.push({transport:"XHR",method:Xs}),k&&en.push({transport:"fetch",method:Ks}),null!=S&&S.sendBeacon&&en.push({transport:"sendBeacon",method:Zs});class tn{isPolling=!1;pollIntervalMs=3e3;queue=[];constructor(e){this.instance=e,this.queue=[],this.areWeOnline=!0,!c(v)&&"onLine"in v.navigator&&(this.areWeOnline=v.navigator.onLine,v.addEventListener("online",(()=>{this.areWeOnline=!0,this.flush()})),v.addEventListener("offline",(()=>{this.areWeOnline=!1})))}retriableRequest(e){let{retriesPerformedSoFar:t,...i}=e;g(t)&&t>0&&(i.url=Js(i.url,{retry_count:t})),this.instance._send_request({...i,callback:e=>{var s;200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this.enqueue({retriesPerformedSoFar:t,...i}):null===(s=i.callback)||void 0===s||s.call(i,e)}})}enqueue(e){const t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;const i=function(e){const t=3e3*2**e,i=t/2,s=Math.min(18e5,t),n=(Math.random()-.5)*(s-i);return Math.ceil(s+n)}(t),s=Date.now()+i;this.queue.push({retryAt:s,requestOptions:e});let n=`Enqueued failed request for retry in ${i}`;navigator.onLine||(n+=" (Browser is offline)"),T.warn(n),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(){const e=Date.now(),t=[],i=this.queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this.queue=t,i.length>0)for(const{requestOptions:e}of i)this.retriableRequest(e)}unload(){this.poller&&(clearTimeout(this.poller),this.poller=void 0);for(const{requestOptions:e}of this.queue)try{this.instance._send_request({...e,transport:"sendBeacon"})}catch(e){T.error(e)}this.queue=[]}}const sn=1800;class nn{_sessionIdChangedHandlers=[];constructor(e,t,i,s){var n;this.config=e,this.persistence=t,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=i||He,this._windowIdGenerator=s||He;const r=e.persistence_name||e.token;let o=e.session_idle_timeout_seconds||sn;if(g(o)?o>sn?T.warn("session_idle_timeout_seconds cannot be greater than 30 minutes. Using 30 minutes instead."):o<60&&T.warn("session_idle_timeout_seconds cannot be less than 60 seconds. Using 60 seconds instead."):(T.warn("session_idle_timeout_seconds must be a number. Defaulting to 30 minutes."),o=sn),this._sessionTimeoutMs=1e3*Math.min(Math.max(o,60),sn),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){const e=tt.parse(this._window_id_storage_key),t=tt.parse(this._primary_window_exists_storage_key);e&&!t?this._windowId=e:tt.remove(this._window_id_storage_key),tt.set(this._primary_window_exists_storage_key,!0)}if(null!==(n=this.config.bootstrap)&&void 0!==n&&n.sessionID)try{const e=(e=>{const 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(),e)}catch(e){T.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return c(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&&tt.is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&tt.set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?tt.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({[ue]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];const e=this.persistence.props[ue];return r(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){null==v||v.addEventListener("beforeunload",(()=>{this._canUseSessionStorage()&&tt.remove(this._primary_window_exists_storage_key)}))}checkAndGetSessionAndWindowId(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||(new Date).getTime();let[i,s,n]=this._getSessionId(),r=this._getWindowId();const o=g(n)&&n>0&&Math.abs(t-n)>864e5;let a=!1;const l=!s,c=!e&&Math.abs(t-i)>this.sessionTimeoutMs;l||c||o?(s=this._sessionIdGenerator(),r=this._windowIdGenerator(),T.info("[SessionId] new session ID generated",{sessionId:s,windowId:r,changeReason:{noSessionId:l,activityTimeout:c,sessionPastMaximumLength:o}}),n=t,a=!0):r||(r=this._windowIdGenerator(),a=!0);const u=0===i||!e||o?t:i,d=0===n?(new Date).getTime():n;return this._setWindowId(r),this._setSessionId(s,u,d),a&&this._sessionIdChangedHandlers.forEach((e=>e(s,r,a?{noSessionId:l,activityTimeout:c,sessionPastMaximumLength:o}:void 0))),{sessionId:s,windowId:r,sessionStartTimestamp:d,changeReason:a?{noSessionId:l,activityTimeout:c,sessionPastMaximumLength:o}:void 0}}}let rn;!function(e){e.US="us",e.EU="eu",e.CUSTOM="custom"}(rn||(rn={}));const on="i.posthog.com";class an{_regionCache={};constructor(e){this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e;let t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${on}`,".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]=rn.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=rn.EU:this._regionCache[this.apiHost]=rn.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t&&(t="/"===t[0]?t:`/${t}`),"ui"===e)return this.uiHost+t;if(this.region===rn.CUSTOM)return this.apiHost+t;const i=on+t;switch(e){case"assets":return`https://${this.region}-assets.${i}`;case"api":return`https://${this.region}.${i}`}}}const ln="posthog-js";function cn(e){let{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=>{var o,a,l,c,u;if(!("*"===n||n.includes(r.level))||!e.__loaded)return r;r.tags||(r.tags={});const d=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);r.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(r.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const h=(null===(o=r.exception)||void 0===o?void 0:o.values)||[],p={$exception_message:(null===(a=h[0])||void 0===a?void 0:a.value)||r.message,$exception_type:null===(l=h[0])||void 0===l?void 0:l.type,$exception_personURL:d,$exception_level:r.level,$exception_list:h,$sentry_event_id:r.event_id,$sentry_exception:r.exception,$sentry_exception_message:(null===(c=h[0])||void 0===c?void 0:c.value)||r.message,$sentry_exception_type:null===(u=h[0])||void 0===u?void 0:u.type,$sentry_tags:r.tags,$level:r.level};return t&&i&&(p.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+r.event_id),e.exceptions.sendExceptionEvent(p),r}}class un{constructor(e,t,i,s,n){this.name=ln,this.setupOnce=function(r){r(cn(e,{organization:t,projectId:i,prefix:s,severityAllowList:n}))}}}function dn(e,t){const i=e.config.segment;if(!i)return t();!function(e,t){const i=e.config.segment;if(!i)return t();const s=i=>{const s=()=>i.anonymousId()||He();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(we,"identified")),t()},n=i.user();"then"in n&&o(n.then)?n.then((e=>s(e))):s(n)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||T.warn("This browser does not have Promise support, and can not use the segment integration");const t=(t,i)=>{var s;if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(T.info("Segment integration does not have a userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(T.info("Segment integration has a userId set, identifying with PostHog"),e.identify(t.event.userId));const n=e._calculate_event_properties(i,null!==(s=t.event.properties)&&void 0!==s?s:{},new Date);return t.event.properties=Object.assign({},n,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()}))}))}class hn{constructor(e){this._instance=e}doPageView(e){var t;const i=this._previousPageViewProperties(e);return this._currentPath=null!==(t=null==v?void 0:v.location.pathname)&&void 0!==t?t:"",this._instance.scrollManager.resetContext(),this._prevPageviewTimestamp=e,i}doPageLeave(e){return this._previousPageViewProperties(e)}_previousPageViewProperties(e){const t=this._currentPath,i=this._prevPageviewTimestamp,s=this._instance.scrollManager.getContext();if(!i)return{};let n={};if(s){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:i,maxContentHeight:r,lastContentY:o,maxContentY:a}=s;if(!(c(e)||c(t)||c(i)||c(r)||c(o)||c(a))){e=Math.ceil(e),t=Math.ceil(t),i=Math.ceil(i),r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a);n={$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:e<=1?1:pn(t/e,0,1),$prev_pageview_max_scroll:i,$prev_pageview_max_scroll_percentage:e<=1?1:pn(i/e,0,1),$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:r<=1?1:pn(o/r,0,1),$prev_pageview_max_content:a,$prev_pageview_max_content_percentage:r<=1?1:pn(a/r,0,1)}}}return t&&(n.$prev_pageview_pathname=t),i&&(n.$prev_pageview_duration=(e.getTime()-i.getTime())/1e3),n}}function pn(e,t,i){return Math.max(t,Math.min(e,i))}let gn,_n,fn;!function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(gn||(gn={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(_n||(_n={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(fn||(fn={}));class vn{events={};constructor(){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(const i of this.events[e]||[])i(t);for(const i of this.events["*"]||[])i(e,t)}}class mn{_debugEventEmitter=new vn;constructor(e){this.instance=e,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var e;if(!c(null===(e=this.instance)||void 0===e?void 0:e._addCaptureHook)){var t;const e=(e,t)=>{this.on(e,t)};null===(t=this.instance)||void 0===t||t._addCaptureHook(e)}}register(e){var t,i;if(!c(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null===(t=this.actionRegistry)||void 0===t||t.add(e),null===(i=e.steps)||void 0===i||i.forEach((e=>{var t;null===(t=this.actionEvents)||void 0===t||t.add((null==e?void 0:e.event)||"")}))})),null!==(i=this.instance)&&void 0!==i&&i.autocapture)){var s;const t=new Set;e.forEach((e=>{var i;null===(i=e.steps)||void 0===i||i.forEach((e=>{null!=e&&e.selector&&t.add(null==e?void 0:e.selector)}))})),null===(s=this.instance)||void 0===s||s.autocapture.setElementSelectors(t)}}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?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(const i of t.steps)if(this.checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}checkStep=(e,t)=>this.checkStepEvent(e,t)&&this.checkStepUrl(e,t)&&this.checkStepElement(e,t);checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event);checkStepUrl(e,t){if(null!=t&&t.url){var i;const s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!mn.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!!v&&nt(e,t);case"exact":return t===e;case"contains":const i=mn.escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return nt(e,i);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){if(!this.getElementsList(e).some((e=>!(null!=t&&t.href&&!mn.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&&!mn.matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!mn.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;const s=null==e||null===(i=e.properties)||void 0===i?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}}class bn{static SURVEY_SHOWN_EVENT_NAME="survey shown";constructor(e){this.instance=e,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(e){var t;c(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)||(this.setupEventBasedSurveys(e),this.setupActionBasedSurveys(e))}setupActionBasedSurveys(e){const t=e.filter((e=>{var t,i,s,n;return(null===(t=e.conditions)||void 0===t?void 0:t.actions)&&(null===(i=e.conditions)||void 0===i||null===(s=i.actions)||void 0===s||null===(n=s.values)||void 0===n?void 0:n.length)>0}));if(0!==t.length){if(null==this.actionMatcher){this.actionMatcher=new mn(this.instance),this.actionMatcher.init();const e=e=>{this.onAction(e)};this.actionMatcher._addActionHook(e)}t.forEach((e=>{var t,i,s,n,r,o,a,l,c,u;e.conditions&&null!==(t=e.conditions)&&void 0!==t&&t.actions&&null!==(i=e.conditions)&&void 0!==i&&null!==(s=i.actions)&&void 0!==s&&s.values&&(null===(n=e.conditions)||void 0===n||null===(r=n.actions)||void 0===r||null===(o=r.values)||void 0===o?void 0:o.length)>0&&(null===(a=this.actionMatcher)||void 0===a||a.register(e.conditions.actions.values),null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c||null===(u=c.values)||void 0===u||u.forEach((t=>{if(t&&t.name){const 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,s,n;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s||null===(n=s.values)||void 0===n?void 0:n.length)>0})).length)return;null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t,i,s;null===(t=e.conditions)||void 0===t||null===(i=t.events)||void 0===i||null===(s=i.values)||void 0===s||s.forEach((t=>{if(t&&t.name){const 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;const n=(null===(i=this.instance)||void 0===i||null===(s=i.persistence)||void 0===s?void 0:s.props[be])||[];if(bn.SURVEY_SHOWN_EVENT_NAME==e&&t&&n.length>0){var r;const e=null==t||null===(r=t.properties)||void 0===r?void 0:r.$survey_id;if(e){const t=n.indexOf(e);t>=0&&(n.splice(t,1),this._updateActivatedSurveys(n))}}else this.eventToSurveys.has(e)&&this._updateActivatedSurveys(n.concat(this.eventToSurveys.get(e)||[]))}onAction(e){var t,i;const s=(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i?void 0:i.props[be])||[];this.actionToSurveys.has(e)&&this._updateActivatedSurveys(s.concat(this.actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t,i;null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({[be]:[...new Set(e)]})}getSurveys(){var e,t;const i=null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t?void 0:t.props[be];return i||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}const yn="[Surveys]",wn={icontains:e=>!!v&&v.location.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:e=>!!v&&-1===v.location.href.toLowerCase().indexOf(e.toLowerCase()),regex:e=>!!v&&nt(v.location.href,e),not_regex:e=>!!v&&!nt(v.location.href,e),exact:e=>(null==v?void 0:v.location.href)===e,is_not:e=>(null==v?void 0:v.location.href)!==e};class Sn{constructor(e){this.instance=e,this._surveyEventReceiver=null}afterDecideResponse(e){this._decideServerResponse=!!e.surveys,this.loadIfEnabled()}loadIfEnabled(){var e;const t=null==P||null===(e=P.__PosthogExtensions__)||void 0===e?void 0:e.generateSurveys;var i,s;this.instance.config.disable_surveys||!this._decideServerResponse||t||(null==this._surveyEventReceiver&&(this._surveyEventReceiver=new bn(this.instance)),null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"surveys",(e=>{var t,i;if(e)return T.error(yn,"Could not load surveys script",e);this._surveyManager=null===(t=P.__PosthogExtensions__)||void 0===t||null===(i=t.generateSurveys)||void 0===i?void 0:i.call(t,this.instance)})))}getSurveys(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.instance.config.disable_surveys)return e([]);null==this._surveyEventReceiver&&(this._surveyEventReceiver=new bn(this.instance));const i=this.instance.get_property(me);if(i&&!t)return e(i);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api",`/api/surveys/?token=${this.instance.config.token}`),method:"GET",transport:"XHR",callback:t=>{var i;if(200!==t.statusCode||!t.json)return e([]);const s=t.json.surveys||[],n=s.filter((e=>{var t,i,s,n,r,o,a,l,c,u,d,h;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s?void 0:s.values)&&(null===(n=e.conditions)||void 0===n||null===(r=n.events)||void 0===r||null===(o=r.values)||void 0===o?void 0:o.length)>0||(null===(a=e.conditions)||void 0===a?void 0:a.actions)&&(null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c?void 0:c.values)&&(null===(u=e.conditions)||void 0===u||null===(d=u.actions)||void 0===d||null===(h=d.values)||void 0===h?void 0:h.length)>0}));var r;n.length>0&&(null===(r=this._surveyEventReceiver)||void 0===r||r.register(n));return null===(i=this.instance.persistence)||void 0===i||i.register({[me]:s}),e(s)}})}getActiveMatchingSurveys(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.getSurveys((t=>{var i;const s=t.filter((e=>!(!e.start_date||e.end_date))).filter((e=>{var t,i,s,n;if(!e.conditions)return!0;const r=null===(t=e.conditions)||void 0===t||!t.url||wn[null!==(i=null===(s=e.conditions)||void 0===s?void 0:s.urlMatchType)&&void 0!==i?i:"icontains"](e.conditions.url),o=null===(n=e.conditions)||void 0===n||!n.selector||(null==E?void 0:E.querySelector(e.conditions.selector));return r&&o})),n=null===(i=this._surveyEventReceiver)||void 0===i?void 0:i.getSurveys(),r=s.filter((e=>{var t,i,s,r,o,a,l,c,u,d;if(!e.linked_flag_key&&!e.targeting_flag_key&&!e.internal_targeting_flag_key)return!0;const h=!e.linked_flag_key||this.instance.featureFlags.isFeatureEnabled(e.linked_flag_key),p=!e.targeting_flag_key||this.instance.featureFlags.isFeatureEnabled(e.targeting_flag_key),g=(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s?void 0:s.values)&&(null===(r=e.conditions)||void 0===r||null===(o=r.events)||void 0===o?void 0:o.values.length)>0,_=(null===(a=e.conditions)||void 0===a?void 0:a.actions)&&(null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c?void 0:c.values)&&(null===(u=e.conditions)||void 0===u||null===(d=u.actions)||void 0===d?void 0:d.values.length)>0,f=!g&&!_||(null==n?void 0:n.includes(e.id)),v=this._canActivateRepeatedly(e),m=!(e.internal_targeting_flag_key&&!v)||this.instance.featureFlags.isFeatureEnabled(e.internal_targeting_flag_key);return h&&p&&m&&f}));return e(r)}),t)}getNextSurveyStep(e,t,i){var s;const n=e.questions[t],r=t+1;if(null===(s=n.branching)||void 0===s||!s.type)return t===e.questions.length-1?fn.End:r;if(n.branching.type===fn.End)return fn.End;if(n.branching.type===fn.SpecificQuestion){if(Number.isInteger(n.branching.index))return n.branching.index}else if(n.branching.type===fn.ResponseBased){if(n.type===_n.SingleChoice){var o,a;const e=n.choices.indexOf(`${i}`);if(null!==(o=n.branching)&&void 0!==o&&null!==(a=o.responseValues)&&void 0!==a&&a.hasOwnProperty(e)){const t=n.branching.responseValues[e];return Number.isInteger(t)?t:t===fn.End?fn.End:r}}else if(n.type===_n.Rating){var l,c;if("number"!=typeof i||!Number.isInteger(i))throw new Error("The response type must be an integer");const e=function(e,t){if(3===t){if(e<1||e>3)throw new Error("The response must be in range 1-3");return 1===e?"negative":2===e?"neutral":"positive"}if(5===t){if(e<1||e>5)throw new Error("The response must be in range 1-5");return e<=2?"negative":3===e?"neutral":"positive"}if(7===t){if(e<1||e>7)throw new Error("The response must be in range 1-7");return e<=3?"negative":4===e?"neutral":"positive"}if(10===t){if(e<0||e>10)throw new Error("The response must be in range 0-10");return e<=6?"detractors":e<=8?"passives":"promoters"}throw new Error("The scale must be one of: 3, 5, 7, 10")}(i,n.scale);if(null!==(l=n.branching)&&void 0!==l&&null!==(c=l.responseValues)&&void 0!==c&&c.hasOwnProperty(e)){const t=n.branching.responseValues[e];return Number.isInteger(t)?t:t===fn.End?fn.End:r}}return r}return T.warn(yn,"Falling back to next question index due to unexpected branching type"),r}_canActivateRepeatedly(e){var t;return p(null===(t=P.__PosthogExtensions__)||void 0===t?void 0:t.canActivateRepeatedly)?(T.warn(yn,"canActivateRepeatedly is not defined, must init before calling"),!1):P.__PosthogExtensions__.canActivateRepeatedly(e)}canRenderSurvey(e){p(this._surveyManager)?T.warn(yn,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys((t=>{const i=t.filter((t=>t.id===e))[0];this._surveyManager.canRenderSurvey(i)}))}renderSurvey(e,t){p(this._surveyManager)?T.warn(yn,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys((i=>{const s=i.filter((t=>t.id===e))[0];this._surveyManager.renderSurvey(s,null==E?void 0:E.querySelector(t))}))}}class En{serverLimits={};lastEventRateLimited=!1;constructor(e){var t,i;this.instance=e,this.captureEventsPerSecond=(null===(t=e.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null===(i=e.config.rate_limiting)||void 0===i?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var e,t,i;let s=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const n=(new Date).getTime(),r=null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_property(Ee))&&void 0!==e?e:{tokens:this.captureEventsBurstLimit,last:n};r.tokens+=(n-r.last)/1e3*this.captureEventsPerSecond,r.last=n,r.tokens>this.captureEventsBurstLimit&&(r.tokens=this.captureEventsBurstLimit);const o=r.tokens<1;return o||s||(r.tokens=Math.max(0,r.tokens-1)),!o||this.lastEventRateLimited||s||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===(i=this.instance.persistence)||void 0===i||i.set_property(Ee,r),{isRateLimited:o,remainingTokens:r.tokens}}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}checkForLimiting=e=>{const t=e.text;if(t&&t.length)try{const e=JSON.parse(t);(e.quota_limited||[]).forEach((e=>{T.info(`[RateLimiter] ${e||"events"} is quota limited.`),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void T.warn(`[RateLimiter] could not rate limit - continuing. Error: "${null==e?void 0:e.message}"`,{text:t})}}}const xn=()=>({initialPathName:(null==x?void 0:x.pathname)||"",referringDomain:ri.referringDomain(),...ri.campaignParams()});class kn{constructor(e,t,i){this._sessionIdManager=e,this._persistence=t,this._sessionSourceParamGenerator=i||xn,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStoredProps(){return this._persistence.props[Se]}_onSessionIdCallback=e=>{const t=this._getStoredProps();if(t&&t.sessionId===e)return;const i={sessionId:e,props:this._sessionSourceParamGenerator()};this._persistence.register({[Se]:i})};getSessionProps(){var e;const t=null===(e=this._getStoredProps())||void 0===e?void 0:e.props;return t?{$client_session_initial_referring_host:t.referringDomain,$client_session_initial_pathname:t.initialPathName,$client_session_initial_utm_source:t.utm_source,$client_session_initial_utm_campaign:t.utm_campaign,$client_session_initial_utm_medium:t.utm_medium,$client_session_initial_utm_content:t.utm_content,$client_session_initial_utm_term:t.utm_term}:{}}}const In=["ahrefsbot","ahrefssiteaudit","applebot","baiduspider","bingbot","bingpreview","bot.htm","bot.php","crawler","deepscan","duckduckbot","facebookexternal","facebookcatalog","gptbot","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","semrushbot","sitebulb","slurp","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","headlesschrome","cypress","Google-HotelAdsVerifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","Bytespider;"],Fn=function(e,t){if(!e)return!1;const i=e.toLowerCase();return In.concat(t||[]).some((e=>{const t=e.toLowerCase();return-1!==i.indexOf(t)}))},Rn=function(e,t){if(!e)return!1;const i=e.userAgent;if(i&&Fn(i,t))return!0;try{const i=null==e?void 0:e.userAgentData;if(null!=i&&i.brands&&i.brands.some((e=>Fn(null==e?void 0:e.brand,t))))return!0}catch{}return!!e.webdriver};class Pn{constructor(){this.clicks=[]}isRageClick(e,t,i){const 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}}function $n(e){var t;return e.id===Re||!(null===(t=e.closest)||void 0===t||!t.call(e,"#"+Re))}class Tn{rageclicks=new Pn;_enabledServerSide=!1;_initialized=!1;_flushInterval=null;constructor(e){var t;this.instance=e,this._enabledServerSide=!(null===(t=this.instance.persistence)||void 0===t||!t.props[Z]),null==v||v.addEventListener("beforeunload",(()=>{this.flush()}))}get flushIntervalMilliseconds(){let e=5e3;return a(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 c(this.instance.config.capture_heatmaps)?c(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;T.info("[heatmaps] starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this.getAndClearBuffer()}}afterDecideResponse(e){const t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Z]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){const e=this.buffer;return this.buffer=void 0,e}_setupListeners(){v&&E&&(V(E,"click",(e=>this._onClick(e||(null==v?void 0:v.event))),!1,!0),V(E,"mousemove",(e=>this._onMouseMove(e||(null==v?void 0:v.event))),!1,!0),this._initialized=!0)}_getProperties(e,t){const i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=function(e,t,i){let s=e;for(;s&&mi(s)&&!bi(s,"body");){if(s===i)return!1;if(D(t,null==v?void 0:v.getComputedStyle(s).position))return!0;s=Ei(s)}return!1}(vi(e),["fixed","sticky"],n);return{x:e.clientX+(r?0:s),y:e.clientY+(r?0:i),target_fixed:r,type:t}}_onClick(e){var t;if($n(e.target))return;const i=this._getProperties(e,"click");null!==(t=this.rageclicks)&&void 0!==t&&t.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture({...i,type:"rageclick"}),this._capture(i)}_onMouseMove(e){$n(e.target)||(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(!v)return;const t=v.location.href;this.buffer=this.buffer||{},this.buffer[t]||(this.buffer[t]=[]),this.buffer[t].push(e)}flush(){this.buffer&&!l(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Cn{constructor(e){this.instance=e}getContext(){return this.context}resetContext(){const e=this.context;return setTimeout(this._updateScrollData,0),e}_updateScrollData=()=>{var e,t,i,s;this.context||(this.context={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=r+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this.context.lastScrollY=Math.ceil(r),this.context.maxScrollY=Math.max(r,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)};startMeasuringScrollPosition(){null==v||v.addEventListener("scroll",this._updateScrollData,!0),null==v||v.addEventListener("scrollend",this._updateScrollData,!0),null==v||v.addEventListener("resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return null==v?void 0:v.document.documentElement;{const e=r(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(const t of e){const e=null==v?void 0:v.document.querySelector(t);if(e)return e}}}scrollY(){if(this.instance.config.scroll_root_selector){const e=this.scrollElement();return e&&e.scrollTop||0}return v&&(v.scrollY||v.pageYOffset||v.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){const e=this.scrollElement();return e&&e.scrollLeft||0}return v&&(v.scrollX||v.pageXOffset||v.document.documentElement.scrollLeft)||0}}const Mn="$copy_autocapture";function An(e,t){return t.length>e?t.slice(0,e)+"...":t}class Ln{_initialized=!1;_isDisabledServerSide=null;rageclicks=new Pn;_elementsChainAsString=!1;constructor(e){this.instance=e,this._elementSelectors=null}get config(){var e,t;const i=a(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null===(e=i.url_allowlist)||void 0===e?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null===(t=i.url_ignorelist)||void 0===t?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(!this.isBrowserSupported())return void T.info("Disabling Automatic Event Collection because this browser is not supported");if(!v||!E)return;const e=e=>{e=e||(null==v?void 0:v.event);try{this._captureEvent(e)}catch(e){T.error("Failed to capture event",e)}},t=e=>{e=e||(null==v?void 0:v.event),this._captureEvent(e,Mn)};V(E,"submit",e,!1,!0),V(E,"change",e,!1,!0),V(E,"click",e,!1,!0),this.config.capture_copied_text&&(V(E,"copy",t,!1,!0),V(E,"cut",t,!1,!0))}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}afterDecideResponse(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[K]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t;const i=[];return null===(t=this._elementSelectors)||void 0===t||t.forEach((t=>{const s=null==E?void 0:E.querySelectorAll(t);null==s||s.forEach((s=>{e===s&&i.push(t)}))})),i}get isEnabled(){var e,t;const i=null===(e=this.instance.persistence)||void 0===e?void 0:e.props[K],s=this._isDisabledServerSide;if(h(s)&&!_(i)&&!this.instance.config.advanced_disable_decide)return!1;const n=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!n}_previousElementSibling(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do{t=t.previousSibling}while(t&&!mi(t));return t}_getAugmentPropertiesFromElement(e){if(!ki(e))return{};const t={};return L(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){const i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&Mi(s)&&(t[i]=s)}})),t}_getPropertiesFromElement(e,t,i){var s;const n=e.tagName.toLowerCase(),r={tag_name:n};Si.indexOf(n)>-1&&!i&&("a"===n.toLowerCase()||"button"===n.toLowerCase()?r.$el_text=An(1024,Ai(e)):r.$el_text=An(1024,fi(e)));const o=gi(e);o.length>0&&(r.classes=o.filter((function(e){return""!==e})));const a=null===(s=this.config)||void 0===s?void 0:s.element_attribute_ignorelist;L(e.attributes,(function(i){var s;if((!Ii(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==a||!a.includes(i.name))&&!t&&Mi(i.value)&&(s=i.name,!u(s)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7)))){let e=i.value;"class"===i.name&&(e=hi(e).join(" ")),r["attr__"+i.name]=An(1024,e)}}));let l=1,c=1,d=e;for(;d=this._previousElementSibling(d);)l++,d.tagName===e.tagName&&c++;return r.nth_child=l,r.nth_of_type=c,r}_getDefaultProperties(e){return{$event_type:e,$ce_version:1}}_captureEvent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$autocapture";if(!this.isEnabled)return;let i=vi(e);var s;(yi(i)&&(i=i.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)&&(this.instance.config.rageclick&&null!==(s=this.rageclicks)&&void 0!==s&&s.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._captureEvent(e,"$rageclick"));const n=t===Mn;if(i&&xi(i,e,this.config,n,n?["copy","cut"]:void 0)){var r,o;const s=[i];let n=i;for(;n.parentNode&&!bi(n,"body");)wi(n.parentNode)?(s.push(n.parentNode.host),n=n.parentNode.host):(s.push(n.parentNode),n=n.parentNode);const u=[],d={};let h,p,g=!1;if(L(s,(e=>{const t=ki(e);"a"===e.tagName.toLowerCase()&&(h=e.getAttribute("href"),h=t&&Mi(h)&&h);D(gi(e),"ph-no-capture")&&(g=!0),u.push(this._getPropertiesFromElement(e,this.instance.config.mask_all_element_attributes,this.instance.config.mask_all_text));const i=this._getAugmentPropertiesFromElement(e);O(d,i)})),this.instance.config.mask_all_text||("a"===i.tagName.toLowerCase()||"button"===i.tagName.toLowerCase()?u[0].$el_text=Ai(i):u[0].$el_text=fi(i)),h){var a,l;u[0].attr__href=h;const e=null===(a=st(h))||void 0===a?void 0:a.host,t=null==v||null===(l=v.location)||void 0===l?void 0:l.host;e&&t&&e!==t&&(p=h)}if(g)return!1;const _=O(this._getDefaultProperties(e.type),this._elementsChainAsString?{$elements_chain:Oi(u)}:{$elements:u},null!==(r=u[0])&&void 0!==r&&r.$el_text?{$el_text:null===(o=u[0])||void 0===o?void 0:o.$el_text}:{},p&&"click"===e.type?{$external_click_url:p}:{},d),f=this.getElementSelectors(i);if(f&&f.length>0&&(_.$element_selectors=f),t===Mn){var c;const t=_i(null==v||null===(c=v.getSelection())||void 0===c?void 0:c.toString()),i=e.type||"clipboard";if(!t)return!1;_.$selected_content=t,_.$copy_type=i}return this.instance.capture(t,_),!0}}isBrowserSupported(){return o(null==E?void 0:E.querySelectorAll)}}class On{_restoreXHRPatch=void 0;_restoreFetchPatch=void 0;constructor(e){this.instance=e}_loadScript(e){var t,i,s;null!==(t=P.__PosthogExtensions__)&&void 0!==t&&t.tracingHeadersPatchFns&&e(),null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"tracing-headers",(t=>{if(t)return T.error("[TRACING-HEADERS] failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}_startCapturing=()=>{var e,t,i,s;c(this._restoreXHRPatch)&&(null===(e=P.__PosthogExtensions__)||void 0===e||null===(t=e.tracingHeadersPatchFns)||void 0===t||t._patchXHR(this.instance.sessionManager));c(this._restoreFetchPatch)&&(null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.tracingHeadersPatchFns)||void 0===s||s._patchFetch(this.instance.sessionManager))}}let Dn;!function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"}(Dn||(Dn={}));class Nn{constructor(e){this.instance=e}get config(){return this.instance.config}get consent(){return this.getDnt()?Dn.DENIED:this.storedConsent}isOptedOut(){return this.consent===Dn.DENIED||this.consent===Dn.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}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(){const{token:e,opt_out_capturing_cookie_prefix:t}=this.instance.config;return(t||"__ph_opt_in_out_")+e}get storedConsent(){const e=this.storage.get(this.storageKey);return"1"===e?Dn.GRANTED:"0"===e?Dn.DENIED:Dn.PENDING}get storage(){if(!this._storage){const e=this.config.opt_out_capturing_persistence_type;this._storage="localStorage"===e?Je:je;const t="localStorage"===e?je:Je;t.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut("1"===t.get(this.storageKey)),t.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!j([null==S?void 0:S.doNotTrack,null==S?void 0:S.msDoNotTrack,P.doNotTrack],(e=>D([!0,1,"1","yes"],e)))}}const qn="[Exception Autocapture]";class Bn{originalOnUnhandledRejectionHandler=void 0;constructor(e){var t;this.instance=e,this.remoteEnabled=!(null===(t=this.instance.persistence)||void 0===t||!t.props[ee]),this.startIfEnabled()}get isEnabled(){var e;return null!==(e=this.remoteEnabled)&&void 0!==e&&e}get isCapturing(){var e;return!(null==v||null===(e=v.onerror)||void 0===e||!e.__POSTHOG_INSTRUMENTED__)}get hasHandlers(){return this.originalOnUnhandledRejectionHandler||this.unwrapOnError}startIfEnabled(){this.isEnabled&&!this.isCapturing&&(T.info(qn+" enabled, starting..."),this.loadScript(this.startCapturing))}loadScript(e){var t,i;this.hasHandlers&&e(),null===(t=P.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"exception-autocapture",(t=>{if(t)return T.error(qn+" failed to load script",t);e()}))}startCapturing=()=>{var e,t,i,s;if(!v||!this.isEnabled||this.hasHandlers||this.isCapturing)return;const n=null===(e=P.__PosthogExtensions__)||void 0===e||null===(t=e.errorWrappingFunctions)||void 0===t?void 0:t.wrapOnError,r=null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.errorWrappingFunctions)||void 0===s?void 0:s.wrapUnhandledRejection;if(n&&r)try{this.unwrapOnError=n(this.captureException.bind(this)),this.unwrapUnhandledRejection=r(this.captureException.bind(this))}catch(e){T.error(qn+" failed to start",e),this.stopCapturing()}else T.error(qn+" failed to load error wrapping functions - cannot start")};stopCapturing(){var e,t;null===(e=this.unwrapOnError)||void 0===e||e.call(this),null===(t=this.unwrapUnhandledRejection)||void 0===t||t.call(this)}afterDecideResponse(e){const t=e.autocaptureExceptions;this.remoteEnabled=!!t||!1,this.instance.persistence&&this.instance.persistence.register({[ee]:this.remoteEnabled}),this.startIfEnabled()}captureException(e){const t=this.instance.requestRouter.endpointFor("ui");e.$exception_personURL=`${t}/project/${this.instance.config.token}/person/${this.instance.get_distinct_id()}`,this.instance.exceptions.sendExceptionEvent(e)}}const Hn=9e5,Un="[Web Vitals]";class Wn{_enabledServerSide=!1;_initialized=!1;buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0};constructor(e){var t;this.instance=e,this._enabledServerSide=!(null===(t=this.instance.persistence)||void 0===t||!t.props[ie]),this.startIfEnabled()}get allowedMetrics(){var e,t;const i=a(this.instance.config.capture_performance)?null===(e=this.instance.config.capture_performance)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return c(i)?(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[se])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(a(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){const e=a(this.instance.config.capture_performance)&&g(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Hn;return 0<e&&e<=6e4?Hn:e}get isEnabled(){const e=a(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return _(e)?e:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(T.info(Un+" enabled, starting..."),this.loadScript(this._startCapturing))}afterDecideResponse(e){const t=a(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=a(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[ie]:t}),this.instance.persistence.register({[se]:i})),this._enabledServerSide=t,this.startIfEnabled()}loadScript(e){var t,i,s;null!==(t=P.__PosthogExtensions__)&&void 0!==t&&t.postHogWebVitalsCallbacks&&e(),null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"web-vitals",(t=>{t?T.error(Un+" failed to load script",t):e()}))}_currentURL(){const e=v?v.location.href:void 0;return e||T.error(Un+"Could not determine current URL"),e}_flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this.buffer.metrics.length&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce(((e,t)=>({...e,[`$web_vitals_${t.name}_event`]:{...t},[`$web_vitals_${t.name}_value`]:t.value})),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})};_addToBuffer=e=>{var t;const i=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);if(c(i))return void T.error(Un+"Could not read session ID. Dropping metrics!");this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};const s=this._currentURL();if(c(s))return;if(p(null==e?void 0:e.name)||p(null==e?void 0:e.value))return void T.error(Un+"Invalid metric received",e);if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)return void T.error(Un+"Ignoring metric with value >= "+this._maxAllowedValue,e);this.buffer.url!==s&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),c(this.buffer.url)&&(this.buffer.url=s),this.buffer.firstMetricTimestamp=c(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.buffer.metrics.push({...e,$current_url:s,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()}),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()};_startCapturing=()=>{let e,t,i,s;const n=P.__PosthogExtensions__;c(n)||c(n.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:s}=n.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):T.error(Un+"web vitals callbacks not loaded - not starting")}}const zn={icontains:(e,t)=>!!v&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!v&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!v&&nt(t.href,e),not_regex:(e,t)=>!!v&&!nt(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class Vn{constructor(e){this.instance=e;const t=e=>{this.applyFeatureFlagChanges(e)};this.instance.onFeatureFlags&&this.instance.onFeatureFlags(t),this._flagToExperiments=new Map}applyFeatureFlagChanges(e){p(this._flagToExperiments)||this.instance.config.disable_web_experiments||(Vn.logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!==(t=this._flagToExperiments)&&void 0!==t&&t.has(e)){var i;const t=this.instance.getFeatureFlag(e),s=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);t&&null!=s&&s.variants[t]&&this.applyTransforms(s.name,t,s.variants[t].transforms)}})))}afterDecideResponse(e){this._is_bot()?Vn.logInfo("Refusing to render web experiment since the viewer is a likely bot"):(this._featureFlags=e.featureFlags,this.loadIfEnabled(),this.previewWebExperiment())}previewWebExperiment(){const e=Vn.getWindowLocation();if(null!=e&&e.search){const t=ot(null==e?void 0:e.search,"__experiment_id"),i=ot(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Vn.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()}getWebExperimentsAndEvaluateDisplayLogic=(()=>{var e=this;return function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e.getWebExperiments((t=>{Vn.logInfo("retrieved web experiments from the server"),e._flagToExperiments=new Map,t.forEach((t=>{if(t.feature_flag_key&&e._featureFlags&&e._featureFlags[t.feature_flag_key]){var i;if(e._flagToExperiments)Vn.logInfo("setting flag key ",t.feature_flag_key," to web experiment ",t),null===(i=e._flagToExperiments)||void 0===i||i.set(t.feature_flag_key,t);const s=e._featureFlags[t.feature_flag_key];s&&t.variants[s]&&e.applyTransforms(t.name,s,t.variants[s].transforms)}else if(t.variants)for(const i in t.variants){const s=t.variants[i];Vn.matchesTestVariant(s)&&e.applyTransforms(t.name,i,s.transforms)}}))}),t)}})();getWebExperiments(e,t,i){if(this.instance.config.disable_web_experiments&&!i)return e([]);const 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",transport:"XHR",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);const i=t.json.experiments||[];return e(i)}})}showPreviewWebExperiment(e,t,i){const s=i.filter((t=>t.id===e));s&&s.length>0&&(Vn.logInfo(`Previewing web experiment [${s[0].name}] with variant [${t}]`),this.applyTransforms(s[0].name,t,s[0].variants[t].transforms,!0))}static matchesTestVariant(e){return!p(e.conditions)&&(Vn.matchUrlConditions(e)&&Vn.matchUTMConditions(e))}static matchUrlConditions(e){var t;if(p(e.conditions)||p(null===(t=e.conditions)||void 0===t?void 0:t.url))return!0;const i=Vn.getWindowLocation();if(i){var s,n,r;return null===(s=e.conditions)||void 0===s||!s.url||zn[null!==(n=null===(r=e.conditions)||void 0===r?void 0:r.urlMatchType)&&void 0!==n?n:"icontains"](e.conditions.url,i)}return!1}static getWindowLocation(){return null==v?void 0:v.location}static matchUTMConditions(e){var t;if(p(e.conditions)||p(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;const i=ri.campaignParams();if(i.utm_source){var s,n,r,o,a,l,c,u,d,h,g,_,f,v,m,b;const t=null===(s=e.conditions)||void 0===s||null===(n=s.utm)||void 0===n||!n.utm_campaign||(null===(r=e.conditions)||void 0===r||null===(o=r.utm)||void 0===o?void 0:o.utm_campaign)==i.utm_campaign,p=null===(a=e.conditions)||void 0===a||null===(l=a.utm)||void 0===l||!l.utm_source||(null===(c=e.conditions)||void 0===c||null===(u=c.utm)||void 0===u?void 0:u.utm_source)==i.utm_source,y=null===(d=e.conditions)||void 0===d||null===(h=d.utm)||void 0===h||!h.utm_medium||(null===(g=e.conditions)||void 0===g||null===(_=g.utm)||void 0===_?void 0:_.utm_medium)==i.utm_medium,w=null===(f=e.conditions)||void 0===f||null===(v=f.utm)||void 0===v||!v.utm_term||(null===(m=e.conditions)||void 0===m||null===(b=m.utm)||void 0===b?void 0:b.utm_term)==i.utm_term;return t&&y&&w&&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];T.info(`[WebExperiments] ${e}`,i)}applyTransforms(e,t,i,s){var n;this._is_bot()?Vn.logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var n;Vn.logInfo(`applying transform of variant ${t} for experiment ${e} `,i);let o=0;const a=null===(n=document)||void 0===n?void 0:n.querySelectorAll(i.selector);var r;if(null==a||a.forEach((e=>{const t=e;o+=1,i.attributes&&i.attributes.forEach((e=>{switch(e.name){case"text":t.innerText=e.value;break;case"html":t.innerHTML=e.value;break;case"cssClass":t.className=e.value;break;default:t.setAttribute(e.name,e.value)}})),i.text&&(t.innerText=i.text),i.html&&(t.parentElement?t.parentElement.innerHTML=i.html:t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)})),this.instance&&this.instance.capture)this.instance.capture("$web_experiment_applied",{$web_experiment_name:e,$web_experiment_variant:t,$web_experiment_preview:s,$web_experiment_document_url:null===(r=Vn.getWindowLocation())||void 0===r?void 0:r.href,$web_experiment_elements_modified:o})}})):(Vn.logInfo("Control variants leave the page unmodified."),this.instance&&this.instance.capture&&this.instance.capture("$web_experiment_applied",{$web_experiment_name:e,$web_experiment_preview:s,$web_experiment_variant:t,$web_experiment_document_url:null===(n=Vn.getWindowLocation())||void 0===n?void 0:n.href,$web_experiment_elements_modified:0}))}_is_bot(){return S&&this.instance?Rn(S,this.instance.config.custom_blocked_useragents):void 0}}const Gn="/e/";class jn{constructor(e){var t;this.instance=e,this._endpointSuffix=(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[te])||Gn}get endpoint(){return this.instance.requestRouter.endpointFor("api",this._endpointSuffix)}afterDecideResponse(e){const t=e.autocaptureExceptions;this._endpointSuffix=a(t)&&t.endpoint||Gn,this.instance.persistence&&this.instance.persistence.register({[te]:this._endpointSuffix})}sendExceptionEvent(e){this.instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",_url:this.endpoint})}}const Qn={},Jn=()=>{},Yn="posthog";let Xn=!js&&-1===(null==R?void 0:R.indexOf("MSIE"))&&-1===(null==R?void 0:R.indexOf("Mozilla"));const Kn=()=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:G(null==E?void 0:E.location),persistence:"localStorage+cookie",persistence_name:"",loaded:Jn,store_google:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:x&&u(null==x?void 0:x.search)&&-1!==x.search.indexOf("__posthog_debug=true")||!1,verbose:!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==v||null===(e=v.location)||void 0===e?void 0:e.protocol),ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},inapp_protocol:"//",inapp_link_new_window:!1,request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,on_request_error:e=>{const t="Bad HTTP status: "+e.statusCode+" "+e.text;T.error(t)},get_device_id:e=>e,_onCapture:Jn,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",__add_tracing_headers:!1}},Zn=e=>{const t={};c(e.process_person)||(t.person_profiles=e.process_person),c(e.xhr_headers)||(t.request_headers=e.xhr_headers),c(e.cookie_name)||(t.persistence_name=e.cookie_name),c(e.disable_cookie)||(t.disable_persistence=e.disable_cookie);const i=O({},t,e);return r(e.property_blacklist)&&(c(e.property_denylist)?i.property_denylist=e.property_blacklist:r(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:T.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class er{get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){T.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}__forceAllowLocalhost=!1}class tr{webPerformance=new er;version=e.LIB_VERSION;_internalEventEmitter=new vn;constructor(){this.config=Kn(),this.decideEndpointWasHit=!1,this.SentryIntegration=un,this.sentryIntegration=e=>function(e,t){const i=cn(e,t);return{name:ln,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this.featureFlags=new Ae(this),this.toolbar=new Vs(this),this.scrollManager=new Cn(this),this.pageViewManager=new hn(this),this.surveys=new Sn(this),this.experiments=new Vn(this),this.exceptions=new jn(this),this.rateLimiter=new En(this),this.requestRouter=new an(this),this.consent=new Nn(this),this.people={set:(e,t,i)=>{const s=u(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{const s=u(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>T.info(`send "${null==e?void 0:e.event}"`,e)))}init(e,t,i){if(i&&i!==Yn){var s;const n=null!==(s=Qn[i])&&void 0!==s?s:new tr;return n._init(e,t,i),Qn[i]=n,Qn[Yn][i]=n,n}return this._init(e,t,i)}_init(t){var i,s;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if(c(t)||d(t))return T.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 T.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],n.person_profiles&&(this._initialPersonProfilesConfig=n.person_profiles),this.set_config(O({},Kn(),Zn(n),{name:r,token:t})),this.config.on_xhr_error&&T.error("[posthog] on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:Q.GZipJS,this.persistence=new ai(this.config),this.sessionPersistence="sessionStorage"===this.config.persistence?this.persistence:new ai({...this.config,persistence:"sessionStorage"});const a={...this.persistence.props},l={...this.sessionPersistence.props};if(this._requestQueue=new Gs((e=>this._send_retriable_request(e))),this._retryQueue=new tn(this),this.__request_queue=[],this.sessionManager=new nn(this.config,this.persistence),this.sessionPropsManager=new kn(this.sessionManager,this.persistence),new On(this).startIfEnabledOrStop(),this.sessionRecording=new Bs(this),this.sessionRecording.startIfEnabledOrStop(),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Ln(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new Tn(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Wn(this),this.exceptionObserver=new Bn(this),this.exceptionObserver.startIfEnabled(),e.DEBUG=e.DEBUG||this.config.debug,e.DEBUG&&T.info("Starting in debug mode",{this:this,config:n,thisC:{...this.config},p:a,s:l}),this._sync_opt_out_with_persistence(),void 0!==(null===(i=n.bootstrap)||void 0===i?void 0:i.distinctID)){var u,h;const e=this.config.get_device_id(He()),t=null!==(u=n.bootstrap)&&void 0!==u&&u.isIdentifiedID?e:n.bootstrap.distinctID;this.persistence.set_property(we,null!==(h=n.bootstrap)&&void 0!==h&&h.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:t})}if(this._hasBootstrappedFeatureFlags()){var p,g;const e=Object.keys((null===(p=n.bootstrap)||void 0===p?void 0:p.featureFlags)||{}).filter((e=>{var t,i;return!(null===(t=n.bootstrap)||void 0===t||null===(i=t.featureFlags)||void 0===i||!i[e])})).reduce(((e,t)=>{var i,s;return e[t]=(null===(i=n.bootstrap)||void 0===i||null===(s=i.featureFlags)||void 0===s?void 0:s[t])||!1,e}),{}),t=Object.keys((null===(g=n.bootstrap)||void 0===g?void 0:g.featureFlagPayloads)||{}).filter((t=>e[t])).reduce(((e,t)=>{var i,s,r,o;null!==(i=n.bootstrap)&&void 0!==i&&null!==(s=i.featureFlagPayloads)&&void 0!==s&&s[t]&&(e[t]=null===(r=n.bootstrap)||void 0===r||null===(o=r.featureFlagPayloads)||void 0===o?void 0:o[t]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:e,featureFlagPayloads:t})}if(!this.get_distinct_id()){const e=this.config.get_device_id(He());this.register_once({distinct_id:e,$device_id:e},""),this.persistence.set_property(we,"anonymous")}return null==v||null===(s=v.addEventListener)||void 0===s||s.call(v,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),this.toolbar.maybeLoadToolbar(),n.segment?dn(this,(()=>this._loaded())):this._loaded(),o(this.config._onCapture)&&this.on("eventCaptured",(e=>this.config._onCapture(e.event,e))),this}_afterDecideResponse(e){var t,i,s,n,r,o,a,l,c;this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=D(e.supportedCompression,Q.GZipJS)?Q.GZipJS:D(e.supportedCompression,Q.Base64)?Q.Base64:void 0),null!==(t=e.analytics)&&void 0!==t&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:e.defaultIdentifiedOnly?"identified_only":"always"}),null===(i=this.sessionRecording)||void 0===i||i.afterDecideResponse(e),null===(s=this.autocapture)||void 0===s||s.afterDecideResponse(e),null===(n=this.heatmaps)||void 0===n||n.afterDecideResponse(e),null===(r=this.experiments)||void 0===r||r.afterDecideResponse(e),null===(o=this.surveys)||void 0===o||o.afterDecideResponse(e),null===(a=this.webVitalsAutocapture)||void 0===a||a.afterDecideResponse(e),null===(l=this.exceptions)||void 0===l||l.afterDecideResponse(e),null===(c=this.exceptionObserver)||void 0===c||c.afterDecideResponse(e)}_loaded(){const e=this.config.advanced_disable_decide;e||this.featureFlags.setReloadingPaused(!0);try{this.config.loaded(this)}catch(e){T.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{this.consent.isOptedIn()&&this._captureInitialPageview()}),1),e||(new Hs(this).call(),this.featureFlags.resetRequestQueue())}_start_queue_if_opted_in(){var e;this.has_opted_out_capturing()||this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.has_opted_out_capturing()||A(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)||void 0===e||e.unload(),null===(t=this._retryQueue)||void 0===t||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(t){this.__loaded&&(Xn?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)||(t.transport=t.transport||this.config.api_transport,t.url=Js(t.url,{ip:this.config.ip?1:0}),t.headers={...this.config.request_headers},t.compression="best-available"===t.compression?this.compression:t.compression,(t=>{var i,s,n;const r={...t};r.timeout=r.timeout||6e4,r.url=Js(r.url,{_:(new Date).getTime().toString(),ver:e.LIB_VERSION,compression:r.compression});const o=null!==(i=r.transport)&&void 0!==i?i:"XHR",a=null!==(s=null===(n=j(en,(e=>e.transport===o)))||void 0===n?void 0:n.method)&&void 0!==s?s:en[0].method;if(!a)throw new Error("No available transport method");a(r)})({...t,callback:e=>{var i,s,n;(this.rateLimiter.checkForLimiting(e),e.statusCode>=400)&&(null===(s=(n=this.config).on_request_error)||void 0===s||s.call(n,e));null===(i=t.callback)||void 0===i||i.call(t,e)}})))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){let t;const i=[],s=[],n=[];A(e,(e=>{e&&(t=e[0],r(t)?n.push(e):o(e)?e.call(this):r(e)&&"alias"===t?i.push(e):r(e)&&-1!==t.indexOf("capture")&&o(this[t])?n.push(e):s.push(e))}));const a=function(e,t){A(e,(function(e){if(r(e[0])){let i=t;L(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};a(i,this),a(s,this),a(n,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null===(e=this.config.bootstrap)||void 0===e?void 0:e.featureFlags)&&Object.keys(null===(t=this.config.bootstrap)||void 0===t?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,i){var s;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue))return void T.uninitializedWarning("posthog.capture");if(this.consent.isOptedOut())return;if(c(e)||!u(e))return void T.error("No event name provided to posthog.capture");if(!this.config.opt_out_useragent_filter&&this._is_bot())return;const n=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null!=n&&n.isRateLimited)return void T.critical("This capture call is ignored due to client rate limiting.");this.sessionPersistence.update_search_keyword(),this.config.store_google&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.store_google||this.config.save_referrer)&&this.persistence.set_initial_person_info();const r=new Date,o=(null==i?void 0:i.timestamp)||r;let a={uuid:He(),event:e,properties:this._calculate_event_properties(e,t||{},o)};n&&(a.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens);(null==i?void 0:i.$set)&&(a.$set=null==i?void 0:i.$set);const d=this._calculate_set_once_properties(null==i?void 0:i.$set_once);d&&(a.$set_once=d),a=W(a,null!=i&&i._noTruncate?null:this.config.properties_string_max_length),a.timestamp=o,c(null==i?void 0:i.timestamp)||(a.properties.$event_time_override_provided=!0,a.properties.$event_time_override_system_time=r);const h={...a.properties.$set,...a.$set};l(h)||this.setPersonPropertiesForFlags(h),this._internalEventEmitter.emit("eventCaptured",a);const p={method:"POST",url:null!==(s=null==i?void 0:i._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:a,compression:"best-available",batchKey:null==i?void 0:i._batchKey};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this._send_retriable_request(p):this._requestQueue.enqueue(p),a}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}_calculate_event_properties(e,t,i){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;const s=this.persistence.remove_event_timer(e);let n={...t};if(n.token=this.config.token,"$snapshot"===e){const e={...this.persistence.properties(),...this.sessionPersistence.properties()};return n.distinct_id=e.distinct_id,(!u(n.distinct_id)&&!g(n.distinct_id)||d(n.distinct_id))&&T.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),n}const o=ri.properties();if(this.sessionManager){const{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId();n.$session_id=e,n.$window_id=t}if(this.requestRouter.region===rn.CUSTOM&&(n.$lib_custom_api_host=this.config.api_host),this.sessionPropsManager&&this.config.__preview_send_client_session_params&&("$pageview"===e||"$pageleave"===e||"$autocapture"===e)){const e=this.sessionPropsManager.getSessionProps();n=O(n,e)}if(!this.config.disable_scroll_properties){let t={};"$pageview"===e?t=this.pageViewManager.doPageView(i):"$pageleave"===e&&(t=this.pageViewManager.doPageLeave(i)),n=O(n,t)}if("$pageview"===e&&E&&(n.title=E.title),!c(s)){const e=i.getTime()-s;n.$duration=parseFloat((e/1e3).toFixed(3))}R&&this.config.opt_out_useragent_filter&&(n.$browser_type=this._is_bot()?"bot":"browser"),n=O({},o,this.persistence.properties(),this.sessionPersistence.properties(),n),n.$is_identified=this._isIdentified(),r(this.config.property_denylist)?L(this.config.property_denylist,(function(e){delete n[e]})):T.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const a=this.config.sanitize_properties;a&&(n=a(n,e));const l=this._hasPersonProcessing();return n.$process_person_profile=l,l&&this._requirePersonProcessing("_calculate_event_properties"),n}_calculate_set_once_properties(e){if(!this.persistence||!this._hasPersonProcessing())return e;let t=O({},this.persistence.get_initial_props(),e||{});const i=this.config.sanitize_properties;return i&&(t=i(t,"$set_once")),l(t)?void 0:t}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var s;null===(s=this.persistence)||void 0===s||s.register_once(e,t,i)}register_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.register(e)}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){const t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch{return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t)}getEarlyAccessFeatures(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.featureFlags.getEarlyAccessFeatures(e,t)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}canRenderSurvey(e){this.surveys.canRenderSurvey(e)}getNextSurveyStep(e,t,i){return this.surveys.getNextSurveyStep(e,t,i)}identify(e,t,i){if(!this.__loaded||!this.persistence)return T.uninitializedWarning("posthog.identify");if(g(e)&&(e=e.toString(),T.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!e)return void T.error("Unique user id has not been set in posthog.identify");if(["distinct_id","distinctid"].includes(e.toLowerCase()))return void T.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.`);if(!this._requirePersonProcessing("posthog.identify"))return;const s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){const e=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:e},"")}e!==s&&e!==this.get_property(Y)&&(this.unregister(Y),this.register({distinct_id:e}));const n="anonymous"===(this.persistence.get_property(we)||"anonymous");e!==s&&n?(this.persistence.set_property(we,"identified"),this.setPersonPropertiesForFlags(t||{},!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:i||{}}),this.featureFlags.setAnonymousDistinctId(s)):(t||i)&&this.setPersonProperties(t,i),e!==s&&(this.reloadFeatureFlags(),this.unregister(ye))}setPersonProperties(e,t){(e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(e||{}),this.capture("$set",{$set:e||{},$set_once:t||{}}))}group(e,t,i){if(!e||!t)return void T.error("posthog.group requires a group type and group key");if(!this._requirePersonProcessing("posthog.group"))return;const s=this.getGroups();s[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:{...s,[e]:t}}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),s[e]===t||i||this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this._requirePersonProcessing("posthog.setPersonPropertiesForFlags")&&this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,n;if(T.info("reset"),!this.__loaded)return T.uninitializedWarning("posthog.reset");const r=this.get_property("$device_id");this.consent.reset(),null===(t=this.persistence)||void 0===t||t.clear(),null===(i=this.sessionPersistence)||void 0===i||i.clear(),null===(s=this.persistence)||void 0===s||s.set_property(we,"anonymous"),null===(n=this.sessionManager)||void 0===n||n.resetSessionId();const o=this.config.get_device_id(He());this.register_once({distinct_id:o,$device_id:e?o:r},"")}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?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${t}`);if(null!=e&&e.withTimestamp&&i){var n;const t=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-i)/1e3)-t,0)}`}return s}alias(e,t){return e===this.get_property(J)?(T.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(c(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Y,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(T.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(t){const i={...this.config};var s,n,r,o;a(t)&&(O(this.config,Zn(t)),null===(s=this.persistence)||void 0===s||s.update_config(this.config,i),this.sessionPersistence="sessionStorage"===this.config.persistence?this.persistence:new ai({...this.config,persistence:"sessionStorage"}),Je.is_supported()&&"true"===Je.get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(e.DEBUG=!0,T.info("set_config",{config:t,oldConfig:i,newConfig:{...this.config}})),null===(n=this.sessionRecording)||void 0===n||n.startIfEnabledOrStop(),null===(r=this.autocapture)||void 0===r||r.startIfEnabled(),null===(o=this.heatmaps)||void 0===o||o.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(e){const t=_(e)&&e;if(t||null!=e&&e.sampling||null!=e&&e.linked_flag){var i;const r=null===(i=this.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId();var s,n;if(t||null!=e&&e.sampling)null===(s=this.sessionRecording)||void 0===s||s.overrideSampling(),T.info("Session recording started with sampling override for session: ",null==r?void 0:r.sessionId);if(t||null!=e&&e.linked_flag)null===(n=this.sessionRecording)||void 0===n||n.overrideLinkedFlag(),T.info("Session recording started with linked_flags override")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null===(e=this.sessionRecording)||void 0===e||!e.started)}captureException(e,t){var i;const s=new Error("PostHog syntheticException"),n=o(null===(i=P.__PosthogExtensions__)||void 0===i?void 0:i.parseErrorAsProperties)?P.__PosthogExtensions__.parseErrorAsProperties([e.message,void 0,void 0,void 0,e],{syntheticException:s}):{$exception_level:"error",$exception_list:[{type:e.name,value:e.message,mechanism:{handled:!0,synthetic:!1}}],...t};this.exceptions.sendExceptionEvent(n)}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e;let t=null!==(e=this.config.name)&&void 0!==e?e:Yn;return t!==Yn&&(t=Yn+"."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property(we))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property(we))}_hasPersonProcessing(){var e,t,i,s;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&l(this.getGroups())&&(null===(e=this.persistence)||void 0===e||null===(t=e.props)||void 0===t||!t[Y])&&(null===(i=this.persistence)||void 0===i||null===(s=i.props)||void 0===s||!s[Fe]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(T.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Fe,!0),!0)}_sync_opt_out_with_persistence(){var e,t;const i=this.consent.isOptedOut(),s=this.config.opt_out_persistence_by_default,n=this.config.disable_persistence||i&&!!s;var r,o;(null===(e=this.persistence)||void 0===e?void 0:e.disabled)!==n&&(null===(r=this.persistence)||void 0===r||r.set_disabled(n));(null===(t=this.sessionPersistence)||void 0===t?void 0:t.disabled)!==n&&(null===(o=this.sessionPersistence)||void 0===o||o.set_disabled(n))}opt_in_capturing(e){var t;(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),c(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()}opt_out_capturing(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return S?Rn(S,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){E&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:E.title},{send_instantly:!0}))}debug(e){!1===e?(null==v||v.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==v||v.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}))}}!function(e,t){for(let i=0;i<t.length;i++)e.prototype[t[i]]=B(e.prototype[t[i]])}(tr,["identify"]);!function(){const e=Qn[Yn]=new tr,t=P.posthog;t&&L(t._i,(function(i){if(i&&r(i)){const s=e.init(i[0],i[1],i[2]),n=t[i[2]]||t;s&&(s._execute_array.call(s.people,n.people),s._execute_array(n))}})),P.posthog=e,function(){function e(){e.done||(e.done=!0,Xn=!1,L(Qn,(function(e){e._dom_loaded()})))}null!=E&&E.addEventListener&&("complete"===E.readyState?e():E.addEventListener("DOMContentLoaded",e,!1)),v&&V(v,"load",e,!0)}()}()}();
10
+ */Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return g(e)&&isFinite(e)&&Math.floor(e)===e});const Le="0123456789abcdef";class Oe{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");const n=new Uint8Array(16);return n[0]=e/2**40,n[1]=e/2**32,n[2]=e/2**24,n[3]=e/65536,n[4]=e/256,n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=s>>>24,n[13]=s>>>16,n[14]=s>>>8,n[15]=s,new Oe(n)}toString(){let e="";for(let t=0;t<this.bytes.length;t++)e=e+Le.charAt(this.bytes[t]>>>4)+Le.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 Oe(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(let t=0;t<16;t++){const i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class De{timestamp=0;counter=0;random=new Be;generate(){const e=this.generateOrAbort();if(c(e)){this.timestamp=0;const e=this.generateOrAbort();if(c(e))throw new Error("Could not generate UUID after timestamp reset");return e}return e}generateOrAbort(){const 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 Oe.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}let Ne,qe=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};v&&!c(v.crypto)&&crypto.getRandomValues&&(qe=e=>crypto.getRandomValues(e));class Be{buffer=new Uint32Array(8);cursor=1/0;nextUint32(){return this.cursor>=this.buffer.length&&(qe(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}const He=()=>Ue().toString(),Ue=()=>(Ne||(Ne=new De)).generate(),We="Thu, 01 Jan 1970 00:00:00 GMT";let ze="";const Ve=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ge(e,t){if(t){let t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E;if(ze)return ze;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";const i=e.split(".");let s=Math.min(i.length,8);const n="dmn_chk_"+He(),r=new RegExp("(^|;)\\s*"+n+"=1");for(;!ze&&s--;){const e=i.slice(s).join("."),o=n+"=1;domain=."+e;t.cookie=o,r.test(t.cookie)&&(t.cookie=o+";expires="+We,ze=e)}return ze}(e);if(!t){const i=(e=>{const t=e.match(Ve);return t?t[0]:""})(e);i!==t&&T.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}const je={is_supported:()=>!!E,error:function(e){T.error("cookieStore error: "+e)},get:function(e){if(E){try{const t=e+"=",i=E.cookie.split(";").filter((e=>e.length));for(let e=0;e<i.length;e++){let s=i[e];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch{}return null}},parse:function(e){let t;try{t=JSON.parse(je.get(e))||{}}catch{}return t},set:function(e,t,i,s,n){if(E)try{let r="",o="";const a=Ge(E.location.hostname,s);if(i){const e=new Date;e.setTime(e.getTime()+24*i*60*60*1e3),r="; expires="+e.toUTCString()}n&&(o="; secure");const l=e+"="+encodeURIComponent(JSON.stringify(t))+r+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&T.warn("cookieStore warning: large cookie, len="+l.length),E.cookie=l,l}catch{return}},remove:function(e,t){try{je.set(e,"",-1,t)}catch{return}}};let Qe=null;const Je={is_supported:function(){if(!h(Qe))return Qe;let e=!0;if(c(v))e=!1;else try{const t="__mplssupport__",i="xyz";Je.set(t,i),'"xyz"'!==Je.get(t)&&(e=!1),Je.remove(t)}catch{e=!1}return e||T.error("localStorage unsupported; falling back to cookie store"),Qe=e,e},error:function(e){T.error("localStorage error: "+e)},get:function(e){try{return null==v?void 0:v.localStorage.getItem(e)}catch(e){Je.error(e)}return null},parse:function(e){try{return JSON.parse(Je.get(e))||{}}catch{}return null},set:function(e,t){try{null==v||v.localStorage.setItem(e,JSON.stringify(t))}catch(e){Je.error(e)}},remove:function(e){try{null==v||v.localStorage.removeItem(e)}catch(e){Je.error(e)}}},Ye=["distinct_id",ue,de,Fe],Xe={...Je,parse:function(e){try{let t={};try{t=je.parse(e)||{}}catch{}const i=O(t,JSON.parse(Je.get(e)||"{}"));return Je.set(e,i),i}catch{}return null},set:function(e,t,i,s,n,r){try{Je.set(e,t,void 0,void 0,r);const o={};Ye.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&je.set(e,o,i,s,n,r)}catch(e){Je.error(e)}},remove:function(e,t){try{null==v||v.localStorage.removeItem(e),je.remove(e,t)}catch(e){Je.error(e)}}},Ke={},Ze={is_supported:function(){return!0},error:function(e){T.error("memoryStorage error: "+e)},get:function(e){return Ke[e]||null},parse:function(e){return Ke[e]||null},set:function(e,t){Ke[e]=t},remove:function(e){delete Ke[e]}};let et=null;const tt={is_supported:function(){if(!h(et))return et;if(et=!0,c(v))et=!1;else try{const e="__support__",t="xyz";tt.set(e,t),'"xyz"'!==tt.get(e)&&(et=!1),tt.remove(e)}catch{et=!1}return et},error:function(e){T.error("sessionStorage error: ",e)},get:function(e){try{return null==v?void 0:v.sessionStorage.getItem(e)}catch(e){tt.error(e)}return null},parse:function(e){try{return JSON.parse(tt.get(e))||null}catch{}return null},set:function(e,t){try{null==v||v.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){tt.error(e)}},remove:function(e){try{null==v||v.sessionStorage.removeItem(e)}catch(e){tt.error(e)}}},it=["localhost","127.0.0.1"],st=e=>{const t=null==E?void 0:E.createElement("a");return c(t)?null:(t.href=e,t)},nt=function(e,t){return!!function(e){try{new RegExp(e)}catch{return!1}return!0}(t)&&new RegExp(t).test(e)},rt=function(e){let t,i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"&";const n=[];return L(e,(function(e,s){c(e)||c(s)||"undefined"===s||(t=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),i=encodeURIComponent(s),n[n.length]=i+"="+t)})),n.join(s)},ot=function(e,t){const i=((e.split("#")[0]||"").split("?")[1]||"").split("&");let s;for(let e=0;e<i.length;e++){const n=i[e].split("=");if(n[0]===t){s=n;break}}if(!r(s)||s.length<2)return"";{let e=s[1];try{e=decodeURIComponent(e)}catch{T.error("Skipping decoding for malformed query param: "+e)}return e.replace(/\+/g," ")}},at=function(e,t){const i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},lt="Mobile",ct="iOS",ut="Android",dt="Tablet",ht=ut+" "+dt,pt="iPad",gt="Apple",_t=gt+" Watch",ft="Safari",vt="BlackBerry",mt="Samsung",bt=mt+"Browser",yt=mt+" Internet",wt="Chrome",St=wt+" OS",Et=wt+" "+ct,xt="Internet Explorer",kt=xt+" "+lt,It="Opera",Ft=It+" Mini",Rt="Edge",Pt="Microsoft "+Rt,$t="Firefox",Tt=$t+" "+ct,Ct="Nintendo",Mt="PlayStation",At="Xbox",Lt=ut+" "+lt,Ot=lt+" "+ft,Dt="Windows",Nt=Dt+" Phone",qt="Nokia",Bt="Ouya",Ht="Generic",Ut=Ht+" "+lt.toLowerCase(),Wt=Ht+" "+dt.toLowerCase(),zt="Konqueror",Vt="(\\d+(\\.\\d+)?)",Gt=new RegExp("Version/"+Vt),jt=new RegExp(At,"i"),Qt=new RegExp(Mt+" \\w+","i"),Jt=new RegExp(Ct+" \\w+","i"),Yt=new RegExp(vt+"|PlayBook|BB10","i"),Xt={"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"};const Kt=(e,t)=>t&&D(t,gt)||function(e){return D(e,ft)&&!D(e,wt)&&!D(e,ut)}(e),Zt=function(e,t){return t=t||"",D(e," OPR/")&&D(e,"Mini")?Ft:D(e," OPR/")?It:Yt.test(e)?vt:D(e,"IE"+lt)||D(e,"WPDesktop")?kt:D(e,bt)?yt:D(e,Rt)||D(e,"Edg/")?Pt:D(e,"FBIOS")?"Facebook "+lt:D(e,"UCWEB")||D(e,"UCBrowser")?"UC Browser":D(e,"CriOS")?Et:D(e,"CrMo")?wt:D(e,ut)&&D(e,ft)?Lt:D(e,wt)?wt:D(e,"FxiOS")?Tt:D(e.toLowerCase(),zt.toLowerCase())?zt:Kt(e,t)?D(e,lt)?Ot:ft:D(e,$t)?$t:D(e,"MSIE")||D(e,"Trident/")?xt:D(e,"Gecko")?$t:""},ei={[kt]:[new RegExp("rv:"+Vt)],[Pt]:[new RegExp(Rt+"?\\/"+Vt)],[wt]:[new RegExp("("+wt+"|CrMo)\\/"+Vt)],[Et]:[new RegExp("CriOS\\/"+Vt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Vt)],[ft]:[Gt],[Ot]:[Gt],[It]:[new RegExp("(Opera|OPR)\\/"+Vt)],[$t]:[new RegExp($t+"\\/"+Vt)],[Tt]:[new RegExp("FxiOS\\/"+Vt)],[zt]:[new RegExp("Konqueror[:/]?"+Vt,"i")],[vt]:[new RegExp(vt+" "+Vt),Gt],[Lt]:[new RegExp("android\\s"+Vt,"i")],[yt]:[new RegExp(bt+"\\/"+Vt)],[xt]:[new RegExp("(rv:|MSIE )"+Vt)],Mozilla:[new RegExp("rv:"+Vt)]},ti=[[new RegExp(At+"; "+At+" (.*?)[);]","i"),e=>[At,e&&e[1]||""]],[new RegExp(Ct,"i"),[Ct,""]],[new RegExp(Mt,"i"),[Mt,""]],[Yt,[vt,""]],[new RegExp(Dt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Nt,""];if(new RegExp(lt).test(t)&&!/IEMobile\b/.test(t))return[Dt+" "+lt,""];const i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){const e=i[1];let s=Xt[e]||"";return/arm/i.test(t)&&(s="RT"),[Dt,s]}return[Dt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){const t=[e[3],e[4],e[5]||"0"];return[ct,t.join(".")]}return[ct,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=c(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ut+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ut+")","i"),e=>{if(e&&e[2]){const t=[e[2],e[3],e[4]||"0"];return[ut,t.join(".")]}return[ut,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];if(e&&e[1]){const i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[St,""]],[/Linux|debian/i,["Linux",""]]],ii=function(e){return Jt.test(e)?Ct:Qt.test(e)?Mt:jt.test(e)?At:new RegExp(Bt,"i").test(e)?Bt:new RegExp("("+Nt+"|WPDesktop)","i").test(e)?Nt:/iPad/.test(e)?pt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?_t:Yt.test(e)?vt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(qt,"i").test(e)?qt:/(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(lt).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)?ut:ht:ut:new RegExp("(pda|"+lt+")","i").test(e)?Ut:new RegExp(dt,"i").test(e)&&!new RegExp(dt+" pc","i").test(e)?Wt:""},si="https?://(.*)",ni=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","mc_cid","igshid","ttclid","rdt_cid"],ri={campaignParams:function(e){return E?this._campaignParamsFromUrl(E.URL,e):{}},_campaignParamsFromUrl:function(e,t){const i=ni.concat(t||[]),s={};return L(i,(function(t){const i=ot(e,t);s[t]=i||null})),s},_searchEngine:function(e){return e?0===e.search(si+"google.([^/?]*)")?"google":0===e.search(si+"bing.com")?"bing":0===e.search(si+"yahoo.com")?"yahoo":0===e.search(si+"duckduckgo.com")?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){const t=ri._searchEngine(e),i="yahoo"!=t?"q":"p",s={};if(!h(t)){s.$search_engine=t;const e=E?ot(E.referrer,i):"";e.length&&(s.ph_keyword=e)}return s},searchInfo:function(){const e=null==E?void 0:E.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:Zt,browserVersion:function(e,t){const i=Zt(e,t),s=ei[i];if(c(s))return null;for(let t=0;t<s.length;t++){const i=s[t],n=e.match(i);if(n)return parseFloat(n[n.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},os:function(e){for(let t=0;t<ti.length;t++){const[i,s]=ti[t],n=i.exec(e),r=n&&(o(s)?s(n,e):s);if(r)return r}return["",""]},device:ii,deviceType:function(e){const t=ii(e);return t===pt||t===ht||"Kobo"===t||"Kindle Fire"===t||t===Wt?dt:t===Ct||t===At||t===Mt||t===Bt?"Console":t===_t?"Wearable":t?lt:"Desktop"},referrer:function(){return(null==E?void 0:E.referrer)||"$direct"},referringDomain:function(){var e;return null!=E&&E.referrer&&(null===(e=st(E.referrer))||void 0===e?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},initialPersonInfo:function(){return{r:this.referrer(),u:null==x?void 0:x.href}},initialPersonPropsFromInfo:function(e){var t;const{r:i,u:s}=e,n={$initial_referrer:i,$initial_referring_domain:null==i?void 0:"$direct"==i?"$direct":null===(t=st(i))||void 0===t?void 0:t.host};if(s){n.$initial_current_url=s;const e=st(s);n.$initial_host=null==e?void 0:e.host,n.$initial_pathname=null==e?void 0:e.pathname;L(this._campaignParamsFromUrl(s),(function(e,t){n["$initial_"+U(t)]=e}))}if(i){L(this._searchInfoFromReferrer(i),(function(e,t){n["$initial_"+U(t)]=e}))}return n},properties:function(){if(!R)return{};const[t,i]=ri.os(R);return O(H({$os:t,$os_version:i,$browser:ri.browser(R,navigator.vendor),$device:ri.device(R),$device_type:ri.deviceType(R)}),{$current_url:null==x?void 0:x.href,$host:null==x?void 0:x.host,$pathname:null==x?void 0:x.pathname,$raw_user_agent:R.length>1e3?R.substring(0,997)+"...":R,$browser_version:ri.browserVersion(R,navigator.vendor),$browser_language:ri.browserLanguage(),$screen_height:null==v?void 0:v.screen.height,$screen_width:null==v?void 0:v.screen.width,$viewport_height:null==v?void 0:v.innerHeight,$viewport_width:null==v?void 0:v.innerWidth,$lib:"web",$lib_version:e.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!R)return{};const[e,t]=ri.os(R);return O(H({$os:e,$os_version:t,$browser:ri.browser(R,navigator.vendor)}),{$browser_version:ri.browserVersion(R,navigator.vendor)})}},oi=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class ai{constructor(e){this.config=e,this.props={},this.campaign_params_saved=!1,this.name=(e=>{let 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&&T.info("Persistence loaded",e.persistence,{...this.props}),this.update_config(e,e),this.save()}buildStorage(e){let t;-1===oi.indexOf(e.persistence.toLowerCase())&&(T.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const i=e.persistence.toLowerCase();return t="localstorage"===i&&Je.is_supported()?Je:"localstorage+cookie"===i&&Xe.is_supported()?Xe:"sessionstorage"===i&&tt.is_supported()?tt:"memory"===i?Ze:"cookie"===i?je:Xe.is_supported()?Xe:je,t}properties(){const e={};return L(this.props,(function(t,i){if(i===ge&&a(t)){const i=Object.keys(t);for(let s=0;s<i.length;s++)e[`$feature/${i[s]}`]=t[i[s]]}else(function(e,t){let i=!1;return h(e)?i:w&&e.indexOf===w?-1!=e.indexOf(t):(L(e,(function(e){if(i||(i=e===t))return C})),i)})(Pe,i)||(e[i]=t)})),e}load(){if(this.disabled)return;const e=this.storage.parse(this.name);e&&(this.props=O({},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(a(e)){c(t)&&(t="None"),this.expire_days=c(i)?this.default_expiry:i;let s=!1;if(L(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(a(e)){this.expire_days=c(t)?this.default_expiry:t;let i=!1;if(L(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(){this.campaign_params_saved||(this.register(ri.campaignParams(this.config.custom_campaign_params)),this.campaign_params_saved=!0)}update_search_keyword(){this.register(ri.searchInfo())}update_referrer_info(){this.register_once(ri.referrerInfo(),void 0)}set_initial_person_info(){this.props[xe]||this.props[ke]||this.register_once({[Ie]:ri.initialPersonInfo()},void 0)}get_referrer_info(){return H({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){const e={};L([ke,xe],(t=>{const i=this.props[t];i&&L(i,(function(t,i){e["$initial_"+U(i)]=t}))}));const t=this.props[Ie];if(t){const i=ri.initialPersonPropsFromInfo(t);O(e,i)}return e}safe_merge(e){return L(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t){if(this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){const t=this.buildStorage(e),i=this.props;this.clear(),this.storage=t,this.props=i,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())}get_cross_subdomain(){return!!this.cross_subdomain}set_secure(e){e!==this.secure&&(this.secure=e,this.remove(),this.save())}set_event_timer(e,t){const i=this.props[X]||{};i[e]=t,this.props[X]=i,this.save()}remove_event_timer(e){const t=(this.props[X]||{})[e];return c(t)||(delete this.props[X][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}function li(e){var t;return(null===(t=JSON.stringify(e,function(){const e=[];return function(t,i){if(a(i)){for(;e.length>0&&e.at(-1)!==this;)e.pop();return e.includes(i)?"[Circular]":(e.push(i),i)}return i}}()))||void 0===t?void 0:t.length)||0}function ci(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6606028.8;if(e.size>=t&&e.data.length>1){const t=Math.floor(e.data.length/2),i=e.data.slice(0,t),s=e.data.slice(t);return[ci({size:li(i),data:i,sessionId:e.sessionId,windowId:e.windowId}),ci({size:li(s),data:s,sessionId:e.sessionId,windowId:e.windowId})].flatMap((e=>e))}return[e]}var ui=(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))(ui||{}),di=(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))(di||{});function hi(e){return e?M(e).split(/\s+/):[]}function pi(e){const t=null==v?void 0:v.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function gi(e){let 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 hi(t)}function _i(e){return p(e)?null:M(e).split(/(\s+)/).filter((e=>Mi(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function fi(e){let t="";return ki(e)&&!Ii(e)&&e.childNodes&&e.childNodes.length&&L(e.childNodes,(function(e){var i;yi(e)&&e.textContent&&(t+=null!==(i=_i(e.textContent))&&void 0!==i?i:"")})),M(t)}function vi(e){return c(e.target)?e.srcElement||null:null!==(t=e.target)&&void 0!==t&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}function mi(e){return!!e&&1===e.nodeType}function bi(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function yi(e){return!!e&&3===e.nodeType}function wi(e){return!!e&&11===e.nodeType}const Si=["a","button","form","input","select","textarea","label"];function Ei(e){const t=e.parentNode;return!(!t||!mi(t))&&t}function xi(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;if(!v||!e||bi(e,"html")||!mi(e))return!1;if(null!=i&&i.url_allowlist&&!pi(i.url_allowlist))return!1;if(null!=i&&i.url_ignorelist&&pi(i.url_ignorelist))return!1;if(null!=i&&i.dom_event_allowlist){const e=i.dom_event_allowlist;if(e&&!e.some((e=>t.type===e)))return!1}let r=!1;const o=[e];let a=!0,l=e;for(;l.parentNode&&!bi(l,"body");)if(wi(l.parentNode))o.push(l.parentNode.host),l=l.parentNode.host;else{if(a=Ei(l),!a)break;if(s||Si.indexOf(a.tagName.toLowerCase())>-1)r=!0;else{const e=v.getComputedStyle(a);e&&"pointer"===e.getPropertyValue("cursor")&&(r=!0)}o.push(a),l=a}if(!function(e,t){const i=null==t?void 0:t.element_allowlist;if(c(i))return!0;for(const t of e)if(i.some((e=>t.tagName.toLowerCase()===e)))return!0;return!1}(o,i))return!1;if(!function(e,t){const i=null==t?void 0:t.css_selector_allowlist;if(c(i))return!0;for(const t of e)if(i.some((e=>t.matches(e))))return!0;return!1}(o,i))return!1;const u=v.getComputedStyle(e);if(u&&"pointer"===u.getPropertyValue("cursor")&&"click"===t.type)return!0;const d=e.tagName.toLowerCase();switch(d){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 r?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(Si.indexOf(d)>-1||"true"===e.getAttribute("contenteditable"))}}function ki(e){for(let t=e;t.parentNode&&!bi(t,"body");t=t.parentNode){const e=gi(t);if(D(e,"ph-sensitive")||D(e,"ph-no-capture"))return!1}if(D(gi(e),"ph-include"))return!0;const t=e.type||"";if(u(t))switch(t.toLowerCase()){case"hidden":case"password":return!1}const i=e.name||e.id||"";if(u(i)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function Ii(e){return!!(bi(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||bi(e,"select")||bi(e,"textarea")||"true"===e.getAttribute("contenteditable"))}const Fi="(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})",Ri=new RegExp(`^(?:${Fi})$`),Pi=new RegExp(Fi),$i="\\d{3}-?\\d{2}-?\\d{4}",Ti=new RegExp(`^(${$i})$`),Ci=new RegExp(`(${$i})`);function Mi(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(p(e))return!1;if(u(e)){e=M(e);if((t?Ri:Pi).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Ti:Ci).test(e))return!1}return!0}function Ai(e){let t=fi(e);return t=`${t} ${Li(e)}`.trim(),Mi(t)?t:""}function Li(e){let t="";return e&&e.childNodes&&e.childNodes.length&&L(e.childNodes,(function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{const i=fi(e);t=`${t} ${i}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${Li(e)}`.trim())}catch(e){T.error(e)}})),t}function Oi(e){return function(e){const t=e.map((e=>{var t,i;let s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class){e.attr_class.sort();for(const t of e.attr_class)s+=`.${t.replace(/"/g,"")}`}const n={...e.text?{text:e.text}:{},"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0,...e.href?{href:e.href}:{},...e.attr_id?{attr_id:e.attr_id}:{},...e.attributes},r={};return N(n).sort(((e,t)=>{let[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{let[t,i]=e;return r[Di(t.toString())]=Di(i.toString())})),s+=":",s+=N(n).map((e=>{let[t,i]=e;return`${t}="${i}"`})).join(""),s}));return t.join(";")}(function(e){return e.map((e=>{var t,i;const s={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:Ni(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return N(e).filter((e=>{let[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{let[t,i]=e;return s.attributes[t]=i})),s}))}(e))}function Di(e){return e.replace(/"|\\"/g,'\\"')}function Ni(e){const t=e.attr__class;return t?r(t)?t:hi(t):void 0}const qi="[SessionRecording]",Bi="redacted",Hi={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"]},Ui=["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"],Wi=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],zi=["/s/","/e/","/i/"];function Vi(e,t,i,s){if(p(e))return e;let n=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return u(n)&&(n=parseInt(n)),n>i?qi+` ${s} body too large to record (${n} bytes)`:e}function Gi(e,t){if(p(e))return e;let i=e;return Mi(i,!1)||(i=qi+" "+t+" body "+Bi),L(Wi,(e=>{var s,n;null!==(s=i)&&void 0!==s&&s.length&&-1!==(null===(n=i)||void 0===n?void 0:n.indexOf(e))&&(i=qi+" "+t+" body "+Bi+" as might contain: "+e)})),i}const ji=(e,t)=>{const i={payloadSizeLimitBytes:Hi.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...Hi.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...Hi.payloadHostDenyList]},s=!1!==e.session_recording.recordHeaders&&t.recordHeaders,n=!1!==e.session_recording.recordBody&&t.recordBody,r=!1!==e.capture_performance&&t.recordPerformance,a=(e=>{var t;const i=Math.min(1e6,null!==(t=e.payloadSizeLimitBytes)&&void 0!==t?t:1e6);return e=>(null!=e&&e.requestBody&&(e.requestBody=Vi(e.requestBody,e.requestHeaders,i,"Request")),null!=e&&e.responseBody&&(e.responseBody=Vi(e.responseBody,e.responseHeaders,i,"Response")),e)})(i),l=e=>a((e=>{const t=st(e.name);if(!(t&&t.pathname&&zi.some((e=>0===t.pathname.indexOf(e)))))return e})((e=>{const t=e.requestHeaders;return p(t)||L(Object.keys(null!=t?t:{}),(e=>{Ui.includes(e.toLowerCase())&&(t[e]=Bi)})),e})(e))),u=o(e.session_recording.maskNetworkRequestFn);return u&&o(e.session_recording.maskCapturedNetworkRequestFn)&&T.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),u&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{const i=e.session_recording.maskNetworkRequestFn({url:t.name});return{...t,name:null==i?void 0:i.url}}),i.maskRequestFn=o(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,s,n;const r=l(t);return r&&null!==(i=null===(s=(n=e.session_recording).maskCapturedNetworkRequestFn)||void 0===s?void 0:s.call(n,r))&&void 0!==i?i:void 0}:e=>function(e){if(!c(e))return e.requestBody=Gi(e.requestBody,"Request"),e.responseBody=Gi(e.responseBody,"Response"),e}(l(e)),{...Hi,...i,recordHeaders:s,recordBody:n,recordPerformance:r,recordInitialRequests:r}};class Qi{bucketSize=100;refillRate=10;mutationBuckets={};loggedTracker={};constructor(e){var t,i;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.rrweb=e,this.options=s,this.refillRate=null!==(t=this.options.refillRate)&&void 0!==t?t:this.refillRate,this.bucketSize=null!==(i=this.options.bucketSize)&&void 0!==i?i:this.bucketSize,setInterval((()=>{this.refillBuckets()}),1e3)}refillBuckets=()=>{Object.keys(this.mutationBuckets).forEach((e=>{this.mutationBuckets[e]=this.mutationBuckets[e]+this.refillRate,this.mutationBuckets[e]>=this.bucketSize&&delete this.mutationBuckets[e]}))};getNodeOrRelevantParent=e=>{const t=this.rrweb.mirror.getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){const e=t.closest("svg");if(e)return[this.rrweb.mirror.getId(e),e]}return[e,t]};numberOfChanges=e=>{var t,i,s,n,r,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(s=null===(n=e.attributes)||void 0===n?void 0:n.length)&&void 0!==s?s:0)+(null!==(r=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==r?r:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)};throttleMutations=e=>{if(3!==e.type||0!==e.data.source)return e;const t=e.data,i=this.numberOfChanges(t);t.attributes&&(t.attributes=t.attributes.filter((e=>{var t;const[i,s]=this.getNodeOrRelevantParent(e.id);if(0===this.mutationBuckets[i])return!1;var n,r;(this.mutationBuckets[i]=null!==(t=this.mutationBuckets[i])&&void 0!==t?t:this.bucketSize,this.mutationBuckets[i]=Math.max(this.mutationBuckets[i]-1,0),0===this.mutationBuckets[i])&&(this.loggedTracker[i]||(this.loggedTracker[i]=!0,null===(n=(r=this.options).onBlockedNode)||void 0===n||n.call(r,i,s)));return e})));const s=this.numberOfChanges(t);return 0!==s||i===s?e:void 0}}var Ji=Uint8Array,Yi=Uint16Array,Xi=Uint32Array,Ki=new Ji([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]),Zi=new Ji([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]),es=new Ji([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ts=function(e,t){for(var i=new Yi(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var n=new Xi(i[30]);for(s=1;s<30;++s)for(var r=i[s];r<i[s+1];++r)n[r]=r-i[s]<<5|s;return[i,n]},is=ts(Ki,2),ss=is[0],ns=is[1];ss[28]=258,ns[258]=28;for(var rs=ts(Zi,0)[1],os=new Yi(32768),as=0;as<32768;++as){var ls=(43690&as)>>>1|(21845&as)<<1;ls=(61680&(ls=(52428&ls)>>>2|(13107&ls)<<2))>>>4|(3855&ls)<<4,os[as]=((65280&ls)>>>8|(255&ls)<<8)>>>1}var cs=function(e,t,i){for(var s=e.length,n=0,r=new Yi(t);n<s;++n)++r[e[n]-1];var o,a=new Yi(t);for(n=0;n<t;++n)a[n]=a[n-1]+r[n-1]<<1;if(i){o=new Yi(1<<t);var l=15-t;for(n=0;n<s;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],d=a[e[n]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)o[os[d]>>>l]=c}else for(o=new Yi(s),n=0;n<s;++n)o[n]=os[a[e[n]-1]++]>>>15-e[n];return o},us=new Ji(288);for(as=0;as<144;++as)us[as]=8;for(as=144;as<256;++as)us[as]=9;for(as=256;as<280;++as)us[as]=7;for(as=280;as<288;++as)us[as]=8;var ds=new Ji(32);for(as=0;as<32;++as)ds[as]=5;var hs=cs(us,9,0),ps=cs(ds,5,0),gs=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 Yi?Yi:e instanceof Xi?Xi:Ji)(i-t);return s.set(e.subarray(t,i)),s},fs=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},vs=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},ms=function(e,t){for(var i=[],s=0;s<e.length;++s)e[s]&&i.push({s:s,f:e[s]});var n=i.length,r=i.slice();if(!n)return[new Ji(0),0];if(1==n){var o=new Ji(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=r[0].s;for(s=1;s<n;++s)r[s].s>h&&(h=r[s].s);var p=new Yi(h+1),g=bs(i[u-1],p,0);if(g>t){s=0;var _=0,f=g-t,v=1<<f;for(r.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));s<n;++s){var m=r[s].s;if(!(p[m]>t))break;_+=v-(1<<g-p[m]),p[m]=t}for(_>>>=f;_>0;){var b=r[s].s;p[b]<t?_-=1<<t-p[b]++-1:++s}for(;s>=0&&_;--s){var y=r[s].s;p[y]==t&&(--p[y],++_)}g=t}return[new Ji(p),g]},bs=function(e,t,i){return-1==e.s?Math.max(bs(e.l,t,i+1),bs(e.r,t,i+1)):t[e.s]=i},ys=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Yi(++t),s=0,n=e[0],r=1,o=function(e){i[s++]=e},a=1;a<=t;++a)if(e[a]==n&&a!=t)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=e[a]}return[i.subarray(0,s),t]},ws=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Ss=function(e,t,i){var s=i.length,n=gs(t+2);e[n]=255&s,e[n+1]=s>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var r=0;r<s;++r)e[n+r+4]=i[r];return 8*(n+4+s)},Es=function(e,t,i,s,n,r,o,a,l,c,u){fs(t,u++,i),++n[256];for(var d=ms(n,15),h=d[0],p=d[1],g=ms(r,15),_=g[0],f=g[1],v=ys(h),m=v[0],b=v[1],y=ys(_),w=y[0],S=y[1],E=new Yi(19),x=0;x<m.length;++x)E[31&m[x]]++;for(x=0;x<w.length;++x)E[31&w[x]]++;for(var k=ms(E,7),I=k[0],F=k[1],R=19;R>4&&!I[es[R-1]];--R);var P,$,T,C,M=c+5<<3,A=ws(n,us)+ws(r,ds)+o,L=ws(n,h)+ws(r,_)+o+14+3*R+ws(E,I)+(2*E[16]+3*E[17]+7*E[18]);if(M<=A&&M<=L)return Ss(t,u,e.subarray(l,l+c));if(fs(t,u,1+(L<A)),u+=2,L<A){P=cs(h,p,0),$=h,T=cs(_,f,0),C=_;var O=cs(I,F,0);fs(t,u,b-257),fs(t,u+5,S-1),fs(t,u+10,R-4),u+=14;for(x=0;x<R;++x)fs(t,u+3*x,I[es[x]]);u+=3*R;for(var D=[m,w],N=0;N<2;++N){var q=D[N];for(x=0;x<q.length;++x){var B=31&q[x];fs(t,u,O[B]),u+=I[B],B>15&&(fs(t,u,q[x]>>>5&127),u+=q[x]>>>12)}}}else P=hs,$=us,T=ps,C=ds;for(x=0;x<a;++x)if(s[x]>255){B=s[x]>>>18&31;vs(t,u,P[B+257]),u+=$[B+257],B>7&&(fs(t,u,s[x]>>>23&31),u+=Ki[B]);var H=31&s[x];vs(t,u,T[H]),u+=C[H],H>3&&(vs(t,u,s[x]>>>5&8191),u+=Zi[H])}else vs(t,u,P[s[x]]),u+=$[s[x]];return vs(t,u,P[256]),u+$[256]},xs=new Xi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ks=function(){for(var e=new Xi(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Is=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=ks[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}},Fs=function(e,t,i,s,n){return function(e,t,i,s,n,r){var o=e.length,a=new Ji(s+o+5*(1+Math.floor(o/7e3))+n),l=a.subarray(s,a.length-n),c=0;if(!t||o<8)for(var u=0;u<=o;u+=65535){var d=u+65535;d<o?c=Ss(l,c,e.subarray(u,d)):(l[u]=r,c=Ss(l,c,e.subarray(u,o)))}else{for(var h=xs[t-1],p=h>>>13,g=8191&h,_=(1<<i)-1,f=new Yi(32768),v=new Yi(_+1),m=Math.ceil(i/3),b=2*m,y=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<b)&_},w=new Xi(25e3),S=new Yi(288),E=new Yi(32),x=0,k=0,I=(u=0,0),F=0,R=0;u<o;++u){var P=y(u),$=32767&u,T=v[P];if(f[$]=T,v[P]=$,F<=u){var C=o-u;if((x>7e3||I>24576)&&C>423){c=Es(e,l,0,w,S,E,k,I,R,u-R,c),I=x=k=0,R=u;for(var M=0;M<286;++M)S[M]=0;for(M=0;M<30;++M)E[M]=0}var A=2,L=0,O=g,D=$-T&32767;if(C>2&&P==y(u-D))for(var N=Math.min(p,C)-1,q=Math.min(32767,u),B=Math.min(258,C);D<=q&&--O&&$!=T;){if(e[u+A]==e[u+A-D]){for(var H=0;H<B&&e[u+H]==e[u+H-D];++H);if(H>A){if(A=H,L=D,H>N)break;var U=Math.min(D,H-2),W=0;for(M=0;M<U;++M){var z=u-D+M+32768&32767,V=z-f[z]+32768&32767;V>W&&(W=V,T=z)}}}D+=($=T)-(T=f[$])+32768&32767}if(L){w[I++]=268435456|ns[A]<<18|rs[L];var G=31&ns[A],j=31&rs[L];k+=Ki[G]+Zi[j],++S[257+G],++E[j],F=u+A,++x}else w[I++]=e[u],++S[e[u]]}}c=Es(e,l,r,w,S,E,k,I,R,u-R,c)}return _s(a,0,s+gs(c)+n)}(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,!n)},Rs=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},Ps=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&&Rs(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)}},$s=function(e){return 10+(e.filename&&e.filename.length+1||0)};function Ts(e,t){void 0===t&&(t={});var i=Is(),s=e.length;i.p(e);var n=Fs(e,t,$s(t),8),r=n.length;return Ps(n,t),Rs(n,r-8,i.d()),Rs(n,r-4,s),n}function Cs(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new Ji(e.length+(e.length>>>1)),n=0,r=function(e){s[n++]=e},o=0;o<i;++o){if(n+5>s.length){var a=new Ji(n+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);l<128||t?r(l):l<2048?(r(192|l>>>6),r(128|63&l)):l>55295&&l<57344?(r(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),r(128|l>>>12&63),r(128|l>>>6&63),r(128|63&l)):(r(224|l>>>12),r(128|l>>>6&63),r(128|63&l))}return _s(s,0,n)}const Ms=3e5,As=[di.MouseMove,di.MouseInteraction,di.Scroll,di.ViewportResize,di.Input,di.TouchMove,di.MediaInteraction,di.Drag],Ls=["trigger_activated","trigger_pending","trigger_disabled"],Os=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1}),Ds="[SessionRecording]";function Ns(e){return function(e,t){for(var i="",s=0;s<e.length;){var n=e[s++];n<128||t?i+=String.fromCharCode(n):n<224?i+=String.fromCharCode((31&n)<<6|63&e[s++]):n<240?i+=String.fromCharCode((15&n)<<12|(63&e[s++])<<6|63&e[s++]):(n=((15&n)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536,i+=String.fromCharCode(55296|n>>10,56320|1023&n))}return i}(Ts(Cs(JSON.stringify(e))),!0)}function qs(e){return e.type===ui.Custom&&"sessionIdle"===e.data.tag}class Bs{queuedRRWebEvents=[];isIdle=!1;_linkedFlagSeen=!1;_lastActivityTimestamp=Date.now();_linkedFlag=null;_removePageViewCaptureHook=void 0;_onSessionIdListener=void 0;_persistDecideOnSessionListener=void 0;_samplingSessionListener=void 0;_urlTriggers=[];_forceAllowLocalhostNetworkCapture=!1;get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get rrwebRecord(){var e,t;return null==P||null===(e=P.__PosthogExtensions__)||void 0===e||null===(t=e.rrweb)||void 0===t?void 0:t.record}get started(){return this._captureStarted}get sessionManager(){if(!this.instance.sessionManager)throw new Error(Ds+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var e,t;return"trigger_pending"===this.urlTriggerStatus?6e4:null!==(e=null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.full_snapshot_interval_millis)&&void 0!==e?e:Ms}get isSampled(){const e=this.instance.get_property(de);return _(e)?e:null}get sessionDuration(){var e,t;const i=null===(e=this.buffer)||void 0===e?void 0:e.data[(null===(t=this.buffer)||void 0===t?void 0:t.data.length)-1],{sessionStartTimestamp:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return i?i.timestamp-s:null}get isRecordingEnabled(){const e=!!this.instance.get_property(ne),t=!this.instance.config.disable_session_recording;return v&&e&&t}get isConsoleLogCaptureEnabled(){const e=!!this.instance.get_property(re),t=this.instance.config.enable_recording_console_log;return null!=t?t:e}get canvasRecording(){const e=this.instance.get_property(ae);return e&&e.fps&&e.quality?{enabled:e.enabled,fps:e.fps,quality:e.quality}:void 0}get networkPayloadCapture(){var e,t;const i=this.instance.get_property(oe),s={recordHeaders:null===(e=this.instance.config.session_recording)||void 0===e?void 0:e.recordHeaders,recordBody:null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.recordBody},n=(null==s?void 0:s.recordHeaders)||(null==i?void 0:i.recordHeaders),r=(null==s?void 0:s.recordBody)||(null==i?void 0:i.recordBody),o=a(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,l=!!(_(o)?o:null==i?void 0:i.capturePerformance);return n||r||l?{recordHeaders:n,recordBody:r,recordPerformance:l}:void 0}get sampleRate(){const e=this.instance.get_property(le);return g(e)?e:null}get minimumDuration(){const e=this.instance.get_property(ce);return g(e)?e:null}get status(){return this.receivedDecide?this.isRecordingEnabled?p(this._linkedFlag)||this._linkedFlagSeen?"trigger_pending"===this.urlTriggerStatus?"buffering":_(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var e,t;if(this.receivedDecide&&0===this._urlTriggers.length)return"trigger_disabled";const i=null===(e=this.instance)||void 0===e?void 0:e.get_property(pe);var s,n,r,o;return(null===(t=this.instance)||void 0===t?void 0:t.get_property(he))!==this.sessionId?(null===(s=this.instance)||void 0===s||null===(n=s.persistence)||void 0===n||n.unregister(he),null===(r=this.instance)||void 0===r||null===(o=r.persistence)||void 0===o||o.unregister(pe),"trigger_pending"):Ls.includes(i)?i:"trigger_pending"}set urlTriggerStatus(e){var t,i;null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({[he]:this.sessionId,[pe]:e})}constructor(e){if(this.instance=e,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw T.error(Ds+" started without valid sessionManager"),new Error(Ds+" started without valid sessionManager. This is a bug.");const{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=t,this.windowId=i,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&T.warn(Ds+` session_idle_threshold_ms (${this.sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this.sessionManager.sessionTimeoutMs}). Session will never be detected as idle`)}_onBeforeUnload=()=>{this._flushBuffer()};_onOffline=()=>{this._tryAddCustomEvent("browser offline",{})};_onOnline=()=>{this._tryAddCustomEvent("browser online",{})};_onVisibilityChange=()=>{if(null!=E&&E.visibilityState){const e="window "+E.visibilityState;this._tryAddCustomEvent(e,{})}};startIfEnabledOrStop(e){this.isRecordingEnabled?(this._startCapture(e),null==v||v.addEventListener("beforeunload",this._onBeforeUnload),null==v||v.addEventListener("offline",this._onOffline),null==v||v.addEventListener("online",this._onOnline),null==v||v.addEventListener("visibilitychange",this._onVisibilityChange),this._setupSampling(),p(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance._addCaptureHook((e=>{try{if("$pageview"===e){const e=v?this._maskUrl(v.location.href):"";if(!e)return;this._tryAddCustomEvent("$pageview",{href:e})}}catch(e){T.error("Could not add $pageview to rrweb session",e)}}))),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId(((e,t,i)=>{var s,n,r,o;i&&(this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),null===(s=this.instance)||void 0===s||null===(n=s.persistence)||void 0===n||n.unregister(he),null===(r=this.instance)||void 0===r||null===(o=r.persistence)||void 0===o||o.unregister(pe))})))):this.stopRecording()}stopRecording(){var e,t,i;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,null==v||v.removeEventListener("beforeunload",this._onBeforeUnload),null==v||v.removeEventListener("offline",this._onOffline),null==v||v.removeEventListener("online",this._onOnline),null==v||v.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),null===(e=this._removePageViewCaptureHook)||void 0===e||e.call(this),this._removePageViewCaptureHook=void 0,null===(t=this._onSessionIdListener)||void 0===t||t.call(this),this._onSessionIdListener=void 0,null===(i=this._samplingSessionListener)||void 0===i||i.call(this),this._samplingSessionListener=void 0,T.info(Ds+" stopped"))}makeSamplingDecision(e){var t;const i=this.sessionId!==e,s=this.sampleRate;var n;if(!g(s))return void(null===(n=this.instance.persistence)||void 0===n||n.register({[de]:null}));const r=this.isSampled;let o;const a=i||!_(r);if(a){o=Math.random()<s}else o=r;a&&(o?this._reportStarted("sampling"):T.warn(Ds+` 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)||void 0===t||t.register({[de]:o})}afterDecideResponse(e){var t,i,s,n;(this._persistDecideResponse(e),this._linkedFlag=(null===(t=e.sessionRecording)||void 0===t?void 0:t.linkedFlag)||null,null!==(i=e.sessionRecording)&&void 0!==i&&i.endpoint)&&(this._endpoint=null===(n=e.sessionRecording)||void 0===n?void 0:n.endpoint);if(this._setupSampling(),!p(this._linkedFlag)&&!this._linkedFlagSeen){const e=u(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,t=u(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags(((i,s)=>{const n=a(s)&&e in s,r=t?s[e]===t:n;if(r){const i={linkedFlag:e,linkedVariant:t},s="linked flag matched";T.info(Ds+" "+s,i),this._tryAddCustomEvent(s,i),this._reportStarted("linked_flag_match")}this._linkedFlagSeen=r}))}null!==(s=e.sessionRecording)&&void 0!==s&&s.urlTriggers&&(this._urlTriggers=e.sessionRecording.urlTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){g(this.sampleRate)&&p(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId((e=>{this.makeSamplingDecision(e)})))}_persistDecideResponse(e){if(this.instance.persistence){var t;const i=this.instance.persistence,s=()=>{var t,s,n,r,o,a,l;const u=null===(t=e.sessionRecording)||void 0===t?void 0:t.sampleRate,d=p(u)?null:parseFloat(u),h=null===(s=e.sessionRecording)||void 0===s?void 0:s.minimumDurationMilliseconds;i.register({[ne]:!!e.sessionRecording,[re]:null===(n=e.sessionRecording)||void 0===n?void 0:n.consoleLogRecordingEnabled,[oe]:{capturePerformance:e.capturePerformance,...null===(r=e.sessionRecording)||void 0===r?void 0:r.networkPayloadCapture},[ae]:{enabled:null===(o=e.sessionRecording)||void 0===o?void 0:o.recordCanvas,fps:null===(a=e.sessionRecording)||void 0===a?void 0:a.canvasFps,quality:null===(l=e.sessionRecording)||void 0===l?void 0:l.canvasQuality},[le]:d,[ce]:c(h)?null:h})};s(),null===(t=this._persistDecideOnSessionListener)||void 0===t||t.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(s)}}log(e){var t;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"log";null===(t=this.instance.sessionRecording)||void 0===t||t.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:i,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}_startCapture(e){if(!c(Object.assign)&&!c(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var t,i;if(this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),this.rrwebRecord)this._onScriptLoaded();else null===(t=P.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"recorder",(e=>{if(e)return T.error(Ds+" could not load recorder",e);this._onScriptLoaded()}));T.info(Ds+" starting"),"active"===this.status&&this._reportStarted(e||"recording_initialized")}}isInteractiveEvent(e){var t;return 3===e.type&&-1!==As.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){const t=this.isInteractiveEvent(e);if(!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())}let i=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)),this.isIdle)return;const{windowId:s,sessionId:n}=this.sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),r=this.sessionId!==n,o=this.windowId!==s;this.windowId=s,this.sessionId=n,r||o?(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}):T.warn(Ds+" could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(Os((()=>this.rrwebRecord.addCustomEvent(e,t))))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(Os((()=>this.rrwebRecord.takeFullSnapshot())))}_onScriptLoaded(){var e;const t={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},i=this.instance.config.session_recording;for(const[e,s]of Object.entries(i||{}))e in t&&("maskInputOptions"===e?t.maskInputOptions={password:!0,...s}:t[e]=s);if(this.canvasRecording&&this.canvasRecording.enabled&&(t.recordCanvas=!0,t.sampling={canvas:this.canvasRecording.fps},t.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),!this.rrwebRecord)return void T.error(Ds+"onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.");this.mutationRateLimiter=null!==(e=this.mutationRateLimiter)&&void 0!==e?e:new Qi(this.rrwebRecord,{onBlockedNode:(e,t)=>{const i=`Too many mutations on node '${e}'. Rate limiting. This could be due to SVG animations or something similar`;T.info(i,{node:t}),this.log(Ds+" "+i,"warn")}});const s=this._gatherRRWebPlugins();this.stopRrweb=this.rrwebRecord({emit:e=>{this.onRRwebEmit(e)},plugins:s,...t}),this._lastActivityTimestamp=Date.now(),this.isIdle=!1,this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:t,activePlugins:s.map((e=>null==e?void 0:e.name))}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),this.isIdle)return;const e=this.fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval((()=>{this._tryTakeFullSnapshot()}),e))}_gatherRRWebPlugins(){var e,t,i,s;const n=[],r=null===(e=P.__PosthogExtensions__)||void 0===e||null===(t=e.rrwebPlugins)||void 0===t?void 0:t.getRecordConsolePlugin;r&&this.isConsoleLogCaptureEnabled&&n.push(r());const a=null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.rrwebPlugins)||void 0===s?void 0:s.getRecordNetworkPlugin;if(this.networkPayloadCapture&&o(a)){!it.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?n.push(a(ji(this.instance.config,this.networkPayloadCapture))):T.info(Ds+" NetworkCapture not started because we are on localhost.")}return n}onRRwebEmit(e){var t;if(this._processQueuedEvents(),!e||!a(e))return;if(e.type===ui.Meta){const t=this._maskUrl(e.data.href);if(this._lastHref=t,!t)return;e.data.href=t}else this._pageViewFallBack();this._checkUrlTrigger(),e.type===ui.FullSnapshot&&this._scheduleFullSnapshot(),e.type===ui.FullSnapshot&&"trigger_pending"===this.urlTriggerStatus&&this.clearBuffer();const i=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(e):e;if(!i)return;const s=function(e){const t=e;if(t&&a(t)&&6===t.type&&a(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]"));const i=[];for(let e=0;e<t.data.payload.payload.length;e++)t.data.payload.payload[e]&&t.data.payload.payload[e].length>2e3?i.push(t.data.payload.payload[e].slice(0,2e3)+"...[truncated]"):i.push(t.data.payload.payload[e]);return t.data.payload.payload=i,e}return e}(i);if(this._updateWindowAndSessionIds(s),this.isIdle&&!qs(s))return;if(qs(s)){const e=s.data.payload;if(e){const t=e.lastActivityTimestamp,i=e.threshold;s.timestamp=t+i}}const n=null===(t=this.instance.config.session_recording.compress_events)||void 0===t||t?function(e){if(li(e)<1024)return e;try{if(e.type===ui.FullSnapshot)return{...e,data:Ns(e.data),cv:"2024-10"};if(e.type===ui.IncrementalSnapshot&&e.data.source===di.Mutation)return{...e,cv:"2024-10",data:{...e.data,texts:Ns(e.data.texts),attributes:Ns(e.data.attributes),removes:Ns(e.data.removes),adds:Ns(e.data.adds)}};if(e.type===ui.IncrementalSnapshot&&e.data.source===di.StyleSheetRule)return{...e,cv:"2024-10",data:{...e.data,adds:Ns(e.data.adds),removes:Ns(e.data.removes)}}}catch(e){T.error(Ds+" could not compress event - will use uncompressed event",e)}return e}(s):s,r={$snapshot_bytes:li(n),$snapshot_data:n,$session_id:this.sessionId,$window_id:this.windowId};"disabled"!==this.status?this._captureSnapshotBuffered(r):this.clearBuffer()}_pageViewFallBack(){if(this.instance.config.capture_pageview||!v)return;const e=this._maskUrl(v.location.href);this._lastHref!==e&&(this._tryAddCustomEvent("$url_changed",{href:e}),this._lastHref=e)}_processQueuedEvents(){if(this.queuedRRWebEvents.length){const e=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],e.forEach((e=>{Date.now()-e.enqueuedAt<=2e3&&this._tryRRWebMethod(e)}))}}_maskUrl(e){const t=this.instance.config.session_recording;if(t.maskNetworkRequestFn){var i;let s={url:e};return s=t.maskNetworkRequestFn(s),null===(i=s)||void 0===i?void 0:i.url}return e}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);const e=this.minimumDuration,t=this.sessionDuration,i=g(t)&&t>=0,s=g(e)&&i&&t<e;if("buffering"===this.status||s)return this.flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3),this.buffer;if(this.buffer.data.length>0){ci(this.buffer).forEach((e=>{this._captureSnapshot({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId})}))}return this.clearBuffer()}_captureSnapshotBuffered(e){var t;const i=2+((null===(t=this.buffer)||void 0===t?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})}_checkUrlTrigger(){if(void 0===v||!v.location.href)return;const e=v.location.href;this._urlTriggers.some((t=>"regex"===t.matching&&new RegExp(t.url).test(e)))&&this._activateUrlTrigger()}_activateUrlTrigger(){"trigger_pending"===this.urlTriggerStatus&&(this.urlTriggerStatus="trigger_activated",this._tryAddCustomEvent("url trigger activated",{}),this._flushBuffer(),T.info(Ds+" recording triggered by URL pattern match"))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._reportStarted("linked_flag_override")}overrideSampling(){var e;null===(e=this.instance.persistence)||void 0===e||e.register({[de]:!0}),this._reportStarted("sampling_override")}_reportStarted(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>!0)()&&this.instance.register_for_session({$session_recording_start_reason:e})}}class Hs{constructor(e){this.instance=e,this.instance.decideEndpointWasHit=this.instance._hasBootstrappedFeatureFlags()}call(){const e={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),person_properties:this.instance.get_property(fe),group_properties:this.instance.get_property(ve),disable_flags:this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load||void 0};this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:e,compression:this.instance.config.disable_compression?void 0:Q.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:e=>this.parseDecideResponse(e.json)})}parseDecideResponse(e){this.instance.featureFlags.setReloadingPaused(!1),this.instance.featureFlags._startReloadTimer();const t=!e;if(this.instance.config.advanced_disable_feature_flags_on_first_load||this.instance.config.advanced_disable_feature_flags||this.instance.featureFlags.receivedFeatureFlags(null!=e?e:{},t),t)T.error("Failed to fetch feature flags from PostHog.");else{if(!E||!E.body)return T.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.parseDecideResponse(e)}),500);if(this.instance._afterDecideResponse(e),e.siteApps)if(this.instance.config.opt_in_site_apps)for(const{id:t,url:r}of e.siteApps){var i,s,n;P[`__$$ph_site_app_${t}`]=this.instance,null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=(n=i).loadSiteApp)||void 0===s||s.call(n,this.instance,r,(e=>{if(e)return T.error(`Error while initializing PostHog app with config id ${t}`,e)}))}else e.siteApps.length>0&&T.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}const Us=null!=v&&v.location?at(v.location.hash,"__posthog")||at(location.hash,"state"):null,Ws="_postHogToolbarParams";var zs;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"}(zs||(zs={}));class Vs{constructor(e){this.instance=e}setToolbarState(e){P.ph_toolbar_state=e}getToolbarState(){var e;return null!==(e=P.ph_toolbar_state)&&void 0!==e?e:zs.UNINITIALIZED}maybeLoadToolbar(){var e,t;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if(!v||!E)return!1;i=null!==(e=i)&&void 0!==e?e:v.location,n=null!==(t=n)&&void 0!==t?t:v.history;try{if(!s){try{v.localStorage.setItem("test","test"),v.localStorage.removeItem("test")}catch{return!1}s=null==v?void 0:v.localStorage}const e=Us||at(i.hash,"__posthog")||at(i.hash,"state");let t;const r=e?q((()=>JSON.parse(atob(decodeURIComponent(e)))))||q((()=>JSON.parse(decodeURIComponent(e)))):null;return r&&"ph_authorize"===r.action?(t=r,t.source="url",t&&Object.keys(t).length>0&&(r.desiredHash?i.hash=r.desiredHash:n?n.replaceState(n.state,"",i.pathname+i.search):i.hash="")):(t=JSON.parse(s.getItem(Ws)||"{}"),t.source="localstorage",delete t.userIntent),!(!t.token||this.instance.config.token!==t.token)&&(this.loadToolbar(t),!0)}catch{return!1}}_callLoadToolbar(e){(P.ph_load_toolbar||P.ph_load_editor)(e,this.instance)}loadToolbar(e){const t=!(null==E||!E.getElementById(Re));if(!v||t)return!1;const i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s={token:this.instance.config.token,...e,apiURL:this.instance.requestRouter.endpointFor("ui"),...i?{instrument:!1}:{}};if(v.localStorage.setItem(Ws,JSON.stringify({...s,source:void 0})),this.getToolbarState()===zs.LOADED)this._callLoadToolbar(s);else if(this.getToolbarState()===zs.UNINITIALIZED){var n,r;this.setToolbarState(zs.LOADING),null===(n=P.__PosthogExtensions__)||void 0===n||null===(r=n.loadExternalDependency)||void 0===r||r.call(n,this.instance,"toolbar",(e=>{if(e)return T.error("Failed to load toolbar",e),void this.setToolbarState(zs.UNINITIALIZED);this.setToolbarState(zs.LOADED),this._callLoadToolbar(s)})),V(v,"turbolinks:load",(()=>{this.setToolbarState(zs.UNINITIALIZED),this.loadToolbar(s)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return this.maybeLoadToolbar(e,t,i)}}class Gs{isPaused=!0;queue=[];flushTimeoutMs=3e3;constructor(e){this.sendRequest=e}enqueue(e){this.queue.push(e),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();const 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({...e,transport:"sendBeacon"})}))}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){this.isPaused||(this.flushTimeout=setTimeout((()=>{if(this.clearFlushTimeout(),this.queue.length>0){const e=this.formatQueue();for(const t in e){const i=e[t],s=(new Date).getTime();i.data&&r(i.data)&&L(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),this.sendRequest(i)}}}),this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){const e={};return L(this.queue,(t=>{var i;const s=t,n=(s?s.batchKey:null)||s.url;c(e[n])&&(e[n]={...s,data:[]}),null===(i=e[n].data)||void 0===i||i.push(s.data)})),this.queue=[],e}}const js=!!I||!!k,Qs="text/plain",Js=(e,t)=>{const[i,s]=e.split("?"),n={...t};null==s||s.split("&").forEach((e=>{const[t]=e.split("=");delete n[t]}));let r=rt(n);return r=r?(s?s+"&":"")+r:s,`${i}?${r}`},Ys=e=>{let{data:t,compression:i}=e;if(!t)return;if(i===Q.GZipJS){const e=Ts(Cs(JSON.stringify(t)),{mtime:0}),i=new Blob([e],{type:Qs});return{contentType:Qs,body:i,estimatedSize:i.size}}if(i===Q.Base64){const e=function(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let i,s,n,r,o,a,l,c,u=0,d=0,h="";const p=[];if(!e)return e;e=z(e);do{i=e.charCodeAt(u++),s=e.charCodeAt(u++),n=e.charCodeAt(u++),c=i<<16|s<<8|n,r=c>>18&63,o=c>>12&63,a=c>>6&63,l=63&c,p[d++]=t.charAt(r)+t.charAt(o)+t.charAt(a)+t.charAt(l)}while(u<e.length);switch(h=p.join(""),e.length%3){case 1:h=h.slice(0,-2)+"==";break;case 2:h=h.slice(0,-1)+"="}return h}(JSON.stringify(t)),i=(e=>"data="+encodeURIComponent("string"==typeof e?e:JSON.stringify(e)))(e);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}const s=JSON.stringify(t);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},Xs=e=>{var t;const i=new I;i.open(e.method||"GET",e.url,!0);const{contentType:s,body:n}=null!==(t=Ys(e))&&void 0!==t?t:{};L(e.headers,(function(e,t){i.setRequestHeader(t,e)})),s&&i.setRequestHeader("Content-Type",s),e.timeout&&(i.timeout=e.timeout),i.withCredentials=!0,i.onreadystatechange=()=>{if(4===i.readyState){var t;const s={statusCode:i.status,text:i.responseText};if(200===i.status)try{s.json=JSON.parse(i.responseText)}catch{}null===(t=e.callback)||void 0===t||t.call(e,s)}},i.send(n)},Ks=e=>{var t,i;const{contentType:s,body:n,estimatedSize:r}=null!==(t=Ys(e))&&void 0!==t?t:{},o=new Headers;L(e.headers,(function(e,t){o.append(t,e)})),s&&o.append("Content-Type",s);const a=e.url;let l=null;if(F){const t=new F;l={signal:t.signal,timeout:setTimeout((()=>t.abort()),e.timeout)}}k(a,{method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(r||0)<65536,body:n,signal:null===(i=l)||void 0===i?void 0:i.signal}).then((t=>t.text().then((i=>{var s;const n={statusCode:t.status,text:i};if(200===t.status)try{n.json=JSON.parse(i)}catch(e){T.error(e)}null===(s=e.callback)||void 0===s||s.call(e,n)})))).catch((t=>{var i;T.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,text:t})})).finally((()=>l?clearTimeout(l.timeout):null))},Zs=e=>{const t=Js(e.url,{beacon:"1"});try{var i;const{contentType:s,body:n}=null!==(i=Ys(e))&&void 0!==i?i:{},r="string"==typeof n?new Blob([n],{type:s}):n;S.sendBeacon(t,r)}catch{}},en=[];I&&en.push({transport:"XHR",method:Xs}),k&&en.push({transport:"fetch",method:Ks}),null!=S&&S.sendBeacon&&en.push({transport:"sendBeacon",method:Zs});class tn{isPolling=!1;pollIntervalMs=3e3;queue=[];constructor(e){this.instance=e,this.queue=[],this.areWeOnline=!0,!c(v)&&"onLine"in v.navigator&&(this.areWeOnline=v.navigator.onLine,v.addEventListener("online",(()=>{this.areWeOnline=!0,this.flush()})),v.addEventListener("offline",(()=>{this.areWeOnline=!1})))}retriableRequest(e){let{retriesPerformedSoFar:t,...i}=e;g(t)&&t>0&&(i.url=Js(i.url,{retry_count:t})),this.instance._send_request({...i,callback:e=>{var s;200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this.enqueue({retriesPerformedSoFar:t,...i}):null===(s=i.callback)||void 0===s||s.call(i,e)}})}enqueue(e){const t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;const i=function(e){const t=3e3*2**e,i=t/2,s=Math.min(18e5,t),n=(Math.random()-.5)*(s-i);return Math.ceil(s+n)}(t),s=Date.now()+i;this.queue.push({retryAt:s,requestOptions:e});let n=`Enqueued failed request for retry in ${i}`;navigator.onLine||(n+=" (Browser is offline)"),T.warn(n),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(){const e=Date.now(),t=[],i=this.queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this.queue=t,i.length>0)for(const{requestOptions:e}of i)this.retriableRequest(e)}unload(){this.poller&&(clearTimeout(this.poller),this.poller=void 0);for(const{requestOptions:e}of this.queue)try{this.instance._send_request({...e,transport:"sendBeacon"})}catch(e){T.error(e)}this.queue=[]}}const sn=1800;class nn{_sessionIdChangedHandlers=[];constructor(e,t,i,s){var n;this.config=e,this.persistence=t,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=i||He,this._windowIdGenerator=s||He;const r=e.persistence_name||e.token;let o=e.session_idle_timeout_seconds||sn;if(g(o)?o>sn?T.warn("session_idle_timeout_seconds cannot be greater than 30 minutes. Using 30 minutes instead."):o<60&&T.warn("session_idle_timeout_seconds cannot be less than 60 seconds. Using 60 seconds instead."):(T.warn("session_idle_timeout_seconds must be a number. Defaulting to 30 minutes."),o=sn),this._sessionTimeoutMs=1e3*Math.min(Math.max(o,60),sn),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){const e=tt.parse(this._window_id_storage_key),t=tt.parse(this._primary_window_exists_storage_key);e&&!t?this._windowId=e:tt.remove(this._window_id_storage_key),tt.set(this._primary_window_exists_storage_key,!0)}if(null!==(n=this.config.bootstrap)&&void 0!==n&&n.sessionID)try{const e=(e=>{const 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(),e)}catch(e){T.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return c(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&&tt.is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&tt.set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?tt.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({[ue]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];const e=this.persistence.props[ue];return r(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){null==v||v.addEventListener("beforeunload",(()=>{this._canUseSessionStorage()&&tt.remove(this._primary_window_exists_storage_key)}))}checkAndGetSessionAndWindowId(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||(new Date).getTime();let[i,s,n]=this._getSessionId(),r=this._getWindowId();const o=g(n)&&n>0&&Math.abs(t-n)>864e5;let a=!1;const l=!s,c=!e&&Math.abs(t-i)>this.sessionTimeoutMs;l||c||o?(s=this._sessionIdGenerator(),r=this._windowIdGenerator(),T.info("[SessionId] new session ID generated",{sessionId:s,windowId:r,changeReason:{noSessionId:l,activityTimeout:c,sessionPastMaximumLength:o}}),n=t,a=!0):r||(r=this._windowIdGenerator(),a=!0);const u=0===i||!e||o?t:i,d=0===n?(new Date).getTime():n;return this._setWindowId(r),this._setSessionId(s,u,d),a&&this._sessionIdChangedHandlers.forEach((e=>e(s,r,a?{noSessionId:l,activityTimeout:c,sessionPastMaximumLength:o}:void 0))),{sessionId:s,windowId:r,sessionStartTimestamp:d,changeReason:a?{noSessionId:l,activityTimeout:c,sessionPastMaximumLength:o}:void 0,lastActivityTimestamp:i}}}let rn;!function(e){e.US="us",e.EU="eu",e.CUSTOM="custom"}(rn||(rn={}));const on="i.posthog.com";class an{_regionCache={};constructor(e){this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e;let t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${on}`,".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]=rn.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=rn.EU:this._regionCache[this.apiHost]=rn.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t&&(t="/"===t[0]?t:`/${t}`),"ui"===e)return this.uiHost+t;if(this.region===rn.CUSTOM)return this.apiHost+t;const i=on+t;switch(e){case"assets":return`https://${this.region}-assets.${i}`;case"api":return`https://${this.region}.${i}`}}}const ln="posthog-js";function cn(e){let{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=>{var o,a,l,c,u;if(!("*"===n||n.includes(r.level))||!e.__loaded)return r;r.tags||(r.tags={});const d=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);r.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(r.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const h=(null===(o=r.exception)||void 0===o?void 0:o.values)||[],p={$exception_message:(null===(a=h[0])||void 0===a?void 0:a.value)||r.message,$exception_type:null===(l=h[0])||void 0===l?void 0:l.type,$exception_personURL:d,$exception_level:r.level,$exception_list:h,$sentry_event_id:r.event_id,$sentry_exception:r.exception,$sentry_exception_message:(null===(c=h[0])||void 0===c?void 0:c.value)||r.message,$sentry_exception_type:null===(u=h[0])||void 0===u?void 0:u.type,$sentry_tags:r.tags,$level:r.level};return t&&i&&(p.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+r.event_id),e.exceptions.sendExceptionEvent(p),r}}class un{constructor(e,t,i,s,n){this.name=ln,this.setupOnce=function(r){r(cn(e,{organization:t,projectId:i,prefix:s,severityAllowList:n}))}}}function dn(e,t){const i=e.config.segment;if(!i)return t();!function(e,t){const i=e.config.segment;if(!i)return t();const s=i=>{const s=()=>i.anonymousId()||He();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(we,"identified")),t()},n=i.user();"then"in n&&o(n.then)?n.then((e=>s(e))):s(n)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||T.warn("This browser does not have Promise support, and can not use the segment integration");const t=(t,i)=>{var s;if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(T.info("Segment integration does not have a userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(T.info("Segment integration has a userId set, identifying with PostHog"),e.identify(t.event.userId));const n=e._calculate_event_properties(i,null!==(s=t.event.properties)&&void 0!==s?s:{},new Date);return t.event.properties=Object.assign({},n,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()}))}))}class hn{constructor(e){this._instance=e}doPageView(e){var t;const i=this._previousPageViewProperties(e);return this._currentPath=null!==(t=null==v?void 0:v.location.pathname)&&void 0!==t?t:"",this._instance.scrollManager.resetContext(),this._prevPageviewTimestamp=e,i}doPageLeave(e){return this._previousPageViewProperties(e)}_previousPageViewProperties(e){const t=this._currentPath,i=this._prevPageviewTimestamp,s=this._instance.scrollManager.getContext();if(!i)return{};let n={};if(s){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:i,maxContentHeight:r,lastContentY:o,maxContentY:a}=s;if(!(c(e)||c(t)||c(i)||c(r)||c(o)||c(a))){e=Math.ceil(e),t=Math.ceil(t),i=Math.ceil(i),r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a);n={$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:e<=1?1:pn(t/e,0,1),$prev_pageview_max_scroll:i,$prev_pageview_max_scroll_percentage:e<=1?1:pn(i/e,0,1),$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:r<=1?1:pn(o/r,0,1),$prev_pageview_max_content:a,$prev_pageview_max_content_percentage:r<=1?1:pn(a/r,0,1)}}}return t&&(n.$prev_pageview_pathname=t),i&&(n.$prev_pageview_duration=(e.getTime()-i.getTime())/1e3),n}}function pn(e,t,i){return Math.max(t,Math.min(e,i))}let gn,_n,fn;!function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(gn||(gn={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(_n||(_n={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(fn||(fn={}));class vn{events={};constructor(){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(const i of this.events[e]||[])i(t);for(const i of this.events["*"]||[])i(e,t)}}class mn{_debugEventEmitter=new vn;constructor(e){this.instance=e,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var e;if(!c(null===(e=this.instance)||void 0===e?void 0:e._addCaptureHook)){var t;const e=(e,t)=>{this.on(e,t)};null===(t=this.instance)||void 0===t||t._addCaptureHook(e)}}register(e){var t,i;if(!c(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null===(t=this.actionRegistry)||void 0===t||t.add(e),null===(i=e.steps)||void 0===i||i.forEach((e=>{var t;null===(t=this.actionEvents)||void 0===t||t.add((null==e?void 0:e.event)||"")}))})),null!==(i=this.instance)&&void 0!==i&&i.autocapture)){var s;const t=new Set;e.forEach((e=>{var i;null===(i=e.steps)||void 0===i||i.forEach((e=>{null!=e&&e.selector&&t.add(null==e?void 0:e.selector)}))})),null===(s=this.instance)||void 0===s||s.autocapture.setElementSelectors(t)}}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?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(const i of t.steps)if(this.checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}checkStep=(e,t)=>this.checkStepEvent(e,t)&&this.checkStepUrl(e,t)&&this.checkStepElement(e,t);checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event);checkStepUrl(e,t){if(null!=t&&t.url){var i;const s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!mn.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!!v&&nt(e,t);case"exact":return t===e;case"contains":const i=mn.escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return nt(e,i);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){if(!this.getElementsList(e).some((e=>!(null!=t&&t.href&&!mn.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&&!mn.matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!mn.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;const s=null==e||null===(i=e.properties)||void 0===i?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}}class bn{static SURVEY_SHOWN_EVENT_NAME="survey shown";constructor(e){this.instance=e,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(e){var t;c(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)||(this.setupEventBasedSurveys(e),this.setupActionBasedSurveys(e))}setupActionBasedSurveys(e){const t=e.filter((e=>{var t,i,s,n;return(null===(t=e.conditions)||void 0===t?void 0:t.actions)&&(null===(i=e.conditions)||void 0===i||null===(s=i.actions)||void 0===s||null===(n=s.values)||void 0===n?void 0:n.length)>0}));if(0!==t.length){if(null==this.actionMatcher){this.actionMatcher=new mn(this.instance),this.actionMatcher.init();const e=e=>{this.onAction(e)};this.actionMatcher._addActionHook(e)}t.forEach((e=>{var t,i,s,n,r,o,a,l,c,u;e.conditions&&null!==(t=e.conditions)&&void 0!==t&&t.actions&&null!==(i=e.conditions)&&void 0!==i&&null!==(s=i.actions)&&void 0!==s&&s.values&&(null===(n=e.conditions)||void 0===n||null===(r=n.actions)||void 0===r||null===(o=r.values)||void 0===o?void 0:o.length)>0&&(null===(a=this.actionMatcher)||void 0===a||a.register(e.conditions.actions.values),null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c||null===(u=c.values)||void 0===u||u.forEach((t=>{if(t&&t.name){const 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,s,n;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s||null===(n=s.values)||void 0===n?void 0:n.length)>0})).length)return;null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t,i,s;null===(t=e.conditions)||void 0===t||null===(i=t.events)||void 0===i||null===(s=i.values)||void 0===s||s.forEach((t=>{if(t&&t.name){const 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;const n=(null===(i=this.instance)||void 0===i||null===(s=i.persistence)||void 0===s?void 0:s.props[be])||[];if(bn.SURVEY_SHOWN_EVENT_NAME==e&&t&&n.length>0){var r;const e=null==t||null===(r=t.properties)||void 0===r?void 0:r.$survey_id;if(e){const t=n.indexOf(e);t>=0&&(n.splice(t,1),this._updateActivatedSurveys(n))}}else this.eventToSurveys.has(e)&&this._updateActivatedSurveys(n.concat(this.eventToSurveys.get(e)||[]))}onAction(e){var t,i;const s=(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i?void 0:i.props[be])||[];this.actionToSurveys.has(e)&&this._updateActivatedSurveys(s.concat(this.actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t,i;null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({[be]:[...new Set(e)]})}getSurveys(){var e,t;const i=null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t?void 0:t.props[be];return i||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}const yn="[Surveys]",wn={icontains:e=>!!v&&v.location.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:e=>!!v&&-1===v.location.href.toLowerCase().indexOf(e.toLowerCase()),regex:e=>!!v&&nt(v.location.href,e),not_regex:e=>!!v&&!nt(v.location.href,e),exact:e=>(null==v?void 0:v.location.href)===e,is_not:e=>(null==v?void 0:v.location.href)!==e};class Sn{constructor(e){this.instance=e,this._surveyEventReceiver=null}afterDecideResponse(e){this._decideServerResponse=!!e.surveys,this.loadIfEnabled()}loadIfEnabled(){var e;const t=null==P||null===(e=P.__PosthogExtensions__)||void 0===e?void 0:e.generateSurveys;var i,s;this.instance.config.disable_surveys||!this._decideServerResponse||t||(null==this._surveyEventReceiver&&(this._surveyEventReceiver=new bn(this.instance)),null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"surveys",(e=>{var t,i;if(e)return T.error(yn,"Could not load surveys script",e);this._surveyManager=null===(t=P.__PosthogExtensions__)||void 0===t||null===(i=t.generateSurveys)||void 0===i?void 0:i.call(t,this.instance)})))}getSurveys(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.instance.config.disable_surveys)return e([]);null==this._surveyEventReceiver&&(this._surveyEventReceiver=new bn(this.instance));const i=this.instance.get_property(me);if(i&&!t)return e(i);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api",`/api/surveys/?token=${this.instance.config.token}`),method:"GET",transport:"XHR",callback:t=>{var i;if(200!==t.statusCode||!t.json)return e([]);const s=t.json.surveys||[],n=s.filter((e=>{var t,i,s,n,r,o,a,l,c,u,d,h;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s?void 0:s.values)&&(null===(n=e.conditions)||void 0===n||null===(r=n.events)||void 0===r||null===(o=r.values)||void 0===o?void 0:o.length)>0||(null===(a=e.conditions)||void 0===a?void 0:a.actions)&&(null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c?void 0:c.values)&&(null===(u=e.conditions)||void 0===u||null===(d=u.actions)||void 0===d||null===(h=d.values)||void 0===h?void 0:h.length)>0}));var r;n.length>0&&(null===(r=this._surveyEventReceiver)||void 0===r||r.register(n));return null===(i=this.instance.persistence)||void 0===i||i.register({[me]:s}),e(s)}})}getActiveMatchingSurveys(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.getSurveys((t=>{var i;const s=t.filter((e=>!(!e.start_date||e.end_date))).filter((e=>{var t,i,s,n;if(!e.conditions)return!0;const r=null===(t=e.conditions)||void 0===t||!t.url||wn[null!==(i=null===(s=e.conditions)||void 0===s?void 0:s.urlMatchType)&&void 0!==i?i:"icontains"](e.conditions.url),o=null===(n=e.conditions)||void 0===n||!n.selector||(null==E?void 0:E.querySelector(e.conditions.selector));return r&&o})),n=null===(i=this._surveyEventReceiver)||void 0===i?void 0:i.getSurveys(),r=s.filter((e=>{var t,i,s,r,o,a,l,c,u,d;if(!e.linked_flag_key&&!e.targeting_flag_key&&!e.internal_targeting_flag_key)return!0;const h=!e.linked_flag_key||this.instance.featureFlags.isFeatureEnabled(e.linked_flag_key),p=!e.targeting_flag_key||this.instance.featureFlags.isFeatureEnabled(e.targeting_flag_key),g=(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s?void 0:s.values)&&(null===(r=e.conditions)||void 0===r||null===(o=r.events)||void 0===o?void 0:o.values.length)>0,_=(null===(a=e.conditions)||void 0===a?void 0:a.actions)&&(null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c?void 0:c.values)&&(null===(u=e.conditions)||void 0===u||null===(d=u.actions)||void 0===d?void 0:d.values.length)>0,f=!g&&!_||(null==n?void 0:n.includes(e.id)),v=this._canActivateRepeatedly(e),m=!(e.internal_targeting_flag_key&&!v)||this.instance.featureFlags.isFeatureEnabled(e.internal_targeting_flag_key);return h&&p&&m&&f}));return e(r)}),t)}getNextSurveyStep(e,t,i){var s;const n=e.questions[t],r=t+1;if(null===(s=n.branching)||void 0===s||!s.type)return t===e.questions.length-1?fn.End:r;if(n.branching.type===fn.End)return fn.End;if(n.branching.type===fn.SpecificQuestion){if(Number.isInteger(n.branching.index))return n.branching.index}else if(n.branching.type===fn.ResponseBased){if(n.type===_n.SingleChoice){var o,a;const e=n.choices.indexOf(`${i}`);if(null!==(o=n.branching)&&void 0!==o&&null!==(a=o.responseValues)&&void 0!==a&&a.hasOwnProperty(e)){const t=n.branching.responseValues[e];return Number.isInteger(t)?t:t===fn.End?fn.End:r}}else if(n.type===_n.Rating){var l,c;if("number"!=typeof i||!Number.isInteger(i))throw new Error("The response type must be an integer");const e=function(e,t){if(3===t){if(e<1||e>3)throw new Error("The response must be in range 1-3");return 1===e?"negative":2===e?"neutral":"positive"}if(5===t){if(e<1||e>5)throw new Error("The response must be in range 1-5");return e<=2?"negative":3===e?"neutral":"positive"}if(7===t){if(e<1||e>7)throw new Error("The response must be in range 1-7");return e<=3?"negative":4===e?"neutral":"positive"}if(10===t){if(e<0||e>10)throw new Error("The response must be in range 0-10");return e<=6?"detractors":e<=8?"passives":"promoters"}throw new Error("The scale must be one of: 3, 5, 7, 10")}(i,n.scale);if(null!==(l=n.branching)&&void 0!==l&&null!==(c=l.responseValues)&&void 0!==c&&c.hasOwnProperty(e)){const t=n.branching.responseValues[e];return Number.isInteger(t)?t:t===fn.End?fn.End:r}}return r}return T.warn(yn,"Falling back to next question index due to unexpected branching type"),r}_canActivateRepeatedly(e){var t;return p(null===(t=P.__PosthogExtensions__)||void 0===t?void 0:t.canActivateRepeatedly)?(T.warn(yn,"canActivateRepeatedly is not defined, must init before calling"),!1):P.__PosthogExtensions__.canActivateRepeatedly(e)}canRenderSurvey(e){p(this._surveyManager)?T.warn(yn,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys((t=>{const i=t.filter((t=>t.id===e))[0];this._surveyManager.canRenderSurvey(i)}))}renderSurvey(e,t){p(this._surveyManager)?T.warn(yn,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys((i=>{const s=i.filter((t=>t.id===e))[0];this._surveyManager.renderSurvey(s,null==E?void 0:E.querySelector(t))}))}}class En{serverLimits={};lastEventRateLimited=!1;constructor(e){var t,i;this.instance=e,this.captureEventsPerSecond=(null===(t=e.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null===(i=e.config.rate_limiting)||void 0===i?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var e,t,i;let s=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const n=(new Date).getTime(),r=null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_property(Ee))&&void 0!==e?e:{tokens:this.captureEventsBurstLimit,last:n};r.tokens+=(n-r.last)/1e3*this.captureEventsPerSecond,r.last=n,r.tokens>this.captureEventsBurstLimit&&(r.tokens=this.captureEventsBurstLimit);const o=r.tokens<1;return o||s||(r.tokens=Math.max(0,r.tokens-1)),!o||this.lastEventRateLimited||s||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===(i=this.instance.persistence)||void 0===i||i.set_property(Ee,r),{isRateLimited:o,remainingTokens:r.tokens}}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}checkForLimiting=e=>{const t=e.text;if(t&&t.length)try{const e=JSON.parse(t);(e.quota_limited||[]).forEach((e=>{T.info(`[RateLimiter] ${e||"events"} is quota limited.`),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void T.warn(`[RateLimiter] could not rate limit - continuing. Error: "${null==e?void 0:e.message}"`,{text:t})}}}const xn=()=>({initialPathName:(null==x?void 0:x.pathname)||"",referringDomain:ri.referringDomain(),...ri.campaignParams()});class kn{constructor(e,t,i){this._sessionIdManager=e,this._persistence=t,this._sessionSourceParamGenerator=i||xn,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStoredProps(){return this._persistence.props[Se]}_onSessionIdCallback=e=>{const t=this._getStoredProps();if(t&&t.sessionId===e)return;const i={sessionId:e,props:this._sessionSourceParamGenerator()};this._persistence.register({[Se]:i})};getSessionProps(){var e;const t=null===(e=this._getStoredProps())||void 0===e?void 0:e.props;return t?{$client_session_initial_referring_host:t.referringDomain,$client_session_initial_pathname:t.initialPathName,$client_session_initial_utm_source:t.utm_source,$client_session_initial_utm_campaign:t.utm_campaign,$client_session_initial_utm_medium:t.utm_medium,$client_session_initial_utm_content:t.utm_content,$client_session_initial_utm_term:t.utm_term}:{}}}const In=["ahrefsbot","ahrefssiteaudit","applebot","baiduspider","bingbot","bingpreview","bot.htm","bot.php","crawler","deepscan","duckduckbot","facebookexternal","facebookcatalog","gptbot","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","semrushbot","sitebulb","slurp","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","headlesschrome","cypress","Google-HotelAdsVerifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","Bytespider;"],Fn=function(e,t){if(!e)return!1;const i=e.toLowerCase();return In.concat(t||[]).some((e=>{const t=e.toLowerCase();return-1!==i.indexOf(t)}))},Rn=function(e,t){if(!e)return!1;const i=e.userAgent;if(i&&Fn(i,t))return!0;try{const i=null==e?void 0:e.userAgentData;if(null!=i&&i.brands&&i.brands.some((e=>Fn(null==e?void 0:e.brand,t))))return!0}catch{}return!!e.webdriver};class Pn{constructor(){this.clicks=[]}isRageClick(e,t,i){const 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}}function $n(e){var t;return e.id===Re||!(null===(t=e.closest)||void 0===t||!t.call(e,"#"+Re))}class Tn{rageclicks=new Pn;_enabledServerSide=!1;_initialized=!1;_flushInterval=null;constructor(e){var t;this.instance=e,this._enabledServerSide=!(null===(t=this.instance.persistence)||void 0===t||!t.props[Z]),null==v||v.addEventListener("beforeunload",(()=>{this.flush()}))}get flushIntervalMilliseconds(){let e=5e3;return a(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 c(this.instance.config.capture_heatmaps)?c(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;T.info("[heatmaps] starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this.getAndClearBuffer()}}afterDecideResponse(e){const t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Z]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){const e=this.buffer;return this.buffer=void 0,e}_setupListeners(){v&&E&&(V(E,"click",(e=>this._onClick(e||(null==v?void 0:v.event))),!1,!0),V(E,"mousemove",(e=>this._onMouseMove(e||(null==v?void 0:v.event))),!1,!0),this._initialized=!0)}_getProperties(e,t){const i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=function(e,t,i){let s=e;for(;s&&mi(s)&&!bi(s,"body");){if(s===i)return!1;if(D(t,null==v?void 0:v.getComputedStyle(s).position))return!0;s=Ei(s)}return!1}(vi(e),["fixed","sticky"],n);return{x:e.clientX+(r?0:s),y:e.clientY+(r?0:i),target_fixed:r,type:t}}_onClick(e){var t;if($n(e.target))return;const i=this._getProperties(e,"click");null!==(t=this.rageclicks)&&void 0!==t&&t.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture({...i,type:"rageclick"}),this._capture(i)}_onMouseMove(e){$n(e.target)||(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(!v)return;const t=v.location.href;this.buffer=this.buffer||{},this.buffer[t]||(this.buffer[t]=[]),this.buffer[t].push(e)}flush(){this.buffer&&!l(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Cn{constructor(e){this.instance=e}getContext(){return this.context}resetContext(){const e=this.context;return setTimeout(this._updateScrollData,0),e}_updateScrollData=()=>{var e,t,i,s;this.context||(this.context={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=r+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this.context.lastScrollY=Math.ceil(r),this.context.maxScrollY=Math.max(r,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)};startMeasuringScrollPosition(){null==v||v.addEventListener("scroll",this._updateScrollData,!0),null==v||v.addEventListener("scrollend",this._updateScrollData,!0),null==v||v.addEventListener("resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return null==v?void 0:v.document.documentElement;{const e=r(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(const t of e){const e=null==v?void 0:v.document.querySelector(t);if(e)return e}}}scrollY(){if(this.instance.config.scroll_root_selector){const e=this.scrollElement();return e&&e.scrollTop||0}return v&&(v.scrollY||v.pageYOffset||v.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){const e=this.scrollElement();return e&&e.scrollLeft||0}return v&&(v.scrollX||v.pageXOffset||v.document.documentElement.scrollLeft)||0}}const Mn="$copy_autocapture";function An(e,t){return t.length>e?t.slice(0,e)+"...":t}class Ln{_initialized=!1;_isDisabledServerSide=null;rageclicks=new Pn;_elementsChainAsString=!1;constructor(e){this.instance=e,this._elementSelectors=null}get config(){var e,t;const i=a(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null===(e=i.url_allowlist)||void 0===e?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null===(t=i.url_ignorelist)||void 0===t?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(!this.isBrowserSupported())return void T.info("Disabling Automatic Event Collection because this browser is not supported");if(!v||!E)return;const e=e=>{e=e||(null==v?void 0:v.event);try{this._captureEvent(e)}catch(e){T.error("Failed to capture event",e)}},t=e=>{e=e||(null==v?void 0:v.event),this._captureEvent(e,Mn)};V(E,"submit",e,!1,!0),V(E,"change",e,!1,!0),V(E,"click",e,!1,!0),this.config.capture_copied_text&&(V(E,"copy",t,!1,!0),V(E,"cut",t,!1,!0))}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}afterDecideResponse(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[K]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t;const i=[];return null===(t=this._elementSelectors)||void 0===t||t.forEach((t=>{const s=null==E?void 0:E.querySelectorAll(t);null==s||s.forEach((s=>{e===s&&i.push(t)}))})),i}get isEnabled(){var e,t;const i=null===(e=this.instance.persistence)||void 0===e?void 0:e.props[K],s=this._isDisabledServerSide;if(h(s)&&!_(i)&&!this.instance.config.advanced_disable_decide)return!1;const n=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!n}_previousElementSibling(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do{t=t.previousSibling}while(t&&!mi(t));return t}_getAugmentPropertiesFromElement(e){if(!ki(e))return{};const t={};return L(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){const i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&Mi(s)&&(t[i]=s)}})),t}_getPropertiesFromElement(e,t,i){var s;const n=e.tagName.toLowerCase(),r={tag_name:n};Si.indexOf(n)>-1&&!i&&("a"===n.toLowerCase()||"button"===n.toLowerCase()?r.$el_text=An(1024,Ai(e)):r.$el_text=An(1024,fi(e)));const o=gi(e);o.length>0&&(r.classes=o.filter((function(e){return""!==e})));const a=null===(s=this.config)||void 0===s?void 0:s.element_attribute_ignorelist;L(e.attributes,(function(i){var s;if((!Ii(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==a||!a.includes(i.name))&&!t&&Mi(i.value)&&(s=i.name,!u(s)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7)))){let e=i.value;"class"===i.name&&(e=hi(e).join(" ")),r["attr__"+i.name]=An(1024,e)}}));let l=1,c=1,d=e;for(;d=this._previousElementSibling(d);)l++,d.tagName===e.tagName&&c++;return r.nth_child=l,r.nth_of_type=c,r}_getDefaultProperties(e){return{$event_type:e,$ce_version:1}}_captureEvent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$autocapture";if(!this.isEnabled)return;let i=vi(e);var s;(yi(i)&&(i=i.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)&&(this.instance.config.rageclick&&null!==(s=this.rageclicks)&&void 0!==s&&s.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._captureEvent(e,"$rageclick"));const n=t===Mn;if(i&&xi(i,e,this.config,n,n?["copy","cut"]:void 0)){var r,o;const s=[i];let n=i;for(;n.parentNode&&!bi(n,"body");)wi(n.parentNode)?(s.push(n.parentNode.host),n=n.parentNode.host):(s.push(n.parentNode),n=n.parentNode);const u=[],d={};let h,p,g=!1;if(L(s,(e=>{const t=ki(e);"a"===e.tagName.toLowerCase()&&(h=e.getAttribute("href"),h=t&&Mi(h)&&h);D(gi(e),"ph-no-capture")&&(g=!0),u.push(this._getPropertiesFromElement(e,this.instance.config.mask_all_element_attributes,this.instance.config.mask_all_text));const i=this._getAugmentPropertiesFromElement(e);O(d,i)})),this.instance.config.mask_all_text||("a"===i.tagName.toLowerCase()||"button"===i.tagName.toLowerCase()?u[0].$el_text=Ai(i):u[0].$el_text=fi(i)),h){var a,l;u[0].attr__href=h;const e=null===(a=st(h))||void 0===a?void 0:a.host,t=null==v||null===(l=v.location)||void 0===l?void 0:l.host;e&&t&&e!==t&&(p=h)}if(g)return!1;const _=O(this._getDefaultProperties(e.type),this._elementsChainAsString?{$elements_chain:Oi(u)}:{$elements:u},null!==(r=u[0])&&void 0!==r&&r.$el_text?{$el_text:null===(o=u[0])||void 0===o?void 0:o.$el_text}:{},p&&"click"===e.type?{$external_click_url:p}:{},d),f=this.getElementSelectors(i);if(f&&f.length>0&&(_.$element_selectors=f),t===Mn){var c;const t=_i(null==v||null===(c=v.getSelection())||void 0===c?void 0:c.toString()),i=e.type||"clipboard";if(!t)return!1;_.$selected_content=t,_.$copy_type=i}return this.instance.capture(t,_),!0}}isBrowserSupported(){return o(null==E?void 0:E.querySelectorAll)}}class On{_restoreXHRPatch=void 0;_restoreFetchPatch=void 0;constructor(e){this.instance=e}_loadScript(e){var t,i,s;null!==(t=P.__PosthogExtensions__)&&void 0!==t&&t.tracingHeadersPatchFns&&e(),null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"tracing-headers",(t=>{if(t)return T.error("[TRACING-HEADERS] failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}_startCapturing=()=>{var e,t,i,s;c(this._restoreXHRPatch)&&(null===(e=P.__PosthogExtensions__)||void 0===e||null===(t=e.tracingHeadersPatchFns)||void 0===t||t._patchXHR(this.instance.sessionManager));c(this._restoreFetchPatch)&&(null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.tracingHeadersPatchFns)||void 0===s||s._patchFetch(this.instance.sessionManager))}}let Dn;!function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"}(Dn||(Dn={}));class Nn{constructor(e){this.instance=e}get config(){return this.instance.config}get consent(){return this.getDnt()?Dn.DENIED:this.storedConsent}isOptedOut(){return this.consent===Dn.DENIED||this.consent===Dn.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}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(){const{token:e,opt_out_capturing_cookie_prefix:t}=this.instance.config;return(t||"__ph_opt_in_out_")+e}get storedConsent(){const e=this.storage.get(this.storageKey);return"1"===e?Dn.GRANTED:"0"===e?Dn.DENIED:Dn.PENDING}get storage(){if(!this._storage){const e=this.config.opt_out_capturing_persistence_type;this._storage="localStorage"===e?Je:je;const t="localStorage"===e?je:Je;t.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut("1"===t.get(this.storageKey)),t.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!j([null==S?void 0:S.doNotTrack,null==S?void 0:S.msDoNotTrack,P.doNotTrack],(e=>D([!0,1,"1","yes"],e)))}}const qn="[Exception Autocapture]";class Bn{originalOnUnhandledRejectionHandler=void 0;constructor(e){var t;this.instance=e,this.remoteEnabled=!(null===(t=this.instance.persistence)||void 0===t||!t.props[ee]),this.startIfEnabled()}get isEnabled(){var e;return null!==(e=this.remoteEnabled)&&void 0!==e&&e}get isCapturing(){var e;return!(null==v||null===(e=v.onerror)||void 0===e||!e.__POSTHOG_INSTRUMENTED__)}get hasHandlers(){return this.originalOnUnhandledRejectionHandler||this.unwrapOnError}startIfEnabled(){this.isEnabled&&!this.isCapturing&&(T.info(qn+" enabled, starting..."),this.loadScript(this.startCapturing))}loadScript(e){var t,i;this.hasHandlers&&e(),null===(t=P.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"exception-autocapture",(t=>{if(t)return T.error(qn+" failed to load script",t);e()}))}startCapturing=()=>{var e,t,i,s;if(!v||!this.isEnabled||this.hasHandlers||this.isCapturing)return;const n=null===(e=P.__PosthogExtensions__)||void 0===e||null===(t=e.errorWrappingFunctions)||void 0===t?void 0:t.wrapOnError,r=null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.errorWrappingFunctions)||void 0===s?void 0:s.wrapUnhandledRejection;if(n&&r)try{this.unwrapOnError=n(this.captureException.bind(this)),this.unwrapUnhandledRejection=r(this.captureException.bind(this))}catch(e){T.error(qn+" failed to start",e),this.stopCapturing()}else T.error(qn+" failed to load error wrapping functions - cannot start")};stopCapturing(){var e,t;null===(e=this.unwrapOnError)||void 0===e||e.call(this),null===(t=this.unwrapUnhandledRejection)||void 0===t||t.call(this)}afterDecideResponse(e){const t=e.autocaptureExceptions;this.remoteEnabled=!!t||!1,this.instance.persistence&&this.instance.persistence.register({[ee]:this.remoteEnabled}),this.startIfEnabled()}captureException(e){const t=this.instance.requestRouter.endpointFor("ui");e.$exception_personURL=`${t}/project/${this.instance.config.token}/person/${this.instance.get_distinct_id()}`,this.instance.exceptions.sendExceptionEvent(e)}}const Hn=9e5,Un="[Web Vitals]";class Wn{_enabledServerSide=!1;_initialized=!1;buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0};constructor(e){var t;this.instance=e,this._enabledServerSide=!(null===(t=this.instance.persistence)||void 0===t||!t.props[ie]),this.startIfEnabled()}get allowedMetrics(){var e,t;const i=a(this.instance.config.capture_performance)?null===(e=this.instance.config.capture_performance)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return c(i)?(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[se])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(a(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){const e=a(this.instance.config.capture_performance)&&g(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Hn;return 0<e&&e<=6e4?Hn:e}get isEnabled(){const e=a(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return _(e)?e:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(T.info(Un+" enabled, starting..."),this.loadScript(this._startCapturing))}afterDecideResponse(e){const t=a(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=a(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[ie]:t}),this.instance.persistence.register({[se]:i})),this._enabledServerSide=t,this.startIfEnabled()}loadScript(e){var t,i,s;null!==(t=P.__PosthogExtensions__)&&void 0!==t&&t.postHogWebVitalsCallbacks&&e(),null===(i=P.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"web-vitals",(t=>{t?T.error(Un+" failed to load script",t):e()}))}_currentURL(){const e=v?v.location.href:void 0;return e||T.error(Un+"Could not determine current URL"),e}_flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this.buffer.metrics.length&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce(((e,t)=>({...e,[`$web_vitals_${t.name}_event`]:{...t},[`$web_vitals_${t.name}_value`]:t.value})),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})};_addToBuffer=e=>{var t;const i=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);if(c(i))return void T.error(Un+"Could not read session ID. Dropping metrics!");this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};const s=this._currentURL();if(c(s))return;if(p(null==e?void 0:e.name)||p(null==e?void 0:e.value))return void T.error(Un+"Invalid metric received",e);if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)return void T.error(Un+"Ignoring metric with value >= "+this._maxAllowedValue,e);this.buffer.url!==s&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),c(this.buffer.url)&&(this.buffer.url=s),this.buffer.firstMetricTimestamp=c(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.buffer.metrics.push({...e,$current_url:s,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()}),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()};_startCapturing=()=>{let e,t,i,s;const n=P.__PosthogExtensions__;c(n)||c(n.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:s}=n.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):T.error(Un+"web vitals callbacks not loaded - not starting")}}const zn={icontains:(e,t)=>!!v&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!v&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!v&&nt(t.href,e),not_regex:(e,t)=>!!v&&!nt(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class Vn{constructor(e){this.instance=e;const t=e=>{this.applyFeatureFlagChanges(e)};this.instance.onFeatureFlags&&this.instance.onFeatureFlags(t),this._flagToExperiments=new Map}applyFeatureFlagChanges(e){p(this._flagToExperiments)||this.instance.config.disable_web_experiments||(Vn.logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!==(t=this._flagToExperiments)&&void 0!==t&&t.has(e)){var i;const t=this.instance.getFeatureFlag(e),s=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);t&&null!=s&&s.variants[t]&&this.applyTransforms(s.name,t,s.variants[t].transforms)}})))}afterDecideResponse(e){this._is_bot()?Vn.logInfo("Refusing to render web experiment since the viewer is a likely bot"):(this._featureFlags=e.featureFlags,this.loadIfEnabled(),this.previewWebExperiment())}previewWebExperiment(){const e=Vn.getWindowLocation();if(null!=e&&e.search){const t=ot(null==e?void 0:e.search,"__experiment_id"),i=ot(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Vn.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()}getWebExperimentsAndEvaluateDisplayLogic=(()=>{var e=this;return function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e.getWebExperiments((t=>{Vn.logInfo("retrieved web experiments from the server"),e._flagToExperiments=new Map,t.forEach((t=>{if(t.feature_flag_key&&e._featureFlags&&e._featureFlags[t.feature_flag_key]){var i;if(e._flagToExperiments)Vn.logInfo("setting flag key ",t.feature_flag_key," to web experiment ",t),null===(i=e._flagToExperiments)||void 0===i||i.set(t.feature_flag_key,t);const s=e._featureFlags[t.feature_flag_key];s&&t.variants[s]&&e.applyTransforms(t.name,s,t.variants[s].transforms)}else if(t.variants)for(const i in t.variants){const s=t.variants[i];Vn.matchesTestVariant(s)&&e.applyTransforms(t.name,i,s.transforms)}}))}),t)}})();getWebExperiments(e,t,i){if(this.instance.config.disable_web_experiments&&!i)return e([]);const 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",transport:"XHR",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);const i=t.json.experiments||[];return e(i)}})}showPreviewWebExperiment(e,t,i){const s=i.filter((t=>t.id===e));s&&s.length>0&&(Vn.logInfo(`Previewing web experiment [${s[0].name}] with variant [${t}]`),this.applyTransforms(s[0].name,t,s[0].variants[t].transforms,!0))}static matchesTestVariant(e){return!p(e.conditions)&&(Vn.matchUrlConditions(e)&&Vn.matchUTMConditions(e))}static matchUrlConditions(e){var t;if(p(e.conditions)||p(null===(t=e.conditions)||void 0===t?void 0:t.url))return!0;const i=Vn.getWindowLocation();if(i){var s,n,r;return null===(s=e.conditions)||void 0===s||!s.url||zn[null!==(n=null===(r=e.conditions)||void 0===r?void 0:r.urlMatchType)&&void 0!==n?n:"icontains"](e.conditions.url,i)}return!1}static getWindowLocation(){return null==v?void 0:v.location}static matchUTMConditions(e){var t;if(p(e.conditions)||p(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;const i=ri.campaignParams();if(i.utm_source){var s,n,r,o,a,l,c,u,d,h,g,_,f,v,m,b;const t=null===(s=e.conditions)||void 0===s||null===(n=s.utm)||void 0===n||!n.utm_campaign||(null===(r=e.conditions)||void 0===r||null===(o=r.utm)||void 0===o?void 0:o.utm_campaign)==i.utm_campaign,p=null===(a=e.conditions)||void 0===a||null===(l=a.utm)||void 0===l||!l.utm_source||(null===(c=e.conditions)||void 0===c||null===(u=c.utm)||void 0===u?void 0:u.utm_source)==i.utm_source,y=null===(d=e.conditions)||void 0===d||null===(h=d.utm)||void 0===h||!h.utm_medium||(null===(g=e.conditions)||void 0===g||null===(_=g.utm)||void 0===_?void 0:_.utm_medium)==i.utm_medium,w=null===(f=e.conditions)||void 0===f||null===(v=f.utm)||void 0===v||!v.utm_term||(null===(m=e.conditions)||void 0===m||null===(b=m.utm)||void 0===b?void 0:b.utm_term)==i.utm_term;return t&&y&&w&&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];T.info(`[WebExperiments] ${e}`,i)}applyTransforms(e,t,i,s){var n;this._is_bot()?Vn.logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var n;Vn.logInfo(`applying transform of variant ${t} for experiment ${e} `,i);let o=0;const a=null===(n=document)||void 0===n?void 0:n.querySelectorAll(i.selector);var r;if(null==a||a.forEach((e=>{const t=e;o+=1,i.attributes&&i.attributes.forEach((e=>{switch(e.name){case"text":t.innerText=e.value;break;case"html":t.innerHTML=e.value;break;case"cssClass":t.className=e.value;break;default:t.setAttribute(e.name,e.value)}})),i.text&&(t.innerText=i.text),i.html&&(t.parentElement?t.parentElement.innerHTML=i.html:t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)})),this.instance&&this.instance.capture)this.instance.capture("$web_experiment_applied",{$web_experiment_name:e,$web_experiment_variant:t,$web_experiment_preview:s,$web_experiment_document_url:null===(r=Vn.getWindowLocation())||void 0===r?void 0:r.href,$web_experiment_elements_modified:o})}})):(Vn.logInfo("Control variants leave the page unmodified."),this.instance&&this.instance.capture&&this.instance.capture("$web_experiment_applied",{$web_experiment_name:e,$web_experiment_preview:s,$web_experiment_variant:t,$web_experiment_document_url:null===(n=Vn.getWindowLocation())||void 0===n?void 0:n.href,$web_experiment_elements_modified:0}))}_is_bot(){return S&&this.instance?Rn(S,this.instance.config.custom_blocked_useragents):void 0}}const Gn="/e/";class jn{constructor(e){var t;this.instance=e,this._endpointSuffix=(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[te])||Gn}get endpoint(){return this.instance.requestRouter.endpointFor("api",this._endpointSuffix)}afterDecideResponse(e){const t=e.autocaptureExceptions;this._endpointSuffix=a(t)&&t.endpoint||Gn,this.instance.persistence&&this.instance.persistence.register({[te]:this._endpointSuffix})}sendExceptionEvent(e){this.instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",_url:this.endpoint})}}const Qn={},Jn=()=>{},Yn="posthog";let Xn=!js&&-1===(null==R?void 0:R.indexOf("MSIE"))&&-1===(null==R?void 0:R.indexOf("Mozilla"));const Kn=()=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:G(null==E?void 0:E.location),persistence:"localStorage+cookie",persistence_name:"",loaded:Jn,store_google:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:x&&u(null==x?void 0:x.search)&&-1!==x.search.indexOf("__posthog_debug=true")||!1,verbose:!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==v||null===(e=v.location)||void 0===e?void 0:e.protocol),ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},inapp_protocol:"//",inapp_link_new_window:!1,request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,on_request_error:e=>{const t="Bad HTTP status: "+e.statusCode+" "+e.text;T.error(t)},get_device_id:e=>e,_onCapture:Jn,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",__add_tracing_headers:!1}},Zn=e=>{const t={};c(e.process_person)||(t.person_profiles=e.process_person),c(e.xhr_headers)||(t.request_headers=e.xhr_headers),c(e.cookie_name)||(t.persistence_name=e.cookie_name),c(e.disable_cookie)||(t.disable_persistence=e.disable_cookie);const i=O({},t,e);return r(e.property_blacklist)&&(c(e.property_denylist)?i.property_denylist=e.property_blacklist:r(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:T.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class er{get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){T.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}__forceAllowLocalhost=!1}class tr{webPerformance=new er;version=e.LIB_VERSION;_internalEventEmitter=new vn;constructor(){this.config=Kn(),this.decideEndpointWasHit=!1,this.SentryIntegration=un,this.sentryIntegration=e=>function(e,t){const i=cn(e,t);return{name:ln,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this.featureFlags=new Ae(this),this.toolbar=new Vs(this),this.scrollManager=new Cn(this),this.pageViewManager=new hn(this),this.surveys=new Sn(this),this.experiments=new Vn(this),this.exceptions=new jn(this),this.rateLimiter=new En(this),this.requestRouter=new an(this),this.consent=new Nn(this),this.people={set:(e,t,i)=>{const s=u(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{const s=u(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>T.info(`send "${null==e?void 0:e.event}"`,e)))}init(e,t,i){if(i&&i!==Yn){var s;const n=null!==(s=Qn[i])&&void 0!==s?s:new tr;return n._init(e,t,i),Qn[i]=n,Qn[Yn][i]=n,n}return this._init(e,t,i)}_init(t){var i,s;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if(c(t)||d(t))return T.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 T.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],n.person_profiles&&(this._initialPersonProfilesConfig=n.person_profiles),this.set_config(O({},Kn(),Zn(n),{name:r,token:t})),this.config.on_xhr_error&&T.error("[posthog] on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:Q.GZipJS,this.persistence=new ai(this.config),this.sessionPersistence="sessionStorage"===this.config.persistence?this.persistence:new ai({...this.config,persistence:"sessionStorage"});const a={...this.persistence.props},l={...this.sessionPersistence.props};if(this._requestQueue=new Gs((e=>this._send_retriable_request(e))),this._retryQueue=new tn(this),this.__request_queue=[],this.sessionManager=new nn(this.config,this.persistence),this.sessionPropsManager=new kn(this.sessionManager,this.persistence),new On(this).startIfEnabledOrStop(),this.sessionRecording=new Bs(this),this.sessionRecording.startIfEnabledOrStop(),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Ln(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new Tn(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Wn(this),this.exceptionObserver=new Bn(this),this.exceptionObserver.startIfEnabled(),e.DEBUG=e.DEBUG||this.config.debug,e.DEBUG&&T.info("Starting in debug mode",{this:this,config:n,thisC:{...this.config},p:a,s:l}),this._sync_opt_out_with_persistence(),void 0!==(null===(i=n.bootstrap)||void 0===i?void 0:i.distinctID)){var u,h;const e=this.config.get_device_id(He()),t=null!==(u=n.bootstrap)&&void 0!==u&&u.isIdentifiedID?e:n.bootstrap.distinctID;this.persistence.set_property(we,null!==(h=n.bootstrap)&&void 0!==h&&h.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:t})}if(this._hasBootstrappedFeatureFlags()){var p,g;const e=Object.keys((null===(p=n.bootstrap)||void 0===p?void 0:p.featureFlags)||{}).filter((e=>{var t,i;return!(null===(t=n.bootstrap)||void 0===t||null===(i=t.featureFlags)||void 0===i||!i[e])})).reduce(((e,t)=>{var i,s;return e[t]=(null===(i=n.bootstrap)||void 0===i||null===(s=i.featureFlags)||void 0===s?void 0:s[t])||!1,e}),{}),t=Object.keys((null===(g=n.bootstrap)||void 0===g?void 0:g.featureFlagPayloads)||{}).filter((t=>e[t])).reduce(((e,t)=>{var i,s,r,o;null!==(i=n.bootstrap)&&void 0!==i&&null!==(s=i.featureFlagPayloads)&&void 0!==s&&s[t]&&(e[t]=null===(r=n.bootstrap)||void 0===r||null===(o=r.featureFlagPayloads)||void 0===o?void 0:o[t]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:e,featureFlagPayloads:t})}if(!this.get_distinct_id()){const e=this.config.get_device_id(He());this.register_once({distinct_id:e,$device_id:e},""),this.persistence.set_property(we,"anonymous")}return null==v||null===(s=v.addEventListener)||void 0===s||s.call(v,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),this.toolbar.maybeLoadToolbar(),n.segment?dn(this,(()=>this._loaded())):this._loaded(),o(this.config._onCapture)&&this.on("eventCaptured",(e=>this.config._onCapture(e.event,e))),this}_afterDecideResponse(e){var t,i,s,n,r,o,a,l,c;this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=D(e.supportedCompression,Q.GZipJS)?Q.GZipJS:D(e.supportedCompression,Q.Base64)?Q.Base64:void 0),null!==(t=e.analytics)&&void 0!==t&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:e.defaultIdentifiedOnly?"identified_only":"always"}),null===(i=this.sessionRecording)||void 0===i||i.afterDecideResponse(e),null===(s=this.autocapture)||void 0===s||s.afterDecideResponse(e),null===(n=this.heatmaps)||void 0===n||n.afterDecideResponse(e),null===(r=this.experiments)||void 0===r||r.afterDecideResponse(e),null===(o=this.surveys)||void 0===o||o.afterDecideResponse(e),null===(a=this.webVitalsAutocapture)||void 0===a||a.afterDecideResponse(e),null===(l=this.exceptions)||void 0===l||l.afterDecideResponse(e),null===(c=this.exceptionObserver)||void 0===c||c.afterDecideResponse(e)}_loaded(){const e=this.config.advanced_disable_decide;e||this.featureFlags.setReloadingPaused(!0);try{this.config.loaded(this)}catch(e){T.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{this.consent.isOptedIn()&&this._captureInitialPageview()}),1),e||(new Hs(this).call(),this.featureFlags.resetRequestQueue())}_start_queue_if_opted_in(){var e;this.has_opted_out_capturing()||this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.has_opted_out_capturing()||A(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)||void 0===e||e.unload(),null===(t=this._retryQueue)||void 0===t||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(t){this.__loaded&&(Xn?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)||(t.transport=t.transport||this.config.api_transport,t.url=Js(t.url,{ip:this.config.ip?1:0}),t.headers={...this.config.request_headers},t.compression="best-available"===t.compression?this.compression:t.compression,(t=>{var i,s,n;const r={...t};r.timeout=r.timeout||6e4,r.url=Js(r.url,{_:(new Date).getTime().toString(),ver:e.LIB_VERSION,compression:r.compression});const o=null!==(i=r.transport)&&void 0!==i?i:"XHR",a=null!==(s=null===(n=j(en,(e=>e.transport===o)))||void 0===n?void 0:n.method)&&void 0!==s?s:en[0].method;if(!a)throw new Error("No available transport method");a(r)})({...t,callback:e=>{var i,s,n;(this.rateLimiter.checkForLimiting(e),e.statusCode>=400)&&(null===(s=(n=this.config).on_request_error)||void 0===s||s.call(n,e));null===(i=t.callback)||void 0===i||i.call(t,e)}})))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){let t;const i=[],s=[],n=[];A(e,(e=>{e&&(t=e[0],r(t)?n.push(e):o(e)?e.call(this):r(e)&&"alias"===t?i.push(e):r(e)&&-1!==t.indexOf("capture")&&o(this[t])?n.push(e):s.push(e))}));const a=function(e,t){A(e,(function(e){if(r(e[0])){let i=t;L(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};a(i,this),a(s,this),a(n,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null===(e=this.config.bootstrap)||void 0===e?void 0:e.featureFlags)&&Object.keys(null===(t=this.config.bootstrap)||void 0===t?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,i){var s;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue))return void T.uninitializedWarning("posthog.capture");if(this.consent.isOptedOut())return;if(c(e)||!u(e))return void T.error("No event name provided to posthog.capture");if(!this.config.opt_out_useragent_filter&&this._is_bot())return;const n=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null!=n&&n.isRateLimited)return void T.critical("This capture call is ignored due to client rate limiting.");this.sessionPersistence.update_search_keyword(),this.config.store_google&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.store_google||this.config.save_referrer)&&this.persistence.set_initial_person_info();const r=new Date,o=(null==i?void 0:i.timestamp)||r;let a={uuid:He(),event:e,properties:this._calculate_event_properties(e,t||{},o)};n&&(a.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens);(null==i?void 0:i.$set)&&(a.$set=null==i?void 0:i.$set);const d=this._calculate_set_once_properties(null==i?void 0:i.$set_once);d&&(a.$set_once=d),a=W(a,null!=i&&i._noTruncate?null:this.config.properties_string_max_length),a.timestamp=o,c(null==i?void 0:i.timestamp)||(a.properties.$event_time_override_provided=!0,a.properties.$event_time_override_system_time=r);const h={...a.properties.$set,...a.$set};l(h)||this.setPersonPropertiesForFlags(h),this._internalEventEmitter.emit("eventCaptured",a);const p={method:"POST",url:null!==(s=null==i?void 0:i._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:a,compression:"best-available",batchKey:null==i?void 0:i._batchKey};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this._send_retriable_request(p):this._requestQueue.enqueue(p),a}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}_calculate_event_properties(e,t,i){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;const s=this.persistence.remove_event_timer(e);let n={...t};if(n.token=this.config.token,"$snapshot"===e){const e={...this.persistence.properties(),...this.sessionPersistence.properties()};return n.distinct_id=e.distinct_id,(!u(n.distinct_id)&&!g(n.distinct_id)||d(n.distinct_id))&&T.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),n}const o=ri.properties();if(this.sessionManager){const{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId();n.$session_id=e,n.$window_id=t}if(this.requestRouter.region===rn.CUSTOM&&(n.$lib_custom_api_host=this.config.api_host),this.sessionPropsManager&&this.config.__preview_send_client_session_params&&("$pageview"===e||"$pageleave"===e||"$autocapture"===e)){const e=this.sessionPropsManager.getSessionProps();n=O(n,e)}if(!this.config.disable_scroll_properties){let t={};"$pageview"===e?t=this.pageViewManager.doPageView(i):"$pageleave"===e&&(t=this.pageViewManager.doPageLeave(i)),n=O(n,t)}if("$pageview"===e&&E&&(n.title=E.title),!c(s)){const e=i.getTime()-s;n.$duration=parseFloat((e/1e3).toFixed(3))}R&&this.config.opt_out_useragent_filter&&(n.$browser_type=this._is_bot()?"bot":"browser"),n=O({},o,this.persistence.properties(),this.sessionPersistence.properties(),n),n.$is_identified=this._isIdentified(),r(this.config.property_denylist)?L(this.config.property_denylist,(function(e){delete n[e]})):T.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const a=this.config.sanitize_properties;a&&(n=a(n,e));const l=this._hasPersonProcessing();return n.$process_person_profile=l,l&&this._requirePersonProcessing("_calculate_event_properties"),n}_calculate_set_once_properties(e){if(!this.persistence||!this._hasPersonProcessing())return e;let t=O({},this.persistence.get_initial_props(),e||{});const i=this.config.sanitize_properties;return i&&(t=i(t,"$set_once")),l(t)?void 0:t}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var s;null===(s=this.persistence)||void 0===s||s.register_once(e,t,i)}register_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.register(e)}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){const t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch{return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t)}getEarlyAccessFeatures(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.featureFlags.getEarlyAccessFeatures(e,t)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}canRenderSurvey(e){this.surveys.canRenderSurvey(e)}getNextSurveyStep(e,t,i){return this.surveys.getNextSurveyStep(e,t,i)}identify(e,t,i){if(!this.__loaded||!this.persistence)return T.uninitializedWarning("posthog.identify");if(g(e)&&(e=e.toString(),T.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!e)return void T.error("Unique user id has not been set in posthog.identify");if(["distinct_id","distinctid"].includes(e.toLowerCase()))return void T.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.`);if(!this._requirePersonProcessing("posthog.identify"))return;const s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){const e=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:e},"")}e!==s&&e!==this.get_property(Y)&&(this.unregister(Y),this.register({distinct_id:e}));const n="anonymous"===(this.persistence.get_property(we)||"anonymous");e!==s&&n?(this.persistence.set_property(we,"identified"),this.setPersonPropertiesForFlags(t||{},!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:i||{}}),this.featureFlags.setAnonymousDistinctId(s)):(t||i)&&this.setPersonProperties(t,i),e!==s&&(this.reloadFeatureFlags(),this.unregister(ye))}setPersonProperties(e,t){(e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(e||{}),this.capture("$set",{$set:e||{},$set_once:t||{}}))}group(e,t,i){if(!e||!t)return void T.error("posthog.group requires a group type and group key");if(!this._requirePersonProcessing("posthog.group"))return;const s=this.getGroups();s[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:{...s,[e]:t}}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),s[e]===t||i||this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this._requirePersonProcessing("posthog.setPersonPropertiesForFlags")&&this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,n;if(T.info("reset"),!this.__loaded)return T.uninitializedWarning("posthog.reset");const r=this.get_property("$device_id");this.consent.reset(),null===(t=this.persistence)||void 0===t||t.clear(),null===(i=this.sessionPersistence)||void 0===i||i.clear(),null===(s=this.persistence)||void 0===s||s.set_property(we,"anonymous"),null===(n=this.sessionManager)||void 0===n||n.resetSessionId();const o=this.config.get_device_id(He());this.register_once({distinct_id:o,$device_id:e?o:r},"")}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?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${t}`);if(null!=e&&e.withTimestamp&&i){var n;const t=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-i)/1e3)-t,0)}`}return s}alias(e,t){return e===this.get_property(J)?(T.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(c(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Y,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(T.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(t){const i={...this.config};var s,n,r,o;a(t)&&(O(this.config,Zn(t)),null===(s=this.persistence)||void 0===s||s.update_config(this.config,i),this.sessionPersistence="sessionStorage"===this.config.persistence?this.persistence:new ai({...this.config,persistence:"sessionStorage"}),Je.is_supported()&&"true"===Je.get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(e.DEBUG=!0,T.info("set_config",{config:t,oldConfig:i,newConfig:{...this.config}})),null===(n=this.sessionRecording)||void 0===n||n.startIfEnabledOrStop(),null===(r=this.autocapture)||void 0===r||r.startIfEnabled(),null===(o=this.heatmaps)||void 0===o||o.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(e){const t=_(e)&&e;if(t||null!=e&&e.sampling||null!=e&&e.linked_flag){var i;const r=null===(i=this.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId();var s,n;if(t||null!=e&&e.sampling)null===(s=this.sessionRecording)||void 0===s||s.overrideSampling(),T.info("Session recording started with sampling override for session: ",null==r?void 0:r.sessionId);if(t||null!=e&&e.linked_flag)null===(n=this.sessionRecording)||void 0===n||n.overrideLinkedFlag(),T.info("Session recording started with linked_flags override")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null===(e=this.sessionRecording)||void 0===e||!e.started)}captureException(e,t){var i;const s=new Error("PostHog syntheticException"),n=o(null===(i=P.__PosthogExtensions__)||void 0===i?void 0:i.parseErrorAsProperties)?P.__PosthogExtensions__.parseErrorAsProperties([e.message,void 0,void 0,void 0,e],{syntheticException:s}):{$exception_level:"error",$exception_list:[{type:e.name,value:e.message,mechanism:{handled:!0,synthetic:!1}}],...t};this.exceptions.sendExceptionEvent(n)}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e;let t=null!==(e=this.config.name)&&void 0!==e?e:Yn;return t!==Yn&&(t=Yn+"."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property(we))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property(we))}_hasPersonProcessing(){var e,t,i,s;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&l(this.getGroups())&&(null===(e=this.persistence)||void 0===e||null===(t=e.props)||void 0===t||!t[Y])&&(null===(i=this.persistence)||void 0===i||null===(s=i.props)||void 0===s||!s[Fe]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(T.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Fe,!0),!0)}_sync_opt_out_with_persistence(){var e,t;const i=this.consent.isOptedOut(),s=this.config.opt_out_persistence_by_default,n=this.config.disable_persistence||i&&!!s;var r,o;(null===(e=this.persistence)||void 0===e?void 0:e.disabled)!==n&&(null===(r=this.persistence)||void 0===r||r.set_disabled(n));(null===(t=this.sessionPersistence)||void 0===t?void 0:t.disabled)!==n&&(null===(o=this.sessionPersistence)||void 0===o||o.set_disabled(n))}opt_in_capturing(e){var t;(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),c(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()}opt_out_capturing(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return S?Rn(S,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){E&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:E.title},{send_instantly:!0}))}debug(e){!1===e?(null==v||v.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==v||v.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}))}}!function(e,t){for(let i=0;i<t.length;i++)e.prototype[t[i]]=B(e.prototype[t[i]])}(tr,["identify"]);!function(){const e=Qn[Yn]=new tr,t=P.posthog;t&&L(t._i,(function(i){if(i&&r(i)){const s=e.init(i[0],i[1],i[2]),n=t[i[2]]||t;s&&(s._execute_array.call(s.people,n.people),s._execute_array(n))}})),P.posthog=e,function(){function e(){e.done||(e.done=!0,Xn=!1,L(Qn,(function(e){e._dom_loaded()})))}null!=E&&E.addEventListener&&("complete"===E.readyState?e():E.addEventListener("DOMContentLoaded",e,!1)),v&&V(v,"load",e,!0)}()}()}();
11
11
  //# sourceMappingURL=array.no-external.js.map