posthog-js 1.200.0 → 1.200.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  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 +1 -1
  6. package/dist/array.full.js.map +1 -1
  7. package/dist/array.full.no-external.js +1 -1
  8. package/dist/array.full.no-external.js.map +1 -1
  9. package/dist/array.js +1 -1
  10. package/dist/array.js.map +1 -1
  11. package/dist/array.no-external.js +1 -1
  12. package/dist/array.no-external.js.map +1 -1
  13. package/dist/customizations.full.js +1 -1
  14. package/dist/customizations.full.js.map +1 -1
  15. package/dist/dead-clicks-autocapture.js.map +1 -1
  16. package/dist/exception-autocapture.js.map +1 -1
  17. package/dist/external-scripts-loader.js.map +1 -1
  18. package/dist/main.js +1 -1
  19. package/dist/main.js.map +1 -1
  20. package/dist/module.d.ts +5 -0
  21. package/dist/module.full.d.ts +5 -0
  22. package/dist/module.full.js +1 -1
  23. package/dist/module.full.js.map +1 -1
  24. package/dist/module.full.no-external.d.ts +5 -0
  25. package/dist/module.full.no-external.js +1 -1
  26. package/dist/module.full.no-external.js.map +1 -1
  27. package/dist/module.js +1 -1
  28. package/dist/module.js.map +1 -1
  29. package/dist/module.no-external.d.ts +5 -0
  30. package/dist/module.no-external.js +1 -1
  31. package/dist/module.no-external.js.map +1 -1
  32. package/dist/recorder-v2.js.map +1 -1
  33. package/dist/recorder.js.map +1 -1
  34. package/dist/src/constants.d.ts +6 -0
  35. package/dist/src/entrypoints/tracing-headers.d.ts +2 -2
  36. package/dist/src/types.d.ts +5 -0
  37. package/dist/src/utils/globals.d.ts +2 -2
  38. package/dist/surveys-preview.js.map +1 -1
  39. package/dist/surveys.js.map +1 -1
  40. package/dist/tracing-headers.js +1 -1
  41. package/dist/tracing-headers.js.map +1 -1
  42. package/dist/web-vitals.js.map +1 -1
  43. package/lib/package.json +1 -1
  44. package/lib/src/constants.d.ts +6 -0
  45. package/lib/src/constants.js +6 -0
  46. package/lib/src/constants.js.map +1 -1
  47. package/lib/src/entrypoints/tracing-headers.d.ts +2 -2
  48. package/lib/src/entrypoints/tracing-headers.js +5 -3
  49. package/lib/src/entrypoints/tracing-headers.js.map +1 -1
  50. package/lib/src/extensions/replay/sessionrecording.js +3 -0
  51. package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
  52. package/lib/src/extensions/tracing-headers.js +0 -1
  53. package/lib/src/extensions/tracing-headers.js.map +1 -1
  54. package/lib/src/posthog-core.js +36 -13
  55. package/lib/src/posthog-core.js.map +1 -1
  56. package/lib/src/sessionid.js +6 -0
  57. package/lib/src/sessionid.js.map +1 -1
  58. package/lib/src/types.d.ts +5 -0
  59. package/lib/src/types.js.map +1 -1
  60. package/lib/src/utils/globals.d.ts +2 -2
  61. package/lib/src/utils/globals.js.map +1 -1
  62. package/package.json +1 -1
package/dist/module.js CHANGED
@@ -1,2 +1,2 @@
1
- var e="undefined"!=typeof window?window:void 0,t="undefined"!=typeof globalThis?globalThis:e,i=Array.prototype,n=i.forEach,r=i.indexOf,s=null==t?void 0:t.navigator,o=null==t?void 0:t.document,a=null==t?void 0:t.location,l=null==t?void 0:t.fetch,u=null!=t&&t.XMLHttpRequest&&"withCredentials"in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,c=null==t?void 0:t.AbortController,d=null==s?void 0:s.userAgent,h=null!=e?e:{},_={DEBUG:!1,LIB_VERSION:"1.200.0"},p={},v=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function g(e,t,i){if(D(e))if(n&&e.forEach===n)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var r=0,s=e.length;r<s;r++)if(r in e&&t.call(i,e[r],r)===p)return}function f(e,t,i){if(!W(e)){if(D(e))return g(e,t,i);if(J(e)){for(var n of e.entries())if(t.call(i,n[1],n[0])===p)return}else for(var r in e)if(M.call(e,r)&&t.call(i,e[r],r)===p)return}}var m=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return g(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e};function b(e,t){return-1!==e.indexOf(t)}function y(e){for(var t=Object.keys(e),i=t.length,n=new Array(i);i--;)n[i]=[t[i],e[t[i]]];return n}var w=function(e){try{return e()}catch(e){return}},S=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return e.apply(this,i)}catch(e){K.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),K.critical(e)}}},E=function(e){var t={};return f(e,(function(e,i){U(e)&&e.length>0&&(t[i]=e)})),t},k=function(e){return e.replace(/^\$/,"")};function x(e,t){return i=e,n=e=>U(e)&&!j(t)?e.slice(0,t):e,r=new Set,function e(t,i){return t!==Object(t)?n?n(t,i):t:r.has(t)?void 0:(r.add(t),D(t)?(s=[],g(t,(t=>{s.push(e(t))}))):(s={},f(t,((t,i)=>{r.has(t)||(s[i]=e(t,i))}))),s);var s}(i);var i,n,r}var I=function(e){var t,i,n,r,s="";for(t=i=0,n=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,r=0;r<n;r++){var o=e.charCodeAt(r),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),j(a)||(i>t&&(s+=e.substring(t,i)),s+=a,t=i=r+1)}return i>t&&(s+=e.substring(t,e.length)),s},C=function(){function t(e){return e&&(e.preventDefault=t.preventDefault,e.stopPropagation=t.stopPropagation),e}return t.preventDefault=function(){this.returnValue=!1},t.stopPropagation=function(){this.cancelBubble=!0},function(i,n,r,s,o){if(i)if(i.addEventListener&&!s)i.addEventListener(n,r,!!o);else{var a="on"+n,l=i[a];i[a]=function(i,n,r){return function(s){if(s=s||t(null==e?void 0:e.event)){var o,a=!0;N(r)&&(o=r(s));var l=n.call(i,s);return!1!==o&&!1!==l||(a=!1),a}}}(i,r,l)}else K.error("No valid element provided to register_event")}}();function P(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}var R,F="$copy_autocapture",T=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(R||(R={}));var $=["fatal","error","warning","log","info","debug"],O=Array.isArray,L=Object.prototype,M=L.hasOwnProperty,A=L.toString,D=O||function(e){return"[object Array]"===A.call(e)},N=e=>"function"==typeof e,q=e=>e===Object(e)&&!D(e),B=e=>{if(q(e)){for(var t in e)if(M.call(e,t))return!1;return!0}return!1},H=e=>void 0===e,U=e=>"[object String]"==A.call(e),z=e=>U(e)&&0===e.trim().length,j=e=>null===e,W=e=>H(e)||j(e),G=e=>"[object Number]"==A.call(e),V=e=>"[object Boolean]"===A.call(e),J=e=>e instanceof FormData,Y=e=>b(T,e),X=t=>{var i={_log:function(i){if(e&&(_.DEBUG||h.POSTHOG_DEBUG)&&!H(e.console)&&e.console){for(var n=("__rrweb_original__"in e.console[i]?e.console[i].__rrweb_original__:e.console[i]),r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];n(t,...s)}},info:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];i._log("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];i._log("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];i._log("error",...t)},critical:function(){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];console.error(t,...i)},uninitializedWarning:e=>{i.error("You must initialize PostHog before calling ".concat(e))},createLogger:e=>X("".concat(t," ").concat(e))};return i},K=X("[PostHog.js]"),Q=K.createLogger,Z=Q("[ExternalScriptsLoader]"),ee=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return Z.warn("".concat(t," was requested but loading of external scripts is disabled.")),i("Loading of external scripts is disabled");var n=()=>{if(!o)return i("document not found");var e=o.createElement("script");e.type="text/javascript",e.crossOrigin="anonymous",e.src=t,e.onload=e=>i(void 0,e),e.onerror=e=>i(e);var n,r=o.querySelectorAll("body > script");r.length>0?null===(n=r[0].parentNode)||void 0===n||n.insertBefore(e,r[0]):o.body.appendChild(e)};null!=o&&o.body?n():null==o||o.addEventListener("DOMContentLoaded",n)};function te(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function ie(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?te(Object(i),!0).forEach((function(t){ne(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):te(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function ne(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function re(e,t){if(null==e)return{};var i,n,r=function(e,t){if(null==e)return{};var i,n,r={},s=Object.keys(e);for(n=0;n<s.length;n++)i=s[n],t.indexOf(i)>=0||(r[i]=e[i]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)i=s[n],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{var n="/static/".concat(t,".js")+"?v=".concat(e.version);if("remote-config"===t&&(n="/array/".concat(e.config.token,"/config.js")),"toolbar"===t){var r=3e5,s=Math.floor(Date.now()/r)*r;n="".concat(n,"&t=").concat(s)}var o=e.requestRouter.endpointFor("assets",n);ee(e,o,i)},h.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{var n=e.requestRouter.endpointFor("api",t);ee(e,n,i)};var se="$people_distinct_id",oe="__alias",ae="__timers",le="$autocapture_disabled_server_side",ue="$heatmaps_enabled_server_side",ce="$exception_capture_enabled_server_side",de="$web_vitals_enabled_server_side",he="$dead_clicks_enabled_server_side",_e="$web_vitals_allowed_metrics",pe="$session_recording_enabled_server_side",ve="$console_log_recording_enabled_server_side",ge="$session_recording_network_payload_capture",fe="$session_recording_canvas_recording",me="$replay_sample_rate",be="$replay_minimum_duration",ye="$replay_script_config",we="$sesid",Se="$session_is_sampled",Ee="$session_recording_url_trigger_activated_session",ke="$session_recording_event_trigger_activated_session",xe="$enabled_feature_flags",Ie="$early_access_features",Ce="$stored_person_properties",Pe="$stored_group_properties",Re="$surveys",Fe="$surveys_activated",Te="$flag_call_reported",$e="$user_state",Oe="$client_session_props",Le="$capture_rate_limit",Me="$initial_campaign_params",Ae="$initial_referrer_info",De="$initial_person_info",Ne="$epp",qe="__POSTHOG_TOOLBAR__",Be=[se,oe,"__cmpns",ae,pe,ue,we,xe,$e,Ie,Pe,Ce,Re,Te,Oe,Le,Me,Ae,Ne],He=Q("[FeatureFlags]"),Ue="$active_feature_flags",ze="$override_feature_flags",je="$feature_flag_payloads",We=e=>{var t={};for(var[i,n]of y(e||{}))n&&(t[i]=n);return t};class Ge{constructor(e){ne(this,"_override_warning",!1),ne(this,"_hasLoadedFlags",!1),ne(this,"_requestInFlight",!1),ne(this,"_reloadingDisabled",!1),ne(this,"_additionalReloadRequested",!1),ne(this,"_decideCalled",!1),ne(this,"_flagsLoadedFromRemote",!1),this.instance=e,this.featureFlagEventHandlers=[]}decide(){if(this.instance.config.__preview_remote_config)this._decideCalled=!0;else{var e=!this._reloadDebouncer&&(this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load);this._callDecideEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagVariants(){var e=this.instance.get_property(xe),t=this.instance.get_property(ze);if(!t)return e||{};for(var i=m({},e),n=Object.keys(t),r=0;r<n.length;r++)i[n[r]]=t[n[r]];return this._override_warning||(He.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){return this.instance.get_property(je)||{}}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callDecideEndpoint()}),5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callDecideEndpoint(e){if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var t={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:this.instance.get_property(Ce),group_properties:this.instance.get_property(Pe)};(null!=e&&e.disableFlags||this.instance.config.advanced_disable_feature_flags)&&(t.disable_flags=!0),this._requestInFlight=!0,this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:t,compression:this.instance.config.disable_compression?void 0:R.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:e=>{var i,n,r=!0;(200===e.statusCode&&(this.$anon_distinct_id=void 0,r=!1),this._requestInFlight=!1,this._decideCalled)||(this._decideCalled=!0,this.instance._onRemoteConfig(null!==(n=e.json)&&void 0!==n?n:{}));t.disable_flags||(this._flagsLoadedFromRemote=!r,this.receivedFeatureFlags(null!==(i=e.json)&&void 0!==i?i:{},r),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callDecideEndpoint()))}})}}getFeatureFlag(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i,n,r,s,o,a=this.getFlagVariants()[e],l="".concat(a),u=this.instance.get_property(Te)||{};if(t.send_event||!("send_event"in t))if(!(e in u)||!u[e].includes(l))D(u[e])?u[e].push(l):u[e]=[l],null===(i=this.instance.persistence)||void 0===i||i.register({[Te]:u}),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:a,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_bootstrapped_response:(null===(n=this.instance.config.bootstrap)||void 0===n||null===(r=n.featureFlags)||void 0===r?void 0:r[e])||null,$feature_flag_bootstrapped_payload:(null===(s=this.instance.config.bootstrap)||void 0===s||null===(o=s.featureFlagPayloads)||void 0===o?void 0:o[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote});return a}He.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}isFeatureEnabled(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,t);He.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time.")}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this.instance.persistence){this._hasLoadedFlags=!0;var i=this.getFlagVariants(),n=this.getFlagPayloads();!function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=e.featureFlags,s=e.featureFlagPayloads;if(r)if(D(r)){var o={};if(r)for(var a=0;a<r.length;a++)o[r[a]]=!0;t&&t.register({[Ue]:r,[xe]:o})}else{var l=r,u=s;e.errorsWhileComputingFlags&&(l=ie(ie({},i),l),u=ie(ie({},n),u)),t&&t.register({[Ue]:Object.keys(We(l)),[xe]:l||{},[je]:u||{}})}}(e,this.instance.persistence,i,n),this._fireFeatureFlagsCallbacks(t)}}override(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.instance.__loaded||!this.instance.persistence)return He.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=t,!1===e)this.instance.persistence.unregister(ze);else if(D(e)){for(var i={},n=0;n<e.length;n++)i[e[n]]=!0;this.instance.persistence.register({[ze]:i})}else this.instance.persistence.register({[ze]:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t){var i,n={["$feature_enrollment/".concat(e)]:t};this.instance.capture("$feature_enrollment_update",{$feature_flag:e,$feature_enrollment:t,$set:n}),this.setPersonPropertiesForFlags(n,!1);var r=ie(ie({},this.getFlagVariants()),{},{[e]:t});null===(i=this.instance.persistence)||void 0===i||i.register({[Ue]:Object.keys(We(r)),[xe]:r}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.instance.get_property(Ie);if(i&&!t)return e(i);this.instance._send_request({transport:"XHR",url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token)),method:"GET",callback:t=>{var i;if(t.json){var n=t.json.earlyAccessFeatures;return null===(i=this.instance.persistence)||void 0===i||i.register({[Ie]:n}),e(n)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((n=>n(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.instance.get_property(Ce)||{};this.instance.register({[Ce]:ie(ie({},i),e)}),t&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(Ce)}setGroupPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.instance.get_property(Pe)||{};0!==Object.keys(i).length&&Object.keys(i).forEach((t=>{i[t]=ie(ie({},i[t]),e[t]),delete e[t]})),this.instance.register({[Pe]:ie(ie({},i),e)}),t&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.instance.get_property(Pe)||{};this.instance.register({[Pe]:ie(ie({},t),{},{[e]:{}})})}else this.instance.unregister(Pe)}}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});var Ve="0123456789abcdef";class Je{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,n){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(n)||e<0||t<0||i<0||n<0||e>0xffffffffffff||t>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");var r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new Je(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Ve.charAt(this.bytes[t]>>>4)+Ve.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 Je(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class Ye{constructor(){ne(this,"timestamp",0),ne(this,"counter",0),ne(this,"random",new Qe)}generate(){var e=this.generateOrAbort();if(H(e)){this.timestamp=0;var t=this.generateOrAbort();if(H(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return Je.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}var Xe,Ke=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!H(e.crypto)&&crypto.getRandomValues&&(Ke=e=>crypto.getRandomValues(e));class Qe{constructor(){ne(this,"buffer",new Uint32Array(8)),ne(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(Ke(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}var Ze=()=>et().toString(),et=()=>(Xe||(Xe=new Ye)).generate(),tt="Thu, 01 Jan 1970 00:00:00 GMT",it="";var nt=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function rt(e,t){if(t){var i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;if(it)return it;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),n=Math.min(i.length,8),r="dmn_chk_"+Ze(),s=new RegExp("(^|;)\\s*"+r+"=1");!it&&n--;){var a=i.slice(n).join("."),l=r+"=1;domain=."+a;t.cookie=l,s.test(t.cookie)&&(t.cookie=l+";expires="+tt,it=a)}return it}(e);if(!i){var n=(e=>{var t=e.match(nt);return t?t[0]:""})(e);n!==i&&K.info("Warning: cookie subdomain discovery mismatch",n,i),i=n}return i?"; domain=."+i:""}return""}var st={is_supported:()=>!!o,error:function(e){K.error("cookieStore error: "+e)},get:function(e){if(o){try{for(var t=e+"=",i=o.cookie.split(";").filter((e=>e.length)),n=0;n<i.length;n++){for(var r=i[n];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}},parse:function(e){var t;try{t=JSON.parse(st.get(e))||{}}catch(e){}return t},set:function(e,t,i,n,r){if(o)try{var s="",a="",l=rt(o.location.hostname,n);if(i){var u=new Date;u.setTime(u.getTime()+24*i*60*60*1e3),s="; expires="+u.toUTCString()}r&&(a="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+l+a;return c.length>3686.4&&K.warn("cookieStore warning: large cookie, len="+c.length),o.cookie=c,c}catch(e){return}},remove:function(e,t){try{st.set(e,"",-1,t)}catch(e){return}}},ot=null,at={is_supported:function(){if(!j(ot))return ot;var t=!0;if(H(e))t=!1;else try{var i="__mplssupport__";at.set(i,"xyz"),'"xyz"'!==at.get(i)&&(t=!1),at.remove(i)}catch(e){t=!1}return t||K.error("localStorage unsupported; falling back to cookie store"),ot=t,t},error:function(e){K.error("localStorage error: "+e)},get:function(t){try{return null==e?void 0:e.localStorage.getItem(t)}catch(e){at.error(e)}return null},parse:function(e){try{return JSON.parse(at.get(e))||{}}catch(e){}return null},set:function(t,i){try{null==e||e.localStorage.setItem(t,JSON.stringify(i))}catch(e){at.error(e)}},remove:function(t){try{null==e||e.localStorage.removeItem(t)}catch(e){at.error(e)}}},lt=["distinct_id",we,Se,Ne,De],ut=ie(ie({},at),{},{parse:function(e){try{var t={};try{t=st.parse(e)||{}}catch(e){}var i=m(t,JSON.parse(at.get(e)||"{}"));return at.set(e,i),i}catch(e){}return null},set:function(e,t,i,n,r,s){try{at.set(e,t,void 0,void 0,s);var o={};lt.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&st.set(e,o,i,n,r,s)}catch(e){at.error(e)}},remove:function(t,i){try{null==e||e.localStorage.removeItem(t),st.remove(t,i)}catch(e){at.error(e)}}}),ct={},dt={is_supported:function(){return!0},error:function(e){K.error("memoryStorage error: "+e)},get:function(e){return ct[e]||null},parse:function(e){return ct[e]||null},set:function(e,t){ct[e]=t},remove:function(e){delete ct[e]}},ht=null,_t={is_supported:function(){if(!j(ht))return ht;if(ht=!0,H(e))ht=!1;else try{var t="__support__";_t.set(t,"xyz"),'"xyz"'!==_t.get(t)&&(ht=!1),_t.remove(t)}catch(e){ht=!1}return ht},error:function(e){K.error("sessionStorage error: ",e)},get:function(t){try{return null==e?void 0:e.sessionStorage.getItem(t)}catch(e){_t.error(e)}return null},parse:function(e){try{return JSON.parse(_t.get(e))||null}catch(e){}return null},set:function(t,i){try{null==e||e.sessionStorage.setItem(t,JSON.stringify(i))}catch(e){_t.error(e)}},remove:function(t){try{null==e||e.sessionStorage.removeItem(t)}catch(e){_t.error(e)}}},pt=["localhost","127.0.0.1"],vt=e=>{var t=null==o?void 0:o.createElement("a");return H(t)?null:(t.href=e,t)},gt=function(e,t){return!!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t)&&new RegExp(t).test(e)},ft=function(e){var t,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"&",r=[];return f(e,(function(e,n){H(e)||H(n)||"undefined"===n||(t=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),i=encodeURIComponent(n),r[r.length]=i+"="+t)})),r.join(n)},mt=function(e,t){for(var i,n=((e.split("#")[0]||"").split("?")[1]||"").split("&"),r=0;r<n.length;r++){var s=n[r].split("=");if(s[0]===t){i=s;break}}if(!D(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){K.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},bt=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},yt="Mobile",wt="iOS",St="Android",Et="Tablet",kt=St+" "+Et,xt="iPad",It="Apple",Ct=It+" Watch",Pt="Safari",Rt="BlackBerry",Ft="Samsung",Tt=Ft+"Browser",$t=Ft+" Internet",Ot="Chrome",Lt=Ot+" OS",Mt=Ot+" "+wt,At="Internet Explorer",Dt=At+" "+yt,Nt="Opera",qt=Nt+" Mini",Bt="Edge",Ht="Microsoft "+Bt,Ut="Firefox",zt=Ut+" "+wt,jt="Nintendo",Wt="PlayStation",Gt="Xbox",Vt=St+" "+yt,Jt=yt+" "+Pt,Yt="Windows",Xt=Yt+" Phone",Kt="Nokia",Qt="Ouya",Zt="Generic",ei=Zt+" "+yt.toLowerCase(),ti=Zt+" "+Et.toLowerCase(),ii="Konqueror",ni="(\\d+(\\.\\d+)?)",ri=new RegExp("Version/"+ni),si=new RegExp(Gt,"i"),oi=new RegExp(Wt+" \\w+","i"),ai=new RegExp(jt+" \\w+","i"),li=new RegExp(Rt+"|PlayBook|BB10","i"),ui={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var ci=(e,t)=>t&&b(t,It)||function(e){return b(e,Pt)&&!b(e,Ot)&&!b(e,St)}(e),di=function(e,t){return t=t||"",b(e," OPR/")&&b(e,"Mini")?qt:b(e," OPR/")?Nt:li.test(e)?Rt:b(e,"IE"+yt)||b(e,"WPDesktop")?Dt:b(e,Tt)?$t:b(e,Bt)||b(e,"Edg/")?Ht:b(e,"FBIOS")?"Facebook "+yt:b(e,"UCWEB")||b(e,"UCBrowser")?"UC Browser":b(e,"CriOS")?Mt:b(e,"CrMo")||b(e,Ot)?Ot:b(e,St)&&b(e,Pt)?Vt:b(e,"FxiOS")?zt:b(e.toLowerCase(),ii.toLowerCase())?ii:ci(e,t)?b(e,yt)?Jt:Pt:b(e,Ut)?Ut:b(e,"MSIE")||b(e,"Trident/")?At:b(e,"Gecko")?Ut:""},hi={[Dt]:[new RegExp("rv:"+ni)],[Ht]:[new RegExp(Bt+"?\\/"+ni)],[Ot]:[new RegExp("("+Ot+"|CrMo)\\/"+ni)],[Mt]:[new RegExp("CriOS\\/"+ni)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ni)],[Pt]:[ri],[Jt]:[ri],[Nt]:[new RegExp("(Opera|OPR)\\/"+ni)],[Ut]:[new RegExp(Ut+"\\/"+ni)],[zt]:[new RegExp("FxiOS\\/"+ni)],[ii]:[new RegExp("Konqueror[:/]?"+ni,"i")],[Rt]:[new RegExp(Rt+" "+ni),ri],[Vt]:[new RegExp("android\\s"+ni,"i")],[$t]:[new RegExp(Tt+"\\/"+ni)],[At]:[new RegExp("(rv:|MSIE )"+ni)],Mozilla:[new RegExp("rv:"+ni)]},_i=[[new RegExp(Gt+"; "+Gt+" (.*?)[);]","i"),e=>[Gt,e&&e[1]||""]],[new RegExp(jt,"i"),[jt,""]],[new RegExp(Wt,"i"),[Wt,""]],[li,[Rt,""]],[new RegExp(Yt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Xt,""];if(new RegExp(yt).test(t)&&!/IEMobile\b/.test(t))return[Yt+" "+yt,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var n=i[1],r=ui[n]||"";return/arm/i.test(t)&&(r="RT"),[Yt,r]}return[Yt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[wt,t.join(".")]}return[wt,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=H(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+St+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+St+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[St,t.join(".")]}return[St,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Lt,""]],[/Linux|debian/i,["Linux",""]]],pi=function(e){return ai.test(e)?jt:oi.test(e)?Wt:si.test(e)?Gt:new RegExp(Qt,"i").test(e)?Qt:new RegExp("("+Xt+"|WPDesktop)","i").test(e)?Xt:/iPad/.test(e)?xt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Ct:li.test(e)?Rt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Kt,"i").test(e)?Kt:/(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(yt).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)?St:kt:St:new RegExp("(pda|"+yt+")","i").test(e)?ei:new RegExp(Et,"i").test(e)&&!new RegExp(Et+" pc","i").test(e)?ti:""},vi="https?://(.*)",gi=["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"],fi={campaignParams:function(e){return o?this._campaignParamsFromUrl(o.URL,e):{}},_campaignParamsFromUrl:function(e,t){var i=gi.concat(t||[]),n={};return f(i,(function(t){var i=mt(e,t);n[t]=i||null})),n},_searchEngine:function(e){return e?0===e.search(vi+"google.([^/?]*)")?"google":0===e.search(vi+"bing.com")?"bing":0===e.search(vi+"yahoo.com")?"yahoo":0===e.search(vi+"duckduckgo.com")?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=fi._searchEngine(e),i="yahoo"!=t?"q":"p",n={};if(!j(t)){n.$search_engine=t;var r=o?mt(o.referrer,i):"";r.length&&(n.ph_keyword=r)}return n},searchInfo:function(){var e=null==o?void 0:o.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:di,browserVersion:function(e,t){var i=di(e,t),n=hi[i];if(H(n))return null;for(var r=0;r<n.length;r++){var s=n[r],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return"string"==typeof e?e.split("-")[0]:void 0},os:function(e){for(var t=0;t<_i.length;t++){var[i,n]=_i[t],r=i.exec(e),s=r&&(N(n)?n(r,e):n);if(s)return s}return["",""]},device:pi,deviceType:function(e){var t=pi(e);return t===xt||t===kt||"Kobo"===t||"Kindle Fire"===t||t===ti?Et:t===jt||t===Gt||t===Wt||t===Qt?"Console":t===Ct?"Wearable":t?yt:"Desktop"},referrer:function(){return(null==o?void 0:o.referrer)||"$direct"},referringDomain:function(){var e;return null!=o&&o.referrer&&(null===(e=vt(o.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().substring(0,1e3),u:null==a?void 0:a.href.substring(0,1e3)}},initialPersonPropsFromInfo:function(e){var t,{r:i,u:n}=e,r={$initial_referrer:i,$initial_referring_domain:null==i?void 0:"$direct"==i?"$direct":null===(t=vt(i))||void 0===t?void 0:t.host};if(n){r.$initial_current_url=n;var s=vt(n);r.$initial_host=null==s?void 0:s.host,r.$initial_pathname=null==s?void 0:s.pathname,f(this._campaignParamsFromUrl(n),(function(e,t){r["$initial_"+k(t)]=e}))}i&&f(this._searchInfoFromReferrer(i),(function(e,t){r["$initial_"+k(t)]=e}));return r},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}},timezoneOffset:function(){try{return(new Date).getTimezoneOffset()}catch(e){return}},properties:function(){if(!d)return{};var[t,i]=fi.os(d);return m(E({$os:t,$os_version:i,$browser:fi.browser(d,navigator.vendor),$device:fi.device(d),$device_type:fi.deviceType(d),$timezone:fi.timezone(),$timezone_offset:fi.timezoneOffset()}),{$current_url:null==a?void 0:a.href,$host:null==a?void 0:a.host,$pathname:null==a?void 0:a.pathname,$raw_user_agent:d.length>1e3?d.substring(0,997)+"...":d,$browser_version:fi.browserVersion(d,navigator.vendor),$browser_language:fi.browserLanguage(),$browser_language_prefix:fi.browserLanguagePrefix(),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:"web",$lib_version:_.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(!d)return{};var[e,t]=fi.os(d);return m(E({$os:e,$os_version:t,$browser:fi.browser(d,navigator.vendor)}),{$browser_version:fi.browserVersion(d,navigator.vendor)})}},mi=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class bi{constructor(e){this.config=e,this.props={},this.campaign_params_saved=!1,this.name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this.storage=this.buildStorage(e),this.load(),e.debug&&K.info("Persistence loaded",e.persistence,ie({},this.props)),this.update_config(e,e),this.save()}buildStorage(e){-1===mi.indexOf(e.persistence.toLowerCase())&&(K.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&at.is_supported()?at:"localstorage+cookie"===t&&ut.is_supported()?ut:"sessionstorage"===t&&_t.is_supported()?_t:"memory"===t?dt:"cookie"===t?st:ut.is_supported()?ut:st}properties(){var e={};return f(this.props,(function(t,i){if(i===xe&&q(t))for(var n=Object.keys(t),s=0;s<n.length;s++)e["$feature/".concat(n[s])]=t[n[s]];else a=i,l=!1,(j(o=Be)?l:r&&o.indexOf===r?-1!=o.indexOf(a):(f(o,(function(e){if(l||(l=e===a))return p})),l))||(e[i]=t);var o,a,l})),e}load(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=m({},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(q(e)){H(t)&&(t="None"),this.expire_days=H(i)?this.default_expiry:i;var n=!1;if(f(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,n=!0)})),n)return this.save(),!0}return!1}register(e,t){if(q(e)){this.expire_days=H(t)?this.default_expiry:t;var i=!1;if(f(e,((t,n)=>{e.hasOwnProperty(n)&&this.props[n]!==t&&(this.props[n]=t,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.campaign_params_saved){var e=fi.campaignParams(this.config.custom_campaign_params);B(E(e))||this.register(e),this.campaign_params_saved=!0}}update_search_keyword(){this.register(fi.searchInfo())}update_referrer_info(){this.register_once(fi.referrerInfo(),void 0)}set_initial_person_info(){this.props[Me]||this.props[Ae]||this.register_once({[De]:fi.initialPersonInfo()},void 0)}get_referrer_info(){return E({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var e={};f([Ae,Me],(t=>{var i=this.props[t];i&&f(i,(function(t,i){e["$initial_"+k(i)]=t}))}));var t=this.props[De];if(t){var i=fi.initialPersonPropsFromInfo(t);m(e,i)}return e}safe_merge(e){return f(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){var i=this.buildStorage(e),n=this.props;this.clear(),this.storage=i,this.props=n,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){var i=this.props[ae]||{};i[e]=t,this.props[ae]=i,this.save()}remove_event_timer(e){var t=(this.props[ae]||{})[e];return H(t)||(delete this.props[ae][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}function yi(e){var t,i;return(null===(t=JSON.stringify(e,(i=[],function(e,t){if(q(t)){for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(t)?"[Circular]":(i.push(t),t)}return t})))||void 0===t?void 0:t.length)||0}function wi(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6606028.8;if(e.size>=t&&e.data.length>1){var i=Math.floor(e.data.length/2),n=e.data.slice(0,i),r=e.data.slice(i);return[wi({size:yi(n),data:n,sessionId:e.sessionId,windowId:e.windowId}),wi({size:yi(r),data:r,sessionId:e.sessionId,windowId:e.windowId})].flatMap((e=>e))}return[e]}var Si=(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))(Si||{}),Ei=(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))(Ei||{});function ki(e){var t;return e.id===qe||!(null===(t=e.closest)||void 0===t||!t.call(e,".toolbar-global-fade-container"))}function xi(e){return!!e&&1===e.nodeType}function Ii(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Ci(e){return!!e&&3===e.nodeType}function Pi(e){return!!e&&11===e.nodeType}function Ri(e){return e?v(e).split(/\s+/):[]}function Fi(t){var i=null==e?void 0:e.location.href;return!!(i&&t&&t.some((e=>i.match(e))))}function Ti(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Ri(t)}function $i(e){return W(e)?null:v(e).split(/(\s+)/).filter((e=>Gi(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Oi(e){var t="";return Ni(e)&&!qi(e)&&e.childNodes&&e.childNodes.length&&f(e.childNodes,(function(e){var i;Ci(e)&&e.textContent&&(t+=null!==(i=$i(e.textContent))&&void 0!==i?i:"")})),v(t)}function Li(e){return H(e.target)?e.srcElement||null:null!==(t=e.target)&&void 0!==t&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Mi=["a","button","form","input","select","textarea","label"];function Ai(e){var t=e.parentNode;return!(!t||!xi(t))&&t}function Di(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!e||!t||Ii(t,"html")||!xi(t))return!1;if(null!=n&&n.url_allowlist&&!Fi(n.url_allowlist))return!1;if(null!=n&&n.url_ignorelist&&Fi(n.url_ignorelist))return!1;if(null!=n&&n.dom_event_allowlist){var o=n.dom_event_allowlist;if(o&&!o.some((e=>i.type===e)))return!1}for(var a=!1,l=[t],u=!0,c=t;c.parentNode&&!Ii(c,"body");)if(Pi(c.parentNode))l.push(c.parentNode.host),c=c.parentNode.host;else{if(!(u=Ai(c)))break;if(r||Mi.indexOf(u.tagName.toLowerCase())>-1)a=!0;else{var d=e.getComputedStyle(u);d&&"pointer"===d.getPropertyValue("cursor")&&(a=!0)}l.push(u),c=u}if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(H(i))return!0;var n=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var r of e){var s=n(r);if("object"==typeof s)return s.v}return!1}(l,n))return!1;if(!function(e,t){var i=null==t?void 0:t.css_selector_allowlist;if(H(i))return!0;var n=function(e){if(i.some((t=>e.matches(t))))return{v:!0}};for(var r of e){var s=n(r);if("object"==typeof s)return s.v}return!1}(l,n))return!1;var h=e.getComputedStyle(t);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===i.type)return!0;var _=t.tagName.toLowerCase();switch(_){case"html":return!1;case"form":return(s||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(i.type)>=0;default:return a?(s||["click"]).indexOf(i.type)>=0:(s||["click"]).indexOf(i.type)>=0&&(Mi.indexOf(_)>-1||"true"===t.getAttribute("contenteditable"))}}function Ni(e){for(var t=e;t.parentNode&&!Ii(t,"body");t=t.parentNode){var i=Ti(t);if(b(i,"ph-sensitive")||b(i,"ph-no-capture"))return!1}if(b(Ti(e),"ph-include"))return!0;var n=e.type||"";if(U(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(U(r)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function qi(e){return!!(Ii(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ii(e,"select")||Ii(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Bi="(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})",Hi=new RegExp("^(?:".concat(Bi,")$")),Ui=new RegExp(Bi),zi="\\d{3}-?\\d{2}-?\\d{4}",ji=new RegExp("^(".concat(zi,")$")),Wi=new RegExp("(".concat(zi,")"));function Gi(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(W(e))return!1;if(U(e)){if(e=v(e),(t?Hi:Ui).test((e||"").replace(/[- ]/g,"")))return!1;if((t?ji:Wi).test(e))return!1}return!0}function Vi(e){var t=Oi(e);return Gi(t="".concat(t," ").concat(Ji(e)).trim())?t:""}function Ji(e){var t="";return e&&e.childNodes&&e.childNodes.length&&f(e.childNodes,(function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{var n=Oi(e);t="".concat(t," ").concat(n).trim(),e.childNodes&&e.childNodes.length&&(t="".concat(t," ").concat(Ji(e)).trim())}catch(e){K.error("[AutoCapture]",e)}})),t}function Yi(e){return function(e){var t=e.map((e=>{var t,i,n="";if(e.tag_name&&(n+=e.tag_name),e.attr_class)for(var r of(e.attr_class.sort(),e.attr_class))n+=".".concat(r.replace(/"/g,""));var s=ie(ie(ie(ie({},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),o={};return y(s).sort(((e,t)=>{var[i]=e,[n]=t;return i.localeCompare(n)})).forEach((e=>{var[t,i]=e;return o[Xi(t.toString())]=Xi(i.toString())})),n+=":",n+=y(s).map((e=>{var[t,i]=e;return"".concat(t,'="').concat(i,'"')})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,i,n={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:Ki(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return y(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return n.attributes[t]=i})),n}))}(e))}function Xi(e){return e.replace(/"|\\"/g,'\\"')}function Ki(e){var t=e.attr__class;return t?D(t)?t:Ri(t):void 0}var Qi="[SessionRecording]",Zi="redacted",en={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"]},tn=["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"],nn=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],rn=["/s/","/e/","/i/"];function sn(e,t,i,n){if(W(e))return e;var r=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return U(r)&&(r=parseInt(r)),r>i?Qi+" ".concat(n," body too large to record (").concat(r," bytes)"):e}function on(e,t){if(W(e))return e;var i=e;return Gi(i,!1)||(i=Qi+" "+t+" body "+Zi),f(nn,(e=>{var n,r;null!==(n=i)&&void 0!==n&&n.length&&-1!==(null===(r=i)||void 0===r?void 0:r.indexOf(e))&&(i=Qi+" "+t+" body "+Zi+" as might contain: "+e)})),i}var an=(e,t)=>{var i,n,r,s={payloadSizeLimitBytes:en.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...en.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...en.payloadHostDenyList]},o=!1!==e.session_recording.recordHeaders&&t.recordHeaders,a=!1!==e.session_recording.recordBody&&t.recordBody,l=!1!==e.capture_performance&&t.recordPerformance,u=(i=s,r=Math.min(1e6,null!==(n=i.payloadSizeLimitBytes)&&void 0!==n?n:1e6),e=>(null!=e&&e.requestBody&&(e.requestBody=sn(e.requestBody,e.requestHeaders,r,"Request")),null!=e&&e.responseBody&&(e.responseBody=sn(e.responseBody,e.responseHeaders,r,"Response")),e)),c=t=>{return u(((e,t)=>{var i,n=vt(e.name),r=0===t.indexOf("http")?null===(i=vt(t))||void 0===i?void 0:i.pathname:t;"/"===r&&(r="");var s=null==n?void 0:n.pathname.replace(r||"","");if(!(n&&s&&rn.some((e=>0===s.indexOf(e)))))return e})((n=(i=t).requestHeaders,W(n)||f(Object.keys(null!=n?n:{}),(e=>{tn.includes(e.toLowerCase())&&(n[e]=Zi)})),i),e.api_host));var i,n},d=N(e.session_recording.maskNetworkRequestFn);return d&&N(e.session_recording.maskCapturedNetworkRequestFn)&&K.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),d&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{var i=e.session_recording.maskNetworkRequestFn({url:t.name});return ie(ie({},t),{},{name:null==i?void 0:i.url})}),s.maskRequestFn=N(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,n,r,s=c(t);return s&&null!==(i=null===(n=(r=e.session_recording).maskCapturedNetworkRequestFn)||void 0===n?void 0:n.call(r,s))&&void 0!==i?i:void 0}:e=>function(e){if(!H(e))return e.requestBody=on(e.requestBody,"Request"),e.responseBody=on(e.responseBody,"Response"),e}(c(e)),ie(ie(ie({},en),s),{},{recordHeaders:o,recordBody:a,recordPerformance:l,recordInitialRequests:l})};function ln(e,t,i,n,r){return t>i&&(K.warn("min cannot be greater than max."),t=i),G(e)?e>i?(n&&K.warn(n+" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(n&&K.warn(n+" cannot be less than min: "+t+". Using min value instead."),t):e:(n&&K.warn(n+" must be a number. using max or fallback. max: "+i+", fallback: "+r),ln(r||i,t,i,n))}class un{constructor(e){var t,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ne(this,"bucketSize",100),ne(this,"refillRate",10),ne(this,"mutationBuckets",{}),ne(this,"loggedTracker",{}),ne(this,"refillBuckets",(()=>{Object.keys(this.mutationBuckets).forEach((e=>{this.mutationBuckets[e]=this.mutationBuckets[e]+this.refillRate,this.mutationBuckets[e]>=this.bucketSize&&delete this.mutationBuckets[e]}))})),ne(this,"getNodeOrRelevantParent",(e=>{var t=this.rrweb.mirror.getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){var i=t.closest("svg");if(i)return[this.rrweb.mirror.getId(i),i]}return[e,t]})),ne(this,"numberOfChanges",(e=>{var t,i,n,r,s,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(n=null===(r=e.attributes)||void 0===r?void 0:r.length)&&void 0!==n?n:0)+(null!==(s=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==s?s:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)})),ne(this,"throttleMutations",(e=>{if(3!==e.type||0!==e.data.source)return e;var t=e.data,i=this.numberOfChanges(t);t.attributes&&(t.attributes=t.attributes.filter((e=>{var t,i,n,[r,s]=this.getNodeOrRelevantParent(e.id);if(0===this.mutationBuckets[r])return!1;(this.mutationBuckets[r]=null!==(t=this.mutationBuckets[r])&&void 0!==t?t:this.bucketSize,this.mutationBuckets[r]=Math.max(this.mutationBuckets[r]-1,0),0===this.mutationBuckets[r])&&(this.loggedTracker[r]||(this.loggedTracker[r]=!0,null===(i=(n=this.options).onBlockedNode)||void 0===i||i.call(n,r,s)));return e})));var n=this.numberOfChanges(t);return 0!==n||i===n?e:void 0})),this.rrweb=e,this.options=n,this.refillRate=ln(null!==(t=this.options.refillRate)&&void 0!==t?t:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=ln(null!==(i=this.options.bucketSize)&&void 0!==i?i:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval((()=>{this.refillBuckets()}),1e3)}}var cn=Uint8Array,dn=Uint16Array,hn=Uint32Array,_n=new cn([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]),pn=new cn([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]),vn=new cn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gn=function(e,t){for(var i=new dn(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var r=new hn(i[30]);for(n=1;n<30;++n)for(var s=i[n];s<i[n+1];++s)r[s]=s-i[n]<<5|n;return[i,r]},fn=gn(_n,2),mn=fn[0],bn=fn[1];mn[28]=258,bn[258]=28;for(var yn=gn(pn,0)[1],wn=new dn(32768),Sn=0;Sn<32768;++Sn){var En=(43690&Sn)>>>1|(21845&Sn)<<1;En=(61680&(En=(52428&En)>>>2|(13107&En)<<2))>>>4|(3855&En)<<4,wn[Sn]=((65280&En)>>>8|(255&En)<<8)>>>1}var kn=function(e,t,i){for(var n=e.length,r=0,s=new dn(t);r<n;++r)++s[e[r]-1];var o,a=new dn(t);for(r=0;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;if(i){o=new dn(1<<t);var l=15-t;for(r=0;r<n;++r)if(e[r])for(var u=r<<4|e[r],c=t-e[r],d=a[e[r]-1]++<<c,h=d|(1<<c)-1;d<=h;++d)o[wn[d]>>>l]=u}else for(o=new dn(n),r=0;r<n;++r)o[r]=wn[a[e[r]-1]++]>>>15-e[r];return o},xn=new cn(288);for(Sn=0;Sn<144;++Sn)xn[Sn]=8;for(Sn=144;Sn<256;++Sn)xn[Sn]=9;for(Sn=256;Sn<280;++Sn)xn[Sn]=7;for(Sn=280;Sn<288;++Sn)xn[Sn]=8;var In=new cn(32);for(Sn=0;Sn<32;++Sn)In[Sn]=5;var Cn=kn(xn,9,0),Pn=kn(In,5,0),Rn=function(e){return(e/8>>0)+(7&e&&1)},Fn=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var n=new(e instanceof dn?dn:e instanceof hn?hn:cn)(i-t);return n.set(e.subarray(t,i)),n},Tn=function(e,t,i){i<<=7&t;var n=t/8>>0;e[n]|=i,e[n+1]|=i>>>8},$n=function(e,t,i){i<<=7&t;var n=t/8>>0;e[n]|=i,e[n+1]|=i>>>8,e[n+2]|=i>>>16},On=function(e,t){for(var i=[],n=0;n<e.length;++n)e[n]&&i.push({s:n,f:e[n]});var r=i.length,s=i.slice();if(!r)return[new cn(0),0];if(1==r){var o=new cn(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[u].f<i[d].f?u++:d++],l=i[u!=c&&i[u].f<i[d].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var h=s[0].s;for(n=1;n<r;++n)s[n].s>h&&(h=s[n].s);var _=new dn(h+1),p=Ln(i[c-1],_,0);if(p>t){n=0;var v=0,g=p-t,f=1<<g;for(s.sort((function(e,t){return _[t.s]-_[e.s]||e.f-t.f}));n<r;++n){var m=s[n].s;if(!(_[m]>t))break;v+=f-(1<<p-_[m]),_[m]=t}for(v>>>=g;v>0;){var b=s[n].s;_[b]<t?v-=1<<t-_[b]++-1:++n}for(;n>=0&&v;--n){var y=s[n].s;_[y]==t&&(--_[y],++v)}p=t}return[new cn(_),p]},Ln=function(e,t,i){return-1==e.s?Math.max(Ln(e.l,t,i+1),Ln(e.r,t,i+1)):t[e.s]=i},Mn=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new dn(++t),n=0,r=e[0],s=1,o=function(e){i[n++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(r),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(r);s=1,r=e[a]}return[i.subarray(0,n),t]},An=function(e,t){for(var i=0,n=0;n<t.length;++n)i+=e[n]*t[n];return i},Dn=function(e,t,i){var n=i.length,r=Rn(t+2);e[r]=255&n,e[r+1]=n>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var s=0;s<n;++s)e[r+s+4]=i[s];return 8*(r+4+n)},Nn=function(e,t,i,n,r,s,o,a,l,u,c){Tn(t,c++,i),++r[256];for(var d=On(r,15),h=d[0],_=d[1],p=On(s,15),v=p[0],g=p[1],f=Mn(h),m=f[0],b=f[1],y=Mn(v),w=y[0],S=y[1],E=new dn(19),k=0;k<m.length;++k)E[31&m[k]]++;for(k=0;k<w.length;++k)E[31&w[k]]++;for(var x=On(E,7),I=x[0],C=x[1],P=19;P>4&&!I[vn[P-1]];--P);var R,F,T,$,O=u+5<<3,L=An(r,xn)+An(s,In)+o,M=An(r,h)+An(s,v)+o+14+3*P+An(E,I)+(2*E[16]+3*E[17]+7*E[18]);if(O<=L&&O<=M)return Dn(t,c,e.subarray(l,l+u));if(Tn(t,c,1+(M<L)),c+=2,M<L){R=kn(h,_,0),F=h,T=kn(v,g,0),$=v;var A=kn(I,C,0);Tn(t,c,b-257),Tn(t,c+5,S-1),Tn(t,c+10,P-4),c+=14;for(k=0;k<P;++k)Tn(t,c+3*k,I[vn[k]]);c+=3*P;for(var D=[m,w],N=0;N<2;++N){var q=D[N];for(k=0;k<q.length;++k){var B=31&q[k];Tn(t,c,A[B]),c+=I[B],B>15&&(Tn(t,c,q[k]>>>5&127),c+=q[k]>>>12)}}}else R=Cn,F=xn,T=Pn,$=In;for(k=0;k<a;++k)if(n[k]>255){B=n[k]>>>18&31;$n(t,c,R[B+257]),c+=F[B+257],B>7&&(Tn(t,c,n[k]>>>23&31),c+=_n[B]);var H=31&n[k];$n(t,c,T[H]),c+=$[H],H>3&&($n(t,c,n[k]>>>5&8191),c+=pn[H])}else $n(t,c,R[n[k]]),c+=F[n[k]];return $n(t,c,R[256]),c+F[256]},qn=new hn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bn=function(){for(var e=new hn(256),t=0;t<256;++t){for(var i=t,n=9;--n;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Hn=function(){var e=4294967295;return{p:function(t){for(var i=e,n=0;n<t.length;++n)i=Bn[255&i^t[n]]^i>>>8;e=i},d:function(){return 4294967295^e}}},Un=function(e,t,i,n,r){return function(e,t,i,n,r,s){var o=e.length,a=new cn(n+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(n,a.length-r),u=0;if(!t||o<8)for(var c=0;c<=o;c+=65535){var d=c+65535;d<o?u=Dn(l,u,e.subarray(c,d)):(l[c]=s,u=Dn(l,u,e.subarray(c,o)))}else{for(var h=qn[t-1],_=h>>>13,p=8191&h,v=(1<<i)-1,g=new dn(32768),f=new dn(v+1),m=Math.ceil(i/3),b=2*m,y=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<b)&v},w=new hn(25e3),S=new dn(288),E=new dn(32),k=0,x=0,I=(c=0,0),C=0,P=0;c<o;++c){var R=y(c),F=32767&c,T=f[R];if(g[F]=T,f[R]=F,C<=c){var $=o-c;if((k>7e3||I>24576)&&$>423){u=Nn(e,l,0,w,S,E,x,I,P,c-P,u),I=k=x=0,P=c;for(var O=0;O<286;++O)S[O]=0;for(O=0;O<30;++O)E[O]=0}var L=2,M=0,A=p,D=F-T&32767;if($>2&&R==y(c-D))for(var N=Math.min(_,$)-1,q=Math.min(32767,c),B=Math.min(258,$);D<=q&&--A&&F!=T;){if(e[c+L]==e[c+L-D]){for(var H=0;H<B&&e[c+H]==e[c+H-D];++H);if(H>L){if(L=H,M=D,H>N)break;var U=Math.min(D,H-2),z=0;for(O=0;O<U;++O){var j=c-D+O+32768&32767,W=j-g[j]+32768&32767;W>z&&(z=W,T=j)}}}D+=(F=T)-(T=g[F])+32768&32767}if(M){w[I++]=268435456|bn[L]<<18|yn[M];var G=31&bn[L],V=31&yn[M];x+=_n[G]+pn[V],++S[257+G],++E[V],C=c+L,++k}else w[I++]=e[c],++S[e[c]]}}u=Nn(e,l,s,w,S,E,x,I,P,c-P,u)}return Fn(a,0,n+Rn(u)+r)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,n,!r)},zn=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},jn=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&&zn(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var n=0;n<=i.length;++n)e[n+10]=i.charCodeAt(n)}},Wn=function(e){return 10+(e.filename&&e.filename.length+1||0)};function Gn(e,t){void 0===t&&(t={});var i=Hn(),n=e.length;i.p(e);var r=Un(e,t,Wn(t),8),s=r.length;return jn(r,t),zn(r,s-8,i.d()),zn(r,s-4,n),r}function Vn(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var n=new cn(e.length+(e.length>>>1)),r=0,s=function(e){n[r++]=e},o=0;o<i;++o){if(r+5>n.length){var a=new cn(r+8+(i-o<<1));a.set(n),n=a}var l=e.charCodeAt(o);l<128||t?s(l):l<2048?(s(192|l>>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),s(128|l>>>12&63),s(128|l>>>6&63),s(128|63&l)):(s(224|l>>>12),s(128|l>>>6&63),s(128|63&l))}return Fn(n,0,r)}var Jn="[SessionRecording]",Yn=Q(Jn),Xn=3e5,Kn=[Ei.MouseMove,Ei.MouseInteraction,Ei.Scroll,Ei.ViewportResize,Ei.Input,Ei.TouchMove,Ei.MediaInteraction,Ei.Drag],Qn=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function Zn(e){return function(e,t){for(var i="",n=0;n<e.length;){var r=e[n++];r<128||t?i+=String.fromCharCode(r):r<224?i+=String.fromCharCode((31&r)<<6|63&e[n++]):r<240?i+=String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,i+=String.fromCharCode(55296|r>>10,56320|1023&r))}return i}(Gn(Vn(JSON.stringify(e))),!0)}function er(e){return e.type===Si.Custom&&"sessionIdle"===e.data.tag}function tr(e,t){return t.some((t=>"regex"===t.matching&&new RegExp(t.url).test(e)))}class ir{get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get rrwebRecord(){var e,t;return null==h||null===(e=h.__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(Jn+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var e,t;return"trigger_pending"===this.triggerStatus?6e4:null!==(e=null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.full_snapshot_interval_millis)&&void 0!==e?e:Xn}get isSampled(){var e=this.instance.get_property(Se);return V(e)?e:null}get sessionDuration(){var e,t,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:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return i?i.timestamp-n:null}get isRecordingEnabled(){var t=!!this.instance.get_property(pe),i=!this.instance.config.disable_session_recording;return e&&t&&i}get isConsoleLogCaptureEnabled(){var e=!!this.instance.get_property(ve),t=this.instance.config.enable_recording_console_log;return null!=t?t:e}get canvasRecording(){var e,t,i,n,r,s,o=this.instance.config.session_recording.captureCanvas,a=this.instance.get_property(fe),l=null!==(e=null!==(t=null==o?void 0:o.recordCanvas)&&void 0!==t?t:null==a?void 0:a.enabled)&&void 0!==e&&e,u=null!==(i=null!==(n=null==o?void 0:o.canvasFps)&&void 0!==n?n:null==a?void 0:a.fps)&&void 0!==i?i:0,c=null!==(r=null!==(s=null==o?void 0:o.canvasQuality)&&void 0!==s?s:null==a?void 0:a.quality)&&void 0!==r?r:0;return{enabled:l,fps:ln(u,0,12,"canvas recording fps"),quality:ln(c,0,1,"canvas recording quality")}}get networkPayloadCapture(){var e,t,i=this.instance.get_property(ge),n={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},r=(null==n?void 0:n.recordHeaders)||(null==i?void 0:i.recordHeaders),s=(null==n?void 0:n.recordBody)||(null==i?void 0:i.recordBody),o=q(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,a=!!(V(o)?o:null==i?void 0:i.capturePerformance);return r||s||a?{recordHeaders:r,recordBody:s,recordPerformance:a}:void 0}get sampleRate(){var e=this.instance.get_property(me);return G(e)?e:null}get minimumDuration(){var e=this.instance.get_property(be);return G(e)?e:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this._urlBlocked?"paused":W(this._linkedFlag)||this._linkedFlagSeen?"trigger_pending"===this.triggerStatus?"buffering":V(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var e;return 0===this._urlTriggers.length?"trigger_disabled":(null===(e=this.instance)||void 0===e?void 0:e.get_property(Ee))===this.sessionId?"trigger_activated":"trigger_pending"}get eventTriggerStatus(){var e;return 0===this._eventTriggers.length?"trigger_disabled":(null===(e=this.instance)||void 0===e?void 0:e.get_property(ke))===this.sessionId?"trigger_activated":"trigger_pending"}get triggerStatus(){var e="trigger_activated"===this.eventTriggerStatus||"trigger_activated"===this.urlTriggerStatus,t="trigger_pending"===this.eventTriggerStatus||"trigger_pending"===this.urlTriggerStatus;return e?"trigger_activated":t?"trigger_pending":"trigger_disabled"}constructor(e){if(ne(this,"queuedRRWebEvents",[]),ne(this,"isIdle",!1),ne(this,"_linkedFlagSeen",!1),ne(this,"_lastActivityTimestamp",Date.now()),ne(this,"_linkedFlag",null),ne(this,"_removePageViewCaptureHook",void 0),ne(this,"_onSessionIdListener",void 0),ne(this,"_persistDecideOnSessionListener",void 0),ne(this,"_samplingSessionListener",void 0),ne(this,"_urlTriggers",[]),ne(this,"_urlBlocklist",[]),ne(this,"_urlBlocked",!1),ne(this,"_eventTriggers",[]),ne(this,"_removeEventTriggerCaptureHook",void 0),ne(this,"_forceAllowLocalhostNetworkCapture",!1),ne(this,"_onBeforeUnload",(()=>{this._flushBuffer()})),ne(this,"_onOffline",(()=>{this._tryAddCustomEvent("browser offline",{})})),ne(this,"_onOnline",(()=>{this._tryAddCustomEvent("browser online",{})})),ne(this,"_onVisibilityChange",(()=>{if(null!=o&&o.visibilityState){var e="window "+o.visibilityState;this._tryAddCustomEvent(e,{})}})),this.instance=e,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw Yn.error("started without valid sessionManager"),new Error(Jn+" started without valid sessionManager. This is a bug.");var{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=t,this.windowId=i,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&Yn.warn("session_idle_threshold_ms (".concat(this.sessionIdleThresholdMilliseconds,") is greater than the session timeout (").concat(this.sessionManager.sessionTimeoutMs,"). Session will never be detected as idle"))}startIfEnabledOrStop(t){this.isRecordingEnabled?(this._startCapture(t),null==e||e.addEventListener("beforeunload",this._onBeforeUnload),null==e||e.addEventListener("offline",this._onOffline),null==e||e.addEventListener("online",this._onOnline),null==e||e.addEventListener("visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),W(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance.on("eventCaptured",(e=>{try{if("$pageview"===e.event){var t=null!=e&&e.properties.$current_url?this._maskUrl(null==e?void 0:e.properties.$current_url):"";if(!t)return;this._tryAddCustomEvent("$pageview",{href:t})}}catch(e){Yn.error("Could not add $pageview to rrweb session",e)}}))),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId(((e,t,i)=>{var n,r,s,o;i&&(this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),null===(n=this.instance)||void 0===n||null===(r=n.persistence)||void 0===r||r.unregister(ke),null===(s=this.instance)||void 0===s||null===(o=s.persistence)||void 0===o||o.unregister(Ee))})))):this.stopRecording()}stopRecording(){var t,i,n,r;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,null==e||e.removeEventListener("beforeunload",this._onBeforeUnload),null==e||e.removeEventListener("offline",this._onOffline),null==e||e.removeEventListener("online",this._onOnline),null==e||e.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),null===(t=this._removePageViewCaptureHook)||void 0===t||t.call(this),this._removePageViewCaptureHook=void 0,null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),this._removeEventTriggerCaptureHook=void 0,null===(n=this._onSessionIdListener)||void 0===n||n.call(this),this._onSessionIdListener=void 0,null===(r=this._samplingSessionListener)||void 0===r||r.call(this),this._samplingSessionListener=void 0,Yn.info("stopped"))}makeSamplingDecision(e){var t,i=this.sessionId!==e,n=this.sampleRate;if(G(n)){var r,s=this.isSampled,o=i||!V(s);if(o)r=Math.random()<n;else r=s;o&&(r?this._reportStarted("sampled"):Yn.warn("Sample rate (".concat(n,") has determined that this sessionId (").concat(e,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:n,isSampled:r})),null===(t=this.instance.persistence)||void 0===t||t.register({[Se]:r})}else{var a;null===(a=this.instance.persistence)||void 0===a||a.register({[Se]:null})}}onRemoteConfig(e){var t,i,n,r,s,o;(this._persistRemoteConfig(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===(o=e.sessionRecording)||void 0===o?void 0:o.endpoint);if(this._setupSampling(),!W(this._linkedFlag)&&!this._linkedFlagSeen){var a=U(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,l=U(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags(((e,t)=>{var i=q(t)&&a in t,n=l?t[a]===l:i;n&&this._reportStarted("linked_flag_matched",{linkedFlag:a,linkedVariant:l}),this._linkedFlagSeen=n}))}null!==(n=e.sessionRecording)&&void 0!==n&&n.urlTriggers&&(this._urlTriggers=e.sessionRecording.urlTriggers),null!==(r=e.sessionRecording)&&void 0!==r&&r.urlBlocklist&&(this._urlBlocklist=e.sessionRecording.urlBlocklist),null!==(s=e.sessionRecording)&&void 0!==s&&s.eventTriggers&&(this._eventTriggers=e.sessionRecording.eventTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){G(this.sampleRate)&&W(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId((e=>{this.makeSamplingDecision(e)})))}_persistRemoteConfig(e){if(this.instance.persistence){var t,i=this.instance.persistence,n=()=>{var t,n,r,s,o,a,l,u,c=null===(t=e.sessionRecording)||void 0===t?void 0:t.sampleRate,d=W(c)?null:parseFloat(c),h=null===(n=e.sessionRecording)||void 0===n?void 0:n.minimumDurationMilliseconds;i.register({[pe]:!!e.sessionRecording,[ve]:null===(r=e.sessionRecording)||void 0===r?void 0:r.consoleLogRecordingEnabled,[ge]:ie({capturePerformance:e.capturePerformance},null===(s=e.sessionRecording)||void 0===s?void 0:s.networkPayloadCapture),[fe]:{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},[me]:d,[be]:H(h)?null:h,[ye]:null===(u=e.sessionRecording)||void 0===u?void 0:u.scriptConfig})};n(),null===(t=this._persistDecideOnSessionListener)||void 0===t||t.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(n)}}log(e){var t,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(!H(Object.assign)&&!H(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=h.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,this.scriptName,(e=>{if(e)return Yn.error("could not load recorder",e);this._onScriptLoaded()}));Yn.info("starting"),"active"===this.status&&this._reportStarted(e||"recording_initialized")}}get scriptName(){var e,t,i;return(null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t||null===(i=t.get_property(ye))||void 0===i?void 0:i.script)||"recorder"}isInteractiveEvent(e){var t;return 3===e.type&&-1!==Kn.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){var t=this.isInteractiveEvent(e);t||this.isIdle||e.timestamp-this._lastActivityTimestamp>this.sessionIdleThresholdMilliseconds&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this.sessionIdleThresholdMilliseconds,bufferLength:this.buffer.data.length,bufferSize:this.buffer.size}),this._flushBuffer());var i=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)),!this.isIdle){var{windowId:n,sessionId:r}=this.sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),s=this.sessionId!==r,o=this.windowId!==n;this.windowId=n,this.sessionId=r,s||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}):Yn.warn("could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(Qn((()=>this.rrwebRecord.addCustomEvent(e,t))))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(Qn((()=>this.rrwebRecord.takeFullSnapshot())))}_onScriptLoaded(){var e,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(var[n,r]of Object.entries(i||{}))n in t&&("maskInputOptions"===n?t.maskInputOptions=ie({password:!0},r):t[n]=r);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){this.mutationRateLimiter=null!==(e=this.mutationRateLimiter)&&void 0!==e?e:new un(this.rrwebRecord,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(e,t)=>{var i="Too many mutations on node '".concat(e,"'. Rate limiting. This could be due to SVG animations or something similar");Yn.info(i,{node:t}),this.log(Jn+" "+i,"warn")}});var s=this._gatherRRWebPlugins();this.stopRrweb=this.rrwebRecord(ie({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})}else Yn.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!this.isIdle){var e=this.fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval((()=>{this._tryTakeFullSnapshot()}),e))}}_gatherRRWebPlugins(){var e,t,i,n,r=[],s=null===(e=h.__PosthogExtensions__)||void 0===e||null===(t=e.rrwebPlugins)||void 0===t?void 0:t.getRecordConsolePlugin;s&&this.isConsoleLogCaptureEnabled&&r.push(s());var o=null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.rrwebPlugins)||void 0===n?void 0:n.getRecordNetworkPlugin;this.networkPayloadCapture&&N(o)&&(!pt.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?r.push(o(an(this.instance.config,this.networkPayloadCapture))):Yn.info("NetworkCapture not started because we are on localhost."));return r}onRRwebEmit(e){var t;if(this._processQueuedEvents(),e&&q(e)){if(e.type===Si.Meta){var i=this._maskUrl(e.data.href);if(this._lastHref=i,!i)return;e.data.href=i}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),"paused"!==this.status||function(e){return e.type===Si.Custom&&"recording paused"===e.data.tag}(e)){e.type===Si.FullSnapshot&&this._scheduleFullSnapshot(),e.type===Si.FullSnapshot&&"trigger_pending"===this.triggerStatus&&this.clearBuffer();var n=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(e):e;if(n){var r=function(e){var t=e;if(t&&q(t)&&6===t.type&&q(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));for(var i=[],n=0;n<t.data.payload.payload.length;n++)t.data.payload.payload[n]&&t.data.payload.payload[n].length>2e3?i.push(t.data.payload.payload[n].slice(0,2e3)+"...[truncated]"):i.push(t.data.payload.payload[n]);return t.data.payload.payload=i,e}return e}(n);if(this._updateWindowAndSessionIds(r),!this.isIdle||er(r)){if(er(r)){var s=r.data.payload;if(s){var o=s.lastActivityTimestamp,a=s.threshold;r.timestamp=o+a}}var l=null===(t=this.instance.config.session_recording.compress_events)||void 0===t||t?function(e){if(yi(e)<1024)return e;try{if(e.type===Si.FullSnapshot)return ie(ie({},e),{},{data:Zn(e.data),cv:"2024-10"});if(e.type===Si.IncrementalSnapshot&&e.data.source===Ei.Mutation)return ie(ie({},e),{},{cv:"2024-10",data:ie(ie({},e.data),{},{texts:Zn(e.data.texts),attributes:Zn(e.data.attributes),removes:Zn(e.data.removes),adds:Zn(e.data.adds)})});if(e.type===Si.IncrementalSnapshot&&e.data.source===Ei.StyleSheetRule)return ie(ie({},e),{},{cv:"2024-10",data:ie(ie({},e.data),{},{adds:Zn(e.data.adds),removes:Zn(e.data.removes)})})}catch(e){Yn.error("could not compress event - will use uncompressed event",e)}return e}(r):r,u={$snapshot_bytes:yi(l),$snapshot_data:l,$session_id:this.sessionId,$window_id:this.windowId};"disabled"!==this.status?this._captureSnapshotBuffered(u):this.clearBuffer()}}}}}_pageViewFallBack(){if(!this.instance.config.capture_pageview&&e){var t=this._maskUrl(e.location.href);this._lastHref!==t&&(this._tryAddCustomEvent("$url_changed",{href:t}),this._lastHref=t)}}_processQueuedEvents(){if(this.queuedRRWebEvents.length){var e=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],e.forEach((e=>{Date.now()-e.enqueuedAt<=2e3&&this._tryRRWebMethod(e)}))}}_maskUrl(e){var t=this.instance.config.session_recording;if(t.maskNetworkRequestFn){var i,n={url:e};return null===(i=n=t.maskNetworkRequestFn(n))||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);var e=this.minimumDuration,t=this.sessionDuration,i=G(t)&&t>=0,n=G(e)&&i&&t<e;if("buffering"===this.status||n)return this.flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3),this.buffer;this.buffer.data.length>0&&wi(this.buffer).forEach((e=>{this._captureSnapshot({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId,$lib:"web",$lib_version:_.LIB_VERSION})}));return this.clearBuffer()}_captureSnapshotBuffered(e){var t,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})}_checkUrlTriggerConditions(){if(void 0!==e&&e.location.href){var t=e.location.href,i="paused"===this.status,n=tr(t,this._urlBlocklist);n&&!i?this._pauseRecording():!n&&i&&this._resumeRecording(),tr(t,this._urlTriggers)&&this._activateTrigger("url")}}_activateTrigger(e){var t,i;"trigger_pending"===this.triggerStatus&&(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({["url"===e?Ee:ke]:this.sessionId}),this._flushBuffer(),this._reportStarted(e+"_trigger_matched"))}_pauseRecording(){var e,t;"paused"!==this.status&&(this._urlBlocked=!0,null==o||null===(e=o.body)||void 0===e||null===(t=e.classList)||void 0===t||t.add("ph-no-capture"),clearInterval(this._fullSnapshotTimer),setTimeout((()=>{this._flushBuffer()}),100),Yn.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){var e,t;"paused"===this.status&&(this._urlBlocked=!1,null==o||null===(e=o.body)||void 0===e||null===(t=e.classList)||void 0===t||t.remove("ph-no-capture"),this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),Yn.info("recording resumed"))}_addEventTriggerListener(){0!==this._eventTriggers.length&&W(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",(e=>{try{this._eventTriggers.includes(e.event)&&this._activateTrigger("event")}catch(e){Yn.error("Could not activate event trigger",e)}})))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null===(e=this.instance.persistence)||void 0===e||e.register({[Se]:!0}),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e)}_reportStarted(e,t){this.instance.register_for_session({$session_recording_start_reason:e}),Yn.info(e.replace("_"," "),t),b(["recording_initialized","session_id_changed"],e)||this._tryAddCustomEvent(e,t)}}var nr=Q("[Decide]");class rr{constructor(e){this.instance=e}_loadRemoteConfigJs(e){var t,i,n;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.loadExternalDependency?null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"remote-config",(()=>e(h._POSTHOG_CONFIG))):(nr.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(e){this.instance._send_request({method:"GET",url:this.instance.requestRouter.endpointFor("assets","/array/".concat(this.instance.config.token,"/config")),callback:t=>{e(t.json)}})}load(){if(this.instance.config.__preview_remote_config)return h._POSTHOG_CONFIG?(nr.info("Using preloaded remote config",h._POSTHOG_CONFIG),void this.onRemoteConfig(h._POSTHOG_CONFIG)):void(this.instance.config.advanced_disable_decide?nr.warn("Remote config is disabled. Falling back to local config."):this._loadRemoteConfigJs((e=>{if(!e)return nr.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this.onRemoteConfig(e)}));this.onRemoteConfig(e)})))}onRemoteConfig(e){e?(this.instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this.instance.featureFlags.ensureFlagsLoaded()):nr.error("Failed to fetch remote config from PostHog.")}}var sr,or=null!=e&&e.location?bt(e.location.hash,"__posthog")||bt(location.hash,"state"):null,ar="_postHogToolbarParams";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"}(sr||(sr={}));class lr{constructor(e){this.instance=e}setToolbarState(e){h.ph_toolbar_state=e}getToolbarState(){var e;return null!==(e=h.ph_toolbar_state)&&void 0!==e?e:sr.UNINITIALIZED}maybeLoadToolbar(){var t,i,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if(!e||!o)return!1;n=null!==(t=n)&&void 0!==t?t:e.location,s=null!==(i=s)&&void 0!==i?i:e.history;try{if(!r){try{e.localStorage.setItem("test","test"),e.localStorage.removeItem("test")}catch(e){return!1}r=null==e?void 0:e.localStorage}var a,l=or||bt(n.hash,"__posthog")||bt(n.hash,"state"),u=l?w((()=>JSON.parse(atob(decodeURIComponent(l)))))||w((()=>JSON.parse(decodeURIComponent(l)))):null;return u&&"ph_authorize"===u.action?((a=u).source="url",a&&Object.keys(a).length>0&&(u.desiredHash?n.hash=u.desiredHash:s?s.replaceState(s.state,"",n.pathname+n.search):n.hash="")):((a=JSON.parse(r.getItem(ar)||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch(e){return!1}}_callLoadToolbar(e){(h.ph_load_toolbar||h.ph_load_editor)(e,this.instance)}loadToolbar(t){var i=!(null==o||!o.getElementById(qe));if(!e||i)return!1;var n="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=ie(ie({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(e.localStorage.setItem(ar,JSON.stringify(ie(ie({},r),{},{source:void 0}))),this.getToolbarState()===sr.LOADED)this._callLoadToolbar(r);else if(this.getToolbarState()===sr.UNINITIALIZED){var s,a;this.setToolbarState(sr.LOADING),null===(s=h.__PosthogExtensions__)||void 0===s||null===(a=s.loadExternalDependency)||void 0===a||a.call(s,this.instance,"toolbar",(e=>{if(e)return K.error("[Toolbar] Failed to load",e),void this.setToolbarState(sr.UNINITIALIZED);this.setToolbarState(sr.LOADED),this._callLoadToolbar(r)})),C(e,"turbolinks:load",(()=>{this.setToolbarState(sr.UNINITIALIZED),this.loadToolbar(r)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(){var 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 ur{constructor(e){ne(this,"isPaused",!0),ne(this,"queue",[]),ne(this,"flushTimeoutMs",3e3),this.sendRequest=e}enqueue(e){this.queue.push(e),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var e=this.queue.length>0?this.formatQueue():{},t=Object.values(e),i=[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))];i.map((e=>{this.sendRequest(ie(ie({},e),{},{transport:"sendBeacon"}))}))}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var e=this;this.isPaused||(this.flushTimeout=setTimeout((()=>{if(this.clearFlushTimeout(),this.queue.length>0){var t=this.formatQueue(),i=function(i){var n=t[i],r=(new Date).getTime();n.data&&D(n.data)&&f(n.data,(e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp})),e.sendRequest(n)};for(var n in t)i(n)}}),this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){var e={};return f(this.queue,(t=>{var i,n=t,r=(n?n.batchKey:null)||n.url;H(e[r])&&(e[r]=ie(ie({},n),{},{data:[]})),null===(i=e[r].data)||void 0===i||i.push(n.data)})),this.queue=[],e}}var cr=!!u||!!l,dr="text/plain",hr=(e,t)=>{var[i,n]=e.split("?"),r=ie({},t);null==n||n.split("&").forEach((e=>{var[t]=e.split("=");delete r[t]}));var s=ft(r);return s=s?(n?n+"&":"")+s:n,"".concat(i,"?").concat(s)},_r=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),pr=e=>{var{data:t,compression:i}=e;if(t){if(i===R.GZipJS){var n=Gn(Vn(_r(t)),{mtime:0}),r=new Blob([n],{type:dr});return{contentType:dr,body:r,estimatedSize:r.size}}if(i===R.Base64){var s=function(e){var t,i,n,r,s,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,u="",c=[];if(!e)return e;e=I(e);do{t=(s=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=s>>12&63,n=s>>6&63,r=63&s,c[l++]=o.charAt(t)+o.charAt(i)+o.charAt(n)+o.charAt(r)}while(a<e.length);switch(u=c.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u}(_r(t)),o=(e=>"data="+encodeURIComponent("string"==typeof e?e:_r(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=_r(t);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},vr=[];u&&vr.push({transport:"XHR",method:e=>{var t,i=new u;i.open(e.method||"GET",e.url,!0);var{contentType:n,body:r}=null!==(t=pr(e))&&void 0!==t?t:{};f(e.headers,(function(e,t){i.setRequestHeader(t,e)})),n&&i.setRequestHeader("Content-Type",n),e.timeout&&(i.timeout=e.timeout),i.withCredentials=!0,i.onreadystatechange=()=>{if(4===i.readyState){var t,n={statusCode:i.status,text:i.responseText};if(200===i.status)try{n.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,n)}},i.send(r)}}),l&&vr.push({transport:"fetch",method:e=>{var t,i,{contentType:n,body:r,estimatedSize:s}=null!==(t=pr(e))&&void 0!==t?t:{},o=new Headers;f(e.headers,(function(e,t){o.append(t,e)})),n&&o.append("Content-Type",n);var a=e.url,u=null;if(c){var d=new c;u={signal:d.signal,timeout:setTimeout((()=>d.abort()),e.timeout)}}l(a,ie({method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(s||0)<52428.8,body:r,signal:null===(i=u)||void 0===i?void 0:i.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var n,r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){K.error(e)}null===(n=e.callback)||void 0===n||n.call(e,r)})))).catch((t=>{var i;K.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,text:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),null!=s&&s.sendBeacon&&vr.push({transport:"sendBeacon",method:e=>{var t=hr(e.url,{beacon:"1"});try{var i,{contentType:n,body:r}=null!==(i=pr(e))&&void 0!==i?i:{},o="string"==typeof r?new Blob([r],{type:n}):r;s.sendBeacon(t,o)}catch(e){}}});var gr=["retriesPerformedSoFar"];class fr{constructor(t){ne(this,"isPolling",!1),ne(this,"pollIntervalMs",3e3),ne(this,"queue",[]),this.instance=t,this.queue=[],this.areWeOnline=!0,!H(e)&&"onLine"in e.navigator&&(this.areWeOnline=e.navigator.onLine,e.addEventListener("online",(()=>{this.areWeOnline=!0,this.flush()})),e.addEventListener("offline",(()=>{this.areWeOnline=!1})))}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=re(e,gr);G(t)&&t>0&&(i.url=hr(i.url,{retry_count:t})),this.instance._send_request(ie(ie({},i),{},{callback:e=>{var n;200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this.enqueue(ie({retriesPerformedSoFar:t},i)):null===(n=i.callback)||void 0===n||n.call(i,e)}}))}enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,n=Math.min(18e5,t),r=(Math.random()-.5)*(n-i);return Math.ceil(n+r)}(t),n=Date.now()+i;this.queue.push({retryAt:n,requestOptions:e});var r="Enqueued failed request for retry in ".concat(i);navigator.onLine||(r+=" (Browser is offline)"),K.warn(r),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout((()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()}),this.pollIntervalMs)}flush(){var e=Date.now(),t=[],i=this.queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this.queue=t,i.length>0)for(var{requestOptions:n}of i)this.retriableRequest(n)}unload(){for(var{requestOptions:e}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(ie(ie({},e),{},{transport:"sendBeacon"}))}catch(e){K.error(e)}this.queue=[]}}var mr,br=Q("[SessionId]");class yr{constructor(e,t,i){var n;if(ne(this,"_sessionIdChangedHandlers",[]),!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");this.config=e.config,this.persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Ze,this._windowIdGenerator=i||Ze;var r=this.config.persistence_name||this.config.token,s=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*ln(s,60,36e3,"session_idle_timeout_seconds",1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var o=_t.parse(this._window_id_storage_key),a=_t.parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:_t.remove(this._window_id_storage_key),_t.set(this._primary_window_exists_storage_key,!0)}if(null!==(n=this.config.bootstrap)&&void 0!==n&&n.sessionID)try{var l=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,(new Date).getTime(),l)}catch(e){br.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return H(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&&_t.is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&_t.set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?_t.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({[we]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this.persistence.props[we];return D(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){null==e||e.addEventListener("beforeunload",(()=>{this._canUseSessionStorage()&&_t.remove(this._primary_window_exists_storage_key)}))}checkAndGetSessionAndWindowId(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||(new Date).getTime(),[i,n,r]=this._getSessionId(),s=this._getWindowId(),o=G(r)&&r>0&&Math.abs(t-r)>864e5,a=!1,l=!n,u=!e&&Math.abs(t-i)>this.sessionTimeoutMs;l||u||o?(n=this._sessionIdGenerator(),s=this._windowIdGenerator(),br.info("new session ID generated",{sessionId:n,windowId:s,changeReason:{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:o}}),r=t,a=!0):s||(s=this._windowIdGenerator(),a=!0);var c=0===i||!e||o?t:i,d=0===r?(new Date).getTime():r;return this._setWindowId(s),this._setSessionId(n,c,d),a&&this._sessionIdChangedHandlers.forEach((e=>e(n,s,a?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:o}:void 0))),{sessionId:n,windowId:s,sessionStartTimestamp:d,changeReason:a?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:o}:void 0,lastActivityTimestamp:i}}}!function(e){e.US="us",e.EU="eu",e.CUSTOM="custom"}(mr||(mr={}));var wr="i.posthog.com";class Sr{constructor(e){ne(this,"_regionCache",{}),this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e,t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(".".concat(wr),".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]=mr.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=mr.EU:this._regionCache[this.apiHost]=mr.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t&&(t="/"===t[0]?t:"/".concat(t)),"ui"===e)return this.uiHost+t;if(this.region===mr.CUSTOM)return this.apiHost+t;var i=wr+t;switch(e){case"assets":return"https://".concat(this.region,"-assets.").concat(i);case"api":return"https://".concat(this.region,".").concat(i)}}}var Er="posthog-js";function kr(e){var{organization:t,projectId:i,prefix:n,severityAllowList:r=["error"]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s=>{var o,a,l,u,c;if(!("*"===r||r.includes(s.level))||!e.__loaded)return s;s.tags||(s.tags={});var d=e.requestRouter.endpointFor("ui","/project/".concat(e.config.token,"/person/").concat(e.get_distinct_id()));s.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(s.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var h=(null===(o=s.exception)||void 0===o?void 0:o.values)||[];h.map((e=>{e.stacktrace&&(e.stacktrace.type="raw")}));var _={$exception_message:(null===(a=h[0])||void 0===a?void 0:a.value)||s.message,$exception_type:null===(l=h[0])||void 0===l?void 0:l.type,$exception_personURL:d,$exception_level:s.level,$exception_list:h,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:(null===(u=h[0])||void 0===u?void 0:u.value)||s.message,$sentry_exception_type:null===(c=h[0])||void 0===c?void 0:c.type,$sentry_tags:s.tags};return t&&i&&(_.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+s.event_id),e.exceptions.sendExceptionEvent(_),s}}class xr{constructor(e,t,i,n,r){this.name=Er,this.setupOnce=function(s){s(kr(e,{organization:t,projectId:i,prefix:n,severityAllowList:r}))}}}var Ir,Cr,Pr,Rr=Q("[SegmentIntegration]");function Fr(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var n=i=>{var n=()=>i.anonymousId()||Ze();e.config.get_device_id=n,i.id()&&(e.register({distinct_id:i.id(),$device_id:n()}),e.persistence.set_property($e,"identified")),t()},r=i.user();"then"in r&&N(r.then)?r.then((e=>n(e))):n(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||Rr.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{var n;if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Rr.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Rr.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e._calculate_event_properties(i,null!==(n=t.event.properties)&&void 0!==n?n:{},new Date);return t.event.properties=Object.assign({},r,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 Tr{constructor(e){this._instance=e}doPageView(t){var i,n=this._previousPageViewProperties(t);return this._currentPath=null!==(i=null==e?void 0:e.location.pathname)&&void 0!==i?i:"",this._instance.scrollManager.resetContext(),this._prevPageviewTimestamp=t,n}doPageLeave(e){return this._previousPageViewProperties(e)}_previousPageViewProperties(e){var t=this._currentPath,i=this._prevPageviewTimestamp,n=this._instance.scrollManager.getContext();if(!i)return{};var r={};if(n){var{maxScrollHeight:s,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=n;if(!(H(s)||H(o)||H(a)||H(l)||H(u)||H(c)))s=Math.ceil(s),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),r={$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:s<=1?1:ln(o/s,0,1),$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:s<=1?1:ln(a/s,0,1),$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:l<=1?1:ln(u/l,0,1),$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:l<=1?1:ln(c/l,0,1)}}return t&&(r.$prev_pageview_pathname=t),i&&(r.$prev_pageview_duration=(e.getTime()-i.getTime())/1e3),r}}!function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(Ir||(Ir={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(Cr||(Cr={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(Pr||(Pr={}));class $r{constructor(){ne(this,"events",{}),this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this.events[e]||[])i(t);for(var n of this.events["*"]||[])n(e,t)}}class Or{constructor(e){ne(this,"_debugEventEmitter",new $r),ne(this,"checkStep",((e,t)=>this.checkStepEvent(e,t)&&this.checkStepUrl(e,t)&&this.checkStepElement(e,t))),ne(this,"checkStepEvent",((e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event))),this.instance=e,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var e;if(!H(null===(e=this.instance)||void 0===e?void 0:e._addCaptureHook)){var t;null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!H(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 n,r=new Set;e.forEach((e=>{var t;null===(t=e.steps)||void 0===t||t.forEach((e=>{null!=e&&e.selector&&r.add(null==e?void 0:e.selector)}))})),null===(n=this.instance)||void 0===n||n.autocapture.setElementSelectors(r)}}on(e,t){var i;null!=t&&0!=e.length&&(this.actionEvents.has(e)||this.actionEvents.has(null==t?void 0:t.event))&&this.actionRegistry&&(null===(i=this.actionRegistry)||void 0===i?void 0:i.size)>0&&this.actionRegistry.forEach((e=>{this.checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this.checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}checkStepUrl(e,t){if(null!=t&&t.url){var i,n=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!n||"string"!=typeof n)return!1;if(!Or.matchString(n,null==t?void 0:t.url,(null==t?void 0:t.url_matching)||"contains"))return!1}return!0}static matchString(t,i,n){switch(n){case"regex":return!!e&&gt(t,i);case"exact":return i===t;case"contains":var r=Or.escapeStringRegexp(i).replace(/_/g,".").replace(/%/g,".*");return gt(t,r);default:return!1}}static escapeStringRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}checkStepElement(e,t){if((null!=t&&t.href||null!=t&&t.tag_name||null!=t&&t.text)&&!this.getElementsList(e).some((e=>!(null!=t&&t.href&&!Or.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&&!Or.matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!Or.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,n=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(!n)return!1;if(!n.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 Lr{constructor(e){this.instance=e,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(e){var t;H(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)||(this.setupEventBasedSurveys(e),this.setupActionBasedSurveys(e))}setupActionBasedSurveys(e){var t=e.filter((e=>{var t,i,n,r;return(null===(t=e.conditions)||void 0===t?void 0:t.actions)&&(null===(i=e.conditions)||void 0===i||null===(n=i.actions)||void 0===n||null===(r=n.values)||void 0===r?void 0:r.length)>0}));if(0!==t.length){if(null==this.actionMatcher){this.actionMatcher=new Or(this.instance),this.actionMatcher.init();this.actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,n,r,s,o,a,l,u,c;e.conditions&&null!==(t=e.conditions)&&void 0!==t&&t.actions&&null!==(i=e.conditions)&&void 0!==i&&null!==(n=i.actions)&&void 0!==n&&n.values&&(null===(r=e.conditions)||void 0===r||null===(s=r.actions)||void 0===s||null===(o=s.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===(u=l.actions)||void 0===u||null===(c=u.values)||void 0===c||c.forEach((t=>{if(t&&t.name){var i=this.actionToSurveys.get(t.name);i&&i.push(e.id),this.actionToSurveys.set(t.name,i||[e.id])}})))}))}}setupEventBasedSurveys(e){var t;if(0!==e.filter((e=>{var t,i,n,r;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(n=i.events)||void 0===n||null===(r=n.values)||void 0===r?void 0:r.length)>0})).length){null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t,i,n;null===(t=e.conditions)||void 0===t||null===(i=t.events)||void 0===i||null===(n=i.values)||void 0===n||n.forEach((t=>{if(t&&t.name){var i=this.eventToSurveys.get(t.name);i&&i.push(e.id),this.eventToSurveys.set(t.name,i||[e.id])}}))}))}}onEvent(e,t){var i,n,r=(null===(i=this.instance)||void 0===i||null===(n=i.persistence)||void 0===n?void 0:n.props[Fe])||[];if(Lr.SURVEY_SHOWN_EVENT_NAME==e&&t&&r.length>0){var s,o=null==t||null===(s=t.properties)||void 0===s?void 0:s.$survey_id;if(o){var a=r.indexOf(o);a>=0&&(r.splice(a,1),this._updateActivatedSurveys(r))}}else this.eventToSurveys.has(e)&&this._updateActivatedSurveys(r.concat(this.eventToSurveys.get(e)||[]))}onAction(e){var t,i,n=(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i?void 0:i.props[Fe])||[];this.actionToSurveys.has(e)&&this._updateActivatedSurveys(n.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({[Fe]:[...new Set(e)]})}getSurveys(){var e,t,i=null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t?void 0:t.props[Fe];return i||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}ne(Lr,"SURVEY_SHOWN_EVENT_NAME","survey shown");var Mr,Ar,Dr,Nr,qr,Br,Hr,Ur,zr={},jr=[],Wr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Gr=Array.isArray;function Vr(e,t){for(var i in t)e[i]=t[i];return e}function Jr(e){var t=e.parentNode;t&&t.removeChild(e)}function Yr(e,t,i,n,r){var s={type:e,props:t,key:i,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++Dr:r,__i:-1,__u:0};return null==r&&null!=Ar.vnode&&Ar.vnode(s),s}function Xr(e){return e.children}function Kr(e,t){this.props=e,this.context=t}function Qr(e,t){if(null==t)return e.__?Qr(e.__,e.__i+1):null;for(var i;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e)return i.__e;return"function"==typeof e.type?Qr(e):null}function Zr(e){var t,i;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e){e.__e=e.__c.base=i.__e;break}return Zr(e)}}function es(e){(!e.__d&&(e.__d=!0)&&Nr.push(e)&&!ts.__r++||qr!==Ar.debounceRendering)&&((qr=Ar.debounceRendering)||Br)(ts)}function ts(){var e,t,i,n,r,s,o,a,l;for(Nr.sort(Hr);e=Nr.shift();)e.__d&&(t=Nr.length,n=void 0,s=(r=(i=e).__v).__e,a=[],l=[],(o=i.__P)&&((n=Vr({},r)).__v=r.__v+1,Ar.vnode&&Ar.vnode(n),cs(o,n,r,i.__n,void 0!==o.ownerSVGElement,32&r.__u?[s]:null,a,null==s?Qr(r):s,!!(32&r.__u),l),n.__.__k[n.__i]=n,ds(a,n,l),n.__e!=s&&Zr(n)),Nr.length>t&&Nr.sort(Hr));ts.__r=0}function is(e,t,i,n,r,s,o,a,l,u,c){var d,h,_,p,v,g=n&&n.__k||jr,f=t.length;for(i.__d=l,ns(i,t,g),l=i.__d,d=0;d<f;d++)null!=(_=i.__k[d])&&"boolean"!=typeof _&&"function"!=typeof _&&(h=-1===_.__i?zr:g[_.__i]||zr,_.__i=d,cs(e,_,h,r,s,o,a,l,u,c),p=_.__e,_.ref&&h.ref!=_.ref&&(h.ref&&_s(h.ref,null,_),c.push(_.ref,_.__c||p,_)),null==v&&null!=p&&(v=p),65536&_.__u||h.__k===_.__k?l=rs(_,l,e):"function"==typeof _.type&&void 0!==_.__d?l=_.__d:p&&(l=p.nextSibling),_.__d=void 0,_.__u&=-196609);i.__d=l,i.__e=v}function ns(e,t,i){var n,r,s,o,a,l=t.length,u=i.length,c=u,d=0;for(e.__k=[],n=0;n<l;n++)null!=(r=e.__k[n]=null==(r=t[n])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?Yr(null,r,null,null,r):Gr(r)?Yr(Xr,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?Yr(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=e,r.__b=e.__b+1,a=ss(r,i,o=n+d,c),r.__i=a,s=null,-1!==a&&(c--,(s=i[a])&&(s.__u|=131072)),null==s||null===s.__v?(-1==a&&d--,"function"!=typeof r.type&&(r.__u|=65536)):a!==o&&(a===o+1?d++:a>o?c>l-o?d+=a-o:d--:d=a<o&&a==o-1?a-o:0,a!==n+d&&(r.__u|=65536))):(s=i[n])&&null==s.key&&s.__e&&(s.__e==e.__d&&(e.__d=Qr(s)),ps(s,s,!1),i[n]=null,c--);if(c)for(n=0;n<u;n++)null!=(s=i[n])&&0==(131072&s.__u)&&(s.__e==e.__d&&(e.__d=Qr(s)),ps(s,s))}function rs(e,t,i){var n,r;if("function"==typeof e.type){for(n=e.__k,r=0;n&&r<n.length;r++)n[r]&&(n[r].__=e,t=rs(n[r],t,i));return t}return e.__e!=t&&(i.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function ss(e,t,i,n){var r=e.key,s=e.type,o=i-1,a=i+1,l=t[i];if(null===l||l&&r==l.key&&s===l.type)return i;if(n>(null!=l&&0==(131072&l.__u)?1:0))for(;o>=0||a<t.length;){if(o>=0){if((l=t[o])&&0==(131072&l.__u)&&r==l.key&&s===l.type)return o;o--}if(a<t.length){if((l=t[a])&&0==(131072&l.__u)&&r==l.key&&s===l.type)return a;a++}}return-1}function os(e,t,i){"-"===t[0]?e.setProperty(t,null==i?"":i):e[t]=null==i?"":"number"!=typeof i||Wr.test(t)?i:i+"px"}function as(e,t,i,n,r){var s;e:if("style"===t)if("string"==typeof i)e.style.cssText=i;else{if("string"==typeof n&&(e.style.cssText=n=""),n)for(t in n)i&&t in i||os(e.style,t,"");if(i)for(t in i)n&&i[t]===n[t]||os(e.style,t,i[t])}else if("o"===t[0]&&"n"===t[1])s=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=i,i?n?i.u=n.u:(i.u=Date.now(),e.addEventListener(t,s?us:ls,s)):e.removeEventListener(t,s?us:ls,s);else{if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null==i||!1===i&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,i))}}function ls(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Ar.event?Ar.event(e):e)}function us(e){return this.l[e.type+!0](Ar.event?Ar.event(e):e)}function cs(e,t,i,n,r,s,o,a,l,u){var c,d,h,_,p,v,g,f,m,b,y,w,S,E,k,x=t.type;if(void 0!==t.constructor)return null;128&i.__u&&(l=!!(32&i.__u),s=[a=t.__e=i.__e]),(c=Ar.__b)&&c(t);e:if("function"==typeof x)try{if(f=t.props,m=(c=x.contextType)&&n[c.__c],b=c?m?m.props.value:c.__:n,i.__c?g=(d=t.__c=i.__c).__=d.__E:("prototype"in x&&x.prototype.render?t.__c=d=new x(f,b):(t.__c=d=new Kr(f,b),d.constructor=x,d.render=vs),m&&m.sub(d),d.props=f,d.state||(d.state={}),d.context=b,d.__n=n,h=d.__d=!0,d.__h=[],d._sb=[]),null==d.__s&&(d.__s=d.state),null!=x.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=Vr({},d.__s)),Vr(d.__s,x.getDerivedStateFromProps(f,d.__s))),_=d.props,p=d.state,d.__v=t,h)null==x.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(null==x.getDerivedStateFromProps&&f!==_&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(f,b),!d.__e&&(null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(f,d.__s,b)||t.__v===i.__v)){for(t.__v!==i.__v&&(d.props=f,d.state=d.__s,d.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.forEach((function(e){e&&(e.__=t)})),y=0;y<d._sb.length;y++)d.__h.push(d._sb[y]);d._sb=[],d.__h.length&&o.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(f,d.__s,b),null!=d.componentDidUpdate&&d.__h.push((function(){d.componentDidUpdate(_,p,v)}))}if(d.context=b,d.props=f,d.__P=e,d.__e=!1,w=Ar.__r,S=0,"prototype"in x&&x.prototype.render){for(d.state=d.__s,d.__d=!1,w&&w(t),c=d.render(d.props,d.state,d.context),E=0;E<d._sb.length;E++)d.__h.push(d._sb[E]);d._sb=[]}else do{d.__d=!1,w&&w(t),c=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(n=Vr(Vr({},n),d.getChildContext())),h||null==d.getSnapshotBeforeUpdate||(v=d.getSnapshotBeforeUpdate(_,p)),is(e,Gr(k=null!=c&&c.type===Xr&&null==c.key?c.props.children:c)?k:[k],t,i,n,r,s,o,a,l,u),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),g&&(d.__E=d.__=null)}catch(e){t.__v=null,l||null!=s?(t.__e=a,t.__u|=l?160:32,s[s.indexOf(a)]=null):(t.__e=i.__e,t.__k=i.__k),Ar.__e(e,t,i)}else null==s&&t.__v===i.__v?(t.__k=i.__k,t.__e=i.__e):t.__e=hs(i.__e,t,i,n,r,s,o,l,u);(c=Ar.diffed)&&c(t)}function ds(e,t,i){t.__d=void 0;for(var n=0;n<i.length;n++)_s(i[n],i[++n],i[++n]);Ar.__c&&Ar.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){Ar.__e(e,t.__v)}}))}function hs(e,t,i,n,r,s,o,a,l){var u,c,d,h,_,p,v,g=i.props,f=t.props,m=t.type;if("svg"===m&&(r=!0),null!=s)for(u=0;u<s.length;u++)if((_=s[u])&&"setAttribute"in _==!!m&&(m?_.localName===m:3===_.nodeType)){e=_,s[u]=null;break}if(null==e){if(null===m)return document.createTextNode(f);e=r?document.createElementNS("http://www.w3.org/2000/svg",m):document.createElement(m,f.is&&f),s=null,a=!1}if(null===m)g===f||a&&e.data===f||(e.data=f);else{if(s=s&&Mr.call(e.childNodes),g=i.props||zr,!a&&null!=s)for(g={},u=0;u<e.attributes.length;u++)g[(_=e.attributes[u]).name]=_.value;for(u in g)_=g[u],"children"==u||("dangerouslySetInnerHTML"==u?d=_:"key"===u||u in f||as(e,u,null,_,r));for(u in f)_=f[u],"children"==u?h=_:"dangerouslySetInnerHTML"==u?c=_:"value"==u?p=_:"checked"==u?v=_:"key"===u||a&&"function"!=typeof _||g[u]===_||as(e,u,_,g[u],r);if(c)a||d&&(c.__html===d.__html||c.__html===e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(d&&(e.innerHTML=""),is(e,Gr(h)?h:[h],t,i,n,r&&"foreignObject"!==m,s,o,s?s[0]:i.__k&&Qr(i,0),a,l),null!=s)for(u=s.length;u--;)null!=s[u]&&Jr(s[u]);a||(u="value",void 0!==p&&(p!==e[u]||"progress"===m&&!p||"option"===m&&p!==g[u])&&as(e,u,p,g[u],!1),u="checked",void 0!==v&&v!==e[u]&&as(e,u,v,g[u],!1))}return e}function _s(e,t,i){try{"function"==typeof e?e(t):e.current=t}catch(e){Ar.__e(e,i)}}function ps(e,t,i){var n,r;if(Ar.unmount&&Ar.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||_s(n,null,t)),null!=(n=e.__c)){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(e){Ar.__e(e,t)}n.base=n.__P=null,e.__c=void 0}if(n=e.__k)for(r=0;r<n.length;r++)n[r]&&ps(n[r],t,i||"function"!=typeof e.type);i||null==e.__e||Jr(e.__e),e.__=e.__e=e.__d=void 0}function vs(e,t,i){return this.constructor(e,i)}Mr=jr.slice,Ar={__e:function(e,t,i,n){for(var r,s,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((s=r.constructor)&&null!=s.getDerivedStateFromError&&(r.setState(s.getDerivedStateFromError(e)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,n||{}),o=r.__d),o)return r.__E=r}catch(t){e=t}throw e}},Dr=0,Kr.prototype.setState=function(e,t){var i;i=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=Vr({},this.state),"function"==typeof e&&(e=e(Vr({},i),this.props)),e&&Vr(i,e),null!=e&&this.__v&&(t&&this._sb.push(t),es(this))},Kr.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),es(this))},Kr.prototype.render=Xr,Nr=[],Br="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Hr=function(e,t){return e.__v.__b-t.__v.__b},ts.__r=0,Ur=0;!function(e,t){var i={__c:t="__cC"+Ur++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var i,n;return this.getChildContext||(i=[],(n={})[t]=this,this.getChildContext=function(){return n},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&i.some((function(e){e.__e=!0,es(e)}))},this.sub=function(e){i.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){i.splice(i.indexOf(e),1),t&&t.call(e)}}),e.children}};i.Provider.__=i.Consumer.contextType=i}({isPreviewMode:!1,previewPageIndex:0,handleCloseSurveyPopup:()=>{},isPopup:!0});var gs=Q("[Surveys]"),fs={icontains:t=>!!e&&e.location.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:t=>!!e&&-1===e.location.href.toLowerCase().indexOf(t.toLowerCase()),regex:t=>!!e&&gt(e.location.href,t),not_regex:t=>!!e&&!gt(e.location.href,t),exact:t=>(null==e?void 0:e.location.href)===t,is_not:t=>(null==e?void 0:e.location.href)!==t};class ms{constructor(e){this.instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){this._decideServerResponse=!!e.surveys,this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var e=(()=>{for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);null!=i&&i.startsWith("seenSurvey_")&&e.push(i)}return e})();e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){var e,t,i,n=null==h||null===(e=h.__PosthogExtensions__)||void 0===e?void 0:e.generateSurveys;this.instance.config.disable_surveys||!this._decideServerResponse||n||(null==this._surveyEventReceiver&&(this._surveyEventReceiver=new Lr(this.instance)),null===(t=h.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"surveys",(e=>{var t,i;if(e)return gs.error("Could not load surveys script",e);this._surveyManager=null===(t=h.__PosthogExtensions__)||void 0===t||null===(i=t.generateSurveys)||void 0===i?void 0:i.call(t,this.instance)})))}getSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.instance.config.disable_surveys)return e([]);null==this._surveyEventReceiver&&(this._surveyEventReceiver=new Lr(this.instance));var i=this.instance.get_property(Re);if(i&&!t)return e(i);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",transport:"XHR",callback:t=>{var i;if(200!==t.statusCode||!t.json)return e([]);var n,r=t.json.surveys||[],s=r.filter((e=>{var t,i,n,r,s,o,a,l,u,c,d,h;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(n=i.events)||void 0===n?void 0:n.values)&&(null===(r=e.conditions)||void 0===r||null===(s=r.events)||void 0===s||null===(o=s.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===(u=l.actions)||void 0===u?void 0:u.values)&&(null===(c=e.conditions)||void 0===c||null===(d=c.actions)||void 0===d||null===(h=d.values)||void 0===h?void 0:h.length)>0}));s.length>0&&(null===(n=this._surveyEventReceiver)||void 0===n||n.register(s));return null===(i=this.instance.persistence)||void 0===i||i.register({[Re]:r}),e(r)}})}getActiveMatchingSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.getSurveys((t=>{var i,n=t.filter((e=>!(!e.start_date||e.end_date))).filter((e=>{var t,i,n,r;if(!e.conditions)return!0;var s=null===(t=e.conditions)||void 0===t||!t.url||fs[null!==(i=null===(n=e.conditions)||void 0===n?void 0:n.urlMatchType)&&void 0!==i?i:"icontains"](e.conditions.url),a=null===(r=e.conditions)||void 0===r||!r.selector||(null==o?void 0:o.querySelector(e.conditions.selector));return s&&a})),r=null===(i=this._surveyEventReceiver)||void 0===i?void 0:i.getSurveys(),s=n.filter((e=>{var t,i,n,s,o,a,l,u,c,d,h;if(!(e.linked_flag_key||e.targeting_flag_key||e.internal_targeting_flag_key||null!==(t=e.feature_flag_keys)&&void 0!==t&&t.length))return!0;var _=!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),v=(null===(i=e.conditions)||void 0===i?void 0:i.events)&&(null===(n=e.conditions)||void 0===n||null===(s=n.events)||void 0===s?void 0:s.values)&&(null===(o=e.conditions)||void 0===o||null===(a=o.events)||void 0===a?void 0:a.values.length)>0,g=(null===(l=e.conditions)||void 0===l?void 0:l.actions)&&(null===(u=e.conditions)||void 0===u||null===(c=u.actions)||void 0===c?void 0:c.values)&&(null===(d=e.conditions)||void 0===d||null===(h=d.actions)||void 0===h?void 0:h.values.length)>0,f=!v&&!g||(null==r?void 0:r.includes(e.id)),m=this._canActivateRepeatedly(e),b=!(e.internal_targeting_flag_key&&!m)||this.instance.featureFlags.isFeatureEnabled(e.internal_targeting_flag_key),y=this.checkFlags(e);return _&&p&&b&&f&&y}));return e(s)}),t)}checkFlags(e){var t;return null===(t=e.feature_flag_keys)||void 0===t||!t.length||e.feature_flag_keys.every((e=>{var{key:t,value:i}=e;return!t||!i||this.instance.featureFlags.isFeatureEnabled(i)}))}getNextSurveyStep(e,t,i){var n,r=e.questions[t],s=t+1;if(null===(n=r.branching)||void 0===n||!n.type)return t===e.questions.length-1?Pr.End:s;if(r.branching.type===Pr.End)return Pr.End;if(r.branching.type===Pr.SpecificQuestion){if(Number.isInteger(r.branching.index))return r.branching.index}else if(r.branching.type===Pr.ResponseBased){if(r.type===Cr.SingleChoice){var o,a,l=r.choices.indexOf("".concat(i));if(null!==(o=r.branching)&&void 0!==o&&null!==(a=o.responseValues)&&void 0!==a&&a.hasOwnProperty(l)){var u=r.branching.responseValues[l];return Number.isInteger(u)?u:u===Pr.End?Pr.End:s}}else if(r.type===Cr.Rating){var c,d;if("number"!=typeof i||!Number.isInteger(i))throw new Error("The response type must be an integer");var h=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,r.scale);if(null!==(c=r.branching)&&void 0!==c&&null!==(d=c.responseValues)&&void 0!==d&&d.hasOwnProperty(h)){var _=r.branching.responseValues[h];return Number.isInteger(_)?_:_===Pr.End?Pr.End:s}}return s}return gs.warn("Falling back to next question index due to unexpected branching type"),s}_canActivateRepeatedly(e){var t;return W(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.canActivateRepeatedly)?(gs.warn("init was not called"),!1):h.__PosthogExtensions__.canActivateRepeatedly(e)}canRenderSurvey(e){W(this._surveyManager)?gs.warn("init was not called"):this.getSurveys((t=>{var i=t.filter((t=>t.id===e))[0];this._surveyManager.canRenderSurvey(i)}))}renderSurvey(e,t){W(this._surveyManager)?gs.warn("init was not called"):this.getSurveys((i=>{var n=i.filter((t=>t.id===e))[0];this._surveyManager.renderSurvey(n,null==o?void 0:o.querySelector(t))}))}}var bs=Q("[RateLimiter]");class ys{constructor(e){var t,i;ne(this,"serverLimits",{}),ne(this,"lastEventRateLimited",!1),ne(this,"checkForLimiting",(e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{bs.info("".concat(e||"events"," is quota limited.")),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void bs.warn('could not rate limit - continuing. Error: "'.concat(null==e?void 0:e.message,'"'),{text:t})}})),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,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=(new Date).getTime(),s=null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_property(Le))&&void 0!==e?e:{tokens:this.captureEventsBurstLimit,last:r};s.tokens+=(r-s.last)/1e3*this.captureEventsPerSecond,s.last=r,s.tokens>this.captureEventsBurstLimit&&(s.tokens=this.captureEventsBurstLimit);var o=s.tokens<1;return o||n||(s.tokens=Math.max(0,s.tokens-1)),!o||this.lastEventRateLimited||n||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,null===(i=this.instance.persistence)||void 0===i||i.set_property(Le,s),{isRateLimited:o,remainingTokens:s.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var ws=()=>ie({initialPathName:(null==a?void 0:a.pathname)||"",referringDomain:fi.referringDomain()},fi.campaignParams());class Ss{constructor(e,t,i){ne(this,"_onSessionIdCallback",(e=>{var t=this._getStoredProps();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator()};this._persistence.register({[Oe]:i})}})),this._sessionIdManager=e,this._persistence=t,this._sessionSourceParamGenerator=i||ws,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStoredProps(){return this._persistence.props[Oe]}getSessionProps(){var e,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}:{}}}var Es=["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;"],ks=function(e,t){if(!e)return!1;var i=e.toLowerCase();return Es.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},xs=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&ks(i,t))return!0;try{var n=null==e?void 0:e.userAgentData;if(null!=n&&n.brands&&n.brands.some((e=>ks(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};class Is{constructor(){this.clicks=[]}isRageClick(e,t,i){var n=this.clicks[this.clicks.length-1];if(n&&Math.abs(e-n.x)+Math.abs(t-n.y)<30&&i-n.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:i}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var Cs=Q("[Dead Clicks]"),Ps=()=>!0,Rs=e=>{var t,i=!(null===(t=e.instance.persistence)||void 0===t||!t.get_property(he)),n=e.instance.config.capture_dead_clicks;return V(n)?n:i};class Fs{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[he]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript((()=>{this.start()}))}loadScript(e){var t,i,n;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.initDeadClicksAutocapture&&e(),null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"dead-clicks-autocapture",(t=>{t?Cs.error("failed to load script",t):e()}))}start(){var e;if(o){if(!this._lazyLoadedDeadClicksAutocapture&&null!==(e=h.__PosthogExtensions__)&&void 0!==e&&e.initDeadClicksAutocapture){var t=q(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=h.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(o),Cs.info("starting...")}}else Cs.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Cs.info("stopping..."))}}var Ts=Q("[Heatmaps]");class $s{constructor(t){var i;ne(this,"rageclicks",new Is),ne(this,"_enabledServerSide",!1),ne(this,"_initialized",!1),ne(this,"_flushInterval",null),this.instance=t,this._enabledServerSide=!(null===(i=this.instance.persistence)||void 0===i||!i.props[ue]),null==e||e.addEventListener("beforeunload",(()=>{this.flush()}))}get flushIntervalMilliseconds(){var e=5e3;return q(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return H(this.instance.config.capture_heatmaps)?H(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;Ts.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),null===(t=this.deadClicksCapture)||void 0===t||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ue]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.buffer;return this.buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_setupListeners(){e&&o&&(C(o,"click",(t=>this._onClick(t||(null==e?void 0:e.event))),!1,!0),C(o,"mousemove",(t=>this._onMouseMove(t||(null==e?void 0:e.event))),!1,!0),this.deadClicksCapture=new Fs(this.instance,Ps,this._onDeadClick.bind(this)),this.deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(t,i){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=function(t,i,n){for(var r=t;r&&xi(r)&&!Ii(r,"body");){if(r===n)return!1;if(b(i,null==e?void 0:e.getComputedStyle(r).position))return!0;r=Ai(r)}return!1}(Li(t),["fixed","sticky"],s);return{x:t.clientX+(o?0:r),y:t.clientY+(o?0:n),target_fixed:o,type:i}}_onClick(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"click";if(!ki(e.target)){var n=this._getProperties(e,i);null!==(t=this.rageclicks)&&void 0!==t&&t.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(ie(ie({},n),{},{type:"rageclick"})),this._capture(n)}}_onMouseMove(e){ki(e.target)||(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(t){if(e){var i=e.location.href;this.buffer=this.buffer||{},this.buffer[i]||(this.buffer[i]=[]),this.buffer[i].push(t)}}flush(){this.buffer&&!B(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Os{constructor(e){ne(this,"_updateScrollData",(()=>{var e,t,i,n;this.context||(this.context={});var r=this.scrollElement(),s=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=s+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this.context.lastScrollY=Math.ceil(s),this.context.maxScrollY=Math.max(s,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!==(n=this.context.maxContentHeight)&&void 0!==n?n:0)})),this.instance=e}getContext(){return this.context}resetContext(){var e=this.context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){null==e||e.addEventListener("scroll",this._updateScrollData,!0),null==e||e.addEventListener("scrollend",this._updateScrollData,!0),null==e||e.addEventListener("resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return null==e?void 0:e.document.documentElement;var t=D(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(var i of t){var n=null==e?void 0:e.document.querySelector(i);if(n)return n}}scrollY(){if(this.instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollTop||0}return e&&(e.scrollY||e.pageYOffset||e.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollLeft||0}return e&&(e.scrollX||e.pageXOffset||e.document.documentElement.scrollLeft)||0}}var Ls=Q("[AutoCapture]");function Ms(e,t){return t.length>e?t.slice(0,e)+"...":t}function As(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!xi(t));return t}function Ds(e,t,i,n){var r=e.tagName.toLowerCase(),s={tag_name:r};Mi.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?s.$el_text=Ms(1024,Vi(e)):s.$el_text=Ms(1024,Oi(e)));var o=Ti(e);o.length>0&&(s.classes=o.filter((function(e){return""!==e}))),f(e.attributes,(function(i){var r;if((!qi(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==n||!n.includes(i.name))&&!t&&Gi(i.value)&&(r=i.name,!U(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Ri(o).join(" ")),s["attr__"+i.name]=Ms(1024,o)}}));for(var a=1,l=1,u=e;u=As(u);)a++,u.tagName===e.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function Ns(t,i){for(var n,r,{e:s,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=i,c=[t],d=t;d.parentNode&&!Ii(d,"body");)Pi(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var h,_=[],p={},v=!1,g=!1;if(f(c,(e=>{var t=Ni(e);"a"===e.tagName.toLowerCase()&&(v=e.getAttribute("href"),v=t&&v&&Gi(v)&&v),b(Ti(e),"ph-no-capture")&&(g=!0),_.push(Ds(e,o,a,l));var i=function(e){if(!Ni(e))return{};var t={};return f(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),n=e.value;i&&n&&Gi(n)&&(t[i]=n)}})),t}(e);m(p,i)})),g)return{props:{},explicitNoCapture:g};if(a||("a"===t.tagName.toLowerCase()||"button"===t.tagName.toLowerCase()?_[0].$el_text=Vi(t):_[0].$el_text=Oi(t)),v){var y,w;_[0].attr__href=v;var S=null===(y=vt(v))||void 0===y?void 0:y.host,E=null==e||null===(w=e.location)||void 0===w?void 0:w.host;S&&E&&S!==E&&(h=v)}return{props:m({$event_type:s.type,$ce_version:1},u?{}:{$elements:_},{$elements_chain:Yi(_)},null!==(n=_[0])&&void 0!==n&&n.$el_text?{$el_text:null===(r=_[0])||void 0===r?void 0:r.$el_text}:{},h&&"click"===s.type?{$external_click_url:h}:{},p)}}class qs{constructor(e){ne(this,"_initialized",!1),ne(this,"_isDisabledServerSide",null),ne(this,"rageclicks",new Is),ne(this,"_elementsChainAsString",!1),this.instance=e,this._elementSelectors=null}get config(){var e,t,i=q(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()){if(e&&o){var t=t=>{t=t||(null==e?void 0:e.event);try{this._captureEvent(t)}catch(e){Ls.error("Failed to capture event",e)}},i=t=>{t=t||(null==e?void 0:e.event),this._captureEvent(t,F)};C(o,"submit",t,!1,!0),C(o,"change",t,!1,!0),C(o,"click",t,!1,!0),this.config.capture_copied_text&&(C(o,"copy",i,!1,!0),C(o,"cut",i,!1,!0))}}else Ls.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[le]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null===(t=this._elementSelectors)||void 0===t||t.forEach((t=>{var n=null==o?void 0:o.querySelectorAll(t);null==n||n.forEach((n=>{e===n&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null===(e=this.instance.persistence)||void 0===e?void 0:e.props[le],n=this._isDisabledServerSide;if(j(n)&&!V(i)&&!this.instance.config.advanced_disable_decide)return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$autocapture";if(this.isEnabled){var n,r=Li(t);if(Ci(r)&&(r=r.parentNode||null),"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent)this.instance.config.rageclick&&null!==(n=this.rageclicks)&&void 0!==n&&n.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&this._captureEvent(t,"$rageclick");var s=i===F;if(r&&Di(r,t,this.config,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=Ns(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(a)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(o.$element_selectors=l),i===F){var u,c=$i(null==e||null===(u=e.getSelection())||void 0===u?void 0:u.toString()),d=t.type||"clipboard";if(!c)return!1;o.$selected_content=c,o.$copy_type=d}return this.instance.capture(i,o),!0}}}isBrowserSupported(){return N(null==o?void 0:o.querySelectorAll)}}var Bs=Q("[TracingHeaders]");class Hs{constructor(e){ne(this,"_restoreXHRPatch",void 0),ne(this,"_restoreFetchPatch",void 0),ne(this,"_startCapturing",(()=>{var e,t,i,n;H(this._restoreXHRPatch)&&(null===(e=h.__PosthogExtensions__)||void 0===e||null===(t=e.tracingHeadersPatchFns)||void 0===t||t._patchXHR(this.instance.sessionManager));H(this._restoreFetchPatch)&&(null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.tracingHeadersPatchFns)||void 0===n||n._patchFetch(this.instance.sessionManager))})),this.instance=e}_loadScript(e){var t,i,n;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.tracingHeadersPatchFns&&e(),null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"tracing-headers",(t=>{if(t)return Bs.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var Us;!function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"}(Us||(Us={}));class zs{constructor(e){this.instance=e}get config(){return this.instance.config}get consent(){return this.getDnt()?Us.DENIED:this.storedConsent}isOptedOut(){return this.consent===Us.DENIED||this.consent===Us.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(){var{token:e,opt_out_capturing_cookie_prefix:t}=this.instance.config;return(t||"__ph_opt_in_out_")+e}get storedConsent(){var e=this.storage.get(this.storageKey);return"1"===e?Us.GRANTED:"0"===e?Us.DENIED:Us.PENDING}get storage(){if(!this._storage){var e=this.config.opt_out_capturing_persistence_type;this._storage="localStorage"===e?at:st;var t="localStorage"===e?st:at;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&&!!P([null==s?void 0:s.doNotTrack,null==s?void 0:s.msDoNotTrack,h.doNotTrack],(e=>b([!0,1,"1","yes"],e)))}}var js=Q("[ExceptionAutocapture]");class Ws{constructor(t){var i;ne(this,"originalOnUnhandledRejectionHandler",void 0),ne(this,"startCapturing",(()=>{var t,i,n,r;if(e&&this.isEnabled&&!this.hasHandlers&&!this.isCapturing){var s=null===(t=h.__PosthogExtensions__)||void 0===t||null===(i=t.errorWrappingFunctions)||void 0===i?void 0:i.wrapOnError,o=null===(n=h.__PosthogExtensions__)||void 0===n||null===(r=n.errorWrappingFunctions)||void 0===r?void 0:r.wrapUnhandledRejection;if(s&&o)try{this.unwrapOnError=s(this.captureException.bind(this)),this.unwrapUnhandledRejection=o(this.captureException.bind(this))}catch(e){js.error("failed to start",e),this.stopCapturing()}else js.error("failed to load error wrapping functions - cannot start")}})),this.instance=t,this.remoteEnabled=!(null===(i=this.instance.persistence)||void 0===i||!i.props[ce]),this.startIfEnabled()}get isEnabled(){var e;return null!==(e=this.remoteEnabled)&&void 0!==e&&e}get isCapturing(){var t;return!(null==e||null===(t=e.onerror)||void 0===t||!t.__POSTHOG_INSTRUMENTED__)}get hasHandlers(){return this.originalOnUnhandledRejectionHandler||this.unwrapOnError}startIfEnabled(){this.isEnabled&&!this.isCapturing&&(js.info("enabled, starting..."),this.loadScript(this.startCapturing))}loadScript(e){var t,i;this.hasHandlers&&e(),null===(t=h.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"exception-autocapture",(t=>{if(t)return js.error("failed to load script",t);e()}))}stopCapturing(){var e,t;null===(e=this.unwrapOnError)||void 0===e||e.call(this),null===(t=this.unwrapUnhandledRejection)||void 0===t||t.call(this)}onRemoteConfig(e){var t=e.autocaptureExceptions;this.remoteEnabled=!!t||!1,this.instance.persistence&&this.instance.persistence.register({[ce]:this.remoteEnabled}),this.startIfEnabled()}captureException(e){var t=this.instance.requestRouter.endpointFor("ui");e.$exception_personURL="".concat(t,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(e)}}var Gs=Q("[Web Vitals]"),Vs=9e5;class Js{constructor(e){var t;ne(this,"_enabledServerSide",!1),ne(this,"_initialized",!1),ne(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),ne(this,"_flushToCapture",(()=>{clearTimeout(this._delayedFlushTimer),0!==this.buffer.metrics.length&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce(((e,t)=>ie(ie({},e),{},{["$web_vitals_".concat(t.name,"_event")]:ie({},t),["$web_vitals_".concat(t.name,"_value")]:t.value})),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})})),ne(this,"_addToBuffer",(e=>{var t,i=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);if(H(i))Gs.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this._currentURL();if(!H(n))if(W(null==e?void 0:e.name)||W(null==e?void 0:e.value))Gs.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)Gs.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this.buffer.url!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),H(this.buffer.url)&&(this.buffer.url=n),this.buffer.firstMetricTimestamp=H(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(ie(ie({},e),{},{$current_url:n,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}})),ne(this,"_startCapturing",(()=>{var e,t,i,n,r=h.__PosthogExtensions__;H(r)||H(r.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:n}=r.postHogWebVitalsCallbacks),e&&t&&i&&n?(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&&n(this._addToBuffer.bind(this)),this._initialized=!0):Gs.error("web vitals callbacks not loaded - not starting")})),this.instance=e,this._enabledServerSide=!(null===(t=this.instance.persistence)||void 0===t||!t.props[de]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=q(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 H(i)?(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[_e])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(q(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=q(this.instance.config.capture_performance)&&G(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Vs;return 0<e&&e<=6e4?Vs:e}get isEnabled(){var e=q(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return V(e)?e:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Gs.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(e){var t=q(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=q(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[de]:t}),this.instance.persistence.register({[_e]:i})),this._enabledServerSide=t,this.startIfEnabled()}loadScript(e){var t,i,n;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.postHogWebVitalsCallbacks&&e(),null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"web-vitals",(t=>{t?Gs.error("failed to load script",t):e()}))}_currentURL(){var t=e?e.location.href:void 0;return t||Gs.error("Could not determine current URL"),t}}var Ys={icontains:(t,i)=>!!e&&i.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>!!e&&-1===i.href.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>!!e&&gt(i.href,t),not_regex:(t,i)=>!!e&&!gt(i.href,t),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class Xs{constructor(e){var t=this;ne(this,"getWebExperimentsAndEvaluateDisplayLogic",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t.getWebExperiments((e=>{Xs.logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)Xs.logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null===(i=t._flagToExperiments)||void 0===i||i.set(e.feature_flag_key,e);var n=t.instance.getFeatureFlag(e.feature_flag_key);U(n)&&e.variants[n]&&t.applyTransforms(e.name,n,e.variants[n].transforms)}else if(e.variants)for(var r in e.variants){var s=e.variants[r];Xs.matchesTestVariant(s)&&t.applyTransforms(e.name,r,s.transforms)}}))}),e)})),this.instance=e,this.instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())Xs.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(W(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Xs.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,n=this.instance.getFeatureFlag(e),r=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);n&&null!=r&&r.variants[n]&&this.applyTransforms(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var e=Xs.getWindowLocation();if(null!=e&&e.search){var t=mt(null==e?void 0:e.search,"__experiment_id"),i=mt(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Xs.logInfo("previewing web experiments ".concat(t," && ").concat(i)),this.getWebExperiments((e=>{this.showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this.instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.instance.config.disable_web_experiments&&!i)return e([]);var n=this.instance.get_property("$web_experiments");if(n&&!t)return e(n);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/web_experiments/?token=".concat(this.instance.config.token)),method:"GET",transport:"XHR",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}showPreviewWebExperiment(e,t,i){var n=i.filter((t=>t.id===e));n&&n.length>0&&(Xs.logInfo("Previewing web experiment [".concat(n[0].name,"] with variant [").concat(t,"]")),this.applyTransforms(n[0].name,t,n[0].variants[t].transforms,!0))}static matchesTestVariant(e){return!W(e.conditions)&&(Xs.matchUrlConditions(e)&&Xs.matchUTMConditions(e))}static matchUrlConditions(e){var t;if(W(e.conditions)||W(null===(t=e.conditions)||void 0===t?void 0:t.url))return!0;var i,n,r,s=Xs.getWindowLocation();return!!s&&(null===(i=e.conditions)||void 0===i||!i.url||Ys[null!==(n=null===(r=e.conditions)||void 0===r?void 0:r.urlMatchType)&&void 0!==n?n:"icontains"](e.conditions.url,s))}static getWindowLocation(){return null==e?void 0:e.location}static matchUTMConditions(e){var t;if(W(e.conditions)||W(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;var i=fi.campaignParams();if(i.utm_source){var n,r,s,o,a,l,u,c,d,h,_,p,v,g,f,m,b=null===(n=e.conditions)||void 0===n||null===(r=n.utm)||void 0===r||!r.utm_campaign||(null===(s=e.conditions)||void 0===s||null===(o=s.utm)||void 0===o?void 0:o.utm_campaign)==i.utm_campaign,y=null===(a=e.conditions)||void 0===a||null===(l=a.utm)||void 0===l||!l.utm_source||(null===(u=e.conditions)||void 0===u||null===(c=u.utm)||void 0===c?void 0:c.utm_source)==i.utm_source,w=null===(d=e.conditions)||void 0===d||null===(h=d.utm)||void 0===h||!h.utm_medium||(null===(_=e.conditions)||void 0===_||null===(p=_.utm)||void 0===p?void 0:p.utm_medium)==i.utm_medium,S=null===(v=e.conditions)||void 0===v||null===(g=v.utm)||void 0===g||!g.utm_term||(null===(f=e.conditions)||void 0===f||null===(m=f.utm)||void 0===m?void 0:m.utm_term)==i.utm_term;return b&&w&&S&&y}return!1}static logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];K.info("[WebExperiments] ".concat(e),i)}applyTransforms(e,t,i,n){var r;this._is_bot()?Xs.logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var r;Xs.logInfo("applying transform of variant ".concat(t," for experiment ").concat(e," "),i);var s,o=0,a=null===(r=document)||void 0===r?void 0:r.querySelectorAll(i.selector);if(null==a||a.forEach((e=>{var 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:n,$web_experiment_document_url:null===(s=Xs.getWindowLocation())||void 0===s?void 0:s.href,$web_experiment_elements_modified:o})}})):(Xs.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:n,$web_experiment_variant:t,$web_experiment_document_url:null===(r=Xs.getWindowLocation())||void 0===r?void 0:r.href,$web_experiment_elements_modified:0}))}_is_bot(){return s&&this.instance?xs(s,this.instance.config.custom_blocked_useragents):void 0}}class Ks{constructor(e){this.instance=e}sendExceptionEvent(e){this.instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}}var Qs=["$set_once","$set"],Zs=Q("[SiteApps]");class eo{constructor(e){this.instance=e,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this.bufferedInvocations.push(i),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}init(){if(this.isEnabled){var e=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{e(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(e){var t,i,n,r,s,o,a;if(!e)throw new Error("Event payload is required");var l={},u=this.instance.get_property("$groups")||[],c=this.instance.get_property("$stored_group_properties")||{};for(var[d,h]of Object.entries(c))l[d]={id:u[d],type:d,properties:h};var{$set_once:_,$set:p}=e;return{event:ie(ie({},re(e,Qs)),{},{properties:ie(ie(ie({},e.properties),p?{$set:ie(ie({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),p)}:{}),_?{$set_once:ie(ie({},null!==(n=null===(r=e.properties)||void 0===r?void 0:r.$set_once)&&void 0!==n?n:{}),_)}:{}),elements_chain:null!==(s=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==s?s:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(e){var t={id:e.id,loaded:!1,errored:!1};this.apps[e.id]=t;var i=i=>{var n;for(var r of(this.apps[e.id].errored=!i,this.apps[e.id].loaded=!0,Zs.info("Site app with id ".concat(e.id," ").concat(i?"loaded":"errored")),i&&this.bufferedInvocations.length&&(Zs.info("Processing ".concat(this.bufferedInvocations.length," events for site app with id ").concat(e.id)),this.bufferedInvocations.forEach((e=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)}))),Object.values(this.apps)))if(!r.loaded)return;null===(n=this.stopBuffering)||void 0===n||n.call(this)};try{var{processEvent:n}=e.init({posthog:this.instance,callback:e=>{i(e)}});n&&(t.processEvent=n)}catch(t){Zs.error("Error while initializing PostHog app with config id ".concat(e.id),t),i(!1)}}onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{var n;null===(n=i.processEvent)||void 0===n||n.call(i,t)}catch(t){Zs.error("Error while processing event ".concat(e.event," for site app ").concat(i.id),t)}}}onRemoteConfig(e){var t,i,n=this;if(D(h._POSTHOG_JS_APPS)){if(!this.isEnabled)return void Zs.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');for(var r of h._POSTHOG_JS_APPS)this.setupSiteApp(r);var s;h._POSTHOG_JS_APPS.length?this.instance.on("eventCaptured",(e=>this.onCapturedEvent(e))):null===(s=this.stopBuffering)||void 0===s||s.call(this)}else if(null===(t=this.stopBuffering)||void 0===t||t.call(this),null!==(i=e.siteApps)&&void 0!==i&&i.length)if(this.isEnabled){var o=function(e,t){var i,r;h["__$$ph_site_app_".concat(e)]=n.instance,null===(i=h.__PosthogExtensions__)||void 0===i||null===(r=i.loadSiteApp)||void 0===r||r.call(i,n.instance,t,(t=>{if(t)return Zs.error("Error while initializing PostHog app with config id ".concat(e),t)}))};for(var{id:a,url:l}of e.siteApps)o(a,l)}else Zs.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var to={},io=()=>{},no="posthog",ro=!cr&&-1===(null==d?void 0:d.indexOf("MSIE"))&&-1===(null==d?void 0:d.indexOf("Mozilla")),so=()=>{var t,i,n;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:(i=null==o?void 0:o.location,n=null==i?void 0:i.hostname,!!U(n)&&"herokuapp.com"!==n.split(".").slice(-2).join(".")),persistence:"localStorage+cookie",persistence_name:"",loaded:io,store_google:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:a&&U(null==a?void 0:a.search)&&-1!==a.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==e||null===(t=e.location)||void 0===t?void 0:t.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=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;K.error(t)},get_device_id:e=>e,_onCapture:io,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",__add_tracing_headers:!1,before_send:void 0}},oo=e=>{var t={};H(e.process_person)||(t.person_profiles=e.process_person),H(e.xhr_headers)||(t.request_headers=e.xhr_headers),H(e.cookie_name)||(t.persistence_name=e.cookie_name),H(e.disable_cookie)||(t.disable_persistence=e.disable_cookie);var i=m({},t,e);return D(e.property_blacklist)&&(H(e.property_denylist)?i.property_denylist=e.property_blacklist:D(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:K.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class ao{constructor(){ne(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){K.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class lo{get decideEndpointWasHit(){return this.featureFlags.hasLoadedFlags}constructor(){ne(this,"webPerformance",new ao),ne(this,"version",_.LIB_VERSION),ne(this,"_internalEventEmitter",new $r),this.config=so(),this.SentryIntegration=xr,this.sentryIntegration=e=>function(e,t){var i=kr(e,t);return{name:Er,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this.featureFlags=new Ge(this),this.toolbar=new lr(this),this.scrollManager=new Os(this),this.pageViewManager=new Tr(this),this.surveys=new ms(this),this.experiments=new Xs(this),this.exceptions=new Ks(this),this.rateLimiter=new ys(this),this.requestRouter=new Sr(this),this.consent=new zs(this),this.people={set:(e,t,i)=>{var n=U(e)?{[e]:t}:e;this.setPersonProperties(n),null==i||i({})},set_once:(e,t,i)=>{var n=U(e)?{[e]:t}:e;this.setPersonProperties(void 0,n),null==i||i({})}},this.on("eventCaptured",(e=>K.info('send "'.concat(null==e?void 0:e.event,'"'),e)))}init(e,t,i){if(i&&i!==no){var n,r=null!==(n=to[i])&&void 0!==n?n:new lo;return r._init(e,t,i),to[i]=r,to[no][i]=r,r}return this._init(e,t,i)}_init(t){var i,n,r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(H(t)||z(t))return K.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 K.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],s.person_profiles&&(this._initialPersonProfilesConfig=s.person_profiles),this.set_config(m({},so(),oo(s),{name:o,token:t})),this.config.on_xhr_error&&K.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:R.GZipJS,this.persistence=new bi(this.config),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new bi(ie(ie({},this.config),{},{persistence:"sessionStorage"}));var a=ie({},this.persistence.props),l=ie({},this.sessionPersistence.props);if(this._requestQueue=new ur((e=>this._send_retriable_request(e))),this._retryQueue=new fr(this),this.__request_queue=[],this.sessionManager=new yr(this),this.sessionPropsManager=new Ss(this.sessionManager,this.persistence),new Hs(this).startIfEnabledOrStop(),this.siteApps=new eo(this),null===(i=this.siteApps)||void 0===i||i.init(),this.sessionRecording=new ir(this),this.sessionRecording.startIfEnabledOrStop(),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new qs(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new $s(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Js(this),this.exceptionObserver=new Ws(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Fs(this,Rs),this.deadClicksAutocapture.startIfEnabled(),_.DEBUG=_.DEBUG||this.config.debug,_.DEBUG&&K.info("Starting in debug mode",{this:this,config:s,thisC:ie({},this.config),p:a,s:l}),this._sync_opt_out_with_persistence(),void 0!==(null===(n=s.bootstrap)||void 0===n?void 0:n.distinctID)){var u,c,d=this.config.get_device_id(Ze()),h=null!==(u=s.bootstrap)&&void 0!==u&&u.isIdentifiedID?d:s.bootstrap.distinctID;this.persistence.set_property($e,null!==(c=s.bootstrap)&&void 0!==c&&c.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:s.bootstrap.distinctID,$device_id:h})}if(this._hasBootstrappedFeatureFlags()){var p,v,g=Object.keys((null===(p=s.bootstrap)||void 0===p?void 0:p.featureFlags)||{}).filter((e=>{var t,i;return!(null===(t=s.bootstrap)||void 0===t||null===(i=t.featureFlags)||void 0===i||!i[e])})).reduce(((e,t)=>{var i,n;return e[t]=(null===(i=s.bootstrap)||void 0===i||null===(n=i.featureFlags)||void 0===n?void 0:n[t])||!1,e}),{}),f=Object.keys((null===(v=s.bootstrap)||void 0===v?void 0:v.featureFlagPayloads)||{}).filter((e=>g[e])).reduce(((e,t)=>{var i,n,r,o;null!==(i=s.bootstrap)&&void 0!==i&&null!==(n=i.featureFlagPayloads)&&void 0!==n&&n[t]&&(e[t]=null===(r=s.bootstrap)||void 0===r||null===(o=r.featureFlagPayloads)||void 0===o?void 0:o[t]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:f})}if(!this.get_distinct_id()){var b=this.config.get_device_id(Ze());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property($e,"anonymous")}return null==e||null===(r=e.addEventListener)||void 0===r||r.call(e,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),this.toolbar.maybeLoadToolbar(),s.segment?Fr(this,(()=>this._loaded())):this._loaded(),N(this.config._onCapture)&&this.config._onCapture!==io&&(K.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this}_onRemoteConfig(e){var t,i,n,r,s,a,l,u,c;if(!o||!o.body)return K.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=b(e.supportedCompression,R.GZipJS)?R.GZipJS:b(e.supportedCompression,R.Base64)?R.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.siteApps)||void 0===i||i.onRemoteConfig(e),null===(n=this.sessionRecording)||void 0===n||n.onRemoteConfig(e),null===(r=this.autocapture)||void 0===r||r.onRemoteConfig(e),null===(s=this.heatmaps)||void 0===s||s.onRemoteConfig(e),null===(a=this.surveys)||void 0===a||a.onRemoteConfig(e),null===(l=this.webVitalsAutocapture)||void 0===l||l.onRemoteConfig(e),null===(u=this.exceptionObserver)||void 0===u||u.onRemoteConfig(e),null===(c=this.deadClicksAutocapture)||void 0===c||c.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){K.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{this.consent.isOptedIn()&&this._captureInitialPageview()}),1),new rr(this).load(),this.featureFlags.decide()}_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()||g(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(e){this.__loaded&&(ro?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=hr(e.url,{ip:this.config.ip?1:0}),e.headers=ie({},this.config.request_headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,i,n,r=ie({},e);r.timeout=r.timeout||6e4,r.url=hr(r.url,{_:(new Date).getTime().toString(),ver:_.LIB_VERSION,compression:r.compression});var s=null!==(t=r.transport)&&void 0!==t?t:"XHR",o=null!==(i=null===(n=P(vr,(e=>e.transport===s)))||void 0===n?void 0:n.method)&&void 0!==i?i:vr[0].method;if(!o)throw new Error("No available transport method");o(r)})(ie(ie({},e),{},{callback:t=>{var i,n,r;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null===(n=(r=this.config).on_request_error)||void 0===n||n.call(r,t));null===(i=e.callback)||void 0===i||i.call(e,t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],n=[],r=[];g(e,(e=>{e&&(t=e[0],D(t)?r.push(e):N(e)?e.call(this):D(e)&&"alias"===t?i.push(e):D(e)&&-1!==t.indexOf("capture")&&N(this[t])?r.push(e):n.push(e))}));var s=function(e,t){g(e,(function(e){if(D(e[0])){var i=t;f(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};s(i,this),s(n,this),s(r,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 n;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!H(e)&&U(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var r=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==r||!r.isRateLimited){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();var s=new Date,o=(null==i?void 0:i.timestamp)||s,a={uuid:Ze(),event:e,properties:this._calculate_event_properties(e,t||{},o)};r&&(a.properties.$lib_rate_limit_remaining_tokens=r.remainingTokens),(null==i?void 0:i.$set)&&(a.$set=null==i?void 0:i.$set);var l=this._calculate_set_once_properties(null==i?void 0:i.$set_once);l&&(a.$set_once=l),(a=x(a,null!=i&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=o,H(null==i?void 0:i.timestamp)||(a.properties.$event_time_override_provided=!0,a.properties.$event_time_override_system_time=s);var u=ie(ie({},a.properties.$set),a.$set);if(B(u)||this.setPersonPropertiesForFlags(u),!W(this.config.before_send)){var c=this._runBeforeSend(a);if(!c)return;a=c}this._internalEventEmitter.emit("eventCaptured",a);var d={method:"POST",url:null!==(n=null==i?void 0:i._url)&&void 0!==n?n: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(d):this._requestQueue.enqueue(d),a}K.critical("This capture call is ignored due to client rate limiting.")}}else K.error("No event name provided to posthog.capture")}else K.uninitializedWarning("posthog.capture")}_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;var n=this.persistence.remove_event_timer(e),r=ie({},t);if(r.token=this.config.token,"$snapshot"===e){var s=ie(ie({},this.persistence.properties()),this.sessionPersistence.properties());return r.distinct_id=s.distinct_id,(!U(r.distinct_id)&&!G(r.distinct_id)||z(r.distinct_id))&&K.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),r}var a=fi.properties();if(this.sessionManager){var{sessionId:l,windowId:u}=this.sessionManager.checkAndGetSessionAndWindowId();r.$session_id=l,r.$window_id=u}if(this.sessionRecording&&(r.$recording_status=this.sessionRecording.status),this.requestRouter.region===mr.CUSTOM&&(r.$lib_custom_api_host=this.config.api_host),this.sessionPropsManager&&this.config.__preview_send_client_session_params&&("$pageview"===e||"$pageleave"===e||"$autocapture"===e)){var c=this.sessionPropsManager.getSessionProps();r=m(r,c)}if(!this.config.disable_scroll_properties){var h={};"$pageview"===e?h=this.pageViewManager.doPageView(i):"$pageleave"===e&&(h=this.pageViewManager.doPageLeave(i)),r=m(r,h)}if("$pageview"===e&&o&&(r.title=o.title),!H(n)){var _=i.getTime()-n;r.$duration=parseFloat((_/1e3).toFixed(3))}d&&this.config.opt_out_useragent_filter&&(r.$browser_type=this._is_bot()?"bot":"browser"),(r=m({},a,this.persistence.properties(),this.sessionPersistence.properties(),r)).$is_identified=this._isIdentified(),D(this.config.property_denylist)?f(this.config.property_denylist,(function(e){delete r[e]})):K.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(r=p(r,e));var v=this._hasPersonProcessing();return r.$process_person_profile=v,v&&this._requirePersonProcessing("_calculate_event_properties"),r}_calculate_set_once_properties(e){if(!this.persistence||!this._hasPersonProcessing())return e;var t=m({},this.persistence.get_initial_props(),e||{}),i=this.config.sanitize_properties;return i&&(t=i(t,"$set_once")),B(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 n;null===(n=this.persistence)||void 0===n||n.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){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t)}getEarlyAccessFeatures(e){var 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){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e){var 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 K.uninitializedWarning("posthog.identify");if(G(e)&&(e=e.toString(),K.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e){if(["distinct_id","distinctid"].includes(e.toLowerCase()))K.critical('The string "'.concat(e,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var n=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var r=n;this.register_once({$had_persisted_distinct_id:!0,$device_id:r},"")}e!==n&&e!==this.get_property(oe)&&(this.unregister(oe),this.register({distinct_id:e}));var s="anonymous"===(this.persistence.get_property($e)||"anonymous");e!==n&&s?(this.persistence.set_property($e,"identified"),this.setPersonPropertiesForFlags(t||{},!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n},{$set:t||{},$set_once:i||{}}),this.featureFlags.setAnonymousDistinctId(n)):(t||i)&&this.setPersonProperties(t,i),e!==n&&(this.reloadFeatureFlags(),this.unregister(Te))}}else K.error("Unique user id has not been set in posthog.identify")}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){if(this._requirePersonProcessing("posthog.group")){var n=this.getGroups();n[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ie(ie({},n),{},{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),n[e]===t||i||this.reloadFeatureFlags()}}else K.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e){var 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,n,r,s;if(K.info("reset"),!this.__loaded)return K.uninitializedWarning("posthog.reset");var o=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===(n=this.surveys)||void 0===n||n.reset(),null===(r=this.persistence)||void 0===r||r.set_property($e,"anonymous"),null===(s=this.sessionManager)||void 0===s||s.resetSessionId();var a=this.config.get_device_id(Ze());this.register_once({distinct_id:a,$device_id:e?a:o},"")}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"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(t));if(null!=e&&e.withTimestamp&&i){var r,s=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return n;var o=Math.max(Math.floor(((new Date).getTime()-i)/1e3)-s,0);n+="?t=".concat(o)}return n}alias(e,t){return e===this.get_property(se)?(K.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(H(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(oe,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(K.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t,i,n,r,s=ie({},this.config);q(e)&&(m(this.config,oo(e)),null===(t=this.persistence)||void 0===t||t.update_config(this.config,s),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new bi(ie(ie({},this.config),{},{persistence:"sessionStorage"})),at.is_supported()&&"true"===at.get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(_.DEBUG=!0,K.info("set_config",{config:e,oldConfig:s,newConfig:ie({},this.config)})),null===(i=this.sessionRecording)||void 0===i||i.startIfEnabledOrStop(),null===(n=this.autocapture)||void 0===n||n.startIfEnabled(),null===(r=this.heatmaps)||void 0===r||r.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var n,r,s,o,a;if(null===(n=this.sessionManager)||void 0===n||n.checkAndGetSessionAndWindowId(),i.sampling)null===(r=this.sessionRecording)||void 0===r||r.overrideSampling();if(i.linked_flag)null===(s=this.sessionRecording)||void 0===s||s.overrideLinkedFlag();if(i.url_trigger)null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url");if(i.event_trigger)null===(a=this.sessionRecording)||void 0===a||a.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null===(e=this.sessionRecording)||void 0===e||!e.started)}captureException(e,t){var i,n=new Error("PostHog syntheticException"),r=N(null===(i=h.__PosthogExtensions__)||void 0===i?void 0:i.parseErrorAsProperties)?h.__PosthogExtensions__.parseErrorAsProperties([e.message,void 0,void 0,void 0,e],{syntheticException:n}):ie({$exception_level:"error",$exception_list:[{type:e.name,value:e.message,mechanism:{handled:!0,synthetic:!1}}]},t);this.exceptions.sendExceptionEvent(r)}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,t=null!==(e=this.config.name)&&void 0!==e?e:no;return t!==no&&(t=no+"."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property($e))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property($e))}_hasPersonProcessing(){var e,t,i,n;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&B(this.getGroups())&&(null===(e=this.persistence)||void 0===e||null===(t=e.props)||void 0===t||!t[oe])&&(null===(i=this.persistence)||void 0===i||null===(n=i.props)||void 0===n||!n[Ne]))}_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?(K.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Ne,!0),!0)}_sync_opt_out_with_persistence(){var e,t,i,n,r=this.consent.isOptedOut(),s=this.config.opt_out_persistence_by_default,o=this.config.disable_persistence||r&&!!s;(null===(e=this.persistence)||void 0===e?void 0:e.disabled)!==o&&(null===(i=this.persistence)||void 0===i||i.set_disabled(o));(null===(t=this.sessionPersistence)||void 0===t?void 0:t.disabled)!==o&&(null===(n=this.sessionPersistence)||void 0===n||n.set_disabled(o))}opt_in_capturing(e){var t;(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),H(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?xs(s,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){o&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:o.title},{send_instantly:!0}))}debug(t){!1===t?(null==e||e.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==e||e.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}))}_runBeforeSend(e){if(W(this.config.before_send))return e;var t=D(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var n of t){if(i=n(i),W(i)){var r="Event '".concat(e.event,"' was rejected in beforeSend function");return Y(e.event)?K.warn("".concat(r,". This can cause unexpected behavior.")):K.info(r),null}i.properties&&!B(i.properties)||K.warn("Event '".concat(e.event,"' has no properties after beforeSend function, this is likely an error."))}return i}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=S(e.prototype[t[i]])}(lo,["identify"]);var uo,co=(uo=to[no]=new lo,function(){function t(){t.done||(t.done=!0,ro=!1,f(to,(function(e){e._dom_loaded()})))}null!=o&&o.addEventListener&&("complete"===o.readyState?t():o.addEventListener("DOMContentLoaded",t,!1)),e&&C(e,"load",t,!0)}(),uo);export{F as COPY_AUTOCAPTURE_EVENT,R as Compression,lo as PostHog,Pr as SurveyQuestionBranchingType,Cr as SurveyQuestionType,Ir as SurveyType,co as default,T as knownUnsafeEditableEvent,co as posthog,$ as severityLevels};
1
+ var e="undefined"!=typeof window?window:void 0,t="undefined"!=typeof globalThis?globalThis:e,i=Array.prototype,n=i.forEach,r=i.indexOf,s=null==t?void 0:t.navigator,o=null==t?void 0:t.document,a=null==t?void 0:t.location,l=null==t?void 0:t.fetch,u=null!=t&&t.XMLHttpRequest&&"withCredentials"in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,c=null==t?void 0:t.AbortController,d=null==s?void 0:s.userAgent,h=null!=e?e:{},_={DEBUG:!1,LIB_VERSION:"1.200.2"},p={},v=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function g(e,t,i){if(D(e))if(n&&e.forEach===n)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var r=0,s=e.length;r<s;r++)if(r in e&&t.call(i,e[r],r)===p)return}function f(e,t,i){if(!W(e)){if(D(e))return g(e,t,i);if(J(e)){for(var n of e.entries())if(t.call(i,n[1],n[0])===p)return}else for(var r in e)if(M.call(e,r)&&t.call(i,e[r],r)===p)return}}var m=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return g(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e};function b(e,t){return-1!==e.indexOf(t)}function y(e){for(var t=Object.keys(e),i=t.length,n=new Array(i);i--;)n[i]=[t[i],e[t[i]]];return n}var w=function(e){try{return e()}catch(e){return}},S=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return e.apply(this,i)}catch(e){K.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),K.critical(e)}}},E=function(e){var t={};return f(e,(function(e,i){U(e)&&e.length>0&&(t[i]=e)})),t},k=function(e){return e.replace(/^\$/,"")};function x(e,t){return i=e,n=e=>U(e)&&!j(t)?e.slice(0,t):e,r=new Set,function e(t,i){return t!==Object(t)?n?n(t,i):t:r.has(t)?void 0:(r.add(t),D(t)?(s=[],g(t,(t=>{s.push(e(t))}))):(s={},f(t,((t,i)=>{r.has(t)||(s[i]=e(t,i))}))),s);var s}(i);var i,n,r}var I=function(e){var t,i,n,r,s="";for(t=i=0,n=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,r=0;r<n;r++){var o=e.charCodeAt(r),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),j(a)||(i>t&&(s+=e.substring(t,i)),s+=a,t=i=r+1)}return i>t&&(s+=e.substring(t,e.length)),s},C=function(){function t(e){return e&&(e.preventDefault=t.preventDefault,e.stopPropagation=t.stopPropagation),e}return t.preventDefault=function(){this.returnValue=!1},t.stopPropagation=function(){this.cancelBubble=!0},function(i,n,r,s,o){if(i)if(i.addEventListener&&!s)i.addEventListener(n,r,!!o);else{var a="on"+n,l=i[a];i[a]=function(i,n,r){return function(s){if(s=s||t(null==e?void 0:e.event)){var o,a=!0;N(r)&&(o=r(s));var l=n.call(i,s);return!1!==o&&!1!==l||(a=!1),a}}}(i,r,l)}else K.error("No valid element provided to register_event")}}();function P(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}var R,F="$copy_autocapture",T=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(R||(R={}));var $=["fatal","error","warning","log","info","debug"],O=Array.isArray,L=Object.prototype,M=L.hasOwnProperty,A=L.toString,D=O||function(e){return"[object Array]"===A.call(e)},N=e=>"function"==typeof e,q=e=>e===Object(e)&&!D(e),B=e=>{if(q(e)){for(var t in e)if(M.call(e,t))return!1;return!0}return!1},H=e=>void 0===e,U=e=>"[object String]"==A.call(e),z=e=>U(e)&&0===e.trim().length,j=e=>null===e,W=e=>H(e)||j(e),G=e=>"[object Number]"==A.call(e),V=e=>"[object Boolean]"===A.call(e),J=e=>e instanceof FormData,Y=e=>b(T,e),X=t=>{var i={_log:function(i){if(e&&(_.DEBUG||h.POSTHOG_DEBUG)&&!H(e.console)&&e.console){for(var n=("__rrweb_original__"in e.console[i]?e.console[i].__rrweb_original__:e.console[i]),r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];n(t,...s)}},info:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];i._log("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];i._log("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];i._log("error",...t)},critical:function(){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];console.error(t,...i)},uninitializedWarning:e=>{i.error("You must initialize PostHog before calling ".concat(e))},createLogger:e=>X("".concat(t," ").concat(e))};return i},K=X("[PostHog.js]"),Q=K.createLogger,Z=Q("[ExternalScriptsLoader]"),ee=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return Z.warn("".concat(t," was requested but loading of external scripts is disabled.")),i("Loading of external scripts is disabled");var n=()=>{if(!o)return i("document not found");var e=o.createElement("script");e.type="text/javascript",e.crossOrigin="anonymous",e.src=t,e.onload=e=>i(void 0,e),e.onerror=e=>i(e);var n,r=o.querySelectorAll("body > script");r.length>0?null===(n=r[0].parentNode)||void 0===n||n.insertBefore(e,r[0]):o.body.appendChild(e)};null!=o&&o.body?n():null==o||o.addEventListener("DOMContentLoaded",n)};function te(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function ie(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?te(Object(i),!0).forEach((function(t){ne(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):te(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function ne(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function re(e,t){if(null==e)return{};var i,n,r=function(e,t){if(null==e)return{};var i,n,r={},s=Object.keys(e);for(n=0;n<s.length;n++)i=s[n],t.indexOf(i)>=0||(r[i]=e[i]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)i=s[n],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{var n="/static/".concat(t,".js")+"?v=".concat(e.version);if("remote-config"===t&&(n="/array/".concat(e.config.token,"/config.js")),"toolbar"===t){var r=3e5,s=Math.floor(Date.now()/r)*r;n="".concat(n,"&t=").concat(s)}var o=e.requestRouter.endpointFor("assets",n);ee(e,o,i)},h.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{var n=e.requestRouter.endpointFor("api",t);ee(e,n,i)};var se="$people_distinct_id",oe="__alias",ae="__timers",le="$autocapture_disabled_server_side",ue="$heatmaps_enabled_server_side",ce="$exception_capture_enabled_server_side",de="$web_vitals_enabled_server_side",he="$dead_clicks_enabled_server_side",_e="$web_vitals_allowed_metrics",pe="$session_recording_enabled_server_side",ve="$console_log_recording_enabled_server_side",ge="$session_recording_network_payload_capture",fe="$session_recording_canvas_recording",me="$replay_sample_rate",be="$replay_minimum_duration",ye="$replay_script_config",we="$sesid",Se="$session_is_sampled",Ee="$session_recording_url_trigger_activated_session",ke="$session_recording_event_trigger_activated_session",xe="$enabled_feature_flags",Ie="$early_access_features",Ce="$stored_person_properties",Pe="$stored_group_properties",Re="$surveys",Fe="$surveys_activated",Te="$flag_call_reported",$e="$user_state",Oe="$client_session_props",Le="$capture_rate_limit",Me="$initial_campaign_params",Ae="$initial_referrer_info",De="$initial_person_info",Ne="$epp",qe="__POSTHOG_TOOLBAR__",Be="$posthog_cklsh",He=[se,oe,"__cmpns",ae,pe,ue,we,xe,$e,Ie,Pe,Ce,Re,Te,Oe,Le,Me,Ae,Ne],Ue=Q("[FeatureFlags]"),ze="$active_feature_flags",je="$override_feature_flags",We="$feature_flag_payloads",Ge=e=>{var t={};for(var[i,n]of y(e||{}))n&&(t[i]=n);return t};class Ve{constructor(e){ne(this,"_override_warning",!1),ne(this,"_hasLoadedFlags",!1),ne(this,"_requestInFlight",!1),ne(this,"_reloadingDisabled",!1),ne(this,"_additionalReloadRequested",!1),ne(this,"_decideCalled",!1),ne(this,"_flagsLoadedFromRemote",!1),this.instance=e,this.featureFlagEventHandlers=[]}decide(){if(this.instance.config.__preview_remote_config)this._decideCalled=!0;else{var e=!this._reloadDebouncer&&(this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load);this._callDecideEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagVariants(){var e=this.instance.get_property(xe),t=this.instance.get_property(je);if(!t)return e||{};for(var i=m({},e),n=Object.keys(t),r=0;r<n.length;r++)i[n[r]]=t[n[r]];return this._override_warning||(Ue.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){return this.instance.get_property(We)||{}}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callDecideEndpoint()}),5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callDecideEndpoint(e){if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var t={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:this.instance.get_property(Ce),group_properties:this.instance.get_property(Pe)};(null!=e&&e.disableFlags||this.instance.config.advanced_disable_feature_flags)&&(t.disable_flags=!0),this._requestInFlight=!0,this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:t,compression:this.instance.config.disable_compression?void 0:R.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:e=>{var i,n,r=!0;(200===e.statusCode&&(this.$anon_distinct_id=void 0,r=!1),this._requestInFlight=!1,this._decideCalled)||(this._decideCalled=!0,this.instance._onRemoteConfig(null!==(n=e.json)&&void 0!==n?n:{}));t.disable_flags||(this._flagsLoadedFromRemote=!r,this.receivedFeatureFlags(null!==(i=e.json)&&void 0!==i?i:{},r),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callDecideEndpoint()))}})}}getFeatureFlag(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i,n,r,s,o,a=this.getFlagVariants()[e],l="".concat(a),u=this.instance.get_property(Te)||{};if(t.send_event||!("send_event"in t))if(!(e in u)||!u[e].includes(l))D(u[e])?u[e].push(l):u[e]=[l],null===(i=this.instance.persistence)||void 0===i||i.register({[Te]:u}),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:a,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_bootstrapped_response:(null===(n=this.instance.config.bootstrap)||void 0===n||null===(r=n.featureFlags)||void 0===r?void 0:r[e])||null,$feature_flag_bootstrapped_payload:(null===(s=this.instance.config.bootstrap)||void 0===s||null===(o=s.featureFlagPayloads)||void 0===o?void 0:o[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote});return a}Ue.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}isFeatureEnabled(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,t);Ue.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time.")}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this.instance.persistence){this._hasLoadedFlags=!0;var i=this.getFlagVariants(),n=this.getFlagPayloads();!function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=e.featureFlags,s=e.featureFlagPayloads;if(r)if(D(r)){var o={};if(r)for(var a=0;a<r.length;a++)o[r[a]]=!0;t&&t.register({[ze]:r,[xe]:o})}else{var l=r,u=s;e.errorsWhileComputingFlags&&(l=ie(ie({},i),l),u=ie(ie({},n),u)),t&&t.register({[ze]:Object.keys(Ge(l)),[xe]:l||{},[We]:u||{}})}}(e,this.instance.persistence,i,n),this._fireFeatureFlagsCallbacks(t)}}override(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.instance.__loaded||!this.instance.persistence)return Ue.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=t,!1===e)this.instance.persistence.unregister(je);else if(D(e)){for(var i={},n=0;n<e.length;n++)i[e[n]]=!0;this.instance.persistence.register({[je]:i})}else this.instance.persistence.register({[je]:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t){var i,n={["$feature_enrollment/".concat(e)]:t};this.instance.capture("$feature_enrollment_update",{$feature_flag:e,$feature_enrollment:t,$set:n}),this.setPersonPropertiesForFlags(n,!1);var r=ie(ie({},this.getFlagVariants()),{},{[e]:t});null===(i=this.instance.persistence)||void 0===i||i.register({[ze]:Object.keys(Ge(r)),[xe]:r}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.instance.get_property(Ie);if(i&&!t)return e(i);this.instance._send_request({transport:"XHR",url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token)),method:"GET",callback:t=>{var i;if(t.json){var n=t.json.earlyAccessFeatures;return null===(i=this.instance.persistence)||void 0===i||i.register({[Ie]:n}),e(n)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((n=>n(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.instance.get_property(Ce)||{};this.instance.register({[Ce]:ie(ie({},i),e)}),t&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(Ce)}setGroupPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.instance.get_property(Pe)||{};0!==Object.keys(i).length&&Object.keys(i).forEach((t=>{i[t]=ie(ie({},i[t]),e[t]),delete e[t]})),this.instance.register({[Pe]:ie(ie({},i),e)}),t&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.instance.get_property(Pe)||{};this.instance.register({[Pe]:ie(ie({},t),{},{[e]:{}})})}else this.instance.unregister(Pe)}}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});var Je="0123456789abcdef";class Ye{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,n){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(n)||e<0||t<0||i<0||n<0||e>0xffffffffffff||t>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");var r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new Ye(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Je.charAt(this.bytes[t]>>>4)+Je.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 Ye(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class Xe{constructor(){ne(this,"timestamp",0),ne(this,"counter",0),ne(this,"random",new Ze)}generate(){var e=this.generateOrAbort();if(H(e)){this.timestamp=0;var t=this.generateOrAbort();if(H(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return Ye.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}var Ke,Qe=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!H(e.crypto)&&crypto.getRandomValues&&(Qe=e=>crypto.getRandomValues(e));class Ze{constructor(){ne(this,"buffer",new Uint32Array(8)),ne(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(Qe(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}var et=()=>tt().toString(),tt=()=>(Ke||(Ke=new Xe)).generate(),it="Thu, 01 Jan 1970 00:00:00 GMT",nt="";var rt=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function st(e,t){if(t){var i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;if(nt)return nt;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),n=Math.min(i.length,8),r="dmn_chk_"+et(),s=new RegExp("(^|;)\\s*"+r+"=1");!nt&&n--;){var a=i.slice(n).join("."),l=r+"=1;domain=."+a;t.cookie=l,s.test(t.cookie)&&(t.cookie=l+";expires="+it,nt=a)}return nt}(e);if(!i){var n=(e=>{var t=e.match(rt);return t?t[0]:""})(e);n!==i&&K.info("Warning: cookie subdomain discovery mismatch",n,i),i=n}return i?"; domain=."+i:""}return""}var ot={is_supported:()=>!!o,error:function(e){K.error("cookieStore error: "+e)},get:function(e){if(o){try{for(var t=e+"=",i=o.cookie.split(";").filter((e=>e.length)),n=0;n<i.length;n++){for(var r=i[n];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}},parse:function(e){var t;try{t=JSON.parse(ot.get(e))||{}}catch(e){}return t},set:function(e,t,i,n,r){if(o)try{var s="",a="",l=st(o.location.hostname,n);if(i){var u=new Date;u.setTime(u.getTime()+24*i*60*60*1e3),s="; expires="+u.toUTCString()}r&&(a="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+l+a;return c.length>3686.4&&K.warn("cookieStore warning: large cookie, len="+c.length),o.cookie=c,c}catch(e){return}},remove:function(e,t){try{ot.set(e,"",-1,t)}catch(e){return}}},at=null,lt={is_supported:function(){if(!j(at))return at;var t=!0;if(H(e))t=!1;else try{var i="__mplssupport__";lt.set(i,"xyz"),'"xyz"'!==lt.get(i)&&(t=!1),lt.remove(i)}catch(e){t=!1}return t||K.error("localStorage unsupported; falling back to cookie store"),at=t,t},error:function(e){K.error("localStorage error: "+e)},get:function(t){try{return null==e?void 0:e.localStorage.getItem(t)}catch(e){lt.error(e)}return null},parse:function(e){try{return JSON.parse(lt.get(e))||{}}catch(e){}return null},set:function(t,i){try{null==e||e.localStorage.setItem(t,JSON.stringify(i))}catch(e){lt.error(e)}},remove:function(t){try{null==e||e.localStorage.removeItem(t)}catch(e){lt.error(e)}}},ut=["distinct_id",we,Se,Ne,De],ct=ie(ie({},lt),{},{parse:function(e){try{var t={};try{t=ot.parse(e)||{}}catch(e){}var i=m(t,JSON.parse(lt.get(e)||"{}"));return lt.set(e,i),i}catch(e){}return null},set:function(e,t,i,n,r,s){try{lt.set(e,t,void 0,void 0,s);var o={};ut.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&ot.set(e,o,i,n,r,s)}catch(e){lt.error(e)}},remove:function(t,i){try{null==e||e.localStorage.removeItem(t),ot.remove(t,i)}catch(e){lt.error(e)}}}),dt={},ht={is_supported:function(){return!0},error:function(e){K.error("memoryStorage error: "+e)},get:function(e){return dt[e]||null},parse:function(e){return dt[e]||null},set:function(e,t){dt[e]=t},remove:function(e){delete dt[e]}},_t=null,pt={is_supported:function(){if(!j(_t))return _t;if(_t=!0,H(e))_t=!1;else try{var t="__support__";pt.set(t,"xyz"),'"xyz"'!==pt.get(t)&&(_t=!1),pt.remove(t)}catch(e){_t=!1}return _t},error:function(e){K.error("sessionStorage error: ",e)},get:function(t){try{return null==e?void 0:e.sessionStorage.getItem(t)}catch(e){pt.error(e)}return null},parse:function(e){try{return JSON.parse(pt.get(e))||null}catch(e){}return null},set:function(t,i){try{null==e||e.sessionStorage.setItem(t,JSON.stringify(i))}catch(e){pt.error(e)}},remove:function(t){try{null==e||e.sessionStorage.removeItem(t)}catch(e){pt.error(e)}}},vt=["localhost","127.0.0.1"],gt=e=>{var t=null==o?void 0:o.createElement("a");return H(t)?null:(t.href=e,t)},ft=function(e,t){return!!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t)&&new RegExp(t).test(e)},mt=function(e){var t,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"&",r=[];return f(e,(function(e,n){H(e)||H(n)||"undefined"===n||(t=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),i=encodeURIComponent(n),r[r.length]=i+"="+t)})),r.join(n)},bt=function(e,t){for(var i,n=((e.split("#")[0]||"").split("?")[1]||"").split("&"),r=0;r<n.length;r++){var s=n[r].split("=");if(s[0]===t){i=s;break}}if(!D(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){K.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},yt=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},wt="Mobile",St="iOS",Et="Android",kt="Tablet",xt=Et+" "+kt,It="iPad",Ct="Apple",Pt=Ct+" Watch",Rt="Safari",Ft="BlackBerry",Tt="Samsung",$t=Tt+"Browser",Ot=Tt+" Internet",Lt="Chrome",Mt=Lt+" OS",At=Lt+" "+St,Dt="Internet Explorer",Nt=Dt+" "+wt,qt="Opera",Bt=qt+" Mini",Ht="Edge",Ut="Microsoft "+Ht,zt="Firefox",jt=zt+" "+St,Wt="Nintendo",Gt="PlayStation",Vt="Xbox",Jt=Et+" "+wt,Yt=wt+" "+Rt,Xt="Windows",Kt=Xt+" Phone",Qt="Nokia",Zt="Ouya",ei="Generic",ti=ei+" "+wt.toLowerCase(),ii=ei+" "+kt.toLowerCase(),ni="Konqueror",ri="(\\d+(\\.\\d+)?)",si=new RegExp("Version/"+ri),oi=new RegExp(Vt,"i"),ai=new RegExp(Gt+" \\w+","i"),li=new RegExp(Wt+" \\w+","i"),ui=new RegExp(Ft+"|PlayBook|BB10","i"),ci={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var di=(e,t)=>t&&b(t,Ct)||function(e){return b(e,Rt)&&!b(e,Lt)&&!b(e,Et)}(e),hi=function(e,t){return t=t||"",b(e," OPR/")&&b(e,"Mini")?Bt:b(e," OPR/")?qt:ui.test(e)?Ft:b(e,"IE"+wt)||b(e,"WPDesktop")?Nt:b(e,$t)?Ot:b(e,Ht)||b(e,"Edg/")?Ut:b(e,"FBIOS")?"Facebook "+wt:b(e,"UCWEB")||b(e,"UCBrowser")?"UC Browser":b(e,"CriOS")?At:b(e,"CrMo")||b(e,Lt)?Lt:b(e,Et)&&b(e,Rt)?Jt:b(e,"FxiOS")?jt:b(e.toLowerCase(),ni.toLowerCase())?ni:di(e,t)?b(e,wt)?Yt:Rt:b(e,zt)?zt:b(e,"MSIE")||b(e,"Trident/")?Dt:b(e,"Gecko")?zt:""},_i={[Nt]:[new RegExp("rv:"+ri)],[Ut]:[new RegExp(Ht+"?\\/"+ri)],[Lt]:[new RegExp("("+Lt+"|CrMo)\\/"+ri)],[At]:[new RegExp("CriOS\\/"+ri)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ri)],[Rt]:[si],[Yt]:[si],[qt]:[new RegExp("(Opera|OPR)\\/"+ri)],[zt]:[new RegExp(zt+"\\/"+ri)],[jt]:[new RegExp("FxiOS\\/"+ri)],[ni]:[new RegExp("Konqueror[:/]?"+ri,"i")],[Ft]:[new RegExp(Ft+" "+ri),si],[Jt]:[new RegExp("android\\s"+ri,"i")],[Ot]:[new RegExp($t+"\\/"+ri)],[Dt]:[new RegExp("(rv:|MSIE )"+ri)],Mozilla:[new RegExp("rv:"+ri)]},pi=[[new RegExp(Vt+"; "+Vt+" (.*?)[);]","i"),e=>[Vt,e&&e[1]||""]],[new RegExp(Wt,"i"),[Wt,""]],[new RegExp(Gt,"i"),[Gt,""]],[ui,[Ft,""]],[new RegExp(Xt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Kt,""];if(new RegExp(wt).test(t)&&!/IEMobile\b/.test(t))return[Xt+" "+wt,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var n=i[1],r=ci[n]||"";return/arm/i.test(t)&&(r="RT"),[Xt,r]}return[Xt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[St,t.join(".")]}return[St,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=H(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Et+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Et+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Et,t.join(".")]}return[Et,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Mt,""]],[/Linux|debian/i,["Linux",""]]],vi=function(e){return li.test(e)?Wt:ai.test(e)?Gt:oi.test(e)?Vt:new RegExp(Zt,"i").test(e)?Zt:new RegExp("("+Kt+"|WPDesktop)","i").test(e)?Kt:/iPad/.test(e)?It:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Pt:ui.test(e)?Ft:/(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(wt).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)?Et:xt:Et:new RegExp("(pda|"+wt+")","i").test(e)?ti:new RegExp(kt,"i").test(e)&&!new RegExp(kt+" pc","i").test(e)?ii:""},gi="https?://(.*)",fi=["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"],mi={campaignParams:function(e){return o?this._campaignParamsFromUrl(o.URL,e):{}},_campaignParamsFromUrl:function(e,t){var i=fi.concat(t||[]),n={};return f(i,(function(t){var i=bt(e,t);n[t]=i||null})),n},_searchEngine:function(e){return e?0===e.search(gi+"google.([^/?]*)")?"google":0===e.search(gi+"bing.com")?"bing":0===e.search(gi+"yahoo.com")?"yahoo":0===e.search(gi+"duckduckgo.com")?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=mi._searchEngine(e),i="yahoo"!=t?"q":"p",n={};if(!j(t)){n.$search_engine=t;var r=o?bt(o.referrer,i):"";r.length&&(n.ph_keyword=r)}return n},searchInfo:function(){var e=null==o?void 0:o.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:hi,browserVersion:function(e,t){var i=hi(e,t),n=_i[i];if(H(n))return null;for(var r=0;r<n.length;r++){var s=n[r],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return"string"==typeof e?e.split("-")[0]:void 0},os:function(e){for(var t=0;t<pi.length;t++){var[i,n]=pi[t],r=i.exec(e),s=r&&(N(n)?n(r,e):n);if(s)return s}return["",""]},device:vi,deviceType:function(e){var t=vi(e);return t===It||t===xt||"Kobo"===t||"Kindle Fire"===t||t===ii?kt:t===Wt||t===Vt||t===Gt||t===Zt?"Console":t===Pt?"Wearable":t?wt:"Desktop"},referrer:function(){return(null==o?void 0:o.referrer)||"$direct"},referringDomain:function(){var e;return null!=o&&o.referrer&&(null===(e=gt(o.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().substring(0,1e3),u:null==a?void 0:a.href.substring(0,1e3)}},initialPersonPropsFromInfo:function(e){var t,{r:i,u:n}=e,r={$initial_referrer:i,$initial_referring_domain:null==i?void 0:"$direct"==i?"$direct":null===(t=gt(i))||void 0===t?void 0:t.host};if(n){r.$initial_current_url=n;var s=gt(n);r.$initial_host=null==s?void 0:s.host,r.$initial_pathname=null==s?void 0:s.pathname,f(this._campaignParamsFromUrl(n),(function(e,t){r["$initial_"+k(t)]=e}))}i&&f(this._searchInfoFromReferrer(i),(function(e,t){r["$initial_"+k(t)]=e}));return r},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}},timezoneOffset:function(){try{return(new Date).getTimezoneOffset()}catch(e){return}},properties:function(){if(!d)return{};var[t,i]=mi.os(d);return m(E({$os:t,$os_version:i,$browser:mi.browser(d,navigator.vendor),$device:mi.device(d),$device_type:mi.deviceType(d),$timezone:mi.timezone(),$timezone_offset:mi.timezoneOffset()}),{$current_url:null==a?void 0:a.href,$host:null==a?void 0:a.host,$pathname:null==a?void 0:a.pathname,$raw_user_agent:d.length>1e3?d.substring(0,997)+"...":d,$browser_version:mi.browserVersion(d,navigator.vendor),$browser_language:mi.browserLanguage(),$browser_language_prefix:mi.browserLanguagePrefix(),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:"web",$lib_version:_.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(!d)return{};var[e,t]=mi.os(d);return m(E({$os:e,$os_version:t,$browser:mi.browser(d,navigator.vendor)}),{$browser_version:mi.browserVersion(d,navigator.vendor)})}},bi=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class yi{constructor(e){this.config=e,this.props={},this.campaign_params_saved=!1,this.name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this.storage=this.buildStorage(e),this.load(),e.debug&&K.info("Persistence loaded",e.persistence,ie({},this.props)),this.update_config(e,e),this.save()}buildStorage(e){-1===bi.indexOf(e.persistence.toLowerCase())&&(K.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&lt.is_supported()?lt:"localstorage+cookie"===t&&ct.is_supported()?ct:"sessionstorage"===t&&pt.is_supported()?pt:"memory"===t?ht:"cookie"===t?ot:ct.is_supported()?ct:ot}properties(){var e={};return f(this.props,(function(t,i){if(i===xe&&q(t))for(var n=Object.keys(t),s=0;s<n.length;s++)e["$feature/".concat(n[s])]=t[n[s]];else a=i,l=!1,(j(o=He)?l:r&&o.indexOf===r?-1!=o.indexOf(a):(f(o,(function(e){if(l||(l=e===a))return p})),l))||(e[i]=t);var o,a,l})),e}load(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=m({},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(q(e)){H(t)&&(t="None"),this.expire_days=H(i)?this.default_expiry:i;var n=!1;if(f(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,n=!0)})),n)return this.save(),!0}return!1}register(e,t){if(q(e)){this.expire_days=H(t)?this.default_expiry:t;var i=!1;if(f(e,((t,n)=>{e.hasOwnProperty(n)&&this.props[n]!==t&&(this.props[n]=t,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.campaign_params_saved){var e=mi.campaignParams(this.config.custom_campaign_params);B(E(e))||this.register(e),this.campaign_params_saved=!0}}update_search_keyword(){this.register(mi.searchInfo())}update_referrer_info(){this.register_once(mi.referrerInfo(),void 0)}set_initial_person_info(){this.props[Me]||this.props[Ae]||this.register_once({[De]:mi.initialPersonInfo()},void 0)}get_referrer_info(){return E({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var e={};f([Ae,Me],(t=>{var i=this.props[t];i&&f(i,(function(t,i){e["$initial_"+k(i)]=t}))}));var t=this.props[De];if(t){var i=mi.initialPersonPropsFromInfo(t);m(e,i)}return e}safe_merge(e){return f(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){var i=this.buildStorage(e),n=this.props;this.clear(),this.storage=i,this.props=n,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){var i=this.props[ae]||{};i[e]=t,this.props[ae]=i,this.save()}remove_event_timer(e){var t=(this.props[ae]||{})[e];return H(t)||(delete this.props[ae][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}function wi(e){var t,i;return(null===(t=JSON.stringify(e,(i=[],function(e,t){if(q(t)){for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(t)?"[Circular]":(i.push(t),t)}return t})))||void 0===t?void 0:t.length)||0}function Si(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6606028.8;if(e.size>=t&&e.data.length>1){var i=Math.floor(e.data.length/2),n=e.data.slice(0,i),r=e.data.slice(i);return[Si({size:wi(n),data:n,sessionId:e.sessionId,windowId:e.windowId}),Si({size:wi(r),data:r,sessionId:e.sessionId,windowId:e.windowId})].flatMap((e=>e))}return[e]}var Ei=(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))(Ei||{}),ki=(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))(ki||{});function xi(e){var t;return e.id===qe||!(null===(t=e.closest)||void 0===t||!t.call(e,".toolbar-global-fade-container"))}function Ii(e){return!!e&&1===e.nodeType}function Ci(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Pi(e){return!!e&&3===e.nodeType}function Ri(e){return!!e&&11===e.nodeType}function Fi(e){return e?v(e).split(/\s+/):[]}function Ti(t){var i=null==e?void 0:e.location.href;return!!(i&&t&&t.some((e=>i.match(e))))}function $i(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Fi(t)}function Oi(e){return W(e)?null:v(e).split(/(\s+)/).filter((e=>Vi(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Li(e){var t="";return qi(e)&&!Bi(e)&&e.childNodes&&e.childNodes.length&&f(e.childNodes,(function(e){var i;Pi(e)&&e.textContent&&(t+=null!==(i=Oi(e.textContent))&&void 0!==i?i:"")})),v(t)}function Mi(e){return H(e.target)?e.srcElement||null:null!==(t=e.target)&&void 0!==t&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Ai=["a","button","form","input","select","textarea","label"];function Di(e){var t=e.parentNode;return!(!t||!Ii(t))&&t}function Ni(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!e||!t||Ci(t,"html")||!Ii(t))return!1;if(null!=n&&n.url_allowlist&&!Ti(n.url_allowlist))return!1;if(null!=n&&n.url_ignorelist&&Ti(n.url_ignorelist))return!1;if(null!=n&&n.dom_event_allowlist){var o=n.dom_event_allowlist;if(o&&!o.some((e=>i.type===e)))return!1}for(var a=!1,l=[t],u=!0,c=t;c.parentNode&&!Ci(c,"body");)if(Ri(c.parentNode))l.push(c.parentNode.host),c=c.parentNode.host;else{if(!(u=Di(c)))break;if(r||Ai.indexOf(u.tagName.toLowerCase())>-1)a=!0;else{var d=e.getComputedStyle(u);d&&"pointer"===d.getPropertyValue("cursor")&&(a=!0)}l.push(u),c=u}if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(H(i))return!0;var n=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var r of e){var s=n(r);if("object"==typeof s)return s.v}return!1}(l,n))return!1;if(!function(e,t){var i=null==t?void 0:t.css_selector_allowlist;if(H(i))return!0;var n=function(e){if(i.some((t=>e.matches(t))))return{v:!0}};for(var r of e){var s=n(r);if("object"==typeof s)return s.v}return!1}(l,n))return!1;var h=e.getComputedStyle(t);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===i.type)return!0;var _=t.tagName.toLowerCase();switch(_){case"html":return!1;case"form":return(s||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(i.type)>=0;default:return a?(s||["click"]).indexOf(i.type)>=0:(s||["click"]).indexOf(i.type)>=0&&(Ai.indexOf(_)>-1||"true"===t.getAttribute("contenteditable"))}}function qi(e){for(var t=e;t.parentNode&&!Ci(t,"body");t=t.parentNode){var i=$i(t);if(b(i,"ph-sensitive")||b(i,"ph-no-capture"))return!1}if(b($i(e),"ph-include"))return!0;var n=e.type||"";if(U(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(U(r)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function Bi(e){return!!(Ci(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ci(e,"select")||Ci(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Hi="(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})",Ui=new RegExp("^(?:".concat(Hi,")$")),zi=new RegExp(Hi),ji="\\d{3}-?\\d{2}-?\\d{4}",Wi=new RegExp("^(".concat(ji,")$")),Gi=new RegExp("(".concat(ji,")"));function Vi(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(W(e))return!1;if(U(e)){if(e=v(e),(t?Ui:zi).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Wi:Gi).test(e))return!1}return!0}function Ji(e){var t=Li(e);return Vi(t="".concat(t," ").concat(Yi(e)).trim())?t:""}function Yi(e){var t="";return e&&e.childNodes&&e.childNodes.length&&f(e.childNodes,(function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{var n=Li(e);t="".concat(t," ").concat(n).trim(),e.childNodes&&e.childNodes.length&&(t="".concat(t," ").concat(Yi(e)).trim())}catch(e){K.error("[AutoCapture]",e)}})),t}function Xi(e){return function(e){var t=e.map((e=>{var t,i,n="";if(e.tag_name&&(n+=e.tag_name),e.attr_class)for(var r of(e.attr_class.sort(),e.attr_class))n+=".".concat(r.replace(/"/g,""));var s=ie(ie(ie(ie({},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),o={};return y(s).sort(((e,t)=>{var[i]=e,[n]=t;return i.localeCompare(n)})).forEach((e=>{var[t,i]=e;return o[Ki(t.toString())]=Ki(i.toString())})),n+=":",n+=y(s).map((e=>{var[t,i]=e;return"".concat(t,'="').concat(i,'"')})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,i,n={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:Qi(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return y(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return n.attributes[t]=i})),n}))}(e))}function Ki(e){return e.replace(/"|\\"/g,'\\"')}function Qi(e){var t=e.attr__class;return t?D(t)?t:Fi(t):void 0}var Zi="[SessionRecording]",en="redacted",tn={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"]},nn=["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"],rn=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],sn=["/s/","/e/","/i/"];function on(e,t,i,n){if(W(e))return e;var r=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return U(r)&&(r=parseInt(r)),r>i?Zi+" ".concat(n," body too large to record (").concat(r," bytes)"):e}function an(e,t){if(W(e))return e;var i=e;return Vi(i,!1)||(i=Zi+" "+t+" body "+en),f(rn,(e=>{var n,r;null!==(n=i)&&void 0!==n&&n.length&&-1!==(null===(r=i)||void 0===r?void 0:r.indexOf(e))&&(i=Zi+" "+t+" body "+en+" as might contain: "+e)})),i}var ln=(e,t)=>{var i,n,r,s={payloadSizeLimitBytes:tn.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...tn.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...tn.payloadHostDenyList]},o=!1!==e.session_recording.recordHeaders&&t.recordHeaders,a=!1!==e.session_recording.recordBody&&t.recordBody,l=!1!==e.capture_performance&&t.recordPerformance,u=(i=s,r=Math.min(1e6,null!==(n=i.payloadSizeLimitBytes)&&void 0!==n?n:1e6),e=>(null!=e&&e.requestBody&&(e.requestBody=on(e.requestBody,e.requestHeaders,r,"Request")),null!=e&&e.responseBody&&(e.responseBody=on(e.responseBody,e.responseHeaders,r,"Response")),e)),c=t=>{return u(((e,t)=>{var i,n=gt(e.name),r=0===t.indexOf("http")?null===(i=gt(t))||void 0===i?void 0:i.pathname:t;"/"===r&&(r="");var s=null==n?void 0:n.pathname.replace(r||"","");if(!(n&&s&&sn.some((e=>0===s.indexOf(e)))))return e})((n=(i=t).requestHeaders,W(n)||f(Object.keys(null!=n?n:{}),(e=>{nn.includes(e.toLowerCase())&&(n[e]=en)})),i),e.api_host));var i,n},d=N(e.session_recording.maskNetworkRequestFn);return d&&N(e.session_recording.maskCapturedNetworkRequestFn)&&K.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),d&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{var i=e.session_recording.maskNetworkRequestFn({url:t.name});return ie(ie({},t),{},{name:null==i?void 0:i.url})}),s.maskRequestFn=N(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,n,r,s=c(t);return s&&null!==(i=null===(n=(r=e.session_recording).maskCapturedNetworkRequestFn)||void 0===n?void 0:n.call(r,s))&&void 0!==i?i:void 0}:e=>function(e){if(!H(e))return e.requestBody=an(e.requestBody,"Request"),e.responseBody=an(e.responseBody,"Response"),e}(c(e)),ie(ie(ie({},tn),s),{},{recordHeaders:o,recordBody:a,recordPerformance:l,recordInitialRequests:l})};function un(e,t,i,n,r){return t>i&&(K.warn("min cannot be greater than max."),t=i),G(e)?e>i?(n&&K.warn(n+" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(n&&K.warn(n+" cannot be less than min: "+t+". Using min value instead."),t):e:(n&&K.warn(n+" must be a number. using max or fallback. max: "+i+", fallback: "+r),un(r||i,t,i,n))}class cn{constructor(e){var t,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ne(this,"bucketSize",100),ne(this,"refillRate",10),ne(this,"mutationBuckets",{}),ne(this,"loggedTracker",{}),ne(this,"refillBuckets",(()=>{Object.keys(this.mutationBuckets).forEach((e=>{this.mutationBuckets[e]=this.mutationBuckets[e]+this.refillRate,this.mutationBuckets[e]>=this.bucketSize&&delete this.mutationBuckets[e]}))})),ne(this,"getNodeOrRelevantParent",(e=>{var t=this.rrweb.mirror.getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){var i=t.closest("svg");if(i)return[this.rrweb.mirror.getId(i),i]}return[e,t]})),ne(this,"numberOfChanges",(e=>{var t,i,n,r,s,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(n=null===(r=e.attributes)||void 0===r?void 0:r.length)&&void 0!==n?n:0)+(null!==(s=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==s?s:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)})),ne(this,"throttleMutations",(e=>{if(3!==e.type||0!==e.data.source)return e;var t=e.data,i=this.numberOfChanges(t);t.attributes&&(t.attributes=t.attributes.filter((e=>{var t,i,n,[r,s]=this.getNodeOrRelevantParent(e.id);if(0===this.mutationBuckets[r])return!1;(this.mutationBuckets[r]=null!==(t=this.mutationBuckets[r])&&void 0!==t?t:this.bucketSize,this.mutationBuckets[r]=Math.max(this.mutationBuckets[r]-1,0),0===this.mutationBuckets[r])&&(this.loggedTracker[r]||(this.loggedTracker[r]=!0,null===(i=(n=this.options).onBlockedNode)||void 0===i||i.call(n,r,s)));return e})));var n=this.numberOfChanges(t);return 0!==n||i===n?e:void 0})),this.rrweb=e,this.options=n,this.refillRate=un(null!==(t=this.options.refillRate)&&void 0!==t?t:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=un(null!==(i=this.options.bucketSize)&&void 0!==i?i:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval((()=>{this.refillBuckets()}),1e3)}}var dn=Uint8Array,hn=Uint16Array,_n=Uint32Array,pn=new dn([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]),vn=new dn([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]),gn=new dn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fn=function(e,t){for(var i=new hn(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var r=new _n(i[30]);for(n=1;n<30;++n)for(var s=i[n];s<i[n+1];++s)r[s]=s-i[n]<<5|n;return[i,r]},mn=fn(pn,2),bn=mn[0],yn=mn[1];bn[28]=258,yn[258]=28;for(var wn=fn(vn,0)[1],Sn=new hn(32768),En=0;En<32768;++En){var kn=(43690&En)>>>1|(21845&En)<<1;kn=(61680&(kn=(52428&kn)>>>2|(13107&kn)<<2))>>>4|(3855&kn)<<4,Sn[En]=((65280&kn)>>>8|(255&kn)<<8)>>>1}var xn=function(e,t,i){for(var n=e.length,r=0,s=new hn(t);r<n;++r)++s[e[r]-1];var o,a=new hn(t);for(r=0;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;if(i){o=new hn(1<<t);var l=15-t;for(r=0;r<n;++r)if(e[r])for(var u=r<<4|e[r],c=t-e[r],d=a[e[r]-1]++<<c,h=d|(1<<c)-1;d<=h;++d)o[Sn[d]>>>l]=u}else for(o=new hn(n),r=0;r<n;++r)o[r]=Sn[a[e[r]-1]++]>>>15-e[r];return o},In=new dn(288);for(En=0;En<144;++En)In[En]=8;for(En=144;En<256;++En)In[En]=9;for(En=256;En<280;++En)In[En]=7;for(En=280;En<288;++En)In[En]=8;var Cn=new dn(32);for(En=0;En<32;++En)Cn[En]=5;var Pn=xn(In,9,0),Rn=xn(Cn,5,0),Fn=function(e){return(e/8>>0)+(7&e&&1)},Tn=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var n=new(e instanceof hn?hn:e instanceof _n?_n:dn)(i-t);return n.set(e.subarray(t,i)),n},$n=function(e,t,i){i<<=7&t;var n=t/8>>0;e[n]|=i,e[n+1]|=i>>>8},On=function(e,t,i){i<<=7&t;var n=t/8>>0;e[n]|=i,e[n+1]|=i>>>8,e[n+2]|=i>>>16},Ln=function(e,t){for(var i=[],n=0;n<e.length;++n)e[n]&&i.push({s:n,f:e[n]});var r=i.length,s=i.slice();if(!r)return[new dn(0),0];if(1==r){var o=new dn(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[u].f<i[d].f?u++:d++],l=i[u!=c&&i[u].f<i[d].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var h=s[0].s;for(n=1;n<r;++n)s[n].s>h&&(h=s[n].s);var _=new hn(h+1),p=Mn(i[c-1],_,0);if(p>t){n=0;var v=0,g=p-t,f=1<<g;for(s.sort((function(e,t){return _[t.s]-_[e.s]||e.f-t.f}));n<r;++n){var m=s[n].s;if(!(_[m]>t))break;v+=f-(1<<p-_[m]),_[m]=t}for(v>>>=g;v>0;){var b=s[n].s;_[b]<t?v-=1<<t-_[b]++-1:++n}for(;n>=0&&v;--n){var y=s[n].s;_[y]==t&&(--_[y],++v)}p=t}return[new dn(_),p]},Mn=function(e,t,i){return-1==e.s?Math.max(Mn(e.l,t,i+1),Mn(e.r,t,i+1)):t[e.s]=i},An=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new hn(++t),n=0,r=e[0],s=1,o=function(e){i[n++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(r),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(r);s=1,r=e[a]}return[i.subarray(0,n),t]},Dn=function(e,t){for(var i=0,n=0;n<t.length;++n)i+=e[n]*t[n];return i},Nn=function(e,t,i){var n=i.length,r=Fn(t+2);e[r]=255&n,e[r+1]=n>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var s=0;s<n;++s)e[r+s+4]=i[s];return 8*(r+4+n)},qn=function(e,t,i,n,r,s,o,a,l,u,c){$n(t,c++,i),++r[256];for(var d=Ln(r,15),h=d[0],_=d[1],p=Ln(s,15),v=p[0],g=p[1],f=An(h),m=f[0],b=f[1],y=An(v),w=y[0],S=y[1],E=new hn(19),k=0;k<m.length;++k)E[31&m[k]]++;for(k=0;k<w.length;++k)E[31&w[k]]++;for(var x=Ln(E,7),I=x[0],C=x[1],P=19;P>4&&!I[gn[P-1]];--P);var R,F,T,$,O=u+5<<3,L=Dn(r,In)+Dn(s,Cn)+o,M=Dn(r,h)+Dn(s,v)+o+14+3*P+Dn(E,I)+(2*E[16]+3*E[17]+7*E[18]);if(O<=L&&O<=M)return Nn(t,c,e.subarray(l,l+u));if($n(t,c,1+(M<L)),c+=2,M<L){R=xn(h,_,0),F=h,T=xn(v,g,0),$=v;var A=xn(I,C,0);$n(t,c,b-257),$n(t,c+5,S-1),$n(t,c+10,P-4),c+=14;for(k=0;k<P;++k)$n(t,c+3*k,I[gn[k]]);c+=3*P;for(var D=[m,w],N=0;N<2;++N){var q=D[N];for(k=0;k<q.length;++k){var B=31&q[k];$n(t,c,A[B]),c+=I[B],B>15&&($n(t,c,q[k]>>>5&127),c+=q[k]>>>12)}}}else R=Pn,F=In,T=Rn,$=Cn;for(k=0;k<a;++k)if(n[k]>255){B=n[k]>>>18&31;On(t,c,R[B+257]),c+=F[B+257],B>7&&($n(t,c,n[k]>>>23&31),c+=pn[B]);var H=31&n[k];On(t,c,T[H]),c+=$[H],H>3&&(On(t,c,n[k]>>>5&8191),c+=vn[H])}else On(t,c,R[n[k]]),c+=F[n[k]];return On(t,c,R[256]),c+F[256]},Bn=new _n([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Hn=function(){for(var e=new _n(256),t=0;t<256;++t){for(var i=t,n=9;--n;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Un=function(){var e=4294967295;return{p:function(t){for(var i=e,n=0;n<t.length;++n)i=Hn[255&i^t[n]]^i>>>8;e=i},d:function(){return 4294967295^e}}},zn=function(e,t,i,n,r){return function(e,t,i,n,r,s){var o=e.length,a=new dn(n+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(n,a.length-r),u=0;if(!t||o<8)for(var c=0;c<=o;c+=65535){var d=c+65535;d<o?u=Nn(l,u,e.subarray(c,d)):(l[c]=s,u=Nn(l,u,e.subarray(c,o)))}else{for(var h=Bn[t-1],_=h>>>13,p=8191&h,v=(1<<i)-1,g=new hn(32768),f=new hn(v+1),m=Math.ceil(i/3),b=2*m,y=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<b)&v},w=new _n(25e3),S=new hn(288),E=new hn(32),k=0,x=0,I=(c=0,0),C=0,P=0;c<o;++c){var R=y(c),F=32767&c,T=f[R];if(g[F]=T,f[R]=F,C<=c){var $=o-c;if((k>7e3||I>24576)&&$>423){u=qn(e,l,0,w,S,E,x,I,P,c-P,u),I=k=x=0,P=c;for(var O=0;O<286;++O)S[O]=0;for(O=0;O<30;++O)E[O]=0}var L=2,M=0,A=p,D=F-T&32767;if($>2&&R==y(c-D))for(var N=Math.min(_,$)-1,q=Math.min(32767,c),B=Math.min(258,$);D<=q&&--A&&F!=T;){if(e[c+L]==e[c+L-D]){for(var H=0;H<B&&e[c+H]==e[c+H-D];++H);if(H>L){if(L=H,M=D,H>N)break;var U=Math.min(D,H-2),z=0;for(O=0;O<U;++O){var j=c-D+O+32768&32767,W=j-g[j]+32768&32767;W>z&&(z=W,T=j)}}}D+=(F=T)-(T=g[F])+32768&32767}if(M){w[I++]=268435456|yn[L]<<18|wn[M];var G=31&yn[L],V=31&wn[M];x+=pn[G]+vn[V],++S[257+G],++E[V],C=c+L,++k}else w[I++]=e[c],++S[e[c]]}}u=qn(e,l,s,w,S,E,x,I,P,c-P,u)}return Tn(a,0,n+Fn(u)+r)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,n,!r)},jn=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},Wn=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&&jn(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var n=0;n<=i.length;++n)e[n+10]=i.charCodeAt(n)}},Gn=function(e){return 10+(e.filename&&e.filename.length+1||0)};function Vn(e,t){void 0===t&&(t={});var i=Un(),n=e.length;i.p(e);var r=zn(e,t,Gn(t),8),s=r.length;return Wn(r,t),jn(r,s-8,i.d()),jn(r,s-4,n),r}function Jn(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var n=new dn(e.length+(e.length>>>1)),r=0,s=function(e){n[r++]=e},o=0;o<i;++o){if(r+5>n.length){var a=new dn(r+8+(i-o<<1));a.set(n),n=a}var l=e.charCodeAt(o);l<128||t?s(l):l<2048?(s(192|l>>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),s(128|l>>>12&63),s(128|l>>>6&63),s(128|63&l)):(s(224|l>>>12),s(128|l>>>6&63),s(128|63&l))}return Tn(n,0,r)}var Yn="[SessionRecording]",Xn=Q(Yn),Kn=3e5,Qn=[ki.MouseMove,ki.MouseInteraction,ki.Scroll,ki.ViewportResize,ki.Input,ki.TouchMove,ki.MediaInteraction,ki.Drag],Zn=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function er(e){return function(e,t){for(var i="",n=0;n<e.length;){var r=e[n++];r<128||t?i+=String.fromCharCode(r):r<224?i+=String.fromCharCode((31&r)<<6|63&e[n++]):r<240?i+=String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,i+=String.fromCharCode(55296|r>>10,56320|1023&r))}return i}(Vn(Jn(JSON.stringify(e))),!0)}function tr(e){return e.type===Ei.Custom&&"sessionIdle"===e.data.tag}function ir(e,t){return t.some((t=>"regex"===t.matching&&new RegExp(t.url).test(e)))}class nr{get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get rrwebRecord(){var e,t;return null==h||null===(e=h.__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(Yn+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var e,t;return"trigger_pending"===this.triggerStatus?6e4:null!==(e=null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.full_snapshot_interval_millis)&&void 0!==e?e:Kn}get isSampled(){var e=this.instance.get_property(Se);return V(e)?e:null}get sessionDuration(){var e,t,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:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return i?i.timestamp-n:null}get isRecordingEnabled(){var t=!!this.instance.get_property(pe),i=!this.instance.config.disable_session_recording;return e&&t&&i}get isConsoleLogCaptureEnabled(){var e=!!this.instance.get_property(ve),t=this.instance.config.enable_recording_console_log;return null!=t?t:e}get canvasRecording(){var e,t,i,n,r,s,o=this.instance.config.session_recording.captureCanvas,a=this.instance.get_property(fe),l=null!==(e=null!==(t=null==o?void 0:o.recordCanvas)&&void 0!==t?t:null==a?void 0:a.enabled)&&void 0!==e&&e,u=null!==(i=null!==(n=null==o?void 0:o.canvasFps)&&void 0!==n?n:null==a?void 0:a.fps)&&void 0!==i?i:0,c=null!==(r=null!==(s=null==o?void 0:o.canvasQuality)&&void 0!==s?s:null==a?void 0:a.quality)&&void 0!==r?r:0;return{enabled:l,fps:un(u,0,12,"canvas recording fps"),quality:un(c,0,1,"canvas recording quality")}}get networkPayloadCapture(){var e,t,i=this.instance.get_property(ge),n={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},r=(null==n?void 0:n.recordHeaders)||(null==i?void 0:i.recordHeaders),s=(null==n?void 0:n.recordBody)||(null==i?void 0:i.recordBody),o=q(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,a=!!(V(o)?o:null==i?void 0:i.capturePerformance);return r||s||a?{recordHeaders:r,recordBody:s,recordPerformance:a}:void 0}get sampleRate(){var e=this.instance.get_property(me);return G(e)?e:null}get minimumDuration(){var e=this.instance.get_property(be);return G(e)?e:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this._urlBlocked?"paused":W(this._linkedFlag)||this._linkedFlagSeen?"trigger_pending"===this.triggerStatus?"buffering":V(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var e;return 0===this._urlTriggers.length?"trigger_disabled":(null===(e=this.instance)||void 0===e?void 0:e.get_property(Ee))===this.sessionId?"trigger_activated":"trigger_pending"}get eventTriggerStatus(){var e;return 0===this._eventTriggers.length?"trigger_disabled":(null===(e=this.instance)||void 0===e?void 0:e.get_property(ke))===this.sessionId?"trigger_activated":"trigger_pending"}get triggerStatus(){var e="trigger_activated"===this.eventTriggerStatus||"trigger_activated"===this.urlTriggerStatus,t="trigger_pending"===this.eventTriggerStatus||"trigger_pending"===this.urlTriggerStatus;return e?"trigger_activated":t?"trigger_pending":"trigger_disabled"}constructor(e){if(ne(this,"queuedRRWebEvents",[]),ne(this,"isIdle",!1),ne(this,"_linkedFlagSeen",!1),ne(this,"_lastActivityTimestamp",Date.now()),ne(this,"_linkedFlag",null),ne(this,"_removePageViewCaptureHook",void 0),ne(this,"_onSessionIdListener",void 0),ne(this,"_persistDecideOnSessionListener",void 0),ne(this,"_samplingSessionListener",void 0),ne(this,"_urlTriggers",[]),ne(this,"_urlBlocklist",[]),ne(this,"_urlBlocked",!1),ne(this,"_eventTriggers",[]),ne(this,"_removeEventTriggerCaptureHook",void 0),ne(this,"_forceAllowLocalhostNetworkCapture",!1),ne(this,"_onBeforeUnload",(()=>{this._flushBuffer()})),ne(this,"_onOffline",(()=>{this._tryAddCustomEvent("browser offline",{})})),ne(this,"_onOnline",(()=>{this._tryAddCustomEvent("browser online",{})})),ne(this,"_onVisibilityChange",(()=>{if(null!=o&&o.visibilityState){var e="window "+o.visibilityState;this._tryAddCustomEvent(e,{})}})),this.instance=e,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw Xn.error("started without valid sessionManager"),new Error(Yn+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(Yn+" cannot be used with __preview_experimental_cookieless_mode.");var{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=t,this.windowId=i,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&Xn.warn("session_idle_threshold_ms (".concat(this.sessionIdleThresholdMilliseconds,") is greater than the session timeout (").concat(this.sessionManager.sessionTimeoutMs,"). Session will never be detected as idle"))}startIfEnabledOrStop(t){this.isRecordingEnabled?(this._startCapture(t),null==e||e.addEventListener("beforeunload",this._onBeforeUnload),null==e||e.addEventListener("offline",this._onOffline),null==e||e.addEventListener("online",this._onOnline),null==e||e.addEventListener("visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),W(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance.on("eventCaptured",(e=>{try{if("$pageview"===e.event){var t=null!=e&&e.properties.$current_url?this._maskUrl(null==e?void 0:e.properties.$current_url):"";if(!t)return;this._tryAddCustomEvent("$pageview",{href:t})}}catch(e){Xn.error("Could not add $pageview to rrweb session",e)}}))),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId(((e,t,i)=>{var n,r,s,o;i&&(this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),null===(n=this.instance)||void 0===n||null===(r=n.persistence)||void 0===r||r.unregister(ke),null===(s=this.instance)||void 0===s||null===(o=s.persistence)||void 0===o||o.unregister(Ee))})))):this.stopRecording()}stopRecording(){var t,i,n,r;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,null==e||e.removeEventListener("beforeunload",this._onBeforeUnload),null==e||e.removeEventListener("offline",this._onOffline),null==e||e.removeEventListener("online",this._onOnline),null==e||e.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),null===(t=this._removePageViewCaptureHook)||void 0===t||t.call(this),this._removePageViewCaptureHook=void 0,null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),this._removeEventTriggerCaptureHook=void 0,null===(n=this._onSessionIdListener)||void 0===n||n.call(this),this._onSessionIdListener=void 0,null===(r=this._samplingSessionListener)||void 0===r||r.call(this),this._samplingSessionListener=void 0,Xn.info("stopped"))}makeSamplingDecision(e){var t,i=this.sessionId!==e,n=this.sampleRate;if(G(n)){var r,s=this.isSampled,o=i||!V(s);if(o)r=Math.random()<n;else r=s;o&&(r?this._reportStarted("sampled"):Xn.warn("Sample rate (".concat(n,") has determined that this sessionId (").concat(e,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:n,isSampled:r})),null===(t=this.instance.persistence)||void 0===t||t.register({[Se]:r})}else{var a;null===(a=this.instance.persistence)||void 0===a||a.register({[Se]:null})}}onRemoteConfig(e){var t,i,n,r,s,o;(this._persistRemoteConfig(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===(o=e.sessionRecording)||void 0===o?void 0:o.endpoint);if(this._setupSampling(),!W(this._linkedFlag)&&!this._linkedFlagSeen){var a=U(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,l=U(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags(((e,t)=>{var i=q(t)&&a in t,n=l?t[a]===l:i;n&&this._reportStarted("linked_flag_matched",{linkedFlag:a,linkedVariant:l}),this._linkedFlagSeen=n}))}null!==(n=e.sessionRecording)&&void 0!==n&&n.urlTriggers&&(this._urlTriggers=e.sessionRecording.urlTriggers),null!==(r=e.sessionRecording)&&void 0!==r&&r.urlBlocklist&&(this._urlBlocklist=e.sessionRecording.urlBlocklist),null!==(s=e.sessionRecording)&&void 0!==s&&s.eventTriggers&&(this._eventTriggers=e.sessionRecording.eventTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){G(this.sampleRate)&&W(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId((e=>{this.makeSamplingDecision(e)})))}_persistRemoteConfig(e){if(this.instance.persistence){var t,i=this.instance.persistence,n=()=>{var t,n,r,s,o,a,l,u,c=null===(t=e.sessionRecording)||void 0===t?void 0:t.sampleRate,d=W(c)?null:parseFloat(c),h=null===(n=e.sessionRecording)||void 0===n?void 0:n.minimumDurationMilliseconds;i.register({[pe]:!!e.sessionRecording,[ve]:null===(r=e.sessionRecording)||void 0===r?void 0:r.consoleLogRecordingEnabled,[ge]:ie({capturePerformance:e.capturePerformance},null===(s=e.sessionRecording)||void 0===s?void 0:s.networkPayloadCapture),[fe]:{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},[me]:d,[be]:H(h)?null:h,[ye]:null===(u=e.sessionRecording)||void 0===u?void 0:u.scriptConfig})};n(),null===(t=this._persistDecideOnSessionListener)||void 0===t||t.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(n)}}log(e){var t,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(!H(Object.assign)&&!H(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=h.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,this.scriptName,(e=>{if(e)return Xn.error("could not load recorder",e);this._onScriptLoaded()}));Xn.info("starting"),"active"===this.status&&this._reportStarted(e||"recording_initialized")}}get scriptName(){var e,t,i;return(null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t||null===(i=t.get_property(ye))||void 0===i?void 0:i.script)||"recorder"}isInteractiveEvent(e){var t;return 3===e.type&&-1!==Qn.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){var t=this.isInteractiveEvent(e);t||this.isIdle||e.timestamp-this._lastActivityTimestamp>this.sessionIdleThresholdMilliseconds&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this.sessionIdleThresholdMilliseconds,bufferLength:this.buffer.data.length,bufferSize:this.buffer.size}),this._flushBuffer());var i=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)),!this.isIdle){var{windowId:n,sessionId:r}=this.sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),s=this.sessionId!==r,o=this.windowId!==n;this.windowId=n,this.sessionId=r,s||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}):Xn.warn("could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(Zn((()=>this.rrwebRecord.addCustomEvent(e,t))))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(Zn((()=>this.rrwebRecord.takeFullSnapshot())))}_onScriptLoaded(){var e,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(var[n,r]of Object.entries(i||{}))n in t&&("maskInputOptions"===n?t.maskInputOptions=ie({password:!0},r):t[n]=r);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){this.mutationRateLimiter=null!==(e=this.mutationRateLimiter)&&void 0!==e?e:new cn(this.rrwebRecord,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(e,t)=>{var i="Too many mutations on node '".concat(e,"'. Rate limiting. This could be due to SVG animations or something similar");Xn.info(i,{node:t}),this.log(Yn+" "+i,"warn")}});var s=this._gatherRRWebPlugins();this.stopRrweb=this.rrwebRecord(ie({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})}else Xn.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!this.isIdle){var e=this.fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval((()=>{this._tryTakeFullSnapshot()}),e))}}_gatherRRWebPlugins(){var e,t,i,n,r=[],s=null===(e=h.__PosthogExtensions__)||void 0===e||null===(t=e.rrwebPlugins)||void 0===t?void 0:t.getRecordConsolePlugin;s&&this.isConsoleLogCaptureEnabled&&r.push(s());var o=null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.rrwebPlugins)||void 0===n?void 0:n.getRecordNetworkPlugin;this.networkPayloadCapture&&N(o)&&(!vt.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?r.push(o(ln(this.instance.config,this.networkPayloadCapture))):Xn.info("NetworkCapture not started because we are on localhost."));return r}onRRwebEmit(e){var t;if(this._processQueuedEvents(),e&&q(e)){if(e.type===Ei.Meta){var i=this._maskUrl(e.data.href);if(this._lastHref=i,!i)return;e.data.href=i}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),"paused"!==this.status||function(e){return e.type===Ei.Custom&&"recording paused"===e.data.tag}(e)){e.type===Ei.FullSnapshot&&this._scheduleFullSnapshot(),e.type===Ei.FullSnapshot&&"trigger_pending"===this.triggerStatus&&this.clearBuffer();var n=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(e):e;if(n){var r=function(e){var t=e;if(t&&q(t)&&6===t.type&&q(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));for(var i=[],n=0;n<t.data.payload.payload.length;n++)t.data.payload.payload[n]&&t.data.payload.payload[n].length>2e3?i.push(t.data.payload.payload[n].slice(0,2e3)+"...[truncated]"):i.push(t.data.payload.payload[n]);return t.data.payload.payload=i,e}return e}(n);if(this._updateWindowAndSessionIds(r),!this.isIdle||tr(r)){if(tr(r)){var s=r.data.payload;if(s){var o=s.lastActivityTimestamp,a=s.threshold;r.timestamp=o+a}}var l=null===(t=this.instance.config.session_recording.compress_events)||void 0===t||t?function(e){if(wi(e)<1024)return e;try{if(e.type===Ei.FullSnapshot)return ie(ie({},e),{},{data:er(e.data),cv:"2024-10"});if(e.type===Ei.IncrementalSnapshot&&e.data.source===ki.Mutation)return ie(ie({},e),{},{cv:"2024-10",data:ie(ie({},e.data),{},{texts:er(e.data.texts),attributes:er(e.data.attributes),removes:er(e.data.removes),adds:er(e.data.adds)})});if(e.type===Ei.IncrementalSnapshot&&e.data.source===ki.StyleSheetRule)return ie(ie({},e),{},{cv:"2024-10",data:ie(ie({},e.data),{},{adds:er(e.data.adds),removes:er(e.data.removes)})})}catch(e){Xn.error("could not compress event - will use uncompressed event",e)}return e}(r):r,u={$snapshot_bytes:wi(l),$snapshot_data:l,$session_id:this.sessionId,$window_id:this.windowId};"disabled"!==this.status?this._captureSnapshotBuffered(u):this.clearBuffer()}}}}}_pageViewFallBack(){if(!this.instance.config.capture_pageview&&e){var t=this._maskUrl(e.location.href);this._lastHref!==t&&(this._tryAddCustomEvent("$url_changed",{href:t}),this._lastHref=t)}}_processQueuedEvents(){if(this.queuedRRWebEvents.length){var e=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],e.forEach((e=>{Date.now()-e.enqueuedAt<=2e3&&this._tryRRWebMethod(e)}))}}_maskUrl(e){var t=this.instance.config.session_recording;if(t.maskNetworkRequestFn){var i,n={url:e};return null===(i=n=t.maskNetworkRequestFn(n))||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);var e=this.minimumDuration,t=this.sessionDuration,i=G(t)&&t>=0,n=G(e)&&i&&t<e;if("buffering"===this.status||n)return this.flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3),this.buffer;this.buffer.data.length>0&&Si(this.buffer).forEach((e=>{this._captureSnapshot({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId,$lib:"web",$lib_version:_.LIB_VERSION})}));return this.clearBuffer()}_captureSnapshotBuffered(e){var t,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})}_checkUrlTriggerConditions(){if(void 0!==e&&e.location.href){var t=e.location.href,i="paused"===this.status,n=ir(t,this._urlBlocklist);n&&!i?this._pauseRecording():!n&&i&&this._resumeRecording(),ir(t,this._urlTriggers)&&this._activateTrigger("url")}}_activateTrigger(e){var t,i;"trigger_pending"===this.triggerStatus&&(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({["url"===e?Ee:ke]:this.sessionId}),this._flushBuffer(),this._reportStarted(e+"_trigger_matched"))}_pauseRecording(){var e,t;"paused"!==this.status&&(this._urlBlocked=!0,null==o||null===(e=o.body)||void 0===e||null===(t=e.classList)||void 0===t||t.add("ph-no-capture"),clearInterval(this._fullSnapshotTimer),setTimeout((()=>{this._flushBuffer()}),100),Xn.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){var e,t;"paused"===this.status&&(this._urlBlocked=!1,null==o||null===(e=o.body)||void 0===e||null===(t=e.classList)||void 0===t||t.remove("ph-no-capture"),this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),Xn.info("recording resumed"))}_addEventTriggerListener(){0!==this._eventTriggers.length&&W(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",(e=>{try{this._eventTriggers.includes(e.event)&&this._activateTrigger("event")}catch(e){Xn.error("Could not activate event trigger",e)}})))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null===(e=this.instance.persistence)||void 0===e||e.register({[Se]:!0}),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e)}_reportStarted(e,t){this.instance.register_for_session({$session_recording_start_reason:e}),Xn.info(e.replace("_"," "),t),b(["recording_initialized","session_id_changed"],e)||this._tryAddCustomEvent(e,t)}}var rr=Q("[Decide]");class sr{constructor(e){this.instance=e}_loadRemoteConfigJs(e){var t,i,n;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.loadExternalDependency?null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"remote-config",(()=>e(h._POSTHOG_CONFIG))):(rr.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(e){this.instance._send_request({method:"GET",url:this.instance.requestRouter.endpointFor("assets","/array/".concat(this.instance.config.token,"/config")),callback:t=>{e(t.json)}})}load(){if(this.instance.config.__preview_remote_config)return h._POSTHOG_CONFIG?(rr.info("Using preloaded remote config",h._POSTHOG_CONFIG),void this.onRemoteConfig(h._POSTHOG_CONFIG)):void(this.instance.config.advanced_disable_decide?rr.warn("Remote config is disabled. Falling back to local config."):this._loadRemoteConfigJs((e=>{if(!e)return rr.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this.onRemoteConfig(e)}));this.onRemoteConfig(e)})))}onRemoteConfig(e){e?(this.instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this.instance.featureFlags.ensureFlagsLoaded()):rr.error("Failed to fetch remote config from PostHog.")}}var or,ar=null!=e&&e.location?yt(e.location.hash,"__posthog")||yt(location.hash,"state"):null,lr="_postHogToolbarParams";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"}(or||(or={}));class ur{constructor(e){this.instance=e}setToolbarState(e){h.ph_toolbar_state=e}getToolbarState(){var e;return null!==(e=h.ph_toolbar_state)&&void 0!==e?e:or.UNINITIALIZED}maybeLoadToolbar(){var t,i,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if(!e||!o)return!1;n=null!==(t=n)&&void 0!==t?t:e.location,s=null!==(i=s)&&void 0!==i?i:e.history;try{if(!r){try{e.localStorage.setItem("test","test"),e.localStorage.removeItem("test")}catch(e){return!1}r=null==e?void 0:e.localStorage}var a,l=ar||yt(n.hash,"__posthog")||yt(n.hash,"state"),u=l?w((()=>JSON.parse(atob(decodeURIComponent(l)))))||w((()=>JSON.parse(decodeURIComponent(l)))):null;return u&&"ph_authorize"===u.action?((a=u).source="url",a&&Object.keys(a).length>0&&(u.desiredHash?n.hash=u.desiredHash:s?s.replaceState(s.state,"",n.pathname+n.search):n.hash="")):((a=JSON.parse(r.getItem(lr)||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch(e){return!1}}_callLoadToolbar(e){(h.ph_load_toolbar||h.ph_load_editor)(e,this.instance)}loadToolbar(t){var i=!(null==o||!o.getElementById(qe));if(!e||i)return!1;var n="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=ie(ie({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(e.localStorage.setItem(lr,JSON.stringify(ie(ie({},r),{},{source:void 0}))),this.getToolbarState()===or.LOADED)this._callLoadToolbar(r);else if(this.getToolbarState()===or.UNINITIALIZED){var s,a;this.setToolbarState(or.LOADING),null===(s=h.__PosthogExtensions__)||void 0===s||null===(a=s.loadExternalDependency)||void 0===a||a.call(s,this.instance,"toolbar",(e=>{if(e)return K.error("[Toolbar] Failed to load",e),void this.setToolbarState(or.UNINITIALIZED);this.setToolbarState(or.LOADED),this._callLoadToolbar(r)})),C(e,"turbolinks:load",(()=>{this.setToolbarState(or.UNINITIALIZED),this.loadToolbar(r)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(){var 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 cr{constructor(e){ne(this,"isPaused",!0),ne(this,"queue",[]),ne(this,"flushTimeoutMs",3e3),this.sendRequest=e}enqueue(e){this.queue.push(e),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var e=this.queue.length>0?this.formatQueue():{},t=Object.values(e),i=[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))];i.map((e=>{this.sendRequest(ie(ie({},e),{},{transport:"sendBeacon"}))}))}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var e=this;this.isPaused||(this.flushTimeout=setTimeout((()=>{if(this.clearFlushTimeout(),this.queue.length>0){var t=this.formatQueue(),i=function(i){var n=t[i],r=(new Date).getTime();n.data&&D(n.data)&&f(n.data,(e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp})),e.sendRequest(n)};for(var n in t)i(n)}}),this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){var e={};return f(this.queue,(t=>{var i,n=t,r=(n?n.batchKey:null)||n.url;H(e[r])&&(e[r]=ie(ie({},n),{},{data:[]})),null===(i=e[r].data)||void 0===i||i.push(n.data)})),this.queue=[],e}}var dr=!!u||!!l,hr="text/plain",_r=(e,t)=>{var[i,n]=e.split("?"),r=ie({},t);null==n||n.split("&").forEach((e=>{var[t]=e.split("=");delete r[t]}));var s=mt(r);return s=s?(n?n+"&":"")+s:n,"".concat(i,"?").concat(s)},pr=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),vr=e=>{var{data:t,compression:i}=e;if(t){if(i===R.GZipJS){var n=Vn(Jn(pr(t)),{mtime:0}),r=new Blob([n],{type:hr});return{contentType:hr,body:r,estimatedSize:r.size}}if(i===R.Base64){var s=function(e){var t,i,n,r,s,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,u="",c=[];if(!e)return e;e=I(e);do{t=(s=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=s>>12&63,n=s>>6&63,r=63&s,c[l++]=o.charAt(t)+o.charAt(i)+o.charAt(n)+o.charAt(r)}while(a<e.length);switch(u=c.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u}(pr(t)),o=(e=>"data="+encodeURIComponent("string"==typeof e?e:pr(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=pr(t);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},gr=[];u&&gr.push({transport:"XHR",method:e=>{var t,i=new u;i.open(e.method||"GET",e.url,!0);var{contentType:n,body:r}=null!==(t=vr(e))&&void 0!==t?t:{};f(e.headers,(function(e,t){i.setRequestHeader(t,e)})),n&&i.setRequestHeader("Content-Type",n),e.timeout&&(i.timeout=e.timeout),i.withCredentials=!0,i.onreadystatechange=()=>{if(4===i.readyState){var t,n={statusCode:i.status,text:i.responseText};if(200===i.status)try{n.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,n)}},i.send(r)}}),l&&gr.push({transport:"fetch",method:e=>{var t,i,{contentType:n,body:r,estimatedSize:s}=null!==(t=vr(e))&&void 0!==t?t:{},o=new Headers;f(e.headers,(function(e,t){o.append(t,e)})),n&&o.append("Content-Type",n);var a=e.url,u=null;if(c){var d=new c;u={signal:d.signal,timeout:setTimeout((()=>d.abort()),e.timeout)}}l(a,ie({method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(s||0)<52428.8,body:r,signal:null===(i=u)||void 0===i?void 0:i.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var n,r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){K.error(e)}null===(n=e.callback)||void 0===n||n.call(e,r)})))).catch((t=>{var i;K.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,text:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),null!=s&&s.sendBeacon&&gr.push({transport:"sendBeacon",method:e=>{var t=_r(e.url,{beacon:"1"});try{var i,{contentType:n,body:r}=null!==(i=vr(e))&&void 0!==i?i:{},o="string"==typeof r?new Blob([r],{type:n}):r;s.sendBeacon(t,o)}catch(e){}}});var fr=["retriesPerformedSoFar"];class mr{constructor(t){ne(this,"isPolling",!1),ne(this,"pollIntervalMs",3e3),ne(this,"queue",[]),this.instance=t,this.queue=[],this.areWeOnline=!0,!H(e)&&"onLine"in e.navigator&&(this.areWeOnline=e.navigator.onLine,e.addEventListener("online",(()=>{this.areWeOnline=!0,this.flush()})),e.addEventListener("offline",(()=>{this.areWeOnline=!1})))}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=re(e,fr);G(t)&&t>0&&(i.url=_r(i.url,{retry_count:t})),this.instance._send_request(ie(ie({},i),{},{callback:e=>{var n;200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this.enqueue(ie({retriesPerformedSoFar:t},i)):null===(n=i.callback)||void 0===n||n.call(i,e)}}))}enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,n=Math.min(18e5,t),r=(Math.random()-.5)*(n-i);return Math.ceil(n+r)}(t),n=Date.now()+i;this.queue.push({retryAt:n,requestOptions:e});var r="Enqueued failed request for retry in ".concat(i);navigator.onLine||(r+=" (Browser is offline)"),K.warn(r),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout((()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()}),this.pollIntervalMs)}flush(){var e=Date.now(),t=[],i=this.queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this.queue=t,i.length>0)for(var{requestOptions:n}of i)this.retriableRequest(n)}unload(){for(var{requestOptions:e}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(ie(ie({},e),{},{transport:"sendBeacon"}))}catch(e){K.error(e)}this.queue=[]}}var br,yr=Q("[SessionId]");class wr{constructor(e,t,i){var n;if(ne(this,"_sessionIdChangedHandlers",[]),!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.__preview_experimental_cookieless_mode)throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");this.config=e.config,this.persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||et,this._windowIdGenerator=i||et;var r=this.config.persistence_name||this.config.token,s=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*un(s,60,36e3,"session_idle_timeout_seconds",1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var o=pt.parse(this._window_id_storage_key),a=pt.parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:pt.remove(this._window_id_storage_key),pt.set(this._primary_window_exists_storage_key,!0)}if(null!==(n=this.config.bootstrap)&&void 0!==n&&n.sessionID)try{var l=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,(new Date).getTime(),l)}catch(e){yr.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return H(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&&pt.is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&pt.set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?pt.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({[we]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this.persistence.props[we];return D(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){null==e||e.addEventListener("beforeunload",(()=>{this._canUseSessionStorage()&&pt.remove(this._primary_window_exists_storage_key)}))}checkAndGetSessionAndWindowId(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.config.__preview_experimental_cookieless_mode)throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");var i=t||(new Date).getTime(),[n,r,s]=this._getSessionId(),o=this._getWindowId(),a=G(s)&&s>0&&Math.abs(i-s)>864e5,l=!1,u=!r,c=!e&&Math.abs(i-n)>this.sessionTimeoutMs;u||c||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),yr.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}}),s=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=0===n||!e||a?i:n,h=0===s?(new Date).getTime():s;return this._setWindowId(o),this._setSessionId(r,d,h),l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:h,changeReason:l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:n}}}!function(e){e.US="us",e.EU="eu",e.CUSTOM="custom"}(br||(br={}));var Sr="i.posthog.com";class Er{constructor(e){ne(this,"_regionCache",{}),this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e,t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(".".concat(Sr),".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]=br.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=br.EU:this._regionCache[this.apiHost]=br.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t&&(t="/"===t[0]?t:"/".concat(t)),"ui"===e)return this.uiHost+t;if(this.region===br.CUSTOM)return this.apiHost+t;var i=Sr+t;switch(e){case"assets":return"https://".concat(this.region,"-assets.").concat(i);case"api":return"https://".concat(this.region,".").concat(i)}}}var kr="posthog-js";function xr(e){var{organization:t,projectId:i,prefix:n,severityAllowList:r=["error"]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s=>{var o,a,l,u,c;if(!("*"===r||r.includes(s.level))||!e.__loaded)return s;s.tags||(s.tags={});var d=e.requestRouter.endpointFor("ui","/project/".concat(e.config.token,"/person/").concat(e.get_distinct_id()));s.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(s.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var h=(null===(o=s.exception)||void 0===o?void 0:o.values)||[];h.map((e=>{e.stacktrace&&(e.stacktrace.type="raw")}));var _={$exception_message:(null===(a=h[0])||void 0===a?void 0:a.value)||s.message,$exception_type:null===(l=h[0])||void 0===l?void 0:l.type,$exception_personURL:d,$exception_level:s.level,$exception_list:h,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:(null===(u=h[0])||void 0===u?void 0:u.value)||s.message,$sentry_exception_type:null===(c=h[0])||void 0===c?void 0:c.type,$sentry_tags:s.tags};return t&&i&&(_.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+s.event_id),e.exceptions.sendExceptionEvent(_),s}}class Ir{constructor(e,t,i,n,r){this.name=kr,this.setupOnce=function(s){s(xr(e,{organization:t,projectId:i,prefix:n,severityAllowList:r}))}}}var Cr,Pr,Rr,Fr=Q("[SegmentIntegration]");function Tr(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var n=i=>{var n=()=>i.anonymousId()||et();e.config.get_device_id=n,i.id()&&(e.register({distinct_id:i.id(),$device_id:n()}),e.persistence.set_property($e,"identified")),t()},r=i.user();"then"in r&&N(r.then)?r.then((e=>n(e))):n(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||Fr.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{var n;if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Fr.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Fr.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e._calculate_event_properties(i,null!==(n=t.event.properties)&&void 0!==n?n:{},new Date);return t.event.properties=Object.assign({},r,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 $r{constructor(e){this._instance=e}doPageView(t){var i,n=this._previousPageViewProperties(t);return this._currentPath=null!==(i=null==e?void 0:e.location.pathname)&&void 0!==i?i:"",this._instance.scrollManager.resetContext(),this._prevPageviewTimestamp=t,n}doPageLeave(e){return this._previousPageViewProperties(e)}_previousPageViewProperties(e){var t=this._currentPath,i=this._prevPageviewTimestamp,n=this._instance.scrollManager.getContext();if(!i)return{};var r={};if(n){var{maxScrollHeight:s,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=n;if(!(H(s)||H(o)||H(a)||H(l)||H(u)||H(c)))s=Math.ceil(s),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),r={$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:s<=1?1:un(o/s,0,1),$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:s<=1?1:un(a/s,0,1),$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:l<=1?1:un(u/l,0,1),$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:l<=1?1:un(c/l,0,1)}}return t&&(r.$prev_pageview_pathname=t),i&&(r.$prev_pageview_duration=(e.getTime()-i.getTime())/1e3),r}}!function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(Cr||(Cr={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(Pr||(Pr={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(Rr||(Rr={}));class Or{constructor(){ne(this,"events",{}),this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this.events[e]||[])i(t);for(var n of this.events["*"]||[])n(e,t)}}class Lr{constructor(e){ne(this,"_debugEventEmitter",new Or),ne(this,"checkStep",((e,t)=>this.checkStepEvent(e,t)&&this.checkStepUrl(e,t)&&this.checkStepElement(e,t))),ne(this,"checkStepEvent",((e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event))),this.instance=e,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var e;if(!H(null===(e=this.instance)||void 0===e?void 0:e._addCaptureHook)){var t;null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!H(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 n,r=new Set;e.forEach((e=>{var t;null===(t=e.steps)||void 0===t||t.forEach((e=>{null!=e&&e.selector&&r.add(null==e?void 0:e.selector)}))})),null===(n=this.instance)||void 0===n||n.autocapture.setElementSelectors(r)}}on(e,t){var i;null!=t&&0!=e.length&&(this.actionEvents.has(e)||this.actionEvents.has(null==t?void 0:t.event))&&this.actionRegistry&&(null===(i=this.actionRegistry)||void 0===i?void 0:i.size)>0&&this.actionRegistry.forEach((e=>{this.checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this.checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}checkStepUrl(e,t){if(null!=t&&t.url){var i,n=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!n||"string"!=typeof n)return!1;if(!Lr.matchString(n,null==t?void 0:t.url,(null==t?void 0:t.url_matching)||"contains"))return!1}return!0}static matchString(t,i,n){switch(n){case"regex":return!!e&&ft(t,i);case"exact":return i===t;case"contains":var r=Lr.escapeStringRegexp(i).replace(/_/g,".").replace(/%/g,".*");return ft(t,r);default:return!1}}static escapeStringRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}checkStepElement(e,t){if((null!=t&&t.href||null!=t&&t.tag_name||null!=t&&t.text)&&!this.getElementsList(e).some((e=>!(null!=t&&t.href&&!Lr.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&&!Lr.matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!Lr.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,n=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(!n)return!1;if(!n.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 Mr{constructor(e){this.instance=e,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(e){var t;H(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)||(this.setupEventBasedSurveys(e),this.setupActionBasedSurveys(e))}setupActionBasedSurveys(e){var t=e.filter((e=>{var t,i,n,r;return(null===(t=e.conditions)||void 0===t?void 0:t.actions)&&(null===(i=e.conditions)||void 0===i||null===(n=i.actions)||void 0===n||null===(r=n.values)||void 0===r?void 0:r.length)>0}));if(0!==t.length){if(null==this.actionMatcher){this.actionMatcher=new Lr(this.instance),this.actionMatcher.init();this.actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,n,r,s,o,a,l,u,c;e.conditions&&null!==(t=e.conditions)&&void 0!==t&&t.actions&&null!==(i=e.conditions)&&void 0!==i&&null!==(n=i.actions)&&void 0!==n&&n.values&&(null===(r=e.conditions)||void 0===r||null===(s=r.actions)||void 0===s||null===(o=s.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===(u=l.actions)||void 0===u||null===(c=u.values)||void 0===c||c.forEach((t=>{if(t&&t.name){var i=this.actionToSurveys.get(t.name);i&&i.push(e.id),this.actionToSurveys.set(t.name,i||[e.id])}})))}))}}setupEventBasedSurveys(e){var t;if(0!==e.filter((e=>{var t,i,n,r;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(n=i.events)||void 0===n||null===(r=n.values)||void 0===r?void 0:r.length)>0})).length){null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t,i,n;null===(t=e.conditions)||void 0===t||null===(i=t.events)||void 0===i||null===(n=i.values)||void 0===n||n.forEach((t=>{if(t&&t.name){var i=this.eventToSurveys.get(t.name);i&&i.push(e.id),this.eventToSurveys.set(t.name,i||[e.id])}}))}))}}onEvent(e,t){var i,n,r=(null===(i=this.instance)||void 0===i||null===(n=i.persistence)||void 0===n?void 0:n.props[Fe])||[];if(Mr.SURVEY_SHOWN_EVENT_NAME==e&&t&&r.length>0){var s,o=null==t||null===(s=t.properties)||void 0===s?void 0:s.$survey_id;if(o){var a=r.indexOf(o);a>=0&&(r.splice(a,1),this._updateActivatedSurveys(r))}}else this.eventToSurveys.has(e)&&this._updateActivatedSurveys(r.concat(this.eventToSurveys.get(e)||[]))}onAction(e){var t,i,n=(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i?void 0:i.props[Fe])||[];this.actionToSurveys.has(e)&&this._updateActivatedSurveys(n.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({[Fe]:[...new Set(e)]})}getSurveys(){var e,t,i=null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t?void 0:t.props[Fe];return i||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}ne(Mr,"SURVEY_SHOWN_EVENT_NAME","survey shown");var Ar,Dr,Nr,qr,Br,Hr,Ur,zr,jr={},Wr=[],Gr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Vr=Array.isArray;function Jr(e,t){for(var i in t)e[i]=t[i];return e}function Yr(e){var t=e.parentNode;t&&t.removeChild(e)}function Xr(e,t,i,n,r){var s={type:e,props:t,key:i,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++Nr:r,__i:-1,__u:0};return null==r&&null!=Dr.vnode&&Dr.vnode(s),s}function Kr(e){return e.children}function Qr(e,t){this.props=e,this.context=t}function Zr(e,t){if(null==t)return e.__?Zr(e.__,e.__i+1):null;for(var i;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e)return i.__e;return"function"==typeof e.type?Zr(e):null}function es(e){var t,i;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e){e.__e=e.__c.base=i.__e;break}return es(e)}}function ts(e){(!e.__d&&(e.__d=!0)&&qr.push(e)&&!is.__r++||Br!==Dr.debounceRendering)&&((Br=Dr.debounceRendering)||Hr)(is)}function is(){var e,t,i,n,r,s,o,a,l;for(qr.sort(Ur);e=qr.shift();)e.__d&&(t=qr.length,n=void 0,s=(r=(i=e).__v).__e,a=[],l=[],(o=i.__P)&&((n=Jr({},r)).__v=r.__v+1,Dr.vnode&&Dr.vnode(n),ds(o,n,r,i.__n,void 0!==o.ownerSVGElement,32&r.__u?[s]:null,a,null==s?Zr(r):s,!!(32&r.__u),l),n.__.__k[n.__i]=n,hs(a,n,l),n.__e!=s&&es(n)),qr.length>t&&qr.sort(Ur));is.__r=0}function ns(e,t,i,n,r,s,o,a,l,u,c){var d,h,_,p,v,g=n&&n.__k||Wr,f=t.length;for(i.__d=l,rs(i,t,g),l=i.__d,d=0;d<f;d++)null!=(_=i.__k[d])&&"boolean"!=typeof _&&"function"!=typeof _&&(h=-1===_.__i?jr:g[_.__i]||jr,_.__i=d,ds(e,_,h,r,s,o,a,l,u,c),p=_.__e,_.ref&&h.ref!=_.ref&&(h.ref&&ps(h.ref,null,_),c.push(_.ref,_.__c||p,_)),null==v&&null!=p&&(v=p),65536&_.__u||h.__k===_.__k?l=ss(_,l,e):"function"==typeof _.type&&void 0!==_.__d?l=_.__d:p&&(l=p.nextSibling),_.__d=void 0,_.__u&=-196609);i.__d=l,i.__e=v}function rs(e,t,i){var n,r,s,o,a,l=t.length,u=i.length,c=u,d=0;for(e.__k=[],n=0;n<l;n++)null!=(r=e.__k[n]=null==(r=t[n])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?Xr(null,r,null,null,r):Vr(r)?Xr(Kr,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?Xr(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=e,r.__b=e.__b+1,a=os(r,i,o=n+d,c),r.__i=a,s=null,-1!==a&&(c--,(s=i[a])&&(s.__u|=131072)),null==s||null===s.__v?(-1==a&&d--,"function"!=typeof r.type&&(r.__u|=65536)):a!==o&&(a===o+1?d++:a>o?c>l-o?d+=a-o:d--:d=a<o&&a==o-1?a-o:0,a!==n+d&&(r.__u|=65536))):(s=i[n])&&null==s.key&&s.__e&&(s.__e==e.__d&&(e.__d=Zr(s)),vs(s,s,!1),i[n]=null,c--);if(c)for(n=0;n<u;n++)null!=(s=i[n])&&0==(131072&s.__u)&&(s.__e==e.__d&&(e.__d=Zr(s)),vs(s,s))}function ss(e,t,i){var n,r;if("function"==typeof e.type){for(n=e.__k,r=0;n&&r<n.length;r++)n[r]&&(n[r].__=e,t=ss(n[r],t,i));return t}return e.__e!=t&&(i.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function os(e,t,i,n){var r=e.key,s=e.type,o=i-1,a=i+1,l=t[i];if(null===l||l&&r==l.key&&s===l.type)return i;if(n>(null!=l&&0==(131072&l.__u)?1:0))for(;o>=0||a<t.length;){if(o>=0){if((l=t[o])&&0==(131072&l.__u)&&r==l.key&&s===l.type)return o;o--}if(a<t.length){if((l=t[a])&&0==(131072&l.__u)&&r==l.key&&s===l.type)return a;a++}}return-1}function as(e,t,i){"-"===t[0]?e.setProperty(t,null==i?"":i):e[t]=null==i?"":"number"!=typeof i||Gr.test(t)?i:i+"px"}function ls(e,t,i,n,r){var s;e:if("style"===t)if("string"==typeof i)e.style.cssText=i;else{if("string"==typeof n&&(e.style.cssText=n=""),n)for(t in n)i&&t in i||as(e.style,t,"");if(i)for(t in i)n&&i[t]===n[t]||as(e.style,t,i[t])}else if("o"===t[0]&&"n"===t[1])s=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=i,i?n?i.u=n.u:(i.u=Date.now(),e.addEventListener(t,s?cs:us,s)):e.removeEventListener(t,s?cs:us,s);else{if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null==i||!1===i&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,i))}}function us(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Dr.event?Dr.event(e):e)}function cs(e){return this.l[e.type+!0](Dr.event?Dr.event(e):e)}function ds(e,t,i,n,r,s,o,a,l,u){var c,d,h,_,p,v,g,f,m,b,y,w,S,E,k,x=t.type;if(void 0!==t.constructor)return null;128&i.__u&&(l=!!(32&i.__u),s=[a=t.__e=i.__e]),(c=Dr.__b)&&c(t);e:if("function"==typeof x)try{if(f=t.props,m=(c=x.contextType)&&n[c.__c],b=c?m?m.props.value:c.__:n,i.__c?g=(d=t.__c=i.__c).__=d.__E:("prototype"in x&&x.prototype.render?t.__c=d=new x(f,b):(t.__c=d=new Qr(f,b),d.constructor=x,d.render=gs),m&&m.sub(d),d.props=f,d.state||(d.state={}),d.context=b,d.__n=n,h=d.__d=!0,d.__h=[],d._sb=[]),null==d.__s&&(d.__s=d.state),null!=x.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=Jr({},d.__s)),Jr(d.__s,x.getDerivedStateFromProps(f,d.__s))),_=d.props,p=d.state,d.__v=t,h)null==x.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(null==x.getDerivedStateFromProps&&f!==_&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(f,b),!d.__e&&(null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(f,d.__s,b)||t.__v===i.__v)){for(t.__v!==i.__v&&(d.props=f,d.state=d.__s,d.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.forEach((function(e){e&&(e.__=t)})),y=0;y<d._sb.length;y++)d.__h.push(d._sb[y]);d._sb=[],d.__h.length&&o.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(f,d.__s,b),null!=d.componentDidUpdate&&d.__h.push((function(){d.componentDidUpdate(_,p,v)}))}if(d.context=b,d.props=f,d.__P=e,d.__e=!1,w=Dr.__r,S=0,"prototype"in x&&x.prototype.render){for(d.state=d.__s,d.__d=!1,w&&w(t),c=d.render(d.props,d.state,d.context),E=0;E<d._sb.length;E++)d.__h.push(d._sb[E]);d._sb=[]}else do{d.__d=!1,w&&w(t),c=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(n=Jr(Jr({},n),d.getChildContext())),h||null==d.getSnapshotBeforeUpdate||(v=d.getSnapshotBeforeUpdate(_,p)),ns(e,Vr(k=null!=c&&c.type===Kr&&null==c.key?c.props.children:c)?k:[k],t,i,n,r,s,o,a,l,u),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),g&&(d.__E=d.__=null)}catch(e){t.__v=null,l||null!=s?(t.__e=a,t.__u|=l?160:32,s[s.indexOf(a)]=null):(t.__e=i.__e,t.__k=i.__k),Dr.__e(e,t,i)}else null==s&&t.__v===i.__v?(t.__k=i.__k,t.__e=i.__e):t.__e=_s(i.__e,t,i,n,r,s,o,l,u);(c=Dr.diffed)&&c(t)}function hs(e,t,i){t.__d=void 0;for(var n=0;n<i.length;n++)ps(i[n],i[++n],i[++n]);Dr.__c&&Dr.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){Dr.__e(e,t.__v)}}))}function _s(e,t,i,n,r,s,o,a,l){var u,c,d,h,_,p,v,g=i.props,f=t.props,m=t.type;if("svg"===m&&(r=!0),null!=s)for(u=0;u<s.length;u++)if((_=s[u])&&"setAttribute"in _==!!m&&(m?_.localName===m:3===_.nodeType)){e=_,s[u]=null;break}if(null==e){if(null===m)return document.createTextNode(f);e=r?document.createElementNS("http://www.w3.org/2000/svg",m):document.createElement(m,f.is&&f),s=null,a=!1}if(null===m)g===f||a&&e.data===f||(e.data=f);else{if(s=s&&Ar.call(e.childNodes),g=i.props||jr,!a&&null!=s)for(g={},u=0;u<e.attributes.length;u++)g[(_=e.attributes[u]).name]=_.value;for(u in g)_=g[u],"children"==u||("dangerouslySetInnerHTML"==u?d=_:"key"===u||u in f||ls(e,u,null,_,r));for(u in f)_=f[u],"children"==u?h=_:"dangerouslySetInnerHTML"==u?c=_:"value"==u?p=_:"checked"==u?v=_:"key"===u||a&&"function"!=typeof _||g[u]===_||ls(e,u,_,g[u],r);if(c)a||d&&(c.__html===d.__html||c.__html===e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(d&&(e.innerHTML=""),ns(e,Vr(h)?h:[h],t,i,n,r&&"foreignObject"!==m,s,o,s?s[0]:i.__k&&Zr(i,0),a,l),null!=s)for(u=s.length;u--;)null!=s[u]&&Yr(s[u]);a||(u="value",void 0!==p&&(p!==e[u]||"progress"===m&&!p||"option"===m&&p!==g[u])&&ls(e,u,p,g[u],!1),u="checked",void 0!==v&&v!==e[u]&&ls(e,u,v,g[u],!1))}return e}function ps(e,t,i){try{"function"==typeof e?e(t):e.current=t}catch(e){Dr.__e(e,i)}}function vs(e,t,i){var n,r;if(Dr.unmount&&Dr.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||ps(n,null,t)),null!=(n=e.__c)){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(e){Dr.__e(e,t)}n.base=n.__P=null,e.__c=void 0}if(n=e.__k)for(r=0;r<n.length;r++)n[r]&&vs(n[r],t,i||"function"!=typeof e.type);i||null==e.__e||Yr(e.__e),e.__=e.__e=e.__d=void 0}function gs(e,t,i){return this.constructor(e,i)}Ar=Wr.slice,Dr={__e:function(e,t,i,n){for(var r,s,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((s=r.constructor)&&null!=s.getDerivedStateFromError&&(r.setState(s.getDerivedStateFromError(e)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,n||{}),o=r.__d),o)return r.__E=r}catch(t){e=t}throw e}},Nr=0,Qr.prototype.setState=function(e,t){var i;i=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=Jr({},this.state),"function"==typeof e&&(e=e(Jr({},i),this.props)),e&&Jr(i,e),null!=e&&this.__v&&(t&&this._sb.push(t),ts(this))},Qr.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ts(this))},Qr.prototype.render=Kr,qr=[],Hr="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ur=function(e,t){return e.__v.__b-t.__v.__b},is.__r=0,zr=0;!function(e,t){var i={__c:t="__cC"+zr++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var i,n;return this.getChildContext||(i=[],(n={})[t]=this,this.getChildContext=function(){return n},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&i.some((function(e){e.__e=!0,ts(e)}))},this.sub=function(e){i.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){i.splice(i.indexOf(e),1),t&&t.call(e)}}),e.children}};i.Provider.__=i.Consumer.contextType=i}({isPreviewMode:!1,previewPageIndex:0,handleCloseSurveyPopup:()=>{},isPopup:!0});var fs=Q("[Surveys]"),ms={icontains:t=>!!e&&e.location.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:t=>!!e&&-1===e.location.href.toLowerCase().indexOf(t.toLowerCase()),regex:t=>!!e&&ft(e.location.href,t),not_regex:t=>!!e&&!ft(e.location.href,t),exact:t=>(null==e?void 0:e.location.href)===t,is_not:t=>(null==e?void 0:e.location.href)!==t};class bs{constructor(e){this.instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){this._decideServerResponse=!!e.surveys,this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var e=(()=>{for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);null!=i&&i.startsWith("seenSurvey_")&&e.push(i)}return e})();e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){var e,t,i,n=null==h||null===(e=h.__PosthogExtensions__)||void 0===e?void 0:e.generateSurveys;this.instance.config.disable_surveys||!this._decideServerResponse||n||(null==this._surveyEventReceiver&&(this._surveyEventReceiver=new Mr(this.instance)),null===(t=h.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"surveys",(e=>{var t,i;if(e)return fs.error("Could not load surveys script",e);this._surveyManager=null===(t=h.__PosthogExtensions__)||void 0===t||null===(i=t.generateSurveys)||void 0===i?void 0:i.call(t,this.instance)})))}getSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.instance.config.disable_surveys)return e([]);null==this._surveyEventReceiver&&(this._surveyEventReceiver=new Mr(this.instance));var i=this.instance.get_property(Re);if(i&&!t)return e(i);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",transport:"XHR",callback:t=>{var i;if(200!==t.statusCode||!t.json)return e([]);var n,r=t.json.surveys||[],s=r.filter((e=>{var t,i,n,r,s,o,a,l,u,c,d,h;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(n=i.events)||void 0===n?void 0:n.values)&&(null===(r=e.conditions)||void 0===r||null===(s=r.events)||void 0===s||null===(o=s.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===(u=l.actions)||void 0===u?void 0:u.values)&&(null===(c=e.conditions)||void 0===c||null===(d=c.actions)||void 0===d||null===(h=d.values)||void 0===h?void 0:h.length)>0}));s.length>0&&(null===(n=this._surveyEventReceiver)||void 0===n||n.register(s));return null===(i=this.instance.persistence)||void 0===i||i.register({[Re]:r}),e(r)}})}getActiveMatchingSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.getSurveys((t=>{var i,n=t.filter((e=>!(!e.start_date||e.end_date))).filter((e=>{var t,i,n,r;if(!e.conditions)return!0;var s=null===(t=e.conditions)||void 0===t||!t.url||ms[null!==(i=null===(n=e.conditions)||void 0===n?void 0:n.urlMatchType)&&void 0!==i?i:"icontains"](e.conditions.url),a=null===(r=e.conditions)||void 0===r||!r.selector||(null==o?void 0:o.querySelector(e.conditions.selector));return s&&a})),r=null===(i=this._surveyEventReceiver)||void 0===i?void 0:i.getSurveys(),s=n.filter((e=>{var t,i,n,s,o,a,l,u,c,d,h;if(!(e.linked_flag_key||e.targeting_flag_key||e.internal_targeting_flag_key||null!==(t=e.feature_flag_keys)&&void 0!==t&&t.length))return!0;var _=!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),v=(null===(i=e.conditions)||void 0===i?void 0:i.events)&&(null===(n=e.conditions)||void 0===n||null===(s=n.events)||void 0===s?void 0:s.values)&&(null===(o=e.conditions)||void 0===o||null===(a=o.events)||void 0===a?void 0:a.values.length)>0,g=(null===(l=e.conditions)||void 0===l?void 0:l.actions)&&(null===(u=e.conditions)||void 0===u||null===(c=u.actions)||void 0===c?void 0:c.values)&&(null===(d=e.conditions)||void 0===d||null===(h=d.actions)||void 0===h?void 0:h.values.length)>0,f=!v&&!g||(null==r?void 0:r.includes(e.id)),m=this._canActivateRepeatedly(e),b=!(e.internal_targeting_flag_key&&!m)||this.instance.featureFlags.isFeatureEnabled(e.internal_targeting_flag_key),y=this.checkFlags(e);return _&&p&&b&&f&&y}));return e(s)}),t)}checkFlags(e){var t;return null===(t=e.feature_flag_keys)||void 0===t||!t.length||e.feature_flag_keys.every((e=>{var{key:t,value:i}=e;return!t||!i||this.instance.featureFlags.isFeatureEnabled(i)}))}getNextSurveyStep(e,t,i){var n,r=e.questions[t],s=t+1;if(null===(n=r.branching)||void 0===n||!n.type)return t===e.questions.length-1?Rr.End:s;if(r.branching.type===Rr.End)return Rr.End;if(r.branching.type===Rr.SpecificQuestion){if(Number.isInteger(r.branching.index))return r.branching.index}else if(r.branching.type===Rr.ResponseBased){if(r.type===Pr.SingleChoice){var o,a,l=r.choices.indexOf("".concat(i));if(null!==(o=r.branching)&&void 0!==o&&null!==(a=o.responseValues)&&void 0!==a&&a.hasOwnProperty(l)){var u=r.branching.responseValues[l];return Number.isInteger(u)?u:u===Rr.End?Rr.End:s}}else if(r.type===Pr.Rating){var c,d;if("number"!=typeof i||!Number.isInteger(i))throw new Error("The response type must be an integer");var h=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,r.scale);if(null!==(c=r.branching)&&void 0!==c&&null!==(d=c.responseValues)&&void 0!==d&&d.hasOwnProperty(h)){var _=r.branching.responseValues[h];return Number.isInteger(_)?_:_===Rr.End?Rr.End:s}}return s}return fs.warn("Falling back to next question index due to unexpected branching type"),s}_canActivateRepeatedly(e){var t;return W(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.canActivateRepeatedly)?(fs.warn("init was not called"),!1):h.__PosthogExtensions__.canActivateRepeatedly(e)}canRenderSurvey(e){W(this._surveyManager)?fs.warn("init was not called"):this.getSurveys((t=>{var i=t.filter((t=>t.id===e))[0];this._surveyManager.canRenderSurvey(i)}))}renderSurvey(e,t){W(this._surveyManager)?fs.warn("init was not called"):this.getSurveys((i=>{var n=i.filter((t=>t.id===e))[0];this._surveyManager.renderSurvey(n,null==o?void 0:o.querySelector(t))}))}}var ys=Q("[RateLimiter]");class ws{constructor(e){var t,i;ne(this,"serverLimits",{}),ne(this,"lastEventRateLimited",!1),ne(this,"checkForLimiting",(e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{ys.info("".concat(e||"events"," is quota limited.")),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void ys.warn('could not rate limit - continuing. Error: "'.concat(null==e?void 0:e.message,'"'),{text:t})}})),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,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=(new Date).getTime(),s=null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_property(Le))&&void 0!==e?e:{tokens:this.captureEventsBurstLimit,last:r};s.tokens+=(r-s.last)/1e3*this.captureEventsPerSecond,s.last=r,s.tokens>this.captureEventsBurstLimit&&(s.tokens=this.captureEventsBurstLimit);var o=s.tokens<1;return o||n||(s.tokens=Math.max(0,s.tokens-1)),!o||this.lastEventRateLimited||n||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,null===(i=this.instance.persistence)||void 0===i||i.set_property(Le,s),{isRateLimited:o,remainingTokens:s.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Ss=()=>ie({initialPathName:(null==a?void 0:a.pathname)||"",referringDomain:mi.referringDomain()},mi.campaignParams());class Es{constructor(e,t,i){ne(this,"_onSessionIdCallback",(e=>{var t=this._getStoredProps();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator()};this._persistence.register({[Oe]:i})}})),this._sessionIdManager=e,this._persistence=t,this._sessionSourceParamGenerator=i||Ss,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStoredProps(){return this._persistence.props[Oe]}getSessionProps(){var e,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}:{}}}var ks=["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;"],xs=function(e,t){if(!e)return!1;var i=e.toLowerCase();return ks.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},Is=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&xs(i,t))return!0;try{var n=null==e?void 0:e.userAgentData;if(null!=n&&n.brands&&n.brands.some((e=>xs(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};class Cs{constructor(){this.clicks=[]}isRageClick(e,t,i){var n=this.clicks[this.clicks.length-1];if(n&&Math.abs(e-n.x)+Math.abs(t-n.y)<30&&i-n.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:i}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var Ps=Q("[Dead Clicks]"),Rs=()=>!0,Fs=e=>{var t,i=!(null===(t=e.instance.persistence)||void 0===t||!t.get_property(he)),n=e.instance.config.capture_dead_clicks;return V(n)?n:i};class Ts{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[he]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript((()=>{this.start()}))}loadScript(e){var t,i,n;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.initDeadClicksAutocapture&&e(),null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"dead-clicks-autocapture",(t=>{t?Ps.error("failed to load script",t):e()}))}start(){var e;if(o){if(!this._lazyLoadedDeadClicksAutocapture&&null!==(e=h.__PosthogExtensions__)&&void 0!==e&&e.initDeadClicksAutocapture){var t=q(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=h.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(o),Ps.info("starting...")}}else Ps.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Ps.info("stopping..."))}}var $s=Q("[Heatmaps]");class Os{constructor(t){var i;ne(this,"rageclicks",new Cs),ne(this,"_enabledServerSide",!1),ne(this,"_initialized",!1),ne(this,"_flushInterval",null),this.instance=t,this._enabledServerSide=!(null===(i=this.instance.persistence)||void 0===i||!i.props[ue]),null==e||e.addEventListener("beforeunload",(()=>{this.flush()}))}get flushIntervalMilliseconds(){var e=5e3;return q(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return H(this.instance.config.capture_heatmaps)?H(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;$s.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),null===(t=this.deadClicksCapture)||void 0===t||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ue]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.buffer;return this.buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_setupListeners(){e&&o&&(C(o,"click",(t=>this._onClick(t||(null==e?void 0:e.event))),!1,!0),C(o,"mousemove",(t=>this._onMouseMove(t||(null==e?void 0:e.event))),!1,!0),this.deadClicksCapture=new Ts(this.instance,Rs,this._onDeadClick.bind(this)),this.deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(t,i){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=function(t,i,n){for(var r=t;r&&Ii(r)&&!Ci(r,"body");){if(r===n)return!1;if(b(i,null==e?void 0:e.getComputedStyle(r).position))return!0;r=Di(r)}return!1}(Mi(t),["fixed","sticky"],s);return{x:t.clientX+(o?0:r),y:t.clientY+(o?0:n),target_fixed:o,type:i}}_onClick(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"click";if(!xi(e.target)){var n=this._getProperties(e,i);null!==(t=this.rageclicks)&&void 0!==t&&t.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(ie(ie({},n),{},{type:"rageclick"})),this._capture(n)}}_onMouseMove(e){xi(e.target)||(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(t){if(e){var i=e.location.href;this.buffer=this.buffer||{},this.buffer[i]||(this.buffer[i]=[]),this.buffer[i].push(t)}}flush(){this.buffer&&!B(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Ls{constructor(e){ne(this,"_updateScrollData",(()=>{var e,t,i,n;this.context||(this.context={});var r=this.scrollElement(),s=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=s+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this.context.lastScrollY=Math.ceil(s),this.context.maxScrollY=Math.max(s,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!==(n=this.context.maxContentHeight)&&void 0!==n?n:0)})),this.instance=e}getContext(){return this.context}resetContext(){var e=this.context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){null==e||e.addEventListener("scroll",this._updateScrollData,!0),null==e||e.addEventListener("scrollend",this._updateScrollData,!0),null==e||e.addEventListener("resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return null==e?void 0:e.document.documentElement;var t=D(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(var i of t){var n=null==e?void 0:e.document.querySelector(i);if(n)return n}}scrollY(){if(this.instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollTop||0}return e&&(e.scrollY||e.pageYOffset||e.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollLeft||0}return e&&(e.scrollX||e.pageXOffset||e.document.documentElement.scrollLeft)||0}}var Ms=Q("[AutoCapture]");function As(e,t){return t.length>e?t.slice(0,e)+"...":t}function Ds(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Ii(t));return t}function Ns(e,t,i,n){var r=e.tagName.toLowerCase(),s={tag_name:r};Ai.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?s.$el_text=As(1024,Ji(e)):s.$el_text=As(1024,Li(e)));var o=$i(e);o.length>0&&(s.classes=o.filter((function(e){return""!==e}))),f(e.attributes,(function(i){var r;if((!Bi(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==n||!n.includes(i.name))&&!t&&Vi(i.value)&&(r=i.name,!U(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Fi(o).join(" ")),s["attr__"+i.name]=As(1024,o)}}));for(var a=1,l=1,u=e;u=Ds(u);)a++,u.tagName===e.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function qs(t,i){for(var n,r,{e:s,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=i,c=[t],d=t;d.parentNode&&!Ci(d,"body");)Ri(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var h,_=[],p={},v=!1,g=!1;if(f(c,(e=>{var t=qi(e);"a"===e.tagName.toLowerCase()&&(v=e.getAttribute("href"),v=t&&v&&Vi(v)&&v),b($i(e),"ph-no-capture")&&(g=!0),_.push(Ns(e,o,a,l));var i=function(e){if(!qi(e))return{};var t={};return f(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),n=e.value;i&&n&&Vi(n)&&(t[i]=n)}})),t}(e);m(p,i)})),g)return{props:{},explicitNoCapture:g};if(a||("a"===t.tagName.toLowerCase()||"button"===t.tagName.toLowerCase()?_[0].$el_text=Ji(t):_[0].$el_text=Li(t)),v){var y,w;_[0].attr__href=v;var S=null===(y=gt(v))||void 0===y?void 0:y.host,E=null==e||null===(w=e.location)||void 0===w?void 0:w.host;S&&E&&S!==E&&(h=v)}return{props:m({$event_type:s.type,$ce_version:1},u?{}:{$elements:_},{$elements_chain:Xi(_)},null!==(n=_[0])&&void 0!==n&&n.$el_text?{$el_text:null===(r=_[0])||void 0===r?void 0:r.$el_text}:{},h&&"click"===s.type?{$external_click_url:h}:{},p)}}class Bs{constructor(e){ne(this,"_initialized",!1),ne(this,"_isDisabledServerSide",null),ne(this,"rageclicks",new Cs),ne(this,"_elementsChainAsString",!1),this.instance=e,this._elementSelectors=null}get config(){var e,t,i=q(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()){if(e&&o){var t=t=>{t=t||(null==e?void 0:e.event);try{this._captureEvent(t)}catch(e){Ms.error("Failed to capture event",e)}},i=t=>{t=t||(null==e?void 0:e.event),this._captureEvent(t,F)};C(o,"submit",t,!1,!0),C(o,"change",t,!1,!0),C(o,"click",t,!1,!0),this.config.capture_copied_text&&(C(o,"copy",i,!1,!0),C(o,"cut",i,!1,!0))}}else Ms.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[le]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null===(t=this._elementSelectors)||void 0===t||t.forEach((t=>{var n=null==o?void 0:o.querySelectorAll(t);null==n||n.forEach((n=>{e===n&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null===(e=this.instance.persistence)||void 0===e?void 0:e.props[le],n=this._isDisabledServerSide;if(j(n)&&!V(i)&&!this.instance.config.advanced_disable_decide)return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$autocapture";if(this.isEnabled){var n,r=Mi(t);if(Pi(r)&&(r=r.parentNode||null),"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent)this.instance.config.rageclick&&null!==(n=this.rageclicks)&&void 0!==n&&n.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&this._captureEvent(t,"$rageclick");var s=i===F;if(r&&Ni(r,t,this.config,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=qs(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(a)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(o.$element_selectors=l),i===F){var u,c=Oi(null==e||null===(u=e.getSelection())||void 0===u?void 0:u.toString()),d=t.type||"clipboard";if(!c)return!1;o.$selected_content=c,o.$copy_type=d}return this.instance.capture(i,o),!0}}}isBrowserSupported(){return N(null==o?void 0:o.querySelectorAll)}}var Hs=Q("[TracingHeaders]");class Us{constructor(e){ne(this,"_restoreXHRPatch",void 0),ne(this,"_restoreFetchPatch",void 0),ne(this,"_startCapturing",(()=>{var e,t,i,n;H(this._restoreXHRPatch)&&(null===(e=h.__PosthogExtensions__)||void 0===e||null===(t=e.tracingHeadersPatchFns)||void 0===t||t._patchXHR(this.instance.sessionManager));H(this._restoreFetchPatch)&&(null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.tracingHeadersPatchFns)||void 0===n||n._patchFetch(this.instance.sessionManager))})),this.instance=e}_loadScript(e){var t,i,n;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.tracingHeadersPatchFns&&e(),null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"tracing-headers",(t=>{if(t)return Hs.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var zs;!function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"}(zs||(zs={}));class js{constructor(e){this.instance=e}get config(){return this.instance.config}get consent(){return this.getDnt()?zs.DENIED:this.storedConsent}isOptedOut(){return this.consent===zs.DENIED||this.consent===zs.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(){var{token:e,opt_out_capturing_cookie_prefix:t}=this.instance.config;return(t||"__ph_opt_in_out_")+e}get storedConsent(){var e=this.storage.get(this.storageKey);return"1"===e?zs.GRANTED:"0"===e?zs.DENIED:zs.PENDING}get storage(){if(!this._storage){var e=this.config.opt_out_capturing_persistence_type;this._storage="localStorage"===e?lt:ot;var t="localStorage"===e?ot:lt;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&&!!P([null==s?void 0:s.doNotTrack,null==s?void 0:s.msDoNotTrack,h.doNotTrack],(e=>b([!0,1,"1","yes"],e)))}}var Ws=Q("[ExceptionAutocapture]");class Gs{constructor(t){var i;ne(this,"originalOnUnhandledRejectionHandler",void 0),ne(this,"startCapturing",(()=>{var t,i,n,r;if(e&&this.isEnabled&&!this.hasHandlers&&!this.isCapturing){var s=null===(t=h.__PosthogExtensions__)||void 0===t||null===(i=t.errorWrappingFunctions)||void 0===i?void 0:i.wrapOnError,o=null===(n=h.__PosthogExtensions__)||void 0===n||null===(r=n.errorWrappingFunctions)||void 0===r?void 0:r.wrapUnhandledRejection;if(s&&o)try{this.unwrapOnError=s(this.captureException.bind(this)),this.unwrapUnhandledRejection=o(this.captureException.bind(this))}catch(e){Ws.error("failed to start",e),this.stopCapturing()}else Ws.error("failed to load error wrapping functions - cannot start")}})),this.instance=t,this.remoteEnabled=!(null===(i=this.instance.persistence)||void 0===i||!i.props[ce]),this.startIfEnabled()}get isEnabled(){var e;return null!==(e=this.remoteEnabled)&&void 0!==e&&e}get isCapturing(){var t;return!(null==e||null===(t=e.onerror)||void 0===t||!t.__POSTHOG_INSTRUMENTED__)}get hasHandlers(){return this.originalOnUnhandledRejectionHandler||this.unwrapOnError}startIfEnabled(){this.isEnabled&&!this.isCapturing&&(Ws.info("enabled, starting..."),this.loadScript(this.startCapturing))}loadScript(e){var t,i;this.hasHandlers&&e(),null===(t=h.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"exception-autocapture",(t=>{if(t)return Ws.error("failed to load script",t);e()}))}stopCapturing(){var e,t;null===(e=this.unwrapOnError)||void 0===e||e.call(this),null===(t=this.unwrapUnhandledRejection)||void 0===t||t.call(this)}onRemoteConfig(e){var t=e.autocaptureExceptions;this.remoteEnabled=!!t||!1,this.instance.persistence&&this.instance.persistence.register({[ce]:this.remoteEnabled}),this.startIfEnabled()}captureException(e){var t=this.instance.requestRouter.endpointFor("ui");e.$exception_personURL="".concat(t,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(e)}}var Vs=Q("[Web Vitals]"),Js=9e5;class Ys{constructor(e){var t;ne(this,"_enabledServerSide",!1),ne(this,"_initialized",!1),ne(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),ne(this,"_flushToCapture",(()=>{clearTimeout(this._delayedFlushTimer),0!==this.buffer.metrics.length&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce(((e,t)=>ie(ie({},e),{},{["$web_vitals_".concat(t.name,"_event")]:ie({},t),["$web_vitals_".concat(t.name,"_value")]:t.value})),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})})),ne(this,"_addToBuffer",(e=>{var t,i=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);if(H(i))Vs.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this._currentURL();if(!H(n))if(W(null==e?void 0:e.name)||W(null==e?void 0:e.value))Vs.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)Vs.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this.buffer.url!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),H(this.buffer.url)&&(this.buffer.url=n),this.buffer.firstMetricTimestamp=H(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(ie(ie({},e),{},{$current_url:n,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}})),ne(this,"_startCapturing",(()=>{var e,t,i,n,r=h.__PosthogExtensions__;H(r)||H(r.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:n}=r.postHogWebVitalsCallbacks),e&&t&&i&&n?(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&&n(this._addToBuffer.bind(this)),this._initialized=!0):Vs.error("web vitals callbacks not loaded - not starting")})),this.instance=e,this._enabledServerSide=!(null===(t=this.instance.persistence)||void 0===t||!t.props[de]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=q(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 H(i)?(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[_e])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(q(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=q(this.instance.config.capture_performance)&&G(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Js;return 0<e&&e<=6e4?Js:e}get isEnabled(){var e=q(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return V(e)?e:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Vs.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(e){var t=q(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=q(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[de]:t}),this.instance.persistence.register({[_e]:i})),this._enabledServerSide=t,this.startIfEnabled()}loadScript(e){var t,i,n;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.postHogWebVitalsCallbacks&&e(),null===(i=h.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"web-vitals",(t=>{t?Vs.error("failed to load script",t):e()}))}_currentURL(){var t=e?e.location.href:void 0;return t||Vs.error("Could not determine current URL"),t}}var Xs={icontains:(t,i)=>!!e&&i.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>!!e&&-1===i.href.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>!!e&&ft(i.href,t),not_regex:(t,i)=>!!e&&!ft(i.href,t),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class Ks{constructor(e){var t=this;ne(this,"getWebExperimentsAndEvaluateDisplayLogic",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t.getWebExperiments((e=>{Ks.logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)Ks.logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null===(i=t._flagToExperiments)||void 0===i||i.set(e.feature_flag_key,e);var n=t.instance.getFeatureFlag(e.feature_flag_key);U(n)&&e.variants[n]&&t.applyTransforms(e.name,n,e.variants[n].transforms)}else if(e.variants)for(var r in e.variants){var s=e.variants[r];Ks.matchesTestVariant(s)&&t.applyTransforms(e.name,r,s.transforms)}}))}),e)})),this.instance=e,this.instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())Ks.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(W(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ks.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,n=this.instance.getFeatureFlag(e),r=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);n&&null!=r&&r.variants[n]&&this.applyTransforms(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var e=Ks.getWindowLocation();if(null!=e&&e.search){var t=bt(null==e?void 0:e.search,"__experiment_id"),i=bt(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Ks.logInfo("previewing web experiments ".concat(t," && ").concat(i)),this.getWebExperiments((e=>{this.showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this.instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.instance.config.disable_web_experiments&&!i)return e([]);var n=this.instance.get_property("$web_experiments");if(n&&!t)return e(n);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/web_experiments/?token=".concat(this.instance.config.token)),method:"GET",transport:"XHR",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}showPreviewWebExperiment(e,t,i){var n=i.filter((t=>t.id===e));n&&n.length>0&&(Ks.logInfo("Previewing web experiment [".concat(n[0].name,"] with variant [").concat(t,"]")),this.applyTransforms(n[0].name,t,n[0].variants[t].transforms,!0))}static matchesTestVariant(e){return!W(e.conditions)&&(Ks.matchUrlConditions(e)&&Ks.matchUTMConditions(e))}static matchUrlConditions(e){var t;if(W(e.conditions)||W(null===(t=e.conditions)||void 0===t?void 0:t.url))return!0;var i,n,r,s=Ks.getWindowLocation();return!!s&&(null===(i=e.conditions)||void 0===i||!i.url||Xs[null!==(n=null===(r=e.conditions)||void 0===r?void 0:r.urlMatchType)&&void 0!==n?n:"icontains"](e.conditions.url,s))}static getWindowLocation(){return null==e?void 0:e.location}static matchUTMConditions(e){var t;if(W(e.conditions)||W(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;var i=mi.campaignParams();if(i.utm_source){var n,r,s,o,a,l,u,c,d,h,_,p,v,g,f,m,b=null===(n=e.conditions)||void 0===n||null===(r=n.utm)||void 0===r||!r.utm_campaign||(null===(s=e.conditions)||void 0===s||null===(o=s.utm)||void 0===o?void 0:o.utm_campaign)==i.utm_campaign,y=null===(a=e.conditions)||void 0===a||null===(l=a.utm)||void 0===l||!l.utm_source||(null===(u=e.conditions)||void 0===u||null===(c=u.utm)||void 0===c?void 0:c.utm_source)==i.utm_source,w=null===(d=e.conditions)||void 0===d||null===(h=d.utm)||void 0===h||!h.utm_medium||(null===(_=e.conditions)||void 0===_||null===(p=_.utm)||void 0===p?void 0:p.utm_medium)==i.utm_medium,S=null===(v=e.conditions)||void 0===v||null===(g=v.utm)||void 0===g||!g.utm_term||(null===(f=e.conditions)||void 0===f||null===(m=f.utm)||void 0===m?void 0:m.utm_term)==i.utm_term;return b&&w&&S&&y}return!1}static logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];K.info("[WebExperiments] ".concat(e),i)}applyTransforms(e,t,i,n){var r;this._is_bot()?Ks.logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var r;Ks.logInfo("applying transform of variant ".concat(t," for experiment ").concat(e," "),i);var s,o=0,a=null===(r=document)||void 0===r?void 0:r.querySelectorAll(i.selector);if(null==a||a.forEach((e=>{var 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:n,$web_experiment_document_url:null===(s=Ks.getWindowLocation())||void 0===s?void 0:s.href,$web_experiment_elements_modified:o})}})):(Ks.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:n,$web_experiment_variant:t,$web_experiment_document_url:null===(r=Ks.getWindowLocation())||void 0===r?void 0:r.href,$web_experiment_elements_modified:0}))}_is_bot(){return s&&this.instance?Is(s,this.instance.config.custom_blocked_useragents):void 0}}class Qs{constructor(e){this.instance=e}sendExceptionEvent(e){this.instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}}var Zs=["$set_once","$set"],eo=Q("[SiteApps]");class to{constructor(e){this.instance=e,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this.bufferedInvocations.push(i),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}init(){if(this.isEnabled){var e=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{e(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(e){var t,i,n,r,s,o,a;if(!e)throw new Error("Event payload is required");var l={},u=this.instance.get_property("$groups")||[],c=this.instance.get_property("$stored_group_properties")||{};for(var[d,h]of Object.entries(c))l[d]={id:u[d],type:d,properties:h};var{$set_once:_,$set:p}=e;return{event:ie(ie({},re(e,Zs)),{},{properties:ie(ie(ie({},e.properties),p?{$set:ie(ie({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),p)}:{}),_?{$set_once:ie(ie({},null!==(n=null===(r=e.properties)||void 0===r?void 0:r.$set_once)&&void 0!==n?n:{}),_)}:{}),elements_chain:null!==(s=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==s?s:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(e){var t={id:e.id,loaded:!1,errored:!1};this.apps[e.id]=t;var i=i=>{var n;for(var r of(this.apps[e.id].errored=!i,this.apps[e.id].loaded=!0,eo.info("Site app with id ".concat(e.id," ").concat(i?"loaded":"errored")),i&&this.bufferedInvocations.length&&(eo.info("Processing ".concat(this.bufferedInvocations.length," events for site app with id ").concat(e.id)),this.bufferedInvocations.forEach((e=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)}))),Object.values(this.apps)))if(!r.loaded)return;null===(n=this.stopBuffering)||void 0===n||n.call(this)};try{var{processEvent:n}=e.init({posthog:this.instance,callback:e=>{i(e)}});n&&(t.processEvent=n)}catch(t){eo.error("Error while initializing PostHog app with config id ".concat(e.id),t),i(!1)}}onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{var n;null===(n=i.processEvent)||void 0===n||n.call(i,t)}catch(t){eo.error("Error while processing event ".concat(e.event," for site app ").concat(i.id),t)}}}onRemoteConfig(e){var t,i,n=this;if(D(h._POSTHOG_JS_APPS)){if(!this.isEnabled)return void eo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');for(var r of h._POSTHOG_JS_APPS)this.setupSiteApp(r);var s;h._POSTHOG_JS_APPS.length?this.instance.on("eventCaptured",(e=>this.onCapturedEvent(e))):null===(s=this.stopBuffering)||void 0===s||s.call(this)}else if(null===(t=this.stopBuffering)||void 0===t||t.call(this),null!==(i=e.siteApps)&&void 0!==i&&i.length)if(this.isEnabled){var o=function(e,t){var i,r;h["__$$ph_site_app_".concat(e)]=n.instance,null===(i=h.__PosthogExtensions__)||void 0===i||null===(r=i.loadSiteApp)||void 0===r||r.call(i,n.instance,t,(t=>{if(t)return eo.error("Error while initializing PostHog app with config id ".concat(e),t)}))};for(var{id:a,url:l}of e.siteApps)o(a,l)}else eo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var io={},no=()=>{},ro="posthog",so=!dr&&-1===(null==d?void 0:d.indexOf("MSIE"))&&-1===(null==d?void 0:d.indexOf("Mozilla")),oo=()=>{var t,i,n;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:(i=null==o?void 0:o.location,n=null==i?void 0:i.hostname,!!U(n)&&"herokuapp.com"!==n.split(".").slice(-2).join(".")),persistence:"localStorage+cookie",persistence_name:"",loaded:no,store_google:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:a&&U(null==a?void 0:a.search)&&-1!==a.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==e||null===(t=e.location)||void 0===t?void 0:t.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=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;K.error(t)},get_device_id:e=>e,_onCapture:no,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",__add_tracing_headers:!1,before_send:void 0}},ao=e=>{var t={};H(e.process_person)||(t.person_profiles=e.process_person),H(e.xhr_headers)||(t.request_headers=e.xhr_headers),H(e.cookie_name)||(t.persistence_name=e.cookie_name),H(e.disable_cookie)||(t.disable_persistence=e.disable_cookie);var i=m({},t,e);return D(e.property_blacklist)&&(H(e.property_denylist)?i.property_denylist=e.property_blacklist:D(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:K.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class lo{constructor(){ne(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){K.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class uo{get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){ne(this,"webPerformance",new lo),ne(this,"version",_.LIB_VERSION),ne(this,"_internalEventEmitter",new Or),this.config=oo(),this.SentryIntegration=Ir,this.sentryIntegration=e=>function(e,t){var i=xr(e,t);return{name:kr,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this.featureFlags=new Ve(this),this.toolbar=new ur(this),this.scrollManager=new Ls(this),this.pageViewManager=new $r(this),this.surveys=new bs(this),this.experiments=new Ks(this),this.exceptions=new Qs(this),this.rateLimiter=new ws(this),this.requestRouter=new Er(this),this.consent=new js(this),this.people={set:(e,t,i)=>{var n=U(e)?{[e]:t}:e;this.setPersonProperties(n),null==i||i({})},set_once:(e,t,i)=>{var n=U(e)?{[e]:t}:e;this.setPersonProperties(void 0,n),null==i||i({})}},this.on("eventCaptured",(e=>K.info('send "'.concat(null==e?void 0:e.event,'"'),e)))}init(e,t,i){if(i&&i!==ro){var n,r=null!==(n=io[i])&&void 0!==n?n:new uo;return r._init(e,t,i),io[i]=r,io[ro][i]=r,r}return this._init(e,t,i)}_init(t){var i,n,r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(H(t)||z(t))return K.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 K.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],s.person_profiles&&(this._initialPersonProfilesConfig=s.person_profiles),this.set_config(m({},oo(),ao(s),{name:o,token:t})),this.config.on_xhr_error&&K.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:R.GZipJS,this.persistence=new yi(this.config),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new yi(ie(ie({},this.config),{},{persistence:"sessionStorage"}));var a=ie({},this.persistence.props),l=ie({},this.sessionPersistence.props);if(this._requestQueue=new cr((e=>this._send_retriable_request(e))),this._retryQueue=new mr(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new wr(this),this.sessionPropsManager=new Es(this.sessionManager,this.persistence)),new Us(this).startIfEnabledOrStop(),this.siteApps=new to(this),null===(i=this.siteApps)||void 0===i||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new nr(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Bs(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new Os(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Ys(this),this.exceptionObserver=new Gs(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Ts(this,Fs),this.deadClicksAutocapture.startIfEnabled(),_.DEBUG=_.DEBUG||this.config.debug,_.DEBUG&&K.info("Starting in debug mode",{this:this,config:s,thisC:ie({},this.config),p:a,s:l}),this._sync_opt_out_with_persistence(),void 0!==(null===(n=s.bootstrap)||void 0===n?void 0:n.distinctID)){var u,c,d=this.config.get_device_id(et()),h=null!==(u=s.bootstrap)&&void 0!==u&&u.isIdentifiedID?d:s.bootstrap.distinctID;this.persistence.set_property($e,null!==(c=s.bootstrap)&&void 0!==c&&c.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:s.bootstrap.distinctID,$device_id:h})}if(this._hasBootstrappedFeatureFlags()){var p,v,g=Object.keys((null===(p=s.bootstrap)||void 0===p?void 0:p.featureFlags)||{}).filter((e=>{var t,i;return!(null===(t=s.bootstrap)||void 0===t||null===(i=t.featureFlags)||void 0===i||!i[e])})).reduce(((e,t)=>{var i,n;return e[t]=(null===(i=s.bootstrap)||void 0===i||null===(n=i.featureFlags)||void 0===n?void 0:n[t])||!1,e}),{}),f=Object.keys((null===(v=s.bootstrap)||void 0===v?void 0:v.featureFlagPayloads)||{}).filter((e=>g[e])).reduce(((e,t)=>{var i,n,r,o;null!==(i=s.bootstrap)&&void 0!==i&&null!==(n=i.featureFlagPayloads)&&void 0!==n&&n[t]&&(e[t]=null===(r=s.bootstrap)||void 0===r||null===(o=r.featureFlagPayloads)||void 0===o?void 0:o[t]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:f})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Be,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(et());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property($e,"anonymous")}return null==e||null===(r=e.addEventListener)||void 0===r||r.call(e,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),this.toolbar.maybeLoadToolbar(),s.segment?Tr(this,(()=>this._loaded())):this._loaded(),N(this.config._onCapture)&&this.config._onCapture!==no&&(K.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this}_onRemoteConfig(e){var t,i,n,r,s,a,l,u,c;if(!o||!o.body)return K.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=b(e.supportedCompression,R.GZipJS)?R.GZipJS:b(e.supportedCompression,R.Base64)?R.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.siteApps)||void 0===i||i.onRemoteConfig(e),null===(n=this.sessionRecording)||void 0===n||n.onRemoteConfig(e),null===(r=this.autocapture)||void 0===r||r.onRemoteConfig(e),null===(s=this.heatmaps)||void 0===s||s.onRemoteConfig(e),null===(a=this.surveys)||void 0===a||a.onRemoteConfig(e),null===(l=this.webVitalsAutocapture)||void 0===l||l.onRemoteConfig(e),null===(u=this.exceptionObserver)||void 0===u||u.onRemoteConfig(e),null===(c=this.deadClicksAutocapture)||void 0===c||c.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){K.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{this.consent.isOptedIn()&&this._captureInitialPageview()}),1),new sr(this).load(),this.featureFlags.decide()}_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()||g(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(e){this.__loaded&&(so?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=_r(e.url,{ip:this.config.ip?1:0}),e.headers=ie({},this.config.request_headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,i,n,r=ie({},e);r.timeout=r.timeout||6e4,r.url=_r(r.url,{_:(new Date).getTime().toString(),ver:_.LIB_VERSION,compression:r.compression});var s=null!==(t=r.transport)&&void 0!==t?t:"XHR",o=null!==(i=null===(n=P(gr,(e=>e.transport===s)))||void 0===n?void 0:n.method)&&void 0!==i?i:gr[0].method;if(!o)throw new Error("No available transport method");o(r)})(ie(ie({},e),{},{callback:t=>{var i,n,r;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null===(n=(r=this.config).on_request_error)||void 0===n||n.call(r,t));null===(i=e.callback)||void 0===i||i.call(e,t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],n=[],r=[];g(e,(e=>{e&&(t=e[0],D(t)?r.push(e):N(e)?e.call(this):D(e)&&"alias"===t?i.push(e):D(e)&&-1!==t.indexOf("capture")&&N(this[t])?r.push(e):n.push(e))}));var s=function(e,t){g(e,(function(e){if(D(e[0])){var i=t;f(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};s(i,this),s(n,this),s(r,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 n;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!H(e)&&U(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var r=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==r||!r.isRateLimited){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();var s=new Date,o=(null==i?void 0:i.timestamp)||s,a={uuid:et(),event:e,properties:this._calculate_event_properties(e,t||{},o)};r&&(a.properties.$lib_rate_limit_remaining_tokens=r.remainingTokens),(null==i?void 0:i.$set)&&(a.$set=null==i?void 0:i.$set);var l=this._calculate_set_once_properties(null==i?void 0:i.$set_once);l&&(a.$set_once=l),(a=x(a,null!=i&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=o,H(null==i?void 0:i.timestamp)||(a.properties.$event_time_override_provided=!0,a.properties.$event_time_override_system_time=s);var u=ie(ie({},a.properties.$set),a.$set);if(B(u)||this.setPersonPropertiesForFlags(u),!W(this.config.before_send)){var c=this._runBeforeSend(a);if(!c)return;a=c}this._internalEventEmitter.emit("eventCaptured",a);var d={method:"POST",url:null!==(n=null==i?void 0:i._url)&&void 0!==n?n: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(d):this._requestQueue.enqueue(d),a}K.critical("This capture call is ignored due to client rate limiting.")}}else K.error("No event name provided to posthog.capture")}else K.uninitializedWarning("posthog.capture")}_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;var n=this.persistence.remove_event_timer(e),r=ie({},t);if(r.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(r.$cklsh_mode=!0),"$snapshot"===e){var s=ie(ie({},this.persistence.properties()),this.sessionPersistence.properties());return r.distinct_id=s.distinct_id,(!U(r.distinct_id)&&!G(r.distinct_id)||z(r.distinct_id))&&K.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),r}var a=mi.properties();if(this.sessionManager){var{sessionId:l,windowId:u}=this.sessionManager.checkAndGetSessionAndWindowId();r.$session_id=l,r.$window_id=u}if(this.sessionRecording&&(r.$recording_status=this.sessionRecording.status),this.requestRouter.region===br.CUSTOM&&(r.$lib_custom_api_host=this.config.api_host),this.sessionPropsManager&&this.config.__preview_send_client_session_params&&("$pageview"===e||"$pageleave"===e||"$autocapture"===e)){var c=this.sessionPropsManager.getSessionProps();r=m(r,c)}if(!this.config.disable_scroll_properties){var h={};"$pageview"===e?h=this.pageViewManager.doPageView(i):"$pageleave"===e&&(h=this.pageViewManager.doPageLeave(i)),r=m(r,h)}if("$pageview"===e&&o&&(r.title=o.title),!H(n)){var _=i.getTime()-n;r.$duration=parseFloat((_/1e3).toFixed(3))}d&&this.config.opt_out_useragent_filter&&(r.$browser_type=this._is_bot()?"bot":"browser"),(r=m({},a,this.persistence.properties(),this.sessionPersistence.properties(),r)).$is_identified=this._isIdentified(),D(this.config.property_denylist)?f(this.config.property_denylist,(function(e){delete r[e]})):K.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(r=p(r,e));var v=this._hasPersonProcessing();return r.$process_person_profile=v,v&&this._requirePersonProcessing("_calculate_event_properties"),r}_calculate_set_once_properties(e){if(!this.persistence||!this._hasPersonProcessing())return e;var t=m({},this.persistence.get_initial_props(),e||{}),i=this.config.sanitize_properties;return i&&(t=i(t,"$set_once")),B(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 n;null===(n=this.persistence)||void 0===n||n.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){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t)}getEarlyAccessFeatures(e){var 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){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e){var 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 K.uninitializedWarning("posthog.identify");if(G(e)&&(e=e.toString(),K.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e){if(["distinct_id","distinctid"].includes(e.toLowerCase()))K.critical('The string "'.concat(e,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var n=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var r=n;this.register_once({$had_persisted_distinct_id:!0,$device_id:r},"")}e!==n&&e!==this.get_property(oe)&&(this.unregister(oe),this.register({distinct_id:e}));var s="anonymous"===(this.persistence.get_property($e)||"anonymous");e!==n&&s?(this.persistence.set_property($e,"identified"),this.setPersonPropertiesForFlags(t||{},!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n},{$set:t||{},$set_once:i||{}}),this.featureFlags.setAnonymousDistinctId(n)):(t||i)&&this.setPersonProperties(t,i),e!==n&&(this.reloadFeatureFlags(),this.unregister(Te))}}else K.error("Unique user id has not been set in posthog.identify")}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){if(this._requirePersonProcessing("posthog.group")){var n=this.getGroups();n[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ie(ie({},n),{},{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),n[e]===t||i||this.reloadFeatureFlags()}}else K.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e){var 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,n,r,s;if(K.info("reset"),!this.__loaded)return K.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),null===(t=this.persistence)||void 0===t||t.clear(),null===(i=this.sessionPersistence)||void 0===i||i.clear(),null===(n=this.surveys)||void 0===n||n.reset(),null===(r=this.persistence)||void 0===r||r.set_property($e,"anonymous"),null===(s=this.sessionManager)||void 0===s||s.resetSessionId(),this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Be,$device_id:null},"");else{var a=this.config.get_device_id(et());this.register_once({distinct_id:a,$device_id:e?a:o},"")}}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"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(t));if(null!=e&&e.withTimestamp&&i){var r,s=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return n;var o=Math.max(Math.floor(((new Date).getTime()-i)/1e3)-s,0);n+="?t=".concat(o)}return n}alias(e,t){return e===this.get_property(se)?(K.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(H(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(oe,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(K.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t,i,n,r,s=ie({},this.config);q(e)&&(m(this.config,ao(e)),null===(t=this.persistence)||void 0===t||t.update_config(this.config,s),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new yi(ie(ie({},this.config),{},{persistence:"sessionStorage"})),lt.is_supported()&&"true"===lt.get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(_.DEBUG=!0,K.info("set_config",{config:e,oldConfig:s,newConfig:ie({},this.config)})),null===(i=this.sessionRecording)||void 0===i||i.startIfEnabledOrStop(),null===(n=this.autocapture)||void 0===n||n.startIfEnabled(),null===(r=this.heatmaps)||void 0===r||r.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var n,r,s,o,a;if(null===(n=this.sessionManager)||void 0===n||n.checkAndGetSessionAndWindowId(),i.sampling)null===(r=this.sessionRecording)||void 0===r||r.overrideSampling();if(i.linked_flag)null===(s=this.sessionRecording)||void 0===s||s.overrideLinkedFlag();if(i.url_trigger)null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url");if(i.event_trigger)null===(a=this.sessionRecording)||void 0===a||a.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null===(e=this.sessionRecording)||void 0===e||!e.started)}captureException(e,t){var i,n=new Error("PostHog syntheticException"),r=N(null===(i=h.__PosthogExtensions__)||void 0===i?void 0:i.parseErrorAsProperties)?h.__PosthogExtensions__.parseErrorAsProperties([e.message,void 0,void 0,void 0,e],{syntheticException:n}):ie({$exception_level:"error",$exception_list:[{type:e.name,value:e.message,mechanism:{handled:!0,synthetic:!1}}]},t);this.exceptions.sendExceptionEvent(r)}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,t=null!==(e=this.config.name)&&void 0!==e?e:ro;return t!==ro&&(t=ro+"."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property($e))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property($e))}_hasPersonProcessing(){var e,t,i,n;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&B(this.getGroups())&&(null===(e=this.persistence)||void 0===e||null===(t=e.props)||void 0===t||!t[oe])&&(null===(i=this.persistence)||void 0===i||null===(n=i.props)||void 0===n||!n[Ne]))}_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?(K.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Ne,!0),!0)}_sync_opt_out_with_persistence(){var e,t,i,n,r=this.consent.isOptedOut(),s=this.config.opt_out_persistence_by_default,o=this.config.disable_persistence||r&&!!s;(null===(e=this.persistence)||void 0===e?void 0:e.disabled)!==o&&(null===(i=this.persistence)||void 0===i||i.set_disabled(o));(null===(t=this.sessionPersistence)||void 0===t?void 0:t.disabled)!==o&&(null===(n=this.sessionPersistence)||void 0===n||n.set_disabled(o))}opt_in_capturing(e){var t;(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),H(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?Is(s,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){o&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:o.title},{send_instantly:!0}))}debug(t){!1===t?(null==e||e.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==e||e.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}))}_runBeforeSend(e){if(W(this.config.before_send))return e;var t=D(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var n of t){if(i=n(i),W(i)){var r="Event '".concat(e.event,"' was rejected in beforeSend function");return Y(e.event)?K.warn("".concat(r,". This can cause unexpected behavior.")):K.info(r),null}i.properties&&!B(i.properties)||K.warn("Event '".concat(e.event,"' has no properties after beforeSend function, this is likely an error."))}return i}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=S(e.prototype[t[i]])}(uo,["identify"]);var co,ho=(co=io[ro]=new uo,function(){function t(){t.done||(t.done=!0,so=!1,f(io,(function(e){e._dom_loaded()})))}null!=o&&o.addEventListener&&("complete"===o.readyState?t():o.addEventListener("DOMContentLoaded",t,!1)),e&&C(e,"load",t,!0)}(),co);export{F as COPY_AUTOCAPTURE_EVENT,R as Compression,uo as PostHog,Rr as SurveyQuestionBranchingType,Pr as SurveyQuestionType,Cr as SurveyType,ho as default,T as knownUnsafeEditableEvent,ho as posthog,$ as severityLevels};
2
2
  //# sourceMappingURL=module.js.map